Remove outermost loop parameter.
[official-gcc/graphite-test-results.git] / gcc / fortran / intrinsic.texi
blobbc0ea8dce3ad9447580848561f4b15be5872b290
1 @ignore
2 Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
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 ``Funding Free Software'', the Front-Cover
11 Texts being (a) (see below), and with the Back-Cover Texts being (b)
12 (see below).  A copy of the license is included in the gfdl(7) man page.
15 Some basic guidelines for editing this document:
17   (1) The intrinsic procedures are to be listed in alphabetical order.
18   (2) The generic name is to be used.
19   (3) The specific names are included in the function index and in a
20       table at the end of the node (See ABS entry).
21   (4) Try to maintain the same style for each entry.
24 @end ignore
26 @tex
27 \gdef\acos{\mathop{\rm acos}\nolimits}
28 \gdef\asin{\mathop{\rm asin}\nolimits}
29 \gdef\atan{\mathop{\rm atan}\nolimits}
30 \gdef\acosh{\mathop{\rm acosh}\nolimits}
31 \gdef\asinh{\mathop{\rm asinh}\nolimits}
32 \gdef\atanh{\mathop{\rm atanh}\nolimits}
33 @end tex
36 @node Intrinsic Procedures
37 @chapter Intrinsic Procedures
38 @cindex intrinsic procedures
40 @menu
41 * Introduction:         Introduction to Intrinsics
42 * @code{ABORT}:         ABORT,     Abort the program     
43 * @code{ABS}:           ABS,       Absolute value     
44 * @code{ACCESS}:        ACCESS,    Checks file access modes
45 * @code{ACHAR}:         ACHAR,     Character in @acronym{ASCII} collating sequence
46 * @code{ACOS}:          ACOS,      Arccosine function
47 * @code{ACOSH}:         ACOSH,     Hyperbolic arccosine function
48 * @code{ADJUSTL}:       ADJUSTL,   Left adjust a string
49 * @code{ADJUSTR}:       ADJUSTR,   Right adjust a string
50 * @code{AIMAG}:         AIMAG,     Imaginary part of complex number
51 * @code{AINT}:          AINT,      Truncate to a whole number
52 * @code{ALARM}:         ALARM,     Set an alarm clock
53 * @code{ALL}:           ALL,       Determine if all values are true
54 * @code{ALLOCATED}:     ALLOCATED, Status of allocatable entity
55 * @code{AND}:           AND,       Bitwise logical AND
56 * @code{ANINT}:         ANINT,     Nearest whole number
57 * @code{ANY}:           ANY,       Determine if any values are true
58 * @code{ASIN}:          ASIN,      Arcsine function
59 * @code{ASINH}:         ASINH,     Hyperbolic arcsine function
60 * @code{ASSOCIATED}:    ASSOCIATED, Status of a pointer or pointer/target pair
61 * @code{ATAN}:          ATAN,      Arctangent function
62 * @code{ATAN2}:         ATAN2,     Arctangent function
63 * @code{ATANH}:         ATANH,     Hyperbolic arctangent function
64 * @code{BESSEL_J0}:     BESSEL_J0, Bessel function of the first kind of order 0
65 * @code{BESSEL_J1}:     BESSEL_J1, Bessel function of the first kind of order 1
66 * @code{BESSEL_JN}:     BESSEL_JN, Bessel function of the first kind
67 * @code{BESSEL_Y0}:     BESSEL_Y0, Bessel function of the second kind of order 0
68 * @code{BESSEL_Y1}:     BESSEL_Y1, Bessel function of the second kind of order 1
69 * @code{BESSEL_YN}:     BESSEL_YN, Bessel function of the second kind
70 * @code{BIT_SIZE}:      BIT_SIZE,  Bit size inquiry function
71 * @code{BTEST}:         BTEST,     Bit test function
72 * @code{C_ASSOCIATED}:  C_ASSOCIATED, Status of a C pointer
73 * @code{C_F_POINTER}:   C_F_POINTER, Convert C into Fortran pointer
74 * @code{C_F_PROCPOINTER}: C_F_PROCPOINTER, Convert C into Fortran procedure pointer
75 * @code{C_FUNLOC}:      C_FUNLOC,  Obtain the C address of a procedure
76 * @code{C_LOC}:         C_LOC,     Obtain the C address of an object
77 * @code{C_SIZEOF}:      C_SIZEOF,  Size in bytes of an expression
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{DIGITS}:        DIGITS,    Significant digits function
96 * @code{DIM}:           DIM,       Positive difference
97 * @code{DOT_PRODUCT}:   DOT_PRODUCT, Dot product function
98 * @code{DPROD}:         DPROD,     Double product function
99 * @code{DREAL}:         DREAL,     Double real part function
100 * @code{DTIME}:         DTIME,     Execution time subroutine (or function)
101 * @code{EOSHIFT}:       EOSHIFT,   End-off shift elements of an array
102 * @code{EPSILON}:       EPSILON,   Epsilon function
103 * @code{ERF}:           ERF,       Error function
104 * @code{ERFC}:          ERFC,      Complementary error function
105 * @code{ERFC_SCALED}:   ERFC_SCALED, Exponentially-scaled 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{FLOOR}:         FLOOR,     Integer floor function
114 * @code{FLUSH}:         FLUSH,     Flush I/O unit(s)
115 * @code{FNUM}:          FNUM,      File number function
116 * @code{FPUT}:          FPUT,      Write a single character in stream mode to stdout
117 * @code{FPUTC}:         FPUTC,     Write a single character in stream mode
118 * @code{FRACTION}:      FRACTION,  Fractional part of the model representation
119 * @code{FREE}:          FREE,      Memory de-allocation subroutine
120 * @code{FSEEK}:         FSEEK,     Low level file positioning subroutine
121 * @code{FSTAT}:         FSTAT,     Get file status
122 * @code{FTELL}:         FTELL,     Current stream position
123 * @code{GAMMA}:         GAMMA,     Gamma function
124 * @code{GERROR}:        GERROR,    Get last system error message
125 * @code{GETARG}:        GETARG,    Get command line arguments
126 * @code{GET_COMMAND}:   GET_COMMAND, Get the entire command line
127 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
128 * @code{GETCWD}:        GETCWD,    Get current working directory
129 * @code{GETENV}:        GETENV,    Get an environmental variable
130 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
131 * @code{GETGID}:        GETGID,    Group ID function
132 * @code{GETLOG}:        GETLOG,    Get login name
133 * @code{GETPID}:        GETPID,    Process ID function
134 * @code{GETUID}:        GETUID,    User ID function
135 * @code{GMTIME}:        GMTIME,    Convert time to GMT info
136 * @code{HOSTNM}:        HOSTNM,    Get system host name
137 * @code{HUGE}:          HUGE,      Largest number of a kind
138 * @code{HYPOT}:         HYPOT,     Euclidian distance function
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 intrinsic, 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{IMAGE_INDEX}:   IMAGE_INDEX, Cosubscript to image index convertion
156 * @code{IS_IOSTAT_END}:  IS_IOSTAT_END, Test for end-of-file value
157 * @code{IS_IOSTAT_EOR}:  IS_IOSTAT_EOR, Test for end-of-record value
158 * @code{ISATTY}:        ISATTY,    Whether a unit is a terminal device
159 * @code{ISHFT}:         ISHFT,     Shift bits
160 * @code{ISHFTC}:        ISHFTC,    Shift bits circularly
161 * @code{ISNAN}:         ISNAN,     Tests for a NaN
162 * @code{ITIME}:         ITIME,     Current local time (hour/minutes/seconds)
163 * @code{KILL}:          KILL,      Send a signal to a process
164 * @code{KIND}:          KIND,      Kind of an entity
165 * @code{LBOUND}:        LBOUND,    Lower dimension bounds of an array
166 * @code{LCOBOUND}:      LCOBOUND,  Lower codimension bounds of an array
167 * @code{LEADZ}:         LEADZ,     Number of leading zero bits of an integer
168 * @code{LEN}:           LEN,       Length of a character entity
169 * @code{LEN_TRIM}:      LEN_TRIM,  Length of a character entity without trailing blank characters
170 * @code{LGE}:           LGE,       Lexical greater than or equal
171 * @code{LGT}:           LGT,       Lexical greater than
172 * @code{LINK}:          LINK,      Create a hard link
173 * @code{LLE}:           LLE,       Lexical less than or equal
174 * @code{LLT}:           LLT,       Lexical less than
175 * @code{LNBLNK}:        LNBLNK,    Index of the last non-blank character in a string
176 * @code{LOC}:           LOC,       Returns the address of a variable
177 * @code{LOG}:           LOG,       Logarithm function
178 * @code{LOG10}:         LOG10,     Base 10 logarithm function 
179 * @code{LOG_GAMMA}:     LOG_GAMMA, Logarithm of the Gamma function
180 * @code{LOGICAL}:       LOGICAL,   Convert to logical type
181 * @code{LONG}:          LONG,      Convert to integer type
182 * @code{LSHIFT}:        LSHIFT,    Left shift bits
183 * @code{LSTAT}:         LSTAT,     Get file status
184 * @code{LTIME}:         LTIME,     Convert time to local time info
185 * @code{MALLOC}:        MALLOC,    Dynamic memory allocation function
186 * @code{MATMUL}:        MATMUL,    matrix multiplication
187 * @code{MAX}:           MAX,       Maximum value of an argument list
188 * @code{MAXEXPONENT}:   MAXEXPONENT, Maximum exponent of a real kind
189 * @code{MAXLOC}:        MAXLOC,    Location of the maximum value within an array
190 * @code{MAXVAL}:        MAXVAL,    Maximum value of an array
191 * @code{MCLOCK}:        MCLOCK,    Time function
192 * @code{MCLOCK8}:       MCLOCK8,   Time function (64-bit)
193 * @code{MERGE}:         MERGE,     Merge arrays
194 * @code{MIN}:           MIN,       Minimum value of an argument list
195 * @code{MINEXPONENT}:   MINEXPONENT, Minimum exponent of a real kind
196 * @code{MINLOC}:        MINLOC,    Location of the minimum value within an array
197 * @code{MINVAL}:        MINVAL,    Minimum value of an array
198 * @code{MOD}:           MOD,       Remainder function
199 * @code{MODULO}:        MODULO,    Modulo function
200 * @code{MOVE_ALLOC}:    MOVE_ALLOC, Move allocation from one object to another
201 * @code{MVBITS}:        MVBITS,    Move bits from one integer to another
202 * @code{NEAREST}:       NEAREST,   Nearest representable number
203 * @code{NEW_LINE}:      NEW_LINE,  New line character
204 * @code{NINT}:          NINT,      Nearest whole number
205 * @code{NOT}:           NOT,       Logical negation
206 * @code{NULL}:          NULL,      Function that returns an disassociated pointer
207 * @code{NUM_IMAGES}:    NUM_IMAGES, Number of images
208 * @code{OR}:            OR,        Bitwise logical OR
209 * @code{PACK}:          PACK,      Pack an array into an array of rank one
210 * @code{PERROR}:        PERROR,    Print system error message
211 * @code{PRECISION}:     PRECISION, Decimal precision of a real kind
212 * @code{PRESENT}:       PRESENT,   Determine whether an optional dummy argument is specified
213 * @code{PRODUCT}:       PRODUCT,   Product of array elements
214 * @code{RADIX}:         RADIX,     Base of a data model
215 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
216 * @code{RANDOM_SEED}:   RANDOM_SEED, Initialize a pseudo-random number sequence
217 * @code{RAND}:          RAND,      Real pseudo-random number
218 * @code{RANGE}:         RANGE,     Decimal exponent range
219 * @code{RAN}:           RAN,       Real pseudo-random number
220 * @code{REAL}:          REAL,      Convert to real type 
221 * @code{RENAME}:        RENAME,    Rename a file
222 * @code{REPEAT}:        REPEAT,    Repeated string concatenation
223 * @code{RESHAPE}:       RESHAPE,   Function to reshape an array
224 * @code{RRSPACING}:     RRSPACING, Reciprocal of the relative spacing
225 * @code{RSHIFT}:        RSHIFT,    Right shift bits
226 * @code{SCALE}:         SCALE,     Scale a real value
227 * @code{SCAN}:          SCAN,      Scan a string for the presence of a set of characters
228 * @code{SECNDS}:        SECNDS,    Time function
229 * @code{SECOND}:        SECOND,    CPU time function
230 * @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND,  Choose character kind
231 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND,  Choose integer kind
232 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND,  Choose real kind
233 * @code{SET_EXPONENT}:  SET_EXPONENT, Set the exponent of the model
234 * @code{SHAPE}:         SHAPE,     Determine the shape of an array
235 * @code{SIGN}:          SIGN,      Sign copying function
236 * @code{SIGNAL}:        SIGNAL,    Signal handling subroutine (or function)
237 * @code{SIN}:           SIN,       Sine function
238 * @code{SINH}:          SINH,      Hyperbolic sine function
239 * @code{SIZE}:          SIZE,      Function to determine the size of an array
240 * @code{SIZEOF}:        SIZEOF,    Determine the size in bytes of an expression
241 * @code{SLEEP}:         SLEEP,     Sleep for the specified number of seconds
242 * @code{SPACING}:       SPACING,   Smallest distance between two numbers of a given type
243 * @code{SPREAD}:        SPREAD,    Add a dimension to an array 
244 * @code{SQRT}:          SQRT,      Square-root function
245 * @code{SRAND}:         SRAND,     Reinitialize the random number generator
246 * @code{STAT}:          STAT,      Get file status
247 * @code{SUM}:           SUM,       Sum of array elements
248 * @code{SYMLNK}:        SYMLNK,    Create a symbolic link
249 * @code{SYSTEM}:        SYSTEM,    Execute a shell command
250 * @code{SYSTEM_CLOCK}:  SYSTEM_CLOCK, Time function
251 * @code{TAN}:           TAN,       Tangent function
252 * @code{TANH}:          TANH,      Hyperbolic tangent function
253 * @code{THIS_IMAGE}:    THIS_IMAGE, Cosubscript index of this image
254 * @code{TIME}:          TIME,      Time function
255 * @code{TIME8}:         TIME8,     Time function (64-bit)
256 * @code{TINY}:          TINY,      Smallest positive number of a real kind
257 * @code{TRAILZ}:        TRAILZ,    Number of trailing zero bits of an integer
258 * @code{TRANSFER}:      TRANSFER,  Transfer bit patterns
259 * @code{TRANSPOSE}:     TRANSPOSE, Transpose an array of rank two
260 * @code{TRIM}:          TRIM,      Remove trailing blank characters of a string
261 * @code{TTYNAM}:        TTYNAM,    Get the name of a terminal device.
262 * @code{UBOUND}:        UBOUND,    Upper dimension bounds of an array
263 * @code{UCOBOUND}:      UCOBOUND,  Upper codimension bounds of an array
264 * @code{UMASK}:         UMASK,     Set the file creation mask
265 * @code{UNLINK}:        UNLINK,    Remove a file from the file system
266 * @code{UNPACK}:        UNPACK,    Unpack an array of rank one into an array
267 * @code{VERIFY}:        VERIFY,    Scan a string for the absence of a set of characters
268 * @code{XOR}:           XOR,       Bitwise logical exclusive or
269 @end menu
271 @node Introduction to Intrinsics
272 @section Introduction to intrinsic procedures
274 The intrinsic procedures provided by GNU Fortran include all of the
275 intrinsic procedures required by the Fortran 95 standard, a set of
276 intrinsic procedures for backwards compatibility with G77, and a
277 selection of intrinsic procedures from the Fortran 2003 and Fortran 2008
278 standards.  Any conflict between a description here and a description in
279 either the Fortran 95 standard, the Fortran 2003 standard or the Fortran
280 2008 standard is unintentional, and the standard(s) should be considered
281 authoritative.
283 The enumeration of the @code{KIND} type parameter is processor defined in
284 the Fortran 95 standard.  GNU Fortran defines the default integer type and
285 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
286 respectively.  The standard mandates that both data types shall have
287 another kind, which have more precision.  On typical target architectures
288 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
289 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
290 In the description of generic intrinsic procedures, the kind type parameter
291 will be specified by @code{KIND=*}, and in the description of specific
292 names for an intrinsic procedure the kind type parameter will be explicitly
293 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}).  Finally, for
294 brevity the optional @code{KIND=} syntax will be omitted.
296 Many of the intrinsic procedures take one or more optional arguments.
297 This document follows the convention used in the Fortran 95 standard,
298 and denotes such arguments by square brackets.
300 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
301 which can be used to restrict the set of intrinsic procedures to a 
302 given standard.  By default, @command{gfortran} sets the @option{-std=gnu}
303 option, and so all intrinsic procedures described here are accepted.  There
304 is one caveat.  For a select group of intrinsic procedures, @command{g77}
305 implemented both a function and a subroutine.  Both classes 
306 have been implemented in @command{gfortran} for backwards compatibility
307 with @command{g77}.  It is noted here that these functions and subroutines
308 cannot be intermixed in a given subprogram.  In the descriptions that follow,
309 the applicable standard for each intrinsic procedure is noted.
313 @node ABORT
314 @section @code{ABORT} --- Abort the program
315 @fnindex ABORT
316 @cindex program termination, with core dump
317 @cindex terminate program, with core dump
318 @cindex core, dump
320 @table @asis
321 @item @emph{Description}:
322 @code{ABORT} causes immediate termination of the program.  On operating
323 systems that support a core dump, @code{ABORT} will produce a core dump even if
324 the option @option{-fno-dump-core} is in effect, which is suitable for debugging
325 purposes.
326 @c TODO: Check if this (with -fno-dump-core) is correct.
328 @item @emph{Standard}:
329 GNU extension
331 @item @emph{Class}:
332 Subroutine
334 @item @emph{Syntax}:
335 @code{CALL ABORT}
337 @item @emph{Return value}:
338 Does not return.
340 @item @emph{Example}:
341 @smallexample
342 program test_abort
343   integer :: i = 1, j = 2
344   if (i /= j) call abort
345 end program test_abort
346 @end smallexample
348 @item @emph{See also}:
349 @ref{EXIT}, @ref{KILL}
351 @end table
355 @node ABS
356 @section @code{ABS} --- Absolute value
357 @fnindex ABS
358 @fnindex CABS
359 @fnindex DABS
360 @fnindex IABS
361 @fnindex ZABS
362 @fnindex CDABS
363 @cindex absolute value
365 @table @asis
366 @item @emph{Description}:
367 @code{ABS(A)} computes the absolute value of @code{A}.
369 @item @emph{Standard}:
370 Fortran 77 and later, has overloads that are GNU extensions
372 @item @emph{Class}:
373 Elemental function
375 @item @emph{Syntax}:
376 @code{RESULT = ABS(A)}
378 @item @emph{Arguments}:
379 @multitable @columnfractions .15 .70
380 @item @var{A} @tab The type of the argument shall be an @code{INTEGER},
381 @code{REAL}, or @code{COMPLEX}.
382 @end multitable
384 @item @emph{Return value}:
385 The return value is of the same type and
386 kind as the argument except the return value is @code{REAL} for a
387 @code{COMPLEX} argument.
389 @item @emph{Example}:
390 @smallexample
391 program test_abs
392   integer :: i = -1
393   real :: x = -1.e0
394   complex :: z = (-1.e0,0.e0)
395   i = abs(i)
396   x = abs(x)
397   x = abs(z)
398 end program test_abs
399 @end smallexample
401 @item @emph{Specific names}:
402 @multitable @columnfractions .20 .20 .20 .25
403 @item Name            @tab Argument            @tab Return type       @tab Standard
404 @item @code{ABS(A)}   @tab @code{REAL(4) A}    @tab @code{REAL(4)}    @tab Fortran 77 and later
405 @item @code{CABS(A)}  @tab @code{COMPLEX(4) A} @tab @code{REAL(4)}    @tab Fortran 77 and later
406 @item @code{DABS(A)}  @tab @code{REAL(8) A}    @tab @code{REAL(8)}    @tab Fortran 77 and later
407 @item @code{IABS(A)}  @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab Fortran 77 and later
408 @item @code{ZABS(A)}  @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
409 @item @code{CDABS(A)} @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
410 @end multitable
411 @end table
415 @node ACCESS
416 @section @code{ACCESS} --- Checks file access modes
417 @fnindex ACCESS
418 @cindex file system, access mode
420 @table @asis
421 @item @emph{Description}:
422 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME} 
423 exists, is readable, writable or executable. Except for the
424 executable check, @code{ACCESS} can be replaced by
425 Fortran 95's @code{INQUIRE}.
427 @item @emph{Standard}:
428 GNU extension
430 @item @emph{Class}:
431 Inquiry function
433 @item @emph{Syntax}:
434 @code{RESULT = ACCESS(NAME, MODE)}
436 @item @emph{Arguments}:
437 @multitable @columnfractions .15 .70
438 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
439 file name. Tailing blank are ignored unless the character @code{achar(0)}
440 is present, then all characters up to and excluding @code{achar(0)} are
441 used as file name.
442 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the
443 file access mode, may be any concatenation of @code{"r"} (readable),
444 @code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check
445 for existence.
446 @end multitable
448 @item @emph{Return value}:
449 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
450 accessible in the given mode; otherwise or if an invalid argument
451 has been given for @code{MODE} the value @code{1} is returned.
453 @item @emph{Example}:
454 @smallexample
455 program access_test
456   implicit none
457   character(len=*), parameter :: file  = 'test.dat'
458   character(len=*), parameter :: file2 = 'test.dat  '//achar(0)
459   if(access(file,' ') == 0) print *, trim(file),' is exists'
460   if(access(file,'r') == 0) print *, trim(file),' is readable'
461   if(access(file,'w') == 0) print *, trim(file),' is writable'
462   if(access(file,'x') == 0) print *, trim(file),' is executable'
463   if(access(file2,'rwx') == 0) &
464     print *, trim(file2),' is readable, writable and executable'
465 end program access_test
466 @end smallexample
467 @item @emph{Specific names}:
468 @item @emph{See also}:
470 @end table
474 @node ACHAR
475 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence 
476 @fnindex ACHAR
477 @cindex @acronym{ASCII} collating sequence
478 @cindex collating sequence, @acronym{ASCII}
480 @table @asis
481 @item @emph{Description}:
482 @code{ACHAR(I)} returns the character located at position @code{I}
483 in the @acronym{ASCII} collating sequence.
485 @item @emph{Standard}:
486 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
488 @item @emph{Class}:
489 Elemental function
491 @item @emph{Syntax}:
492 @code{RESULT = ACHAR(I [, KIND])}
494 @item @emph{Arguments}:
495 @multitable @columnfractions .15 .70
496 @item @var{I}    @tab The type shall be @code{INTEGER}.
497 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
498 expression indicating the kind parameter of the result.
499 @end multitable
501 @item @emph{Return value}:
502 The return value is of type @code{CHARACTER} with a length of one.
503 If the @var{KIND} argument is present, the return value is of the
504 specified kind and of the default kind otherwise.
506 @item @emph{Example}:
507 @smallexample
508 program test_achar
509   character c
510   c = achar(32)
511 end program test_achar
512 @end smallexample
514 @item @emph{Note}:
515 See @ref{ICHAR} for a discussion of converting between numerical values
516 and formatted string representations.
518 @item @emph{See also}:
519 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
521 @end table
525 @node ACOS
526 @section @code{ACOS} --- Arccosine function 
527 @fnindex ACOS
528 @fnindex DACOS
529 @cindex trigonometric function, cosine, inverse
530 @cindex cosine, inverse
532 @table @asis
533 @item @emph{Description}:
534 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
536 @item @emph{Standard}:
537 Fortran 77 and later, for a complex argument Fortran 2008 or later
539 @item @emph{Class}:
540 Elemental function
542 @item @emph{Syntax}:
543 @code{RESULT = ACOS(X)}
545 @item @emph{Arguments}:
546 @multitable @columnfractions .15 .70
547 @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
548 less than or equal to one - or the type shall be @code{COMPLEX}.
549 @end multitable
551 @item @emph{Return value}:
552 The return value is of the same type and kind as @var{X}.
553 The real part of the result is in radians and lies in the range
554 @math{0 \leq \Re \acos(x) \leq \pi}.
556 @item @emph{Example}:
557 @smallexample
558 program test_acos
559   real(8) :: x = 0.866_8
560   x = acos(x)
561 end program test_acos
562 @end smallexample
564 @item @emph{Specific names}:
565 @multitable @columnfractions .20 .20 .20 .25
566 @item Name            @tab Argument         @tab Return type     @tab Standard
567 @item @code{ACOS(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}  @tab Fortran 77 and later
568 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}  @tab Fortran 77 and later
569 @end multitable
571 @item @emph{See also}:
572 Inverse function: @ref{COS}
574 @end table
578 @node ACOSH
579 @section @code{ACOSH} --- Hyperbolic arccosine function
580 @fnindex ACOSH
581 @fnindex DACOSH
582 @cindex area hyperbolic cosine
583 @cindex hyperbolic arccosine
584 @cindex hyperbolic function, cosine, inverse
585 @cindex cosine, hyperbolic, inverse
587 @table @asis
588 @item @emph{Description}:
589 @code{ACOSH(X)} computes the hyperbolic arccosine of @var{X} (inverse of
590 @code{COSH(X)}).
592 @item @emph{Standard}:
593 Fortran 2008 and later
595 @item @emph{Class}:
596 Elemental function
598 @item @emph{Syntax}:
599 @code{RESULT = ACOSH(X)}
601 @item @emph{Arguments}:
602 @multitable @columnfractions .15 .70
603 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
604 @end multitable
606 @item @emph{Return value}:
607 The return value has the same type and kind as @var{X}. If @var{X} is
608 complex, the imaginary part of the result is in radians and lies between
609 @math{ 0 \leq \Im \acosh(x) \leq \pi}.
611 @item @emph{Example}:
612 @smallexample
613 PROGRAM test_acosh
614   REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
615   WRITE (*,*) ACOSH(x)
616 END PROGRAM
617 @end smallexample
619 @item @emph{Specific names}:
620 @multitable @columnfractions .20 .20 .20 .25
621 @item Name             @tab Argument          @tab Return type       @tab Standard
622 @item @code{DACOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
623 @end multitable
625 @item @emph{See also}:
626 Inverse function: @ref{COSH}
627 @end table
631 @node ADJUSTL
632 @section @code{ADJUSTL} --- Left adjust a string 
633 @fnindex ADJUSTL
634 @cindex string, adjust left
635 @cindex adjust string
637 @table @asis
638 @item @emph{Description}:
639 @code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
640 Spaces are inserted at the end of the string as needed.
642 @item @emph{Standard}:
643 Fortran 90 and later
645 @item @emph{Class}:
646 Elemental function
648 @item @emph{Syntax}:
649 @code{RESULT = ADJUSTL(STRING)}
651 @item @emph{Arguments}:
652 @multitable @columnfractions .15 .70
653 @item @var{STRING} @tab The type shall be @code{CHARACTER}.
654 @end multitable
656 @item @emph{Return value}:
657 The return value is of type @code{CHARACTER} and of the same kind as
658 @var{STRING} where leading spaces are removed and the same number of
659 spaces are inserted on the end of @var{STRING}.
661 @item @emph{Example}:
662 @smallexample
663 program test_adjustl
664   character(len=20) :: str = '   gfortran'
665   str = adjustl(str)
666   print *, str
667 end program test_adjustl
668 @end smallexample
670 @item @emph{See also}:
671 @ref{ADJUSTR}, @ref{TRIM}
672 @end table
676 @node ADJUSTR
677 @section @code{ADJUSTR} --- Right adjust a string 
678 @fnindex ADJUSTR
679 @cindex string, adjust right
680 @cindex adjust string
682 @table @asis
683 @item @emph{Description}:
684 @code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
685 Spaces are inserted at the start of the string as needed.
687 @item @emph{Standard}:
688 Fortran 95 and later
690 @item @emph{Class}:
691 Elemental function
693 @item @emph{Syntax}:
694 @code{RESULT = ADJUSTR(STRING)}
696 @item @emph{Arguments}:
697 @multitable @columnfractions .15 .70
698 @item @var{STR} @tab The type shall be @code{CHARACTER}.
699 @end multitable
701 @item @emph{Return value}:
702 The return value is of type @code{CHARACTER} and of the same kind as
703 @var{STRING} where trailing spaces are removed and the same number of
704 spaces are inserted at the start of @var{STRING}.
706 @item @emph{Example}:
707 @smallexample
708 program test_adjustr
709   character(len=20) :: str = 'gfortran'
710   str = adjustr(str)
711   print *, str
712 end program test_adjustr
713 @end smallexample
715 @item @emph{See also}:
716 @ref{ADJUSTL}, @ref{TRIM}
717 @end table
721 @node AIMAG
722 @section @code{AIMAG} --- Imaginary part of complex number  
723 @fnindex AIMAG
724 @fnindex DIMAG
725 @fnindex IMAG
726 @fnindex IMAGPART
727 @cindex complex numbers, imaginary part
729 @table @asis
730 @item @emph{Description}:
731 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
732 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
733 for compatibility with @command{g77}, and their use in new code is 
734 strongly discouraged.
736 @item @emph{Standard}:
737 Fortran 77 and later, has overloads that are GNU extensions
739 @item @emph{Class}:
740 Elemental function
742 @item @emph{Syntax}:
743 @code{RESULT = AIMAG(Z)}
745 @item @emph{Arguments}:
746 @multitable @columnfractions .15 .70
747 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
748 @end multitable
750 @item @emph{Return value}:
751 The return value is of type @code{REAL} with the
752 kind type parameter of the argument.
754 @item @emph{Example}:
755 @smallexample
756 program test_aimag
757   complex(4) z4
758   complex(8) z8
759   z4 = cmplx(1.e0_4, 0.e0_4)
760   z8 = cmplx(0.e0_8, 1.e0_8)
761   print *, aimag(z4), dimag(z8)
762 end program test_aimag
763 @end smallexample
765 @item @emph{Specific names}:
766 @multitable @columnfractions .20 .20 .20 .25
767 @item Name               @tab Argument            @tab Return type     @tab Standard
768 @item @code{AIMAG(Z)}    @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
769 @item @code{DIMAG(Z)}    @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)}  @tab GNU extension
770 @item @code{IMAG(Z)}     @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
771 @item @code{IMAGPART(Z)} @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
772 @end multitable
773 @end table
777 @node AINT
778 @section @code{AINT} --- Truncate to a whole number
779 @fnindex AINT
780 @fnindex DINT
781 @cindex floor
782 @cindex rounding, floor
784 @table @asis
785 @item @emph{Description}:
786 @code{AINT(A [, KIND])} truncates its argument to a whole number.
788 @item @emph{Standard}:
789 Fortran 77 and later
791 @item @emph{Class}:
792 Elemental function
794 @item @emph{Syntax}:
795 @code{RESULT = AINT(A [, KIND])} 
797 @item @emph{Arguments}:
798 @multitable @columnfractions .15 .70
799 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
800 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
801 expression indicating the kind parameter of the result.
802 @end multitable
804 @item @emph{Return value}:
805 The return value is of type @code{REAL} with the kind type parameter of the
806 argument if the optional @var{KIND} is absent; otherwise, the kind
807 type parameter will be given by @var{KIND}.  If the magnitude of 
808 @var{X} is less than one, @code{AINT(X)} returns zero.  If the
809 magnitude is equal to or greater than one then it returns the largest
810 whole number that does not exceed its magnitude.  The sign is the same
811 as the sign of @var{X}. 
813 @item @emph{Example}:
814 @smallexample
815 program test_aint
816   real(4) x4
817   real(8) x8
818   x4 = 1.234E0_4
819   x8 = 4.321_8
820   print *, aint(x4), dint(x8)
821   x8 = aint(x4,8)
822 end program test_aint
823 @end smallexample
825 @item @emph{Specific names}:
826 @multitable @columnfractions .20 .20 .20 .25
827 @item Name           @tab Argument         @tab Return type      @tab Standard
828 @item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)}   @tab Fortran 77 and later
829 @item @code{DINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)}   @tab Fortran 77 and later
830 @end multitable
831 @end table
835 @node ALARM
836 @section @code{ALARM} --- Execute a routine after a given delay
837 @fnindex ALARM
838 @cindex delayed execution
840 @table @asis
841 @item @emph{Description}:
842 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
843 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
844 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
845 supplied, it will be returned with the number of seconds remaining until
846 any previously scheduled alarm was due to be delivered, or zero if there
847 was no previously scheduled alarm.
849 @item @emph{Standard}:
850 GNU extension
852 @item @emph{Class}:
853 Subroutine
855 @item @emph{Syntax}:
856 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
858 @item @emph{Arguments}:
859 @multitable @columnfractions .15 .70
860 @item @var{SECONDS} @tab The type of the argument shall be a scalar
861 @code{INTEGER}. It is @code{INTENT(IN)}.
862 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
863 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar 
864 values may be either @code{SIG_IGN=1} to ignore the alarm generated 
865 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
866 @item @var{STATUS}  @tab (Optional) @var{STATUS} shall be a scalar
867 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
868 @end multitable
870 @item @emph{Example}:
871 @smallexample
872 program test_alarm
873   external handler_print
874   integer i
875   call alarm (3, handler_print, i)
876   print *, i
877   call sleep(10)
878 end program test_alarm
879 @end smallexample
880 This will cause the external routine @var{handler_print} to be called
881 after 3 seconds.
882 @end table
886 @node ALL
887 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true 
888 @fnindex ALL
889 @cindex array, apply condition
890 @cindex array, condition testing
892 @table @asis
893 @item @emph{Description}:
894 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
895 in the array along dimension @var{DIM}.
897 @item @emph{Standard}:
898 Fortran 95 and later
900 @item @emph{Class}:
901 Transformational function
903 @item @emph{Syntax}:
904 @code{RESULT = ALL(MASK [, DIM])}
906 @item @emph{Arguments}:
907 @multitable @columnfractions .15 .70
908 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
909 it shall not be scalar.
910 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
911 with a value that lies between one and the rank of @var{MASK}.
912 @end multitable
914 @item @emph{Return value}:
915 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where
916 the kind type parameter is the same as the kind type parameter of
917 @var{MASK}.  If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
918 an array with the rank of @var{MASK} minus 1.  The shape is determined from
919 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
921 @table @asis
922 @item (A)
923 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
924 It also is true if @var{MASK} has zero size; otherwise, it is false.
925 @item (B)
926 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
927 to @code{ALL(MASK)}.  If the rank is greater than one, then @code{ALL(MASK,DIM)}
928 is determined by applying @code{ALL} to the array sections.
929 @end table
931 @item @emph{Example}:
932 @smallexample
933 program test_all
934   logical l
935   l = all((/.true., .true., .true./))
936   print *, l
937   call section
938   contains
939     subroutine section
940       integer a(2,3), b(2,3)
941       a = 1
942       b = 1
943       b(2,2) = 2
944       print *, all(a .eq. b, 1)
945       print *, all(a .eq. b, 2)
946     end subroutine section
947 end program test_all
948 @end smallexample
949 @end table
953 @node ALLOCATED
954 @section @code{ALLOCATED} --- Status of an allocatable entity
955 @fnindex ALLOCATED
956 @cindex allocation, status
958 @table @asis
959 @item @emph{Description}:
960 @code{ALLOCATED(ARRAY)} and @code{ALLOCATED(SCALAR)} check the allocation
961 status of @var{ARRAY} and @var{SCALAR}, respectively.
963 @item @emph{Standard}:
964 Fortran 95 and later.  Note, the @code{SCALAR=} keyword and allocatable
965 scalar entities are available in Fortran 2003 and later.
967 @item @emph{Class}:
968 Inquiry function
970 @item @emph{Syntax}:
971 @code{RESULT = ALLOCATED(ARRAY)} or @code{RESULT = ALLOCATED(SCALAR)} 
973 @item @emph{Arguments}:
974 @multitable @columnfractions .15 .70
975 @item @var{ARRAY}    @tab The argument shall be an @code{ALLOCATABLE} array.
976 @item @var{SCALAR}   @tab The argument shall be an @code{ALLOCATABLE} scalar.
977 @end multitable
979 @item @emph{Return value}:
980 The return value is a scalar @code{LOGICAL} with the default logical
981 kind type parameter.  If the argument is allocated, then the result is
982 @code{.TRUE.}; otherwise, it returns @code{.FALSE.} 
984 @item @emph{Example}:
985 @smallexample
986 program test_allocated
987   integer :: i = 4
988   real(4), allocatable :: x(:)
989   if (.not. allocated(x)) allocate(x(i))
990 end program test_allocated
991 @end smallexample
992 @end table
996 @node AND
997 @section @code{AND} --- Bitwise logical AND
998 @fnindex AND
999 @cindex bitwise logical and
1000 @cindex logical and, bitwise
1002 @table @asis
1003 @item @emph{Description}:
1004 Bitwise logical @code{AND}.
1006 This intrinsic routine is provided for backwards compatibility with 
1007 GNU Fortran 77.  For integer arguments, programmers should consider
1008 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
1010 @item @emph{Standard}:
1011 GNU extension
1013 @item @emph{Class}:
1014 Function
1016 @item @emph{Syntax}:
1017 @code{RESULT = AND(I, J)}
1019 @item @emph{Arguments}:
1020 @multitable @columnfractions .15 .70
1021 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
1022 type or a scalar @code{LOGICAL} type.
1023 @item @var{J} @tab The type shall be the same as the type of @var{I}.
1024 @end multitable
1026 @item @emph{Return value}:
1027 The return type is either a scalar @code{INTEGER} or a scalar
1028 @code{LOGICAL}.  If the kind type parameters differ, then the
1029 smaller kind type is implicitly converted to larger kind, and the 
1030 return has the larger kind.
1032 @item @emph{Example}:
1033 @smallexample
1034 PROGRAM test_and
1035   LOGICAL :: T = .TRUE., F = .FALSE.
1036   INTEGER :: a, b
1037   DATA a / Z'F' /, b / Z'3' /
1039   WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1040   WRITE (*,*) AND(a, b)
1041 END PROGRAM
1042 @end smallexample
1044 @item @emph{See also}:
1045 Fortran 95 elemental function: @ref{IAND}
1046 @end table
1050 @node ANINT
1051 @section @code{ANINT} --- Nearest whole number
1052 @fnindex ANINT
1053 @fnindex DNINT
1054 @cindex ceiling
1055 @cindex rounding, ceiling
1057 @table @asis
1058 @item @emph{Description}:
1059 @code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1061 @item @emph{Standard}:
1062 Fortran 77 and later
1064 @item @emph{Class}:
1065 Elemental function
1067 @item @emph{Syntax}:
1068 @code{RESULT = ANINT(A [, KIND])}
1070 @item @emph{Arguments}:
1071 @multitable @columnfractions .15 .70
1072 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
1073 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
1074 expression indicating the kind parameter of the result.
1075 @end multitable
1077 @item @emph{Return value}:
1078 The return value is of type real with the kind type parameter of the
1079 argument if the optional @var{KIND} is absent; otherwise, the kind
1080 type parameter will be given by @var{KIND}.  If @var{A} is greater than
1081 zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}.  If @var{A} is
1082 less than or equal to zero then it returns @code{AINT(X-0.5)}.
1084 @item @emph{Example}:
1085 @smallexample
1086 program test_anint
1087   real(4) x4
1088   real(8) x8
1089   x4 = 1.234E0_4
1090   x8 = 4.321_8
1091   print *, anint(x4), dnint(x8)
1092   x8 = anint(x4,8)
1093 end program test_anint
1094 @end smallexample
1096 @item @emph{Specific names}:
1097 @multitable @columnfractions .20 .20 .20 .25
1098 @item Name            @tab Argument         @tab Return type      @tab Standard
1099 @item @code{AINT(A)}  @tab @code{REAL(4) A} @tab @code{REAL(4)}   @tab Fortran 77 and later
1100 @item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)}   @tab Fortran 77 and later
1101 @end multitable
1102 @end table
1106 @node ANY
1107 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true 
1108 @fnindex ANY
1109 @cindex array, apply condition
1110 @cindex array, condition testing
1112 @table @asis
1113 @item @emph{Description}:
1114 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1115 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1117 @item @emph{Standard}:
1118 Fortran 95 and later
1120 @item @emph{Class}:
1121 Transformational function
1123 @item @emph{Syntax}:
1124 @code{RESULT = ANY(MASK [, DIM])}
1126 @item @emph{Arguments}:
1127 @multitable @columnfractions .15 .70
1128 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1129 it shall not be scalar.
1130 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
1131 with a value that lies between one and the rank of @var{MASK}.
1132 @end multitable
1134 @item @emph{Return value}:
1135 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1136 the kind type parameter is the same as the kind type parameter of
1137 @var{MASK}.  If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1138 an array with the rank of @var{MASK} minus 1.  The shape is determined from
1139 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
1141 @table @asis
1142 @item (A)
1143 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1144 otherwise, it is false.  It also is false if @var{MASK} has zero size.
1145 @item (B)
1146 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1147 to @code{ANY(MASK)}.  If the rank is greater than one, then @code{ANY(MASK,DIM)}
1148 is determined by applying @code{ANY} to the array sections.
1149 @end table
1151 @item @emph{Example}:
1152 @smallexample
1153 program test_any
1154   logical l
1155   l = any((/.true., .true., .true./))
1156   print *, l
1157   call section
1158   contains
1159     subroutine section
1160       integer a(2,3), b(2,3)
1161       a = 1
1162       b = 1
1163       b(2,2) = 2
1164       print *, any(a .eq. b, 1)
1165       print *, any(a .eq. b, 2)
1166     end subroutine section
1167 end program test_any
1168 @end smallexample
1169 @end table
1173 @node ASIN
1174 @section @code{ASIN} --- Arcsine function 
1175 @fnindex ASIN
1176 @fnindex DASIN
1177 @cindex trigonometric function, sine, inverse
1178 @cindex sine, inverse
1180 @table @asis
1181 @item @emph{Description}:
1182 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1184 @item @emph{Standard}:
1185 Fortran 77 and later, for a complex argument Fortran 2008 or later
1187 @item @emph{Class}:
1188 Elemental function
1190 @item @emph{Syntax}:
1191 @code{RESULT = ASIN(X)}
1193 @item @emph{Arguments}:
1194 @multitable @columnfractions .15 .70
1195 @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1196 less than or equal to one - or be @code{COMPLEX}.
1197 @end multitable
1199 @item @emph{Return value}:
1200 The return value is of the same type and kind as @var{X}.
1201 The real part of the result is in radians and lies in the range
1202 @math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}.
1204 @item @emph{Example}:
1205 @smallexample
1206 program test_asin
1207   real(8) :: x = 0.866_8
1208   x = asin(x)
1209 end program test_asin
1210 @end smallexample
1212 @item @emph{Specific names}:
1213 @multitable @columnfractions .20 .20 .20 .25
1214 @item Name            @tab Argument          @tab Return type       @tab Standard
1215 @item @code{ASIN(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
1216 @item @code{DASIN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1217 @end multitable
1219 @item @emph{See also}:
1220 Inverse function: @ref{SIN}
1222 @end table
1226 @node ASINH
1227 @section @code{ASINH} --- Hyperbolic arcsine function
1228 @fnindex ASINH
1229 @fnindex DASINH
1230 @cindex area hyperbolic sine
1231 @cindex hyperbolic arcsine
1232 @cindex hyperbolic function, sine, inverse
1233 @cindex sine, hyperbolic, inverse
1235 @table @asis
1236 @item @emph{Description}:
1237 @code{ASINH(X)} computes the hyperbolic arcsine of @var{X} (inverse of @code{SINH(X)}).
1239 @item @emph{Standard}:
1240 Fortran 2008 and later
1242 @item @emph{Class}:
1243 Elemental function
1245 @item @emph{Syntax}:
1246 @code{RESULT = ASINH(X)}
1248 @item @emph{Arguments}:
1249 @multitable @columnfractions .15 .70
1250 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1251 @end multitable
1253 @item @emph{Return value}:
1254 The return value is of the same type and kind as  @var{X}. If @var{X} is
1255 complex, the imaginary part of the result is in radians and lies between
1256 @math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}.
1258 @item @emph{Example}:
1259 @smallexample
1260 PROGRAM test_asinh
1261   REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1262   WRITE (*,*) ASINH(x)
1263 END PROGRAM
1264 @end smallexample
1266 @item @emph{Specific names}:
1267 @multitable @columnfractions .20 .20 .20 .25
1268 @item Name             @tab Argument          @tab Return type       @tab Standard
1269 @item @code{DASINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension.
1270 @end multitable
1272 @item @emph{See also}:
1273 Inverse function: @ref{SINH}
1274 @end table
1278 @node ASSOCIATED
1279 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair 
1280 @fnindex ASSOCIATED
1281 @cindex pointer, status
1282 @cindex association status
1284 @table @asis
1285 @item @emph{Description}:
1286 @code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1287 @var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
1289 @item @emph{Standard}:
1290 Fortran 95 and later
1292 @item @emph{Class}:
1293 Inquiry function
1295 @item @emph{Syntax}:
1296 @code{RESULT = ASSOCIATED(POINTER [, TARGET])}
1298 @item @emph{Arguments}:
1299 @multitable @columnfractions .15 .70
1300 @item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1301 and it can be of any type.
1302 @item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1303 a target.  It must have the same type, kind type parameter, and
1304 array rank as @var{POINTER}.
1305 @end multitable
1306 The association status of neither @var{POINTER} nor @var{TARGET} shall be
1307 undefined.
1309 @item @emph{Return value}:
1310 @code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
1311 There are several cases:
1312 @table @asis
1313 @item (A) When the optional @var{TARGET} is not present then
1314 @code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1315 @item (B) If @var{TARGET} is present and a scalar target, the result is true if
1316 @var{TARGET} is not a zero-sized storage sequence and the target associated with @var{POINTER} occupies the same storage units.  If @var{POINTER} is
1317 disassociated, the result is false.
1318 @item (C) If @var{TARGET} is present and an array target, the result is true if
1319 @var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1320 are arrays whose elements are not zero-sized storage sequences, and
1321 @var{TARGET} and @var{POINTER} occupy the same storage units in array element
1322 order.
1323 As in case(B), the result is false, if @var{POINTER} is disassociated.
1324 @item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1325 if @var{TARGET} is associated with @var{POINTER}, the target associated with
1326 @var{TARGET} are not zero-sized storage sequences and occupy the same storage
1327 units.
1328 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1329 @item (E) If @var{TARGET} is present and an array pointer, the result is true if
1330 target associated with @var{POINTER} and the target associated with @var{TARGET}
1331 have the same shape, are not zero-sized arrays, are arrays whose elements are
1332 not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1333 the same storage units in array element order.
1334 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1335 @end table
1337 @item @emph{Example}:
1338 @smallexample
1339 program test_associated
1340    implicit none
1341    real, target  :: tgt(2) = (/1., 2./)
1342    real, pointer :: ptr(:)
1343    ptr => tgt
1344    if (associated(ptr)     .eqv. .false.) call abort
1345    if (associated(ptr,tgt) .eqv. .false.) call abort
1346 end program test_associated
1347 @end smallexample
1349 @item @emph{See also}:
1350 @ref{NULL}
1351 @end table
1355 @node ATAN
1356 @section @code{ATAN} --- Arctangent function 
1357 @fnindex ATAN
1358 @fnindex DATAN
1359 @cindex trigonometric function, tangent, inverse
1360 @cindex tangent, inverse
1362 @table @asis
1363 @item @emph{Description}:
1364 @code{ATAN(X)} computes the arctangent of @var{X}.
1366 @item @emph{Standard}:
1367 Fortran 77 and later, for a complex argument and for two arguments
1368 Fortran 2008 or later
1370 @item @emph{Class}:
1371 Elemental function
1373 @item @emph{Syntax}:
1374 @code{RESULT = ATAN(X)}
1375 @code{RESULT = ATAN(Y, X)}
1377 @item @emph{Arguments}:
1378 @multitable @columnfractions .15 .70
1379 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1380 if @var{Y} is present, @var{X} shall be REAL.
1381 @item @var{Y} shall be of the same type and kind as @var{X}.
1382 @end multitable
1384 @item @emph{Return value}:
1385 The return value is of the same type and kind as @var{X}.
1386 If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}.
1387 Otherwise, it the arcus tangent of @var{X}, where the real part of
1388 the result is in radians and lies in the range
1389 @math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}.
1391 @item @emph{Example}:
1392 @smallexample
1393 program test_atan
1394   real(8) :: x = 2.866_8
1395   x = atan(x)
1396 end program test_atan
1397 @end smallexample
1399 @item @emph{Specific names}:
1400 @multitable @columnfractions .20 .20 .20 .25
1401 @item Name            @tab Argument          @tab Return type       @tab Standard
1402 @item @code{ATAN(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
1403 @item @code{DATAN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1404 @end multitable
1406 @item @emph{See also}:
1407 Inverse function: @ref{TAN}
1409 @end table
1413 @node ATAN2
1414 @section @code{ATAN2} --- Arctangent function 
1415 @fnindex ATAN2
1416 @fnindex DATAN2
1417 @cindex trigonometric function, tangent, inverse
1418 @cindex tangent, inverse
1420 @table @asis
1421 @item @emph{Description}:
1422 @code{ATAN2(Y, X)} computes the principal value of the argument
1423 function of the complex number @math{X + i Y}. This function can
1424 be used to transform from carthesian into polar coordinates and
1425 allows to determine the angle in the correct quadrant.
1427 @item @emph{Standard}:
1428 Fortran 77 and later
1430 @item @emph{Class}:
1431 Elemental function
1433 @item @emph{Syntax}:
1434 @code{RESULT = ATAN2(Y, X)}
1436 @item @emph{Arguments}:
1437 @multitable @columnfractions .15 .70
1438 @item @var{Y} @tab The type shall be @code{REAL}.
1439 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1440 If @var{Y} is zero, then @var{X} must be nonzero.
1441 @end multitable
1443 @item @emph{Return value}:
1444 The return value has the same type and kind type parameter as @var{Y}.
1445 It is the principal value of the complex number @math{X + i Y}.  If
1446 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1447 The sign is positive if @var{Y} is positive.  If @var{Y} is zero, then
1448 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1449 is negative.  Finally, if @var{X} is zero, then the magnitude of the result
1450 is @math{\pi/2}.
1452 @item @emph{Example}:
1453 @smallexample
1454 program test_atan2
1455   real(4) :: x = 1.e0_4, y = 0.5e0_4
1456   x = atan2(y,x)
1457 end program test_atan2
1458 @end smallexample
1460 @item @emph{Specific names}:
1461 @multitable @columnfractions .20 .20 .20 .25
1462 @item Name                @tab Argument            @tab Return type    @tab Standard
1463 @item @code{ATAN2(X, Y)}  @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
1464 @item @code{DATAN2(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
1465 @end multitable
1466 @end table
1470 @node ATANH
1471 @section @code{ATANH} --- Hyperbolic arctangent function
1472 @fnindex ASINH
1473 @fnindex DASINH
1474 @cindex area hyperbolic tangent
1475 @cindex hyperbolic arctangent
1476 @cindex hyperbolic function, tangent, inverse
1477 @cindex tangent, hyperbolic, inverse
1479 @table @asis
1480 @item @emph{Description}:
1481 @code{ATANH(X)} computes the hyperbolic arctangent of @var{X} (inverse
1482 of @code{TANH(X)}).
1484 @item @emph{Standard}:
1485 Fortran 2008 and later
1487 @item @emph{Class}:
1488 Elemental function
1490 @item @emph{Syntax}:
1491 @code{RESULT = ATANH(X)}
1493 @item @emph{Arguments}:
1494 @multitable @columnfractions .15 .70
1495 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1496 @end multitable
1498 @item @emph{Return value}:
1499 The return value has same type and kind as @var{X}. If @var{X} is
1500 complex, the imaginary part of the result is in radians and lies between
1501 @math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}.
1503 @item @emph{Example}:
1504 @smallexample
1505 PROGRAM test_atanh
1506   REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1507   WRITE (*,*) ATANH(x)
1508 END PROGRAM
1509 @end smallexample
1511 @item @emph{Specific names}:
1512 @multitable @columnfractions .20 .20 .20 .25
1513 @item Name             @tab Argument          @tab Return type       @tab Standard
1514 @item @code{DATANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1515 @end multitable
1517 @item @emph{See also}:
1518 Inverse function: @ref{TANH}
1519 @end table
1523 @node BESSEL_J0
1524 @section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
1525 @fnindex BESSEL_J0
1526 @fnindex BESJ0
1527 @fnindex DBESJ0
1528 @cindex Bessel function, first kind
1530 @table @asis
1531 @item @emph{Description}:
1532 @code{BESSEL_J0(X)} computes the Bessel function of the first kind of
1533 order 0 of @var{X}. This function is available under the name
1534 @code{BESJ0} as a GNU extension.
1536 @item @emph{Standard}:
1537 Fortran 2008 and later
1539 @item @emph{Class}:
1540 Elemental function
1542 @item @emph{Syntax}:
1543 @code{RESULT = BESSEL_J0(X)}
1545 @item @emph{Arguments}:
1546 @multitable @columnfractions .15 .70
1547 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1548 @end multitable
1550 @item @emph{Return value}:
1551 The return value is of type @code{REAL} and lies in the
1552 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
1553 kind as @var{X}.
1555 @item @emph{Example}:
1556 @smallexample
1557 program test_besj0
1558   real(8) :: x = 0.0_8
1559   x = bessel_j0(x)
1560 end program test_besj0
1561 @end smallexample
1563 @item @emph{Specific names}:
1564 @multitable @columnfractions .20 .20 .20 .25
1565 @item Name            @tab Argument          @tab Return type       @tab Standard
1566 @item @code{DBESJ0(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}   @tab GNU extension
1567 @end multitable
1568 @end table
1572 @node BESSEL_J1
1573 @section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
1574 @fnindex BESSEL_J1
1575 @fnindex BESJ1
1576 @fnindex DBESJ1
1577 @cindex Bessel function, first kind
1579 @table @asis
1580 @item @emph{Description}:
1581 @code{BESSEL_J1(X)} computes the Bessel function of the first kind of
1582 order 1 of @var{X}. This function is available under the name
1583 @code{BESJ1} as a GNU extension.
1585 @item @emph{Standard}:
1586 Fortran 2008
1588 @item @emph{Class}:
1589 Elemental function
1591 @item @emph{Syntax}:
1592 @code{RESULT = BESSEL_J1(X)}
1594 @item @emph{Arguments}:
1595 @multitable @columnfractions .15 .70
1596 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1597 @end multitable
1599 @item @emph{Return value}:
1600 The return value is of type @code{REAL} and it lies in the
1601 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
1602 kind as @var{X}.
1604 @item @emph{Example}:
1605 @smallexample
1606 program test_besj1
1607   real(8) :: x = 1.0_8
1608   x = bessel_j1(x)
1609 end program test_besj1
1610 @end smallexample
1612 @item @emph{Specific names}:
1613 @multitable @columnfractions .20 .20 .20 .25
1614 @item Name             @tab Argument          @tab Return type       @tab Standard
1615 @item @code{DBESJ1(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1616 @end multitable
1617 @end table
1621 @node BESSEL_JN
1622 @section @code{BESSEL_JN} --- Bessel function of the first kind
1623 @fnindex BESSEL_JN
1624 @fnindex BESJN
1625 @fnindex DBESJN
1626 @cindex Bessel function, first kind
1628 @table @asis
1629 @item @emph{Description}:
1630 @code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
1631 order @var{N} of @var{X}. This function is available under the name
1632 @code{BESJN} as a GNU extension.
1634 If both arguments are arrays, their ranks and shapes shall conform.
1636 @item @emph{Standard}:
1637 Fortran 2008 and later
1639 @item @emph{Class}:
1640 Elemental function
1642 @item @emph{Syntax}:
1643 @code{RESULT = BESSEL_JN(N, X)}
1645 @item @emph{Arguments}:
1646 @multitable @columnfractions .15 .70
1647 @item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER}.
1648 @item @var{X} @tab Shall be a scalar or an array of type  @code{REAL}.
1649 @end multitable
1651 @item @emph{Return value}:
1652 The return value is a scalar of type @code{REAL}. It has the same
1653 kind as @var{X}.
1655 @item @emph{Example}:
1656 @smallexample
1657 program test_besjn
1658   real(8) :: x = 1.0_8
1659   x = bessel_jn(5,x)
1660 end program test_besjn
1661 @end smallexample
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{DBESJN(N, X)} @tab @code{INTEGER N}    @tab @code{REAL(8)}    @tab GNU extension
1667 @item                     @tab @code{REAL(8) X}    @tab                   @tab
1668 @end multitable
1669 @end table
1673 @node BESSEL_Y0
1674 @section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
1675 @fnindex BESSEL_Y0
1676 @fnindex BESY0
1677 @fnindex DBESY0
1678 @cindex Bessel function, second kind
1680 @table @asis
1681 @item @emph{Description}:
1682 @code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
1683 order 0 of @var{X}. This function is available under the name
1684 @code{BESY0} as a GNU extension.
1686 @item @emph{Standard}:
1687 Fortran 2008 and later
1689 @item @emph{Class}:
1690 Elemental function
1692 @item @emph{Syntax}:
1693 @code{RESULT = BESSEL_Y0(X)}
1695 @item @emph{Arguments}:
1696 @multitable @columnfractions .15 .70
1697 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1698 @end multitable
1700 @item @emph{Return value}:
1701 The return value is a scalar of type @code{REAL}. It has the same
1702 kind as @var{X}.
1704 @item @emph{Example}:
1705 @smallexample
1706 program test_besy0
1707   real(8) :: x = 0.0_8
1708   x = bessel_y0(x)
1709 end program test_besy0
1710 @end smallexample
1712 @item @emph{Specific names}:
1713 @multitable @columnfractions .20 .20 .20 .25
1714 @item Name            @tab Argument          @tab Return type       @tab Standard
1715 @item @code{DBESY0(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1716 @end multitable
1717 @end table
1721 @node BESSEL_Y1
1722 @section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
1723 @fnindex BESSEL_Y1
1724 @fnindex BESY1
1725 @fnindex DBESY1
1726 @cindex Bessel function, second kind
1728 @table @asis
1729 @item @emph{Description}:
1730 @code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
1731 order 1 of @var{X}. This function is available under the name
1732 @code{BESY1} as a GNU extension.
1734 @item @emph{Standard}:
1735 Fortran 2008 and later
1737 @item @emph{Class}:
1738 Elemental function
1740 @item @emph{Syntax}:
1741 @code{RESULT = BESSEL_Y1(X)}
1743 @item @emph{Arguments}:
1744 @multitable @columnfractions .15 .70
1745 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1746 @end multitable
1748 @item @emph{Return value}:
1749 The return value is a scalar of type @code{REAL}. It has the same
1750 kind as @var{X}.
1752 @item @emph{Example}:
1753 @smallexample
1754 program test_besy1
1755   real(8) :: x = 1.0_8
1756   x = bessel_y1(x)
1757 end program test_besy1
1758 @end smallexample
1760 @item @emph{Specific names}:
1761 @multitable @columnfractions .20 .20 .20 .25
1762 @item Name            @tab Argument          @tab Return type       @tab Standard
1763 @item @code{DBESY1(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1764 @end multitable
1765 @end table
1769 @node BESSEL_YN
1770 @section @code{BESSEL_YN} --- Bessel function of the second kind
1771 @fnindex BESSEL_YN
1772 @fnindex BESYN
1773 @fnindex DBESYN
1774 @cindex Bessel function, second kind
1776 @table @asis
1777 @item @emph{Description}:
1778 @code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
1779 order @var{N} of @var{X}. This function is available under the name
1780 @code{BESYN} as a GNU extension.
1782 If both arguments are arrays, their ranks and shapes shall conform.
1784 @item @emph{Standard}:
1785 Fortran 2008 and later
1787 @item @emph{Class}:
1788 Elemental function
1790 @item @emph{Syntax}:
1791 @code{RESULT = BESSEL_YN(N, X)}
1793 @item @emph{Arguments}:
1794 @multitable @columnfractions .15 .70
1795 @item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER}.
1796 @item @var{X} @tab Shall be a scalar or an array of type  @code{REAL}.
1797 @end multitable
1799 @item @emph{Return value}:
1800 The return value is a scalar of type @code{REAL}. It has the same
1801 kind as @var{X}.
1803 @item @emph{Example}:
1804 @smallexample
1805 program test_besyn
1806   real(8) :: x = 1.0_8
1807   x = bessel_yn(5,x)
1808 end program test_besyn
1809 @end smallexample
1811 @item @emph{Specific names}:
1812 @multitable @columnfractions .20 .20 .20 .25
1813 @item Name               @tab Argument            @tab Return type     @tab Standard
1814 @item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)}  @tab GNU extension
1815 @item                    @tab @code{REAL(8) X} @tab                 @tab 
1816 @end multitable
1817 @end table
1821 @node BIT_SIZE
1822 @section @code{BIT_SIZE} --- Bit size inquiry function
1823 @fnindex BIT_SIZE
1824 @cindex bits, number of
1825 @cindex size of a variable, in bits
1827 @table @asis
1828 @item @emph{Description}:
1829 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1830 represented by the type of @var{I}.  The result of @code{BIT_SIZE(I)} is
1831 independent of the actual value of @var{I}.
1833 @item @emph{Standard}:
1834 Fortran 95 and later
1836 @item @emph{Class}:
1837 Inquiry function
1839 @item @emph{Syntax}:
1840 @code{RESULT = BIT_SIZE(I)}
1842 @item @emph{Arguments}:
1843 @multitable @columnfractions .15 .70
1844 @item @var{I} @tab The type shall be @code{INTEGER}.
1845 @end multitable
1847 @item @emph{Return value}:
1848 The return value is of type @code{INTEGER}
1850 @item @emph{Example}:
1851 @smallexample
1852 program test_bit_size
1853     integer :: i = 123
1854     integer :: size
1855     size = bit_size(i)
1856     print *, size
1857 end program test_bit_size
1858 @end smallexample
1859 @end table
1863 @node BTEST
1864 @section @code{BTEST} --- Bit test function
1865 @fnindex BTEST
1866 @cindex bits, testing
1868 @table @asis
1869 @item @emph{Description}:
1870 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1871 in @var{I} is set.  The counting of the bits starts at 0.
1873 @item @emph{Standard}:
1874 Fortran 95 and later
1876 @item @emph{Class}:
1877 Elemental function
1879 @item @emph{Syntax}:
1880 @code{RESULT = BTEST(I, POS)}
1882 @item @emph{Arguments}:
1883 @multitable @columnfractions .15 .70
1884 @item @var{I} @tab The type shall be @code{INTEGER}.
1885 @item @var{POS} @tab The type shall be @code{INTEGER}.
1886 @end multitable
1888 @item @emph{Return value}:
1889 The return value is of type @code{LOGICAL}
1891 @item @emph{Example}:
1892 @smallexample
1893 program test_btest
1894     integer :: i = 32768 + 1024 + 64
1895     integer :: pos
1896     logical :: bool
1897     do pos=0,16
1898         bool = btest(i, pos) 
1899         print *, pos, bool
1900     end do
1901 end program test_btest
1902 @end smallexample
1903 @end table
1906 @node C_ASSOCIATED
1907 @section @code{C_ASSOCIATED} --- Status of a C pointer
1908 @fnindex C_ASSOCIATED
1909 @cindex association status, C pointer
1910 @cindex pointer, C association status
1912 @table @asis
1913 @item @emph{Description}:
1914 @code{C_ASSOCIATED(c_prt_1[, c_ptr_2])} determines the status of the C pointer
1915 @var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
1917 @item @emph{Standard}:
1918 Fortran 2003 and later
1920 @item @emph{Class}:
1921 Inquiry function
1923 @item @emph{Syntax}:
1924 @code{RESULT = C_ASSOCIATED(c_prt_1[, c_ptr_2])}
1926 @item @emph{Arguments}:
1927 @multitable @columnfractions .15 .70
1928 @item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
1929 @item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
1930 @end multitable
1932 @item @emph{Return value}:
1933 The return value is of type @code{LOGICAL}; it is @code{.false.} if either
1934 @var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
1935 point to different addresses.
1937 @item @emph{Example}:
1938 @smallexample
1939 subroutine association_test(a,b)
1940   use iso_c_binding, only: c_associated, c_loc, c_ptr
1941   implicit none
1942   real, pointer :: a
1943   type(c_ptr) :: b
1944   if(c_associated(b, c_loc(a))) &
1945      stop 'b and a do not point to same target'
1946 end subroutine association_test
1947 @end smallexample
1949 @item @emph{See also}:
1950 @ref{C_LOC}, @ref{C_FUNLOC}
1951 @end table
1954 @node C_FUNLOC
1955 @section @code{C_FUNLOC} --- Obtain the C address of a procedure
1956 @fnindex C_FUNLOC
1957 @cindex pointer, C address of procedures
1959 @table @asis
1960 @item @emph{Description}:
1961 @code{C_FUNLOC(x)} determines the C address of the argument.
1963 @item @emph{Standard}:
1964 Fortran 2003 and later
1966 @item @emph{Class}:
1967 Inquiry function
1969 @item @emph{Syntax}:
1970 @code{RESULT = C_FUNLOC(x)}
1972 @item @emph{Arguments}:
1973 @multitable @columnfractions .15 .70
1974 @item @var{x} @tab Interoperable function or pointer to such function.
1975 @end multitable
1977 @item @emph{Return value}:
1978 The return value is of type @code{C_FUNPTR} and contains the C address
1979 of the argument.
1981 @item @emph{Example}:
1982 @smallexample
1983 module x
1984   use iso_c_binding
1985   implicit none
1986 contains
1987   subroutine sub(a) bind(c)
1988     real(c_float) :: a
1989     a = sqrt(a)+5.0
1990   end subroutine sub
1991 end module x
1992 program main
1993   use iso_c_binding
1994   use x
1995   implicit none
1996   interface
1997     subroutine my_routine(p) bind(c,name='myC_func')
1998       import :: c_funptr
1999       type(c_funptr), intent(in) :: p
2000     end subroutine
2001   end interface
2002   call my_routine(c_funloc(sub))
2003 end program main
2004 @end smallexample
2006 @item @emph{See also}:
2007 @ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2008 @end table
2011 @node C_F_PROCPOINTER
2012 @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
2013 @fnindex C_F_PROCPOINTER
2014 @cindex pointer, C address of pointers
2016 @table @asis
2017 @item @emph{Description}:
2018 @code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
2019 @var{CPTR} to the Fortran procedure pointer @var{FPTR}.
2021 @item @emph{Standard}:
2022 Fortran 2003 and later
2024 @item @emph{Class}:
2025 Subroutine
2027 @item @emph{Syntax}:
2028 @code{CALL C_F_PROCPOINTER(cptr, fptr)}
2030 @item @emph{Arguments}:
2031 @multitable @columnfractions .15 .70
2032 @item @var{CPTR}  @tab scalar of the type @code{C_FUNPTR}. It is
2033 @code{INTENT(IN)}.
2034 @item @var{FPTR}  @tab procedure pointer interoperable with @var{cptr}. It is
2035 @code{INTENT(OUT)}.
2036 @end multitable
2038 @item @emph{Example}:
2039 @smallexample
2040 program main
2041   use iso_c_binding
2042   implicit none
2043   abstract interface
2044     function func(a)
2045       import :: c_float
2046       real(c_float), intent(in) :: a
2047       real(c_float) :: func
2048     end function
2049   end interface
2050   interface
2051      function getIterFunc() bind(c,name="getIterFunc")
2052        import :: c_funptr
2053        type(c_funptr) :: getIterFunc
2054      end function
2055   end interface
2056   type(c_funptr) :: cfunptr
2057   procedure(func), pointer :: myFunc
2058   cfunptr = getIterFunc()
2059   call c_f_procpointer(cfunptr, myFunc)
2060 end program main
2061 @end smallexample
2063 @item @emph{See also}:
2064 @ref{C_LOC}, @ref{C_F_POINTER}
2065 @end table
2068 @node C_F_POINTER
2069 @section @code{C_F_POINTER} --- Convert C into Fortran pointer
2070 @fnindex C_F_POINTER
2071 @cindex pointer, convert C to Fortran
2073 @table @asis
2074 @item @emph{Description}:
2075 @code{C_F_POINTER(CPTR, FPTR[, SHAPE])} Assign the target the C pointer
2076 @var{CPTR} to the Fortran pointer @var{FPTR} and specify its
2077 shape.
2079 @item @emph{Standard}:
2080 Fortran 2003 and later
2082 @item @emph{Class}:
2083 Subroutine
2085 @item @emph{Syntax}:
2086 @code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
2088 @item @emph{Arguments}:
2089 @multitable @columnfractions .15 .70
2090 @item @var{CPTR}  @tab scalar of the type @code{C_PTR}. It is
2091 @code{INTENT(IN)}.
2092 @item @var{FPTR}  @tab pointer interoperable with @var{cptr}. It is
2093 @code{INTENT(OUT)}.
2094 @item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
2095 with @code{INTENT(IN)}. It shall be present
2096 if and only if @var{fptr} is an array. The size
2097 must be equal to the rank of @var{fptr}.
2098 @end multitable
2100 @item @emph{Example}:
2101 @smallexample
2102 program main
2103   use iso_c_binding
2104   implicit none
2105   interface
2106     subroutine my_routine(p) bind(c,name='myC_func')
2107       import :: c_ptr
2108       type(c_ptr), intent(out) :: p
2109     end subroutine
2110   end interface
2111   type(c_ptr) :: cptr
2112   real,pointer :: a(:)
2113   call my_routine(cptr)
2114   call c_f_pointer(cptr, a, [12])
2115 end program main
2116 @end smallexample
2118 @item @emph{See also}:
2119 @ref{C_LOC}, @ref{C_F_PROCPOINTER}
2120 @end table
2123 @node C_LOC
2124 @section @code{C_LOC} --- Obtain the C address of an object
2125 @fnindex C_LOC
2126 @cindex procedure pointer, convert C to Fortran
2128 @table @asis
2129 @item @emph{Description}:
2130 @code{C_LOC(X)} determines the C address of the argument.
2132 @item @emph{Standard}:
2133 Fortran 2003 and later
2135 @item @emph{Class}:
2136 Inquiry function
2138 @item @emph{Syntax}:
2139 @code{RESULT = C_LOC(X)}
2141 @item @emph{Arguments}:
2142 @multitable @columnfractions .15 .70
2143 @item @var{X} @tab Associated scalar pointer or interoperable scalar
2144 or allocated allocatable variable with @code{TARGET} attribute.
2145 @end multitable
2147 @item @emph{Return value}:
2148 The return value is of type @code{C_PTR} and contains the C address
2149 of the argument.
2151 @item @emph{Example}:
2152 @smallexample
2153 subroutine association_test(a,b)
2154   use iso_c_binding, only: c_associated, c_loc, c_ptr
2155   implicit none
2156   real, pointer :: a
2157   type(c_ptr) :: b
2158   if(c_associated(b, c_loc(a))) &
2159      stop 'b and a do not point to same target'
2160 end subroutine association_test
2161 @end smallexample
2163 @item @emph{See also}:
2164 @ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2165 @end table
2168 @node C_SIZEOF
2169 @section @code{C_SIZEOF} --- Size in bytes of an expression
2170 @fnindex C_SIZEOF
2171 @cindex expression size
2172 @cindex size of an expression
2174 @table @asis
2175 @item @emph{Description}:
2176 @code{C_SIZEOF(X)} calculates the number of bytes of storage the
2177 expression @code{X} occupies.
2179 @item @emph{Standard}:
2180 Fortran 2008
2182 @item @emph{Class}:
2183 Intrinsic function
2185 @item @emph{Syntax}:
2186 @code{N = C_SIZEOF(X)}
2188 @item @emph{Arguments}:
2189 @multitable @columnfractions .15 .70
2190 @item @var{X} @tab The argument shall be of any type, rank or shape.
2191 @end multitable
2193 @item @emph{Return value}:
2194 The return value is of type integer and of the system-dependent kind
2195 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
2196 number of bytes occupied by the argument.  If the argument has the
2197 @code{POINTER} attribute, the number of bytes of the storage area pointed
2198 to is returned.  If the argument is of a derived type with @code{POINTER}
2199 or @code{ALLOCATABLE} components, the return value doesn't account for
2200 the sizes of the data pointed to by these components.
2202 @item @emph{Example}:
2203 @smallexample
2204    use iso_c_binding
2205    integer(c_int) :: i
2206    real(c_float) :: r, s(5)
2207    print *, (c_sizeof(s)/c_sizeof(r) == 5)
2208    end
2209 @end smallexample
2210 The example will print @code{.TRUE.} unless you are using a platform
2211 where default @code{REAL} variables are unusually padded.
2213 @item @emph{See also}:
2214 @ref{SIZEOF}
2215 @end table
2218 @node CEILING
2219 @section @code{CEILING} --- Integer ceiling function
2220 @fnindex CEILING
2221 @cindex ceiling
2222 @cindex rounding, ceiling
2224 @table @asis
2225 @item @emph{Description}:
2226 @code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
2228 @item @emph{Standard}:
2229 Fortran 95 and later
2231 @item @emph{Class}:
2232 Elemental function
2234 @item @emph{Syntax}:
2235 @code{RESULT = CEILING(A [, KIND])}
2237 @item @emph{Arguments}:
2238 @multitable @columnfractions .15 .70
2239 @item @var{A} @tab The type shall be @code{REAL}.
2240 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2241 expression indicating the kind parameter of the result.
2242 @end multitable
2244 @item @emph{Return value}:
2245 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
2246 and a default-kind @code{INTEGER} otherwise.
2248 @item @emph{Example}:
2249 @smallexample
2250 program test_ceiling
2251     real :: x = 63.29
2252     real :: y = -63.59
2253     print *, ceiling(x) ! returns 64
2254     print *, ceiling(y) ! returns -63
2255 end program test_ceiling
2256 @end smallexample
2258 @item @emph{See also}:
2259 @ref{FLOOR}, @ref{NINT}
2261 @end table
2265 @node CHAR
2266 @section @code{CHAR} --- Character conversion function
2267 @fnindex CHAR
2268 @cindex conversion, to character
2270 @table @asis
2271 @item @emph{Description}:
2272 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
2274 @item @emph{Standard}:
2275 Fortran 77 and later
2277 @item @emph{Class}:
2278 Elemental function
2280 @item @emph{Syntax}:
2281 @code{RESULT = CHAR(I [, KIND])}
2283 @item @emph{Arguments}:
2284 @multitable @columnfractions .15 .70
2285 @item @var{I} @tab The type shall be @code{INTEGER}.
2286 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2287 expression indicating the kind parameter of the result.
2288 @end multitable
2290 @item @emph{Return value}:
2291 The return value is of type @code{CHARACTER(1)}
2293 @item @emph{Example}:
2294 @smallexample
2295 program test_char
2296     integer :: i = 74
2297     character(1) :: c
2298     c = char(i)
2299     print *, i, c ! returns 'J'
2300 end program test_char
2301 @end smallexample
2303 @item @emph{Specific names}:
2304 @multitable @columnfractions .20 .20 .20 .25
2305 @item Name           @tab Argument         @tab Return type             @tab Standard
2306 @item @code{CHAR(I)} @tab @code{INTEGER I} @tab @code{CHARACTER(LEN=1)} @tab F77 and later
2307 @end multitable
2309 @item @emph{Note}:
2310 See @ref{ICHAR} for a discussion of converting between numerical values
2311 and formatted string representations.
2313 @item @emph{See also}:
2314 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
2316 @end table
2320 @node CHDIR
2321 @section @code{CHDIR} --- Change working directory
2322 @fnindex CHDIR
2323 @cindex system, working directory
2325 @table @asis
2326 @item @emph{Description}:
2327 Change current working directory to a specified path.
2329 This intrinsic is provided in both subroutine and function forms; however,
2330 only one form can be used in any given program unit.
2332 @item @emph{Standard}:
2333 GNU extension
2335 @item @emph{Class}:
2336 Subroutine, function
2338 @item @emph{Syntax}:
2339 @multitable @columnfractions .80
2340 @item @code{CALL CHDIR(NAME [, STATUS])}
2341 @item @code{STATUS = CHDIR(NAME)}
2342 @end multitable
2344 @item @emph{Arguments}:
2345 @multitable @columnfractions .15 .70
2346 @item @var{NAME}   @tab The type shall be @code{CHARACTER} of default
2347 kind and shall specify a valid path within the file system.
2348 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
2349 kind.  Returns 0 on success, and a system specific and nonzero error code
2350 otherwise.
2351 @end multitable
2353 @item @emph{Example}:
2354 @smallexample
2355 PROGRAM test_chdir
2356   CHARACTER(len=255) :: path
2357   CALL getcwd(path)
2358   WRITE(*,*) TRIM(path)
2359   CALL chdir("/tmp")
2360   CALL getcwd(path)
2361   WRITE(*,*) TRIM(path)
2362 END PROGRAM
2363 @end smallexample
2365 @item @emph{See also}:
2366 @ref{GETCWD}
2367 @end table
2371 @node CHMOD
2372 @section @code{CHMOD} --- Change access permissions of files
2373 @fnindex CHMOD
2374 @cindex file system, change access mode
2376 @table @asis
2377 @item @emph{Description}:
2378 @code{CHMOD} changes the permissions of a file. This function invokes
2379 @code{/bin/chmod} and might therefore not work on all platforms.
2381 This intrinsic is provided in both subroutine and function forms; however,
2382 only one form can be used in any given program unit.
2384 @item @emph{Standard}:
2385 GNU extension
2387 @item @emph{Class}:
2388 Subroutine, function
2390 @item @emph{Syntax}:
2391 @multitable @columnfractions .80
2392 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
2393 @item @code{STATUS = CHMOD(NAME, MODE)}
2394 @end multitable
2396 @item @emph{Arguments}:
2397 @multitable @columnfractions .15 .70
2399 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
2400 file name. Trailing blanks are ignored unless the character
2401 @code{achar(0)} is present, then all characters up to and excluding
2402 @code{achar(0)} are used as the file name.
2404 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
2405 file permission. @var{MODE} uses the same syntax as the @var{MODE}
2406 argument of @code{/bin/chmod}.
2408 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
2409 @code{0} on success and nonzero otherwise.
2410 @end multitable
2412 @item @emph{Return value}:
2413 In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
2414 otherwise.
2416 @item @emph{Example}:
2417 @code{CHMOD} as subroutine
2418 @smallexample
2419 program chmod_test
2420   implicit none
2421   integer :: status
2422   call chmod('test.dat','u+x',status)
2423   print *, 'Status: ', status
2424 end program chmod_test
2425 @end smallexample
2426 @code{CHMOD} as function:
2427 @smallexample
2428 program chmod_test
2429   implicit none
2430   integer :: status
2431   status = chmod('test.dat','u+x')
2432   print *, 'Status: ', status
2433 end program chmod_test
2434 @end smallexample
2436 @end table
2440 @node CMPLX
2441 @section @code{CMPLX} --- Complex conversion function
2442 @fnindex CMPLX
2443 @cindex complex numbers, conversion to
2444 @cindex conversion, to complex
2446 @table @asis
2447 @item @emph{Description}:
2448 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
2449 the real component.  If @var{Y} is present it is converted to the imaginary
2450 component.  If @var{Y} is not present then the imaginary component is set to
2451 0.0.  If @var{X} is complex then @var{Y} must not be present.
2453 @item @emph{Standard}:
2454 Fortran 77 and later
2456 @item @emph{Class}:
2457 Elemental function
2459 @item @emph{Syntax}:
2460 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2462 @item @emph{Arguments}:
2463 @multitable @columnfractions .15 .70
2464 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
2465 or @code{COMPLEX}.
2466 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2467 @code{COMPLEX}.)  May be @code{INTEGER} or @code{REAL}.
2468 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2469 expression indicating the kind parameter of the result.
2470 @end multitable
2472 @item @emph{Return value}:
2473 The return value is of @code{COMPLEX} type, with a kind equal to
2474 @var{KIND} if it is specified.  If @var{KIND} is not specified, the
2475 result is of the default @code{COMPLEX} kind, regardless of the kinds of
2476 @var{X} and @var{Y}. 
2478 @item @emph{Example}:
2479 @smallexample
2480 program test_cmplx
2481     integer :: i = 42
2482     real :: x = 3.14
2483     complex :: z
2484     z = cmplx(i, x)
2485     print *, z, cmplx(x)
2486 end program test_cmplx
2487 @end smallexample
2489 @item @emph{See also}:
2490 @ref{COMPLEX}
2491 @end table
2495 @node COMMAND_ARGUMENT_COUNT
2496 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2497 @fnindex COMMAND_ARGUMENT_COUNT
2498 @cindex command-line arguments
2499 @cindex command-line arguments, number of
2500 @cindex arguments, to program
2502 @table @asis
2503 @item @emph{Description}:
2504 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2505 command line when the containing program was invoked.
2507 @item @emph{Standard}:
2508 Fortran 2003 and later
2510 @item @emph{Class}:
2511 Inquiry function
2513 @item @emph{Syntax}:
2514 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2516 @item @emph{Arguments}:
2517 @multitable @columnfractions .15 .70
2518 @item None
2519 @end multitable
2521 @item @emph{Return value}:
2522 The return value is an @code{INTEGER} of default kind.
2524 @item @emph{Example}:
2525 @smallexample
2526 program test_command_argument_count
2527     integer :: count
2528     count = command_argument_count()
2529     print *, count
2530 end program test_command_argument_count
2531 @end smallexample
2533 @item @emph{See also}:
2534 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2535 @end table
2539 @node COMPLEX
2540 @section @code{COMPLEX} --- Complex conversion function
2541 @fnindex COMPLEX
2542 @cindex complex numbers, conversion to
2543 @cindex conversion, to complex
2545 @table @asis
2546 @item @emph{Description}:
2547 @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
2548 to the real component and @var{Y} is converted to the imaginary
2549 component.
2551 @item @emph{Standard}:
2552 GNU extension
2554 @item @emph{Class}:
2555 Elemental function
2557 @item @emph{Syntax}:
2558 @code{RESULT = COMPLEX(X, Y)}
2560 @item @emph{Arguments}:
2561 @multitable @columnfractions .15 .70
2562 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
2563 @item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
2564 @end multitable
2566 @item @emph{Return value}:
2567 If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
2568 value is of default @code{COMPLEX} type.
2570 If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
2571 type and one is of @code{INTEGER} type, then the return value is of
2572 @code{COMPLEX} type with a kind equal to that of the @code{REAL}
2573 argument with the highest precision.  
2575 @item @emph{Example}:
2576 @smallexample
2577 program test_complex
2578     integer :: i = 42
2579     real :: x = 3.14
2580     print *, complex(i, x)
2581 end program test_complex
2582 @end smallexample
2584 @item @emph{See also}:
2585 @ref{CMPLX}
2586 @end table
2590 @node CONJG
2591 @section @code{CONJG} --- Complex conjugate function 
2592 @fnindex CONJG
2593 @fnindex DCONJG
2594 @cindex complex conjugate
2596 @table @asis
2597 @item @emph{Description}:
2598 @code{CONJG(Z)} returns the conjugate of @var{Z}.  If @var{Z} is @code{(x, y)}
2599 then the result is @code{(x, -y)}
2601 @item @emph{Standard}:
2602 Fortran 77 and later, has overloads that are GNU extensions
2604 @item @emph{Class}:
2605 Elemental function
2607 @item @emph{Syntax}:
2608 @code{Z = CONJG(Z)}
2610 @item @emph{Arguments}:
2611 @multitable @columnfractions .15 .70
2612 @item @var{Z} @tab The type shall be @code{COMPLEX}.
2613 @end multitable
2615 @item @emph{Return value}:
2616 The return value is of type @code{COMPLEX}.
2618 @item @emph{Example}:
2619 @smallexample
2620 program test_conjg
2621     complex :: z = (2.0, 3.0)
2622     complex(8) :: dz = (2.71_8, -3.14_8)
2623     z= conjg(z)
2624     print *, z
2625     dz = dconjg(dz)
2626     print *, dz
2627 end program test_conjg
2628 @end smallexample
2630 @item @emph{Specific names}:
2631 @multitable @columnfractions .20 .20 .20 .25
2632 @item Name             @tab Argument             @tab Return type       @tab Standard
2633 @item @code{CONJG(Z)}  @tab @code{COMPLEX Z}     @tab @code{COMPLEX}    @tab GNU extension
2634 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z}  @tab @code{COMPLEX(8)} @tab GNU extension
2635 @end multitable
2636 @end table
2640 @node COS
2641 @section @code{COS} --- Cosine function 
2642 @fnindex COS
2643 @fnindex DCOS
2644 @fnindex CCOS
2645 @fnindex ZCOS
2646 @fnindex CDCOS
2647 @cindex trigonometric function, cosine
2648 @cindex cosine
2650 @table @asis
2651 @item @emph{Description}:
2652 @code{COS(X)} computes the cosine of @var{X}.
2654 @item @emph{Standard}:
2655 Fortran 77 and later, has overloads that are GNU extensions
2657 @item @emph{Class}:
2658 Elemental function
2660 @item @emph{Syntax}:
2661 @code{RESULT = COS(X)}
2663 @item @emph{Arguments}:
2664 @multitable @columnfractions .15 .70
2665 @item @var{X} @tab The type shall be @code{REAL} or
2666 @code{COMPLEX}.
2667 @end multitable
2669 @item @emph{Return value}:
2670 The return value is of the same type and kind as @var{X}. The real part
2671 of the result is in radians. If @var{X} is of the type @code{REAL},
2672 the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}.
2674 @item @emph{Example}:
2675 @smallexample
2676 program test_cos
2677   real :: x = 0.0
2678   x = cos(x)
2679 end program test_cos
2680 @end smallexample
2682 @item @emph{Specific names}:
2683 @multitable @columnfractions .20 .20 .20 .25
2684 @item Name            @tab Argument            @tab Return type       @tab Standard
2685 @item @code{COS(X)}  n@tab @code{REAL(4) X}    @tab @code{REAL(4)}    @tab Fortran 77 and later
2686 @item @code{DCOS(X)}  @tab @code{REAL(8) X}    @tab @code{REAL(8)}    @tab Fortran 77 and later
2687 @item @code{CCOS(X)}  @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
2688 @item @code{ZCOS(X)}  @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2689 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2690 @end multitable
2692 @item @emph{See also}:
2693 Inverse function: @ref{ACOS}
2695 @end table
2699 @node COSH
2700 @section @code{COSH} --- Hyperbolic cosine function 
2701 @fnindex COSH
2702 @fnindex DCOSH
2703 @cindex hyperbolic cosine
2704 @cindex hyperbolic function, cosine
2705 @cindex cosine, hyperbolic
2707 @table @asis
2708 @item @emph{Description}:
2709 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2711 @item @emph{Standard}:
2712 Fortran 77 and later, for a complex argument Fortran 2008 or later
2714 @item @emph{Class}:
2715 Elemental function
2717 @item @emph{Syntax}:
2718 @code{X = COSH(X)}
2720 @item @emph{Arguments}:
2721 @multitable @columnfractions .15 .70
2722 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
2723 @end multitable
2725 @item @emph{Return value}:
2726 The return value has same type and kind as @var{X}. If @var{X} is
2727 complex, the imaginary part of the result is in radians. If @var{X}
2728 is @code{REAL}, the return value has a lower bound of one,
2729 @math{\cosh (x) \geq 1}.
2731 @item @emph{Example}:
2732 @smallexample
2733 program test_cosh
2734   real(8) :: x = 1.0_8
2735   x = cosh(x)
2736 end program test_cosh
2737 @end smallexample
2739 @item @emph{Specific names}:
2740 @multitable @columnfractions .20 .20 .20 .25
2741 @item Name            @tab Argument          @tab Return type       @tab Standard
2742 @item @code{COSH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
2743 @item @code{DCOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
2744 @end multitable
2746 @item @emph{See also}:
2747 Inverse function: @ref{ACOSH}
2749 @end table
2753 @node COUNT
2754 @section @code{COUNT} --- Count function
2755 @fnindex COUNT
2756 @cindex array, conditionally count elements
2757 @cindex array, element counting
2758 @cindex array, number of elements
2760 @table @asis
2761 @item @emph{Description}:
2763 Counts the number of @code{.TRUE.} elements in a logical @var{MASK},
2764 or, if the @var{DIM} argument is supplied, counts the number of
2765 elements along each row of the array in the @var{DIM} direction.
2766 If the array has zero size, or all of the elements of @var{MASK} are
2767 @code{.FALSE.}, then the result is @code{0}.
2769 @item @emph{Standard}:
2770 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
2772 @item @emph{Class}:
2773 Transformational function
2775 @item @emph{Syntax}:
2776 @code{RESULT = COUNT(MASK [, DIM, KIND])}
2778 @item @emph{Arguments}:
2779 @multitable @columnfractions .15 .70
2780 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2781 @item @var{DIM}  @tab (Optional) The type shall be @code{INTEGER}.
2782 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2783 expression indicating the kind parameter of the result.
2784 @end multitable
2786 @item @emph{Return value}:
2787 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
2788 @var{KIND} is absent, the return value is of default integer kind.
2789 If @var{DIM} is present, the result is an array with a rank one less
2790 than the rank of @var{ARRAY}, and a size corresponding to the shape
2791 of @var{ARRAY} with the @var{DIM} dimension removed.
2793 @item @emph{Example}:
2794 @smallexample
2795 program test_count
2796     integer, dimension(2,3) :: a, b
2797     logical, dimension(2,3) :: mask
2798     a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2799     b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2800     print '(3i3)', a(1,:)
2801     print '(3i3)', a(2,:)
2802     print *
2803     print '(3i3)', b(1,:)
2804     print '(3i3)', b(2,:)
2805     print *
2806     mask = a.ne.b
2807     print '(3l3)', mask(1,:)
2808     print '(3l3)', mask(2,:)
2809     print *
2810     print '(3i3)', count(mask)
2811     print *
2812     print '(3i3)', count(mask, 1)
2813     print *
2814     print '(3i3)', count(mask, 2)
2815 end program test_count
2816 @end smallexample
2817 @end table
2821 @node CPU_TIME
2822 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2823 @fnindex CPU_TIME
2824 @cindex time, elapsed
2826 @table @asis
2827 @item @emph{Description}:
2828 Returns a @code{REAL} value representing the elapsed CPU time in
2829 seconds.  This is useful for testing segments of code to determine
2830 execution time.
2832 If a time source is available, time will be reported with microsecond
2833 resolution. If no time source is available, @var{TIME} is set to
2834 @code{-1.0}.
2836 Note that @var{TIME} may contain a, system dependent, arbitrary offset
2837 and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
2838 value is meaningless, only differences between subsequent calls to
2839 this subroutine, as shown in the example below, should be used.
2842 @item @emph{Standard}:
2843 Fortran 95 and later
2845 @item @emph{Class}:
2846 Subroutine
2848 @item @emph{Syntax}:
2849 @code{CALL CPU_TIME(TIME)}
2851 @item @emph{Arguments}:
2852 @multitable @columnfractions .15 .70
2853 @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2854 @end multitable
2856 @item @emph{Return value}:
2857 None
2859 @item @emph{Example}:
2860 @smallexample
2861 program test_cpu_time
2862     real :: start, finish
2863     call cpu_time(start)
2864         ! put code to test here
2865     call cpu_time(finish)
2866     print '("Time = ",f6.3," seconds.")',finish-start
2867 end program test_cpu_time
2868 @end smallexample
2870 @item @emph{See also}:
2871 @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
2872 @end table
2876 @node CSHIFT
2877 @section @code{CSHIFT} --- Circular shift elements of an array
2878 @fnindex CSHIFT
2879 @cindex array, shift circularly
2880 @cindex array, permutation
2881 @cindex array, rotate
2883 @table @asis
2884 @item @emph{Description}:
2885 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2886 @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is omitted it is
2887 taken to be @code{1}.  @var{DIM} is a scalar of type @code{INTEGER} in the
2888 range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}.
2889 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2890 by @var{SHIFT} places.  If rank is greater than one, then all complete rank one
2891 sections of @var{ARRAY} along the given dimension are shifted.  Elements
2892 shifted out one end of each rank one section are shifted back in the other end.
2894 @item @emph{Standard}:
2895 Fortran 95 and later
2897 @item @emph{Class}:
2898 Transformational function
2900 @item @emph{Syntax}:
2901 @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
2903 @item @emph{Arguments}:
2904 @multitable @columnfractions .15 .70
2905 @item @var{ARRAY}  @tab Shall be an array of any type.
2906 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
2907 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
2908 @end multitable
2910 @item @emph{Return value}:
2911 Returns an array of same type and rank as the @var{ARRAY} argument.
2913 @item @emph{Example}:
2914 @smallexample
2915 program test_cshift
2916     integer, dimension(3,3) :: a
2917     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2918     print '(3i3)', a(1,:)
2919     print '(3i3)', a(2,:)
2920     print '(3i3)', a(3,:)    
2921     a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2922     print *
2923     print '(3i3)', a(1,:)
2924     print '(3i3)', a(2,:)
2925     print '(3i3)', a(3,:)
2926 end program test_cshift
2927 @end smallexample
2928 @end table
2932 @node CTIME
2933 @section @code{CTIME} --- Convert a time into a string
2934 @fnindex CTIME
2935 @cindex time, conversion to string
2936 @cindex conversion, to string
2938 @table @asis
2939 @item @emph{Description}:
2940 @code{CTIME} converts a system time value, such as returned by
2941 @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14 1995}.
2943 This intrinsic is provided in both subroutine and function forms; however,
2944 only one form can be used in any given program unit.
2946 @item @emph{Standard}:
2947 GNU extension
2949 @item @emph{Class}:
2950 Subroutine, function
2952 @item @emph{Syntax}:
2953 @multitable @columnfractions .80
2954 @item @code{CALL CTIME(TIME, RESULT)}.
2955 @item @code{RESULT = CTIME(TIME)}, (not recommended).
2956 @end multitable
2958 @item @emph{Arguments}:
2959 @multitable @columnfractions .15 .70
2960 @item @var{TIME}    @tab The type shall be of type @code{INTEGER(KIND=8)}.
2961 @item @var{RESULT}  @tab The type shall be of type @code{CHARACTER} and
2962 of default kind.
2963 @end multitable
2965 @item @emph{Return value}:
2966 The converted date and time as a string.
2968 @item @emph{Example}:
2969 @smallexample
2970 program test_ctime
2971     integer(8) :: i
2972     character(len=30) :: date
2973     i = time8()
2975     ! Do something, main part of the program
2976     
2977     call ctime(i,date)
2978     print *, 'Program was started on ', date
2979 end program test_ctime
2980 @end smallexample
2982 @item @emph{See Also}:
2983 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2984 @end table
2988 @node DATE_AND_TIME
2989 @section @code{DATE_AND_TIME} --- Date and time subroutine
2990 @fnindex DATE_AND_TIME
2991 @cindex date, current
2992 @cindex current date
2993 @cindex time, current
2994 @cindex current time
2996 @table @asis
2997 @item @emph{Description}:
2998 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2999 time information from the real-time system clock.  @var{DATE} is
3000 @code{INTENT(OUT)} and has form ccyymmdd.  @var{TIME} is @code{INTENT(OUT)} and
3001 has form hhmmss.sss.  @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
3002 representing the difference with respect to Coordinated Universal Time (UTC).
3003 Unavailable time and date parameters return blanks.
3005 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
3007 @multitable @columnfractions .15 .30 .40
3008 @item @tab @code{VALUE(1)}: @tab The year
3009 @item @tab @code{VALUE(2)}: @tab The month
3010 @item @tab @code{VALUE(3)}: @tab The day of the month
3011 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
3012 @item @tab @code{VALUE(5)}: @tab The hour of the day
3013 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
3014 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
3015 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
3016 @end multitable
3018 @item @emph{Standard}:
3019 Fortran 95 and later
3021 @item @emph{Class}:
3022 Subroutine
3024 @item @emph{Syntax}:
3025 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
3027 @item @emph{Arguments}:
3028 @multitable @columnfractions .15 .70
3029 @item @var{DATE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
3030 or larger, and of default kind.
3031 @item @var{TIME}  @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
3032 or larger, and of default kind.
3033 @item @var{ZONE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
3034 or larger, and of default kind.
3035 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
3036 @end multitable
3038 @item @emph{Return value}:
3039 None
3041 @item @emph{Example}:
3042 @smallexample
3043 program test_time_and_date
3044     character(8)  :: date
3045     character(10) :: time
3046     character(5)  :: zone
3047     integer,dimension(8) :: values
3048     ! using keyword arguments
3049     call date_and_time(date,time,zone,values)
3050     call date_and_time(DATE=date,ZONE=zone)
3051     call date_and_time(TIME=time)
3052     call date_and_time(VALUES=values)
3053     print '(a,2x,a,2x,a)', date, time, zone
3054     print '(8i5))', values
3055 end program test_time_and_date
3056 @end smallexample
3058 @item @emph{See also}:
3059 @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
3060 @end table
3064 @node DBLE
3065 @section @code{DBLE} --- Double conversion function 
3066 @fnindex DBLE
3067 @cindex conversion, to real
3069 @table @asis
3070 @item @emph{Description}:
3071 @code{DBLE(A)} Converts @var{A} to double precision real type.
3073 @item @emph{Standard}:
3074 Fortran 77 and later
3076 @item @emph{Class}:
3077 Elemental function
3079 @item @emph{Syntax}:
3080 @code{RESULT = DBLE(A)}
3082 @item @emph{Arguments}:
3083 @multitable @columnfractions .15 .70
3084 @item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
3085 or @code{COMPLEX}.
3086 @end multitable
3088 @item @emph{Return value}:
3089 The return value is of type double precision real.
3091 @item @emph{Example}:
3092 @smallexample
3093 program test_dble
3094     real    :: x = 2.18
3095     integer :: i = 5
3096     complex :: z = (2.3,1.14)
3097     print *, dble(x), dble(i), dble(z)
3098 end program test_dble
3099 @end smallexample
3101 @item @emph{See also}:
3102 @ref{REAL}
3103 @end table
3107 @node DCMPLX
3108 @section @code{DCMPLX} --- Double complex conversion function
3109 @fnindex DCMPLX
3110 @cindex complex numbers, conversion to
3111 @cindex conversion, to complex
3113 @table @asis
3114 @item @emph{Description}:
3115 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
3116 converted to the real component.  If @var{Y} is present it is converted to the
3117 imaginary component.  If @var{Y} is not present then the imaginary component is
3118 set to 0.0.  If @var{X} is complex then @var{Y} must not be present.
3120 @item @emph{Standard}:
3121 GNU extension
3123 @item @emph{Class}:
3124 Elemental function
3126 @item @emph{Syntax}:
3127 @code{RESULT = DCMPLX(X [, Y])}
3129 @item @emph{Arguments}:
3130 @multitable @columnfractions .15 .70
3131 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
3132 or @code{COMPLEX}.
3133 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
3134 @code{INTEGER} or @code{REAL}. 
3135 @end multitable
3137 @item @emph{Return value}:
3138 The return value is of type @code{COMPLEX(8)}
3140 @item @emph{Example}:
3141 @smallexample
3142 program test_dcmplx
3143     integer :: i = 42
3144     real :: x = 3.14
3145     complex :: z
3146     z = cmplx(i, x)
3147     print *, dcmplx(i)
3148     print *, dcmplx(x)
3149     print *, dcmplx(z)
3150     print *, dcmplx(x,i)
3151 end program test_dcmplx
3152 @end smallexample
3153 @end table
3156 @node DIGITS
3157 @section @code{DIGITS} --- Significant binary digits function
3158 @fnindex DIGITS
3159 @cindex model representation, significant digits
3161 @table @asis
3162 @item @emph{Description}:
3163 @code{DIGITS(X)} returns the number of significant binary digits of the internal
3164 model representation of @var{X}.  For example, on a system using a 32-bit
3165 floating point representation, a default real number would likely return 24.
3167 @item @emph{Standard}:
3168 Fortran 95 and later
3170 @item @emph{Class}:
3171 Inquiry function
3173 @item @emph{Syntax}:
3174 @code{RESULT = DIGITS(X)}
3176 @item @emph{Arguments}:
3177 @multitable @columnfractions .15 .70
3178 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
3179 @end multitable
3181 @item @emph{Return value}:
3182 The return value is of type @code{INTEGER}.
3184 @item @emph{Example}:
3185 @smallexample
3186 program test_digits
3187     integer :: i = 12345
3188     real :: x = 3.143
3189     real(8) :: y = 2.33
3190     print *, digits(i)
3191     print *, digits(x)
3192     print *, digits(y)
3193 end program test_digits
3194 @end smallexample
3195 @end table
3199 @node DIM
3200 @section @code{DIM} --- Positive difference
3201 @fnindex DIM
3202 @fnindex IDIM
3203 @fnindex DDIM
3204 @cindex positive difference
3206 @table @asis
3207 @item @emph{Description}:
3208 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
3209 otherwise returns zero.
3211 @item @emph{Standard}:
3212 Fortran 77 and later
3214 @item @emph{Class}:
3215 Elemental function
3217 @item @emph{Syntax}:
3218 @code{RESULT = DIM(X, Y)}
3220 @item @emph{Arguments}:
3221 @multitable @columnfractions .15 .70
3222 @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
3223 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
3224 @end multitable
3226 @item @emph{Return value}:
3227 The return value is of type @code{INTEGER} or @code{REAL}.
3229 @item @emph{Example}:
3230 @smallexample
3231 program test_dim
3232     integer :: i
3233     real(8) :: x
3234     i = dim(4, 15)
3235     x = dim(4.345_8, 2.111_8)
3236     print *, i
3237     print *, x
3238 end program test_dim
3239 @end smallexample
3241 @item @emph{Specific names}:
3242 @multitable @columnfractions .20 .20 .20 .25
3243 @item Name             @tab Argument               @tab Return type       @tab Standard
3244 @item @code{DIM(X,Y)}  @tab @code{REAL(4) X, Y}    @tab @code{REAL(4)}    @tab Fortran 77 and later
3245 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X, Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
3246 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X, Y}    @tab @code{REAL(8)}    @tab Fortran 77 and later
3247 @end multitable
3248 @end table
3252 @node DOT_PRODUCT
3253 @section @code{DOT_PRODUCT} --- Dot product function
3254 @fnindex DOT_PRODUCT
3255 @cindex dot product
3256 @cindex vector product
3257 @cindex product, vector
3259 @table @asis
3260 @item @emph{Description}:
3261 @code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
3262 of two vectors @var{VECTOR_A} and @var{VECTOR_B}.  The two vectors may be
3263 either numeric or logical and must be arrays of rank one and of equal size. If
3264 the vectors are @code{INTEGER} or @code{REAL}, the result is
3265 @code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
3266 is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
3267 the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.  
3269 @item @emph{Standard}:
3270 Fortran 95 and later
3272 @item @emph{Class}:
3273 Transformational function
3275 @item @emph{Syntax}:
3276 @code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
3278 @item @emph{Arguments}:
3279 @multitable @columnfractions .15 .70
3280 @item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
3281 @item @var{VECTOR_B} @tab The type shall be numeric if @var{VECTOR_A} is of numeric type or @code{LOGICAL} if @var{VECTOR_A} is of type @code{LOGICAL}. @var{VECTOR_B} shall be a rank-one array.
3282 @end multitable
3284 @item @emph{Return value}:
3285 If the arguments are numeric, the return value is a scalar of numeric type,
3286 @code{INTEGER}, @code{REAL}, or @code{COMPLEX}.  If the arguments are
3287 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
3289 @item @emph{Example}:
3290 @smallexample
3291 program test_dot_prod
3292     integer, dimension(3) :: a, b
3293     a = (/ 1, 2, 3 /)
3294     b = (/ 4, 5, 6 /)
3295     print '(3i3)', a
3296     print *
3297     print '(3i3)', b
3298     print *
3299     print *, dot_product(a,b)
3300 end program test_dot_prod
3301 @end smallexample
3302 @end table
3306 @node DPROD
3307 @section @code{DPROD} --- Double product function
3308 @fnindex DPROD
3309 @cindex product, double-precision
3311 @table @asis
3312 @item @emph{Description}:
3313 @code{DPROD(X,Y)} returns the product @code{X*Y}.
3315 @item @emph{Standard}:
3316 Fortran 77 and later
3318 @item @emph{Class}:
3319 Elemental function
3321 @item @emph{Syntax}:
3322 @code{RESULT = DPROD(X, Y)}
3324 @item @emph{Arguments}:
3325 @multitable @columnfractions .15 .70
3326 @item @var{X} @tab The type shall be @code{REAL}.
3327 @item @var{Y} @tab The type shall be @code{REAL}.
3328 @end multitable
3330 @item @emph{Return value}:
3331 The return value is of type @code{REAL(8)}.
3333 @item @emph{Example}:
3334 @smallexample
3335 program test_dprod
3336     real :: x = 5.2
3337     real :: y = 2.3
3338     real(8) :: d
3339     d = dprod(x,y)
3340     print *, d
3341 end program test_dprod
3342 @end smallexample
3344 @item @emph{Specific names}:
3345 @multitable @columnfractions .20 .20 .20 .25
3346 @item Name              @tab Argument               @tab Return type       @tab Standard
3347 @item @code{DPROD(X,Y)} @tab @code{REAL(4) X, Y}    @tab @code{REAL(4)}    @tab Fortran 77 and later
3348 @end multitable
3350 @end table
3353 @node DREAL
3354 @section @code{DREAL} --- Double real part function
3355 @fnindex DREAL
3356 @cindex complex numbers, real part
3358 @table @asis
3359 @item @emph{Description}:
3360 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
3362 @item @emph{Standard}:
3363 GNU extension
3365 @item @emph{Class}:
3366 Elemental function
3368 @item @emph{Syntax}:
3369 @code{RESULT = DREAL(A)}
3371 @item @emph{Arguments}:
3372 @multitable @columnfractions .15 .70
3373 @item @var{A} @tab The type shall be @code{COMPLEX(8)}.
3374 @end multitable
3376 @item @emph{Return value}:
3377 The return value is of type @code{REAL(8)}.
3379 @item @emph{Example}:
3380 @smallexample
3381 program test_dreal
3382     complex(8) :: z = (1.3_8,7.2_8)
3383     print *, dreal(z)
3384 end program test_dreal
3385 @end smallexample
3387 @item @emph{See also}:
3388 @ref{AIMAG}
3390 @end table
3394 @node DTIME
3395 @section @code{DTIME} --- Execution time subroutine (or function)
3396 @fnindex DTIME
3397 @cindex time, elapsed
3398 @cindex elapsed time
3400 @table @asis
3401 @item @emph{Description}:
3402 @code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime
3403 since the start of the process's execution in @var{TIME}.  @var{VALUES}
3404 returns the user and system components of this time in @code{VALUES(1)} and
3405 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) +
3406 VALUES(2)}.
3408 Subsequent invocations of @code{DTIME} return values accumulated since the
3409 previous invocation.
3411 On some systems, the underlying timings are represented using types with
3412 sufficiently small limits that overflows (wrap around) are possible, such as
3413 32-bit types. Therefore, the values returned by this intrinsic might be, or
3414 become, negative, or numerically less than previous values, during a single
3415 run of the compiled program.
3417 Please note, that this implementation is thread safe if used within OpenMP
3418 directives, i.e., its state will be consistent while called from multiple
3419 threads. However, if @code{DTIME} is called from multiple threads, the result
3420 is still the time since the last invocation. This may not give the intended
3421 results. If possible, use @code{CPU_TIME} instead.
3423 This intrinsic is provided in both subroutine and function forms; however,
3424 only one form can be used in any given program unit.
3426 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
3428 @multitable @columnfractions .15 .30 .40
3429 @item @tab @code{VALUES(1)}: @tab User time in seconds.
3430 @item @tab @code{VALUES(2)}: @tab System time in seconds.
3431 @item @tab @code{TIME}: @tab Run time since start in seconds.
3432 @end multitable
3434 @item @emph{Standard}:
3435 GNU extension
3437 @item @emph{Class}:
3438 Subroutine, function
3440 @item @emph{Syntax}:
3441 @multitable @columnfractions .80
3442 @item @code{CALL DTIME(VALUES, TIME)}.
3443 @item @code{TIME = DTIME(VALUES)}, (not recommended).
3444 @end multitable
3446 @item @emph{Arguments}:
3447 @multitable @columnfractions .15 .70
3448 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
3449 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
3450 @end multitable
3452 @item @emph{Return value}:
3453 Elapsed time in seconds since the last invocation or since the start of program
3454 execution if not called before.
3456 @item @emph{Example}:
3457 @smallexample
3458 program test_dtime
3459     integer(8) :: i, j
3460     real, dimension(2) :: tarray
3461     real :: result
3462     call dtime(tarray, result)
3463     print *, result
3464     print *, tarray(1)
3465     print *, tarray(2)   
3466     do i=1,100000000    ! Just a delay
3467         j = i * i - i
3468     end do
3469     call dtime(tarray, result)
3470     print *, result
3471     print *, tarray(1)
3472     print *, tarray(2)
3473 end program test_dtime
3474 @end smallexample
3476 @item @emph{See also}:
3477 @ref{CPU_TIME}
3479 @end table
3483 @node EOSHIFT
3484 @section @code{EOSHIFT} --- End-off shift elements of an array
3485 @fnindex EOSHIFT
3486 @cindex array, shift
3488 @table @asis
3489 @item @emph{Description}:
3490 @code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
3491 elements of @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is
3492 omitted it is taken to be @code{1}.  @var{DIM} is a scalar of type
3493 @code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the
3494 rank of @var{ARRAY}.  If the rank of @var{ARRAY} is one, then all elements of
3495 @var{ARRAY} are shifted by @var{SHIFT} places.  If rank is greater than one,
3496 then all complete rank one sections of @var{ARRAY} along the given dimension are
3497 shifted.  Elements shifted out one end of each rank one section are dropped.  If
3498 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
3499 is copied back in the other end.  If @var{BOUNDARY} is not present then the
3500 following are copied in depending on the type of @var{ARRAY}.
3502 @multitable @columnfractions .15 .80
3503 @item @emph{Array Type} @tab @emph{Boundary Value}
3504 @item Numeric  @tab 0 of the type and kind of @var{ARRAY}.
3505 @item Logical  @tab @code{.FALSE.}.
3506 @item Character(@var{len}) @tab @var{len} blanks.
3507 @end multitable
3509 @item @emph{Standard}:
3510 Fortran 95 and later
3512 @item @emph{Class}:
3513 Transformational function
3515 @item @emph{Syntax}:
3516 @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
3518 @item @emph{Arguments}:
3519 @multitable @columnfractions .15 .70
3520 @item @var{ARRAY}  @tab May be any type, not scalar.
3521 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
3522 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}. 
3523 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
3524 @end multitable
3526 @item @emph{Return value}:
3527 Returns an array of same type and rank as the @var{ARRAY} argument.
3529 @item @emph{Example}:
3530 @smallexample
3531 program test_eoshift
3532     integer, dimension(3,3) :: a
3533     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3534     print '(3i3)', a(1,:)
3535     print '(3i3)', a(2,:)
3536     print '(3i3)', a(3,:)    
3537     a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3538     print *
3539     print '(3i3)', a(1,:)
3540     print '(3i3)', a(2,:)
3541     print '(3i3)', a(3,:)
3542 end program test_eoshift
3543 @end smallexample
3544 @end table
3548 @node EPSILON
3549 @section @code{EPSILON} --- Epsilon function
3550 @fnindex EPSILON
3551 @cindex model representation, epsilon
3553 @table @asis
3554 @item @emph{Description}:
3555 @code{EPSILON(X)} returns the smallest number @var{E} of the same kind
3556 as @var{X} such that @math{1 + E > 1}.
3558 @item @emph{Standard}:
3559 Fortran 95 and later
3561 @item @emph{Class}:
3562 Inquiry function
3564 @item @emph{Syntax}:
3565 @code{RESULT = EPSILON(X)}
3567 @item @emph{Arguments}:
3568 @multitable @columnfractions .15 .70
3569 @item @var{X} @tab The type shall be @code{REAL}.
3570 @end multitable
3572 @item @emph{Return value}:
3573 The return value is of same type as the argument.
3575 @item @emph{Example}:
3576 @smallexample
3577 program test_epsilon
3578     real :: x = 3.143
3579     real(8) :: y = 2.33
3580     print *, EPSILON(x)
3581     print *, EPSILON(y)
3582 end program test_epsilon
3583 @end smallexample
3584 @end table
3588 @node ERF
3589 @section @code{ERF} --- Error function 
3590 @fnindex ERF
3591 @cindex error function
3593 @table @asis
3594 @item @emph{Description}:
3595 @code{ERF(X)} computes the error function of @var{X}.
3597 @item @emph{Standard}:
3598 Fortran 2008 and later
3600 @item @emph{Class}:
3601 Elemental function
3603 @item @emph{Syntax}:
3604 @code{RESULT = ERF(X)}
3606 @item @emph{Arguments}:
3607 @multitable @columnfractions .15 .70
3608 @item @var{X} @tab The type shall be @code{REAL}.
3609 @end multitable
3611 @item @emph{Return value}:
3612 The return value is of type @code{REAL}, of the same kind as
3613 @var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
3615 @item @emph{Example}:
3616 @smallexample
3617 program test_erf
3618   real(8) :: x = 0.17_8
3619   x = erf(x)
3620 end program test_erf
3621 @end smallexample
3623 @item @emph{Specific names}:
3624 @multitable @columnfractions .20 .20 .20 .25
3625 @item Name            @tab Argument          @tab Return type       @tab Standard
3626 @item @code{DERF(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
3627 @end multitable
3628 @end table
3632 @node ERFC
3633 @section @code{ERFC} --- Error function 
3634 @fnindex ERFC
3635 @cindex error function, complementary
3637 @table @asis
3638 @item @emph{Description}:
3639 @code{ERFC(X)} computes the complementary error function of @var{X}.
3641 @item @emph{Standard}:
3642 Fortran 2008 and later
3644 @item @emph{Class}:
3645 Elemental function
3647 @item @emph{Syntax}:
3648 @code{RESULT = ERFC(X)}
3650 @item @emph{Arguments}:
3651 @multitable @columnfractions .15 .70
3652 @item @var{X} @tab The type shall be @code{REAL}.
3653 @end multitable
3655 @item @emph{Return value}:
3656 The return value is of type @code{REAL} and of the same kind as @var{X}.
3657 It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
3659 @item @emph{Example}:
3660 @smallexample
3661 program test_erfc
3662   real(8) :: x = 0.17_8
3663   x = erfc(x)
3664 end program test_erfc
3665 @end smallexample
3667 @item @emph{Specific names}:
3668 @multitable @columnfractions .20 .20 .20 .25
3669 @item Name            @tab Argument          @tab Return type       @tab Standard
3670 @item @code{DERFC(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
3671 @end multitable
3672 @end table
3676 @node ERFC_SCALED
3677 @section @code{ERFC_SCALED} --- Error function 
3678 @fnindex ERFC_SCALED
3679 @cindex error function, complementary, exponentially-scaled
3681 @table @asis
3682 @item @emph{Description}:
3683 @code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
3684 error function of @var{X}.
3686 @item @emph{Standard}:
3687 Fortran 2008 and later
3689 @item @emph{Class}:
3690 Elemental function
3692 @item @emph{Syntax}:
3693 @code{RESULT = ERFC_SCALED(X)}
3695 @item @emph{Arguments}:
3696 @multitable @columnfractions .15 .70
3697 @item @var{X} @tab The type shall be @code{REAL}.
3698 @end multitable
3700 @item @emph{Return value}:
3701 The return value is of type @code{REAL} and of the same kind as @var{X}.
3703 @item @emph{Example}:
3704 @smallexample
3705 program test_erfc_scaled
3706   real(8) :: x = 0.17_8
3707   x = erfc_scaled(x)
3708 end program test_erfc_scaled
3709 @end smallexample
3710 @end table
3714 @node ETIME
3715 @section @code{ETIME} --- Execution time subroutine (or function)
3716 @fnindex ETIME
3717 @cindex time, elapsed
3719 @table @asis
3720 @item @emph{Description}:
3721 @code{ETIME(VALUES, TIME)} returns the number of seconds of runtime
3722 since the start of the process's execution in @var{TIME}.  @var{VALUES}
3723 returns the user and system components of this time in @code{VALUES(1)} and
3724 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}.
3726 On some systems, the underlying timings are represented using types with
3727 sufficiently small limits that overflows (wrap around) are possible, such as
3728 32-bit types. Therefore, the values returned by this intrinsic might be, or
3729 become, negative, or numerically less than previous values, during a single
3730 run of the compiled program.
3732 This intrinsic is provided in both subroutine and function forms; however,
3733 only one form can be used in any given program unit.
3735 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
3737 @multitable @columnfractions .15 .30 .60
3738 @item @tab @code{VALUES(1)}: @tab User time in seconds.
3739 @item @tab @code{VALUES(2)}: @tab System time in seconds.
3740 @item @tab @code{TIME}: @tab Run time since start in seconds.
3741 @end multitable
3743 @item @emph{Standard}:
3744 GNU extension
3746 @item @emph{Class}:
3747 Subroutine, function
3749 @item @emph{Syntax}:
3750 @multitable @columnfractions .80
3751 @item @code{CALL ETIME(VALUES, TIME)}.
3752 @item @code{TIME = ETIME(VALUES)}, (not recommended).
3753 @end multitable
3755 @item @emph{Arguments}:
3756 @multitable @columnfractions .15 .70
3757 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
3758 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
3759 @end multitable
3761 @item @emph{Return value}:
3762 Elapsed time in seconds since the start of program execution.
3764 @item @emph{Example}:
3765 @smallexample
3766 program test_etime
3767     integer(8) :: i, j
3768     real, dimension(2) :: tarray
3769     real :: result
3770     call ETIME(tarray, result)
3771     print *, result
3772     print *, tarray(1)
3773     print *, tarray(2)   
3774     do i=1,100000000    ! Just a delay
3775         j = i * i - i
3776     end do
3777     call ETIME(tarray, result)
3778     print *, result
3779     print *, tarray(1)
3780     print *, tarray(2)
3781 end program test_etime
3782 @end smallexample
3784 @item @emph{See also}:
3785 @ref{CPU_TIME}
3787 @end table
3791 @node EXIT
3792 @section @code{EXIT} --- Exit the program with status. 
3793 @fnindex EXIT
3794 @cindex program termination
3795 @cindex terminate program
3797 @table @asis
3798 @item @emph{Description}:
3799 @code{EXIT} causes immediate termination of the program with status.  If status
3800 is omitted it returns the canonical @emph{success} for the system.  All Fortran
3801 I/O units are closed. 
3803 @item @emph{Standard}:
3804 GNU extension
3806 @item @emph{Class}:
3807 Subroutine
3809 @item @emph{Syntax}:
3810 @code{CALL EXIT([STATUS])}
3812 @item @emph{Arguments}:
3813 @multitable @columnfractions .15 .70
3814 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
3815 @end multitable
3817 @item @emph{Return value}:
3818 @code{STATUS} is passed to the parent process on exit.
3820 @item @emph{Example}:
3821 @smallexample
3822 program test_exit
3823   integer :: STATUS = 0
3824   print *, 'This program is going to exit.'
3825   call EXIT(STATUS)
3826 end program test_exit
3827 @end smallexample
3829 @item @emph{See also}:
3830 @ref{ABORT}, @ref{KILL}
3831 @end table
3835 @node EXP
3836 @section @code{EXP} --- Exponential function 
3837 @fnindex EXP
3838 @fnindex DEXP
3839 @fnindex CEXP
3840 @fnindex ZEXP
3841 @fnindex CDEXP
3842 @cindex exponential function
3843 @cindex logarithmic function, inverse
3845 @table @asis
3846 @item @emph{Description}:
3847 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3849 @item @emph{Standard}:
3850 Fortran 77 and later, has overloads that are GNU extensions
3852 @item @emph{Class}:
3853 Elemental function
3855 @item @emph{Syntax}:
3856 @code{RESULT = EXP(X)}
3858 @item @emph{Arguments}:
3859 @multitable @columnfractions .15 .70
3860 @item @var{X} @tab The type shall be @code{REAL} or
3861 @code{COMPLEX}.
3862 @end multitable
3864 @item @emph{Return value}:
3865 The return value has same type and kind as @var{X}.
3867 @item @emph{Example}:
3868 @smallexample
3869 program test_exp
3870   real :: x = 1.0
3871   x = exp(x)
3872 end program test_exp
3873 @end smallexample
3875 @item @emph{Specific names}:
3876 @multitable @columnfractions .20 .20 .20 .25
3877 @item Name            @tab Argument             @tab Return type         @tab Standard
3878 @item @code{EXP(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}      @tab Fortran 77 and later
3879 @item @code{DEXP(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}      @tab Fortran 77 and later
3880 @item @code{CEXP(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}   @tab Fortran 77 and later
3881 @item @code{ZEXP(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
3882 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
3883 @end multitable
3884 @end table
3888 @node EXPONENT
3889 @section @code{EXPONENT} --- Exponent function 
3890 @fnindex EXPONENT
3891 @cindex real number, exponent
3892 @cindex floating point, exponent
3894 @table @asis
3895 @item @emph{Description}:
3896 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3897 is zero the value returned is zero. 
3899 @item @emph{Standard}:
3900 Fortran 95 and later
3902 @item @emph{Class}:
3903 Elemental function
3905 @item @emph{Syntax}:
3906 @code{RESULT = EXPONENT(X)}
3908 @item @emph{Arguments}:
3909 @multitable @columnfractions .15 .70
3910 @item @var{X} @tab The type shall be @code{REAL}.
3911 @end multitable
3913 @item @emph{Return value}:
3914 The return value is of type default @code{INTEGER}.
3916 @item @emph{Example}:
3917 @smallexample
3918 program test_exponent
3919   real :: x = 1.0
3920   integer :: i
3921   i = exponent(x)
3922   print *, i
3923   print *, exponent(0.0)
3924 end program test_exponent
3925 @end smallexample
3926 @end table
3930 @node FDATE
3931 @section @code{FDATE} --- Get the current time as a string
3932 @fnindex FDATE
3933 @cindex time, current
3934 @cindex current time
3935 @cindex date, current
3936 @cindex current date
3938 @table @asis
3939 @item @emph{Description}:
3940 @code{FDATE(DATE)} returns the current date (using the same format as
3941 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3942 TIME())}.
3944 This intrinsic is provided in both subroutine and function forms; however,
3945 only one form can be used in any given program unit.
3947 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable of the
3948 default kind.
3950 @item @emph{Standard}:
3951 GNU extension
3953 @item @emph{Class}:
3954 Subroutine, function
3956 @item @emph{Syntax}:
3957 @multitable @columnfractions .80
3958 @item @code{CALL FDATE(DATE)}.
3959 @item @code{DATE = FDATE()}, (not recommended).
3960 @end multitable
3962 @item @emph{Arguments}:
3963 @multitable @columnfractions .15 .70
3964 @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
3965 default kind
3966 @end multitable
3968 @item @emph{Return value}:
3969 The current date as a string.
3971 @item @emph{Example}:
3972 @smallexample
3973 program test_fdate
3974     integer(8) :: i, j
3975     character(len=30) :: date
3976     call fdate(date)
3977     print *, 'Program started on ', date
3978     do i = 1, 100000000 ! Just a delay
3979         j = i * i - i
3980     end do
3981     call fdate(date)
3982     print *, 'Program ended on ', date
3983 end program test_fdate
3984 @end smallexample
3985 @end table
3989 @node FGET
3990 @section @code{FGET} --- Read a single character in stream mode from stdin 
3991 @fnindex FGET
3992 @cindex read character, stream mode
3993 @cindex stream mode, read character
3994 @cindex file operation, read character
3996 @table @asis
3997 @item @emph{Description}:
3998 Read a single character in stream mode from stdin by bypassing normal 
3999 formatted output. Stream I/O should not be mixed with normal record-oriented 
4000 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4002 This intrinsic is provided in both subroutine and function forms; however,
4003 only one form can be used in any given program unit.
4005 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4006 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4007 Programmers should consider the use of new stream IO feature in new code 
4008 for future portability. See also @ref{Fortran 2003 status}.
4010 @item @emph{Standard}:
4011 GNU extension
4013 @item @emph{Class}:
4014 Subroutine, function
4016 @item @emph{Syntax}:
4017 @code{CALL FGET(C [, STATUS])}
4019 @item @emph{Arguments}:
4020 @multitable @columnfractions .15 .70
4021 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4022 kind.
4023 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4024 Returns 0 on success, -1 on end-of-file, and a system specific positive
4025 error code otherwise.
4026 @end multitable
4028 @item @emph{Example}:
4029 @smallexample
4030 PROGRAM test_fget
4031   INTEGER, PARAMETER :: strlen = 100
4032   INTEGER :: status, i = 1
4033   CHARACTER(len=strlen) :: str = ""
4035   WRITE (*,*) 'Enter text:'
4036   DO
4037     CALL fget(str(i:i), status)
4038     if (status /= 0 .OR. i > strlen) exit
4039     i = i + 1
4040   END DO
4041   WRITE (*,*) TRIM(str)
4042 END PROGRAM
4043 @end smallexample
4045 @item @emph{See also}:
4046 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
4047 @end table
4051 @node FGETC
4052 @section @code{FGETC} --- Read a single character in stream mode
4053 @fnindex FGETC
4054 @cindex read character, stream mode
4055 @cindex stream mode, read character
4056 @cindex file operation, read character
4058 @table @asis
4059 @item @emph{Description}:
4060 Read a single character in stream mode by bypassing normal formatted output. 
4061 Stream I/O should not be mixed with normal record-oriented (formatted or 
4062 unformatted) I/O on the same unit; the results are unpredictable.
4064 This intrinsic is provided in both subroutine and function forms; however,
4065 only one form can be used in any given program unit.
4067 Note that the @code{FGET} intrinsic is provided for backwards compatibility
4068 with @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4069 Programmers should consider the use of new stream IO feature in new code 
4070 for future portability. See also @ref{Fortran 2003 status}.
4072 @item @emph{Standard}:
4073 GNU extension
4075 @item @emph{Class}:
4076 Subroutine, function
4078 @item @emph{Syntax}:
4079 @code{CALL FGETC(UNIT, C [, STATUS])}
4081 @item @emph{Arguments}:
4082 @multitable @columnfractions .15 .70
4083 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4084 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4085 kind.
4086 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4087 Returns 0 on success, -1 on end-of-file and a system specific positive
4088 error code otherwise.
4089 @end multitable
4091 @item @emph{Example}:
4092 @smallexample
4093 PROGRAM test_fgetc
4094   INTEGER :: fd = 42, status
4095   CHARACTER :: c
4097   OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
4098   DO
4099     CALL fgetc(fd, c, status)
4100     IF (status /= 0) EXIT
4101     call fput(c)
4102   END DO
4103   CLOSE(UNIT=fd)
4104 END PROGRAM
4105 @end smallexample
4107 @item @emph{See also}:
4108 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
4109 @end table
4113 @node FLOOR
4114 @section @code{FLOOR} --- Integer floor function
4115 @fnindex FLOOR
4116 @cindex floor
4117 @cindex rounding, floor
4119 @table @asis
4120 @item @emph{Description}:
4121 @code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
4123 @item @emph{Standard}:
4124 Fortran 95 and later
4126 @item @emph{Class}:
4127 Elemental function
4129 @item @emph{Syntax}:
4130 @code{RESULT = FLOOR(A [, KIND])}
4132 @item @emph{Arguments}:
4133 @multitable @columnfractions .15 .70
4134 @item @var{A} @tab The type shall be @code{REAL}.
4135 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
4136 expression indicating the kind parameter of the result.
4137 @end multitable
4139 @item @emph{Return value}:
4140 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
4141 and of default-kind @code{INTEGER} otherwise.
4143 @item @emph{Example}:
4144 @smallexample
4145 program test_floor
4146     real :: x = 63.29
4147     real :: y = -63.59
4148     print *, floor(x) ! returns 63
4149     print *, floor(y) ! returns -64
4150 end program test_floor
4151 @end smallexample
4153 @item @emph{See also}:
4154 @ref{CEILING}, @ref{NINT}
4156 @end table
4160 @node FLUSH
4161 @section @code{FLUSH} --- Flush I/O unit(s)
4162 @fnindex FLUSH
4163 @cindex file operation, flush
4165 @table @asis
4166 @item @emph{Description}:
4167 Flushes Fortran unit(s) currently open for output. Without the optional
4168 argument, all units are flushed, otherwise just the unit specified.
4170 @item @emph{Standard}:
4171 GNU extension
4173 @item @emph{Class}:
4174 Subroutine
4176 @item @emph{Syntax}:
4177 @code{CALL FLUSH(UNIT)}
4179 @item @emph{Arguments}:
4180 @multitable @columnfractions .15 .70
4181 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
4182 @end multitable
4184 @item @emph{Note}:
4185 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
4186 statement that should be preferred over the @code{FLUSH} intrinsic.
4188 @end table
4192 @node FNUM
4193 @section @code{FNUM} --- File number function
4194 @fnindex FNUM
4195 @cindex file operation, file number
4197 @table @asis
4198 @item @emph{Description}:
4199 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
4200 open Fortran I/O unit @code{UNIT}.
4202 @item @emph{Standard}:
4203 GNU extension
4205 @item @emph{Class}:
4206 Function
4208 @item @emph{Syntax}:
4209 @code{RESULT = FNUM(UNIT)}
4211 @item @emph{Arguments}:
4212 @multitable @columnfractions .15 .70
4213 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
4214 @end multitable
4216 @item @emph{Return value}:
4217 The return value is of type @code{INTEGER}
4219 @item @emph{Example}:
4220 @smallexample
4221 program test_fnum
4222   integer :: i
4223   open (unit=10, status = "scratch")
4224   i = fnum(10)
4225   print *, i
4226   close (10)
4227 end program test_fnum
4228 @end smallexample
4229 @end table
4233 @node FPUT
4234 @section @code{FPUT} --- Write a single character in stream mode to stdout 
4235 @fnindex FPUT
4236 @cindex write character, stream mode
4237 @cindex stream mode, write character
4238 @cindex file operation, write character
4240 @table @asis
4241 @item @emph{Description}:
4242 Write a single character in stream mode to stdout by bypassing normal 
4243 formatted output. Stream I/O should not be mixed with normal record-oriented 
4244 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4246 This intrinsic is provided in both subroutine and function forms; however,
4247 only one form can be used in any given program unit.
4249 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4250 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4251 Programmers should consider the use of new stream IO feature in new code 
4252 for future portability. See also @ref{Fortran 2003 status}.
4254 @item @emph{Standard}:
4255 GNU extension
4257 @item @emph{Class}:
4258 Subroutine, function
4260 @item @emph{Syntax}:
4261 @code{CALL FPUT(C [, STATUS])}
4263 @item @emph{Arguments}:
4264 @multitable @columnfractions .15 .70
4265 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4266 kind.
4267 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4268 Returns 0 on success, -1 on end-of-file and a system specific positive
4269 error code otherwise.
4270 @end multitable
4272 @item @emph{Example}:
4273 @smallexample
4274 PROGRAM test_fput
4275   CHARACTER(len=10) :: str = "gfortran"
4276   INTEGER :: i
4277   DO i = 1, len_trim(str)
4278     CALL fput(str(i:i))
4279   END DO
4280 END PROGRAM
4281 @end smallexample
4283 @item @emph{See also}:
4284 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
4285 @end table
4289 @node FPUTC
4290 @section @code{FPUTC} --- Write a single character in stream mode
4291 @fnindex FPUTC
4292 @cindex write character, stream mode
4293 @cindex stream mode, write character
4294 @cindex file operation, write character
4296 @table @asis
4297 @item @emph{Description}:
4298 Write a single character in stream mode by bypassing normal formatted 
4299 output. Stream I/O should not be mixed with normal record-oriented 
4300 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4302 This intrinsic is provided in both subroutine and function forms; however,
4303 only one form can be used in any given program unit.
4305 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4306 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4307 Programmers should consider the use of new stream IO feature in new code 
4308 for future portability. See also @ref{Fortran 2003 status}.
4310 @item @emph{Standard}:
4311 GNU extension
4313 @item @emph{Class}:
4314 Subroutine, function
4316 @item @emph{Syntax}:
4317 @code{CALL FPUTC(UNIT, C [, STATUS])}
4319 @item @emph{Arguments}:
4320 @multitable @columnfractions .15 .70
4321 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4322 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4323 kind.
4324 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4325 Returns 0 on success, -1 on end-of-file and a system specific positive
4326 error code otherwise.
4327 @end multitable
4329 @item @emph{Example}:
4330 @smallexample
4331 PROGRAM test_fputc
4332   CHARACTER(len=10) :: str = "gfortran"
4333   INTEGER :: fd = 42, i
4335   OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
4336   DO i = 1, len_trim(str)
4337     CALL fputc(fd, str(i:i))
4338   END DO
4339   CLOSE(fd)
4340 END PROGRAM
4341 @end smallexample
4343 @item @emph{See also}:
4344 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
4345 @end table
4349 @node FRACTION
4350 @section @code{FRACTION} --- Fractional part of the model representation
4351 @fnindex FRACTION
4352 @cindex real number, fraction
4353 @cindex floating point, fraction
4355 @table @asis
4356 @item @emph{Description}:
4357 @code{FRACTION(X)} returns the fractional part of the model
4358 representation of @code{X}.
4360 @item @emph{Standard}:
4361 Fortran 95 and later
4363 @item @emph{Class}:
4364 Elemental function
4366 @item @emph{Syntax}:
4367 @code{Y = FRACTION(X)}
4369 @item @emph{Arguments}:
4370 @multitable @columnfractions .15 .70
4371 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
4372 @end multitable
4374 @item @emph{Return value}:
4375 The return value is of the same type and kind as the argument.
4376 The fractional part of the model representation of @code{X} is returned;
4377 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
4379 @item @emph{Example}:
4380 @smallexample
4381 program test_fraction
4382   real :: x
4383   x = 178.1387e-4
4384   print *, fraction(x), x * radix(x)**(-exponent(x))
4385 end program test_fraction
4386 @end smallexample
4388 @end table
4392 @node FREE
4393 @section @code{FREE} --- Frees memory
4394 @fnindex FREE
4395 @cindex pointer, cray
4397 @table @asis
4398 @item @emph{Description}:
4399 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
4400 intrinsic is an extension intended to be used with Cray pointers, and is
4401 provided in GNU Fortran to allow user to compile legacy code. For
4402 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
4403 @code{DEALLOCATE}.
4405 @item @emph{Standard}:
4406 GNU extension
4408 @item @emph{Class}:
4409 Subroutine
4411 @item @emph{Syntax}:
4412 @code{CALL FREE(PTR)}
4414 @item @emph{Arguments}:
4415 @multitable @columnfractions .15 .70
4416 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
4417 location of the memory that should be de-allocated.
4418 @end multitable
4420 @item @emph{Return value}:
4421 None
4423 @item @emph{Example}:
4424 See @code{MALLOC} for an example.
4426 @item @emph{See also}:
4427 @ref{MALLOC}
4428 @end table
4432 @node FSEEK
4433 @section @code{FSEEK} --- Low level file positioning subroutine
4434 @fnindex FSEEK
4435 @cindex file operation, seek
4436 @cindex file operation, position
4438 @table @asis
4439 @item @emph{Description}:
4440 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE} 
4441 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
4442 if set to 1, @var{OFFSET} is taken to be relative to the current position 
4443 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
4444 On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek 
4445 fails silently.
4447 This intrinsic routine is not fully backwards compatible with @command{g77}. 
4448 In @command{g77}, the @code{FSEEK} takes a statement label instead of a 
4449 @var{STATUS} variable. If FSEEK is used in old code, change
4450 @smallexample
4451   CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
4452 @end smallexample 
4454 @smallexample
4455   INTEGER :: status
4456   CALL FSEEK(UNIT, OFFSET, WHENCE, status)
4457   IF (status /= 0) GOTO label
4458 @end smallexample 
4460 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
4461 Programmers should consider the use of new stream IO feature in new code 
4462 for future portability. See also @ref{Fortran 2003 status}.
4464 @item @emph{Standard}:
4465 GNU extension
4467 @item @emph{Class}:
4468 Subroutine
4470 @item @emph{Syntax}:
4471 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
4473 @item @emph{Arguments}:
4474 @multitable @columnfractions .15 .70
4475 @item @var{UNIT}   @tab Shall be a scalar of type @code{INTEGER}.
4476 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
4477 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
4478 Its value shall be either 0, 1 or 2.
4479 @item @var{STATUS} @tab (Optional) shall be a scalar of type 
4480 @code{INTEGER(4)}.
4481 @end multitable
4483 @item @emph{Example}:
4484 @smallexample
4485 PROGRAM test_fseek
4486   INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
4487   INTEGER :: fd, offset, ierr
4489   ierr   = 0
4490   offset = 5
4491   fd     = 10
4493   OPEN(UNIT=fd, FILE="fseek.test")
4494   CALL FSEEK(fd, offset, SEEK_SET, ierr)  ! move to OFFSET
4495   print *, FTELL(fd), ierr
4497   CALL FSEEK(fd, 0, SEEK_END, ierr)       ! move to end
4498   print *, FTELL(fd), ierr
4500   CALL FSEEK(fd, 0, SEEK_SET, ierr)       ! move to beginning
4501   print *, FTELL(fd), ierr
4503   CLOSE(UNIT=fd)
4504 END PROGRAM
4505 @end smallexample
4507 @item @emph{See also}:
4508 @ref{FTELL}
4509 @end table
4513 @node FSTAT
4514 @section @code{FSTAT} --- Get file status
4515 @fnindex FSTAT
4516 @cindex file system, file status
4518 @table @asis
4519 @item @emph{Description}:
4520 @code{FSTAT} is identical to @ref{STAT}, except that information about an 
4521 already opened file is obtained.
4523 The elements in @code{VALUES} are the same as described by @ref{STAT}.
4525 This intrinsic is provided in both subroutine and function forms; however,
4526 only one form can be used in any given program unit.
4528 @item @emph{Standard}:
4529 GNU extension
4531 @item @emph{Class}:
4532 Subroutine, function
4534 @item @emph{Syntax}:
4535 @code{CALL FSTAT(UNIT, VALUES [, STATUS])}
4537 @item @emph{Arguments}:
4538 @multitable @columnfractions .15 .70
4539 @item @var{UNIT}   @tab An open I/O unit number of type @code{INTEGER}.
4540 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
4541 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
4542 on success and a system specific error code otherwise.
4543 @end multitable
4545 @item @emph{Example}:
4546 See @ref{STAT} for an example.
4548 @item @emph{See also}:
4549 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
4550 @end table
4554 @node FTELL
4555 @section @code{FTELL} --- Current stream position
4556 @fnindex FTELL
4557 @cindex file operation, position
4559 @table @asis
4560 @item @emph{Description}:
4561 Retrieves the current position within an open file.
4563 This intrinsic is provided in both subroutine and function forms; however,
4564 only one form can be used in any given program unit.
4566 @item @emph{Standard}:
4567 GNU extension
4569 @item @emph{Class}:
4570 Subroutine, function
4572 @item @emph{Syntax}:
4573 @multitable @columnfractions .80
4574 @item @code{CALL FTELL(UNIT, OFFSET)}
4575 @item @code{OFFSET = FTELL(UNIT)}
4576 @end multitable
4578 @item @emph{Arguments}:
4579 @multitable @columnfractions .15 .70
4580 @item @var{OFFSET}  @tab Shall of type @code{INTEGER}.
4581 @item @var{UNIT}    @tab Shall of type @code{INTEGER}.
4582 @end multitable
4584 @item @emph{Return value}:
4585 In either syntax, @var{OFFSET} is set to the current offset of unit
4586 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
4588 @item @emph{Example}:
4589 @smallexample
4590 PROGRAM test_ftell
4591   INTEGER :: i
4592   OPEN(10, FILE="temp.dat")
4593   CALL ftell(10,i)
4594   WRITE(*,*) i
4595 END PROGRAM
4596 @end smallexample
4598 @item @emph{See also}:
4599 @ref{FSEEK}
4600 @end table
4604 @node GAMMA
4605 @section @code{GAMMA} --- Gamma function
4606 @fnindex GAMMA
4607 @fnindex DGAMMA
4608 @cindex Gamma function
4609 @cindex Factorial function
4611 @table @asis
4612 @item @emph{Description}:
4613 @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
4614 integer values of @var{X} the Gamma function simplifies to the factorial
4615 function @math{\Gamma(x)=(x-1)!}.
4617 @tex
4619 \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
4621 @end tex
4623 @item @emph{Standard}:
4624 Fortran 2008 and later
4626 @item @emph{Class}:
4627 Elemental function
4629 @item @emph{Syntax}:
4630 @code{X = GAMMA(X)}
4632 @item @emph{Arguments}:
4633 @multitable @columnfractions .15 .70
4634 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
4635 nor a negative integer.
4636 @end multitable
4638 @item @emph{Return value}:
4639 The return value is of type @code{REAL} of the same kind as @var{X}.
4641 @item @emph{Example}:
4642 @smallexample
4643 program test_gamma
4644   real :: x = 1.0
4645   x = gamma(x) ! returns 1.0
4646 end program test_gamma
4647 @end smallexample
4649 @item @emph{Specific names}:
4650 @multitable @columnfractions .20 .20 .20 .25
4651 @item Name             @tab Argument         @tab Return type       @tab Standard
4652 @item @code{GAMMA(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
4653 @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
4654 @end multitable
4656 @item @emph{See also}:
4657 Logarithm of the Gamma function: @ref{LOG_GAMMA}
4659 @end table
4663 @node GERROR
4664 @section @code{GERROR} --- Get last system error message
4665 @fnindex GERROR
4666 @cindex system, error handling
4668 @table @asis
4669 @item @emph{Description}:
4670 Returns the system error message corresponding to the last system error.
4671 This resembles the functionality of @code{strerror(3)} in C.
4673 @item @emph{Standard}:
4674 GNU extension
4676 @item @emph{Class}:
4677 Subroutine
4679 @item @emph{Syntax}:
4680 @code{CALL GERROR(RESULT)}
4682 @item @emph{Arguments}:
4683 @multitable @columnfractions .15 .70
4684 @item @var{RESULT}  @tab Shall of type @code{CHARACTER} and of default
4685 @end multitable
4687 @item @emph{Example}:
4688 @smallexample
4689 PROGRAM test_gerror
4690   CHARACTER(len=100) :: msg
4691   CALL gerror(msg)
4692   WRITE(*,*) msg
4693 END PROGRAM
4694 @end smallexample
4696 @item @emph{See also}:
4697 @ref{IERRNO}, @ref{PERROR}
4698 @end table
4702 @node GETARG
4703 @section @code{GETARG} --- Get command line arguments
4704 @fnindex GETARG
4705 @cindex command-line arguments
4706 @cindex arguments, to program
4708 @table @asis
4709 @item @emph{Description}:
4710 Retrieve the @var{POS}-th argument that was passed on the
4711 command line when the containing program was invoked.
4713 This intrinsic routine is provided for backwards compatibility with 
4714 GNU Fortran 77.  In new code, programmers should consider the use of 
4715 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003 
4716 standard.
4718 @item @emph{Standard}:
4719 GNU extension
4721 @item @emph{Class}:
4722 Subroutine
4724 @item @emph{Syntax}:
4725 @code{CALL GETARG(POS, VALUE)}
4727 @item @emph{Arguments}:
4728 @multitable @columnfractions .15 .70
4729 @item @var{POS}   @tab Shall be of type @code{INTEGER} and not wider than
4730 the default integer kind; @math{@var{POS} \geq 0}
4731 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
4732 kind.
4733 @item @var{VALUE} @tab Shall be of type @code{CHARACTER}. 
4734 @end multitable
4736 @item @emph{Return value}:
4737 After @code{GETARG} returns, the @var{VALUE} argument holds the
4738 @var{POS}th command line argument. If @var{VALUE} can not hold the
4739 argument, it is truncated to fit the length of @var{VALUE}. If there are
4740 less than @var{POS} arguments specified at the command line, @var{VALUE}
4741 will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
4742 to the name of the program (on systems that support this feature).
4744 @item @emph{Example}:
4745 @smallexample
4746 PROGRAM test_getarg
4747   INTEGER :: i
4748   CHARACTER(len=32) :: arg
4750   DO i = 1, iargc()
4751     CALL getarg(i, arg)
4752     WRITE (*,*) arg
4753   END DO
4754 END PROGRAM
4755 @end smallexample
4757 @item @emph{See also}:
4758 GNU Fortran 77 compatibility function: @ref{IARGC}
4760 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
4761 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4762 @end table
4766 @node GET_COMMAND
4767 @section @code{GET_COMMAND} --- Get the entire command line
4768 @fnindex GET_COMMAND
4769 @cindex command-line arguments
4770 @cindex arguments, to program
4772 @table @asis
4773 @item @emph{Description}:
4774 Retrieve the entire command line that was used to invoke the program.
4776 @item @emph{Standard}:
4777 Fortran 2003 and later
4779 @item @emph{Class}:
4780 Subroutine
4782 @item @emph{Syntax}:
4783 @code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])}
4785 @item @emph{Arguments}:
4786 @multitable @columnfractions .15 .70
4787 @item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and
4788 of default kind.
4789 @item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of
4790 default kind.
4791 @item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of
4792 default kind.
4793 @end multitable
4795 @item @emph{Return value}:
4796 If @var{COMMAND} is present, stores the entire command line that was used
4797 to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is
4798 assigned the length of the command line. If @var{STATUS} is present, it
4799 is assigned 0 upon success of the command, -1 if @var{COMMAND} is too
4800 short to store the command line, or a positive value in case of an error.
4802 @item @emph{Example}:
4803 @smallexample
4804 PROGRAM test_get_command
4805   CHARACTER(len=255) :: cmd
4806   CALL get_command(cmd)
4807   WRITE (*,*) TRIM(cmd)
4808 END PROGRAM
4809 @end smallexample
4811 @item @emph{See also}:
4812 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4813 @end table
4817 @node GET_COMMAND_ARGUMENT
4818 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4819 @fnindex GET_COMMAND_ARGUMENT
4820 @cindex command-line arguments
4821 @cindex arguments, to program
4823 @table @asis
4824 @item @emph{Description}:
4825 Retrieve the @var{NUMBER}-th argument that was passed on the
4826 command line when the containing program was invoked.
4828 @item @emph{Standard}:
4829 Fortran 2003 and later
4831 @item @emph{Class}:
4832 Subroutine
4834 @item @emph{Syntax}:
4835 @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
4837 @item @emph{Arguments}:
4838 @multitable @columnfractions .15 .70
4839 @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of
4840 default kind, @math{@var{NUMBER} \geq 0}
4841 @item @var{VALUE}  @tab Shall be a scalar of type @code{CHARACTER}
4842 and of default kind.
4843 @item @var{LENGTH} @tab (Option) Shall be a scalar of type @code{INTEGER}
4844 and of default kind.
4845 @item @var{STATUS} @tab (Option) Shall be a scalar of type @code{INTEGER}
4846 and of default kind.
4847 @end multitable
4849 @item @emph{Return value}:
4850 After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the 
4851 @var{NUMBER}-th command line argument. If @var{VALUE} can not hold the argument, it is 
4852 truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
4853 arguments specified at the command line, @var{VALUE} will be filled with blanks. 
4854 If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on
4855 systems that support this feature). The @var{LENGTH} argument contains the
4856 length of the @var{NUMBER}-th command line argument. If the argument retrieval
4857 fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated
4858 command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is
4859 zero.
4861 @item @emph{Example}:
4862 @smallexample
4863 PROGRAM test_get_command_argument
4864   INTEGER :: i
4865   CHARACTER(len=32) :: arg
4867   i = 0
4868   DO
4869     CALL get_command_argument(i, arg)
4870     IF (LEN_TRIM(arg) == 0) EXIT
4872     WRITE (*,*) TRIM(arg)
4873     i = i+1
4874   END DO
4875 END PROGRAM
4876 @end smallexample
4878 @item @emph{See also}:
4879 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4880 @end table
4884 @node GETCWD
4885 @section @code{GETCWD} --- Get current working directory
4886 @fnindex GETCWD
4887 @cindex system, working directory
4889 @table @asis
4890 @item @emph{Description}:
4891 Get current working directory.
4893 This intrinsic is provided in both subroutine and function forms; however,
4894 only one form can be used in any given program unit.
4896 @item @emph{Standard}:
4897 GNU extension
4899 @item @emph{Class}:
4900 Subroutine, function
4902 @item @emph{Syntax}:
4903 @code{CALL GETCWD(C [, STATUS])}
4905 @item @emph{Arguments}:
4906 @multitable @columnfractions .15 .70
4907 @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
4908 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success, 
4909 a system specific and nonzero error code otherwise.
4910 @end multitable
4912 @item @emph{Example}:
4913 @smallexample
4914 PROGRAM test_getcwd
4915   CHARACTER(len=255) :: cwd
4916   CALL getcwd(cwd)
4917   WRITE(*,*) TRIM(cwd)
4918 END PROGRAM
4919 @end smallexample
4921 @item @emph{See also}:
4922 @ref{CHDIR}
4923 @end table
4927 @node GETENV
4928 @section @code{GETENV} --- Get an environmental variable
4929 @fnindex GETENV
4930 @cindex environment variable
4932 @table @asis
4933 @item @emph{Description}:
4934 Get the @var{VALUE} of the environmental variable @var{NAME}.
4936 This intrinsic routine is provided for backwards compatibility with 
4937 GNU Fortran 77.  In new code, programmers should consider the use of 
4938 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4939 2003 standard.
4941 @item @emph{Standard}:
4942 GNU extension
4944 @item @emph{Class}:
4945 Subroutine
4947 @item @emph{Syntax}:
4948 @code{CALL GETENV(NAME, VALUE)}
4950 @item @emph{Arguments}:
4951 @multitable @columnfractions .15 .70
4952 @item @var{NAME}  @tab Shall be of type @code{CHARACTER} and of default kind.
4953 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
4954 @end multitable
4956 @item @emph{Return value}:
4957 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
4958 not large enough to hold the data, it is truncated. If @var{NAME}
4959 is not set, @var{VALUE} will be filled with blanks.
4961 @item @emph{Example}:
4962 @smallexample
4963 PROGRAM test_getenv
4964   CHARACTER(len=255) :: homedir
4965   CALL getenv("HOME", homedir)
4966   WRITE (*,*) TRIM(homedir)
4967 END PROGRAM
4968 @end smallexample
4970 @item @emph{See also}:
4971 @ref{GET_ENVIRONMENT_VARIABLE}
4972 @end table
4976 @node GET_ENVIRONMENT_VARIABLE
4977 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
4978 @fnindex GET_ENVIRONMENT_VARIABLE
4979 @cindex environment variable
4981 @table @asis
4982 @item @emph{Description}:
4983 Get the @var{VALUE} of the environmental variable @var{NAME}.
4985 @item @emph{Standard}:
4986 Fortran 2003 and later
4988 @item @emph{Class}:
4989 Subroutine
4991 @item @emph{Syntax}:
4992 @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
4994 @item @emph{Arguments}:
4995 @multitable @columnfractions .15 .70
4996 @item @var{NAME}      @tab Shall be a scalar of type @code{CHARACTER}
4997 and of default kind.
4998 @item @var{VALUE}     @tab Shall be a scalar of type @code{CHARACTER}
4999 and of default kind.
5000 @item @var{LENGTH}    @tab Shall be a scalar of type @code{INTEGER}
5001 and of default kind.
5002 @item @var{STATUS}    @tab Shall be a scalar of type @code{INTEGER}
5003 and of default kind.
5004 @item @var{TRIM_NAME} @tab Shall be a scalar of type @code{LOGICAL}
5005 and of default kind.
5006 @end multitable
5008 @item @emph{Return value}:
5009 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
5010 not large enough to hold the data, it is truncated. If @var{NAME}
5011 is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
5012 contains the length needed for storing the environment variable @var{NAME}
5013 or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
5014 but too short for the environment variable; it is 1 if the environment
5015 variable does not exist and 2 if the processor does not support environment
5016 variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
5017 present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
5018 are significant; otherwise they are not part of the environment variable
5019 name.
5021 @item @emph{Example}:
5022 @smallexample
5023 PROGRAM test_getenv
5024   CHARACTER(len=255) :: homedir
5025   CALL get_environment_variable("HOME", homedir)
5026   WRITE (*,*) TRIM(homedir)
5027 END PROGRAM
5028 @end smallexample
5029 @end table
5033 @node GETGID
5034 @section @code{GETGID} --- Group ID function
5035 @fnindex GETGID
5036 @cindex system, group id
5038 @table @asis
5039 @item @emph{Description}:
5040 Returns the numerical group ID of the current process.
5042 @item @emph{Standard}:
5043 GNU extension
5045 @item @emph{Class}:
5046 Function
5048 @item @emph{Syntax}:
5049 @code{RESULT = GETGID()}
5051 @item @emph{Return value}:
5052 The return value of @code{GETGID} is an @code{INTEGER} of the default
5053 kind.
5056 @item @emph{Example}:
5057 See @code{GETPID} for an example.
5059 @item @emph{See also}:
5060 @ref{GETPID}, @ref{GETUID}
5061 @end table
5065 @node GETLOG
5066 @section @code{GETLOG} --- Get login name
5067 @fnindex GETLOG
5068 @cindex system, login name
5069 @cindex login name
5071 @table @asis
5072 @item @emph{Description}:
5073 Gets the username under which the program is running.
5075 @item @emph{Standard}:
5076 GNU extension
5078 @item @emph{Class}:
5079 Subroutine
5081 @item @emph{Syntax}:
5082 @code{CALL GETLOG(C)}
5084 @item @emph{Arguments}:
5085 @multitable @columnfractions .15 .70
5086 @item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
5087 @end multitable
5089 @item @emph{Return value}:
5090 Stores the current user name in @var{LOGIN}.  (On systems where POSIX
5091 functions @code{geteuid} and @code{getpwuid} are not available, and 
5092 the @code{getlogin} function is not implemented either, this will
5093 return a blank string.)
5095 @item @emph{Example}:
5096 @smallexample
5097 PROGRAM TEST_GETLOG
5098   CHARACTER(32) :: login
5099   CALL GETLOG(login)
5100   WRITE(*,*) login
5101 END PROGRAM
5102 @end smallexample
5104 @item @emph{See also}:
5105 @ref{GETUID}
5106 @end table
5110 @node GETPID
5111 @section @code{GETPID} --- Process ID function
5112 @fnindex GETPID
5113 @cindex system, process id
5114 @cindex process id
5116 @table @asis
5117 @item @emph{Description}:
5118 Returns the numerical process identifier of the current process.
5120 @item @emph{Standard}:
5121 GNU extension
5123 @item @emph{Class}:
5124 Function
5126 @item @emph{Syntax}:
5127 @code{RESULT = GETPID()}
5129 @item @emph{Return value}:
5130 The return value of @code{GETPID} is an @code{INTEGER} of the default
5131 kind.
5134 @item @emph{Example}:
5135 @smallexample
5136 program info
5137   print *, "The current process ID is ", getpid()
5138   print *, "Your numerical user ID is ", getuid()
5139   print *, "Your numerical group ID is ", getgid()
5140 end program info
5141 @end smallexample
5143 @item @emph{See also}:
5144 @ref{GETGID}, @ref{GETUID}
5145 @end table
5149 @node GETUID
5150 @section @code{GETUID} --- User ID function
5151 @fnindex GETUID
5152 @cindex system, user id
5153 @cindex user id
5155 @table @asis
5156 @item @emph{Description}:
5157 Returns the numerical user ID of the current process.
5159 @item @emph{Standard}:
5160 GNU extension
5162 @item @emph{Class}:
5163 Function
5165 @item @emph{Syntax}:
5166 @code{RESULT = GETUID()}
5168 @item @emph{Return value}:
5169 The return value of @code{GETUID} is an @code{INTEGER} of the default
5170 kind.
5173 @item @emph{Example}:
5174 See @code{GETPID} for an example.
5176 @item @emph{See also}:
5177 @ref{GETPID}, @ref{GETLOG}
5178 @end table
5182 @node GMTIME
5183 @section @code{GMTIME} --- Convert time to GMT info
5184 @fnindex GMTIME
5185 @cindex time, conversion to GMT info
5187 @table @asis
5188 @item @emph{Description}:
5189 Given a system time value @var{TIME} (as provided by the @code{TIME8()}
5190 intrinsic), fills @var{VALUES} with values extracted from it appropriate
5191 to the UTC time zone (Universal Coordinated Time, also known in some
5192 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
5194 @item @emph{Standard}:
5195 GNU extension
5197 @item @emph{Class}:
5198 Subroutine
5200 @item @emph{Syntax}:
5201 @code{CALL GMTIME(TIME, VALUES)}
5203 @item @emph{Arguments}:
5204 @multitable @columnfractions .15 .70
5205 @item @var{TIME}   @tab An @code{INTEGER} scalar expression
5206 corresponding to a system time, with @code{INTENT(IN)}.
5207 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
5208 with @code{INTENT(OUT)}.
5209 @end multitable
5211 @item @emph{Return value}:
5212 The elements of @var{VALUES} are assigned as follows:
5213 @enumerate
5214 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
5215 seconds
5216 @item Minutes after the hour, range 0--59
5217 @item Hours past midnight, range 0--23
5218 @item Day of month, range 0--31
5219 @item Number of months since January, range 0--12
5220 @item Years since 1900
5221 @item Number of days since Sunday, range 0--6
5222 @item Days since January 1
5223 @item Daylight savings indicator: positive if daylight savings is in
5224 effect, zero if not, and negative if the information is not available.
5225 @end enumerate
5227 @item @emph{See also}:
5228 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
5230 @end table
5234 @node HOSTNM
5235 @section @code{HOSTNM} --- Get system host name
5236 @fnindex HOSTNM
5237 @cindex system, host name
5239 @table @asis
5240 @item @emph{Description}:
5241 Retrieves the host name of the system on which the program is running.
5243 This intrinsic is provided in both subroutine and function forms; however,
5244 only one form can be used in any given program unit.
5246 @item @emph{Standard}:
5247 GNU extension
5249 @item @emph{Class}:
5250 Subroutine, function
5252 @item @emph{Syntax}:
5253 @multitable @columnfractions .80
5254 @item @code{CALL HOSTNM(C [, STATUS])}
5255 @item @code{STATUS = HOSTNM(NAME)}
5256 @end multitable
5258 @item @emph{Arguments}:
5259 @multitable @columnfractions .15 .70
5260 @item @var{C}    @tab Shall of type @code{CHARACTER} and of default kind.
5261 @item @var{STATUS}  @tab (Optional) status flag of type @code{INTEGER}.
5262 Returns 0 on success, or a system specific error code otherwise.
5263 @end multitable
5265 @item @emph{Return value}:
5266 In either syntax, @var{NAME} is set to the current hostname if it can
5267 be obtained, or to a blank string otherwise.
5269 @end table
5273 @node HUGE
5274 @section @code{HUGE} --- Largest number of a kind
5275 @fnindex HUGE
5276 @cindex limits, largest number
5277 @cindex model representation, largest number
5279 @table @asis
5280 @item @emph{Description}:
5281 @code{HUGE(X)} returns the largest number that is not an infinity in
5282 the model of the type of @code{X}.
5284 @item @emph{Standard}:
5285 Fortran 95 and later
5287 @item @emph{Class}:
5288 Inquiry function
5290 @item @emph{Syntax}:
5291 @code{RESULT = HUGE(X)}
5293 @item @emph{Arguments}:
5294 @multitable @columnfractions .15 .70
5295 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
5296 @end multitable
5298 @item @emph{Return value}:
5299 The return value is of the same type and kind as @var{X}
5301 @item @emph{Example}:
5302 @smallexample
5303 program test_huge_tiny
5304   print *, huge(0), huge(0.0), huge(0.0d0)
5305   print *, tiny(0.0), tiny(0.0d0)
5306 end program test_huge_tiny
5307 @end smallexample
5308 @end table
5312 @node HYPOT
5313 @section @code{HYPOT} --- Euclidean distance function
5314 @fnindex HYPOT
5315 @cindex Euclidean distance
5317 @table @asis
5318 @item @emph{Description}:
5319 @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
5320 @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
5322 @item @emph{Standard}:
5323 Fortran 2008 and later
5325 @item @emph{Class}:
5326 Elemental function
5328 @item @emph{Syntax}:
5329 @code{RESULT = HYPOT(X, Y)}
5331 @item @emph{Arguments}:
5332 @multitable @columnfractions .15 .70
5333 @item @var{X} @tab The type shall be @code{REAL}.
5334 @item @var{Y} @tab The type and kind type parameter shall be the same as
5335 @var{X}.
5336 @end multitable
5338 @item @emph{Return value}:
5339 The return value has the same type and kind type parameter as @var{X}.
5341 @item @emph{Example}:
5342 @smallexample
5343 program test_hypot
5344   real(4) :: x = 1.e0_4, y = 0.5e0_4
5345   x = hypot(x,y)
5346 end program test_hypot
5347 @end smallexample
5348 @end table
5352 @node IACHAR
5353 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence 
5354 @fnindex IACHAR
5355 @cindex @acronym{ASCII} collating sequence
5356 @cindex collating sequence, @acronym{ASCII}
5357 @cindex conversion, to integer
5359 @table @asis
5360 @item @emph{Description}:
5361 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
5362 in the first character position of @code{C}.
5364 @item @emph{Standard}:
5365 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
5367 @item @emph{Class}:
5368 Elemental function
5370 @item @emph{Syntax}:
5371 @code{RESULT = IACHAR(C [, KIND])}
5373 @item @emph{Arguments}:
5374 @multitable @columnfractions .15 .70
5375 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5376 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5377 expression indicating the kind parameter of the result.
5378 @end multitable
5380 @item @emph{Return value}:
5381 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5382 @var{KIND} is absent, the return value is of default integer kind.
5384 @item @emph{Example}:
5385 @smallexample
5386 program test_iachar
5387   integer i
5388   i = iachar(' ')
5389 end program test_iachar
5390 @end smallexample
5392 @item @emph{Note}:
5393 See @ref{ICHAR} for a discussion of converting between numerical values
5394 and formatted string representations.
5396 @item @emph{See also}:
5397 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
5399 @end table
5403 @node IAND
5404 @section @code{IAND} --- Bitwise logical and
5405 @fnindex IAND
5406 @cindex bitwise logical and
5407 @cindex logical and, bitwise
5409 @table @asis
5410 @item @emph{Description}:
5411 Bitwise logical @code{AND}.
5413 @item @emph{Standard}:
5414 Fortran 95 and later
5416 @item @emph{Class}:
5417 Elemental function
5419 @item @emph{Syntax}:
5420 @code{RESULT = IAND(I, J)}
5422 @item @emph{Arguments}:
5423 @multitable @columnfractions .15 .70
5424 @item @var{I} @tab The type shall be @code{INTEGER}.
5425 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
5426 kind as @var{I}.  (As a GNU extension, different kinds are also 
5427 permitted.)
5428 @end multitable
5430 @item @emph{Return value}:
5431 The return type is @code{INTEGER}, of the same kind as the
5432 arguments.  (If the argument kinds differ, it is of the same kind as
5433 the larger argument.)
5435 @item @emph{Example}:
5436 @smallexample
5437 PROGRAM test_iand
5438   INTEGER :: a, b
5439   DATA a / Z'F' /, b / Z'3' /
5440   WRITE (*,*) IAND(a, b)
5441 END PROGRAM
5442 @end smallexample
5444 @item @emph{See also}:
5445 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5447 @end table
5451 @node IARGC
5452 @section @code{IARGC} --- Get the number of command line arguments
5453 @fnindex IARGC
5454 @cindex command-line arguments
5455 @cindex command-line arguments, number of
5456 @cindex arguments, to program
5458 @table @asis
5459 @item @emph{Description}:
5460 @code{IARGC()} returns the number of arguments passed on the
5461 command line when the containing program was invoked.
5463 This intrinsic routine is provided for backwards compatibility with 
5464 GNU Fortran 77.  In new code, programmers should consider the use of 
5465 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003 
5466 standard.
5468 @item @emph{Standard}:
5469 GNU extension
5471 @item @emph{Class}:
5472 Function
5474 @item @emph{Syntax}:
5475 @code{RESULT = IARGC()}
5477 @item @emph{Arguments}:
5478 None.
5480 @item @emph{Return value}:
5481 The number of command line arguments, type @code{INTEGER(4)}.
5483 @item @emph{Example}:
5484 See @ref{GETARG}
5486 @item @emph{See also}:
5487 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
5489 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
5490 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
5491 @end table
5495 @node IBCLR
5496 @section @code{IBCLR} --- Clear bit
5497 @fnindex IBCLR
5498 @cindex bits, unset
5499 @cindex bits, clear
5501 @table @asis
5502 @item @emph{Description}:
5503 @code{IBCLR} returns the value of @var{I} with the bit at position
5504 @var{POS} set to zero.
5506 @item @emph{Standard}:
5507 Fortran 95 and later
5509 @item @emph{Class}:
5510 Elemental function
5512 @item @emph{Syntax}:
5513 @code{RESULT = IBCLR(I, POS)}
5515 @item @emph{Arguments}:
5516 @multitable @columnfractions .15 .70
5517 @item @var{I} @tab The type shall be @code{INTEGER}.
5518 @item @var{POS} @tab The type shall be @code{INTEGER}.
5519 @end multitable
5521 @item @emph{Return value}:
5522 The return value is of type @code{INTEGER} and of the same kind as
5523 @var{I}.
5525 @item @emph{See also}:
5526 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
5528 @end table
5532 @node IBITS
5533 @section @code{IBITS} --- Bit extraction
5534 @fnindex IBITS
5535 @cindex bits, get
5536 @cindex bits, extract
5538 @table @asis
5539 @item @emph{Description}:
5540 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
5541 starting from bit position @var{POS} and extending left for @var{LEN}
5542 bits.  The result is right-justified and the remaining bits are
5543 zeroed.  The value of @code{POS+LEN} must be less than or equal to the
5544 value @code{BIT_SIZE(I)}.
5546 @item @emph{Standard}:
5547 Fortran 95 and later
5549 @item @emph{Class}:
5550 Elemental function
5552 @item @emph{Syntax}:
5553 @code{RESULT = IBITS(I, POS, LEN)}
5555 @item @emph{Arguments}:
5556 @multitable @columnfractions .15 .70
5557 @item @var{I}   @tab The type shall be @code{INTEGER}.
5558 @item @var{POS} @tab The type shall be @code{INTEGER}.
5559 @item @var{LEN} @tab The type shall be @code{INTEGER}.
5560 @end multitable
5562 @item @emph{Return value}:
5563 The return value is of type @code{INTEGER} and of the same kind as
5564 @var{I}.
5566 @item @emph{See also}:
5567 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
5568 @end table
5572 @node IBSET
5573 @section @code{IBSET} --- Set bit
5574 @fnindex IBSET
5575 @cindex bits, set
5577 @table @asis
5578 @item @emph{Description}:
5579 @code{IBSET} returns the value of @var{I} with the bit at position
5580 @var{POS} set to one.
5582 @item @emph{Standard}:
5583 Fortran 95 and later
5585 @item @emph{Class}:
5586 Elemental function
5588 @item @emph{Syntax}:
5589 @code{RESULT = IBSET(I, POS)}
5591 @item @emph{Arguments}:
5592 @multitable @columnfractions .15 .70
5593 @item @var{I} @tab The type shall be @code{INTEGER}.
5594 @item @var{POS} @tab The type shall be @code{INTEGER}.
5595 @end multitable
5597 @item @emph{Return value}:
5598 The return value is of type @code{INTEGER} and of the same kind as
5599 @var{I}.
5601 @item @emph{See also}:
5602 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
5604 @end table
5608 @node ICHAR
5609 @section @code{ICHAR} --- Character-to-integer conversion function
5610 @fnindex ICHAR
5611 @cindex conversion, to integer
5613 @table @asis
5614 @item @emph{Description}:
5615 @code{ICHAR(C)} returns the code for the character in the first character
5616 position of @code{C} in the system's native character set.
5617 The correspondence between characters and their codes is not necessarily
5618 the same across different GNU Fortran implementations.
5620 @item @emph{Standard}:
5621 Fortan 95 and later, with @var{KIND} argument Fortran 2003 and later
5623 @item @emph{Class}:
5624 Elemental function
5626 @item @emph{Syntax}:
5627 @code{RESULT = ICHAR(C [, KIND])}
5629 @item @emph{Arguments}:
5630 @multitable @columnfractions .15 .70
5631 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5632 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5633 expression indicating the kind parameter of the result.
5634 @end multitable
5636 @item @emph{Return value}:
5637 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5638 @var{KIND} is absent, the return value is of default integer kind.
5640 @item @emph{Example}:
5641 @smallexample
5642 program test_ichar
5643   integer i
5644   i = ichar(' ')
5645 end program test_ichar
5646 @end smallexample
5648 @item @emph{Specific names}:
5649 @multitable @columnfractions .20 .20 .20 .25
5650 @item Name             @tab Argument             @tab Return type       @tab Standard
5651 @item @code{ICHAR(C)}  @tab @code{CHARACTER C}   @tab @code{INTEGER(4)}    @tab Fortran 77 and later
5652 @end multitable
5654 @item @emph{Note}:
5655 No intrinsic exists to convert between a numeric value and a formatted
5656 character string representation -- for instance, given the
5657 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
5658 @code{REAL} value with the value 154, or vice versa. Instead, this
5659 functionality is provided by internal-file I/O, as in the following
5660 example:
5661 @smallexample
5662 program read_val
5663   integer value
5664   character(len=10) string, string2
5665   string = '154'
5666   
5667   ! Convert a string to a numeric value
5668   read (string,'(I10)') value
5669   print *, value
5670   
5671   ! Convert a value to a formatted string
5672   write (string2,'(I10)') value
5673   print *, string2
5674 end program read_val
5675 @end smallexample
5677 @item @emph{See also}:
5678 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
5680 @end table
5684 @node IDATE
5685 @section @code{IDATE} --- Get current local time subroutine (day/month/year) 
5686 @fnindex IDATE
5687 @cindex date, current
5688 @cindex current date
5690 @table @asis
5691 @item @emph{Description}:
5692 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the  
5693 current local time. The day (in the range 1-31), month (in the range 1-12), 
5694 and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively. 
5695 The year has four significant digits.
5697 @item @emph{Standard}:
5698 GNU extension
5700 @item @emph{Class}:
5701 Subroutine
5703 @item @emph{Syntax}:
5704 @code{CALL IDATE(VALUES)}
5706 @item @emph{Arguments}:
5707 @multitable @columnfractions .15 .70
5708 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
5709 the kind shall be the default integer kind.
5710 @end multitable
5712 @item @emph{Return value}:
5713 Does not return anything.
5715 @item @emph{Example}:
5716 @smallexample
5717 program test_idate
5718   integer, dimension(3) :: tarray
5719   call idate(tarray)
5720   print *, tarray(1)
5721   print *, tarray(2)
5722   print *, tarray(3)
5723 end program test_idate
5724 @end smallexample
5725 @end table
5729 @node IEOR
5730 @section @code{IEOR} --- Bitwise logical exclusive or
5731 @fnindex IEOR
5732 @cindex bitwise logical exclusive or
5733 @cindex logical exclusive or, bitwise
5735 @table @asis
5736 @item @emph{Description}:
5737 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
5738 @var{J}.
5740 @item @emph{Standard}:
5741 Fortran 95 and later
5743 @item @emph{Class}:
5744 Elemental function
5746 @item @emph{Syntax}:
5747 @code{RESULT = IEOR(I, J)}
5749 @item @emph{Arguments}:
5750 @multitable @columnfractions .15 .70
5751 @item @var{I} @tab The type shall be @code{INTEGER}.
5752 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
5753 kind as @var{I}.  (As a GNU extension, different kinds are also 
5754 permitted.)
5755 @end multitable
5757 @item @emph{Return value}:
5758 The return type is @code{INTEGER}, of the same kind as the
5759 arguments.  (If the argument kinds differ, it is of the same kind as
5760 the larger argument.)
5762 @item @emph{See also}:
5763 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5764 @end table
5768 @node IERRNO
5769 @section @code{IERRNO} --- Get the last system error number
5770 @fnindex IERRNO
5771 @cindex system, error handling
5773 @table @asis
5774 @item @emph{Description}:
5775 Returns the last system error number, as given by the C @code{errno()}
5776 function.
5778 @item @emph{Standard}:
5779 GNU extension
5781 @item @emph{Class}:
5782 Function
5784 @item @emph{Syntax}:
5785 @code{RESULT = IERRNO()}
5787 @item @emph{Arguments}:
5788 None.
5790 @item @emph{Return value}:
5791 The return value is of type @code{INTEGER} and of the default integer
5792 kind.
5794 @item @emph{See also}:
5795 @ref{PERROR}
5796 @end table
5800 @node INDEX intrinsic
5801 @section @code{INDEX} --- Position of a substring within a string
5802 @fnindex INDEX
5803 @cindex substring position
5804 @cindex string, find substring
5806 @table @asis
5807 @item @emph{Description}:
5808 Returns the position of the start of the first occurrence of string
5809 @var{SUBSTRING} as a substring in @var{STRING}, counting from one.  If
5810 @var{SUBSTRING} is not present in @var{STRING}, zero is returned.  If 
5811 the @var{BACK} argument is present and true, the return value is the
5812 start of the last occurrence rather than the first.
5814 @item @emph{Standard}:
5815 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
5817 @item @emph{Class}:
5818 Elemental function
5820 @item @emph{Syntax}:
5821 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
5823 @item @emph{Arguments}:
5824 @multitable @columnfractions .15 .70
5825 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
5826 @code{INTENT(IN)}
5827 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
5828 @code{INTENT(IN)}
5829 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
5830 @code{INTENT(IN)}
5831 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5832 expression indicating the kind parameter of the result.
5833 @end multitable
5835 @item @emph{Return value}:
5836 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5837 @var{KIND} is absent, the return value is of default integer kind.
5839 @item @emph{Specific names}:
5840 @multitable @columnfractions .20 .20 .20 .25
5841 @item Name                            @tab Argument           @tab Return type       @tab Standard
5842 @item @code{INDEX(STRING, SUBSTRING)} @tab @code{CHARACTER}   @tab @code{INTEGER(4)} @tab Fortran 77 and later
5843 @end multitable
5845 @item @emph{See also}:
5846 @ref{SCAN}, @ref{VERIFY}
5847 @end table
5851 @node INT
5852 @section @code{INT} --- Convert to integer type
5853 @fnindex INT
5854 @fnindex IFIX
5855 @fnindex IDINT
5856 @cindex conversion, to integer
5858 @table @asis
5859 @item @emph{Description}:
5860 Convert to integer type
5862 @item @emph{Standard}:
5863 Fortran 77 and later
5865 @item @emph{Class}:
5866 Elemental function
5868 @item @emph{Syntax}:
5869 @code{RESULT = INT(A [, KIND))}
5871 @item @emph{Arguments}:
5872 @multitable @columnfractions .15 .70
5873 @item @var{A}    @tab Shall be of type @code{INTEGER},
5874 @code{REAL}, or @code{COMPLEX}.
5875 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5876 expression indicating the kind parameter of the result.
5877 @end multitable
5879 @item @emph{Return value}:
5880 These functions return a @code{INTEGER} variable or array under 
5881 the following rules: 
5883 @table @asis
5884 @item (A)
5885 If @var{A} is of type @code{INTEGER}, @code{INT(A) = A} 
5886 @item (B)
5887 If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} equals @code{0}. 
5888 If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed 
5889 the range of @var{A} and whose sign is the same as the sign of @var{A}.
5890 @item (C)
5891 If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
5892 @end table
5894 @item @emph{Example}:
5895 @smallexample
5896 program test_int
5897   integer :: i = 42
5898   complex :: z = (-3.7, 1.0)
5899   print *, int(i)
5900   print *, int(z), int(z,8)
5901 end program
5902 @end smallexample
5904 @item @emph{Specific names}:
5905 @multitable @columnfractions .20 .20 .20 .25
5906 @item Name            @tab Argument          @tab Return type       @tab Standard
5907 @item @code{INT(A)}   @tab @code{REAL(4) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
5908 @item @code{IFIX(A)}  @tab @code{REAL(4) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
5909 @item @code{IDINT(A)} @tab @code{REAL(8) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
5910 @end multitable
5912 @end table
5915 @node INT2
5916 @section @code{INT2} --- Convert to 16-bit integer type
5917 @fnindex INT2
5918 @fnindex SHORT
5919 @cindex conversion, to integer
5921 @table @asis
5922 @item @emph{Description}:
5923 Convert to a @code{KIND=2} integer type. This is equivalent to the
5924 standard @code{INT} intrinsic with an optional argument of
5925 @code{KIND=2}, and is only included for backwards compatibility.
5927 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
5929 @item @emph{Standard}:
5930 GNU extension
5932 @item @emph{Class}:
5933 Elemental function
5935 @item @emph{Syntax}:
5936 @code{RESULT = INT2(A)}
5938 @item @emph{Arguments}:
5939 @multitable @columnfractions .15 .70
5940 @item @var{A}    @tab Shall be of type @code{INTEGER},
5941 @code{REAL}, or @code{COMPLEX}.
5942 @end multitable
5944 @item @emph{Return value}:
5945 The return value is a @code{INTEGER(2)} variable.
5947 @item @emph{See also}:
5948 @ref{INT}, @ref{INT8}, @ref{LONG}
5949 @end table
5953 @node INT8
5954 @section @code{INT8} --- Convert to 64-bit integer type
5955 @fnindex INT8
5956 @cindex conversion, to integer
5958 @table @asis
5959 @item @emph{Description}:
5960 Convert to a @code{KIND=8} integer type. This is equivalent to the
5961 standard @code{INT} intrinsic with an optional argument of
5962 @code{KIND=8}, and is only included for backwards compatibility.
5964 @item @emph{Standard}:
5965 GNU extension
5967 @item @emph{Class}:
5968 Elemental function
5970 @item @emph{Syntax}:
5971 @code{RESULT = INT8(A)}
5973 @item @emph{Arguments}:
5974 @multitable @columnfractions .15 .70
5975 @item @var{A}    @tab Shall be of type @code{INTEGER},
5976 @code{REAL}, or @code{COMPLEX}.
5977 @end multitable
5979 @item @emph{Return value}:
5980 The return value is a @code{INTEGER(8)} variable.
5982 @item @emph{See also}:
5983 @ref{INT}, @ref{INT2}, @ref{LONG}
5984 @end table
5988 @node IOR
5989 @section @code{IOR} --- Bitwise logical or
5990 @fnindex IOR
5991 @cindex bitwise logical or
5992 @cindex logical or, bitwise
5994 @table @asis
5995 @item @emph{Description}:
5996 @code{IOR} returns the bitwise boolean inclusive-OR of @var{I} and
5997 @var{J}.
5999 @item @emph{Standard}:
6000 Fortran 95 and later
6002 @item @emph{Class}:
6003 Elemental function
6005 @item @emph{Syntax}:
6006 @code{RESULT = IOR(I, J)}
6008 @item @emph{Arguments}:
6009 @multitable @columnfractions .15 .70
6010 @item @var{I} @tab The type shall be @code{INTEGER}.
6011 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6012 kind as @var{I}.  (As a GNU extension, different kinds are also 
6013 permitted.)
6014 @end multitable
6016 @item @emph{Return value}:
6017 The return type is @code{INTEGER}, of the same kind as the
6018 arguments.  (If the argument kinds differ, it is of the same kind as
6019 the larger argument.)
6021 @item @emph{See also}:
6022 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6023 @end table
6027 @node IRAND
6028 @section @code{IRAND} --- Integer pseudo-random number
6029 @fnindex IRAND
6030 @cindex random number generation
6032 @table @asis
6033 @item @emph{Description}:
6034 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
6035 distribution between 0 and a system-dependent limit (which is in most
6036 cases 2147483647). If @var{FLAG} is 0, the next number
6037 in the current sequence is returned; if @var{FLAG} is 1, the generator
6038 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
6039 it is used as a new seed with @code{SRAND}.
6041 This intrinsic routine is provided for backwards compatibility with
6042 GNU Fortran 77. It implements a simple modulo generator as provided 
6043 by @command{g77}. For new code, one should consider the use of 
6044 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
6046 @item @emph{Standard}:
6047 GNU extension
6049 @item @emph{Class}:
6050 Function
6052 @item @emph{Syntax}:
6053 @code{RESULT = IRAND(I)}
6055 @item @emph{Arguments}:
6056 @multitable @columnfractions .15 .70
6057 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
6058 @end multitable
6060 @item @emph{Return value}:
6061 The return value is of @code{INTEGER(kind=4)} type.
6063 @item @emph{Example}:
6064 @smallexample
6065 program test_irand
6066   integer,parameter :: seed = 86456
6067   
6068   call srand(seed)
6069   print *, irand(), irand(), irand(), irand()
6070   print *, irand(seed), irand(), irand(), irand()
6071 end program test_irand
6072 @end smallexample
6074 @end table
6078 @node IMAGE_INDEX
6079 @section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index
6080 @fnindex IMAGE_INDEX
6081 @cindex coarray, IMAGE_INDEX
6082 @cindex images, cosubscript to image index conversion
6084 @table @asis
6085 @item @emph{Description}:
6086 Returns the image index belonging to a cosubscript.
6088 @item @emph{Standard}:
6089 Fortran 2008 and later
6091 @item @emph{Class}:
6092 Inquiry function.
6094 @item @emph{Syntax}:
6095 @code{RESULT = IMAGE_INDEX(COARRAY, SUB)}
6097 @item @emph{Arguments}: None.
6098 @multitable @columnfractions .15 .70
6099 @item @var{COARRAY} @tab Coarray of any type.
6100 @item @var{SUB}     @tab default integer rank-1 array of a size equal to
6101 the corank of @var{COARRAY}.
6102 @end multitable
6105 @item @emph{Return value}:
6106 Scalar default integer with the value of the image index which corresponds
6107 to the cosubscripts. For invalid cosubscripts the result is zero.
6109 @item @emph{Example}:
6110 @smallexample
6111 INTEGER :: array[2,-1:4,8,*]
6112 ! Writes  28 (or 0 if there are fewer than 28 images)
6113 WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1])
6114 @end smallexample
6116 @item @emph{See also}:
6117 @ref{THIS_IMAGE}, @ref{NUM_IMAGES}
6118 @end table
6122 @node IS_IOSTAT_END
6123 @section @code{IS_IOSTAT_END} --- Test for end-of-file value
6124 @fnindex IS_IOSTAT_END
6125 @cindex IOSTAT, end of file
6127 @table @asis
6128 @item @emph{Description}:
6129 @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
6130 status ``end of file''. The function is equivalent to comparing the variable
6131 with the @code{IOSTAT_END} parameter of the intrinsic module
6132 @code{ISO_FORTRAN_ENV}.
6134 @item @emph{Standard}:
6135 Fortran 2003 and later
6137 @item @emph{Class}:
6138 Elemental function
6140 @item @emph{Syntax}:
6141 @code{RESULT = IS_IOSTAT_END(I)}
6143 @item @emph{Arguments}:
6144 @multitable @columnfractions .15 .70
6145 @item @var{I} @tab Shall be of the type @code{INTEGER}.
6146 @end multitable
6148 @item @emph{Return value}:
6149 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6150 @var{I} has the value which indicates an end of file condition for
6151 IOSTAT= specifiers, and is @code{.FALSE.} otherwise.
6153 @item @emph{Example}:
6154 @smallexample
6155 PROGRAM iostat
6156   IMPLICIT NONE
6157   INTEGER :: stat, i
6158   OPEN(88, FILE='test.dat')
6159   READ(88, *, IOSTAT=stat) i
6160   IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
6161 END PROGRAM
6162 @end smallexample
6163 @end table
6167 @node IS_IOSTAT_EOR
6168 @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
6169 @fnindex IS_IOSTAT_EOR
6170 @cindex IOSTAT, end of record
6172 @table @asis
6173 @item @emph{Description}:
6174 @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
6175 status ``end of record''. The function is equivalent to comparing the
6176 variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
6177 @code{ISO_FORTRAN_ENV}.
6179 @item @emph{Standard}:
6180 Fortran 2003 and later
6182 @item @emph{Class}:
6183 Elemental function
6185 @item @emph{Syntax}:
6186 @code{RESULT = IS_IOSTAT_EOR(I)}
6188 @item @emph{Arguments}:
6189 @multitable @columnfractions .15 .70
6190 @item @var{I} @tab Shall be of the type @code{INTEGER}.
6191 @end multitable
6193 @item @emph{Return value}:
6194 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6195 @var{I} has the value which indicates an end of file condition for
6196 IOSTAT= specifiers, and is @code{.FALSE.} otherwise.
6198 @item @emph{Example}:
6199 @smallexample
6200 PROGRAM iostat
6201   IMPLICIT NONE
6202   INTEGER :: stat, i(50)
6203   OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
6204   READ(88, IOSTAT=stat) i
6205   IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
6206 END PROGRAM
6207 @end smallexample
6208 @end table
6212 @node ISATTY
6213 @section @code{ISATTY} --- Whether a unit is a terminal device.
6214 @fnindex ISATTY
6215 @cindex system, terminal
6217 @table @asis
6218 @item @emph{Description}:
6219 Determine whether a unit is connected to a terminal device.
6221 @item @emph{Standard}:
6222 GNU extension
6224 @item @emph{Class}:
6225 Function
6227 @item @emph{Syntax}:
6228 @code{RESULT = ISATTY(UNIT)}
6230 @item @emph{Arguments}:
6231 @multitable @columnfractions .15 .70
6232 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
6233 @end multitable
6235 @item @emph{Return value}:
6236 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal 
6237 device, @code{.FALSE.} otherwise.
6239 @item @emph{Example}:
6240 @smallexample
6241 PROGRAM test_isatty
6242   INTEGER(kind=1) :: unit
6243   DO unit = 1, 10
6244     write(*,*) isatty(unit=unit)
6245   END DO
6246 END PROGRAM
6247 @end smallexample
6248 @item @emph{See also}:
6249 @ref{TTYNAM}
6250 @end table
6254 @node ISHFT
6255 @section @code{ISHFT} --- Shift bits
6256 @fnindex ISHFT
6257 @cindex bits, shift
6259 @table @asis
6260 @item @emph{Description}:
6261 @code{ISHFT} returns a value corresponding to @var{I} with all of the
6262 bits shifted @var{SHIFT} places.  A value of @var{SHIFT} greater than
6263 zero corresponds to a left shift, a value of zero corresponds to no
6264 shift, and a value less than zero corresponds to a right shift.  If the
6265 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
6266 value is undefined.  Bits shifted out from the left end or right end are
6267 lost; zeros are shifted in from the opposite end.
6269 @item @emph{Standard}:
6270 Fortran 95 and later
6272 @item @emph{Class}:
6273 Elemental function
6275 @item @emph{Syntax}:
6276 @code{RESULT = ISHFT(I, SHIFT)}
6278 @item @emph{Arguments}:
6279 @multitable @columnfractions .15 .70
6280 @item @var{I} @tab The type shall be @code{INTEGER}.
6281 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
6282 @end multitable
6284 @item @emph{Return value}:
6285 The return value is of type @code{INTEGER} and of the same kind as
6286 @var{I}.
6288 @item @emph{See also}:
6289 @ref{ISHFTC}
6290 @end table
6294 @node ISHFTC
6295 @section @code{ISHFTC} --- Shift bits circularly
6296 @fnindex ISHFTC
6297 @cindex bits, shift circular
6299 @table @asis
6300 @item @emph{Description}:
6301 @code{ISHFTC} returns a value corresponding to @var{I} with the
6302 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
6303 is, bits shifted out one end are shifted into the opposite end.  A value
6304 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
6305 zero corresponds to no shift, and a value less than zero corresponds to
6306 a right shift.  The absolute value of @var{SHIFT} must be less than
6307 @var{SIZE}.  If the @var{SIZE} argument is omitted, it is taken to be
6308 equivalent to @code{BIT_SIZE(I)}.
6310 @item @emph{Standard}:
6311 Fortran 95 and later
6313 @item @emph{Class}:
6314 Elemental function
6316 @item @emph{Syntax}:
6317 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
6319 @item @emph{Arguments}:
6320 @multitable @columnfractions .15 .70
6321 @item @var{I} @tab The type shall be @code{INTEGER}.
6322 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
6323 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
6324 the value must be greater than zero and less than or equal to
6325 @code{BIT_SIZE(I)}.
6326 @end multitable
6328 @item @emph{Return value}:
6329 The return value is of type @code{INTEGER} and of the same kind as
6330 @var{I}.
6332 @item @emph{See also}:
6333 @ref{ISHFT}
6334 @end table
6338 @node ISNAN
6339 @section @code{ISNAN} --- Test for a NaN
6340 @fnindex ISNAN
6341 @cindex IEEE, ISNAN
6343 @table @asis
6344 @item @emph{Description}:
6345 @code{ISNAN} tests whether a floating-point value is an IEEE
6346 Not-a-Number (NaN).
6347 @item @emph{Standard}:
6348 GNU extension
6350 @item @emph{Class}:
6351 Elemental function
6353 @item @emph{Syntax}:
6354 @code{ISNAN(X)}
6356 @item @emph{Arguments}:
6357 @multitable @columnfractions .15 .70
6358 @item @var{X} @tab Variable of the type @code{REAL}.
6360 @end multitable
6362 @item @emph{Return value}:
6363 Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
6364 if @var{X} is a NaN and @code{FALSE} otherwise.
6366 @item @emph{Example}:
6367 @smallexample
6368 program test_nan
6369   implicit none
6370   real :: x
6371   x = -1.0
6372   x = sqrt(x)
6373   if (isnan(x)) stop '"x" is a NaN'
6374 end program test_nan
6375 @end smallexample
6376 @end table
6380 @node ITIME
6381 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds) 
6382 @fnindex ITIME
6383 @cindex time, current
6384 @cindex current time
6386 @table @asis
6387 @item @emph{Description}:
6388 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the  
6389 current local time. The hour (in the range 1-24), minute (in the range 1-60), 
6390 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES}, 
6391 respectively.
6393 @item @emph{Standard}:
6394 GNU extension
6396 @item @emph{Class}:
6397 Subroutine
6399 @item @emph{Syntax}:
6400 @code{CALL ITIME(VALUES)}
6402 @item @emph{Arguments}:
6403 @multitable @columnfractions .15 .70
6404 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
6405 and the kind shall be the default integer kind.
6406 @end multitable
6408 @item @emph{Return value}:
6409 Does not return anything.
6412 @item @emph{Example}:
6413 @smallexample
6414 program test_itime
6415   integer, dimension(3) :: tarray
6416   call itime(tarray)
6417   print *, tarray(1)
6418   print *, tarray(2)
6419   print *, tarray(3)
6420 end program test_itime
6421 @end smallexample
6422 @end table
6426 @node KILL
6427 @section @code{KILL} --- Send a signal to a process
6428 @fnindex KILL
6430 @table @asis
6431 @item @emph{Description}:
6432 @item @emph{Standard}:
6433 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
6434 See @code{kill(2)}.
6436 This intrinsic is provided in both subroutine and function forms; however,
6437 only one form can be used in any given program unit.
6439 @item @emph{Class}:
6440 Subroutine, function
6442 @item @emph{Syntax}:
6443 @code{CALL KILL(C, VALUE [, STATUS])}
6445 @item @emph{Arguments}:
6446 @multitable @columnfractions .15 .70
6447 @item @var{C} @tab Shall be a scalar @code{INTEGER}, with
6448 @code{INTENT(IN)}
6449 @item @var{VALUE} @tab Shall be a scalar @code{INTEGER}, with
6450 @code{INTENT(IN)}
6451 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
6452 @code{INTEGER(8)}. Returns 0 on success, or a system-specific error code
6453 otherwise.
6454 @end multitable
6456 @item @emph{See also}:
6457 @ref{ABORT}, @ref{EXIT}
6458 @end table
6462 @node KIND
6463 @section @code{KIND} --- Kind of an entity
6464 @fnindex KIND
6465 @cindex kind
6467 @table @asis
6468 @item @emph{Description}:
6469 @code{KIND(X)} returns the kind value of the entity @var{X}.
6471 @item @emph{Standard}:
6472 Fortran 95 and later
6474 @item @emph{Class}:
6475 Inquiry function
6477 @item @emph{Syntax}:
6478 @code{K = KIND(X)}
6480 @item @emph{Arguments}:
6481 @multitable @columnfractions .15 .70
6482 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
6483 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
6484 @end multitable
6486 @item @emph{Return value}:
6487 The return value is a scalar of type @code{INTEGER} and of the default
6488 integer kind.
6490 @item @emph{Example}:
6491 @smallexample
6492 program test_kind
6493   integer,parameter :: kc = kind(' ')
6494   integer,parameter :: kl = kind(.true.)
6496   print *, "The default character kind is ", kc
6497   print *, "The default logical kind is ", kl
6498 end program test_kind
6499 @end smallexample
6501 @end table
6505 @node LBOUND
6506 @section @code{LBOUND} --- Lower dimension bounds of an array
6507 @fnindex LBOUND
6508 @cindex array, lower bound
6510 @table @asis
6511 @item @emph{Description}:
6512 Returns the lower bounds of an array, or a single lower bound
6513 along the @var{DIM} dimension.
6514 @item @emph{Standard}:
6515 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6517 @item @emph{Class}:
6518 Inquiry function
6520 @item @emph{Syntax}:
6521 @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
6523 @item @emph{Arguments}:
6524 @multitable @columnfractions .15 .70
6525 @item @var{ARRAY} @tab Shall be an array, of any type.
6526 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
6527 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6528 expression indicating the kind parameter of the result.
6529 @end multitable
6531 @item @emph{Return value}:
6532 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6533 @var{KIND} is absent, the return value is of default integer kind.
6534 If @var{DIM} is absent, the result is an array of the lower bounds of
6535 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
6536 corresponding to the lower bound of the array along that dimension.  If
6537 @var{ARRAY} is an expression rather than a whole array or array
6538 structure component, or if it has a zero extent along the relevant
6539 dimension, the lower bound is taken to be 1.
6541 @item @emph{See also}:
6542 @ref{UBOUND}, @ref{LCOBOUND}
6543 @end table
6547 @node LCOBOUND
6548 @section @code{LCOBOUND} --- Lower codimension bounds of an array
6549 @fnindex LCOBOUND
6550 @cindex coarray, lower bound
6552 @table @asis
6553 @item @emph{Description}:
6554 Returns the lower bounds of a coarray, or a single lower cobound
6555 along the @var{DIM} codimension.
6556 @item @emph{Standard}:
6557 Fortran 2008 and later
6559 @item @emph{Class}:
6560 Inquiry function
6562 @item @emph{Syntax}:
6563 @code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])}
6565 @item @emph{Arguments}:
6566 @multitable @columnfractions .15 .70
6567 @item @var{ARRAY} @tab Shall be an coarray, of any type.
6568 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
6569 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6570 expression indicating the kind parameter of the result.
6571 @end multitable
6573 @item @emph{Return value}:
6574 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6575 @var{KIND} is absent, the return value is of default integer kind.
6576 If @var{DIM} is absent, the result is an array of the lower cobounds of
6577 @var{COARRAY}.  If @var{DIM} is present, the result is a scalar
6578 corresponding to the lower cobound of the array along that codimension.
6580 @item @emph{See also}:
6581 @ref{UCOBOUND}, @ref{LBOUND}
6582 @end table
6586 @node LEADZ
6587 @section @code{LEADZ} --- Number of leading zero bits of an integer
6588 @fnindex LEADZ
6589 @cindex zero bits
6591 @table @asis
6592 @item @emph{Description}:
6593 @code{LEADZ} returns the number of leading zero bits of an integer.
6595 @item @emph{Standard}:
6596 Fortran 2008 and later
6598 @item @emph{Class}:
6599 Elemental function
6601 @item @emph{Syntax}:
6602 @code{RESULT = LEADZ(I)}
6604 @item @emph{Arguments}:
6605 @multitable @columnfractions .15 .70
6606 @item @var{I} @tab Shall be of type @code{INTEGER}.
6607 @end multitable
6609 @item @emph{Return value}:
6610 The type of the return value is the default @code{INTEGER}.
6611 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
6613 @item @emph{Example}:
6614 @smallexample
6615 PROGRAM test_leadz
6616   WRITE (*,*) LEADZ(1)  ! prints 8 if BITSIZE(I) has the value 32
6617 END PROGRAM
6618 @end smallexample
6620 @item @emph{See also}:
6621 @ref{BIT_SIZE}, @ref{TRAILZ}
6622 @end table
6626 @node LEN
6627 @section @code{LEN} --- Length of a character entity
6628 @fnindex LEN
6629 @cindex string, length
6631 @table @asis
6632 @item @emph{Description}:
6633 Returns the length of a character string.  If @var{STRING} is an array,
6634 the length of an element of @var{STRING} is returned.  Note that
6635 @var{STRING} need not be defined when this intrinsic is invoked, since
6636 only the length, not the content, of @var{STRING} is needed.
6638 @item @emph{Standard}:
6639 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
6641 @item @emph{Class}:
6642 Inquiry function
6644 @item @emph{Syntax}:
6645 @code{L = LEN(STRING [, KIND])}
6647 @item @emph{Arguments}:
6648 @multitable @columnfractions .15 .70
6649 @item @var{STRING} @tab Shall be a scalar or array of type
6650 @code{CHARACTER}, with @code{INTENT(IN)}
6651 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6652 expression indicating the kind parameter of the result.
6653 @end multitable
6655 @item @emph{Return value}:
6656 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6657 @var{KIND} is absent, the return value is of default integer kind.
6660 @item @emph{Specific names}:
6661 @multitable @columnfractions .20 .20 .20 .25
6662 @item Name               @tab Argument          @tab Return type       @tab Standard
6663 @item @code{LEN(STRING)} @tab @code{CHARACTER}  @tab @code{INTEGER}    @tab Fortran 77 and later
6664 @end multitable
6667 @item @emph{See also}:
6668 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
6669 @end table
6673 @node LEN_TRIM
6674 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
6675 @fnindex LEN_TRIM
6676 @cindex string, length, without trailing whitespace
6678 @table @asis
6679 @item @emph{Description}:
6680 Returns the length of a character string, ignoring any trailing blanks.
6682 @item @emph{Standard}:
6683 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6685 @item @emph{Class}:
6686 Elemental function
6688 @item @emph{Syntax}:
6689 @code{RESULT = LEN_TRIM(STRING [, KIND])}
6691 @item @emph{Arguments}:
6692 @multitable @columnfractions .15 .70
6693 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
6694 with @code{INTENT(IN)}
6695 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6696 expression indicating the kind parameter of the result.
6697 @end multitable
6699 @item @emph{Return value}:
6700 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6701 @var{KIND} is absent, the return value is of default integer kind.
6703 @item @emph{See also}:
6704 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
6705 @end table
6709 @node LGE
6710 @section @code{LGE} --- Lexical greater than or equal
6711 @fnindex LGE
6712 @cindex lexical comparison of strings
6713 @cindex string, comparison
6715 @table @asis
6716 @item @emph{Description}:
6717 Determines whether one string is lexically greater than or equal to
6718 another string, where the two strings are interpreted as containing
6719 ASCII character codes.  If the String A and String B are not the same
6720 length, the shorter is compared as if spaces were appended to it to form
6721 a value that has the same length as the longer.
6723 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6724 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6725 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6726 that the latter use the processor's character ordering (which is not
6727 ASCII on some targets), whereas the former always use the ASCII
6728 ordering.
6730 @item @emph{Standard}:
6731 Fortran 77 and later
6733 @item @emph{Class}:
6734 Elemental function
6736 @item @emph{Syntax}:
6737 @code{RESULT = LGE(STRING_A, STRING_B)}
6739 @item @emph{Arguments}:
6740 @multitable @columnfractions .15 .70
6741 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6742 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6743 @end multitable
6745 @item @emph{Return value}:
6746 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
6747 otherwise, based on the ASCII ordering.
6749 @item @emph{Specific names}:
6750 @multitable @columnfractions .20 .20 .20 .25
6751 @item Name                           @tab Argument          @tab Return type       @tab Standard
6752 @item @code{LGE(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
6753 @end multitable
6755 @item @emph{See also}:
6756 @ref{LGT}, @ref{LLE}, @ref{LLT}
6757 @end table
6761 @node LGT
6762 @section @code{LGT} --- Lexical greater than
6763 @fnindex LGT
6764 @cindex lexical comparison of strings
6765 @cindex string, comparison
6767 @table @asis
6768 @item @emph{Description}:
6769 Determines whether one string is lexically greater than another string,
6770 where the two strings are interpreted as containing ASCII character
6771 codes.  If the String A and String B are not the same length, the
6772 shorter is compared as if spaces were appended to it to form a value
6773 that has the same length as the longer.
6775 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6776 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6777 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6778 that the latter use the processor's character ordering (which is not
6779 ASCII on some targets), whereas the former always use the ASCII
6780 ordering.
6782 @item @emph{Standard}:
6783 Fortran 77 and later
6785 @item @emph{Class}:
6786 Elemental function
6788 @item @emph{Syntax}:
6789 @code{RESULT = LGT(STRING_A, STRING_B)}
6791 @item @emph{Arguments}:
6792 @multitable @columnfractions .15 .70
6793 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6794 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6795 @end multitable
6797 @item @emph{Return value}:
6798 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
6799 otherwise, based on the ASCII ordering.
6801 @item @emph{Specific names}:
6802 @multitable @columnfractions .20 .20 .20 .25
6803 @item Name                           @tab Argument          @tab Return type       @tab Standard
6804 @item @code{LGT(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
6805 @end multitable
6807 @item @emph{See also}:
6808 @ref{LGE}, @ref{LLE}, @ref{LLT}
6809 @end table
6813 @node LINK
6814 @section @code{LINK} --- Create a hard link
6815 @fnindex LINK
6816 @cindex file system, create link
6817 @cindex file system, hard link
6819 @table @asis
6820 @item @emph{Description}:
6821 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
6822 character (@code{CHAR(0)}) can be used to mark the end of the names in
6823 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
6824 names are ignored.  If the @var{STATUS} argument is supplied, it
6825 contains 0 on success or a nonzero error code upon return; see
6826 @code{link(2)}.
6828 This intrinsic is provided in both subroutine and function forms;
6829 however, only one form can be used in any given program unit.
6831 @item @emph{Standard}:
6832 GNU extension
6834 @item @emph{Class}:
6835 Subroutine, function
6837 @item @emph{Syntax}:
6838 @multitable @columnfractions .80
6839 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
6840 @item @code{STATUS = LINK(PATH1, PATH2)}
6841 @end multitable
6843 @item @emph{Arguments}:
6844 @multitable @columnfractions .15 .70
6845 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
6846 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
6847 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
6848 @end multitable
6850 @item @emph{See also}:
6851 @ref{SYMLNK}, @ref{UNLINK}
6852 @end table
6856 @node LLE
6857 @section @code{LLE} --- Lexical less than or equal
6858 @fnindex LLE
6859 @cindex lexical comparison of strings
6860 @cindex string, comparison
6862 @table @asis
6863 @item @emph{Description}:
6864 Determines whether one string is lexically less than or equal to another
6865 string, where the two strings are interpreted as containing ASCII
6866 character codes.  If the String A and String B are not the same length,
6867 the shorter is compared as if spaces were appended to it to form a value
6868 that has the same length as the longer.
6870 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6871 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6872 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6873 that the latter use the processor's character ordering (which is not
6874 ASCII on some targets), whereas the former always use the ASCII
6875 ordering.
6877 @item @emph{Standard}:
6878 Fortran 77 and later
6880 @item @emph{Class}:
6881 Elemental function
6883 @item @emph{Syntax}:
6884 @code{RESULT = LLE(STRING_A, STRING_B)}
6886 @item @emph{Arguments}:
6887 @multitable @columnfractions .15 .70
6888 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6889 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6890 @end multitable
6892 @item @emph{Return value}:
6893 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
6894 otherwise, based on the ASCII ordering.
6896 @item @emph{Specific names}:
6897 @multitable @columnfractions .20 .20 .20 .25
6898 @item Name                           @tab Argument          @tab Return type       @tab Standard
6899 @item @code{LLE(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
6900 @end multitable
6902 @item @emph{See also}:
6903 @ref{LGE}, @ref{LGT}, @ref{LLT}
6904 @end table
6908 @node LLT
6909 @section @code{LLT} --- Lexical less than
6910 @fnindex LLT
6911 @cindex lexical comparison of strings
6912 @cindex string, comparison
6914 @table @asis
6915 @item @emph{Description}:
6916 Determines whether one string is lexically less than another string,
6917 where the two strings are interpreted as containing ASCII character
6918 codes.  If the String A and String B are not the same length, the
6919 shorter is compared as if spaces were appended to it to form a value
6920 that has the same length as the longer.
6922 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6923 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6924 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6925 that the latter use the processor's character ordering (which is not
6926 ASCII on some targets), whereas the former always use the ASCII
6927 ordering.
6929 @item @emph{Standard}:
6930 Fortran 77 and later
6932 @item @emph{Class}:
6933 Elemental function
6935 @item @emph{Syntax}:
6936 @code{RESULT = LLT(STRING_A, STRING_B)}
6938 @item @emph{Arguments}:
6939 @multitable @columnfractions .15 .70
6940 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6941 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6942 @end multitable
6944 @item @emph{Return value}:
6945 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
6946 otherwise, based on the ASCII ordering.
6948 @item @emph{Specific names}:
6949 @multitable @columnfractions .20 .20 .20 .25
6950 @item Name                           @tab Argument          @tab Return type       @tab Standard
6951 @item @code{LLT(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
6952 @end multitable
6954 @item @emph{See also}:
6955 @ref{LGE}, @ref{LGT}, @ref{LLE}
6956 @end table
6960 @node LNBLNK
6961 @section @code{LNBLNK} --- Index of the last non-blank character in a string
6962 @fnindex LNBLNK
6963 @cindex string, find non-blank character
6965 @table @asis
6966 @item @emph{Description}:
6967 Returns the length of a character string, ignoring any trailing blanks.
6968 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
6969 included for backwards compatibility.
6971 @item @emph{Standard}:
6972 GNU extension
6974 @item @emph{Class}:
6975 Elemental function
6977 @item @emph{Syntax}:
6978 @code{RESULT = LNBLNK(STRING)}
6980 @item @emph{Arguments}:
6981 @multitable @columnfractions .15 .70
6982 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
6983 with @code{INTENT(IN)}
6984 @end multitable
6986 @item @emph{Return value}:
6987 The return value is of @code{INTEGER(kind=4)} type.
6989 @item @emph{See also}:
6990 @ref{INDEX intrinsic}, @ref{LEN_TRIM}
6991 @end table
6995 @node LOC
6996 @section @code{LOC} --- Returns the address of a variable
6997 @fnindex LOC
6998 @cindex location of a variable in memory
7000 @table @asis
7001 @item @emph{Description}:
7002 @code{LOC(X)} returns the address of @var{X} as an integer.
7004 @item @emph{Standard}:
7005 GNU extension
7007 @item @emph{Class}:
7008 Inquiry function
7010 @item @emph{Syntax}:
7011 @code{RESULT = LOC(X)}
7013 @item @emph{Arguments}:
7014 @multitable @columnfractions .15 .70
7015 @item @var{X} @tab Variable of any type.
7016 @end multitable
7018 @item @emph{Return value}:
7019 The return value is of type @code{INTEGER}, with a @code{KIND}
7020 corresponding to the size (in bytes) of a memory address on the target
7021 machine.
7023 @item @emph{Example}:
7024 @smallexample
7025 program test_loc
7026   integer :: i
7027   real :: r
7028   i = loc(r)
7029   print *, i
7030 end program test_loc
7031 @end smallexample
7032 @end table
7036 @node LOG
7037 @section @code{LOG} --- Logarithm function
7038 @fnindex LOG
7039 @fnindex ALOG
7040 @fnindex DLOG
7041 @fnindex CLOG
7042 @fnindex ZLOG
7043 @fnindex CDLOG
7044 @cindex exponential function, inverse
7045 @cindex logarithmic function
7047 @table @asis
7048 @item @emph{Description}:
7049 @code{LOG(X)} computes the logarithm of @var{X}.
7051 @item @emph{Standard}:
7052 Fortran 77 and later
7054 @item @emph{Class}:
7055 Elemental function
7057 @item @emph{Syntax}:
7058 @code{RESULT = LOG(X)}
7060 @item @emph{Arguments}:
7061 @multitable @columnfractions .15 .70
7062 @item @var{X} @tab The type shall be @code{REAL} or
7063 @code{COMPLEX}.
7064 @end multitable
7066 @item @emph{Return value}:
7067 The return value is of type @code{REAL} or @code{COMPLEX}.
7068 The kind type parameter is the same as @var{X}.
7069 If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range
7070 @math{-\pi \leq \omega \leq \pi}.
7072 @item @emph{Example}:
7073 @smallexample
7074 program test_log
7075   real(8) :: x = 1.0_8
7076   complex :: z = (1.0, 2.0)
7077   x = log(x)
7078   z = log(z)
7079 end program test_log
7080 @end smallexample
7082 @item @emph{Specific names}:
7083 @multitable @columnfractions .20 .20 .20 .25
7084 @item Name            @tab Argument          @tab Return type       @tab Standard
7085 @item @code{ALOG(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab f95, gnu
7086 @item @code{DLOG(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
7087 @item @code{CLOG(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
7088 @item @code{ZLOG(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
7089 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
7090 @end multitable
7091 @end table
7095 @node LOG10
7096 @section @code{LOG10} --- Base 10 logarithm function
7097 @fnindex LOG10
7098 @fnindex ALOG10
7099 @fnindex DLOG10
7100 @cindex exponential function, inverse
7101 @cindex logarithmic function
7103 @table @asis
7104 @item @emph{Description}:
7105 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
7107 @item @emph{Standard}:
7108 Fortran 77 and later
7110 @item @emph{Class}:
7111 Elemental function
7113 @item @emph{Syntax}:
7114 @code{RESULT = LOG10(X)}
7116 @item @emph{Arguments}:
7117 @multitable @columnfractions .15 .70
7118 @item @var{X} @tab The type shall be @code{REAL}.
7119 @end multitable
7121 @item @emph{Return value}:
7122 The return value is of type @code{REAL} or @code{COMPLEX}.
7123 The kind type parameter is the same as @var{X}.
7125 @item @emph{Example}:
7126 @smallexample
7127 program test_log10
7128   real(8) :: x = 10.0_8
7129   x = log10(x)
7130 end program test_log10
7131 @end smallexample
7133 @item @emph{Specific names}:
7134 @multitable @columnfractions .20 .20 .20 .25
7135 @item Name            @tab Argument          @tab Return type       @tab Standard
7136 @item @code{ALOG10(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
7137 @item @code{DLOG10(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
7138 @end multitable
7139 @end table
7143 @node LOG_GAMMA
7144 @section @code{LOG_GAMMA} --- Logarithm of the Gamma function
7145 @fnindex LOG_GAMMA
7146 @fnindex LGAMMA
7147 @fnindex ALGAMA
7148 @fnindex DLGAMA
7149 @cindex Gamma function, logarithm of
7151 @table @asis
7152 @item @emph{Description}:
7153 @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
7154 of the Gamma (@math{\Gamma}) function.
7156 @item @emph{Standard}:
7157 Fortran 2008 and later
7159 @item @emph{Class}:
7160 Elemental function
7162 @item @emph{Syntax}:
7163 @code{X = LOG_GAMMA(X)}
7165 @item @emph{Arguments}:
7166 @multitable @columnfractions .15 .70
7167 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
7168 nor a negative integer.
7169 @end multitable
7171 @item @emph{Return value}:
7172 The return value is of type @code{REAL} of the same kind as @var{X}.
7174 @item @emph{Example}:
7175 @smallexample
7176 program test_log_gamma
7177   real :: x = 1.0
7178   x = lgamma(x) ! returns 0.0
7179 end program test_log_gamma
7180 @end smallexample
7182 @item @emph{Specific names}:
7183 @multitable @columnfractions .20 .20 .20 .25
7184 @item Name             @tab Argument         @tab Return type       @tab Standard
7185 @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
7186 @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
7187 @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
7188 @end multitable
7190 @item @emph{See also}:
7191 Gamma function: @ref{GAMMA}
7193 @end table
7197 @node LOGICAL
7198 @section @code{LOGICAL} --- Convert to logical type
7199 @fnindex LOGICAL
7200 @cindex conversion, to logical
7202 @table @asis
7203 @item @emph{Description}:
7204 Converts one kind of @code{LOGICAL} variable to another.
7206 @item @emph{Standard}:
7207 Fortran 95 and later
7209 @item @emph{Class}:
7210 Elemental function
7212 @item @emph{Syntax}:
7213 @code{RESULT = LOGICAL(L [, KIND])}
7215 @item @emph{Arguments}:
7216 @multitable @columnfractions .15 .70
7217 @item @var{L}    @tab The type shall be @code{LOGICAL}.
7218 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7219 expression indicating the kind parameter of the result.
7220 @end multitable
7222 @item @emph{Return value}:
7223 The return value is a @code{LOGICAL} value equal to @var{L}, with a
7224 kind corresponding to @var{KIND}, or of the default logical kind if
7225 @var{KIND} is not given.
7227 @item @emph{See also}:
7228 @ref{INT}, @ref{REAL}, @ref{CMPLX}
7229 @end table
7233 @node LONG
7234 @section @code{LONG} --- Convert to integer type
7235 @fnindex LONG
7236 @cindex conversion, to integer
7238 @table @asis
7239 @item @emph{Description}:
7240 Convert to a @code{KIND=4} integer type, which is the same size as a C
7241 @code{long} integer.  This is equivalent to the standard @code{INT}
7242 intrinsic with an optional argument of @code{KIND=4}, and is only
7243 included for backwards compatibility.
7245 @item @emph{Standard}:
7246 GNU extension
7248 @item @emph{Class}:
7249 Elemental function
7251 @item @emph{Syntax}:
7252 @code{RESULT = LONG(A)}
7254 @item @emph{Arguments}:
7255 @multitable @columnfractions .15 .70
7256 @item @var{A}    @tab Shall be of type @code{INTEGER},
7257 @code{REAL}, or @code{COMPLEX}.
7258 @end multitable
7260 @item @emph{Return value}:
7261 The return value is a @code{INTEGER(4)} variable.
7263 @item @emph{See also}:
7264 @ref{INT}, @ref{INT2}, @ref{INT8}
7265 @end table
7269 @node LSHIFT
7270 @section @code{LSHIFT} --- Left shift bits
7271 @fnindex LSHIFT
7272 @cindex bits, shift left
7274 @table @asis
7275 @item @emph{Description}:
7276 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
7277 bits shifted left by @var{SHIFT} places.  If the absolute value of
7278 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined. 
7279 Bits shifted out from the left end are lost; zeros are shifted in from
7280 the opposite end.
7282 This function has been superseded by the @code{ISHFT} intrinsic, which
7283 is standard in Fortran 95 and later.
7285 @item @emph{Standard}:
7286 GNU extension
7288 @item @emph{Class}:
7289 Elemental function
7291 @item @emph{Syntax}:
7292 @code{RESULT = LSHIFT(I, SHIFT)}
7294 @item @emph{Arguments}:
7295 @multitable @columnfractions .15 .70
7296 @item @var{I} @tab The type shall be @code{INTEGER}.
7297 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
7298 @end multitable
7300 @item @emph{Return value}:
7301 The return value is of type @code{INTEGER} and of the same kind as
7302 @var{I}.
7304 @item @emph{See also}:
7305 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
7307 @end table
7311 @node LSTAT
7312 @section @code{LSTAT} --- Get file status
7313 @fnindex LSTAT
7314 @cindex file system, file status
7316 @table @asis
7317 @item @emph{Description}:
7318 @code{LSTAT} is identical to @ref{STAT}, except that if path is a
7319 symbolic link, then the link itself is statted, not the file that it
7320 refers to.
7322 The elements in @code{VALUES} are the same as described by @ref{STAT}.
7324 This intrinsic is provided in both subroutine and function forms;
7325 however, only one form can be used in any given program unit.
7327 @item @emph{Standard}:
7328 GNU extension
7330 @item @emph{Class}:
7331 Subroutine, function
7333 @item @emph{Syntax}:
7334 @code{CALL LSTAT(NAME, VALUES [, STATUS])}
7336 @item @emph{Arguments}:
7337 @multitable @columnfractions .15 .70
7338 @item @var{NAME}   @tab The type shall be @code{CHARACTER} of the default
7339 kind, a valid path within the file system.
7340 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
7341 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
7342 Returns 0 on success and a system specific error code otherwise.
7343 @end multitable
7345 @item @emph{Example}:
7346 See @ref{STAT} for an example.
7348 @item @emph{See also}:
7349 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
7350 @end table
7354 @node LTIME
7355 @section @code{LTIME} --- Convert time to local time info
7356 @fnindex LTIME
7357 @cindex time, conversion to local time info
7359 @table @asis
7360 @item @emph{Description}:
7361 Given a system time value @var{TIME} (as provided by the @code{TIME8()}
7362 intrinsic), fills @var{VALUES} with values extracted from it appropriate
7363 to the local time zone using @code{localtime(3)}.
7365 @item @emph{Standard}:
7366 GNU extension
7368 @item @emph{Class}:
7369 Subroutine
7371 @item @emph{Syntax}:
7372 @code{CALL LTIME(TIME, VALUES)}
7374 @item @emph{Arguments}:
7375 @multitable @columnfractions .15 .70
7376 @item @var{TIME}  @tab An @code{INTEGER} scalar expression
7377 corresponding to a system time, with @code{INTENT(IN)}.
7378 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
7379 with @code{INTENT(OUT)}.
7380 @end multitable
7382 @item @emph{Return value}:
7383 The elements of @var{VALUES} are assigned as follows:
7384 @enumerate
7385 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
7386 seconds
7387 @item Minutes after the hour, range 0--59
7388 @item Hours past midnight, range 0--23
7389 @item Day of month, range 0--31
7390 @item Number of months since January, range 0--12
7391 @item Years since 1900
7392 @item Number of days since Sunday, range 0--6
7393 @item Days since January 1
7394 @item Daylight savings indicator: positive if daylight savings is in
7395 effect, zero if not, and negative if the information is not available.
7396 @end enumerate
7398 @item @emph{See also}:
7399 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
7401 @end table
7405 @node MALLOC
7406 @section @code{MALLOC} --- Allocate dynamic memory
7407 @fnindex MALLOC
7408 @cindex pointer, cray
7410 @table @asis
7411 @item @emph{Description}:
7412 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
7413 returns the address of the allocated memory. The @code{MALLOC} intrinsic
7414 is an extension intended to be used with Cray pointers, and is provided
7415 in GNU Fortran to allow the user to compile legacy code. For new code
7416 using Fortran 95 pointers, the memory allocation intrinsic is
7417 @code{ALLOCATE}.
7419 @item @emph{Standard}:
7420 GNU extension
7422 @item @emph{Class}:
7423 Function
7425 @item @emph{Syntax}:
7426 @code{PTR = MALLOC(SIZE)}
7428 @item @emph{Arguments}:
7429 @multitable @columnfractions .15 .70
7430 @item @var{SIZE} @tab The type shall be @code{INTEGER}.
7431 @end multitable
7433 @item @emph{Return value}:
7434 The return value is of type @code{INTEGER(K)}, with @var{K} such that
7435 variables of type @code{INTEGER(K)} have the same size as
7436 C pointers (@code{sizeof(void *)}).
7438 @item @emph{Example}:
7439 The following example demonstrates the use of @code{MALLOC} and
7440 @code{FREE} with Cray pointers.
7442 @smallexample
7443 program test_malloc
7444   implicit none
7445   integer i
7446   real*8 x(*), z
7447   pointer(ptr_x,x)
7449   ptr_x = malloc(20*8)
7450   do i = 1, 20
7451     x(i) = sqrt(1.0d0 / i)
7452   end do
7453   z = 0
7454   do i = 1, 20
7455     z = z + x(i)
7456     print *, z
7457   end do
7458   call free(ptr_x)
7459 end program test_malloc
7460 @end smallexample
7462 @item @emph{See also}:
7463 @ref{FREE}
7464 @end table
7468 @node MATMUL
7469 @section @code{MATMUL} --- matrix multiplication
7470 @fnindex MATMUL
7471 @cindex matrix multiplication
7472 @cindex product, matrix
7474 @table @asis
7475 @item @emph{Description}:
7476 Performs a matrix multiplication on numeric or logical arguments.
7478 @item @emph{Standard}:
7479 Fortran 95 and later
7481 @item @emph{Class}:
7482 Transformational function
7484 @item @emph{Syntax}:
7485 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
7487 @item @emph{Arguments}:
7488 @multitable @columnfractions .15 .70
7489 @item @var{MATRIX_A} @tab An array of @code{INTEGER},
7490 @code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of
7491 one or two.
7492 @item @var{MATRIX_B} @tab An array of @code{INTEGER},
7493 @code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric
7494 type; otherwise, an array of @code{LOGICAL} type. The rank shall be one
7495 or two, and the first (or only) dimension of @var{MATRIX_B} shall be
7496 equal to the last (or only) dimension of @var{MATRIX_A}.
7497 @end multitable
7499 @item @emph{Return value}:
7500 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}.  The type and
7501 kind of the result follow the usual type and kind promotion rules, as
7502 for the @code{*} or @code{.AND.} operators.
7504 @item @emph{See also}:
7505 @end table
7509 @node MAX
7510 @section @code{MAX} --- Maximum value of an argument list
7511 @fnindex MAX
7512 @fnindex MAX0
7513 @fnindex AMAX0
7514 @fnindex MAX1
7515 @fnindex AMAX1
7516 @fnindex DMAX1
7517 @cindex maximum value
7519 @table @asis
7520 @item @emph{Description}:
7521 Returns the argument with the largest (most positive) value.
7523 @item @emph{Standard}:
7524 Fortran 77 and later
7526 @item @emph{Class}:
7527 Elemental function
7529 @item @emph{Syntax}:
7530 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
7532 @item @emph{Arguments}:
7533 @multitable @columnfractions .15 .70
7534 @item @var{A1}          @tab The type shall be @code{INTEGER} or
7535 @code{REAL}.
7536 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
7537 as @var{A1}.  (As a GNU extension, arguments of different kinds are
7538 permitted.)
7539 @end multitable
7541 @item @emph{Return value}:
7542 The return value corresponds to the maximum value among the arguments,
7543 and has the same type and kind as the first argument.
7545 @item @emph{Specific names}:
7546 @multitable @columnfractions .20 .20 .20 .25
7547 @item Name             @tab Argument             @tab Return type         @tab Standard
7548 @item @code{MAX0(A1)}  @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)}   @tab Fortran 77 and later
7549 @item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
7550 @item @code{MAX1(A1)}  @tab @code{REAL A1}       @tab @code{INT(MAX(X))}  @tab Fortran 77 and later
7551 @item @code{AMAX1(A1)} @tab @code{REAL(4) A1}    @tab @code{REAL(4)}      @tab Fortran 77 and later
7552 @item @code{DMAX1(A1)} @tab @code{REAL(8) A1}    @tab @code{REAL(8)}      @tab Fortran 77 and later
7553 @end multitable
7555 @item @emph{See also}:
7556 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
7558 @end table
7562 @node MAXEXPONENT
7563 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
7564 @fnindex MAXEXPONENT
7565 @cindex model representation, maximum exponent
7567 @table @asis
7568 @item @emph{Description}:
7569 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
7570 type of @code{X}.
7572 @item @emph{Standard}:
7573 Fortran 95 and later
7575 @item @emph{Class}:
7576 Inquiry function
7578 @item @emph{Syntax}:
7579 @code{RESULT = MAXEXPONENT(X)}
7581 @item @emph{Arguments}:
7582 @multitable @columnfractions .15 .70
7583 @item @var{X} @tab Shall be of type @code{REAL}.
7584 @end multitable
7586 @item @emph{Return value}:
7587 The return value is of type @code{INTEGER} and of the default integer
7588 kind.
7590 @item @emph{Example}:
7591 @smallexample
7592 program exponents
7593   real(kind=4) :: x
7594   real(kind=8) :: y
7596   print *, minexponent(x), maxexponent(x)
7597   print *, minexponent(y), maxexponent(y)
7598 end program exponents
7599 @end smallexample
7600 @end table
7604 @node MAXLOC
7605 @section @code{MAXLOC} --- Location of the maximum value within an array
7606 @fnindex MAXLOC
7607 @cindex array, location of maximum element
7609 @table @asis
7610 @item @emph{Description}:
7611 Determines the location of the element in the array with the maximum
7612 value, or, if the @var{DIM} argument is supplied, determines the
7613 locations of the maximum element along each row of the array in the
7614 @var{DIM} direction.  If @var{MASK} is present, only the elements for
7615 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
7616 element in the array has the maximum value, the location returned is
7617 that of the first such element in array element order.  If the array has
7618 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
7619 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
7620 and all of the elements of @var{MASK} along a given row are zero, the
7621 result value for that row is zero.
7623 @item @emph{Standard}:
7624 Fortran 95 and later
7626 @item @emph{Class}:
7627 Transformational function
7629 @item @emph{Syntax}:
7630 @multitable @columnfractions .80
7631 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
7632 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
7633 @end multitable
7635 @item @emph{Arguments}:
7636 @multitable @columnfractions .15 .70
7637 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
7638 @code{REAL}.
7639 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
7640 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
7641 inclusive.  It may not be an optional dummy argument.
7642 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
7643 and conformable with @var{ARRAY}.
7644 @end multitable
7646 @item @emph{Return value}:
7647 If @var{DIM} is absent, the result is a rank-one array with a length
7648 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
7649 is an array with a rank one less than the rank of @var{ARRAY}, and a
7650 size corresponding to the size of @var{ARRAY} with the @var{DIM}
7651 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
7652 of one, the result is a scalar.  In all cases, the result is of default
7653 @code{INTEGER} type.
7655 @item @emph{See also}:
7656 @ref{MAX}, @ref{MAXVAL}
7658 @end table
7662 @node MAXVAL
7663 @section @code{MAXVAL} --- Maximum value of an array
7664 @fnindex MAXVAL
7665 @cindex array, maximum value
7666 @cindex maximum value
7668 @table @asis
7669 @item @emph{Description}:
7670 Determines the maximum value of the elements in an array value, or, if
7671 the @var{DIM} argument is supplied, determines the maximum value along
7672 each row of the array in the @var{DIM} direction.  If @var{MASK} is
7673 present, only the elements for which @var{MASK} is @code{.TRUE.} are
7674 considered.  If the array has zero size, or all of the elements of
7675 @var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)}
7676 if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character
7677 type.
7679 @item @emph{Standard}:
7680 Fortran 95 and later
7682 @item @emph{Class}:
7683 Transformational function
7685 @item @emph{Syntax}:
7686 @multitable @columnfractions .80
7687 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
7688 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
7689 @end multitable
7691 @item @emph{Arguments}:
7692 @multitable @columnfractions .15 .70
7693 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
7694 @code{REAL}.
7695 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
7696 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
7697 inclusive.  It may not be an optional dummy argument.
7698 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
7699 and conformable with @var{ARRAY}.
7700 @end multitable
7702 @item @emph{Return value}:
7703 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
7704 is a scalar.  If @var{DIM} is present, the result is an array with a
7705 rank one less than the rank of @var{ARRAY}, and a size corresponding to
7706 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
7707 cases, the result is of the same type and kind as @var{ARRAY}.
7709 @item @emph{See also}:
7710 @ref{MAX}, @ref{MAXLOC}
7711 @end table
7715 @node MCLOCK
7716 @section @code{MCLOCK} --- Time function
7717 @fnindex MCLOCK
7718 @cindex time, clock ticks
7719 @cindex clock ticks
7721 @table @asis
7722 @item @emph{Description}:
7723 Returns the number of clock ticks since the start of the process, based
7724 on the UNIX function @code{clock(3)}.
7726 This intrinsic is not fully portable, such as to systems with 32-bit
7727 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
7728 the values returned by this intrinsic might be, or become, negative, or
7729 numerically less than previous values, during a single run of the
7730 compiled program.
7732 @item @emph{Standard}:
7733 GNU extension
7735 @item @emph{Class}:
7736 Function
7738 @item @emph{Syntax}:
7739 @code{RESULT = MCLOCK()}
7741 @item @emph{Return value}:
7742 The return value is a scalar of type @code{INTEGER(4)}, equal to the
7743 number of clock ticks since the start of the process, or @code{-1} if
7744 the system does not support @code{clock(3)}.
7746 @item @emph{See also}:
7747 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
7749 @end table
7753 @node MCLOCK8
7754 @section @code{MCLOCK8} --- Time function (64-bit)
7755 @fnindex MCLOCK8
7756 @cindex time, clock ticks
7757 @cindex clock ticks
7759 @table @asis
7760 @item @emph{Description}:
7761 Returns the number of clock ticks since the start of the process, based
7762 on the UNIX function @code{clock(3)}.
7764 @emph{Warning:} this intrinsic does not increase the range of the timing
7765 values over that returned by @code{clock(3)}. On a system with a 32-bit
7766 @code{clock(3)}, @code{MCLOCK8()} will return a 32-bit value, even though
7767 it is converted to a 64-bit @code{INTEGER(8)} value. That means
7768 overflows of the 32-bit value can still occur. Therefore, the values
7769 returned by this intrinsic might be or become negative or numerically
7770 less than previous values during a single run of the compiled program.
7772 @item @emph{Standard}:
7773 GNU extension
7775 @item @emph{Class}:
7776 Function
7778 @item @emph{Syntax}:
7779 @code{RESULT = MCLOCK8()}
7781 @item @emph{Return value}:
7782 The return value is a scalar of type @code{INTEGER(8)}, equal to the
7783 number of clock ticks since the start of the process, or @code{-1} if
7784 the system does not support @code{clock(3)}.
7786 @item @emph{See also}:
7787 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
7789 @end table
7793 @node MERGE
7794 @section @code{MERGE} --- Merge variables
7795 @fnindex MERGE
7796 @cindex array, merge arrays
7797 @cindex array, combine arrays
7799 @table @asis
7800 @item @emph{Description}:
7801 Select values from two arrays according to a logical mask.  The result
7802 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
7803 @var{FSOURCE} if it is @code{.FALSE.}.
7805 @item @emph{Standard}:
7806 Fortran 95 and later
7808 @item @emph{Class}:
7809 Elemental function
7811 @item @emph{Syntax}:
7812 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
7814 @item @emph{Arguments}:
7815 @multitable @columnfractions .15 .70
7816 @item @var{TSOURCE} @tab May be of any type.
7817 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
7818 as @var{TSOURCE}.
7819 @item @var{MASK}    @tab Shall be of type @code{LOGICAL}.
7820 @end multitable
7822 @item @emph{Return value}:
7823 The result is of the same type and type parameters as @var{TSOURCE}.
7825 @end table
7829 @node MIN
7830 @section @code{MIN} --- Minimum value of an argument list
7831 @fnindex MIN
7832 @fnindex MIN0
7833 @fnindex AMIN0
7834 @fnindex MIN1
7835 @fnindex AMIN1
7836 @fnindex DMIN1
7837 @cindex minimum value
7839 @table @asis
7840 @item @emph{Description}:
7841 Returns the argument with the smallest (most negative) value.
7843 @item @emph{Standard}:
7844 Fortran 77 and later
7846 @item @emph{Class}:
7847 Elemental function
7849 @item @emph{Syntax}:
7850 @code{RESULT = MIN(A1, A2 [, A3, ...])}
7852 @item @emph{Arguments}:
7853 @multitable @columnfractions .15 .70
7854 @item @var{A1}          @tab The type shall be @code{INTEGER} or
7855 @code{REAL}.
7856 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
7857 as @var{A1}.  (As a GNU extension, arguments of different kinds are
7858 permitted.)
7859 @end multitable
7861 @item @emph{Return value}:
7862 The return value corresponds to the maximum value among the arguments,
7863 and has the same type and kind as the first argument.
7865 @item @emph{Specific names}:
7866 @multitable @columnfractions .20 .20 .20 .25
7867 @item Name              @tab Argument             @tab Return type        @tab Standard
7868 @item @code{MIN0(A1)}   @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)}  @tab Fortran 77 and later
7869 @item @code{AMIN0(A1)}  @tab @code{INTEGER(4) A1} @tab @code{REAL(4)}     @tab Fortran 77 and later
7870 @item @code{MIN1(A1)}   @tab @code{REAL A1}       @tab @code{INTEGER(4)}  @tab Fortran 77 and later
7871 @item @code{AMIN1(A1)}  @tab @code{REAL(4) A1}    @tab @code{REAL(4)}     @tab Fortran 77 and later
7872 @item @code{DMIN1(A1)}  @tab @code{REAL(8) A1}    @tab @code{REAL(8)}     @tab Fortran 77 and later
7873 @end multitable
7875 @item @emph{See also}:
7876 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
7877 @end table
7881 @node MINEXPONENT
7882 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
7883 @fnindex MINEXPONENT
7884 @cindex model representation, minimum exponent
7886 @table @asis
7887 @item @emph{Description}:
7888 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
7889 type of @code{X}.
7891 @item @emph{Standard}:
7892 Fortran 95 and later
7894 @item @emph{Class}:
7895 Inquiry function
7897 @item @emph{Syntax}:
7898 @code{RESULT = MINEXPONENT(X)}
7900 @item @emph{Arguments}:
7901 @multitable @columnfractions .15 .70
7902 @item @var{X} @tab Shall be of type @code{REAL}.
7903 @end multitable
7905 @item @emph{Return value}:
7906 The return value is of type @code{INTEGER} and of the default integer
7907 kind.
7909 @item @emph{Example}:
7910 See @code{MAXEXPONENT} for an example.
7911 @end table
7915 @node MINLOC
7916 @section @code{MINLOC} --- Location of the minimum value within an array
7917 @fnindex MINLOC
7918 @cindex array, location of minimum element
7920 @table @asis
7921 @item @emph{Description}:
7922 Determines the location of the element in the array with the minimum
7923 value, or, if the @var{DIM} argument is supplied, determines the
7924 locations of the minimum element along each row of the array in the
7925 @var{DIM} direction.  If @var{MASK} is present, only the elements for
7926 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
7927 element in the array has the minimum value, the location returned is
7928 that of the first such element in array element order.  If the array has
7929 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
7930 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
7931 and all of the elements of @var{MASK} along a given row are zero, the
7932 result value for that row is zero.
7934 @item @emph{Standard}:
7935 Fortran 95 and later
7937 @item @emph{Class}:
7938 Transformational function
7940 @item @emph{Syntax}:
7941 @multitable @columnfractions .80
7942 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
7943 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
7944 @end multitable
7946 @item @emph{Arguments}:
7947 @multitable @columnfractions .15 .70
7948 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
7949 @code{REAL}.
7950 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
7951 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
7952 inclusive.  It may not be an optional dummy argument.
7953 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
7954 and conformable with @var{ARRAY}.
7955 @end multitable
7957 @item @emph{Return value}:
7958 If @var{DIM} is absent, the result is a rank-one array with a length
7959 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
7960 is an array with a rank one less than the rank of @var{ARRAY}, and a
7961 size corresponding to the size of @var{ARRAY} with the @var{DIM}
7962 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
7963 of one, the result is a scalar.  In all cases, the result is of default
7964 @code{INTEGER} type.
7966 @item @emph{See also}:
7967 @ref{MIN}, @ref{MINVAL}
7969 @end table
7973 @node MINVAL
7974 @section @code{MINVAL} --- Minimum value of an array
7975 @fnindex MINVAL
7976 @cindex array, minimum value
7977 @cindex minimum value
7979 @table @asis
7980 @item @emph{Description}:
7981 Determines the minimum value of the elements in an array value, or, if
7982 the @var{DIM} argument is supplied, determines the minimum value along
7983 each row of the array in the @var{DIM} direction.  If @var{MASK} is
7984 present, only the elements for which @var{MASK} is @code{.TRUE.} are
7985 considered.  If the array has zero size, or all of the elements of
7986 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
7987 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
7988 @var{ARRAY} is of character type.
7990 @item @emph{Standard}:
7991 Fortran 95 and later
7993 @item @emph{Class}:
7994 Transformational function
7996 @item @emph{Syntax}:
7997 @multitable @columnfractions .80
7998 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
7999 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
8000 @end multitable
8002 @item @emph{Arguments}:
8003 @multitable @columnfractions .15 .70
8004 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8005 @code{REAL}.
8006 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8007 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8008 inclusive.  It may not be an optional dummy argument.
8009 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8010 and conformable with @var{ARRAY}.
8011 @end multitable
8013 @item @emph{Return value}:
8014 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
8015 is a scalar.  If @var{DIM} is present, the result is an array with a
8016 rank one less than the rank of @var{ARRAY}, and a size corresponding to
8017 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
8018 cases, the result is of the same type and kind as @var{ARRAY}.
8020 @item @emph{See also}:
8021 @ref{MIN}, @ref{MINLOC}
8023 @end table
8027 @node MOD
8028 @section @code{MOD} --- Remainder function
8029 @fnindex MOD
8030 @fnindex AMOD
8031 @fnindex DMOD
8032 @cindex remainder
8033 @cindex division, remainder
8035 @table @asis
8036 @item @emph{Description}:
8037 @code{MOD(A,P)} computes the remainder of the division of A by P@. It is
8038 calculated as @code{A - (INT(A/P) * P)}.
8040 @item @emph{Standard}:
8041 Fortran 77 and later
8043 @item @emph{Class}:
8044 Elemental function
8046 @item @emph{Syntax}:
8047 @code{RESULT = MOD(A, P)}
8049 @item @emph{Arguments}:
8050 @multitable @columnfractions .15 .70
8051 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
8052 @item @var{P} @tab Shall be a scalar of the same type as @var{A} and not
8053 equal to zero
8054 @end multitable
8056 @item @emph{Return value}:
8057 The kind of the return value is the result of cross-promoting
8058 the kinds of the arguments.
8060 @item @emph{Example}:
8061 @smallexample
8062 program test_mod
8063   print *, mod(17,3)
8064   print *, mod(17.5,5.5)
8065   print *, mod(17.5d0,5.5)
8066   print *, mod(17.5,5.5d0)
8068   print *, mod(-17,3)
8069   print *, mod(-17.5,5.5)
8070   print *, mod(-17.5d0,5.5)
8071   print *, mod(-17.5,5.5d0)
8073   print *, mod(17,-3)
8074   print *, mod(17.5,-5.5)
8075   print *, mod(17.5d0,-5.5)
8076   print *, mod(17.5,-5.5d0)
8077 end program test_mod
8078 @end smallexample
8080 @item @emph{Specific names}:
8081 @multitable @columnfractions .20 .20 .20 .25
8082 @item Name             @tab Arguments          @tab Return type    @tab Standard
8083 @item @code{MOD(A,P)}  @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 95 and later
8084 @item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 95 and later
8085 @item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 95 and later
8086 @end multitable
8087 @end table
8091 @node MODULO
8092 @section @code{MODULO} --- Modulo function
8093 @fnindex MODULO
8094 @cindex modulo
8095 @cindex division, modulo
8097 @table @asis
8098 @item @emph{Description}:
8099 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
8101 @item @emph{Standard}:
8102 Fortran 95 and later
8104 @item @emph{Class}:
8105 Elemental function
8107 @item @emph{Syntax}:
8108 @code{RESULT = MODULO(A, P)}
8110 @item @emph{Arguments}:
8111 @multitable @columnfractions .15 .70
8112 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
8113 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
8114 @end multitable
8116 @item @emph{Return value}:
8117 The type and kind of the result are those of the arguments.
8118 @table @asis
8119 @item If @var{A} and @var{P} are of type @code{INTEGER}:
8120 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
8121 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
8122 (exclusive).
8123 @item If @var{A} and @var{P} are of type @code{REAL}:
8124 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
8125 @end table
8126 In all cases, if @var{P} is zero the result is processor-dependent.
8128 @item @emph{Example}:
8129 @smallexample
8130 program test_modulo
8131   print *, modulo(17,3)
8132   print *, modulo(17.5,5.5)
8134   print *, modulo(-17,3)
8135   print *, modulo(-17.5,5.5)
8137   print *, modulo(17,-3)
8138   print *, modulo(17.5,-5.5)
8139 end program
8140 @end smallexample
8142 @end table
8146 @node MOVE_ALLOC
8147 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
8148 @fnindex MOVE_ALLOC
8149 @cindex moving allocation
8150 @cindex allocation, moving
8152 @table @asis
8153 @item @emph{Description}:
8154 @code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
8155 @var{TO}.  @var{FROM} will become deallocated in the process.
8157 @item @emph{Standard}:
8158 Fortran 2003 and later
8160 @item @emph{Class}:
8161 Subroutine
8163 @item @emph{Syntax}:
8164 @code{CALL MOVE_ALLOC(FROM, TO)}
8166 @item @emph{Arguments}:
8167 @multitable @columnfractions .15 .70
8168 @item @var{FROM}  @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
8169 of any type and kind.
8170 @item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
8171 of the same type, kind and rank as @var{FROM}.
8172 @end multitable
8174 @item @emph{Return value}:
8175 None
8177 @item @emph{Example}:
8178 @smallexample
8179 program test_move_alloc
8180     integer, allocatable :: a(:), b(:)
8182     allocate(a(3))
8183     a = [ 1, 2, 3 ]
8184     call move_alloc(a, b)
8185     print *, allocated(a), allocated(b)
8186     print *, b
8187 end program test_move_alloc
8188 @end smallexample
8189 @end table
8193 @node MVBITS
8194 @section @code{MVBITS} --- Move bits from one integer to another
8195 @fnindex MVBITS
8196 @cindex bits, move
8198 @table @asis
8199 @item @emph{Description}:
8200 Moves @var{LEN} bits from positions @var{FROMPOS} through
8201 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
8202 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
8203 affected by the movement of bits is unchanged. The values of
8204 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
8205 @code{BIT_SIZE(FROM)}.
8207 @item @emph{Standard}:
8208 Fortran 95 and later
8210 @item @emph{Class}:
8211 Elemental subroutine
8213 @item @emph{Syntax}:
8214 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
8216 @item @emph{Arguments}:
8217 @multitable @columnfractions .15 .70
8218 @item @var{FROM}    @tab The type shall be @code{INTEGER}.
8219 @item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
8220 @item @var{LEN}     @tab The type shall be @code{INTEGER}.
8221 @item @var{TO}      @tab The type shall be @code{INTEGER}, of the
8222 same kind as @var{FROM}.
8223 @item @var{TOPOS}   @tab The type shall be @code{INTEGER}.
8224 @end multitable
8226 @item @emph{See also}:
8227 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
8228 @end table
8232 @node NEAREST
8233 @section @code{NEAREST} --- Nearest representable number
8234 @fnindex NEAREST
8235 @cindex real number, nearest different
8236 @cindex floating point, nearest different
8238 @table @asis
8239 @item @emph{Description}:
8240 @code{NEAREST(X, S)} returns the processor-representable number nearest
8241 to @code{X} in the direction indicated by the sign of @code{S}.
8243 @item @emph{Standard}:
8244 Fortran 95 and later
8246 @item @emph{Class}:
8247 Elemental function
8249 @item @emph{Syntax}:
8250 @code{RESULT = NEAREST(X, S)}
8252 @item @emph{Arguments}:
8253 @multitable @columnfractions .15 .70
8254 @item @var{X} @tab Shall be of type @code{REAL}.
8255 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
8256 not equal to zero.
8257 @end multitable
8259 @item @emph{Return value}:
8260 The return value is of the same type as @code{X}. If @code{S} is
8261 positive, @code{NEAREST} returns the processor-representable number
8262 greater than @code{X} and nearest to it. If @code{S} is negative,
8263 @code{NEAREST} returns the processor-representable number smaller than
8264 @code{X} and nearest to it.
8266 @item @emph{Example}:
8267 @smallexample
8268 program test_nearest
8269   real :: x, y
8270   x = nearest(42.0, 1.0)
8271   y = nearest(42.0, -1.0)
8272   write (*,"(3(G20.15))") x, y, x - y
8273 end program test_nearest
8274 @end smallexample
8275 @end table
8279 @node NEW_LINE
8280 @section @code{NEW_LINE} --- New line character
8281 @fnindex NEW_LINE
8282 @cindex newline
8283 @cindex output, newline
8285 @table @asis
8286 @item @emph{Description}:
8287 @code{NEW_LINE(C)} returns the new-line character.
8289 @item @emph{Standard}:
8290 Fortran 2003 and later
8292 @item @emph{Class}:
8293 Inquiry function
8295 @item @emph{Syntax}:
8296 @code{RESULT = NEW_LINE(C)}
8298 @item @emph{Arguments}:
8299 @multitable @columnfractions .15 .70
8300 @item @var{C}    @tab The argument shall be a scalar or array of the
8301 type @code{CHARACTER}.
8302 @end multitable
8304 @item @emph{Return value}:
8305 Returns a @var{CHARACTER} scalar of length one with the new-line character of
8306 the same kind as parameter @var{C}.
8308 @item @emph{Example}:
8309 @smallexample
8310 program newline
8311   implicit none
8312   write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
8313 end program newline
8314 @end smallexample
8315 @end table
8319 @node NINT
8320 @section @code{NINT} --- Nearest whole number
8321 @fnindex NINT
8322 @fnindex IDNINT
8323 @cindex rounding, nearest whole number
8325 @table @asis
8326 @item @emph{Description}:
8327 @code{NINT(A)} rounds its argument to the nearest whole number.
8329 @item @emph{Standard}:
8330 Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
8332 @item @emph{Class}:
8333 Elemental function
8335 @item @emph{Syntax}:
8336 @code{RESULT = NINT(A [, KIND])}
8338 @item @emph{Arguments}:
8339 @multitable @columnfractions .15 .70
8340 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
8341 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8342 expression indicating the kind parameter of the result.
8343 @end multitable
8345 @item @emph{Return value}:
8346 Returns @var{A} with the fractional portion of its magnitude eliminated by
8347 rounding to the nearest whole number and with its sign preserved,
8348 converted to an @code{INTEGER} of the default kind.
8350 @item @emph{Example}:
8351 @smallexample
8352 program test_nint
8353   real(4) x4
8354   real(8) x8
8355   x4 = 1.234E0_4
8356   x8 = 4.321_8
8357   print *, nint(x4), idnint(x8)
8358 end program test_nint
8359 @end smallexample
8361 @item @emph{Specific names}:
8362 @multitable @columnfractions .20 .20 .20 .25
8363 @item Name             @tab Argument           @tab Return Type     @tab Standard
8364 @item @code{NINT(A)}   @tab @code{REAL(4) A}   @tab  @code{INTEGER} @tab Fortran 95 and later
8365 @item @code{IDNINT(A)} @tab @code{REAL(8) A}   @tab  @code{INTEGER} @tab Fortran 95 and later
8366 @end multitable
8368 @item @emph{See also}:
8369 @ref{CEILING}, @ref{FLOOR}
8371 @end table
8375 @node NOT
8376 @section @code{NOT} --- Logical negation
8377 @fnindex NOT
8378 @cindex bits, negate
8379 @cindex bitwise logical not
8380 @cindex logical not, bitwise
8382 @table @asis
8383 @item @emph{Description}:
8384 @code{NOT} returns the bitwise boolean inverse of @var{I}.
8386 @item @emph{Standard}:
8387 Fortran 95 and later
8389 @item @emph{Class}:
8390 Elemental function
8392 @item @emph{Syntax}:
8393 @code{RESULT = NOT(I)}
8395 @item @emph{Arguments}:
8396 @multitable @columnfractions .15 .70
8397 @item @var{I} @tab The type shall be @code{INTEGER}.
8398 @end multitable
8400 @item @emph{Return value}:
8401 The return type is @code{INTEGER}, of the same kind as the
8402 argument.
8404 @item @emph{See also}:
8405 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
8407 @end table
8411 @node NULL
8412 @section @code{NULL} --- Function that returns an disassociated pointer
8413 @fnindex NULL
8414 @cindex pointer, status
8415 @cindex pointer, disassociated
8417 @table @asis
8418 @item @emph{Description}:
8419 Returns a disassociated pointer.
8421 If @var{MOLD} is present, a dissassociated pointer of the same type is
8422 returned, otherwise the type is determined by context.
8424 In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
8425 includes cases where it is required.
8427 @item @emph{Standard}:
8428 Fortran 95 and later
8430 @item @emph{Class}:
8431 Transformational function
8433 @item @emph{Syntax}:
8434 @code{PTR => NULL([MOLD])}
8436 @item @emph{Arguments}:
8437 @multitable @columnfractions .15 .70
8438 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
8439 status and of any type.
8440 @end multitable
8442 @item @emph{Return value}:
8443 A disassociated pointer.
8445 @item @emph{Example}:
8446 @smallexample
8447 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
8448 @end smallexample
8450 @item @emph{See also}:
8451 @ref{ASSOCIATED}
8452 @end table
8456 @node NUM_IMAGES
8457 @section @code{NUM_IMAGES} --- Function that returns the number of images
8458 @fnindex NUM_IMAGES
8459 @cindex coarray, NUM_IMAGES
8460 @cindex images, number of
8462 @table @asis
8463 @item @emph{Description}:
8464 Returns the number of images.
8466 @item @emph{Standard}:
8467 Fortran 2008 and later
8469 @item @emph{Class}:
8470 Transformational function
8472 @item @emph{Syntax}:
8473 @code{RESULT = NUM_IMAGES()}
8475 @item @emph{Arguments}: None.
8477 @item @emph{Return value}:
8478 Scalar default-kind integer.
8480 @item @emph{Example}:
8481 @smallexample
8482 INTEGER :: value[*]
8483 INTEGER :: i
8484 value = THIS_IMAGE()
8485 SYNC ALL
8486 IF (THIS_IMAGE() == 1) THEN
8487   DO i = 1, NUM_IMAGES()
8488     WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
8489   END DO
8490 END IF
8491 @end smallexample
8493 @item @emph{See also}:
8494 @ref{THIS_IMAGE}, @ref{IMAGE_INDEX}
8495 @end table
8499 @node OR
8500 @section @code{OR} --- Bitwise logical OR
8501 @fnindex OR
8502 @cindex bitwise logical or
8503 @cindex logical or, bitwise
8505 @table @asis
8506 @item @emph{Description}:
8507 Bitwise logical @code{OR}.
8509 This intrinsic routine is provided for backwards compatibility with 
8510 GNU Fortran 77.  For integer arguments, programmers should consider
8511 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
8513 @item @emph{Standard}:
8514 GNU extension
8516 @item @emph{Class}:
8517 Function
8519 @item @emph{Syntax}:
8520 @code{RESULT = OR(I, J)}
8522 @item @emph{Arguments}:
8523 @multitable @columnfractions .15 .70
8524 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
8525 type or a scalar @code{LOGICAL} type.
8526 @item @var{J} @tab The type shall be the same as the type of @var{J}.
8527 @end multitable
8529 @item @emph{Return value}:
8530 The return type is either a scalar @code{INTEGER} or a scalar
8531 @code{LOGICAL}.  If the kind type parameters differ, then the
8532 smaller kind type is implicitly converted to larger kind, and the 
8533 return has the larger kind.
8535 @item @emph{Example}:
8536 @smallexample
8537 PROGRAM test_or
8538   LOGICAL :: T = .TRUE., F = .FALSE.
8539   INTEGER :: a, b
8540   DATA a / Z'F' /, b / Z'3' /
8542   WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
8543   WRITE (*,*) OR(a, b)
8544 END PROGRAM
8545 @end smallexample
8547 @item @emph{See also}:
8548 Fortran 95 elemental function: @ref{IOR}
8549 @end table
8553 @node PACK
8554 @section @code{PACK} --- Pack an array into an array of rank one
8555 @fnindex PACK
8556 @cindex array, packing
8557 @cindex array, reduce dimension
8558 @cindex array, gather elements
8560 @table @asis
8561 @item @emph{Description}:
8562 Stores the elements of @var{ARRAY} in an array of rank one.
8564 The beginning of the resulting array is made up of elements whose @var{MASK} 
8565 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
8566 @var{VECTOR}.
8568 @item @emph{Standard}:
8569 Fortran 95 and later
8571 @item @emph{Class}:
8572 Transformational function
8574 @item @emph{Syntax}:
8575 @code{RESULT = PACK(ARRAY, MASK[,VECTOR]}
8577 @item @emph{Arguments}:
8578 @multitable @columnfractions .15 .70
8579 @item @var{ARRAY}  @tab Shall be an array of any type.
8580 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL} and 
8581 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL} 
8582 scalar.
8583 @item @var{VECTOR} @tab (Optional) shall be an array of the same type 
8584 as @var{ARRAY} and of rank one. If present, the number of elements in 
8585 @var{VECTOR} shall be equal to or greater than the number of true elements 
8586 in @var{MASK}. If @var{MASK} is scalar, the number of elements in 
8587 @var{VECTOR} shall be equal to or greater than the number of elements in
8588 @var{ARRAY}.
8589 @end multitable
8591 @item @emph{Return value}:
8592 The result is an array of rank one and the same type as that of @var{ARRAY}.
8593 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
8594 number of @code{TRUE} values in @var{MASK} otherwise.
8596 @item @emph{Example}:
8597 Gathering nonzero elements from an array:
8598 @smallexample
8599 PROGRAM test_pack_1
8600   INTEGER :: m(6)
8601   m = (/ 1, 0, 0, 0, 5, 0 /)
8602   WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0)  ! "1 5"
8603 END PROGRAM
8604 @end smallexample
8606 Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
8607 @smallexample
8608 PROGRAM test_pack_2
8609   INTEGER :: m(4)
8610   m = (/ 1, 0, 0, 2 /)
8611   WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /))  ! "1 2 3 4"
8612 END PROGRAM
8613 @end smallexample
8615 @item @emph{See also}:
8616 @ref{UNPACK}
8617 @end table
8621 @node PERROR
8622 @section @code{PERROR} --- Print system error message
8623 @fnindex PERROR
8624 @cindex system, error handling
8626 @table @asis
8627 @item @emph{Description}:
8628 Prints (on the C @code{stderr} stream) a newline-terminated error
8629 message corresponding to the last system error. This is prefixed by
8630 @var{STRING}, a colon and a space. See @code{perror(3)}.
8632 @item @emph{Standard}:
8633 GNU extension
8635 @item @emph{Class}:
8636 Subroutine
8638 @item @emph{Syntax}:
8639 @code{CALL PERROR(STRING)}
8641 @item @emph{Arguments}:
8642 @multitable @columnfractions .15 .70
8643 @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
8644 default kind.
8645 @end multitable
8647 @item @emph{See also}:
8648 @ref{IERRNO}
8649 @end table
8653 @node PRECISION
8654 @section @code{PRECISION} --- Decimal precision of a real kind
8655 @fnindex PRECISION
8656 @cindex model representation, precision
8658 @table @asis
8659 @item @emph{Description}:
8660 @code{PRECISION(X)} returns the decimal precision in the model of the
8661 type of @code{X}.
8663 @item @emph{Standard}:
8664 Fortran 95 and later
8666 @item @emph{Class}:
8667 Inquiry function
8669 @item @emph{Syntax}:
8670 @code{RESULT = PRECISION(X)}
8672 @item @emph{Arguments}:
8673 @multitable @columnfractions .15 .70
8674 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
8675 @end multitable
8677 @item @emph{Return value}:
8678 The return value is of type @code{INTEGER} and of the default integer
8679 kind.
8681 @item @emph{Example}:
8682 @smallexample
8683 program prec_and_range
8684   real(kind=4) :: x(2)
8685   complex(kind=8) :: y
8687   print *, precision(x), range(x)
8688   print *, precision(y), range(y)
8689 end program prec_and_range
8690 @end smallexample
8691 @end table
8695 @node PRESENT
8696 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
8697 @fnindex PRESENT
8699 @table @asis
8700 @item @emph{Description}:
8701 Determines whether an optional dummy argument is present.
8703 @item @emph{Standard}:
8704 Fortran 95 and later
8706 @item @emph{Class}:
8707 Inquiry function
8709 @item @emph{Syntax}:
8710 @code{RESULT = PRESENT(A)}
8712 @item @emph{Arguments}:
8713 @multitable @columnfractions .15 .70
8714 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
8715 value, or a dummy procedure. It shall be the name of an optional dummy argument
8716 accessible within the current subroutine or function.
8717 @end multitable
8719 @item @emph{Return value}:
8720 Returns either @code{TRUE} if the optional argument @var{A} is present, or
8721 @code{FALSE} otherwise.
8723 @item @emph{Example}:
8724 @smallexample
8725 PROGRAM test_present
8726   WRITE(*,*) f(), f(42)      ! "F T"
8727 CONTAINS
8728   LOGICAL FUNCTION f(x)
8729     INTEGER, INTENT(IN), OPTIONAL :: x
8730     f = PRESENT(x)
8731   END FUNCTION
8732 END PROGRAM
8733 @end smallexample
8734 @end table
8738 @node PRODUCT
8739 @section @code{PRODUCT} --- Product of array elements
8740 @fnindex PRODUCT
8741 @cindex array, product
8742 @cindex array, multiply elements
8743 @cindex array, conditionally multiply elements
8744 @cindex multiply array elements
8746 @table @asis
8747 @item @emph{Description}:
8748 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
8749 the corresponding element in @var{MASK} is @code{TRUE}.
8751 @item @emph{Standard}:
8752 Fortran 95 and later
8754 @item @emph{Class}:
8755 Transformational function
8757 @item @emph{Syntax}:
8758 @multitable @columnfractions .80
8759 @item @code{RESULT = PRODUCT(ARRAY[, MASK])}
8760 @item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
8761 @end multitable
8763 @item @emph{Arguments}:
8764 @multitable @columnfractions .15 .70
8765 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
8766 @code{REAL} or @code{COMPLEX}.
8767 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
8768 @code{INTEGER} with a value in the range from 1 to n, where n 
8769 equals the rank of @var{ARRAY}.
8770 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
8771 and either be a scalar or an array of the same shape as @var{ARRAY}.
8772 @end multitable
8774 @item @emph{Return value}:
8775 The result is of the same type as @var{ARRAY}.
8777 If @var{DIM} is absent, a scalar with the product of all elements in 
8778 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals 
8779 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with 
8780 dimension @var{DIM} dropped is returned.
8783 @item @emph{Example}:
8784 @smallexample
8785 PROGRAM test_product
8786   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
8787   print *, PRODUCT(x)                    ! all elements, product = 120
8788   print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
8789 END PROGRAM
8790 @end smallexample
8792 @item @emph{See also}:
8793 @ref{SUM}
8794 @end table
8798 @node RADIX
8799 @section @code{RADIX} --- Base of a model number
8800 @fnindex RADIX
8801 @cindex model representation, base
8802 @cindex model representation, radix
8804 @table @asis
8805 @item @emph{Description}:
8806 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
8808 @item @emph{Standard}:
8809 Fortran 95 and later
8811 @item @emph{Class}:
8812 Inquiry function
8814 @item @emph{Syntax}:
8815 @code{RESULT = RADIX(X)}
8817 @item @emph{Arguments}:
8818 @multitable @columnfractions .15 .70
8819 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
8820 @end multitable
8822 @item @emph{Return value}:
8823 The return value is a scalar of type @code{INTEGER} and of the default
8824 integer kind.
8826 @item @emph{Example}:
8827 @smallexample
8828 program test_radix
8829   print *, "The radix for the default integer kind is", radix(0)
8830   print *, "The radix for the default real kind is", radix(0.0)
8831 end program test_radix
8832 @end smallexample
8834 @end table
8838 @node RAN
8839 @section @code{RAN} --- Real pseudo-random number
8840 @fnindex RAN
8841 @cindex random number generation
8843 @table @asis
8844 @item @emph{Description}:
8845 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
8846 provided as an alias for @code{RAND}.  See @ref{RAND} for complete
8847 documentation.
8849 @item @emph{Standard}:
8850 GNU extension
8852 @item @emph{Class}:
8853 Function
8855 @item @emph{See also}:
8856 @ref{RAND}, @ref{RANDOM_NUMBER}
8857 @end table
8861 @node RAND
8862 @section @code{RAND} --- Real pseudo-random number
8863 @fnindex RAND
8864 @cindex random number generation
8866 @table @asis
8867 @item @emph{Description}:
8868 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
8869 distribution between 0 and 1. If @var{FLAG} is 0, the next number
8870 in the current sequence is returned; if @var{FLAG} is 1, the generator
8871 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
8872 it is used as a new seed with @code{SRAND}.
8874 This intrinsic routine is provided for backwards compatibility with
8875 GNU Fortran 77. It implements a simple modulo generator as provided 
8876 by @command{g77}. For new code, one should consider the use of 
8877 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
8879 @item @emph{Standard}:
8880 GNU extension
8882 @item @emph{Class}:
8883 Function
8885 @item @emph{Syntax}:
8886 @code{RESULT = RAND(I)}
8888 @item @emph{Arguments}:
8889 @multitable @columnfractions .15 .70
8890 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
8891 @end multitable
8893 @item @emph{Return value}:
8894 The return value is of @code{REAL} type and the default kind.
8896 @item @emph{Example}:
8897 @smallexample
8898 program test_rand
8899   integer,parameter :: seed = 86456
8900   
8901   call srand(seed)
8902   print *, rand(), rand(), rand(), rand()
8903   print *, rand(seed), rand(), rand(), rand()
8904 end program test_rand
8905 @end smallexample
8907 @item @emph{See also}:
8908 @ref{SRAND}, @ref{RANDOM_NUMBER}
8910 @end table
8914 @node RANDOM_NUMBER
8915 @section @code{RANDOM_NUMBER} --- Pseudo-random number
8916 @fnindex RANDOM_NUMBER
8917 @cindex random number generation
8919 @table @asis
8920 @item @emph{Description}:
8921 Returns a single pseudorandom number or an array of pseudorandom numbers
8922 from the uniform distribution over the range @math{ 0 \leq x < 1}.
8924 The runtime-library implements George Marsaglia's KISS (Keep It Simple 
8925 Stupid) random number generator (RNG). This RNG combines:
8926 @enumerate
8927 @item The congruential generator @math{x(n) = 69069 \cdot x(n-1) + 1327217885}
8928 with a period of @math{2^{32}},
8929 @item A 3-shift shift-register generator with a period of @math{2^{32} - 1},
8930 @item  Two 16-bit multiply-with-carry generators with a period of
8931 @math{597273182964842497 > 2^{59}}.
8932 @end enumerate
8933 The overall period exceeds @math{2^{123}}.
8935 Please note, this RNG is thread safe if used within OpenMP directives,
8936 i.e., its state will be consistent while called from multiple threads.
8937 However, the KISS generator does not create random numbers in parallel 
8938 from multiple sources, but in sequence from a single source. If an
8939 OpenMP-enabled application heavily relies on random numbers, one should 
8940 consider employing a dedicated parallel random number generator instead.
8942 @item @emph{Standard}:
8943 Fortran 95 and later
8945 @item @emph{Class}:
8946 Subroutine
8948 @item @emph{Syntax}:
8949 @code{RANDOM_NUMBER(HARVEST)}
8951 @item @emph{Arguments}:
8952 @multitable @columnfractions .15 .70
8953 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
8954 @end multitable
8956 @item @emph{Example}:
8957 @smallexample
8958 program test_random_number
8959   REAL :: r(5,5)
8960   CALL init_random_seed()         ! see example of RANDOM_SEED
8961   CALL RANDOM_NUMBER(r)
8962 end program
8963 @end smallexample
8965 @item @emph{See also}:
8966 @ref{RANDOM_SEED}
8967 @end table
8971 @node RANDOM_SEED
8972 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
8973 @fnindex RANDOM_SEED
8974 @cindex random number generation, seeding
8975 @cindex seeding a random number generator
8977 @table @asis
8978 @item @emph{Description}:
8979 Restarts or queries the state of the pseudorandom number generator used by 
8980 @code{RANDOM_NUMBER}.
8982 If @code{RANDOM_SEED} is called without arguments, it is initialized to
8983 a default state. The example below shows how to initialize the random 
8984 seed based on the system's time.
8986 @item @emph{Standard}:
8987 Fortran 95 and later
8989 @item @emph{Class}:
8990 Subroutine
8992 @item @emph{Syntax}:
8993 @code{CALL RANDOM_SEED([SIZE, PUT, GET])}
8995 @item @emph{Arguments}:
8996 @multitable @columnfractions .15 .70
8997 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default 
8998 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size 
8999 of the arrays used with the @var{PUT} and @var{GET} arguments.
9000 @item @var{PUT}  @tab (Optional) Shall be an array of type default 
9001 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of 
9002 the array must be larger than or equal to the number returned by the 
9003 @var{SIZE} argument.
9004 @item @var{GET}  @tab (Optional) Shall be an array of type default 
9005 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size 
9006 of the array must be larger than or equal to the number returned by 
9007 the @var{SIZE} argument.
9008 @end multitable
9010 @item @emph{Example}:
9011 @smallexample
9012 SUBROUTINE init_random_seed()
9013   INTEGER :: i, n, clock
9014   INTEGER, DIMENSION(:), ALLOCATABLE :: seed
9016   CALL RANDOM_SEED(size = n)
9017   ALLOCATE(seed(n))
9019   CALL SYSTEM_CLOCK(COUNT=clock)
9021   seed = clock + 37 * (/ (i - 1, i = 1, n) /)
9022   CALL RANDOM_SEED(PUT = seed)
9024   DEALLOCATE(seed)
9025 END SUBROUTINE
9026 @end smallexample
9028 @item @emph{See also}:
9029 @ref{RANDOM_NUMBER}
9030 @end table
9034 @node RANGE
9035 @section @code{RANGE} --- Decimal exponent range
9036 @fnindex RANGE
9037 @cindex model representation, range
9039 @table @asis
9040 @item @emph{Description}:
9041 @code{RANGE(X)} returns the decimal exponent range in the model of the
9042 type of @code{X}.
9044 @item @emph{Standard}:
9045 Fortran 95 and later
9047 @item @emph{Class}:
9048 Inquiry function
9050 @item @emph{Syntax}:
9051 @code{RESULT = RANGE(X)}
9053 @item @emph{Arguments}:
9054 @multitable @columnfractions .15 .70
9055 @item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL}
9056 or @code{COMPLEX}.
9057 @end multitable
9059 @item @emph{Return value}:
9060 The return value is of type @code{INTEGER} and of the default integer
9061 kind.
9063 @item @emph{Example}:
9064 See @code{PRECISION} for an example.
9065 @end table
9069 @node REAL
9070 @section @code{REAL} --- Convert to real type 
9071 @fnindex REAL
9072 @fnindex REALPART
9073 @fnindex FLOAT
9074 @fnindex DFLOAT
9075 @fnindex SNGL
9076 @cindex conversion, to real
9077 @cindex complex numbers, real part
9079 @table @asis
9080 @item @emph{Description}:
9081 @code{REAL(A [, KIND])} converts its argument @var{A} to a real type.  The
9082 @code{REALPART} function is provided for compatibility with @command{g77},
9083 and its use is strongly discouraged.
9085 @item @emph{Standard}:
9086 Fortran 77 and later
9088 @item @emph{Class}:
9089 Elemental function
9091 @item @emph{Syntax}:
9092 @multitable @columnfractions .80
9093 @item @code{RESULT = REAL(A [, KIND])}
9094 @item @code{RESULT = REALPART(Z)}
9095 @end multitable
9097 @item @emph{Arguments}:
9098 @multitable @columnfractions .15 .70
9099 @item @var{A}    @tab Shall be @code{INTEGER}, @code{REAL}, or
9100 @code{COMPLEX}.
9101 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9102 expression indicating the kind parameter of the result.
9103 @end multitable
9105 @item @emph{Return value}:
9106 These functions return a @code{REAL} variable or array under
9107 the following rules: 
9109 @table @asis
9110 @item (A)
9111 @code{REAL(A)} is converted to a default real type if @var{A} is an 
9112 integer or real variable.
9113 @item (B)
9114 @code{REAL(A)} is converted to a real type with the kind type parameter
9115 of @var{A} if @var{A} is a complex variable.
9116 @item (C)
9117 @code{REAL(A, KIND)} is converted to a real type with kind type
9118 parameter @var{KIND} if @var{A} is a complex, integer, or real
9119 variable.
9120 @end table
9122 @item @emph{Example}:
9123 @smallexample
9124 program test_real
9125   complex :: x = (1.0, 2.0)
9126   print *, real(x), real(x,8), realpart(x)
9127 end program test_real
9128 @end smallexample
9130 @item @emph{Specific names}:
9131 @multitable @columnfractions .20 .20 .20 .25
9132 @item Name             @tab Argument           @tab Return type     @tab Standard
9133 @item @code{FLOAT(A)}  @tab @code{INTEGER(4)}  @tab @code{REAL(4)}  @tab Fortran 77 and later
9134 @item @code{DFLOAT(A)} @tab @code{INTEGER(4)}  @tab @code{REAL(8)}  @tab GNU extension
9135 @item @code{SNGL(A)}   @tab @code{INTEGER(8)}  @tab @code{REAL(4)}  @tab Fortran 77 and later
9136 @end multitable
9139 @item @emph{See also}:
9140 @ref{DBLE}
9142 @end table
9146 @node RENAME
9147 @section @code{RENAME} --- Rename a file
9148 @fnindex RENAME
9149 @cindex file system, rename file
9151 @table @asis
9152 @item @emph{Description}:
9153 Renames a file from file @var{PATH1} to @var{PATH2}. A null
9154 character (@code{CHAR(0)}) can be used to mark the end of the names in
9155 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
9156 names are ignored.  If the @var{STATUS} argument is supplied, it
9157 contains 0 on success or a nonzero error code upon return; see
9158 @code{rename(2)}.
9160 This intrinsic is provided in both subroutine and function forms;
9161 however, only one form can be used in any given program unit.
9163 @item @emph{Standard}:
9164 GNU extension
9166 @item @emph{Class}:
9167 Subroutine, function
9169 @item @emph{Syntax}:
9170 @multitable @columnfractions .80
9171 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
9172 @item @code{STATUS = RENAME(PATH1, PATH2)}
9173 @end multitable
9175 @item @emph{Arguments}:
9176 @multitable @columnfractions .15 .70
9177 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
9178 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
9179 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9180 @end multitable
9182 @item @emph{See also}:
9183 @ref{LINK}
9185 @end table
9189 @node REPEAT
9190 @section @code{REPEAT} --- Repeated string concatenation 
9191 @fnindex REPEAT
9192 @cindex string, repeat
9193 @cindex string, concatenate
9195 @table @asis
9196 @item @emph{Description}:
9197 Concatenates @var{NCOPIES} copies of a string.
9199 @item @emph{Standard}:
9200 Fortran 95 and later
9202 @item @emph{Class}:
9203 Transformational function
9205 @item @emph{Syntax}:
9206 @code{RESULT = REPEAT(STRING, NCOPIES)}
9208 @item @emph{Arguments}:
9209 @multitable @columnfractions .15 .70
9210 @item @var{STRING}  @tab Shall be scalar and of type @code{CHARACTER}.
9211 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
9212 @end multitable
9214 @item @emph{Return value}:
9215 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies 
9216 of @var{STRING}.
9218 @item @emph{Example}:
9219 @smallexample
9220 program test_repeat
9221   write(*,*) repeat("x", 5)   ! "xxxxx"
9222 end program
9223 @end smallexample
9224 @end table
9228 @node RESHAPE
9229 @section @code{RESHAPE} --- Function to reshape an array
9230 @fnindex RESHAPE
9231 @cindex array, change dimensions
9232 @cindex array, transmogrify
9234 @table @asis
9235 @item @emph{Description}:
9236 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
9237 the new array may be padded with elements from @var{PAD} or permuted
9238 as defined by @var{ORDER}.
9240 @item @emph{Standard}:
9241 Fortran 95 and later
9243 @item @emph{Class}:
9244 Transformational function
9246 @item @emph{Syntax}:
9247 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
9249 @item @emph{Arguments}:
9250 @multitable @columnfractions .15 .70
9251 @item @var{SOURCE} @tab Shall be an array of any type.
9252 @item @var{SHAPE}  @tab Shall be of type @code{INTEGER} and an 
9253 array of rank one. Its values must be positive or zero.
9254 @item @var{PAD}    @tab (Optional) shall be an array of the same 
9255 type as @var{SOURCE}.
9256 @item @var{ORDER}  @tab (Optional) shall be of type @code{INTEGER}
9257 and an array of the same shape as @var{SHAPE}. Its values shall
9258 be a permutation of the numbers from 1 to n, where n is the size of 
9259 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
9260 be assumed.
9261 @end multitable
9263 @item @emph{Return value}:
9264 The result is an array of shape @var{SHAPE} with the same type as 
9265 @var{SOURCE}. 
9267 @item @emph{Example}:
9268 @smallexample
9269 PROGRAM test_reshape
9270   INTEGER, DIMENSION(4) :: x
9271   WRITE(*,*) SHAPE(x)                       ! prints "4"
9272   WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/)))    ! prints "2 2"
9273 END PROGRAM
9274 @end smallexample
9276 @item @emph{See also}:
9277 @ref{SHAPE}
9278 @end table
9282 @node RRSPACING
9283 @section @code{RRSPACING} --- Reciprocal of the relative spacing
9284 @fnindex RRSPACING
9285 @cindex real number, relative spacing
9286 @cindex floating point, relative spacing
9289 @table @asis
9290 @item @emph{Description}:
9291 @code{RRSPACING(X)} returns the  reciprocal of the relative spacing of
9292 model numbers near @var{X}.
9294 @item @emph{Standard}:
9295 Fortran 95 and later
9297 @item @emph{Class}:
9298 Elemental function
9300 @item @emph{Syntax}:
9301 @code{RESULT = RRSPACING(X)}
9303 @item @emph{Arguments}:
9304 @multitable @columnfractions .15 .70
9305 @item @var{X} @tab Shall be of type @code{REAL}.
9306 @end multitable
9308 @item @emph{Return value}:
9309 The return value is of the same type and kind as @var{X}.
9310 The value returned is equal to
9311 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
9313 @item @emph{See also}:
9314 @ref{SPACING}
9315 @end table
9319 @node RSHIFT
9320 @section @code{RSHIFT} --- Right shift bits
9321 @fnindex RSHIFT
9322 @cindex bits, shift right
9324 @table @asis
9325 @item @emph{Description}:
9326 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
9327 bits shifted right by @var{SHIFT} places.  If the absolute value of
9328 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined. 
9329 Bits shifted out from the left end are lost; zeros are shifted in from
9330 the opposite end.
9332 This function has been superseded by the @code{ISHFT} intrinsic, which
9333 is standard in Fortran 95 and later.
9335 @item @emph{Standard}:
9336 GNU extension
9338 @item @emph{Class}:
9339 Elemental function
9341 @item @emph{Syntax}:
9342 @code{RESULT = RSHIFT(I, SHIFT)}
9344 @item @emph{Arguments}:
9345 @multitable @columnfractions .15 .70
9346 @item @var{I} @tab The type shall be @code{INTEGER}.
9347 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
9348 @end multitable
9350 @item @emph{Return value}:
9351 The return value is of type @code{INTEGER} and of the same kind as
9352 @var{I}.
9354 @item @emph{See also}:
9355 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
9357 @end table
9361 @node SCALE
9362 @section @code{SCALE} --- Scale a real value
9363 @fnindex SCALE
9364 @cindex real number, scale
9365 @cindex floating point, scale
9367 @table @asis
9368 @item @emph{Description}:
9369 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
9371 @item @emph{Standard}:
9372 Fortran 95 and later
9374 @item @emph{Class}:
9375 Elemental function
9377 @item @emph{Syntax}:
9378 @code{RESULT = SCALE(X, I)}
9380 @item @emph{Arguments}:
9381 @multitable @columnfractions .15 .70
9382 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
9383 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
9384 @end multitable
9386 @item @emph{Return value}:
9387 The return value is of the same type and kind as @var{X}.
9388 Its value is @code{X * RADIX(X)**I}.
9390 @item @emph{Example}:
9391 @smallexample
9392 program test_scale
9393   real :: x = 178.1387e-4
9394   integer :: i = 5
9395   print *, scale(x,i), x*radix(x)**i
9396 end program test_scale
9397 @end smallexample
9399 @end table
9403 @node SCAN
9404 @section @code{SCAN} --- Scan a string for the presence of a set of characters
9405 @fnindex SCAN
9406 @cindex string, find subset
9408 @table @asis
9409 @item @emph{Description}:
9410 Scans a @var{STRING} for any of the characters in a @var{SET} 
9411 of characters.
9413 If @var{BACK} is either absent or equals @code{FALSE}, this function
9414 returns the position of the leftmost character of @var{STRING} that is
9415 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
9416 is returned. If no character of @var{SET} is found in @var{STRING}, the 
9417 result is zero.
9419 @item @emph{Standard}:
9420 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
9422 @item @emph{Class}:
9423 Elemental function
9425 @item @emph{Syntax}:
9426 @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
9428 @item @emph{Arguments}:
9429 @multitable @columnfractions .15 .70
9430 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
9431 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
9432 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
9433 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
9434 expression indicating the kind parameter of the result.
9435 @end multitable
9437 @item @emph{Return value}:
9438 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9439 @var{KIND} is absent, the return value is of default integer kind.
9441 @item @emph{Example}:
9442 @smallexample
9443 PROGRAM test_scan
9444   WRITE(*,*) SCAN("FORTRAN", "AO")          ! 2, found 'O'
9445   WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.)  ! 6, found 'A'
9446   WRITE(*,*) SCAN("FORTRAN", "C++")         ! 0, found none
9447 END PROGRAM
9448 @end smallexample
9450 @item @emph{See also}:
9451 @ref{INDEX intrinsic}, @ref{VERIFY}
9452 @end table
9456 @node SECNDS
9457 @section @code{SECNDS} --- Time function
9458 @fnindex SECNDS
9459 @cindex time, elapsed
9460 @cindex elapsed time
9462 @table @asis
9463 @item @emph{Description}:
9464 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
9465 @var{X} is a reference time, also in seconds. If this is zero, the time in
9466 seconds from midnight is returned. This function is non-standard and its
9467 use is discouraged.
9469 @item @emph{Standard}:
9470 GNU extension
9472 @item @emph{Class}:
9473 Function
9475 @item @emph{Syntax}:
9476 @code{RESULT = SECNDS (X)}
9478 @item @emph{Arguments}:
9479 @multitable @columnfractions .15 .70
9480 @item @var{T}     @tab Shall be of type @code{REAL(4)}.
9481 @item @var{X}     @tab Shall be of type @code{REAL(4)}.
9482 @end multitable
9484 @item @emph{Return value}:
9485 None
9487 @item @emph{Example}:
9488 @smallexample
9489 program test_secnds
9490     integer :: i
9491     real(4) :: t1, t2
9492     print *, secnds (0.0)   ! seconds since midnight
9493     t1 = secnds (0.0)       ! reference time
9494     do i = 1, 10000000      ! do something
9495     end do
9496     t2 = secnds (t1)        ! elapsed time
9497     print *, "Something took ", t2, " seconds."
9498 end program test_secnds
9499 @end smallexample
9500 @end table
9504 @node SECOND
9505 @section @code{SECOND} --- CPU time function
9506 @fnindex SECOND
9507 @cindex time, elapsed
9508 @cindex elapsed time
9510 @table @asis
9511 @item @emph{Description}:
9512 Returns a @code{REAL(4)} value representing the elapsed CPU time in
9513 seconds.  This provides the same functionality as the standard
9514 @code{CPU_TIME} intrinsic, and is only included for backwards
9515 compatibility.
9517 This intrinsic is provided in both subroutine and function forms;
9518 however, only one form can be used in any given program unit.
9520 @item @emph{Standard}:
9521 GNU extension
9523 @item @emph{Class}:
9524 Subroutine, function
9526 @item @emph{Syntax}:
9527 @multitable @columnfractions .80
9528 @item @code{CALL SECOND(TIME)}
9529 @item @code{TIME = SECOND()}
9530 @end multitable
9532 @item @emph{Arguments}:
9533 @multitable @columnfractions .15 .70
9534 @item @var{TIME}  @tab Shall be of type @code{REAL(4)}.
9535 @end multitable
9537 @item @emph{Return value}:
9538 In either syntax, @var{TIME} is set to the process's current runtime in
9539 seconds.
9541 @item @emph{See also}:
9542 @ref{CPU_TIME}
9544 @end table
9548 @node SELECTED_CHAR_KIND
9549 @section @code{SELECTED_CHAR_KIND} --- Choose character kind
9550 @fnindex SELECTED_CHAR_KIND
9551 @cindex character kind
9552 @cindex kind, character
9554 @table @asis
9555 @item @emph{Description}:
9557 @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
9558 set named @var{NAME}, if a character set with such a name is supported,
9559 or @math{-1} otherwise. Currently, supported character sets include
9560 ``ASCII'' and ``DEFAULT'', which are equivalent.
9562 @item @emph{Standard}:
9563 Fortran 2003 and later
9565 @item @emph{Class}:
9566 Transformational function
9568 @item @emph{Syntax}:
9569 @code{RESULT = SELECTED_CHAR_KIND(NAME)}
9571 @item @emph{Arguments}:
9572 @multitable @columnfractions .15 .70
9573 @item @var{NAME} @tab Shall be a scalar and of the default character type.
9574 @end multitable
9576 @item @emph{Example}:
9577 @smallexample
9578 program ascii_kind
9579   integer,parameter :: ascii = selected_char_kind("ascii")
9580   character(kind=ascii, len=26) :: s
9582   s = ascii_"abcdefghijklmnopqrstuvwxyz"
9583   print *, s
9584 end program ascii_kind
9585 @end smallexample
9586 @end table
9590 @node SELECTED_INT_KIND
9591 @section @code{SELECTED_INT_KIND} --- Choose integer kind
9592 @fnindex SELECTED_INT_KIND
9593 @cindex integer kind
9594 @cindex kind, integer
9596 @table @asis
9597 @item @emph{Description}:
9598 @code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer
9599 type that can represent all values ranging from @math{-10^R} (exclusive)
9600 to @math{10^R} (exclusive). If there is no integer kind that accommodates
9601 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
9603 @item @emph{Standard}:
9604 Fortran 95 and later
9606 @item @emph{Class}:
9607 Transformational function
9609 @item @emph{Syntax}:
9610 @code{RESULT = SELECTED_INT_KIND(R)}
9612 @item @emph{Arguments}:
9613 @multitable @columnfractions .15 .70
9614 @item @var{R} @tab Shall be a scalar and of type @code{INTEGER}.
9615 @end multitable
9617 @item @emph{Example}:
9618 @smallexample
9619 program large_integers
9620   integer,parameter :: k5 = selected_int_kind(5)
9621   integer,parameter :: k15 = selected_int_kind(15)
9622   integer(kind=k5) :: i5
9623   integer(kind=k15) :: i15
9625   print *, huge(i5), huge(i15)
9627   ! The following inequalities are always true
9628   print *, huge(i5) >= 10_k5**5-1
9629   print *, huge(i15) >= 10_k15**15-1
9630 end program large_integers
9631 @end smallexample
9632 @end table
9636 @node SELECTED_REAL_KIND
9637 @section @code{SELECTED_REAL_KIND} --- Choose real kind
9638 @fnindex SELECTED_REAL_KIND
9639 @cindex real kind
9640 @cindex kind, real
9642 @table @asis
9643 @item @emph{Description}:
9644 @code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type
9645 with decimal precision of at least @code{P} digits and exponent
9646 range greater at least @code{R}. 
9648 @item @emph{Standard}:
9649 Fortran 95 and later
9651 @item @emph{Class}:
9652 Transformational function
9654 @item @emph{Syntax}:
9655 @code{RESULT = SELECTED_REAL_KIND([P, R])}
9657 @item @emph{Arguments}:
9658 @multitable @columnfractions .15 .70
9659 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
9660 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
9661 @end multitable
9662 At least one argument shall be present.
9664 @item @emph{Return value}:
9666 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
9667 a real data type with decimal precision of at least @code{P} digits and a
9668 decimal exponent range of at least @code{R}. If more than one real data
9669 type meet the criteria, the kind of the data type with the smallest
9670 decimal precision is returned. If no real data type matches the criteria,
9671 the result is
9672 @table @asis
9673 @item -1 if the processor does not support a real data type with a
9674 precision greater than or equal to @code{P}
9675 @item -2 if the processor does not support a real type with an exponent
9676 range greater than or equal to @code{R}
9677 @item -3 if neither is supported.
9678 @end table
9680 @item @emph{Example}:
9681 @smallexample
9682 program real_kinds
9683   integer,parameter :: p6 = selected_real_kind(6)
9684   integer,parameter :: p10r100 = selected_real_kind(10,100)
9685   integer,parameter :: r400 = selected_real_kind(r=400)
9686   real(kind=p6) :: x
9687   real(kind=p10r100) :: y
9688   real(kind=r400) :: z
9690   print *, precision(x), range(x)
9691   print *, precision(y), range(y)
9692   print *, precision(z), range(z)
9693 end program real_kinds
9694 @end smallexample
9695 @end table
9699 @node SET_EXPONENT
9700 @section @code{SET_EXPONENT} --- Set the exponent of the model
9701 @fnindex SET_EXPONENT
9702 @cindex real number, set exponent
9703 @cindex floating point, set exponent
9705 @table @asis
9706 @item @emph{Description}:
9707 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
9708 is that that of @var{X} and whose exponent part is @var{I}.
9710 @item @emph{Standard}:
9711 Fortran 95 and later
9713 @item @emph{Class}:
9714 Elemental function
9716 @item @emph{Syntax}:
9717 @code{RESULT = SET_EXPONENT(X, I)}
9719 @item @emph{Arguments}:
9720 @multitable @columnfractions .15 .70
9721 @item @var{X} @tab Shall be of type @code{REAL}.
9722 @item @var{I} @tab Shall be of type @code{INTEGER}.
9723 @end multitable
9725 @item @emph{Return value}:
9726 The return value is of the same type and kind as @var{X}.
9727 The real number whose fractional part
9728 is that that of @var{X} and whose exponent part if @var{I} is returned;
9729 it is @code{FRACTION(X) * RADIX(X)**I}.
9731 @item @emph{Example}:
9732 @smallexample
9733 PROGRAM test_setexp
9734   REAL :: x = 178.1387e-4
9735   INTEGER :: i = 17
9736   PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
9737 END PROGRAM
9738 @end smallexample
9740 @end table
9744 @node SHAPE
9745 @section @code{SHAPE} --- Determine the shape of an array
9746 @fnindex SHAPE
9747 @cindex array, shape
9749 @table @asis
9750 @item @emph{Description}:
9751 Determines the shape of an array.
9753 @item @emph{Standard}:
9754 Fortran 95 and later
9756 @item @emph{Class}:
9757 Inquiry function
9759 @item @emph{Syntax}:
9760 @code{RESULT = SHAPE(SOURCE)}
9762 @item @emph{Arguments}:
9763 @multitable @columnfractions .15 .70
9764 @item @var{SOURCE} @tab Shall be an array or scalar of any type. 
9765 If @var{SOURCE} is a pointer it must be associated and allocatable 
9766 arrays must be allocated.
9767 @end multitable
9769 @item @emph{Return value}:
9770 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE} 
9771 has dimensions. The elements of the resulting array correspond to the extend
9772 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
9773 the result is the rank one array of size zero.
9775 @item @emph{Example}:
9776 @smallexample
9777 PROGRAM test_shape
9778   INTEGER, DIMENSION(-1:1, -1:2) :: A
9779   WRITE(*,*) SHAPE(A)             ! (/ 3, 4 /)
9780   WRITE(*,*) SIZE(SHAPE(42))      ! (/ /)
9781 END PROGRAM
9782 @end smallexample
9784 @item @emph{See also}:
9785 @ref{RESHAPE}, @ref{SIZE}
9786 @end table
9790 @node SIGN
9791 @section @code{SIGN} --- Sign copying function
9792 @fnindex SIGN
9793 @fnindex ISIGN
9794 @fnindex DSIGN
9795 @cindex sign copying
9797 @table @asis
9798 @item @emph{Description}:
9799 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
9801 @item @emph{Standard}:
9802 Fortran 77 and later
9804 @item @emph{Class}:
9805 Elemental function
9807 @item @emph{Syntax}:
9808 @code{RESULT = SIGN(A, B)}
9810 @item @emph{Arguments}:
9811 @multitable @columnfractions .15 .70
9812 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
9813 @item @var{B} @tab Shall be of the same type and kind as @var{A}
9814 @end multitable
9816 @item @emph{Return value}:
9817 The kind of the return value is that of @var{A} and @var{B}.
9818 If @math{B\ge 0} then the result is @code{ABS(A)}, else
9819 it is @code{-ABS(A)}.
9821 @item @emph{Example}:
9822 @smallexample
9823 program test_sign
9824   print *, sign(-12,1)
9825   print *, sign(-12,0)
9826   print *, sign(-12,-1)
9828   print *, sign(-12.,1.)
9829   print *, sign(-12.,0.)
9830   print *, sign(-12.,-1.)
9831 end program test_sign
9832 @end smallexample
9834 @item @emph{Specific names}:
9835 @multitable @columnfractions .20 .20 .20 .25
9836 @item Name              @tab Arguments              @tab Return type       @tab Standard
9837 @item @code{SIGN(A,B)}  @tab @code{REAL(4) A, B}    @tab @code{REAL(4)}    @tab f77, gnu
9838 @item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab f77, gnu
9839 @item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B}    @tab @code{REAL(8)}    @tab f77, gnu
9840 @end multitable
9841 @end table
9845 @node SIGNAL
9846 @section @code{SIGNAL} --- Signal handling subroutine (or function)
9847 @fnindex SIGNAL
9848 @cindex system, signal handling
9850 @table @asis
9851 @item @emph{Description}:
9852 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
9853 @var{HANDLER} to be executed with a single integer argument when signal
9854 @var{NUMBER} occurs.  If @var{HANDLER} is an integer, it can be used to
9855 turn off handling of signal @var{NUMBER} or revert to its default
9856 action.  See @code{signal(2)}.
9858 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
9859 is supplied, it is set to the value returned by @code{signal(2)}.
9861 @item @emph{Standard}:
9862 GNU extension
9864 @item @emph{Class}:
9865 Subroutine, function
9867 @item @emph{Syntax}:
9868 @multitable @columnfractions .80
9869 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
9870 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
9871 @end multitable
9873 @item @emph{Arguments}:
9874 @multitable @columnfractions .15 .70
9875 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
9876 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
9877 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
9878 @code{INTEGER}. It is @code{INTENT(IN)}.
9879 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
9880 integer. It has @code{INTENT(OUT)}.
9881 @end multitable
9882 @c TODO: What should the interface of the handler be?  Does it take arguments?
9884 @item @emph{Return value}:
9885 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
9887 @item @emph{Example}:
9888 @smallexample
9889 program test_signal
9890   intrinsic signal
9891   external handler_print
9893   call signal (12, handler_print)
9894   call signal (10, 1)
9896   call sleep (30)
9897 end program test_signal
9898 @end smallexample
9899 @end table
9903 @node SIN
9904 @section @code{SIN} --- Sine function 
9905 @fnindex SIN
9906 @fnindex DSIN
9907 @fnindex CSIN
9908 @fnindex ZSIN
9909 @fnindex CDSIN
9910 @cindex trigonometric function, sine
9911 @cindex sine
9913 @table @asis
9914 @item @emph{Description}:
9915 @code{SIN(X)} computes the sine of @var{X}.
9917 @item @emph{Standard}:
9918 Fortran 77 and later
9920 @item @emph{Class}:
9921 Elemental function
9923 @item @emph{Syntax}:
9924 @code{RESULT = SIN(X)}
9926 @item @emph{Arguments}:
9927 @multitable @columnfractions .15 .70
9928 @item @var{X} @tab The type shall be @code{REAL} or
9929 @code{COMPLEX}.
9930 @end multitable
9932 @item @emph{Return value}:
9933 The return value has same type and kind as @var{X}.
9935 @item @emph{Example}:
9936 @smallexample
9937 program test_sin
9938   real :: x = 0.0
9939   x = sin(x)
9940 end program test_sin
9941 @end smallexample
9943 @item @emph{Specific names}:
9944 @multitable @columnfractions .20 .20 .20 .25
9945 @item Name            @tab Argument             @tab Return type       @tab Standard
9946 @item @code{SIN(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}    @tab f77, gnu
9947 @item @code{DSIN(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}    @tab f95, gnu
9948 @item @code{CSIN(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)} @tab f95, gnu
9949 @item @code{ZSIN(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)} @tab f95, gnu
9950 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)} @tab f95, gnu
9951 @end multitable
9953 @item @emph{See also}:
9954 @ref{ASIN}
9955 @end table
9959 @node SINH
9960 @section @code{SINH} --- Hyperbolic sine function 
9961 @fnindex SINH
9962 @fnindex DSINH
9963 @cindex hyperbolic sine
9964 @cindex hyperbolic function, sine
9965 @cindex sine, hyperbolic
9967 @table @asis
9968 @item @emph{Description}:
9969 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
9971 @item @emph{Standard}:
9972 Fortran 95 and later, for a complex argument Fortran 2008 or later
9974 @item @emph{Class}:
9975 Elemental function
9977 @item @emph{Syntax}:
9978 @code{RESULT = SINH(X)}
9980 @item @emph{Arguments}:
9981 @multitable @columnfractions .15 .70
9982 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
9983 @end multitable
9985 @item @emph{Return value}:
9986 The return value has same type and kind as @var{X}.
9988 @item @emph{Example}:
9989 @smallexample
9990 program test_sinh
9991   real(8) :: x = - 1.0_8
9992   x = sinh(x)
9993 end program test_sinh
9994 @end smallexample
9996 @item @emph{Specific names}:
9997 @multitable @columnfractions .20 .20 .20 .25
9998 @item Name            @tab Argument          @tab Return type       @tab Standard
9999 @item @code{SINH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
10000 @item @code{DSINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
10001 @end multitable
10003 @item @emph{See also}:
10004 @ref{ASINH}
10005 @end table
10009 @node SIZE
10010 @section @code{SIZE} --- Determine the size of an array
10011 @fnindex SIZE
10012 @cindex array, size
10013 @cindex array, number of elements
10014 @cindex array, count elements
10016 @table @asis
10017 @item @emph{Description}:
10018 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
10019 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
10021 @item @emph{Standard}:
10022 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
10024 @item @emph{Class}:
10025 Inquiry function
10027 @item @emph{Syntax}:
10028 @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
10030 @item @emph{Arguments}:
10031 @multitable @columnfractions .15 .70
10032 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
10033 a pointer it must be associated and allocatable arrays must be allocated.
10034 @item @var{DIM}   @tab (Optional) shall be a scalar of type @code{INTEGER} 
10035 and its value shall be in the range from 1 to n, where n equals the rank 
10036 of @var{ARRAY}.
10037 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10038 expression indicating the kind parameter of the result.
10039 @end multitable
10041 @item @emph{Return value}:
10042 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
10043 @var{KIND} is absent, the return value is of default integer kind.
10045 @item @emph{Example}:
10046 @smallexample
10047 PROGRAM test_size
10048   WRITE(*,*) SIZE((/ 1, 2 /))    ! 2
10049 END PROGRAM
10050 @end smallexample
10052 @item @emph{See also}:
10053 @ref{SHAPE}, @ref{RESHAPE}
10054 @end table
10057 @node SIZEOF
10058 @section @code{SIZEOF} --- Size in bytes of an expression
10059 @fnindex SIZEOF
10060 @cindex expression size
10061 @cindex size of an expression
10063 @table @asis
10064 @item @emph{Description}:
10065 @code{SIZEOF(X)} calculates the number of bytes of storage the
10066 expression @code{X} occupies.
10068 @item @emph{Standard}:
10069 GNU extension
10071 @item @emph{Class}:
10072 Intrinsic function
10074 @item @emph{Syntax}:
10075 @code{N = SIZEOF(X)}
10077 @item @emph{Arguments}:
10078 @multitable @columnfractions .15 .70
10079 @item @var{X} @tab The argument shall be of any type, rank or shape.
10080 @end multitable
10082 @item @emph{Return value}:
10083 The return value is of type integer and of the system-dependent kind
10084 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
10085 number of bytes occupied by the argument.  If the argument has the
10086 @code{POINTER} attribute, the number of bytes of the storage area pointed
10087 to is returned.  If the argument is of a derived type with @code{POINTER}
10088 or @code{ALLOCATABLE} components, the return value doesn't account for
10089 the sizes of the data pointed to by these components.
10091 @item @emph{Example}:
10092 @smallexample
10093    integer :: i
10094    real :: r, s(5)
10095    print *, (sizeof(s)/sizeof(r) == 5)
10096    end
10097 @end smallexample
10098 The example will print @code{.TRUE.} unless you are using a platform
10099 where default @code{REAL} variables are unusually padded.
10101 @item @emph{See also}:
10102 @ref{C_SIZEOF}
10103 @end table
10106 @node SLEEP
10107 @section @code{SLEEP} --- Sleep for the specified number of seconds
10108 @fnindex SLEEP
10109 @cindex delayed execution
10111 @table @asis
10112 @item @emph{Description}:
10113 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
10115 @item @emph{Standard}:
10116 GNU extension
10118 @item @emph{Class}:
10119 Subroutine
10121 @item @emph{Syntax}:
10122 @code{CALL SLEEP(SECONDS)}
10124 @item @emph{Arguments}:
10125 @multitable @columnfractions .15 .70
10126 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
10127 @end multitable
10129 @item @emph{Example}:
10130 @smallexample
10131 program test_sleep
10132   call sleep(5)
10134 @end smallexample
10135 @end table
10139 @node SPACING
10140 @section @code{SPACING} --- Smallest distance between two numbers of a given type
10141 @fnindex SPACING
10142 @cindex real number, relative spacing
10143 @cindex floating point, relative spacing
10145 @table @asis
10146 @item @emph{Description}:
10147 Determines the distance between the argument @var{X} and the nearest 
10148 adjacent number of the same type.
10150 @item @emph{Standard}:
10151 Fortran 95 and later
10153 @item @emph{Class}:
10154 Elemental function
10156 @item @emph{Syntax}:
10157 @code{RESULT = SPACING(X)}
10159 @item @emph{Arguments}:
10160 @multitable @columnfractions .15 .70
10161 @item @var{X} @tab Shall be of type @code{REAL}.
10162 @end multitable
10164 @item @emph{Return value}:
10165 The result is of the same type as the input argument @var{X}.
10167 @item @emph{Example}:
10168 @smallexample
10169 PROGRAM test_spacing
10170   INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
10171   INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
10173   WRITE(*,*) spacing(1.0_SGL)      ! "1.1920929E-07"          on i686
10174   WRITE(*,*) spacing(1.0_DBL)      ! "2.220446049250313E-016" on i686
10175 END PROGRAM
10176 @end smallexample
10178 @item @emph{See also}:
10179 @ref{RRSPACING}
10180 @end table
10184 @node SPREAD
10185 @section @code{SPREAD} --- Add a dimension to an array
10186 @fnindex SPREAD
10187 @cindex array, increase dimension
10188 @cindex array, duplicate elements
10189 @cindex array, duplicate dimensions
10191 @table @asis
10192 @item @emph{Description}:
10193 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified 
10194 dimension @var{DIM}.
10196 @item @emph{Standard}:
10197 Fortran 95 and later
10199 @item @emph{Class}:
10200 Transformational function
10202 @item @emph{Syntax}:
10203 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
10205 @item @emph{Arguments}:
10206 @multitable @columnfractions .15 .70
10207 @item @var{SOURCE}  @tab Shall be a scalar or an array of any type and 
10208 a rank less than seven.
10209 @item @var{DIM}     @tab Shall be a scalar of type @code{INTEGER} with a 
10210 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
10211 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
10212 @end multitable
10214 @item @emph{Return value}:
10215 The result is an array of the same type as @var{SOURCE} and has rank n+1
10216 where n equals the rank of @var{SOURCE}.
10218 @item @emph{Example}:
10219 @smallexample
10220 PROGRAM test_spread
10221   INTEGER :: a = 1, b(2) = (/ 1, 2 /)
10222   WRITE(*,*) SPREAD(A, 1, 2)            ! "1 1"
10223   WRITE(*,*) SPREAD(B, 1, 2)            ! "1 1 2 2"
10224 END PROGRAM
10225 @end smallexample
10227 @item @emph{See also}:
10228 @ref{UNPACK}
10229 @end table
10233 @node SQRT
10234 @section @code{SQRT} --- Square-root function
10235 @fnindex SQRT
10236 @fnindex DSQRT
10237 @fnindex CSQRT
10238 @fnindex ZSQRT
10239 @fnindex CDSQRT
10240 @cindex root
10241 @cindex square-root
10243 @table @asis
10244 @item @emph{Description}:
10245 @code{SQRT(X)} computes the square root of @var{X}.
10247 @item @emph{Standard}:
10248 Fortran 77 and later
10250 @item @emph{Class}:
10251 Elemental function
10253 @item @emph{Syntax}:
10254 @code{RESULT = SQRT(X)}
10256 @item @emph{Arguments}:
10257 @multitable @columnfractions .15 .70
10258 @item @var{X} @tab The type shall be @code{REAL} or
10259 @code{COMPLEX}.
10260 @end multitable
10262 @item @emph{Return value}:
10263 The return value is of type @code{REAL} or @code{COMPLEX}.
10264 The kind type parameter is the same as @var{X}.
10266 @item @emph{Example}:
10267 @smallexample
10268 program test_sqrt
10269   real(8) :: x = 2.0_8
10270   complex :: z = (1.0, 2.0)
10271   x = sqrt(x)
10272   z = sqrt(z)
10273 end program test_sqrt
10274 @end smallexample
10276 @item @emph{Specific names}:
10277 @multitable @columnfractions .20 .20 .20 .25
10278 @item Name             @tab Argument             @tab Return type          @tab Standard
10279 @item @code{SQRT(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}       @tab Fortran 95 and later
10280 @item @code{DSQRT(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}       @tab Fortran 95 and later
10281 @item @code{CSQRT(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab Fortran 95 and later
10282 @item @code{ZSQRT(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
10283 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
10284 @end multitable
10285 @end table
10289 @node SRAND
10290 @section @code{SRAND} --- Reinitialize the random number generator
10291 @fnindex SRAND
10292 @cindex random number generation, seeding
10293 @cindex seeding a random number generator
10295 @table @asis
10296 @item @emph{Description}:
10297 @code{SRAND} reinitializes the pseudo-random number generator
10298 called by @code{RAND} and @code{IRAND}. The new seed used by the
10299 generator is specified by the required argument @var{SEED}.
10301 @item @emph{Standard}:
10302 GNU extension
10304 @item @emph{Class}:
10305 Subroutine
10307 @item @emph{Syntax}:
10308 @code{CALL SRAND(SEED)}
10310 @item @emph{Arguments}:
10311 @multitable @columnfractions .15 .70
10312 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
10313 @end multitable
10315 @item @emph{Return value}:
10316 Does not return anything.
10318 @item @emph{Example}:
10319 See @code{RAND} and @code{IRAND} for examples.
10321 @item @emph{Notes}:
10322 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
10323 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
10324 to generate pseudo-random numbers. Please note that in
10325 GNU Fortran, these two sets of intrinsics (@code{RAND},
10326 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
10327 @code{RANDOM_SEED} on the other hand) access two independent
10328 pseudo-random number generators.
10330 @item @emph{See also}:
10331 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
10333 @end table
10337 @node STAT
10338 @section @code{STAT} --- Get file status
10339 @fnindex STAT
10340 @cindex file system, file status
10342 @table @asis
10343 @item @emph{Description}:
10344 This function returns information about a file. No permissions are required on 
10345 the file itself, but execute (search) permission is required on all of the 
10346 directories in path that lead to the file.
10348 The elements that are obtained and stored in the array @code{VALUES}:
10349 @multitable @columnfractions .15 .70
10350 @item @code{VALUES(1)}   @tab  Device ID 
10351 @item @code{VALUES(2)}   @tab  Inode number 
10352 @item @code{VALUES(3)}   @tab  File mode 
10353 @item @code{VALUES(4)}   @tab  Number of links 
10354 @item @code{VALUES(5)}   @tab  Owner's uid 
10355 @item @code{VALUES(6)}   @tab  Owner's gid 
10356 @item @code{VALUES(7)}   @tab  ID of device containing directory entry for file (0 if not available) 
10357 @item @code{VALUES(8)}   @tab  File size (bytes) 
10358 @item @code{VALUES(9)}   @tab  Last access time 
10359 @item @code{VALUES(10)}  @tab  Last modification time 
10360 @item @code{VALUES(11)}  @tab  Last file status change time 
10361 @item @code{VALUES(12)}  @tab  Preferred I/O block size (-1 if not available) 
10362 @item @code{VALUES(13)}  @tab  Number of blocks allocated (-1 if not available)
10363 @end multitable
10365 Not all these elements are relevant on all systems. 
10366 If an element is not relevant, it is returned as 0.
10368 This intrinsic is provided in both subroutine and function forms; however,
10369 only one form can be used in any given program unit.
10371 @item @emph{Standard}:
10372 GNU extension
10374 @item @emph{Class}:
10375 Subroutine, function
10377 @item @emph{Syntax}:
10378 @code{CALL STAT(NAME, VALUES [, STATUS])}
10380 @item @emph{Arguments}:
10381 @multitable @columnfractions .15 .70
10382 @item @var{NAME}   @tab The type shall be @code{CHARACTER}, of the
10383 default kind and a valid path within the file system.
10384 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
10385 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
10386 on success and a system specific error code otherwise.
10387 @end multitable
10389 @item @emph{Example}:
10390 @smallexample
10391 PROGRAM test_stat
10392   INTEGER, DIMENSION(13) :: buff
10393   INTEGER :: status
10395   CALL STAT("/etc/passwd", buff, status)
10397   IF (status == 0) THEN
10398     WRITE (*, FMT="('Device ID:',               T30, I19)") buff(1)
10399     WRITE (*, FMT="('Inode number:',            T30, I19)") buff(2)
10400     WRITE (*, FMT="('File mode (octal):',       T30, O19)") buff(3)
10401     WRITE (*, FMT="('Number of links:',         T30, I19)") buff(4)
10402     WRITE (*, FMT="('Owner''s uid:',            T30, I19)") buff(5)
10403     WRITE (*, FMT="('Owner''s gid:',            T30, I19)") buff(6)
10404     WRITE (*, FMT="('Device where located:',    T30, I19)") buff(7)
10405     WRITE (*, FMT="('File size:',               T30, I19)") buff(8)
10406     WRITE (*, FMT="('Last access time:',        T30, A19)") CTIME(buff(9))
10407     WRITE (*, FMT="('Last modification time',   T30, A19)") CTIME(buff(10))
10408     WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
10409     WRITE (*, FMT="('Preferred block size:',    T30, I19)") buff(12)
10410     WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
10411   END IF
10412 END PROGRAM
10413 @end smallexample
10415 @item @emph{See also}:
10416 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
10417 @end table
10421 @node SUM
10422 @section @code{SUM} --- Sum of array elements
10423 @fnindex SUM
10424 @cindex array, sum
10425 @cindex array, add elements
10426 @cindex array, conditionally add elements
10427 @cindex sum array elements
10429 @table @asis
10430 @item @emph{Description}:
10431 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
10432 the corresponding element in @var{MASK} is @code{TRUE}.
10434 @item @emph{Standard}:
10435 Fortran 95 and later
10437 @item @emph{Class}:
10438 Transformational function
10440 @item @emph{Syntax}:
10441 @multitable @columnfractions .80
10442 @item @code{RESULT = SUM(ARRAY[, MASK])}
10443 @item @code{RESULT = SUM(ARRAY, DIM[, MASK])}
10444 @end multitable
10446 @item @emph{Arguments}:
10447 @multitable @columnfractions .15 .70
10448 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
10449 @code{REAL} or @code{COMPLEX}.
10450 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
10451 @code{INTEGER} with a value in the range from 1 to n, where n 
10452 equals the rank of @var{ARRAY}.
10453 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
10454 and either be a scalar or an array of the same shape as @var{ARRAY}.
10455 @end multitable
10457 @item @emph{Return value}:
10458 The result is of the same type as @var{ARRAY}.
10460 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
10461 is returned. Otherwise, an array of rank n-1, where n equals the rank of 
10462 @var{ARRAY},and a shape similar to that of @var{ARRAY} with dimension @var{DIM} 
10463 dropped is returned.
10465 @item @emph{Example}:
10466 @smallexample
10467 PROGRAM test_sum
10468   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
10469   print *, SUM(x)                        ! all elements, sum = 15
10470   print *, SUM(x, MASK=MOD(x, 2)==1)     ! odd elements, sum = 9
10471 END PROGRAM
10472 @end smallexample
10474 @item @emph{See also}:
10475 @ref{PRODUCT}
10476 @end table
10480 @node SYMLNK
10481 @section @code{SYMLNK} --- Create a symbolic link
10482 @fnindex SYMLNK
10483 @cindex file system, create link
10484 @cindex file system, soft link
10486 @table @asis
10487 @item @emph{Description}:
10488 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
10489 character (@code{CHAR(0)}) can be used to mark the end of the names in
10490 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
10491 names are ignored.  If the @var{STATUS} argument is supplied, it
10492 contains 0 on success or a nonzero error code upon return; see
10493 @code{symlink(2)}.  If the system does not supply @code{symlink(2)}, 
10494 @code{ENOSYS} is returned.
10496 This intrinsic is provided in both subroutine and function forms;
10497 however, only one form can be used in any given program unit.
10499 @item @emph{Standard}:
10500 GNU extension
10502 @item @emph{Class}:
10503 Subroutine, function
10505 @item @emph{Syntax}:
10506 @multitable @columnfractions .80
10507 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
10508 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
10509 @end multitable
10511 @item @emph{Arguments}:
10512 @multitable @columnfractions .15 .70
10513 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
10514 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
10515 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10516 @end multitable
10518 @item @emph{See also}:
10519 @ref{LINK}, @ref{UNLINK}
10521 @end table
10525 @node SYSTEM
10526 @section @code{SYSTEM} --- Execute a shell command
10527 @fnindex SYSTEM
10528 @cindex system, system call
10530 @table @asis
10531 @item @emph{Description}:
10532 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
10533 argument @var{STATUS} is present, it contains the value returned by
10534 @code{system(3)}, which is presumably 0 if the shell command succeeded.
10535 Note that which shell is used to invoke the command is system-dependent
10536 and environment-dependent.
10538 This intrinsic is provided in both subroutine and function forms;
10539 however, only one form can be used in any given program unit.
10541 @item @emph{Standard}:
10542 GNU extension
10544 @item @emph{Class}:
10545 Subroutine, function
10547 @item @emph{Syntax}:
10548 @multitable @columnfractions .80
10549 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
10550 @item @code{STATUS = SYSTEM(COMMAND)}
10551 @end multitable
10553 @item @emph{Arguments}:
10554 @multitable @columnfractions .15 .70
10555 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
10556 @item @var{STATUS}  @tab (Optional) Shall be of default @code{INTEGER} type.
10557 @end multitable
10559 @item @emph{See also}:
10560 @end table
10564 @node SYSTEM_CLOCK
10565 @section @code{SYSTEM_CLOCK} --- Time function
10566 @fnindex SYSTEM_CLOCK
10567 @cindex time, clock ticks
10568 @cindex clock ticks
10570 @table @asis
10571 @item @emph{Description}:
10572 Determines the @var{COUNT} of milliseconds of wall clock time since 
10573 the Epoch (00:00:00 UTC, January 1, 1970) modulo @var{COUNT_MAX}, 
10574 @var{COUNT_RATE} determines the number of clock ticks per second.
10575 @var{COUNT_RATE} and @var{COUNT_MAX} are constant and specific to 
10576 @command{gfortran}.
10578 If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and
10579 @var{COUNT_RATE} and @var{COUNT_MAX} are set to zero 
10581 @item @emph{Standard}:
10582 Fortran 95 and later
10584 @item @emph{Class}:
10585 Subroutine
10587 @item @emph{Syntax}:
10588 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
10590 @item @emph{Arguments}:
10591 @item @emph{Arguments}:
10592 @multitable @columnfractions .15 .70
10593 @item @var{COUNT}      @tab (Optional) shall be a scalar of type default 
10594 @code{INTEGER} with @code{INTENT(OUT)}.
10595 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type default 
10596 @code{INTEGER} with @code{INTENT(OUT)}.
10597 @item @var{COUNT_MAX}  @tab (Optional) shall be a scalar of type default 
10598 @code{INTEGER} with @code{INTENT(OUT)}.
10599 @end multitable
10601 @item @emph{Example}:
10602 @smallexample
10603 PROGRAM test_system_clock
10604   INTEGER :: count, count_rate, count_max
10605   CALL SYSTEM_CLOCK(count, count_rate, count_max)
10606   WRITE(*,*) count, count_rate, count_max
10607 END PROGRAM
10608 @end smallexample
10610 @item @emph{See also}:
10611 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
10612 @end table
10616 @node TAN
10617 @section @code{TAN} --- Tangent function
10618 @fnindex TAN
10619 @fnindex DTAN
10620 @cindex trigonometric function, tangent
10621 @cindex tangent
10623 @table @asis
10624 @item @emph{Description}:
10625 @code{TAN(X)} computes the tangent of @var{X}.
10627 @item @emph{Standard}:
10628 Fortran 77 and later, for a complex argument Fortran 2008 or later
10630 @item @emph{Class}:
10631 Elemental function
10633 @item @emph{Syntax}:
10634 @code{RESULT = TAN(X)}
10636 @item @emph{Arguments}:
10637 @multitable @columnfractions .15 .70
10638 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
10639 @end multitable
10641 @item @emph{Return value}:
10642 The return value has same type and kind as @var{X}.
10644 @item @emph{Example}:
10645 @smallexample
10646 program test_tan
10647   real(8) :: x = 0.165_8
10648   x = tan(x)
10649 end program test_tan
10650 @end smallexample
10652 @item @emph{Specific names}:
10653 @multitable @columnfractions .20 .20 .20 .25
10654 @item Name            @tab Argument          @tab Return type     @tab Standard
10655 @item @code{TAN(X)}   @tab @code{REAL(4) X}  @tab @code{REAL(4)}  @tab Fortran 95 and later
10656 @item @code{DTAN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}  @tab Fortran 95 and later
10657 @end multitable
10659 @item @emph{See also}:
10660 @ref{ATAN}
10661 @end table
10665 @node TANH
10666 @section @code{TANH} --- Hyperbolic tangent function 
10667 @fnindex TANH
10668 @fnindex DTANH
10669 @cindex hyperbolic tangent
10670 @cindex hyperbolic function, tangent
10671 @cindex tangent, hyperbolic
10673 @table @asis
10674 @item @emph{Description}:
10675 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
10677 @item @emph{Standard}:
10678 Fortran 77 and later, for a complex argument Fortran 2008 or later
10680 @item @emph{Class}:
10681 Elemental function
10683 @item @emph{Syntax}:
10684 @code{X = TANH(X)}
10686 @item @emph{Arguments}:
10687 @multitable @columnfractions .15 .70
10688 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
10689 @end multitable
10691 @item @emph{Return value}:
10692 The return value has same type and kind as @var{X}. If @var{X} is
10693 complex, the imaginary part of the result is in radians. If @var{X}
10694 is @code{REAL}, the return value lies in the range
10695 @math{ - 1 \leq tanh(x) \leq 1 }.
10697 @item @emph{Example}:
10698 @smallexample
10699 program test_tanh
10700   real(8) :: x = 2.1_8
10701   x = tanh(x)
10702 end program test_tanh
10703 @end smallexample
10705 @item @emph{Specific names}:
10706 @multitable @columnfractions .20 .20 .20 .25
10707 @item Name            @tab Argument          @tab Return type       @tab Standard
10708 @item @code{TANH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
10709 @item @code{DTANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
10710 @end multitable
10712 @item @emph{See also}:
10713 @ref{ATANH}
10714 @end table
10718 @node THIS_IMAGE
10719 @section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image
10720 @fnindex THIS_IMAGE
10721 @cindex coarray, THIS_IMAGE
10722 @cindex images, index of this image
10724 @table @asis
10725 @item @emph{Description}:
10726 Returns the cosubscript for this image.
10728 @item @emph{Standard}:
10729 Fortran 2008 and later
10731 @item @emph{Class}:
10732 Transformational function
10734 @item @emph{Syntax}:
10735 @multitable @columnfractions .80
10736 @item @code{RESULT = THIS_IMAGE()}
10737 @item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])}
10738 @end multitable
10740 @item @emph{Arguments}:
10741 @multitable @columnfractions .15 .70
10742 @item @var{COARRAY} @tab Coarray of any type  (optional; if @var{DIM}
10743 present, required).
10744 @item @var{DIM}     @tab default integer scalar (optional). If present,
10745 @var{DIM} shall be between one and the corank of @var{COARRAY}.
10746 @end multitable
10749 @item @emph{Return value}:
10750 Default integer. If @var{COARRAY} is not present, it is scalar and its value
10751 is the index of the invoking image. Otherwise, if @var{DIM} is not present,
10752 a rank-1 array with corank elements is returned, containing the cosubscripts
10753 for @var{COARRAY} specifying the invoking image. If @var{DIM} is present,
10754 a scalar is returned, with the value of the @var{DIM} element of
10755 @code{THIS_IMAGE(COARRAY)}.
10757 @item @emph{Example}:
10758 @smallexample
10759 INTEGER :: value[*]
10760 INTEGER :: i
10761 value = THIS_IMAGE()
10762 SYNC ALL
10763 IF (THIS_IMAGE() == 1) THEN
10764   DO i = 1, NUM_IMAGES()
10765     WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
10766   END DO
10767 END IF
10768 @end smallexample
10770 @item @emph{See also}:
10771 @ref{NUM_IMAGES}, @ref{IMAGE_INDEX}
10772 @end table
10776 @node TIME
10777 @section @code{TIME} --- Time function
10778 @fnindex TIME
10779 @cindex time, current
10780 @cindex current time
10782 @table @asis
10783 @item @emph{Description}:
10784 Returns the current time encoded as an integer (in the manner of the
10785 UNIX function @code{time(3)}). This value is suitable for passing to
10786 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
10788 This intrinsic is not fully portable, such as to systems with 32-bit
10789 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
10790 the values returned by this intrinsic might be, or become, negative, or
10791 numerically less than previous values, during a single run of the
10792 compiled program.
10794 See @ref{TIME8}, for information on a similar intrinsic that might be
10795 portable to more GNU Fortran implementations, though to fewer Fortran
10796 compilers.
10798 @item @emph{Standard}:
10799 GNU extension
10801 @item @emph{Class}:
10802 Function
10804 @item @emph{Syntax}:
10805 @code{RESULT = TIME()}
10807 @item @emph{Return value}:
10808 The return value is a scalar of type @code{INTEGER(4)}.
10810 @item @emph{See also}:
10811 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
10813 @end table
10817 @node TIME8
10818 @section @code{TIME8} --- Time function (64-bit)
10819 @fnindex TIME8
10820 @cindex time, current
10821 @cindex current time
10823 @table @asis
10824 @item @emph{Description}:
10825 Returns the current time encoded as an integer (in the manner of the
10826 UNIX function @code{time(3)}). This value is suitable for passing to
10827 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
10829 @emph{Warning:} this intrinsic does not increase the range of the timing
10830 values over that returned by @code{time(3)}. On a system with a 32-bit
10831 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
10832 it is converted to a 64-bit @code{INTEGER(8)} value. That means
10833 overflows of the 32-bit value can still occur. Therefore, the values
10834 returned by this intrinsic might be or become negative or numerically
10835 less than previous values during a single run of the compiled program.
10837 @item @emph{Standard}:
10838 GNU extension
10840 @item @emph{Class}:
10841 Function
10843 @item @emph{Syntax}:
10844 @code{RESULT = TIME8()}
10846 @item @emph{Return value}:
10847 The return value is a scalar of type @code{INTEGER(8)}.
10849 @item @emph{See also}:
10850 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
10852 @end table
10856 @node TINY
10857 @section @code{TINY} --- Smallest positive number of a real kind
10858 @fnindex TINY
10859 @cindex limits, smallest number
10860 @cindex model representation, smallest number
10862 @table @asis
10863 @item @emph{Description}:
10864 @code{TINY(X)} returns the smallest positive (non zero) number
10865 in the model of the type of @code{X}.
10867 @item @emph{Standard}:
10868 Fortran 95 and later
10870 @item @emph{Class}:
10871 Inquiry function
10873 @item @emph{Syntax}:
10874 @code{RESULT = TINY(X)}
10876 @item @emph{Arguments}:
10877 @multitable @columnfractions .15 .70
10878 @item @var{X} @tab Shall be of type @code{REAL}.
10879 @end multitable
10881 @item @emph{Return value}:
10882 The return value is of the same type and kind as @var{X}
10884 @item @emph{Example}:
10885 See @code{HUGE} for an example.
10886 @end table
10890 @node TRAILZ
10891 @section @code{TRAILZ} --- Number of trailing zero bits of an integer
10892 @fnindex TRAILZ
10893 @cindex zero bits
10895 @table @asis
10896 @item @emph{Description}:
10897 @code{TRAILZ} returns the number of trailing zero bits of an integer.
10899 @item @emph{Standard}:
10900 Fortran 2008 and later
10902 @item @emph{Class}:
10903 Elemental function
10905 @item @emph{Syntax}:
10906 @code{RESULT = TRAILZ(I)}
10908 @item @emph{Arguments}:
10909 @multitable @columnfractions .15 .70
10910 @item @var{I} @tab Shall be of type @code{INTEGER}.
10911 @end multitable
10913 @item @emph{Return value}:
10914 The type of the return value is the default @code{INTEGER}.
10915 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
10917 @item @emph{Example}:
10918 @smallexample
10919 PROGRAM test_trailz
10920   WRITE (*,*) TRAILZ(8)  ! prints 3
10921 END PROGRAM
10922 @end smallexample
10924 @item @emph{See also}:
10925 @ref{BIT_SIZE}, @ref{LEADZ}
10926 @end table
10930 @node TRANSFER
10931 @section @code{TRANSFER} --- Transfer bit patterns
10932 @fnindex TRANSFER
10933 @cindex bits, move
10934 @cindex type cast
10936 @table @asis
10937 @item @emph{Description}:
10938 Interprets the bitwise representation of @var{SOURCE} in memory as if it
10939 is the representation of a variable or array of the same type and type
10940 parameters as @var{MOLD}.
10942 This is approximately equivalent to the C concept of @emph{casting} one
10943 type to another.
10945 @item @emph{Standard}:
10946 Fortran 95 and later
10948 @item @emph{Class}:
10949 Transformational function
10951 @item @emph{Syntax}:
10952 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
10954 @item @emph{Arguments}:
10955 @multitable @columnfractions .15 .70
10956 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
10957 @item @var{MOLD}   @tab Shall be a scalar or an array of any type.
10958 @item @var{SIZE}   @tab (Optional) shall be a scalar of type 
10959 @code{INTEGER}.
10960 @end multitable
10962 @item @emph{Return value}:
10963 The result has the same type as @var{MOLD}, with the bit level
10964 representation of @var{SOURCE}.  If @var{SIZE} is present, the result is
10965 a one-dimensional array of length @var{SIZE}.  If @var{SIZE} is absent
10966 but @var{MOLD} is an array (of any size or shape), the result is a one-
10967 dimensional array of the minimum length needed to contain the entirety
10968 of the bitwise representation of @var{SOURCE}.   If @var{SIZE} is absent
10969 and @var{MOLD} is a scalar, the result is a scalar.
10971 If the bitwise representation of the result is longer than that of
10972 @var{SOURCE}, then the leading bits of the result correspond to those of
10973 @var{SOURCE} and any trailing bits are filled arbitrarily.
10975 When the resulting bit representation does not correspond to a valid
10976 representation of a variable of the same type as @var{MOLD}, the results
10977 are undefined, and subsequent operations on the result cannot be
10978 guaranteed to produce sensible behavior.  For example, it is possible to
10979 create @code{LOGICAL} variables for which @code{@var{VAR}} and
10980 @code{.NOT.@var{VAR}} both appear to be true.
10982 @item @emph{Example}:
10983 @smallexample
10984 PROGRAM test_transfer
10985   integer :: x = 2143289344
10986   print *, transfer(x, 1.0)    ! prints "NaN" on i686
10987 END PROGRAM
10988 @end smallexample
10989 @end table
10993 @node TRANSPOSE
10994 @section @code{TRANSPOSE} --- Transpose an array of rank two
10995 @fnindex TRANSPOSE
10996 @cindex array, transpose
10997 @cindex matrix, transpose
10998 @cindex transpose
11000 @table @asis
11001 @item @emph{Description}:
11002 Transpose an array of rank two. Element (i, j) of the result has the value 
11003 @code{MATRIX(j, i)}, for all i, j.
11005 @item @emph{Standard}:
11006 Fortran 95 and later
11008 @item @emph{Class}:
11009 Transformational function
11011 @item @emph{Syntax}:
11012 @code{RESULT = TRANSPOSE(MATRIX)}
11014 @item @emph{Arguments}:
11015 @multitable @columnfractions .15 .70
11016 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
11017 @end multitable
11019 @item @emph{Return value}:
11020 The result has the same type as @var{MATRIX}, and has shape 
11021 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
11022 @end table
11026 @node TRIM
11027 @section @code{TRIM} --- Remove trailing blank characters of a string
11028 @fnindex TRIM
11029 @cindex string, remove trailing whitespace
11031 @table @asis
11032 @item @emph{Description}:
11033 Removes trailing blank characters of a string.
11035 @item @emph{Standard}:
11036 Fortran 95 and later
11038 @item @emph{Class}:
11039 Transformational function
11041 @item @emph{Syntax}:
11042 @code{RESULT = TRIM(STRING)}
11044 @item @emph{Arguments}:
11045 @multitable @columnfractions .15 .70
11046 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
11047 @end multitable
11049 @item @emph{Return value}:
11050 A scalar of type @code{CHARACTER} which length is that of @var{STRING}
11051 less the number of trailing blanks.
11053 @item @emph{Example}:
11054 @smallexample
11055 PROGRAM test_trim
11056   CHARACTER(len=10), PARAMETER :: s = "GFORTRAN  "
11057   WRITE(*,*) LEN(s), LEN(TRIM(s))  ! "10 8", with/without trailing blanks
11058 END PROGRAM
11059 @end smallexample
11061 @item @emph{See also}:
11062 @ref{ADJUSTL}, @ref{ADJUSTR}
11063 @end table
11067 @node TTYNAM
11068 @section @code{TTYNAM} --- Get the name of a terminal device.
11069 @fnindex TTYNAM
11070 @cindex system, terminal
11072 @table @asis
11073 @item @emph{Description}:
11074 Get the name of a terminal device. For more information, 
11075 see @code{ttyname(3)}.
11077 This intrinsic is provided in both subroutine and function forms; 
11078 however, only one form can be used in any given program unit. 
11080 @item @emph{Standard}:
11081 GNU extension
11083 @item @emph{Class}:
11084 Subroutine, function
11086 @item @emph{Syntax}:
11087 @multitable @columnfractions .80
11088 @item @code{CALL TTYNAM(UNIT, NAME)}
11089 @item @code{NAME = TTYNAM(UNIT)}
11090 @end multitable
11092 @item @emph{Arguments}:
11093 @multitable @columnfractions .15 .70
11094 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
11095 @item @var{NAME} @tab Shall be of type @code{CHARACTER}.
11096 @end multitable
11098 @item @emph{Example}:
11099 @smallexample
11100 PROGRAM test_ttynam
11101   INTEGER :: unit
11102   DO unit = 1, 10
11103     IF (isatty(unit=unit)) write(*,*) ttynam(unit)
11104   END DO
11105 END PROGRAM
11106 @end smallexample
11108 @item @emph{See also}:
11109 @ref{ISATTY}
11110 @end table
11114 @node UBOUND
11115 @section @code{UBOUND} --- Upper dimension bounds of an array
11116 @fnindex UBOUND
11117 @cindex array, upper bound
11119 @table @asis
11120 @item @emph{Description}:
11121 Returns the upper bounds of an array, or a single upper bound
11122 along the @var{DIM} dimension.
11123 @item @emph{Standard}:
11124 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
11126 @item @emph{Class}:
11127 Inquiry function
11129 @item @emph{Syntax}:
11130 @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
11132 @item @emph{Arguments}:
11133 @multitable @columnfractions .15 .70
11134 @item @var{ARRAY} @tab Shall be an array, of any type.
11135 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
11136 @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
11137 expression indicating the kind parameter of the result.
11138 @end multitable
11140 @item @emph{Return value}:
11141 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11142 @var{KIND} is absent, the return value is of default integer kind.
11143 If @var{DIM} is absent, the result is an array of the upper bounds of
11144 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
11145 corresponding to the upper bound of the array along that dimension.  If
11146 @var{ARRAY} is an expression rather than a whole array or array
11147 structure component, or if it has a zero extent along the relevant
11148 dimension, the upper bound is taken to be the number of elements along
11149 the relevant dimension.
11151 @item @emph{See also}:
11152 @ref{LBOUND}, @ref{LCOBOUND}
11153 @end table
11157 @node UCOBOUND
11158 @section @code{UCOBOUND} --- Upper codimension bounds of an array
11159 @fnindex UCOBOUND
11160 @cindex coarray, upper bound
11162 @table @asis
11163 @item @emph{Description}:
11164 Returns the upper cobounds of a coarray, or a single upper cobound
11165 along the @var{DIM} codimension.
11166 @item @emph{Standard}:
11167 Fortran 2008 and later
11169 @item @emph{Class}:
11170 Inquiry function
11172 @item @emph{Syntax}:
11173 @code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])}
11175 @item @emph{Arguments}:
11176 @multitable @columnfractions .15 .70
11177 @item @var{ARRAY} @tab Shall be an coarray, of any type.
11178 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
11179 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
11180 expression indicating the kind parameter of the result.
11181 @end multitable
11183 @item @emph{Return value}:
11184 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11185 @var{KIND} is absent, the return value is of default integer kind.
11186 If @var{DIM} is absent, the result is an array of the lower cobounds of
11187 @var{COARRAY}.  If @var{DIM} is present, the result is a scalar
11188 corresponding to the lower cobound of the array along that codimension.
11190 @item @emph{See also}:
11191 @ref{LCOBOUND}, @ref{LBOUND}
11192 @end table
11196 @node UMASK
11197 @section @code{UMASK} --- Set the file creation mask
11198 @fnindex UMASK
11199 @cindex file system, file creation mask
11201 @table @asis
11202 @item @emph{Description}:
11203 Sets the file creation mask to @var{MASK}. If called as a function, it
11204 returns the old value. If called as a subroutine and argument @var{OLD}
11205 if it is supplied, it is set to the old value. See @code{umask(2)}.
11207 @item @emph{Standard}:
11208 GNU extension
11210 @item @emph{Class}:
11211 Subroutine, function
11213 @item @emph{Syntax}:
11214 @code{CALL UMASK(MASK [, OLD])}
11215 @code{OLD = UMASK(MASK)}
11217 @item @emph{Arguments}:
11218 @multitable @columnfractions .15 .70
11219 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
11220 @item @var{OLD} @tab (Optional) Shall be a scalar of type
11221 @code{INTEGER}.
11222 @end multitable
11224 @end table
11228 @node UNLINK
11229 @section @code{UNLINK} --- Remove a file from the file system
11230 @fnindex UNLINK
11231 @cindex file system, remove file
11233 @table @asis
11234 @item @emph{Description}:
11235 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
11236 used to mark the end of the name in @var{PATH}; otherwise, trailing
11237 blanks in the file name are ignored.  If the @var{STATUS} argument is
11238 supplied, it contains 0 on success or a nonzero error code upon return;
11239 see @code{unlink(2)}.
11241 This intrinsic is provided in both subroutine and function forms;
11242 however, only one form can be used in any given program unit.
11244 @item @emph{Standard}:
11245 GNU extension
11247 @item @emph{Class}:
11248 Subroutine, function
11250 @item @emph{Syntax}:
11251 @multitable @columnfractions .80
11252 @item @code{CALL UNLINK(PATH [, STATUS])}
11253 @item @code{STATUS = UNLINK(PATH)}
11254 @end multitable
11256 @item @emph{Arguments}:
11257 @multitable @columnfractions .15 .70
11258 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
11259 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
11260 @end multitable
11262 @item @emph{See also}:
11263 @ref{LINK}, @ref{SYMLNK}
11264 @end table
11268 @node UNPACK
11269 @section @code{UNPACK} --- Unpack an array of rank one into an array
11270 @fnindex UNPACK
11271 @cindex array, unpacking
11272 @cindex array, increase dimension
11273 @cindex array, scatter elements
11275 @table @asis
11276 @item @emph{Description}:
11277 Store the elements of @var{VECTOR} in an array of higher rank.
11279 @item @emph{Standard}:
11280 Fortran 95 and later
11282 @item @emph{Class}:
11283 Transformational function
11285 @item @emph{Syntax}:
11286 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
11288 @item @emph{Arguments}:
11289 @multitable @columnfractions .15 .70
11290 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It 
11291 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
11292 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL}.
11293 @item @var{FIELD}  @tab Shall be of the same type as @var{VECTOR} and have
11294 the same shape as @var{MASK}.
11295 @end multitable
11297 @item @emph{Return value}:
11298 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
11299 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
11301 @item @emph{Example}:
11302 @smallexample
11303 PROGRAM test_unpack
11304   integer :: vector(2)  = (/1,1/)
11305   logical :: mask(4)  = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
11306   integer :: field(2,2) = 0, unity(2,2)
11308   ! result: unity matrix
11309   unity = unpack(vector, reshape(mask, (/2,2/)), field)
11310 END PROGRAM
11311 @end smallexample
11313 @item @emph{See also}:
11314 @ref{PACK}, @ref{SPREAD}
11315 @end table
11319 @node VERIFY
11320 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
11321 @fnindex VERIFY
11322 @cindex string, find missing set
11324 @table @asis
11325 @item @emph{Description}:
11326 Verifies that all the characters in a @var{SET} are present in a @var{STRING}.
11328 If @var{BACK} is either absent or equals @code{FALSE}, this function
11329 returns the position of the leftmost character of @var{STRING} that is
11330 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
11331 is returned. If all characters of @var{SET} are found in @var{STRING}, the 
11332 result is zero.
11334 @item @emph{Standard}:
11335 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
11337 @item @emph{Class}:
11338 Elemental function
11340 @item @emph{Syntax}:
11341 @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
11343 @item @emph{Arguments}:
11344 @multitable @columnfractions .15 .70
11345 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
11346 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
11347 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
11348 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
11349 expression indicating the kind parameter of the result.
11350 @end multitable
11352 @item @emph{Return value}:
11353 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11354 @var{KIND} is absent, the return value is of default integer kind.
11356 @item @emph{Example}:
11357 @smallexample
11358 PROGRAM test_verify
11359   WRITE(*,*) VERIFY("FORTRAN", "AO")           ! 1, found 'F'
11360   WRITE(*,*) VERIFY("FORTRAN", "FOO")          ! 3, found 'R'
11361   WRITE(*,*) VERIFY("FORTRAN", "C++")          ! 1, found 'F'
11362   WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.)  ! 7, found 'N'
11363   WRITE(*,*) VERIFY("FORTRAN", "FORTRAN")      ! 0' found none
11364 END PROGRAM
11365 @end smallexample
11367 @item @emph{See also}:
11368 @ref{SCAN}, @ref{INDEX intrinsic}
11369 @end table
11373 @node XOR
11374 @section @code{XOR} --- Bitwise logical exclusive OR
11375 @fnindex XOR
11376 @cindex bitwise logical exclusive or
11377 @cindex logical exclusive or, bitwise
11379 @table @asis
11380 @item @emph{Description}:
11381 Bitwise logical exclusive or. 
11383 This intrinsic routine is provided for backwards compatibility with 
11384 GNU Fortran 77.  For integer arguments, programmers should consider
11385 the use of the @ref{IEOR} intrinsic and for logical arguments the
11386 @code{.NEQV.} operator, which are both defined by the Fortran standard.
11388 @item @emph{Standard}:
11389 GNU extension
11391 @item @emph{Class}:
11392 Function
11394 @item @emph{Syntax}:
11395 @code{RESULT = XOR(I, J)}
11397 @item @emph{Arguments}:
11398 @multitable @columnfractions .15 .70
11399 @item @var{I} @tab The type shall be either  a scalar @code{INTEGER}
11400 type or a scalar @code{LOGICAL} type.
11401 @item @var{J} @tab The type shall be the same as the type of @var{I}.
11402 @end multitable
11404 @item @emph{Return value}:
11405 The return type is either a scalar @code{INTEGER} or a scalar
11406 @code{LOGICAL}.  If the kind type parameters differ, then the
11407 smaller kind type is implicitly converted to larger kind, and the 
11408 return has the larger kind.
11410 @item @emph{Example}:
11411 @smallexample
11412 PROGRAM test_xor
11413   LOGICAL :: T = .TRUE., F = .FALSE.
11414   INTEGER :: a, b
11415   DATA a / Z'F' /, b / Z'3' /
11417   WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
11418   WRITE (*,*) XOR(a, b)
11419 END PROGRAM
11420 @end smallexample
11422 @item @emph{See also}:
11423 Fortran 95 elemental function: @ref{IEOR}
11424 @end table
11428 @node Intrinsic Modules
11429 @chapter Intrinsic Modules
11430 @cindex intrinsic Modules
11432 @menu
11433 * ISO_FORTRAN_ENV::
11434 * ISO_C_BINDING::
11435 * OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
11436 @end menu
11438 @node ISO_FORTRAN_ENV
11439 @section @code{ISO_FORTRAN_ENV}
11440 @table @asis
11441 @item @emph{Standard}:
11442 Fortran 2003 and later, except when otherwise noted
11443 @end table
11445 The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
11446 named constants:
11448 @table @asis
11449 @item @code{ATOMIC_INT_KIND}:
11450 Default-kind integer constant to be used as kind parameter when defining
11451 integer variables used in atomic operations. (Fortran 2008 or later.)
11453 @item @code{ATOMIC_LOGICAL_KIND}:
11454 Default-kind integer constant to be used as kind parameter when defining
11455 logical variables used in atomic operations. (Fortran 2008 or later.)
11457 @item @code{CHARACTER_STORAGE_SIZE}:
11458 Size in bits of the character storage unit.
11460 @item @code{ERROR_UNIT}:
11461 Identifies the preconnected unit used for error reporting.
11463 @item @code{FILE_STORAGE_SIZE}:
11464 Size in bits of the file-storage unit.
11466 @item @code{INPUT_UNIT}:
11467 Identifies the preconnected unit identified by the asterisk
11468 (@code{*}) in @code{READ} statement.
11470 @item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}:
11471 Kind type parameters to specify an INTEGER type with a storage
11472 size of 16, 32, and 64 bits. It is negative if a target platform
11473 does not support the particular kind. (Fortran 2008 or later.)
11475 @item @code{IOSTAT_END}:
11476 The value assigned to the variable passed to the IOSTAT= specifier of
11477 an input/output statement if an end-of-file condition occurred.
11479 @item @code{IOSTAT_EOR}:
11480 The value assigned to the variable passed to the IOSTAT= specifier of
11481 an input/output statement if an end-of-record condition occurred.
11483 @item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}:
11484 Scalar default-integer constant, used by @code{INQUIRE} for the
11485 IOSTAT= specifier to denote an that a unit number identifies an
11486 internal unit. (Fortran 2008 or later.)
11488 @item @code{NUMERIC_STORAGE_SIZE}:
11489 The size in bits of the numeric storage unit.
11491 @item @code{OUTPUT_UNIT}:
11492 Identifies the preconnected unit identified by the asterisk
11493 (@code{*}) in @code{WRITE} statement.
11495 @item @code{REAL32}, @code{REAL64}, @code{REAL128}:
11496 Kind type parameters to specify a REAL type with a storage
11497 size of 32, 64, and 128 bits. It is negative if a target platform
11498 does not support the particular kind. (Fortran 2008 or later.)
11500 @item @code{STAT_LOCKED}:
11501 Scalar default-integer constant used as STAT= return value by @code{LOCK} to
11502 denote that the lock variable is locked by the executing image. (Fortran 2008
11503 or later.)
11505 @item @code{STAT_LOCKED_OTHER_IMAGE}:
11506 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
11507 denote that the lock variable is locked by another image. (Fortran 2008 or
11508 later.)
11510 @item @code{STAT_STOPPED_IMAGE}:
11511 Positive, scalar default-integer constant used as STAT= return value if the
11512 argument in the statement requires synchronisation with an image, which has
11513 initiated the termination of the execution. (Fortran 2008 or later.)
11515 @item @code{STAT_UNLOCKED}:
11516 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
11517 denote that the lock variable is unlocked. (Fortran 2008 or later.)
11518 @end table
11522 @node ISO_C_BINDING
11523 @section @code{ISO_C_BINDING}
11524 @table @asis
11525 @item @emph{Standard}:
11526 Fortran 2003 and later, GNU extensions
11527 @end table
11529 The following intrinsic procedures are provided by the module; their
11530 definition can be found in the section Intrinsic Procedures of this
11531 manual.
11533 @table @asis
11534 @item @code{C_ASSOCIATED}
11535 @item @code{C_F_POINTER}
11536 @item @code{C_F_PROCPOINTER}
11537 @item @code{C_FUNLOC}
11538 @item @code{C_LOC}
11539 @end table
11540 @c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
11541 @c don't really know why.
11543 The @code{ISO_C_BINDING} module provides the following named constants of
11544 type default integer, which can be used as KIND type parameters.
11546 In addition to the integer named constants required by the Fortran 2003 
11547 standard, GNU Fortran provides as an extension named constants for the 
11548 128-bit integer types supported by the C compiler: @code{C_INT128_T, 
11549 C_INT_LEAST128_T, C_INT_FAST128_T}.
11551 @multitable @columnfractions .15 .35 .35 .35
11552 @item Fortran Type  @tab Named constant         @tab C type                                @tab Extension
11553 @item @code{INTEGER}@tab @code{C_INT}           @tab @code{int}
11554 @item @code{INTEGER}@tab @code{C_SHORT}         @tab @code{short int}
11555 @item @code{INTEGER}@tab @code{C_LONG}          @tab @code{long int}
11556 @item @code{INTEGER}@tab @code{C_LONG_LONG}     @tab @code{long long int}
11557 @item @code{INTEGER}@tab @code{C_SIGNED_CHAR}   @tab @code{signed char}/@code{unsigned char}
11558 @item @code{INTEGER}@tab @code{C_SIZE_T}        @tab @code{size_t}
11559 @item @code{INTEGER}@tab @code{C_INT8_T}        @tab @code{int8_t}
11560 @item @code{INTEGER}@tab @code{C_INT16_T}       @tab @code{int16_t}
11561 @item @code{INTEGER}@tab @code{C_INT32_T}       @tab @code{int32_t}
11562 @item @code{INTEGER}@tab @code{C_INT64_T}       @tab @code{int64_t}
11563 @item @code{INTEGER}@tab @code{C_INT128_T}      @tab @code{int128_t}                      @tab Ext.
11564 @item @code{INTEGER}@tab @code{C_INT_LEAST8_T}  @tab @code{int_least8_t}
11565 @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
11566 @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
11567 @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
11568 @item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t}                @tab Ext.
11569 @item @code{INTEGER}@tab @code{C_INT_FAST8_T}   @tab @code{int_fast8_t}
11570 @item @code{INTEGER}@tab @code{C_INT_FAST16_T}  @tab @code{int_fast16_t}
11571 @item @code{INTEGER}@tab @code{C_INT_FAST32_T}  @tab @code{int_fast32_t}
11572 @item @code{INTEGER}@tab @code{C_INT_FAST64_T}  @tab @code{int_fast64_t}
11573 @item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t}                 @tab Ext.
11574 @item @code{INTEGER}@tab @code{C_INTMAX_T}      @tab @code{intmax_t}
11575 @item @code{INTEGER}@tab @code{C_INTPTR_T}      @tab @code{intptr_t}
11576 @item @code{REAL}   @tab @code{C_FLOAT}         @tab @code{float}
11577 @item @code{REAL}   @tab @code{C_DOUBLE}        @tab @code{double}
11578 @item @code{REAL}   @tab @code{C_LONG_DOUBLE}   @tab @code{long double}
11579 @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
11580 @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
11581 @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
11582 @item @code{LOGICAL}@tab @code{C_BOOL}          @tab @code{_Bool}
11583 @item @code{CHARACTER}@tab @code{C_CHAR}        @tab @code{char}
11584 @end multitable
11586 Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)}
11587 are defined.
11589 @multitable @columnfractions .20 .45 .15
11590 @item Name                     @tab C definition    @tab Value
11591 @item @code{C_NULL_CHAR}       @tab null character  @tab @code{'\0'}
11592 @item @code{C_ALERT}           @tab alert           @tab @code{'\a'}
11593 @item @code{C_BACKSPACE}       @tab backspace       @tab @code{'\b'}
11594 @item @code{C_FORM_FEED}       @tab form feed       @tab @code{'\f'}
11595 @item @code{C_NEW_LINE}        @tab new line        @tab @code{'\n'}
11596 @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
11597 @item @code{C_HORIZONTAL_TAB}  @tab horizontal tab  @tab @code{'\t'}
11598 @item @code{C_VERTICAL_TAB}    @tab vertical tab    @tab @code{'\v'}
11599 @end multitable
11601 @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
11602 @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
11603 @table @asis
11604 @item @emph{Standard}:
11605 OpenMP Application Program Interface v3.0
11606 @end table
11609 The OpenMP Fortran runtime library routines are provided both in
11610 a form of two Fortran 90 modules, named @code{OMP_LIB} and 
11611 @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
11612 @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
11613 in the @ref{Top,,Introduction,libgomp,GNU OpenMP runtime library} manual,
11614 the named constants defined in the @code{OMP_LIB_KINDS} module are listed
11615 below.
11617 For details refer to the actual
11618 @uref{http://www.openmp.org/mp-documents/spec30.pdf,
11619 OpenMP Application Program Interface v3.0}.
11621 @code{OMP_LIB_KINDS} provides the following scalar default-integer
11622 named constants:
11624 @table @asis
11625 @item @code{omp_integer_kind}
11626 @item @code{omp_logical_kind}
11627 @item @code{omp_lock_kind}
11628 @item @code{omp_nest_lock_kind}
11629 @item @code{omp_sched_kind}
11630 @end table