OSDN Git Service

ee358501bed8629052f9e051bcb672a99dec180f
[pf3gnuchains/gcc-fork.git] / gcc / fortran / intrinsic.texi
1 @ignore
2 Copyright (C) 2005, 2006, 2007, 2008
3 Free Software Foundation, Inc.
4 This is part of the GNU Fortran manual.   
5 For copying conditions, see the file gfortran.texi.
6
7 Permission is granted to copy, distribute and/or modify this document
8 under the terms of the GNU Free Documentation License, Version 1.2 or
9 any later version published by the Free Software Foundation; with the
10 Invariant Sections being ``GNU General Public License'' and ``Funding
11 Free Software'', the Front-Cover texts being (a) (see below), and with
12 the Back-Cover Texts being (b) (see below).  A copy of the license is
13 included in the gfdl(7) man page.
14
15
16 Some basic guidelines for editing this document:
17
18   (1) The intrinsic procedures are to be listed in alphabetical order.
19   (2) The generic name is to be used.
20   (3) The specific names are included in the function index and in a
21       table at the end of the node (See ABS entry).
22   (4) Try to maintain the same style for each entry.
23
24
25 @end ignore
26
27 @tex
28 \gdef\acos{\mathop{\rm acos}\nolimits}
29 \gdef\asin{\mathop{\rm asin}\nolimits}
30 \gdef\atan{\mathop{\rm atan}\nolimits}
31 \gdef\acosh{\mathop{\rm acosh}\nolimits}
32 \gdef\asinh{\mathop{\rm asinh}\nolimits}
33 \gdef\atanh{\mathop{\rm atanh}\nolimits}
34 @end tex
35
36
37 @node Intrinsic Procedures
38 @chapter Intrinsic Procedures
39 @cindex intrinsic procedures
40
41 @menu
42 * Introduction:         Introduction to Intrinsics
43 * @code{ABORT}:         ABORT,     Abort the program     
44 * @code{ABS}:           ABS,       Absolute value     
45 * @code{ACCESS}:        ACCESS,    Checks file access modes
46 * @code{ACHAR}:         ACHAR,     Character in @acronym{ASCII} collating sequence
47 * @code{ACOS}:          ACOS,      Arccosine function
48 * @code{ACOSH}:         ACOSH,     Hyperbolic arccosine function
49 * @code{ADJUSTL}:       ADJUSTL,   Left adjust a string
50 * @code{ADJUSTR}:       ADJUSTR,   Right adjust a string
51 * @code{AIMAG}:         AIMAG,     Imaginary part of complex number
52 * @code{AINT}:          AINT,      Truncate to a whole number
53 * @code{ALARM}:         ALARM,     Set an alarm clock
54 * @code{ALL}:           ALL,       Determine if all values are true
55 * @code{ALLOCATED}:     ALLOCATED, Status of allocatable entity
56 * @code{AND}:           AND,       Bitwise logical AND
57 * @code{ANINT}:         ANINT,     Nearest whole number
58 * @code{ANY}:           ANY,       Determine if any values are true
59 * @code{ASIN}:          ASIN,      Arcsine function
60 * @code{ASINH}:         ASINH,     Hyperbolic arcsine function
61 * @code{ASSOCIATED}:    ASSOCIATED, Status of a pointer or pointer/target pair
62 * @code{ATAN}:          ATAN,      Arctangent function
63 * @code{ATAN2}:         ATAN2,     Arctangent function
64 * @code{ATANH}:         ATANH,     Hyperbolic arctangent function
65 * @code{BESSEL_J0}:     BESSEL_J0, Bessel function of the first kind of order 0
66 * @code{BESSEL_J1}:     BESSEL_J1, Bessel function of the first kind of order 1
67 * @code{BESSEL_JN}:     BESSEL_JN, Bessel function of the first kind
68 * @code{BESSEL_Y0}:     BESSEL_Y0, Bessel function of the second kind of order 0
69 * @code{BESSEL_Y1}:     BESSEL_Y1, Bessel function of the second kind of order 1
70 * @code{BESSEL_YN}:     BESSEL_YN, Bessel function of the second kind
71 * @code{BIT_SIZE}:      BIT_SIZE,  Bit size inquiry function
72 * @code{BTEST}:         BTEST,     Bit test function
73 * @code{C_ASSOCIATED}:  C_ASSOCIATED, Status of a C pointer
74 * @code{C_F_POINTER}:   C_F_POINTER, Convert C into Fortran pointer
75 * @code{C_F_PROCPOINTER}: C_F_PROCPOINTER, Convert C into Fortran procedure pointer
76 * @code{C_FUNLOC}:      C_FUNLOC,  Obtain the C address of a procedure
77 * @code{C_LOC}:         C_LOC,     Obtain the C address of an object
78 * @code{C_SIZEOF}:      C_SIZEOF,  Size in bytes of an expression
79 * @code{CEILING}:       CEILING,   Integer ceiling function
80 * @code{CHAR}:          CHAR,      Integer-to-character conversion function
81 * @code{CHDIR}:         CHDIR,     Change working directory
82 * @code{CHMOD}:         CHMOD,     Change access permissions of files
83 * @code{CMPLX}:         CMPLX,     Complex conversion function
84 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
85 * @code{COMPLEX}:       COMPLEX,   Complex conversion function
86 * @code{CONJG}:         CONJG,     Complex conjugate function
87 * @code{COS}:           COS,       Cosine function
88 * @code{COSH}:          COSH,      Hyperbolic cosine function
89 * @code{COUNT}:         COUNT,     Count occurrences of TRUE in an array
90 * @code{CPU_TIME}:      CPU_TIME,  CPU time subroutine
91 * @code{CSHIFT}:        CSHIFT,    Circular shift elements of an array
92 * @code{CTIME}:         CTIME,     Subroutine (or function) to convert a time into a string
93 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
94 * @code{DBLE}:          DBLE,      Double precision conversion function
95 * @code{DCMPLX}:        DCMPLX,    Double complex conversion function
96 * @code{DFLOAT}:        DFLOAT,    Double precision conversion function
97 * @code{DIGITS}:        DIGITS,    Significant digits function
98 * @code{DIM}:           DIM,       Positive difference
99 * @code{DOT_PRODUCT}:   DOT_PRODUCT, Dot product function
100 * @code{DPROD}:         DPROD,     Double product function
101 * @code{DREAL}:         DREAL,     Double real part function
102 * @code{DTIME}:         DTIME,     Execution time subroutine (or function)
103 * @code{EOSHIFT}:       EOSHIFT,   End-off shift elements of an array
104 * @code{EPSILON}:       EPSILON,   Epsilon function
105 * @code{ERF}:           ERF,       Error function
106 * @code{ERFC}:          ERFC,      Complementary error function
107 * @code{ERFC_SCALED}:   ERFC_SCALED, Exponentially-scaled complementary error function
108 * @code{ETIME}:         ETIME,     Execution time subroutine (or function)
109 * @code{EXIT}:          EXIT,      Exit the program with status.
110 * @code{EXP}:           EXP,       Exponential function
111 * @code{EXPONENT}:      EXPONENT,  Exponent function
112 * @code{FDATE}:         FDATE,     Subroutine (or function) to get the current time as a string
113 * @code{FGET}:          FGET,      Read a single character in stream mode from stdin
114 * @code{FGETC}:         FGETC,     Read a single character in stream mode
115 * @code{FLOAT}:         FLOAT,     Convert integer to default real
116 * @code{FLOOR}:         FLOOR,     Integer floor function
117 * @code{FLUSH}:         FLUSH,     Flush I/O unit(s)
118 * @code{FNUM}:          FNUM,      File number function
119 * @code{FPUT}:          FPUT,      Write a single character in stream mode to stdout
120 * @code{FPUTC}:         FPUTC,     Write a single character in stream mode
121 * @code{FRACTION}:      FRACTION,  Fractional part of the model representation
122 * @code{FREE}:          FREE,      Memory de-allocation subroutine
123 * @code{FSEEK}:         FSEEK,     Low level file positioning subroutine
124 * @code{FSTAT}:         FSTAT,     Get file status
125 * @code{FTELL}:         FTELL,     Current stream position
126 * @code{GAMMA}:         GAMMA,     Gamma function
127 * @code{GERROR}:        GERROR,    Get last system error message
128 * @code{GETARG}:        GETARG,    Get command line arguments
129 * @code{GET_COMMAND}:   GET_COMMAND, Get the entire command line
130 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
131 * @code{GETCWD}:        GETCWD,    Get current working directory
132 * @code{GETENV}:        GETENV,    Get an environmental variable
133 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
134 * @code{GETGID}:        GETGID,    Group ID function
135 * @code{GETLOG}:        GETLOG,    Get login name
136 * @code{GETPID}:        GETPID,    Process ID function
137 * @code{GETUID}:        GETUID,    User ID function
138 * @code{GMTIME}:        GMTIME,    Convert time to GMT info
139 * @code{HOSTNM}:        HOSTNM,    Get system host name
140 * @code{HUGE}:          HUGE,      Largest number of a kind
141 * @code{HYPOT}:         HYPOT,     Euclidian distance function
142 * @code{IACHAR}:        IACHAR,    Code in @acronym{ASCII} collating sequence
143 * @code{IAND}:          IAND,      Bitwise logical and
144 * @code{IARGC}:         IARGC,     Get the number of command line arguments
145 * @code{IBCLR}:         IBCLR,     Clear bit
146 * @code{IBITS}:         IBITS,     Bit extraction
147 * @code{IBSET}:         IBSET,     Set bit
148 * @code{ICHAR}:         ICHAR,     Character-to-integer conversion function
149 * @code{IDATE}:         IDATE,     Current local time (day/month/year)
150 * @code{IEOR}:          IEOR,      Bitwise logical exclusive or
151 * @code{IERRNO}:        IERRNO,    Function to get the last system error number
152 * @code{INDEX}:         INDEX intrinsic, Position of a substring within a string
153 * @code{INT}:           INT,       Convert to integer type
154 * @code{INT2}:          INT2,      Convert to 16-bit integer type
155 * @code{INT8}:          INT8,      Convert to 64-bit integer type
156 * @code{IOR}:           IOR,       Bitwise logical or
157 * @code{IRAND}:         IRAND,     Integer pseudo-random number
158 * @code{IS_IOSTAT_END}:  IS_IOSTAT_END, Test for end-of-file value
159 * @code{IS_IOSTAT_EOR}:  IS_IOSTAT_EOR, Test for end-of-record value
160 * @code{ISATTY}:        ISATTY,    Whether a unit is a terminal device
161 * @code{ISHFT}:         ISHFT,     Shift bits
162 * @code{ISHFTC}:        ISHFTC,    Shift bits circularly
163 * @code{ISNAN}:         ISNAN,     Tests for a NaN
164 * @code{ITIME}:         ITIME,     Current local time (hour/minutes/seconds)
165 * @code{KILL}:          KILL,      Send a signal to a process
166 * @code{KIND}:          KIND,      Kind of an entity
167 * @code{LBOUND}:        LBOUND,    Lower dimension bounds of an array
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{LOG_GAMMA}:     LOG_GAMMA, Logarithm of the Gamma function
171 * @code{LGE}:           LGE,       Lexical greater than or equal
172 * @code{LGT}:           LGT,       Lexical greater than
173 * @code{LINK}:          LINK,      Create a hard link
174 * @code{LLE}:           LLE,       Lexical less than or equal
175 * @code{LLT}:           LLT,       Lexical less than
176 * @code{LNBLNK}:        LNBLNK,    Index of the last non-blank character in a string
177 * @code{LOC}:           LOC,       Returns the address of a variable
178 * @code{LOG}:           LOG,       Logarithm function
179 * @code{LOG10}:         LOG10,     Base 10 logarithm 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{OR}:            OR,        Bitwise logical OR
208 * @code{PACK}:          PACK,      Pack an array into an array of rank one
209 * @code{PERROR}:        PERROR,    Print system error message
210 * @code{PRECISION}:     PRECISION, Decimal precision of a real kind
211 * @code{PRESENT}:       PRESENT,   Determine whether an optional dummy argument is specified
212 * @code{PRODUCT}:       PRODUCT,   Product of array elements
213 * @code{RADIX}:         RADIX,     Base of a data model
214 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
215 * @code{RANDOM_SEED}:   RANDOM_SEED, Initialize a pseudo-random number sequence
216 * @code{RAND}:          RAND,      Real pseudo-random number
217 * @code{RANGE}:         RANGE,     Decimal exponent range of a real kind
218 * @code{RAN}:           RAN,       Real pseudo-random number
219 * @code{REAL}:          REAL,      Convert to real type 
220 * @code{RENAME}:        RENAME,    Rename a file
221 * @code{REPEAT}:        REPEAT,    Repeated string concatenation
222 * @code{RESHAPE}:       RESHAPE,   Function to reshape an array
223 * @code{RRSPACING}:     RRSPACING, Reciprocal of the relative spacing
224 * @code{RSHIFT}:        RSHIFT,    Right shift bits
225 * @code{SCALE}:         SCALE,     Scale a real value
226 * @code{SCAN}:          SCAN,      Scan a string for the presence of a set of characters
227 * @code{SECNDS}:        SECNDS,    Time function
228 * @code{SECOND}:        SECOND,    CPU time function
229 * @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND,  Choose character kind
230 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND,  Choose integer kind
231 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND,  Choose real kind
232 * @code{SET_EXPONENT}:  SET_EXPONENT, Set the exponent of the model
233 * @code{SHAPE}:         SHAPE,     Determine the shape of an array
234 * @code{SIGN}:          SIGN,      Sign copying function
235 * @code{SIGNAL}:        SIGNAL,    Signal handling subroutine (or function)
236 * @code{SIN}:           SIN,       Sine function
237 * @code{SINH}:          SINH,      Hyperbolic sine function
238 * @code{SIZE}:          SIZE,      Function to determine the size of an array
239 * @code{SIZEOF}:        SIZEOF,    Determine the size in bytes of an expression
240 * @code{SLEEP}:         SLEEP,     Sleep for the specified number of seconds
241 * @code{SNGL}:          SNGL,      Convert double precision real to default real
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{TIME}:          TIME,      Time function
254 * @code{TIME8}:         TIME8,     Time function (64-bit)
255 * @code{TINY}:          TINY,      Smallest positive number of a real kind
256 * @code{TRANSFER}:      TRANSFER,  Transfer bit patterns
257 * @code{TRANSPOSE}:     TRANSPOSE, Transpose an array of rank two
258 * @code{TRIM}:          TRIM,      Remove trailing blank characters of a string
259 * @code{TTYNAM}:        TTYNAM,    Get the name of a terminal device.
260 * @code{UBOUND}:        UBOUND,    Upper dimension bounds of an array
261 * @code{UMASK}:         UMASK,     Set the file creation mask
262 * @code{UNLINK}:        UNLINK,    Remove a file from the file system
263 * @code{UNPACK}:        UNPACK,    Unpack an array of rank one into an array
264 * @code{VERIFY}:        VERIFY,    Scan a string for the absence of a set of characters
265 * @code{XOR}:           XOR,       Bitwise logical exclusive or
266 @end menu
267
268 @node Introduction to Intrinsics
269 @section Introduction to intrinsic procedures
270
271 The intrinsic procedures provided by GNU Fortran include all of the
272 intrinsic procedures required by the Fortran 95 standard, a set of
273 intrinsic procedures for backwards compatibility with G77, and a
274 selection of intrinsic procedures from the Fortran 2003 and Fortran 2008
275 standards.  Any conflict between a description here and a description in
276 either the Fortran 95 standard, the Fortran 2003 standard or the Fortran
277 2008 standard is unintentional, and the standard(s) should be considered
278 authoritative.
279
280 The enumeration of the @code{KIND} type parameter is processor defined in
281 the Fortran 95 standard.  GNU Fortran defines the default integer type and
282 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
283 respectively.  The standard mandates that both data types shall have
284 another kind, which have more precision.  On typical target architectures
285 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
286 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
287 In the description of generic intrinsic procedures, the kind type parameter
288 will be specified by @code{KIND=*}, and in the description of specific
289 names for an intrinsic procedure the kind type parameter will be explicitly
290 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}).  Finally, for
291 brevity the optional @code{KIND=} syntax will be omitted.
292
293 Many of the intrinsic procedures take one or more optional arguments.
294 This document follows the convention used in the Fortran 95 standard,
295 and denotes such arguments by square brackets.
296
297 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
298 which can be used to restrict the set of intrinsic procedures to a 
299 given standard.  By default, @command{gfortran} sets the @option{-std=gnu}
300 option, and so all intrinsic procedures described here are accepted.  There
301 is one caveat.  For a select group of intrinsic procedures, @command{g77}
302 implemented both a function and a subroutine.  Both classes 
303 have been implemented in @command{gfortran} for backwards compatibility
304 with @command{g77}.  It is noted here that these functions and subroutines
305 cannot be intermixed in a given subprogram.  In the descriptions that follow,
306 the applicable standard for each intrinsic procedure is noted.
307
308
309
310 @node ABORT
311 @section @code{ABORT} --- Abort the program
312 @fnindex ABORT
313 @cindex program termination, with core dump
314 @cindex terminate program, with core dump
315 @cindex core, dump
316
317 @table @asis
318 @item @emph{Description}:
319 @code{ABORT} causes immediate termination of the program.  On operating
320 systems that support a core dump, @code{ABORT} will produce a core dump,
321 which is suitable for debugging purposes.
322
323 @item @emph{Standard}:
324 GNU extension
325
326 @item @emph{Class}:
327 Subroutine
328
329 @item @emph{Syntax}:
330 @code{CALL ABORT}
331
332 @item @emph{Return value}:
333 Does not return.
334
335 @item @emph{Example}:
336 @smallexample
337 program test_abort
338   integer :: i = 1, j = 2
339   if (i /= j) call abort
340 end program test_abort
341 @end smallexample
342
343 @item @emph{See also}:
344 @ref{EXIT}, @ref{KILL}
345
346 @end table
347
348
349
350 @node ABS
351 @section @code{ABS} --- Absolute value
352 @fnindex ABS
353 @fnindex CABS
354 @fnindex DABS
355 @fnindex IABS
356 @fnindex ZABS
357 @fnindex CDABS
358 @cindex absolute value
359
360 @table @asis
361 @item @emph{Description}:
362 @code{ABS(A)} computes the absolute value of @code{A}.
363
364 @item @emph{Standard}:
365 Fortran 77 and later, has overloads that are GNU extensions
366
367 @item @emph{Class}:
368 Elemental function
369
370 @item @emph{Syntax}:
371 @code{RESULT = ABS(A)}
372
373 @item @emph{Arguments}:
374 @multitable @columnfractions .15 .70
375 @item @var{A} @tab The type of the argument shall be an @code{INTEGER},
376 @code{REAL}, or @code{COMPLEX}.
377 @end multitable
378
379 @item @emph{Return value}:
380 The return value is of the same type and
381 kind as the argument except the return value is @code{REAL} for a
382 @code{COMPLEX} argument.
383
384 @item @emph{Example}:
385 @smallexample
386 program test_abs
387   integer :: i = -1
388   real :: x = -1.e0
389   complex :: z = (-1.e0,0.e0)
390   i = abs(i)
391   x = abs(x)
392   x = abs(z)
393 end program test_abs
394 @end smallexample
395
396 @item @emph{Specific names}:
397 @multitable @columnfractions .20 .20 .20 .25
398 @item Name            @tab Argument            @tab Return type       @tab Standard
399 @item @code{CABS(A)}  @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)}    @tab Fortran 77 and later
400 @item @code{DABS(A)}  @tab @code{REAL(8)    X} @tab @code{REAL(8)}    @tab Fortran 77 and later
401 @item @code{IABS(A)}  @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab Fortran 77 and later
402 @item @code{ZABS(A)}  @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
403 @item @code{CDABS(A)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
404 @end multitable
405 @end table
406
407
408
409 @node ACCESS
410 @section @code{ACCESS} --- Checks file access modes
411 @fnindex ACCESS
412 @cindex file system, access mode
413
414 @table @asis
415 @item @emph{Description}:
416 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME} 
417 exists, is readable, writable or executable. Except for the
418 executable check, @code{ACCESS} can be replaced by
419 Fortran 95's @code{INQUIRE}.
420
421 @item @emph{Standard}:
422 GNU extension
423
424 @item @emph{Class}:
425 Inquiry function
426
427 @item @emph{Syntax}:
428 @code{RESULT = ACCESS(NAME, MODE)}
429
430 @item @emph{Arguments}:
431 @multitable @columnfractions .15 .70
432 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
433 file name. Tailing blank are ignored unless the character @code{achar(0)}
434 is present, then all characters up to and excluding @code{achar(0)} are
435 used as file name.
436 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the
437 file access mode, may be any concatenation of @code{"r"} (readable),
438 @code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check
439 for existence.
440 @end multitable
441
442 @item @emph{Return value}:
443 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
444 accessible in the given mode; otherwise or if an invalid argument
445 has been given for @code{MODE} the value @code{1} is returned.
446
447 @item @emph{Example}:
448 @smallexample
449 program access_test
450   implicit none
451   character(len=*), parameter :: file  = 'test.dat'
452   character(len=*), parameter :: file2 = 'test.dat  '//achar(0)
453   if(access(file,' ') == 0) print *, trim(file),' is exists'
454   if(access(file,'r') == 0) print *, trim(file),' is readable'
455   if(access(file,'w') == 0) print *, trim(file),' is writable'
456   if(access(file,'x') == 0) print *, trim(file),' is executable'
457   if(access(file2,'rwx') == 0) &
458     print *, trim(file2),' is readable, writable and executable'
459 end program access_test
460 @end smallexample
461 @item @emph{Specific names}:
462 @item @emph{See also}:
463
464 @end table
465
466
467
468 @node ACHAR
469 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence 
470 @fnindex ACHAR
471 @cindex @acronym{ASCII} collating sequence
472 @cindex collating sequence, @acronym{ASCII}
473
474 @table @asis
475 @item @emph{Description}:
476 @code{ACHAR(I)} returns the character located at position @code{I}
477 in the @acronym{ASCII} collating sequence.
478
479 @item @emph{Standard}:
480 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
481
482 @item @emph{Class}:
483 Elemental function
484
485 @item @emph{Syntax}:
486 @code{RESULT = ACHAR(I [, KIND])}
487
488 @item @emph{Arguments}:
489 @multitable @columnfractions .15 .70
490 @item @var{I}    @tab The type shall be @code{INTEGER}.
491 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
492                       expression indicating the kind parameter of
493                       the result.
494 @end multitable
495
496 @item @emph{Return value}:
497 The return value is of type @code{CHARACTER} with a length of one.
498 If the @var{KIND} argument is present, the return value is of the
499 specified kind and of the default kind otherwise.
500
501 @item @emph{Example}:
502 @smallexample
503 program test_achar
504   character c
505   c = achar(32)
506 end program test_achar
507 @end smallexample
508
509 @item @emph{Note}:
510 See @ref{ICHAR} for a discussion of converting between numerical values
511 and formatted string representations.
512
513 @item @emph{See also}:
514 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
515
516 @end table
517
518
519
520 @node ACOS
521 @section @code{ACOS} --- Arccosine function 
522 @fnindex ACOS
523 @fnindex DACOS
524 @cindex trigonometric function, cosine, inverse
525 @cindex cosine, inverse
526
527 @table @asis
528 @item @emph{Description}:
529 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
530
531 @item @emph{Standard}:
532 Fortran 77 and later
533
534 @item @emph{Class}:
535 Elemental function
536
537 @item @emph{Syntax}:
538 @code{RESULT = ACOS(X)}
539
540 @item @emph{Arguments}:
541 @multitable @columnfractions .15 .70
542 @item @var{X} @tab The type shall be @code{REAL} with a magnitude that is
543 less than one.
544 @end multitable
545
546 @item @emph{Return value}:
547 The return value is of type @code{REAL} and it lies in the
548 range @math{ 0 \leq \acos(x) \leq \pi}. The return value if of the same
549 kind as @var{X}.
550
551 @item @emph{Example}:
552 @smallexample
553 program test_acos
554   real(8) :: x = 0.866_8
555   x = acos(x)
556 end program test_acos
557 @end smallexample
558
559 @item @emph{Specific names}:
560 @multitable @columnfractions .20 .20 .20 .25
561 @item Name            @tab Argument          @tab Return type       @tab Standard
562 @item @code{DACOS(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
563 @end multitable
564
565 @item @emph{See also}:
566 Inverse function: @ref{COS}
567
568 @end table
569
570
571
572 @node ACOSH
573 @section @code{ACOSH} --- Hyperbolic arccosine function
574 @fnindex ACOSH
575 @fnindex DACOSH
576 @cindex area hyperbolic cosine
577 @cindex hyperbolic arccosine
578 @cindex hyperbolic function, cosine, inverse
579 @cindex cosine, hyperbolic, inverse
580
581 @table @asis
582 @item @emph{Description}:
583 @code{ACOSH(X)} computes the hyperbolic arccosine of @var{X} (inverse of
584 @code{COSH(X)}).
585
586 @item @emph{Standard}:
587 Fortran 2008 and later
588
589 @item @emph{Class}:
590 Elemental function
591
592 @item @emph{Syntax}:
593 @code{RESULT = ACOSH(X)}
594
595 @item @emph{Arguments}:
596 @multitable @columnfractions .15 .70
597 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
598 @end multitable
599
600 @item @emph{Return value}:
601 The return value has the same type and kind as @var{X}
602
603 @item @emph{Example}:
604 @smallexample
605 PROGRAM test_acosh
606   REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
607   WRITE (*,*) ACOSH(x)
608 END PROGRAM
609 @end smallexample
610
611 @item @emph{Specific names}:
612 @multitable @columnfractions .20 .20 .20 .25
613 @item Name             @tab Argument          @tab Return type       @tab Standard
614 @item @code{DACOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
615 @end multitable
616
617 @item @emph{See also}:
618 Inverse function: @ref{COSH}
619 @end table
620
621
622
623 @node ADJUSTL
624 @section @code{ADJUSTL} --- Left adjust a string 
625 @fnindex ADJUSTL
626 @cindex string, adjust left
627 @cindex adjust string
628
629 @table @asis
630 @item @emph{Description}:
631 @code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
632 Spaces are inserted at the end of the string as needed.
633
634 @item @emph{Standard}:
635 Fortran 95 and later
636
637 @item @emph{Class}:
638 Elemental function
639
640 @item @emph{Syntax}:
641 @code{RESULT = ADJUSTL(STRING)}
642
643 @item @emph{Arguments}:
644 @multitable @columnfractions .15 .70
645 @item @var{STRING} @tab The type shall be @code{CHARACTER}.
646 @end multitable
647
648 @item @emph{Return value}:
649 The return value is of type @code{CHARACTER} and of the same kind as
650 @var{STRING} where leading spaces are removed and the same number of
651 spaces are inserted on the end of @var{STRING}.
652
653 @item @emph{Example}:
654 @smallexample
655 program test_adjustl
656   character(len=20) :: str = '   gfortran'
657   str = adjustl(str)
658   print *, str
659 end program test_adjustl
660 @end smallexample
661
662 @item @emph{See also}:
663 @ref{ADJUSTR}, @ref{TRIM}
664 @end table
665
666
667
668 @node ADJUSTR
669 @section @code{ADJUSTR} --- Right adjust a string 
670 @fnindex ADJUSTR
671 @cindex string, adjust right
672 @cindex adjust string
673
674 @table @asis
675 @item @emph{Description}:
676 @code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
677 Spaces are inserted at the start of the string as needed.
678
679 @item @emph{Standard}:
680 Fortran 95 and later
681
682 @item @emph{Class}:
683 Elemental function
684
685 @item @emph{Syntax}:
686 @code{RESULT = ADJUSTR(STRING)}
687
688 @item @emph{Arguments}:
689 @multitable @columnfractions .15 .70
690 @item @var{STR} @tab The type shall be @code{CHARACTER}.
691 @end multitable
692
693 @item @emph{Return value}:
694 The return value is of type @code{CHARACTER} and of the same kind as
695 @var{STRING} where trailing spaces are removed and the same number of
696 spaces are inserted at the start of @var{STRING}.
697
698 @item @emph{Example}:
699 @smallexample
700 program test_adjustr
701   character(len=20) :: str = 'gfortran'
702   str = adjustr(str)
703   print *, str
704 end program test_adjustr
705 @end smallexample
706
707 @item @emph{See also}:
708 @ref{ADJUSTL}, @ref{TRIM}
709 @end table
710
711
712
713 @node AIMAG
714 @section @code{AIMAG} --- Imaginary part of complex number  
715 @fnindex AIMAG
716 @fnindex DIMAG
717 @fnindex IMAG
718 @fnindex IMAGPART
719 @cindex complex numbers, imaginary part
720
721 @table @asis
722 @item @emph{Description}:
723 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
724 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
725 for compatibility with @command{g77}, and their use in new code is 
726 strongly discouraged.
727
728 @item @emph{Standard}:
729 Fortran 77 and later, has overloads that are GNU extensions
730
731 @item @emph{Class}:
732 Elemental function
733
734 @item @emph{Syntax}:
735 @code{RESULT = AIMAG(Z)}
736
737 @item @emph{Arguments}:
738 @multitable @columnfractions .15 .70
739 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
740 @end multitable
741
742 @item @emph{Return value}:
743 The return value is of type @code{REAL} with the
744 kind type parameter of the argument.
745
746 @item @emph{Example}:
747 @smallexample
748 program test_aimag
749   complex(4) z4
750   complex(8) z8
751   z4 = cmplx(1.e0_4, 0.e0_4)
752   z8 = cmplx(0.e0_8, 1.e0_8)
753   print *, aimag(z4), dimag(z8)
754 end program test_aimag
755 @end smallexample
756
757 @item @emph{Specific names}:
758 @multitable @columnfractions .20 .20 .20 .25
759 @item Name            @tab Argument            @tab Return type       @tab Standard
760 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)}    @tab GNU extension
761 @item @code{IMAG(Z)}  @tab @code{COMPLEX Z} @tab @code{REAL}    @tab GNU extension
762 @item @code{IMAGPART(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
763 @end multitable
764 @end table
765
766
767
768 @node AINT
769 @section @code{AINT} --- Truncate to a whole number
770 @fnindex AINT
771 @fnindex DINT
772 @cindex floor
773 @cindex rounding, floor
774
775 @table @asis
776 @item @emph{Description}:
777 @code{AINT(A [, KIND])} truncates its argument to a whole number.
778
779 @item @emph{Standard}:
780 Fortran 77 and later
781
782 @item @emph{Class}:
783 Elemental function
784
785 @item @emph{Syntax}:
786 @code{RESULT = AINT(A [, KIND])} 
787
788 @item @emph{Arguments}:
789 @multitable @columnfractions .15 .70
790 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
791 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
792                       expression indicating the kind parameter of
793                       the result.
794 @end multitable
795
796 @item @emph{Return value}:
797 The return value is of type @code{REAL} with the kind type parameter of the
798 argument if the optional @var{KIND} is absent; otherwise, the kind
799 type parameter will be given by @var{KIND}.  If the magnitude of 
800 @var{X} is less than one, @code{AINT(X)} returns zero.  If the
801 magnitude is equal to or greater than one then it returns the largest
802 whole number that does not exceed its magnitude.  The sign is the same
803 as the sign of @var{X}. 
804
805 @item @emph{Example}:
806 @smallexample
807 program test_aint
808   real(4) x4
809   real(8) x8
810   x4 = 1.234E0_4
811   x8 = 4.321_8
812   print *, aint(x4), dint(x8)
813   x8 = aint(x4,8)
814 end program test_aint
815 @end smallexample
816
817 @item @emph{Specific names}:
818 @multitable @columnfractions .20 .20 .20 .25
819 @item Name           @tab Argument         @tab Return type      @tab Standard
820 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}   @tab Fortran 77 and later
821 @end multitable
822 @end table
823
824
825
826 @node ALARM
827 @section @code{ALARM} --- Execute a routine after a given delay
828 @fnindex ALARM
829 @cindex delayed execution
830
831 @table @asis
832 @item @emph{Description}:
833 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
834 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
835 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
836 supplied, it will be returned with the number of seconds remaining until
837 any previously scheduled alarm was due to be delivered, or zero if there
838 was no previously scheduled alarm.
839
840 @item @emph{Standard}:
841 GNU extension
842
843 @item @emph{Class}:
844 Subroutine
845
846 @item @emph{Syntax}:
847 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
848
849 @item @emph{Arguments}:
850 @multitable @columnfractions .15 .70
851 @item @var{SECONDS} @tab The type of the argument shall be a scalar
852 @code{INTEGER}. It is @code{INTENT(IN)}.
853 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
854 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar 
855 values may be either @code{SIG_IGN=1} to ignore the alarm generated 
856 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
857 @item @var{STATUS}  @tab (Optional) @var{STATUS} shall be a scalar
858 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
859 @end multitable
860
861 @item @emph{Example}:
862 @smallexample
863 program test_alarm
864   external handler_print
865   integer i
866   call alarm (3, handler_print, i)
867   print *, i
868   call sleep(10)
869 end program test_alarm
870 @end smallexample
871 This will cause the external routine @var{handler_print} to be called
872 after 3 seconds.
873 @end table
874
875
876
877 @node ALL
878 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true 
879 @fnindex ALL
880 @cindex array, apply condition
881 @cindex array, condition testing
882
883 @table @asis
884 @item @emph{Description}:
885 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
886 in the array along dimension @var{DIM}.
887
888 @item @emph{Standard}:
889 Fortran 95 and later
890
891 @item @emph{Class}:
892 Transformational function
893
894 @item @emph{Syntax}:
895 @code{RESULT = ALL(MASK [, DIM])}
896
897 @item @emph{Arguments}:
898 @multitable @columnfractions .15 .70
899 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
900 it shall not be scalar.
901 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
902 with a value that lies between one and the rank of @var{MASK}.
903 @end multitable
904
905 @item @emph{Return value}:
906 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where
907 the kind type parameter is the same as the kind type parameter of
908 @var{MASK}.  If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
909 an array with the rank of @var{MASK} minus 1.  The shape is determined from
910 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
911
912 @table @asis
913 @item (A)
914 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
915 It also is true if @var{MASK} has zero size; otherwise, it is false.
916 @item (B)
917 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
918 to @code{ALL(MASK)}.  If the rank is greater than one, then @code{ALL(MASK,DIM)}
919 is determined by applying @code{ALL} to the array sections.
920 @end table
921
922 @item @emph{Example}:
923 @smallexample
924 program test_all
925   logical l
926   l = all((/.true., .true., .true./))
927   print *, l
928   call section
929   contains
930     subroutine section
931       integer a(2,3), b(2,3)
932       a = 1
933       b = 1
934       b(2,2) = 2
935       print *, all(a .eq. b, 1)
936       print *, all(a .eq. b, 2)
937     end subroutine section
938 end program test_all
939 @end smallexample
940 @end table
941
942
943
944 @node ALLOCATED
945 @section @code{ALLOCATED} --- Status of an allocatable entity
946 @fnindex ALLOCATED
947 @cindex allocation, status
948
949 @table @asis
950 @item @emph{Description}:
951 @code{ALLOCATED(ARRAY)} checks the status of whether @var{X} is allocated.
952
953 @item @emph{Standard}:
954 Fortran 95 and later
955
956 @item @emph{Class}:
957 Inquiry function
958
959 @item @emph{Syntax}:
960 @code{RESULT = ALLOCATED(ARRAY)}
961
962 @item @emph{Arguments}:
963 @multitable @columnfractions .15 .70
964 @item @var{ARRAY}    @tab The argument shall be an @code{ALLOCATABLE} array.
965 @end multitable
966
967 @item @emph{Return value}:
968 The return value is a scalar @code{LOGICAL} with the default logical
969 kind type parameter.  If @var{ARRAY} is allocated, @code{ALLOCATED(ARRAY)}
970 is @code{.TRUE.}; otherwise, it returns @code{.FALSE.} 
971
972 @item @emph{Example}:
973 @smallexample
974 program test_allocated
975   integer :: i = 4
976   real(4), allocatable :: x(:)
977   if (allocated(x) .eqv. .false.) allocate(x(i))
978 end program test_allocated
979 @end smallexample
980 @end table
981
982
983
984 @node AND
985 @section @code{AND} --- Bitwise logical AND
986 @fnindex AND
987 @cindex bitwise logical and
988 @cindex logical and, bitwise
989
990 @table @asis
991 @item @emph{Description}:
992 Bitwise logical @code{AND}.
993
994 This intrinsic routine is provided for backwards compatibility with 
995 GNU Fortran 77.  For integer arguments, programmers should consider
996 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
997
998 @item @emph{Standard}:
999 GNU extension
1000
1001 @item @emph{Class}:
1002 Function
1003
1004 @item @emph{Syntax}:
1005 @code{RESULT = AND(I, J)}
1006
1007 @item @emph{Arguments}:
1008 @multitable @columnfractions .15 .70
1009 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
1010 type or a scalar @code{LOGICAL} type.
1011 @item @var{J} @tab The type shall be the same as the type of @var{I}.
1012 @end multitable
1013
1014 @item @emph{Return value}:
1015 The return type is either a scalar @code{INTEGER} or a scalar
1016 @code{LOGICAL}.  If the kind type parameters differ, then the
1017 smaller kind type is implicitly converted to larger kind, and the 
1018 return has the larger kind.
1019
1020 @item @emph{Example}:
1021 @smallexample
1022 PROGRAM test_and
1023   LOGICAL :: T = .TRUE., F = .FALSE.
1024   INTEGER :: a, b
1025   DATA a / Z'F' /, b / Z'3' /
1026
1027   WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1028   WRITE (*,*) AND(a, b)
1029 END PROGRAM
1030 @end smallexample
1031
1032 @item @emph{See also}:
1033 Fortran 95 elemental function: @ref{IAND}
1034 @end table
1035
1036
1037
1038 @node ANINT
1039 @section @code{ANINT} --- Nearest whole number
1040 @fnindex ANINT
1041 @fnindex DNINT
1042 @cindex ceiling
1043 @cindex rounding, ceiling
1044
1045 @table @asis
1046 @item @emph{Description}:
1047 @code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1048
1049 @item @emph{Standard}:
1050 Fortran 77 and later
1051
1052 @item @emph{Class}:
1053 Elemental function
1054
1055 @item @emph{Syntax}:
1056 @code{RESULT = ANINT(A [, KIND])}
1057
1058 @item @emph{Arguments}:
1059 @multitable @columnfractions .15 .70
1060 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
1061 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
1062                       expression indicating the kind parameter of
1063                       the result.
1064 @end multitable
1065
1066 @item @emph{Return value}:
1067 The return value is of type real with the kind type parameter of the
1068 argument if the optional @var{KIND} is absent; otherwise, the kind
1069 type parameter will be given by @var{KIND}.  If @var{A} is greater than
1070 zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}.  If @var{A} is
1071 less than or equal to zero then it returns @code{AINT(X-0.5)}.
1072
1073 @item @emph{Example}:
1074 @smallexample
1075 program test_anint
1076   real(4) x4
1077   real(8) x8
1078   x4 = 1.234E0_4
1079   x8 = 4.321_8
1080   print *, anint(x4), dnint(x8)
1081   x8 = anint(x4,8)
1082 end program test_anint
1083 @end smallexample
1084
1085 @item @emph{Specific names}:
1086 @multitable @columnfractions .20 .20 .20 .25
1087 @item Name            @tab Argument         @tab Return type      @tab Standard
1088 @item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)}   @tab Fortran 77 and later
1089 @end multitable
1090 @end table
1091
1092
1093
1094 @node ANY
1095 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true 
1096 @fnindex ANY
1097 @cindex array, apply condition
1098 @cindex array, condition testing
1099
1100 @table @asis
1101 @item @emph{Description}:
1102 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1103 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1104
1105 @item @emph{Standard}:
1106 Fortran 95 and later
1107
1108 @item @emph{Class}:
1109 Transformational function
1110
1111 @item @emph{Syntax}:
1112 @code{RESULT = ANY(MASK [, DIM])}
1113
1114 @item @emph{Arguments}:
1115 @multitable @columnfractions .15 .70
1116 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1117 it shall not be scalar.
1118 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
1119 with a value that lies between one and the rank of @var{MASK}.
1120 @end multitable
1121
1122 @item @emph{Return value}:
1123 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1124 the kind type parameter is the same as the kind type parameter of
1125 @var{MASK}.  If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1126 an array with the rank of @var{MASK} minus 1.  The shape is determined from
1127 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
1128
1129 @table @asis
1130 @item (A)
1131 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1132 otherwise, it is false.  It also is false if @var{MASK} has zero size.
1133 @item (B)
1134 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1135 to @code{ANY(MASK)}.  If the rank is greater than one, then @code{ANY(MASK,DIM)}
1136 is determined by applying @code{ANY} to the array sections.
1137 @end table
1138
1139 @item @emph{Example}:
1140 @smallexample
1141 program test_any
1142   logical l
1143   l = any((/.true., .true., .true./))
1144   print *, l
1145   call section
1146   contains
1147     subroutine section
1148       integer a(2,3), b(2,3)
1149       a = 1
1150       b = 1
1151       b(2,2) = 2
1152       print *, any(a .eq. b, 1)
1153       print *, any(a .eq. b, 2)
1154     end subroutine section
1155 end program test_any
1156 @end smallexample
1157 @end table
1158
1159
1160
1161 @node ASIN
1162 @section @code{ASIN} --- Arcsine function 
1163 @fnindex ASIN
1164 @fnindex DASIN
1165 @cindex trigonometric function, sine, inverse
1166 @cindex sine, inverse
1167
1168 @table @asis
1169 @item @emph{Description}:
1170 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1171
1172 @item @emph{Standard}:
1173 Fortran 77 and later
1174
1175 @item @emph{Class}:
1176 Elemental function
1177
1178 @item @emph{Syntax}:
1179 @code{RESULT = ASIN(X)}
1180
1181 @item @emph{Arguments}:
1182 @multitable @columnfractions .15 .70
1183 @item @var{X} @tab The type shall be @code{REAL}, and a magnitude that is
1184 less than one.
1185 @end multitable
1186
1187 @item @emph{Return value}:
1188 The return value is of type @code{REAL} and it lies in the
1189 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}.  The kind type
1190 parameter is the same as @var{X}.
1191
1192 @item @emph{Example}:
1193 @smallexample
1194 program test_asin
1195   real(8) :: x = 0.866_8
1196   x = asin(x)
1197 end program test_asin
1198 @end smallexample
1199
1200 @item @emph{Specific names}:
1201 @multitable @columnfractions .20 .20 .20 .25
1202 @item Name            @tab Argument          @tab Return type       @tab Standard
1203 @item @code{DASIN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1204 @end multitable
1205
1206 @item @emph{See also}:
1207 Inverse function: @ref{SIN}
1208
1209 @end table
1210
1211
1212
1213 @node ASINH
1214 @section @code{ASINH} --- Hyperbolic arcsine function
1215 @fnindex ASINH
1216 @fnindex DASINH
1217 @cindex area hyperbolic sine
1218 @cindex hyperbolic arcsine
1219 @cindex hyperbolic function, sine, inverse
1220 @cindex sine, hyperbolic, inverse
1221
1222 @table @asis
1223 @item @emph{Description}:
1224 @code{ASINH(X)} computes the hyperbolic arcsine of @var{X} (inverse of @code{SINH(X)}).
1225
1226 @item @emph{Standard}:
1227 Fortran 2008 and later
1228
1229 @item @emph{Class}:
1230 Elemental function
1231
1232 @item @emph{Syntax}:
1233 @code{RESULT = ASINH(X)}
1234
1235 @item @emph{Arguments}:
1236 @multitable @columnfractions .15 .70
1237 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1238 @end multitable
1239
1240 @item @emph{Return value}:
1241 The return value is of the same type and kind as  @var{X}.
1242
1243 @item @emph{Example}:
1244 @smallexample
1245 PROGRAM test_asinh
1246   REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1247   WRITE (*,*) ASINH(x)
1248 END PROGRAM
1249 @end smallexample
1250
1251 @item @emph{Specific names}:
1252 @multitable @columnfractions .20 .20 .20 .25
1253 @item Name             @tab Argument          @tab Return type       @tab Standard
1254 @item @code{DASINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension.
1255 @end multitable
1256
1257 @item @emph{See also}:
1258 Inverse function: @ref{SINH}
1259 @end table
1260
1261
1262
1263 @node ASSOCIATED
1264 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair 
1265 @fnindex ASSOCIATED
1266 @cindex pointer, status
1267 @cindex association status
1268
1269 @table @asis
1270 @item @emph{Description}:
1271 @code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1272 @var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
1273
1274 @item @emph{Standard}:
1275 Fortran 95 and later
1276
1277 @item @emph{Class}:
1278 Inquiry function
1279
1280 @item @emph{Syntax}:
1281 @code{RESULT = ASSOCIATED(POINTER [, TARGET])}
1282
1283 @item @emph{Arguments}:
1284 @multitable @columnfractions .15 .70
1285 @item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1286 and it can be of any type.
1287 @item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1288 a target.  It must have the same type, kind type parameter, and
1289 array rank as @var{POINTER}.
1290 @end multitable
1291 The association status of neither @var{POINTER} nor @var{TARGET} shall be
1292 undefined.
1293
1294 @item @emph{Return value}:
1295 @code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
1296 There are several cases:
1297 @table @asis
1298 @item (A) When the optional @var{TARGET} is not present then
1299 @code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1300 @item (B) If @var{TARGET} is present and a scalar target, the result is true if
1301 @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
1302 disassociated, the result is false.
1303 @item (C) If @var{TARGET} is present and an array target, the result is true if
1304 @var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1305 are arrays whose elements are not zero-sized storage sequences, and
1306 @var{TARGET} and @var{POINTER} occupy the same storage units in array element
1307 order.
1308 As in case(B), the result is false, if @var{POINTER} is disassociated.
1309 @item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1310 if @var{TARGET} is associated with @var{POINTER}, the target associated with
1311 @var{TARGET} are not zero-sized storage sequences and occupy the same storage
1312 units.
1313 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1314 @item (E) If @var{TARGET} is present and an array pointer, the result is true if
1315 target associated with @var{POINTER} and the target associated with @var{TARGET}
1316 have the same shape, are not zero-sized arrays, are arrays whose elements are
1317 not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1318 the same storage units in array element order.
1319 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1320 @end table
1321
1322 @item @emph{Example}:
1323 @smallexample
1324 program test_associated
1325    implicit none
1326    real, target  :: tgt(2) = (/1., 2./)
1327    real, pointer :: ptr(:)
1328    ptr => tgt
1329    if (associated(ptr)     .eqv. .false.) call abort
1330    if (associated(ptr,tgt) .eqv. .false.) call abort
1331 end program test_associated
1332 @end smallexample
1333
1334 @item @emph{See also}:
1335 @ref{NULL}
1336 @end table
1337
1338
1339
1340 @node ATAN
1341 @section @code{ATAN} --- Arctangent function 
1342 @fnindex ATAN
1343 @fnindex DATAN
1344 @cindex trigonometric function, tangent, inverse
1345 @cindex tangent, inverse
1346
1347 @table @asis
1348 @item @emph{Description}:
1349 @code{ATAN(X)} computes the arctangent of @var{X}.
1350
1351 @item @emph{Standard}:
1352 Fortran 77 and later
1353
1354 @item @emph{Class}:
1355 Elemental function
1356
1357 @item @emph{Syntax}:
1358 @code{RESULT = ATAN(X)}
1359
1360 @item @emph{Arguments}:
1361 @multitable @columnfractions .15 .70
1362 @item @var{X} @tab The type shall be @code{REAL}.
1363 @end multitable
1364
1365 @item @emph{Return value}:
1366 The return value is of type @code{REAL} and it lies in the
1367 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1368
1369 @item @emph{Example}:
1370 @smallexample
1371 program test_atan
1372   real(8) :: x = 2.866_8
1373   x = atan(x)
1374 end program test_atan
1375 @end smallexample
1376
1377 @item @emph{Specific names}:
1378 @multitable @columnfractions .20 .20 .20 .25
1379 @item Name            @tab Argument          @tab Return type       @tab Standard
1380 @item @code{DATAN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1381 @end multitable
1382
1383 @item @emph{See also}:
1384 Inverse function: @ref{TAN}
1385
1386 @end table
1387
1388
1389
1390 @node ATAN2
1391 @section @code{ATAN2} --- Arctangent function 
1392 @fnindex ATAN2
1393 @fnindex DATAN2
1394 @cindex trigonometric function, tangent, inverse
1395 @cindex tangent, inverse
1396
1397 @table @asis
1398 @item @emph{Description}:
1399 @code{ATAN2(Y, X)} computes the arctangent of the complex number
1400 @math{X + i Y}.
1401
1402 @item @emph{Standard}:
1403 Fortran 77 and later
1404
1405 @item @emph{Class}:
1406 Elemental function
1407
1408 @item @emph{Syntax}:
1409 @code{RESULT = ATAN2(Y, X)}
1410
1411 @item @emph{Arguments}:
1412 @multitable @columnfractions .15 .70
1413 @item @var{Y} @tab The type shall be @code{REAL}.
1414 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1415 If @var{Y} is zero, then @var{X} must be nonzero.
1416 @end multitable
1417
1418 @item @emph{Return value}:
1419 The return value has the same type and kind type parameter as @var{Y}.
1420 It is the principal value of the complex number @math{X + i Y}.  If
1421 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1422 The sign is positive if @var{Y} is positive.  If @var{Y} is zero, then
1423 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1424 is negative.  Finally, if @var{X} is zero, then the magnitude of the result
1425 is @math{\pi/2}.
1426
1427 @item @emph{Example}:
1428 @smallexample
1429 program test_atan2
1430   real(4) :: x = 1.e0_4, y = 0.5e0_4
1431   x = atan2(y,x)
1432 end program test_atan2
1433 @end smallexample
1434
1435 @item @emph{Specific names}:
1436 @multitable @columnfractions .20 .20 .20 .25
1437 @item Name            @tab Argument          @tab Return type    @tab Standard
1438 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1439 @end multitable
1440 @end table
1441
1442
1443
1444 @node ATANH
1445 @section @code{ATANH} --- Hyperbolic arctangent function
1446 @fnindex ASINH
1447 @fnindex DASINH
1448 @cindex area hyperbolic tangent
1449 @cindex hyperbolic arctangent
1450 @cindex hyperbolic function, tangent, inverse
1451 @cindex tangent, hyperbolic, inverse
1452
1453 @table @asis
1454 @item @emph{Description}:
1455 @code{ATANH(X)} computes the hyperbolic arctangent of @var{X} (inverse
1456 of @code{TANH(X)}).
1457
1458 @item @emph{Standard}:
1459 Fortran 2008 and later
1460
1461 @item @emph{Class}:
1462 Elemental function
1463
1464 @item @emph{Syntax}:
1465 @code{RESULT = ATANH(X)}
1466
1467 @item @emph{Arguments}:
1468 @multitable @columnfractions .15 .70
1469 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1470 @end multitable
1471
1472 @item @emph{Return value}:
1473 The return value has same type and kind as @var{X}.
1474
1475 @item @emph{Example}:
1476 @smallexample
1477 PROGRAM test_atanh
1478   REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1479   WRITE (*,*) ATANH(x)
1480 END PROGRAM
1481 @end smallexample
1482
1483 @item @emph{Specific names}:
1484 @multitable @columnfractions .20 .20 .20 .25
1485 @item Name             @tab Argument          @tab Return type       @tab Standard
1486 @item @code{DATANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1487 @end multitable
1488
1489 @item @emph{See also}:
1490 Inverse function: @ref{TANH}
1491 @end table
1492
1493
1494
1495 @node BESSEL_J0
1496 @section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
1497 @fnindex BESSEL_J0
1498 @fnindex BESJ0
1499 @fnindex DBESJ0
1500 @cindex Bessel function, first kind
1501
1502 @table @asis
1503 @item @emph{Description}:
1504 @code{BESSEL_J0(X)} computes the Bessel function of the first kind of
1505 order 0 of @var{X}. This function is available under the name
1506 @code{BESJ0} as a GNU extension.
1507
1508 @item @emph{Standard}:
1509 Fortran 2008 and later
1510
1511 @item @emph{Class}:
1512 Elemental function
1513
1514 @item @emph{Syntax}:
1515 @code{RESULT = BESSEL_J0(X)}
1516
1517 @item @emph{Arguments}:
1518 @multitable @columnfractions .15 .70
1519 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1520 @end multitable
1521
1522 @item @emph{Return value}:
1523 The return value is of type @code{REAL} and lies in the
1524 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
1525 kind as @var{X}.
1526
1527 @item @emph{Example}:
1528 @smallexample
1529 program test_besj0
1530   real(8) :: x = 0.0_8
1531   x = bessel_j0(x)
1532 end program test_besj0
1533 @end smallexample
1534
1535 @item @emph{Specific names}:
1536 @multitable @columnfractions .20 .20 .20 .25
1537 @item Name            @tab Argument          @tab Return type       @tab Standard
1538 @item @code{DBESJ0(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}   @tab GNU extension
1539 @end multitable
1540 @end table
1541
1542
1543
1544 @node BESSEL_J1
1545 @section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
1546 @fnindex BESSEL_J1
1547 @fnindex BESJ1
1548 @fnindex DBESJ1
1549 @cindex Bessel function, first kind
1550
1551 @table @asis
1552 @item @emph{Description}:
1553 @code{BESSEL_J1(X)} computes the Bessel function of the first kind of
1554 order 1 of @var{X}. This function is available under the name
1555 @code{BESJ1} as a GNU extension.
1556
1557 @item @emph{Standard}:
1558 Fortran 2008
1559
1560 @item @emph{Class}:
1561 Elemental function
1562
1563 @item @emph{Syntax}:
1564 @code{RESULT = BESSEL_J1(X)}
1565
1566 @item @emph{Arguments}:
1567 @multitable @columnfractions .15 .70
1568 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1569 @end multitable
1570
1571 @item @emph{Return value}:
1572 The return value is of type @code{REAL} and it lies in the
1573 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
1574 kind as @var{X}.
1575
1576 @item @emph{Example}:
1577 @smallexample
1578 program test_besj1
1579   real(8) :: x = 1.0_8
1580   x = bessel_j1(x)
1581 end program test_besj1
1582 @end smallexample
1583
1584 @item @emph{Specific names}:
1585 @multitable @columnfractions .20 .20 .20 .25
1586 @item Name            @tab Argument          @tab Return type       @tab Standard
1587 @item @code{DBESJ1(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1588 @end multitable
1589 @end table
1590
1591
1592
1593 @node BESSEL_JN
1594 @section @code{BESSEL_JN} --- Bessel function of the first kind
1595 @fnindex BESSEL_JN
1596 @fnindex BESJN
1597 @fnindex DBESJN
1598 @cindex Bessel function, first kind
1599
1600 @table @asis
1601 @item @emph{Description}:
1602 @code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
1603 order @var{N} of @var{X}. This function is available under the name
1604 @code{BESJN} as a GNU extension.
1605
1606 If both arguments are arrays, their ranks and shapes shall conform.
1607
1608 @item @emph{Standard}:
1609 Fortran 2008 and later
1610
1611 @item @emph{Class}:
1612 Elemental function
1613
1614 @item @emph{Syntax}:
1615 @code{RESULT = BESSEL_JN(N, X)}
1616
1617 @item @emph{Arguments}:
1618 @multitable @columnfractions .15 .70
1619 @item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER}.
1620 @item @var{X} @tab Shall be a scalar or an array of type  @code{REAL}.
1621 @end multitable
1622
1623 @item @emph{Return value}:
1624 The return value is a scalar of type @code{REAL}. It has the same
1625 kind as @var{X}.
1626
1627 @item @emph{Example}:
1628 @smallexample
1629 program test_besjn
1630   real(8) :: x = 1.0_8
1631   x = bessel_jn(5,x)
1632 end program test_besjn
1633 @end smallexample
1634
1635 @item @emph{Specific names}:
1636 @multitable @columnfractions .20 .20 .20 .25
1637 @item Name             @tab Argument            @tab Return type       @tab Standard
1638 @item @code{DBESJN(X)} @tab @code{INTEGER N} @tab @code{REAL(8)}    @tab GNU extension
1639 @item                  @tab @code{REAL(8) X}    @tab                   @tab
1640 @end multitable
1641 @end table
1642
1643
1644
1645 @node BESSEL_Y0
1646 @section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
1647 @fnindex BESSEL_Y0
1648 @fnindex BESY0
1649 @fnindex DBESY0
1650 @cindex Bessel function, second kind
1651
1652 @table @asis
1653 @item @emph{Description}:
1654 @code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
1655 order 0 of @var{X}. This function is available under the name
1656 @code{BESY0} as a GNU extension.
1657
1658 @item @emph{Standard}:
1659 Fortran 2008 and later
1660
1661 @item @emph{Class}:
1662 Elemental function
1663
1664 @item @emph{Syntax}:
1665 @code{RESULT = BESSEL_Y0(X)}
1666
1667 @item @emph{Arguments}:
1668 @multitable @columnfractions .15 .70
1669 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1670 @end multitable
1671
1672 @item @emph{Return value}:
1673 The return value is a scalar of type @code{REAL}. It has the same
1674 kind as @var{X}.
1675
1676 @item @emph{Example}:
1677 @smallexample
1678 program test_besy0
1679   real(8) :: x = 0.0_8
1680   x = bessel_y0(x)
1681 end program test_besy0
1682 @end smallexample
1683
1684 @item @emph{Specific names}:
1685 @multitable @columnfractions .20 .20 .20 .25
1686 @item Name            @tab Argument          @tab Return type       @tab Standard
1687 @item @code{DBESY0(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1688 @end multitable
1689 @end table
1690
1691
1692
1693 @node BESSEL_Y1
1694 @section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
1695 @fnindex BESSEL_Y1
1696 @fnindex BESY1
1697 @fnindex DBESY1
1698 @cindex Bessel function, second kind
1699
1700 @table @asis
1701 @item @emph{Description}:
1702 @code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
1703 order 1 of @var{X}. This function is available under the name
1704 @code{BESY1} as a GNU extension.
1705
1706 @item @emph{Standard}:
1707 Fortran 2008 and later
1708
1709 @item @emph{Class}:
1710 Elemental function
1711
1712 @item @emph{Syntax}:
1713 @code{RESULT = BESSEL_Y1(X)}
1714
1715 @item @emph{Arguments}:
1716 @multitable @columnfractions .15 .70
1717 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1718 @end multitable
1719
1720 @item @emph{Return value}:
1721 The return value is a scalar of type @code{REAL}. It has the same
1722 kind as @var{X}.
1723
1724 @item @emph{Example}:
1725 @smallexample
1726 program test_besy1
1727   real(8) :: x = 1.0_8
1728   x = bessel_y1(x)
1729 end program test_besy1
1730 @end smallexample
1731
1732 @item @emph{Specific names}:
1733 @multitable @columnfractions .20 .20 .20 .25
1734 @item Name            @tab Argument          @tab Return type       @tab Standard
1735 @item @code{DBESY1(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1736 @end multitable
1737 @end table
1738
1739
1740
1741 @node BESSEL_YN
1742 @section @code{BESSEL_YN} --- Bessel function of the second kind
1743 @fnindex BESSEL_YN
1744 @fnindex BESYN
1745 @fnindex DBESYN
1746 @cindex Bessel function, second kind
1747
1748 @table @asis
1749 @item @emph{Description}:
1750 @code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
1751 order @var{N} of @var{X}. This function is available under the name
1752 @code{BESYN} as a GNU extension.
1753
1754 If both arguments are arrays, their ranks and shapes shall conform.
1755
1756 @item @emph{Standard}:
1757 Fortran 2008 and later
1758
1759 @item @emph{Class}:
1760 Elemental function
1761
1762 @item @emph{Syntax}:
1763 @code{RESULT = BESSEL_YN(N, X)}
1764
1765 @item @emph{Arguments}:
1766 @multitable @columnfractions .15 .70
1767 @item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER}.
1768 @item @var{X} @tab Shall be a scalar or an array of type  @code{REAL}.
1769 @end multitable
1770
1771 @item @emph{Return value}:
1772 The return value is a scalar of type @code{REAL}. It has the same
1773 kind as @var{X}.
1774
1775 @item @emph{Example}:
1776 @smallexample
1777 program test_besyn
1778   real(8) :: x = 1.0_8
1779   x = bessel_yn(5,x)
1780 end program test_besyn
1781 @end smallexample
1782
1783 @item @emph{Specific names}:
1784 @multitable @columnfractions .20 .20 .20 .25
1785 @item Name               @tab Argument            @tab Return type     @tab Standard
1786 @item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)}  @tab GNU extension
1787 @item                    @tab @code{REAL(8)    X} @tab                 @tab 
1788 @end multitable
1789 @end table
1790
1791
1792
1793 @node BIT_SIZE
1794 @section @code{BIT_SIZE} --- Bit size inquiry function
1795 @fnindex BIT_SIZE
1796 @cindex bits, number of
1797 @cindex size of a variable, in bits
1798
1799 @table @asis
1800 @item @emph{Description}:
1801 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1802 represented by the type of @var{I}.
1803
1804 @item @emph{Standard}:
1805 Fortran 95 and later
1806
1807 @item @emph{Class}:
1808 Inquiry function
1809
1810 @item @emph{Syntax}:
1811 @code{RESULT = BIT_SIZE(I)}
1812
1813 @item @emph{Arguments}:
1814 @multitable @columnfractions .15 .70
1815 @item @var{I} @tab The type shall be @code{INTEGER}.
1816 @end multitable
1817
1818 @item @emph{Return value}:
1819 The return value is of type @code{INTEGER}
1820
1821 @item @emph{Example}:
1822 @smallexample
1823 program test_bit_size
1824     integer :: i = 123
1825     integer :: size
1826     size = bit_size(i)
1827     print *, size
1828 end program test_bit_size
1829 @end smallexample
1830 @end table
1831
1832
1833
1834 @node BTEST
1835 @section @code{BTEST} --- Bit test function
1836 @fnindex BTEST
1837 @cindex bits, testing
1838
1839 @table @asis
1840 @item @emph{Description}:
1841 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1842 in @var{I} is set.
1843
1844 @item @emph{Standard}:
1845 Fortran 95 and later
1846
1847 @item @emph{Class}:
1848 Elemental function
1849
1850 @item @emph{Syntax}:
1851 @code{RESULT = BTEST(I, POS)}
1852
1853 @item @emph{Arguments}:
1854 @multitable @columnfractions .15 .70
1855 @item @var{I} @tab The type shall be @code{INTEGER}.
1856 @item @var{POS} @tab The type shall be @code{INTEGER}.
1857 @end multitable
1858
1859 @item @emph{Return value}:
1860 The return value is of type @code{LOGICAL}
1861
1862 @item @emph{Example}:
1863 @smallexample
1864 program test_btest
1865     integer :: i = 32768 + 1024 + 64
1866     integer :: pos
1867     logical :: bool
1868     do pos=0,16
1869         bool = btest(i, pos) 
1870         print *, pos, bool
1871     end do
1872 end program test_btest
1873 @end smallexample
1874 @end table
1875
1876
1877 @node C_ASSOCIATED
1878 @section @code{C_ASSOCIATED} --- Status of a C pointer
1879 @fnindex C_ASSOCIATED
1880 @cindex association status, C pointer
1881 @cindex pointer, C association status
1882
1883 @table @asis
1884 @item @emph{Description}:
1885 @code{C_ASSOCIATED(c_prt_1[, c_ptr_2])} determines the status of the C pointer
1886 @var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
1887
1888 @item @emph{Standard}:
1889 Fortran 2003 and later
1890
1891 @item @emph{Class}:
1892 Inquiry function
1893
1894 @item @emph{Syntax}:
1895 @code{RESULT = C_ASSOCIATED(c_prt_1[, c_ptr_2])}
1896
1897 @item @emph{Arguments}:
1898 @multitable @columnfractions .15 .70
1899 @item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
1900 @item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
1901 @end multitable
1902
1903 @item @emph{Return value}:
1904 The return value is of type @code{LOGICAL}; it is @code{.false.} if either
1905 @var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
1906 point to different addresses.
1907
1908 @item @emph{Example}:
1909 @smallexample
1910 subroutine association_test(a,b)
1911   use iso_c_binding, only: c_associated, c_loc, c_ptr
1912   implicit none
1913   real, pointer :: a
1914   type(c_ptr) :: b
1915   if(c_associated(b, c_loc(a))) &
1916      stop 'b and a do not point to same target'
1917 end subroutine association_test
1918 @end smallexample
1919
1920 @item @emph{See also}:
1921 @ref{C_LOC}, @ref{C_FUNLOC}
1922 @end table
1923
1924
1925 @node C_FUNLOC
1926 @section @code{C_FUNLOC} --- Obtain the C address of a procedure
1927 @fnindex C_FUNLOC
1928 @cindex pointer, C address of procedures
1929
1930 @table @asis
1931 @item @emph{Description}:
1932 @code{C_FUNLOC(x)} determines the C address of the argument.
1933
1934 @item @emph{Standard}:
1935 Fortran 2003 and later
1936
1937 @item @emph{Class}:
1938 Inquiry function
1939
1940 @item @emph{Syntax}:
1941 @code{RESULT = C_FUNLOC(x)}
1942
1943 @item @emph{Arguments}:
1944 @multitable @columnfractions .15 .70
1945 @item @var{x} @tab Interoperable function or pointer to such function.
1946 @end multitable
1947
1948 @item @emph{Return value}:
1949 The return value is of type @code{C_FUNPTR} and contains the C address
1950 of the argument.
1951
1952 @item @emph{Example}:
1953 @smallexample
1954 module x
1955   use iso_c_binding
1956   implicit none
1957 contains
1958   subroutine sub(a) bind(c)
1959     real(c_float) :: a
1960     a = sqrt(a)+5.0
1961   end subroutine sub
1962 end module x
1963 program main
1964   use iso_c_binding
1965   use x
1966   implicit none
1967   interface
1968     subroutine my_routine(p) bind(c,name='myC_func')
1969       import :: c_funptr
1970       type(c_funptr), intent(in) :: p
1971     end subroutine
1972   end interface
1973   call my_routine(c_funloc(sub))
1974 end program main
1975 @end smallexample
1976
1977 @item @emph{See also}:
1978 @ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
1979 @end table
1980
1981
1982 @node C_F_PROCPOINTER
1983 @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
1984 @fnindex C_F_PROCPOINTER
1985 @cindex pointer, C address of pointers
1986
1987 @table @asis
1988 @item @emph{Description}:
1989 @code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
1990 @var{CPTR} to the Fortran procedure pointer @var{FPTR}.
1991
1992 Note: Due to the currently lacking support of procedure pointers in GNU Fortran
1993 this function is not fully operable.
1994
1995 @item @emph{Standard}:
1996 Fortran 2003 and later
1997
1998 @item @emph{Class}:
1999 Subroutine
2000
2001 @item @emph{Syntax}:
2002 @code{CALL C_F_PROCPOINTER(cptr, fptr)}
2003
2004 @item @emph{Arguments}:
2005 @multitable @columnfractions .15 .70
2006 @item @var{CPTR}  @tab scalar of the type @code{C_FUNPTR}. It is
2007                        @code{INTENT(IN)}.
2008 @item @var{FPTR}  @tab procedure pointer interoperable with @var{cptr}. It is
2009                        @code{INTENT(OUT)}.
2010 @end multitable
2011
2012 @item @emph{Example}:
2013 @smallexample
2014 program main
2015   use iso_c_binding
2016   implicit none
2017   abstract interface
2018     function func(a)
2019       import :: c_float
2020       real(c_float), intent(in) :: a
2021       real(c_float) :: func
2022     end function
2023   end interface
2024   interface
2025      function getIterFunc() bind(c,name="getIterFunc")
2026        import :: c_funptr
2027        type(c_funptr) :: getIterFunc
2028      end function
2029   end interface
2030   type(c_funptr) :: cfunptr
2031   procedure(func), pointer :: myFunc
2032   cfunptr = getIterFunc()
2033   call c_f_procpointer(cfunptr, myFunc)
2034 end program main
2035 @end smallexample
2036
2037 @item @emph{See also}:
2038 @ref{C_LOC}, @ref{C_F_POINTER}
2039 @end table
2040
2041
2042 @node C_F_POINTER
2043 @section @code{C_F_POINTER} --- Convert C into Fortran pointer
2044 @fnindex C_F_POINTER
2045 @cindex pointer, convert C to Fortran
2046
2047 @table @asis
2048 @item @emph{Description}:
2049 @code{C_F_POINTER(CPTR, FPTR[, SHAPE])} Assign the target the C pointer
2050 @var{CPTR} to the Fortran pointer @var{FPTR} and specify its
2051 shape.
2052
2053 @item @emph{Standard}:
2054 Fortran 2003 and later
2055
2056 @item @emph{Class}:
2057 Subroutine
2058
2059 @item @emph{Syntax}:
2060 @code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
2061
2062 @item @emph{Arguments}:
2063 @multitable @columnfractions .15 .70
2064 @item @var{CPTR}  @tab scalar of the type @code{C_PTR}. It is
2065                        @code{INTENT(IN)}.
2066 @item @var{FPTR}  @tab pointer interoperable with @var{cptr}. It is
2067                        @code{INTENT(OUT)}.
2068 @item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
2069                        with @code{INTENT(IN)}. It shall be present
2070                        if and only if @var{fptr} is an array. The size
2071                        must be equal to the rank of @var{fptr}.
2072 @end multitable
2073
2074 @item @emph{Example}:
2075 @smallexample
2076 program main
2077   use iso_c_binding
2078   implicit none
2079   interface
2080     subroutine my_routine(p) bind(c,name='myC_func')
2081       import :: c_ptr
2082       type(c_ptr), intent(out) :: p
2083     end subroutine
2084   end interface
2085   type(c_ptr) :: cptr
2086   real,pointer :: a(:)
2087   call my_routine(cptr)
2088   call c_f_pointer(cptr, a, [12])
2089 end program main
2090 @end smallexample
2091
2092 @item @emph{See also}:
2093 @ref{C_LOC}, @ref{C_F_PROCPOINTER}
2094 @end table
2095
2096
2097 @node C_LOC
2098 @section @code{C_LOC} --- Obtain the C address of an object
2099 @fnindex C_LOC
2100 @cindex procedure pointer, convert C to Fortran
2101
2102 @table @asis
2103 @item @emph{Description}:
2104 @code{C_LOC(X)} determines the C address of the argument.
2105
2106 @item @emph{Standard}:
2107 Fortran 2003 and later
2108
2109 @item @emph{Class}:
2110 Inquiry function
2111
2112 @item @emph{Syntax}:
2113 @code{RESULT = C_LOC(X)}
2114
2115 @item @emph{Arguments}:
2116 @multitable @columnfractions .15 .70
2117 @item @var{X} @tab Associated scalar pointer or interoperable scalar
2118                    or allocated allocatable variable with @code{TARGET}
2119                    attribute.
2120 @end multitable
2121
2122 @item @emph{Return value}:
2123 The return value is of type @code{C_PTR} and contains the C address
2124 of the argument.
2125
2126 @item @emph{Example}:
2127 @smallexample
2128 subroutine association_test(a,b)
2129   use iso_c_binding, only: c_associated, c_loc, c_ptr
2130   implicit none
2131   real, pointer :: a
2132   type(c_ptr) :: b
2133   if(c_associated(b, c_loc(a))) &
2134      stop 'b and a do not point to same target'
2135 end subroutine association_test
2136 @end smallexample
2137
2138 @item @emph{See also}:
2139 @ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2140 @end table
2141
2142
2143 @node C_SIZEOF
2144 @section @code{C_SIZEOF} --- Size in bytes of an expression
2145 @fnindex C_SIZEOF
2146 @cindex expression size
2147 @cindex size of an expression
2148
2149 @table @asis
2150 @item @emph{Description}:
2151 @code{C_SIZEOF(X)} calculates the number of bytes of storage the
2152 expression @code{X} occupies.
2153
2154 @item @emph{Standard}:
2155 Fortran 2008
2156
2157 @item @emph{Class}:
2158 Intrinsic function
2159
2160 @item @emph{Syntax}:
2161 @code{N = C_SIZEOF(X)}
2162
2163 @item @emph{Arguments}:
2164 @multitable @columnfractions .15 .70
2165 @item @var{X} @tab The argument shall be of any type, rank or shape.
2166 @end multitable
2167
2168 @item @emph{Return value}:
2169 The return value is of type integer and of the system-dependent kind
2170 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
2171 number of bytes occupied by the argument.  If the argument has the
2172 @code{POINTER} attribute, the number of bytes of the storage area pointed
2173 to is returned.  If the argument is of a derived type with @code{POINTER}
2174 or @code{ALLOCATABLE} components, the return value doesn't account for
2175 the sizes of the data pointed to by these components.
2176
2177 @item @emph{Example}:
2178 @smallexample
2179    use iso_c_binding
2180    integer(c_int) :: i
2181    real(c_float) :: r, s(5)
2182    print *, (c_sizeof(s)/c_sizeof(r) == 5)
2183    end
2184 @end smallexample
2185 The example will print @code{.TRUE.} unless you are using a platform
2186 where default @code{REAL} variables are unusually padded.
2187
2188 @item @emph{See also}:
2189 @ref{SIZEOF}
2190 @end table
2191
2192
2193 @node CEILING
2194 @section @code{CEILING} --- Integer ceiling function
2195 @fnindex CEILING
2196 @cindex ceiling
2197 @cindex rounding, ceiling
2198
2199 @table @asis
2200 @item @emph{Description}:
2201 @code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
2202
2203 @item @emph{Standard}:
2204 Fortran 95 and later
2205
2206 @item @emph{Class}:
2207 Elemental function
2208
2209 @item @emph{Syntax}:
2210 @code{RESULT = CEILING(A [, KIND])}
2211
2212 @item @emph{Arguments}:
2213 @multitable @columnfractions .15 .70
2214 @item @var{A} @tab The type shall be @code{REAL}.
2215 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2216                       expression indicating the kind parameter of
2217                       the result.
2218 @end multitable
2219
2220 @item @emph{Return value}:
2221 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
2222 and a default-kind @code{INTEGER} otherwise.
2223
2224 @item @emph{Example}:
2225 @smallexample
2226 program test_ceiling
2227     real :: x = 63.29
2228     real :: y = -63.59
2229     print *, ceiling(x) ! returns 64
2230     print *, ceiling(y) ! returns -63
2231 end program test_ceiling
2232 @end smallexample
2233
2234 @item @emph{See also}:
2235 @ref{FLOOR}, @ref{NINT}
2236
2237 @end table
2238
2239
2240
2241 @node CHAR
2242 @section @code{CHAR} --- Character conversion function
2243 @fnindex CHAR
2244 @cindex conversion, to character
2245
2246 @table @asis
2247 @item @emph{Description}:
2248 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
2249
2250 @item @emph{Standard}:
2251 Fortran 77 and later
2252
2253 @item @emph{Class}:
2254 Elemental function
2255
2256 @item @emph{Syntax}:
2257 @code{RESULT = CHAR(I [, KIND])}
2258
2259 @item @emph{Arguments}:
2260 @multitable @columnfractions .15 .70
2261 @item @var{I} @tab The type shall be @code{INTEGER}.
2262 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2263                       expression indicating the kind parameter of
2264                       the result.
2265 @end multitable
2266
2267 @item @emph{Return value}:
2268 The return value is of type @code{CHARACTER(1)}
2269
2270 @item @emph{Example}:
2271 @smallexample
2272 program test_char
2273     integer :: i = 74
2274     character(1) :: c
2275     c = char(i)
2276     print *, i, c ! returns 'J'
2277 end program test_char
2278 @end smallexample
2279
2280 @item @emph{Note}:
2281 See @ref{ICHAR} for a discussion of converting between numerical values
2282 and formatted string representations.
2283
2284 @item @emph{See also}:
2285 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
2286
2287 @end table
2288
2289
2290
2291 @node CHDIR
2292 @section @code{CHDIR} --- Change working directory
2293 @fnindex CHDIR
2294 @cindex system, working directory
2295
2296 @table @asis
2297 @item @emph{Description}:
2298 Change current working directory to a specified path.
2299
2300 This intrinsic is provided in both subroutine and function forms; however,
2301 only one form can be used in any given program unit.
2302
2303 @item @emph{Standard}:
2304 GNU extension
2305
2306 @item @emph{Class}:
2307 Subroutine, function
2308
2309 @item @emph{Syntax}:
2310 @multitable @columnfractions .80
2311 @item @code{CALL CHDIR(NAME [, STATUS])}
2312 @item @code{STATUS = CHDIR(NAME)}
2313 @end multitable
2314
2315 @item @emph{Arguments}:
2316 @multitable @columnfractions .15 .70
2317 @item @var{NAME}   @tab The type shall be @code{CHARACTER} of default
2318                         kind and shall specify a valid path within the
2319                         file system.
2320 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
2321                         kind.  Returns 0 on success, and a system specific
2322                         and nonzero error code otherwise.
2323 @end multitable
2324
2325 @item @emph{Example}:
2326 @smallexample
2327 PROGRAM test_chdir
2328   CHARACTER(len=255) :: path
2329   CALL getcwd(path)
2330   WRITE(*,*) TRIM(path)
2331   CALL chdir("/tmp")
2332   CALL getcwd(path)
2333   WRITE(*,*) TRIM(path)
2334 END PROGRAM
2335 @end smallexample
2336
2337 @item @emph{See also}:
2338 @ref{GETCWD}
2339 @end table
2340
2341
2342
2343 @node CHMOD
2344 @section @code{CHMOD} --- Change access permissions of files
2345 @fnindex CHMOD
2346 @cindex file system, change access mode
2347
2348 @table @asis
2349 @item @emph{Description}:
2350 @code{CHMOD} changes the permissions of a file. This function invokes
2351 @code{/bin/chmod} and might therefore not work on all platforms.
2352
2353 This intrinsic is provided in both subroutine and function forms; however,
2354 only one form can be used in any given program unit.
2355
2356 @item @emph{Standard}:
2357 GNU extension
2358
2359 @item @emph{Class}:
2360 Subroutine, function
2361
2362 @item @emph{Syntax}:
2363 @multitable @columnfractions .80
2364 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
2365 @item @code{STATUS = CHMOD(NAME, MODE)}
2366 @end multitable
2367
2368 @item @emph{Arguments}:
2369 @multitable @columnfractions .15 .70
2370
2371 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
2372 file name. Trailing blanks are ignored unless the character
2373 @code{achar(0)} is present, then all characters up to and excluding
2374 @code{achar(0)} are used as the file name.
2375
2376 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
2377 file permission. @var{MODE} uses the same syntax as the @var{MODE}
2378 argument of @code{/bin/chmod}.
2379
2380 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
2381 @code{0} on success and nonzero otherwise.
2382 @end multitable
2383
2384 @item @emph{Return value}:
2385 In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
2386 otherwise.
2387
2388 @item @emph{Example}:
2389 @code{CHMOD} as subroutine
2390 @smallexample
2391 program chmod_test
2392   implicit none
2393   integer :: status
2394   call chmod('test.dat','u+x',status)
2395   print *, 'Status: ', status
2396 end program chmod_test
2397 @end smallexample
2398 @code{CHMOD} as function:
2399 @smallexample
2400 program chmod_test
2401   implicit none
2402   integer :: status
2403   status = chmod('test.dat','u+x')
2404   print *, 'Status: ', status
2405 end program chmod_test
2406 @end smallexample
2407
2408 @end table
2409
2410
2411
2412 @node CMPLX
2413 @section @code{CMPLX} --- Complex conversion function
2414 @fnindex CMPLX
2415 @cindex complex numbers, conversion to
2416 @cindex conversion, to complex
2417
2418 @table @asis
2419 @item @emph{Description}:
2420 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
2421 the real component.  If @var{Y} is present it is converted to the imaginary
2422 component.  If @var{Y} is not present then the imaginary component is set to
2423 0.0.  If @var{X} is complex then @var{Y} must not be present.
2424
2425 @item @emph{Standard}:
2426 Fortran 77 and later
2427
2428 @item @emph{Class}:
2429 Elemental function
2430
2431 @item @emph{Syntax}:
2432 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2433
2434 @item @emph{Arguments}:
2435 @multitable @columnfractions .15 .70
2436 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
2437                    or @code{COMPLEX}.
2438 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2439                    @code{COMPLEX}.)  May be @code{INTEGER}
2440                    or @code{REAL}.
2441 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2442                       expression indicating the kind parameter of
2443                       the result.
2444 @end multitable
2445
2446 @item @emph{Return value}:
2447 The return value is of @code{COMPLEX} type, with a kind equal to
2448 @var{KIND} if it is specified.  If @var{KIND} is not specified, the
2449 result is of the default @code{COMPLEX} kind, regardless of the kinds of
2450 @var{X} and @var{Y}. 
2451
2452 @item @emph{Example}:
2453 @smallexample
2454 program test_cmplx
2455     integer :: i = 42
2456     real :: x = 3.14
2457     complex :: z
2458     z = cmplx(i, x)
2459     print *, z, cmplx(x)
2460 end program test_cmplx
2461 @end smallexample
2462
2463 @item @emph{See also}:
2464 @ref{COMPLEX}
2465 @end table
2466
2467
2468
2469 @node COMMAND_ARGUMENT_COUNT
2470 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2471 @fnindex COMMAND_ARGUMENT_COUNT
2472 @cindex command-line arguments
2473 @cindex command-line arguments, number of
2474 @cindex arguments, to program
2475
2476 @table @asis
2477 @item @emph{Description}:
2478 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2479 command line when the containing program was invoked.
2480
2481 @item @emph{Standard}:
2482 Fortran 2003 and later
2483
2484 @item @emph{Class}:
2485 Inquiry function
2486
2487 @item @emph{Syntax}:
2488 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2489
2490 @item @emph{Arguments}:
2491 @multitable @columnfractions .15 .70
2492 @item None
2493 @end multitable
2494
2495 @item @emph{Return value}:
2496 The return value is of type @code{INTEGER(4)}
2497
2498 @item @emph{Example}:
2499 @smallexample
2500 program test_command_argument_count
2501     integer :: count
2502     count = command_argument_count()
2503     print *, count
2504 end program test_command_argument_count
2505 @end smallexample
2506
2507 @item @emph{See also}:
2508 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2509 @end table
2510
2511
2512
2513 @node COMPLEX
2514 @section @code{COMPLEX} --- Complex conversion function
2515 @fnindex COMPLEX
2516 @cindex complex numbers, conversion to
2517 @cindex conversion, to complex
2518
2519 @table @asis
2520 @item @emph{Description}:
2521 @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
2522 to the real component and @var{Y} is converted to the imaginary
2523 component.
2524
2525 @item @emph{Standard}:
2526 GNU extension
2527
2528 @item @emph{Class}:
2529 Elemental function
2530
2531 @item @emph{Syntax}:
2532 @code{RESULT = COMPLEX(X, Y)}
2533
2534 @item @emph{Arguments}:
2535 @multitable @columnfractions .15 .70
2536 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
2537 @item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
2538 @end multitable
2539
2540 @item @emph{Return value}:
2541 If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
2542 value is of default @code{COMPLEX} type.
2543
2544 If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
2545 type and one is of @code{INTEGER} type, then the return value is of
2546 @code{COMPLEX} type with a kind equal to that of the @code{REAL}
2547 argument with the highest precision.  
2548
2549 @item @emph{Example}:
2550 @smallexample
2551 program test_complex
2552     integer :: i = 42
2553     real :: x = 3.14
2554     print *, complex(i, x)
2555 end program test_complex
2556 @end smallexample
2557
2558 @item @emph{See also}:
2559 @ref{CMPLX}
2560 @end table
2561
2562
2563
2564 @node CONJG
2565 @section @code{CONJG} --- Complex conjugate function 
2566 @fnindex CONJG
2567 @fnindex DCONJG
2568 @cindex complex conjugate
2569
2570 @table @asis
2571 @item @emph{Description}:
2572 @code{CONJG(Z)} returns the conjugate of @var{Z}.  If @var{Z} is @code{(x, y)}
2573 then the result is @code{(x, -y)}
2574
2575 @item @emph{Standard}:
2576 Fortran 77 and later, has overloads that are GNU extensions
2577
2578 @item @emph{Class}:
2579 Elemental function
2580
2581 @item @emph{Syntax}:
2582 @code{Z = CONJG(Z)}
2583
2584 @item @emph{Arguments}:
2585 @multitable @columnfractions .15 .70
2586 @item @var{Z} @tab The type shall be @code{COMPLEX}.
2587 @end multitable
2588
2589 @item @emph{Return value}:
2590 The return value is of type @code{COMPLEX}.
2591
2592 @item @emph{Example}:
2593 @smallexample
2594 program test_conjg
2595     complex :: z = (2.0, 3.0)
2596     complex(8) :: dz = (2.71_8, -3.14_8)
2597     z= conjg(z)
2598     print *, z
2599     dz = dconjg(dz)
2600     print *, dz
2601 end program test_conjg
2602 @end smallexample
2603
2604 @item @emph{Specific names}:
2605 @multitable @columnfractions .20 .20 .20 .25
2606 @item Name             @tab Argument             @tab Return type          @tab Standard
2607 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z}  @tab @code{COMPLEX(8)}    @tab GNU extension
2608 @end multitable
2609 @end table
2610
2611
2612
2613 @node COS
2614 @section @code{COS} --- Cosine function 
2615 @fnindex COS
2616 @fnindex DCOS
2617 @fnindex CCOS
2618 @fnindex ZCOS
2619 @fnindex CDCOS
2620 @cindex trigonometric function, cosine
2621 @cindex cosine
2622
2623 @table @asis
2624 @item @emph{Description}:
2625 @code{COS(X)} computes the cosine of @var{X}.
2626
2627 @item @emph{Standard}:
2628 Fortran 77 and later, has overloads that are GNU extensions
2629
2630 @item @emph{Class}:
2631 Elemental function
2632
2633 @item @emph{Syntax}:
2634 @code{RESULT = COS(X)}
2635
2636 @item @emph{Arguments}:
2637 @multitable @columnfractions .15 .70
2638 @item @var{X} @tab The type shall be @code{REAL} or
2639 @code{COMPLEX}.
2640 @end multitable
2641
2642 @item @emph{Return value}:
2643 The return value is of type @code{REAL} and it lies in the
2644 range @math{ -1 \leq \cos (x) \leq 1}.  The kind type
2645 parameter is the same as @var{X}.
2646
2647 @item @emph{Example}:
2648 @smallexample
2649 program test_cos
2650   real :: x = 0.0
2651   x = cos(x)
2652 end program test_cos
2653 @end smallexample
2654
2655 @item @emph{Specific names}:
2656 @multitable @columnfractions .20 .20 .20 .25
2657 @item Name            @tab Argument            @tab Return type       @tab Standard
2658 @item @code{DCOS(X)}  @tab @code{REAL(8) X}    @tab @code{REAL(8)}    @tab Fortran 77 and later
2659 @item @code{CCOS(X)}  @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
2660 @item @code{ZCOS(X)}  @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2661 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2662 @end multitable
2663
2664 @item @emph{See also}:
2665 Inverse function: @ref{ACOS}
2666
2667 @end table
2668
2669
2670
2671 @node COSH
2672 @section @code{COSH} --- Hyperbolic cosine function 
2673 @fnindex COSH
2674 @fnindex DCOSH
2675 @cindex hyperbolic cosine
2676 @cindex hyperbolic function, cosine
2677 @cindex cosine, hyperbolic
2678
2679 @table @asis
2680 @item @emph{Description}:
2681 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2682
2683 @item @emph{Standard}:
2684 Fortran 77 and later
2685
2686 @item @emph{Class}:
2687 Elemental function
2688
2689 @item @emph{Syntax}:
2690 @code{X = COSH(X)}
2691
2692 @item @emph{Arguments}:
2693 @multitable @columnfractions .15 .70
2694 @item @var{X} @tab The type shall be @code{REAL}.
2695 @end multitable
2696
2697 @item @emph{Return value}:
2698 The return value is of type @code{REAL} and it is positive
2699 (@math{ \cosh (x) \geq 0 }. The return value is of the same
2700 kind as @var{X}.
2701
2702 @item @emph{Example}:
2703 @smallexample
2704 program test_cosh
2705   real(8) :: x = 1.0_8
2706   x = cosh(x)
2707 end program test_cosh
2708 @end smallexample
2709
2710 @item @emph{Specific names}:
2711 @multitable @columnfractions .20 .20 .20 .25
2712 @item Name            @tab Argument          @tab Return type       @tab Standard
2713 @item @code{DCOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
2714 @end multitable
2715
2716 @item @emph{See also}:
2717 Inverse function: @ref{ACOSH}
2718
2719 @end table
2720
2721
2722
2723 @node COUNT
2724 @section @code{COUNT} --- Count function
2725 @fnindex COUNT
2726 @cindex array, conditionally count elements
2727 @cindex array, element counting
2728 @cindex array, number of elements
2729
2730 @table @asis
2731 @item @emph{Description}:
2732
2733 @code{COUNT(MASK [, DIM [, KIND]])} counts the number of @code{.TRUE.}
2734 elements of @var{MASK} along the dimension of @var{DIM}.  If @var{DIM} is
2735 omitted it is taken to be @code{1}.  @var{DIM} is a scaler of type
2736 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n}
2737 is the rank of @var{MASK}.
2738
2739 @item @emph{Standard}:
2740 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
2741
2742 @item @emph{Class}:
2743 Transformational function
2744
2745 @item @emph{Syntax}:
2746 @code{RESULT = COUNT(MASK [, DIM [, KIND]])}
2747
2748 @item @emph{Arguments}:
2749 @multitable @columnfractions .15 .70
2750 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2751 @item @var{DIM}  @tab (Optional) The type shall be @code{INTEGER}.
2752 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2753                       expression indicating the kind parameter of
2754                       the result.
2755 @end multitable
2756
2757 @item @emph{Return value}:
2758 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
2759 @var{KIND} is absent, the return value is of default integer kind.
2760 The result has a rank equal to that of @var{MASK}.
2761
2762 @item @emph{Example}:
2763 @smallexample
2764 program test_count
2765     integer, dimension(2,3) :: a, b
2766     logical, dimension(2,3) :: mask
2767     a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2768     b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2769     print '(3i3)', a(1,:)
2770     print '(3i3)', a(2,:)
2771     print *
2772     print '(3i3)', b(1,:)
2773     print '(3i3)', b(2,:)
2774     print *
2775     mask = a.ne.b
2776     print '(3l3)', mask(1,:)
2777     print '(3l3)', mask(2,:)
2778     print *
2779     print '(3i3)', count(mask)
2780     print *
2781     print '(3i3)', count(mask, 1)
2782     print *
2783     print '(3i3)', count(mask, 2)
2784 end program test_count
2785 @end smallexample
2786 @end table
2787
2788
2789
2790 @node CPU_TIME
2791 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2792 @fnindex CPU_TIME
2793 @cindex time, elapsed
2794
2795 @table @asis
2796 @item @emph{Description}:
2797 Returns a @code{REAL} value representing the elapsed CPU time in
2798 seconds.  This is useful for testing segments of code to determine
2799 execution time.
2800
2801 If a time source is available, time will be reported with microsecond
2802 resolution. If no time source is available, @var{TIME} is set to
2803 @code{-1.0}.
2804
2805 Note that @var{TIME} may contain a, system dependent, arbitrary offset
2806 and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
2807 value is meaningless, only differences between subsequent calls to
2808 this subroutine, as shown in the example below, should be used.
2809
2810
2811 @item @emph{Standard}:
2812 Fortran 95 and later
2813
2814 @item @emph{Class}:
2815 Subroutine
2816
2817 @item @emph{Syntax}:
2818 @code{CALL CPU_TIME(TIME)}
2819
2820 @item @emph{Arguments}:
2821 @multitable @columnfractions .15 .70
2822 @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2823 @end multitable
2824
2825 @item @emph{Return value}:
2826 None
2827
2828 @item @emph{Example}:
2829 @smallexample
2830 program test_cpu_time
2831     real :: start, finish
2832     call cpu_time(start)
2833         ! put code to test here
2834     call cpu_time(finish)
2835     print '("Time = ",f6.3," seconds.")',finish-start
2836 end program test_cpu_time
2837 @end smallexample
2838
2839 @item @emph{See also}:
2840 @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
2841 @end table
2842
2843
2844
2845 @node CSHIFT
2846 @section @code{CSHIFT} --- Circular shift elements of an array
2847 @fnindex CSHIFT
2848 @cindex array, shift circularly
2849 @cindex array, permutation
2850 @cindex array, rotate
2851
2852 @table @asis
2853 @item @emph{Description}:
2854 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2855 @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is omitted it is
2856 taken to be @code{1}.  @var{DIM} is a scaler of type @code{INTEGER} in the
2857 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2858 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2859 by @var{SHIFT} places.  If rank is greater than one, then all complete rank one
2860 sections of @var{ARRAY} along the given dimension are shifted.  Elements
2861 shifted out one end of each rank one section are shifted back in the other end.
2862
2863 @item @emph{Standard}:
2864 Fortran 95 and later
2865
2866 @item @emph{Class}:
2867 Transformational function
2868
2869 @item @emph{Syntax}:
2870 @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
2871
2872 @item @emph{Arguments}:
2873 @multitable @columnfractions .15 .70
2874 @item @var{ARRAY}  @tab Shall be an array of any type.
2875 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
2876 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
2877 @end multitable
2878
2879 @item @emph{Return value}:
2880 Returns an array of same type and rank as the @var{ARRAY} argument.
2881
2882 @item @emph{Example}:
2883 @smallexample
2884 program test_cshift
2885     integer, dimension(3,3) :: a
2886     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2887     print '(3i3)', a(1,:)
2888     print '(3i3)', a(2,:)
2889     print '(3i3)', a(3,:)    
2890     a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2891     print *
2892     print '(3i3)', a(1,:)
2893     print '(3i3)', a(2,:)
2894     print '(3i3)', a(3,:)
2895 end program test_cshift
2896 @end smallexample
2897 @end table
2898
2899
2900
2901 @node CTIME
2902 @section @code{CTIME} --- Convert a time into a string
2903 @fnindex CTIME
2904 @cindex time, conversion to string
2905 @cindex conversion, to string
2906
2907 @table @asis
2908 @item @emph{Description}:
2909 @code{CTIME} converts a system time value, such as returned by
2910 @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14 1995}.
2911
2912 This intrinsic is provided in both subroutine and function forms; however,
2913 only one form can be used in any given program unit.
2914
2915 @item @emph{Standard}:
2916 GNU extension
2917
2918 @item @emph{Class}:
2919 Subroutine, function
2920
2921 @item @emph{Syntax}:
2922 @multitable @columnfractions .80
2923 @item @code{CALL CTIME(TIME, RESULT)}.
2924 @item @code{RESULT = CTIME(TIME)}, (not recommended).
2925 @end multitable
2926
2927 @item @emph{Arguments}:
2928 @multitable @columnfractions .15 .70
2929 @item @var{TIME}    @tab The type shall be of type @code{INTEGER(KIND=8)}.
2930 @item @var{RESULT}  @tab The type shall be of type @code{CHARACTER} and
2931                          of default kind.
2932 @end multitable
2933
2934 @item @emph{Return value}:
2935 The converted date and time as a string.
2936
2937 @item @emph{Example}:
2938 @smallexample
2939 program test_ctime
2940     integer(8) :: i
2941     character(len=30) :: date
2942     i = time8()
2943
2944     ! Do something, main part of the program
2945     
2946     call ctime(i,date)
2947     print *, 'Program was started on ', date
2948 end program test_ctime
2949 @end smallexample
2950
2951 @item @emph{See Also}:
2952 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2953 @end table
2954
2955
2956
2957 @node DATE_AND_TIME
2958 @section @code{DATE_AND_TIME} --- Date and time subroutine
2959 @fnindex DATE_AND_TIME
2960 @cindex date, current
2961 @cindex current date
2962 @cindex time, current
2963 @cindex current time
2964
2965 @table @asis
2966 @item @emph{Description}:
2967 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2968 time information from the real-time system clock.  @var{DATE} is
2969 @code{INTENT(OUT)} and has form ccyymmdd.  @var{TIME} is @code{INTENT(OUT)} and
2970 has form hhmmss.sss.  @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2971 representing the difference with respect to Coordinated Universal Time (UTC).
2972 Unavailable time and date parameters return blanks.
2973
2974 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2975
2976 @multitable @columnfractions .15 .30 .40
2977 @item @tab @code{VALUE(1)}: @tab The year
2978 @item @tab @code{VALUE(2)}: @tab The month
2979 @item @tab @code{VALUE(3)}: @tab The day of the month
2980 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2981 @item @tab @code{VALUE(5)}: @tab The hour of the day
2982 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2983 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2984 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2985 @end multitable     
2986
2987 @item @emph{Standard}:
2988 Fortran 95 and later
2989
2990 @item @emph{Class}:
2991 Subroutine
2992
2993 @item @emph{Syntax}:
2994 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2995
2996 @item @emph{Arguments}:
2997 @multitable @columnfractions .15 .70
2998 @item @var{DATE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
2999                                   or larger, and of default kind.
3000 @item @var{TIME}  @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
3001                                   or larger, and of default kind.
3002 @item @var{ZONE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
3003                                   or larger, and of default kind.
3004 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
3005 @end multitable
3006
3007 @item @emph{Return value}:
3008 None
3009
3010 @item @emph{Example}:
3011 @smallexample
3012 program test_time_and_date
3013     character(8)  :: date
3014     character(10) :: time
3015     character(5)  :: zone
3016     integer,dimension(8) :: values
3017     ! using keyword arguments
3018     call date_and_time(date,time,zone,values)
3019     call date_and_time(DATE=date,ZONE=zone)
3020     call date_and_time(TIME=time)
3021     call date_and_time(VALUES=values)
3022     print '(a,2x,a,2x,a)', date, time, zone
3023     print '(8i5))', values
3024 end program test_time_and_date
3025 @end smallexample
3026
3027 @item @emph{See also}:
3028 @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
3029 @end table
3030
3031
3032
3033 @node DBLE
3034 @section @code{DBLE} --- Double conversion function 
3035 @fnindex DBLE
3036 @cindex conversion, to real
3037
3038 @table @asis
3039 @item @emph{Description}:
3040 @code{DBLE(A)} Converts @var{A} to double precision real type.
3041
3042 @item @emph{Standard}:
3043 Fortran 77 and later
3044
3045 @item @emph{Class}:
3046 Elemental function
3047
3048 @item @emph{Syntax}:
3049 @code{RESULT = DBLE(A)}
3050
3051 @item @emph{Arguments}:
3052 @multitable @columnfractions .15 .70
3053 @item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
3054                    or @code{COMPLEX}.
3055 @end multitable
3056
3057 @item @emph{Return value}:
3058 The return value is of type double precision real.
3059
3060 @item @emph{Example}:
3061 @smallexample
3062 program test_dble
3063     real    :: x = 2.18
3064     integer :: i = 5
3065     complex :: z = (2.3,1.14)
3066     print *, dble(x), dble(i), dble(z)
3067 end program test_dble
3068 @end smallexample
3069
3070 @item @emph{See also}:
3071 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
3072 @end table
3073
3074
3075
3076 @node DCMPLX
3077 @section @code{DCMPLX} --- Double complex conversion function
3078 @fnindex DCMPLX
3079 @cindex complex numbers, conversion to
3080 @cindex conversion, to complex
3081
3082 @table @asis
3083 @item @emph{Description}:
3084 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
3085 converted to the real component.  If @var{Y} is present it is converted to the
3086 imaginary component.  If @var{Y} is not present then the imaginary component is
3087 set to 0.0.  If @var{X} is complex then @var{Y} must not be present.
3088
3089 @item @emph{Standard}:
3090 GNU extension
3091
3092 @item @emph{Class}:
3093 Elemental function
3094
3095 @item @emph{Syntax}:
3096 @code{RESULT = DCMPLX(X [, Y])}
3097
3098 @item @emph{Arguments}:
3099 @multitable @columnfractions .15 .70
3100 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
3101                    or @code{COMPLEX}.
3102 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
3103                    @code{INTEGER} or @code{REAL}. 
3104 @end multitable
3105
3106 @item @emph{Return value}:
3107 The return value is of type @code{COMPLEX(8)}
3108
3109 @item @emph{Example}:
3110 @smallexample
3111 program test_dcmplx
3112     integer :: i = 42
3113     real :: x = 3.14
3114     complex :: z
3115     z = cmplx(i, x)
3116     print *, dcmplx(i)
3117     print *, dcmplx(x)
3118     print *, dcmplx(z)
3119     print *, dcmplx(x,i)
3120 end program test_dcmplx
3121 @end smallexample
3122 @end table
3123
3124
3125
3126 @node DFLOAT
3127 @section @code{DFLOAT} --- Double conversion function 
3128 @fnindex DFLOAT
3129 @cindex conversion, to real
3130
3131 @table @asis
3132 @item @emph{Description}:
3133 @code{DFLOAT(A)} Converts @var{A} to double precision real type.
3134
3135 @item @emph{Standard}:
3136 GNU extension
3137
3138 @item @emph{Class}:
3139 Elemental function
3140
3141 @item @emph{Syntax}:
3142 @code{RESULT = DFLOAT(A)}
3143
3144 @item @emph{Arguments}:
3145 @multitable @columnfractions .15 .70
3146 @item @var{A} @tab The type shall be @code{INTEGER}.
3147 @end multitable
3148
3149 @item @emph{Return value}:
3150 The return value is of type double precision real.
3151
3152 @item @emph{Example}:
3153 @smallexample
3154 program test_dfloat
3155     integer :: i = 5
3156     print *, dfloat(i)
3157 end program test_dfloat
3158 @end smallexample
3159
3160 @item @emph{See also}:
3161 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
3162 @end table
3163
3164
3165
3166 @node DIGITS
3167 @section @code{DIGITS} --- Significant digits function
3168 @fnindex DIGITS
3169 @cindex model representation, significant digits
3170
3171 @table @asis
3172 @item @emph{Description}:
3173 @code{DIGITS(X)} returns the number of significant digits of the internal model
3174 representation of @var{X}.  For example, on a system using a 32-bit
3175 floating point representation, a default real number would likely return 24.
3176
3177 @item @emph{Standard}:
3178 Fortran 95 and later
3179
3180 @item @emph{Class}:
3181 Inquiry function
3182
3183 @item @emph{Syntax}:
3184 @code{RESULT = DIGITS(X)}
3185
3186 @item @emph{Arguments}:
3187 @multitable @columnfractions .15 .70
3188 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
3189 @end multitable
3190
3191 @item @emph{Return value}:
3192 The return value is of type @code{INTEGER}.
3193
3194 @item @emph{Example}:
3195 @smallexample
3196 program test_digits
3197     integer :: i = 12345
3198     real :: x = 3.143
3199     real(8) :: y = 2.33
3200     print *, digits(i)
3201     print *, digits(x)
3202     print *, digits(y)
3203 end program test_digits
3204 @end smallexample
3205 @end table
3206
3207
3208
3209 @node DIM
3210 @section @code{DIM} --- Positive difference
3211 @fnindex DIM
3212 @fnindex IDIM
3213 @fnindex DDIM
3214 @cindex positive difference
3215
3216 @table @asis
3217 @item @emph{Description}:
3218 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
3219 otherwise returns zero.
3220
3221 @item @emph{Standard}:
3222 Fortran 77 and later
3223
3224 @item @emph{Class}:
3225 Elemental function
3226
3227 @item @emph{Syntax}:
3228 @code{RESULT = DIM(X, Y)}
3229
3230 @item @emph{Arguments}:
3231 @multitable @columnfractions .15 .70
3232 @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
3233 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
3234 @end multitable
3235
3236 @item @emph{Return value}:
3237 The return value is of type @code{INTEGER} or @code{REAL}.
3238
3239 @item @emph{Example}:
3240 @smallexample
3241 program test_dim
3242     integer :: i
3243     real(8) :: x
3244     i = dim(4, 15)
3245     x = dim(4.345_8, 2.111_8)
3246     print *, i
3247     print *, x
3248 end program test_dim
3249 @end smallexample
3250
3251 @item @emph{Specific names}:
3252 @multitable @columnfractions .20 .20 .20 .25
3253 @item Name             @tab Argument              @tab Return type       @tab Standard
3254 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
3255 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y}    @tab @code{REAL(8)}    @tab Fortran 77 and later
3256 @end multitable
3257 @end table
3258
3259
3260
3261 @node DOT_PRODUCT
3262 @section @code{DOT_PRODUCT} --- Dot product function
3263 @fnindex DOT_PRODUCT
3264 @cindex dot product
3265 @cindex vector product
3266 @cindex product, vector
3267
3268 @table @asis
3269 @item @emph{Description}:
3270 @code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
3271 of two vectors @var{VECTOR_A} and @var{VECTOR_B}.  The two vectors may be
3272 either numeric or logical and must be arrays of rank one and of equal size. If
3273 the vectors are @code{INTEGER} or @code{REAL}, the result is
3274 @code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
3275 is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
3276 the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.  
3277
3278 @item @emph{Standard}:
3279 Fortran 95 and later
3280
3281 @item @emph{Class}:
3282 Transformational function
3283
3284 @item @emph{Syntax}:
3285 @code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
3286
3287 @item @emph{Arguments}:
3288 @multitable @columnfractions .15 .70
3289 @item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
3290 @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.
3291 @end multitable
3292
3293 @item @emph{Return value}:
3294 If the arguments are numeric, the return value is a scaler of numeric type,
3295 @code{INTEGER}, @code{REAL}, or @code{COMPLEX}.  If the arguments are
3296 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
3297
3298 @item @emph{Example}:
3299 @smallexample
3300 program test_dot_prod
3301     integer, dimension(3) :: a, b
3302     a = (/ 1, 2, 3 /)
3303     b = (/ 4, 5, 6 /)
3304     print '(3i3)', a
3305     print *
3306     print '(3i3)', b
3307     print *
3308     print *, dot_product(a,b)
3309 end program test_dot_prod
3310 @end smallexample
3311 @end table
3312
3313
3314
3315 @node DPROD
3316 @section @code{DPROD} --- Double product function
3317 @fnindex DPROD
3318 @cindex product, double-precision
3319
3320 @table @asis
3321 @item @emph{Description}:
3322 @code{DPROD(X,Y)} returns the product @code{X*Y}.
3323
3324 @item @emph{Standard}:
3325 Fortran 77 and later
3326
3327 @item @emph{Class}:
3328 Elemental function
3329
3330 @item @emph{Syntax}:
3331 @code{RESULT = DPROD(X, Y)}
3332
3333 @item @emph{Arguments}:
3334 @multitable @columnfractions .15 .70
3335 @item @var{X} @tab The type shall be @code{REAL}.
3336 @item @var{Y} @tab The type shall be @code{REAL}.
3337 @end multitable
3338
3339 @item @emph{Return value}:
3340 The return value is of type @code{REAL(8)}.
3341
3342 @item @emph{Example}:
3343 @smallexample
3344 program test_dprod
3345     real :: x = 5.2
3346     real :: y = 2.3
3347     real(8) :: d
3348     d = dprod(x,y)
3349     print *, d
3350 end program test_dprod
3351 @end smallexample
3352 @end table
3353
3354
3355
3356 @node DREAL
3357 @section @code{DREAL} --- Double real part function
3358 @fnindex DREAL
3359 @cindex complex numbers, real part
3360
3361 @table @asis
3362 @item @emph{Description}:
3363 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
3364
3365 @item @emph{Standard}:
3366 GNU extension
3367
3368 @item @emph{Class}:
3369 Elemental function
3370
3371 @item @emph{Syntax}:
3372 @code{RESULT = DREAL(A)}
3373
3374 @item @emph{Arguments}:
3375 @multitable @columnfractions .15 .70
3376 @item @var{A} @tab The type shall be @code{COMPLEX(8)}.
3377 @end multitable
3378
3379 @item @emph{Return value}:
3380 The return value is of type @code{REAL(8)}.
3381
3382 @item @emph{Example}:
3383 @smallexample
3384 program test_dreal
3385     complex(8) :: z = (1.3_8,7.2_8)
3386     print *, dreal(z)
3387 end program test_dreal
3388 @end smallexample
3389
3390 @item @emph{See also}:
3391 @ref{AIMAG}
3392
3393 @end table
3394
3395
3396
3397 @node DTIME
3398 @section @code{DTIME} --- Execution time subroutine (or function)
3399 @fnindex DTIME
3400 @cindex time, elapsed
3401 @cindex elapsed time
3402
3403 @table @asis
3404 @item @emph{Description}:
3405 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
3406 since the start of the process's execution in @var{RESULT}.  @var{TARRAY}
3407 returns the user and system components of this time in @code{TARRAY(1)} and
3408 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
3409 TARRAY(2)}.
3410
3411 Subsequent invocations of @code{DTIME} return values accumulated since the
3412 previous invocation.
3413
3414 On some systems, the underlying timings are represented using types with
3415 sufficiently small limits that overflows (wrap around) are possible, such as
3416 32-bit types. Therefore, the values returned by this intrinsic might be, or
3417 become, negative, or numerically less than previous values, during a single
3418 run of the compiled program.
3419
3420 Please note, that this implementation is thread safe if used within OpenMP
3421 directives, i.e., its state will be consistent while called from multiple
3422 threads. However, if @code{DTIME} is called from multiple threads, the result
3423 is still the time since the last invocation. This may not give the intended
3424 results. If possible, use @code{CPU_TIME} instead.
3425
3426 This intrinsic is provided in both subroutine and function forms; however,
3427 only one form can be used in any given program unit.
3428
3429 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3430
3431 @multitable @columnfractions .15 .30 .40
3432 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3433 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3434 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3435 @end multitable
3436
3437 @item @emph{Standard}:
3438 GNU extension
3439
3440 @item @emph{Class}:
3441 Subroutine, function
3442
3443 @item @emph{Syntax}:
3444 @multitable @columnfractions .80
3445 @item @code{CALL DTIME(TARRAY, RESULT)}.
3446 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
3447 @end multitable
3448
3449 @item @emph{Arguments}:
3450 @multitable @columnfractions .15 .70
3451 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3452 @item @var{RESULT}@tab The type shall be @code{REAL}.
3453 @end multitable
3454
3455 @item @emph{Return value}:
3456 Elapsed time in seconds since the last invocation or since the start of program
3457 execution if not called before.
3458
3459 @item @emph{Example}:
3460 @smallexample
3461 program test_dtime
3462     integer(8) :: i, j
3463     real, dimension(2) :: tarray
3464     real :: result
3465     call dtime(tarray, result)
3466     print *, result
3467     print *, tarray(1)
3468     print *, tarray(2)   
3469     do i=1,100000000    ! Just a delay
3470         j = i * i - i
3471     end do
3472     call dtime(tarray, result)
3473     print *, result
3474     print *, tarray(1)
3475     print *, tarray(2)
3476 end program test_dtime
3477 @end smallexample
3478
3479 @item @emph{See also}:
3480 @ref{CPU_TIME}
3481
3482 @end table
3483
3484
3485
3486 @node EOSHIFT
3487 @section @code{EOSHIFT} --- End-off shift elements of an array
3488 @fnindex EOSHIFT
3489 @cindex array, shift
3490
3491 @table @asis
3492 @item @emph{Description}:
3493 @code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
3494 elements of @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is
3495 omitted it is taken to be @code{1}.  @var{DIM} is a scaler of type
3496 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
3497 rank of @var{ARRAY}.  If the rank of @var{ARRAY} is one, then all elements of
3498 @var{ARRAY} are shifted by @var{SHIFT} places.  If rank is greater than one,
3499 then all complete rank one sections of @var{ARRAY} along the given dimension are
3500 shifted.  Elements shifted out one end of each rank one section are dropped.  If
3501 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
3502 is copied back in the other end.  If @var{BOUNDARY} is not present then the
3503 following are copied in depending on the type of @var{ARRAY}.
3504
3505 @multitable @columnfractions .15 .80
3506 @item @emph{Array Type} @tab @emph{Boundary Value}
3507 @item Numeric  @tab 0 of the type and kind of @var{ARRAY}.
3508 @item Logical  @tab @code{.FALSE.}.
3509 @item Character(@var{len}) @tab @var{len} blanks.
3510 @end multitable
3511
3512 @item @emph{Standard}:
3513 Fortran 95 and later
3514
3515 @item @emph{Class}:
3516 Transformational function
3517
3518 @item @emph{Syntax}:
3519 @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
3520
3521 @item @emph{Arguments}:
3522 @multitable @columnfractions .15 .70
3523 @item @var{ARRAY}  @tab May be any type, not scaler.
3524 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
3525 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}. 
3526 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
3527 @end multitable
3528
3529 @item @emph{Return value}:
3530 Returns an array of same type and rank as the @var{ARRAY} argument.
3531
3532 @item @emph{Example}:
3533 @smallexample
3534 program test_eoshift
3535     integer, dimension(3,3) :: a
3536     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3537     print '(3i3)', a(1,:)
3538     print '(3i3)', a(2,:)
3539     print '(3i3)', a(3,:)    
3540     a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3541     print *
3542     print '(3i3)', a(1,:)
3543     print '(3i3)', a(2,:)
3544     print '(3i3)', a(3,:)
3545 end program test_eoshift
3546 @end smallexample
3547 @end table
3548
3549
3550
3551 @node EPSILON
3552 @section @code{EPSILON} --- Epsilon function
3553 @fnindex EPSILON
3554 @cindex model representation, epsilon
3555
3556 @table @asis
3557 @item @emph{Description}:
3558 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3559
3560 @item @emph{Standard}:
3561 Fortran 95 and later
3562
3563 @item @emph{Class}:
3564 Inquiry function
3565
3566 @item @emph{Syntax}:
3567 @code{RESULT = EPSILON(X)}
3568
3569 @item @emph{Arguments}:
3570 @multitable @columnfractions .15 .70
3571 @item @var{X} @tab The type shall be @code{REAL}.
3572 @end multitable
3573
3574 @item @emph{Return value}:
3575 The return value is of same type as the argument.
3576
3577 @item @emph{Example}:
3578 @smallexample
3579 program test_epsilon
3580     real :: x = 3.143
3581     real(8) :: y = 2.33
3582     print *, EPSILON(x)
3583     print *, EPSILON(y)
3584 end program test_epsilon
3585 @end smallexample
3586 @end table
3587
3588
3589
3590 @node ERF
3591 @section @code{ERF} --- Error function 
3592 @fnindex ERF
3593 @cindex error function
3594
3595 @table @asis
3596 @item @emph{Description}:
3597 @code{ERF(X)} computes the error function of @var{X}.
3598
3599 @item @emph{Standard}:
3600 Fortran 2008 and later
3601
3602 @item @emph{Class}:
3603 Elemental function
3604
3605 @item @emph{Syntax}:
3606 @code{RESULT = ERF(X)}
3607
3608 @item @emph{Arguments}:
3609 @multitable @columnfractions .15 .70
3610 @item @var{X} @tab The type shall be @code{REAL}.
3611 @end multitable
3612
3613 @item @emph{Return value}:
3614 The return value is of type @code{REAL}, of the same kind as
3615 @var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
3616
3617 @item @emph{Example}:
3618 @smallexample
3619 program test_erf
3620   real(8) :: x = 0.17_8
3621   x = erf(x)
3622 end program test_erf
3623 @end smallexample
3624
3625 @item @emph{Specific names}:
3626 @multitable @columnfractions .20 .20 .20 .25
3627 @item Name            @tab Argument          @tab Return type       @tab Standard
3628 @item @code{DERF(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
3629 @end multitable
3630 @end table
3631
3632
3633
3634 @node ERFC
3635 @section @code{ERFC} --- Error function 
3636 @fnindex ERFC
3637 @cindex error function, complementary
3638
3639 @table @asis
3640 @item @emph{Description}:
3641 @code{ERFC(X)} computes the complementary error function of @var{X}.
3642
3643 @item @emph{Standard}:
3644 Fortran 2008 and later
3645
3646 @item @emph{Class}:
3647 Elemental function
3648
3649 @item @emph{Syntax}:
3650 @code{RESULT = ERFC(X)}
3651
3652 @item @emph{Arguments}:
3653 @multitable @columnfractions .15 .70
3654 @item @var{X} @tab The type shall be @code{REAL}.
3655 @end multitable
3656
3657 @item @emph{Return value}:
3658 The return value is of type @code{REAL} and of the same kind as @var{X}.
3659 It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
3660
3661 @item @emph{Example}:
3662 @smallexample
3663 program test_erfc
3664   real(8) :: x = 0.17_8
3665   x = erfc(x)
3666 end program test_erfc
3667 @end smallexample
3668
3669 @item @emph{Specific names}:
3670 @multitable @columnfractions .20 .20 .20 .25
3671 @item Name            @tab Argument          @tab Return type       @tab Standard
3672 @item @code{DERFC(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
3673 @end multitable
3674 @end table
3675
3676
3677
3678 @node ERFC_SCALED
3679 @section @code{ERFC_SCALED} --- Error function 
3680 @fnindex ERFC_SCALED
3681 @cindex error function, complementary, exponentially-scaled
3682
3683 @table @asis
3684 @item @emph{Description}:
3685 @code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
3686 error function of @var{X}.
3687
3688 @item @emph{Standard}:
3689 Fortran 2008 and later
3690
3691 @item @emph{Class}:
3692 Elemental function
3693
3694 @item @emph{Syntax}:
3695 @code{RESULT = ERFC_SCALED(X)}
3696
3697 @item @emph{Arguments}:
3698 @multitable @columnfractions .15 .70
3699 @item @var{X} @tab The type shall be @code{REAL}.
3700 @end multitable
3701
3702 @item @emph{Return value}:
3703 The return value is of type @code{REAL} and of the same kind as @var{X}.
3704
3705 @item @emph{Example}:
3706 @smallexample
3707 program test_erfc_scaled
3708   real(8) :: x = 0.17_8
3709   x = erfc_scaled(x)
3710 end program test_erfc_scaled
3711 @end smallexample
3712 @end table
3713
3714
3715
3716 @node ETIME
3717 @section @code{ETIME} --- Execution time subroutine (or function)
3718 @fnindex ETIME
3719 @cindex time, elapsed
3720
3721 @table @asis
3722 @item @emph{Description}:
3723 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3724 since the start of the process's execution in @var{RESULT}.  @var{TARRAY}
3725 returns the user and system components of this time in @code{TARRAY(1)} and
3726 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3727
3728 On some systems, the underlying timings are represented using types with
3729 sufficiently small limits that overflows (wrap around) are possible, such as
3730 32-bit types. Therefore, the values returned by this intrinsic might be, or
3731 become, negative, or numerically less than previous values, during a single
3732 run of the compiled program.
3733
3734 This intrinsic is provided in both subroutine and function forms; however,
3735 only one form can be used in any given program unit.
3736
3737 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3738
3739 @multitable @columnfractions .15 .30 .60
3740 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3741 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3742 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3743 @end multitable
3744
3745 @item @emph{Standard}:
3746 GNU extension
3747
3748 @item @emph{Class}:
3749 Subroutine, function
3750
3751 @item @emph{Syntax}:
3752 @multitable @columnfractions .80
3753 @item @code{CALL ETIME(TARRAY, RESULT)}.
3754 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3755 @end multitable
3756
3757 @item @emph{Arguments}:
3758 @multitable @columnfractions .15 .70
3759 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3760 @item @var{RESULT}@tab The type shall be @code{REAL}.
3761 @end multitable
3762
3763 @item @emph{Return value}:
3764 Elapsed time in seconds since the start of program execution.
3765
3766 @item @emph{Example}:
3767 @smallexample
3768 program test_etime
3769     integer(8) :: i, j
3770     real, dimension(2) :: tarray
3771     real :: result
3772     call ETIME(tarray, result)
3773     print *, result
3774     print *, tarray(1)
3775     print *, tarray(2)   
3776     do i=1,100000000    ! Just a delay
3777         j = i * i - i
3778     end do
3779     call ETIME(tarray, result)
3780     print *, result
3781     print *, tarray(1)
3782     print *, tarray(2)
3783 end program test_etime
3784 @end smallexample
3785
3786 @item @emph{See also}:
3787 @ref{CPU_TIME}
3788
3789 @end table
3790
3791
3792
3793 @node EXIT
3794 @section @code{EXIT} --- Exit the program with status. 
3795 @fnindex EXIT
3796 @cindex program termination
3797 @cindex terminate program
3798
3799 @table @asis
3800 @item @emph{Description}:
3801 @code{EXIT} causes immediate termination of the program with status.  If status
3802 is omitted it returns the canonical @emph{success} for the system.  All Fortran
3803 I/O units are closed. 
3804
3805 @item @emph{Standard}:
3806 GNU extension
3807
3808 @item @emph{Class}:
3809 Subroutine
3810
3811 @item @emph{Syntax}:
3812 @code{CALL EXIT([STATUS])}
3813
3814 @item @emph{Arguments}:
3815 @multitable @columnfractions .15 .70
3816 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
3817 @end multitable
3818
3819 @item @emph{Return value}:
3820 @code{STATUS} is passed to the parent process on exit.
3821
3822 @item @emph{Example}:
3823 @smallexample
3824 program test_exit
3825   integer :: STATUS = 0
3826   print *, 'This program is going to exit.'
3827   call EXIT(STATUS)
3828 end program test_exit
3829 @end smallexample
3830
3831 @item @emph{See also}:
3832 @ref{ABORT}, @ref{KILL}
3833 @end table
3834
3835
3836
3837 @node EXP
3838 @section @code{EXP} --- Exponential function 
3839 @fnindex EXP
3840 @fnindex DEXP
3841 @fnindex CEXP
3842 @fnindex ZEXP
3843 @fnindex CDEXP
3844 @cindex exponential function
3845 @cindex logarithmic function, inverse
3846
3847 @table @asis
3848 @item @emph{Description}:
3849 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3850
3851 @item @emph{Standard}:
3852 Fortran 77 and later, has overloads that are GNU extensions
3853
3854 @item @emph{Class}:
3855 Elemental function
3856
3857 @item @emph{Syntax}:
3858 @code{RESULT = EXP(X)}
3859
3860 @item @emph{Arguments}:
3861 @multitable @columnfractions .15 .70
3862 @item @var{X} @tab The type shall be @code{REAL} or
3863 @code{COMPLEX}.
3864 @end multitable
3865
3866 @item @emph{Return value}:
3867 The return value has same type and kind as @var{X}.
3868
3869 @item @emph{Example}:
3870 @smallexample
3871 program test_exp
3872   real :: x = 1.0
3873   x = exp(x)
3874 end program test_exp
3875 @end smallexample
3876
3877 @item @emph{Specific names}:
3878 @multitable @columnfractions .20 .20 .20 .25
3879 @item Name            @tab Argument             @tab Return type         @tab Standard
3880 @item @code{DEXP(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}      @tab Fortran 77 and later
3881 @item @code{CEXP(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}   @tab Fortran 77 and later
3882 @item @code{ZEXP(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
3883 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
3884 @end multitable
3885 @end table
3886
3887
3888
3889 @node EXPONENT
3890 @section @code{EXPONENT} --- Exponent function 
3891 @fnindex EXPONENT
3892 @cindex real number, exponent
3893 @cindex floating point, exponent
3894
3895 @table @asis
3896 @item @emph{Description}:
3897 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3898 is zero the value returned is zero. 
3899
3900 @item @emph{Standard}:
3901 Fortran 95 and later
3902
3903 @item @emph{Class}:
3904 Elemental function
3905
3906 @item @emph{Syntax}:
3907 @code{RESULT = EXPONENT(X)}
3908
3909 @item @emph{Arguments}:
3910 @multitable @columnfractions .15 .70
3911 @item @var{X} @tab The type shall be @code{REAL}.
3912 @end multitable
3913
3914 @item @emph{Return value}:
3915 The return value is of type default @code{INTEGER}.
3916
3917 @item @emph{Example}:
3918 @smallexample
3919 program test_exponent
3920   real :: x = 1.0
3921   integer :: i
3922   i = exponent(x)
3923   print *, i
3924   print *, exponent(0.0)
3925 end program test_exponent
3926 @end smallexample
3927 @end table
3928
3929
3930
3931 @node FDATE
3932 @section @code{FDATE} --- Get the current time as a string
3933 @fnindex FDATE
3934 @cindex time, current
3935 @cindex current time
3936 @cindex date, current
3937 @cindex current date
3938
3939 @table @asis
3940 @item @emph{Description}:
3941 @code{FDATE(DATE)} returns the current date (using the same format as
3942 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3943 TIME())}.
3944
3945 This intrinsic is provided in both subroutine and function forms; however,
3946 only one form can be used in any given program unit.
3947
3948 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable of the
3949 default kind.
3950
3951 @item @emph{Standard}:
3952 GNU extension
3953
3954 @item @emph{Class}:
3955 Subroutine, function
3956
3957 @item @emph{Syntax}:
3958 @multitable @columnfractions .80
3959 @item @code{CALL FDATE(DATE)}.
3960 @item @code{DATE = FDATE()}, (not recommended).
3961 @end multitable
3962
3963 @item @emph{Arguments}:
3964 @multitable @columnfractions .15 .70
3965 @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
3966 default kind
3967 @end multitable
3968
3969 @item @emph{Return value}:
3970 The current date as a string.
3971
3972 @item @emph{Example}:
3973 @smallexample
3974 program test_fdate
3975     integer(8) :: i, j
3976     character(len=30) :: date
3977     call fdate(date)
3978     print *, 'Program started on ', date
3979     do i = 1, 100000000 ! Just a delay
3980         j = i * i - i
3981     end do
3982     call fdate(date)
3983     print *, 'Program ended on ', date
3984 end program test_fdate
3985 @end smallexample
3986 @end table
3987
3988
3989
3990 @node FLOAT
3991 @section @code{FLOAT} --- Convert integer to default real
3992 @fnindex FLOAT
3993 @cindex conversion, to real
3994
3995 @table @asis
3996 @item @emph{Description}:
3997 @code{FLOAT(A)} converts the integer @var{A} to a default real value.
3998
3999 @item @emph{Standard}:
4000 Fortran 77 and later
4001
4002 @item @emph{Class}:
4003 Elemental function
4004
4005 @item @emph{Syntax}:
4006 @code{RESULT = FLOAT(A)}
4007
4008 @item @emph{Arguments}:
4009 @multitable @columnfractions .15 .70
4010 @item @var{A} @tab The type shall be @code{INTEGER}.
4011 @end multitable
4012
4013 @item @emph{Return value}:
4014 The return value is of type default @code{REAL}.
4015
4016 @item @emph{Example}:
4017 @smallexample
4018 program test_float
4019     integer :: i = 1
4020     if (float(i) /= 1.) call abort
4021 end program test_float
4022 @end smallexample
4023
4024 @item @emph{See also}:
4025 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
4026 @end table
4027
4028
4029
4030 @node FGET
4031 @section @code{FGET} --- Read a single character in stream mode from stdin 
4032 @fnindex FGET
4033 @cindex read character, stream mode
4034 @cindex stream mode, read character
4035 @cindex file operation, read character
4036
4037 @table @asis
4038 @item @emph{Description}:
4039 Read a single character in stream mode from stdin by bypassing normal 
4040 formatted output. Stream I/O should not be mixed with normal record-oriented 
4041 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4042
4043 This intrinsic is provided in both subroutine and function forms; however,
4044 only one form can be used in any given program unit.
4045
4046 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4047 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4048 Programmers should consider the use of new stream IO feature in new code 
4049 for future portability. See also @ref{Fortran 2003 status}.
4050
4051 @item @emph{Standard}:
4052 GNU extension
4053
4054 @item @emph{Class}:
4055 Subroutine, function
4056
4057 @item @emph{Syntax}:
4058 @code{CALL FGET(C [, STATUS])}
4059
4060 @item @emph{Arguments}:
4061 @multitable @columnfractions .15 .70
4062 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4063                         kind.
4064 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4065                         Returns 0 on success, -1 on end-of-file, and a
4066                         system specific positive error code otherwise.
4067 @end multitable
4068
4069 @item @emph{Example}:
4070 @smallexample
4071 PROGRAM test_fget
4072   INTEGER, PARAMETER :: strlen = 100
4073   INTEGER :: status, i = 1
4074   CHARACTER(len=strlen) :: str = ""
4075
4076   WRITE (*,*) 'Enter text:'
4077   DO
4078     CALL fget(str(i:i), status)
4079     if (status /= 0 .OR. i > strlen) exit
4080     i = i + 1
4081   END DO
4082   WRITE (*,*) TRIM(str)
4083 END PROGRAM
4084 @end smallexample
4085
4086 @item @emph{See also}:
4087 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
4088 @end table
4089
4090
4091
4092 @node FGETC
4093 @section @code{FGETC} --- Read a single character in stream mode
4094 @fnindex FGETC
4095 @cindex read character, stream mode
4096 @cindex stream mode, read character
4097 @cindex file operation, read character
4098
4099 @table @asis
4100 @item @emph{Description}:
4101 Read a single character in stream mode by bypassing normal formatted output. 
4102 Stream I/O should not be mixed with normal record-oriented (formatted or 
4103 unformatted) I/O on the same unit; the results are unpredictable.
4104
4105 This intrinsic is provided in both subroutine and function forms; however,
4106 only one form can be used in any given program unit.
4107
4108 Note that the @code{FGET} intrinsic is provided for backwards compatibility
4109 with @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4110 Programmers should consider the use of new stream IO feature in new code 
4111 for future portability. See also @ref{Fortran 2003 status}.
4112
4113 @item @emph{Standard}:
4114 GNU extension
4115
4116 @item @emph{Class}:
4117 Subroutine, function
4118
4119 @item @emph{Syntax}:
4120 @code{CALL FGETC(UNIT, C [, STATUS])}
4121
4122 @item @emph{Arguments}:
4123 @multitable @columnfractions .15 .70
4124 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4125 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4126                         kind.
4127 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4128                         Returns 0 on success, -1 on end-of-file and a
4129                         system specific positive error code otherwise.
4130 @end multitable
4131
4132 @item @emph{Example}:
4133 @smallexample
4134 PROGRAM test_fgetc
4135   INTEGER :: fd = 42, status
4136   CHARACTER :: c
4137
4138   OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
4139   DO
4140     CALL fgetc(fd, c, status)
4141     IF (status /= 0) EXIT
4142     call fput(c)
4143   END DO
4144   CLOSE(UNIT=fd)
4145 END PROGRAM
4146 @end smallexample
4147
4148 @item @emph{See also}:
4149 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
4150 @end table
4151
4152
4153
4154 @node FLOOR
4155 @section @code{FLOOR} --- Integer floor function
4156 @fnindex FLOOR
4157 @cindex floor
4158 @cindex rounding, floor
4159
4160 @table @asis
4161 @item @emph{Description}:
4162 @code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
4163
4164 @item @emph{Standard}:
4165 Fortran 95 and later
4166
4167 @item @emph{Class}:
4168 Elemental function
4169
4170 @item @emph{Syntax}:
4171 @code{RESULT = FLOOR(A [, KIND])}
4172
4173 @item @emph{Arguments}:
4174 @multitable @columnfractions .15 .70
4175 @item @var{A} @tab The type shall be @code{REAL}.
4176 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
4177                       expression indicating the kind parameter of
4178                       the result.
4179 @end multitable
4180
4181 @item @emph{Return value}:
4182 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
4183 and of default-kind @code{INTEGER} otherwise.
4184
4185 @item @emph{Example}:
4186 @smallexample
4187 program test_floor
4188     real :: x = 63.29
4189     real :: y = -63.59
4190     print *, floor(x) ! returns 63
4191     print *, floor(y) ! returns -64
4192 end program test_floor
4193 @end smallexample
4194
4195 @item @emph{See also}:
4196 @ref{CEILING}, @ref{NINT}
4197
4198 @end table
4199
4200
4201
4202 @node FLUSH
4203 @section @code{FLUSH} --- Flush I/O unit(s)
4204 @fnindex FLUSH
4205 @cindex file operation, flush
4206
4207 @table @asis
4208 @item @emph{Description}:
4209 Flushes Fortran unit(s) currently open for output. Without the optional
4210 argument, all units are flushed, otherwise just the unit specified.
4211
4212 @item @emph{Standard}:
4213 GNU extension
4214
4215 @item @emph{Class}:
4216 Subroutine
4217
4218 @item @emph{Syntax}:
4219 @code{CALL FLUSH(UNIT)}
4220
4221 @item @emph{Arguments}:
4222 @multitable @columnfractions .15 .70
4223 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
4224 @end multitable
4225
4226 @item @emph{Note}:
4227 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
4228 statement that should be preferred over the @code{FLUSH} intrinsic.
4229
4230 @end table
4231
4232
4233
4234 @node FNUM
4235 @section @code{FNUM} --- File number function
4236 @fnindex FNUM
4237 @cindex file operation, file number
4238
4239 @table @asis
4240 @item @emph{Description}:
4241 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
4242 open Fortran I/O unit @code{UNIT}.
4243
4244 @item @emph{Standard}:
4245 GNU extension
4246
4247 @item @emph{Class}:
4248 Function
4249
4250 @item @emph{Syntax}:
4251 @code{RESULT = FNUM(UNIT)}
4252
4253 @item @emph{Arguments}:
4254 @multitable @columnfractions .15 .70
4255 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
4256 @end multitable
4257
4258 @item @emph{Return value}:
4259 The return value is of type @code{INTEGER}
4260
4261 @item @emph{Example}:
4262 @smallexample
4263 program test_fnum
4264   integer :: i
4265   open (unit=10, status = "scratch")
4266   i = fnum(10)
4267   print *, i
4268   close (10)
4269 end program test_fnum
4270 @end smallexample
4271 @end table
4272
4273
4274
4275 @node FPUT
4276 @section @code{FPUT} --- Write a single character in stream mode to stdout 
4277 @fnindex FPUT
4278 @cindex write character, stream mode
4279 @cindex stream mode, write character
4280 @cindex file operation, write character
4281
4282 @table @asis
4283 @item @emph{Description}:
4284 Write a single character in stream mode to stdout by bypassing normal 
4285 formatted output. Stream I/O should not be mixed with normal record-oriented 
4286 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4287
4288 This intrinsic is provided in both subroutine and function forms; however,
4289 only one form can be used in any given program unit.
4290
4291 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4292 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4293 Programmers should consider the use of new stream IO feature in new code 
4294 for future portability. See also @ref{Fortran 2003 status}.
4295
4296 @item @emph{Standard}:
4297 GNU extension
4298
4299 @item @emph{Class}:
4300 Subroutine, function
4301
4302 @item @emph{Syntax}:
4303 @code{CALL FPUT(C [, STATUS])}
4304
4305 @item @emph{Arguments}:
4306 @multitable @columnfractions .15 .70
4307 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4308                         kind.
4309 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4310                         Returns 0 on success, -1 on end-of-file and a
4311                         system specific positive error code otherwise.
4312 @end multitable
4313
4314 @item @emph{Example}:
4315 @smallexample
4316 PROGRAM test_fput
4317   CHARACTER(len=10) :: str = "gfortran"
4318   INTEGER :: i
4319   DO i = 1, len_trim(str)
4320     CALL fput(str(i:i))
4321   END DO
4322 END PROGRAM
4323 @end smallexample
4324
4325 @item @emph{See also}:
4326 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
4327 @end table
4328
4329
4330
4331 @node FPUTC
4332 @section @code{FPUTC} --- Write a single character in stream mode
4333 @fnindex FPUTC
4334 @cindex write character, stream mode
4335 @cindex stream mode, write character
4336 @cindex file operation, write character
4337
4338 @table @asis
4339 @item @emph{Description}:
4340 Write a single character in stream mode by bypassing normal formatted 
4341 output. Stream I/O should not be mixed with normal record-oriented 
4342 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4343
4344 This intrinsic is provided in both subroutine and function forms; however,
4345 only one form can be used in any given program unit.
4346
4347 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4348 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4349 Programmers should consider the use of new stream IO feature in new code 
4350 for future portability. See also @ref{Fortran 2003 status}.
4351
4352 @item @emph{Standard}:
4353 GNU extension
4354
4355 @item @emph{Class}:
4356 Subroutine, function
4357
4358 @item @emph{Syntax}:
4359 @code{CALL FPUTC(UNIT, C [, STATUS])}
4360
4361 @item @emph{Arguments}:
4362 @multitable @columnfractions .15 .70
4363 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4364 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4365                         kind.
4366 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4367                         Returns 0 on success, -1 on end-of-file and a
4368                         system specific positive error code otherwise.
4369 @end multitable
4370
4371 @item @emph{Example}:
4372 @smallexample
4373 PROGRAM test_fputc
4374   CHARACTER(len=10) :: str = "gfortran"
4375   INTEGER :: fd = 42, i
4376
4377   OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
4378   DO i = 1, len_trim(str)
4379     CALL fputc(fd, str(i:i))
4380   END DO
4381   CLOSE(fd)
4382 END PROGRAM
4383 @end smallexample
4384
4385 @item @emph{See also}:
4386 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
4387 @end table
4388
4389
4390
4391 @node FRACTION
4392 @section @code{FRACTION} --- Fractional part of the model representation
4393 @fnindex FRACTION
4394 @cindex real number, fraction
4395 @cindex floating point, fraction
4396
4397 @table @asis
4398 @item @emph{Description}:
4399 @code{FRACTION(X)} returns the fractional part of the model
4400 representation of @code{X}.
4401
4402 @item @emph{Standard}:
4403 Fortran 95 and later
4404
4405 @item @emph{Class}:
4406 Elemental function
4407
4408 @item @emph{Syntax}:
4409 @code{Y = FRACTION(X)}
4410
4411 @item @emph{Arguments}:
4412 @multitable @columnfractions .15 .70
4413 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
4414 @end multitable
4415
4416 @item @emph{Return value}:
4417 The return value is of the same type and kind as the argument.
4418 The fractional part of the model representation of @code{X} is returned;
4419 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
4420
4421 @item @emph{Example}:
4422 @smallexample
4423 program test_fraction
4424   real :: x
4425   x = 178.1387e-4
4426   print *, fraction(x), x * radix(x)**(-exponent(x))
4427 end program test_fraction
4428 @end smallexample
4429
4430 @end table
4431
4432
4433
4434 @node FREE
4435 @section @code{FREE} --- Frees memory
4436 @fnindex FREE
4437 @cindex pointer, cray
4438
4439 @table @asis
4440 @item @emph{Description}:
4441 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
4442 intrinsic is an extension intended to be used with Cray pointers, and is
4443 provided in GNU Fortran to allow user to compile legacy code. For
4444 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
4445 @code{DEALLOCATE}.
4446
4447 @item @emph{Standard}:
4448 GNU extension
4449
4450 @item @emph{Class}:
4451 Subroutine
4452
4453 @item @emph{Syntax}:
4454 @code{CALL FREE(PTR)}
4455
4456 @item @emph{Arguments}:
4457 @multitable @columnfractions .15 .70
4458 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
4459 location of the memory that should be de-allocated.
4460 @end multitable
4461
4462 @item @emph{Return value}:
4463 None
4464
4465 @item @emph{Example}:
4466 See @code{MALLOC} for an example.
4467
4468 @item @emph{See also}:
4469 @ref{MALLOC}
4470 @end table
4471
4472
4473
4474 @node FSEEK
4475 @section @code{FSEEK} --- Low level file positioning subroutine
4476 @fnindex FSEEK
4477 @cindex file operation, seek
4478 @cindex file operation, position
4479
4480 @table @asis
4481 @item @emph{Description}:
4482 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE} 
4483 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
4484 if set to 1, @var{OFFSET} is taken to be relative to the current position 
4485 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
4486 On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek 
4487 fails silently.
4488
4489 This intrinsic routine is not fully backwards compatible with @command{g77}. 
4490 In @command{g77}, the @code{FSEEK} takes a statement label instead of a 
4491 @var{STATUS} variable. If FSEEK is used in old code, change
4492 @smallexample
4493   CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
4494 @end smallexample 
4495 to
4496 @smallexample
4497   INTEGER :: status
4498   CALL FSEEK(UNIT, OFFSET, WHENCE, status)
4499   IF (status /= 0) GOTO label
4500 @end smallexample 
4501
4502 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
4503 Programmers should consider the use of new stream IO feature in new code 
4504 for future portability. See also @ref{Fortran 2003 status}.
4505
4506 @item @emph{Standard}:
4507 GNU extension
4508
4509 @item @emph{Class}:
4510 Subroutine
4511
4512 @item @emph{Syntax}:
4513 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
4514
4515 @item @emph{Arguments}:
4516 @multitable @columnfractions .15 .70
4517 @item @var{UNIT}   @tab Shall be a scalar of type @code{INTEGER}.
4518 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
4519 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
4520 Its value shall be either 0, 1 or 2.
4521 @item @var{STATUS} @tab (Optional) shall be a scalar of type 
4522 @code{INTEGER(4)}.
4523 @end multitable
4524
4525 @item @emph{Example}:
4526 @smallexample
4527 PROGRAM test_fseek
4528   INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
4529   INTEGER :: fd, offset, ierr
4530
4531   ierr   = 0
4532   offset = 5
4533   fd     = 10
4534
4535   OPEN(UNIT=fd, FILE="fseek.test")
4536   CALL FSEEK(fd, offset, SEEK_SET, ierr)  ! move to OFFSET
4537   print *, FTELL(fd), ierr
4538
4539   CALL FSEEK(fd, 0, SEEK_END, ierr)       ! move to end
4540   print *, FTELL(fd), ierr
4541
4542   CALL FSEEK(fd, 0, SEEK_SET, ierr)       ! move to beginning
4543   print *, FTELL(fd), ierr
4544
4545   CLOSE(UNIT=fd)
4546 END PROGRAM
4547 @end smallexample
4548
4549 @item @emph{See also}:
4550 @ref{FTELL}
4551 @end table
4552
4553
4554
4555 @node FSTAT
4556 @section @code{FSTAT} --- Get file status
4557 @fnindex FSTAT
4558 @cindex file system, file status
4559
4560 @table @asis
4561 @item @emph{Description}:
4562 @code{FSTAT} is identical to @ref{STAT}, except that information about an 
4563 already opened file is obtained.
4564
4565 The elements in @code{BUFF} are the same as described by @ref{STAT}.
4566
4567 This intrinsic is provided in both subroutine and function forms; however,
4568 only one form can be used in any given program unit.
4569
4570 @item @emph{Standard}:
4571 GNU extension
4572
4573 @item @emph{Class}:
4574 Subroutine, function
4575
4576 @item @emph{Syntax}:
4577 @code{CALL FSTAT(UNIT, BUFF [, STATUS])}
4578
4579 @item @emph{Arguments}:
4580 @multitable @columnfractions .15 .70
4581 @item @var{UNIT}   @tab An open I/O unit number of type @code{INTEGER}.
4582 @item @var{BUFF}   @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
4583 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
4584                         on success and a system specific error code otherwise.
4585 @end multitable
4586
4587 @item @emph{Example}:
4588 See @ref{STAT} for an example.
4589
4590 @item @emph{See also}:
4591 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
4592 @end table
4593
4594
4595
4596 @node FTELL
4597 @section @code{FTELL} --- Current stream position
4598 @fnindex FTELL
4599 @cindex file operation, position
4600
4601 @table @asis
4602 @item @emph{Description}:
4603 Retrieves the current position within an open file.
4604
4605 This intrinsic is provided in both subroutine and function forms; however,
4606 only one form can be used in any given program unit.
4607
4608 @item @emph{Standard}:
4609 GNU extension
4610
4611 @item @emph{Class}:
4612 Subroutine, function
4613
4614 @item @emph{Syntax}:
4615 @multitable @columnfractions .80
4616 @item @code{CALL FTELL(UNIT, OFFSET)}
4617 @item @code{OFFSET = FTELL(UNIT)}
4618 @end multitable
4619
4620 @item @emph{Arguments}:
4621 @multitable @columnfractions .15 .70
4622 @item @var{OFFSET}  @tab Shall of type @code{INTEGER}.
4623 @item @var{UNIT}    @tab Shall of type @code{INTEGER}.
4624 @end multitable
4625
4626 @item @emph{Return value}:
4627 In either syntax, @var{OFFSET} is set to the current offset of unit
4628 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
4629
4630 @item @emph{Example}:
4631 @smallexample
4632 PROGRAM test_ftell
4633   INTEGER :: i
4634   OPEN(10, FILE="temp.dat")
4635   CALL ftell(10,i)
4636   WRITE(*,*) i
4637 END PROGRAM
4638 @end smallexample
4639
4640 @item @emph{See also}:
4641 @ref{FSEEK}
4642 @end table
4643
4644
4645
4646 @node GAMMA
4647 @section @code{GAMMA} --- Gamma function
4648 @fnindex GAMMA
4649 @fnindex DGAMMA
4650 @cindex Gamma function
4651 @cindex Factorial function
4652
4653 @table @asis
4654 @item @emph{Description}:
4655 @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
4656 integer values of @var{X} the Gamma function simplifies to the factorial
4657 function @math{\Gamma(x)=(x-1)!}.
4658
4659 @tex
4660 $$
4661 \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
4662 $$
4663 @end tex
4664
4665 @item @emph{Standard}:
4666 Fortran 2008 and later
4667
4668 @item @emph{Class}:
4669 Elemental function
4670
4671 @item @emph{Syntax}:
4672 @code{X = GAMMA(X)}
4673
4674 @item @emph{Arguments}:
4675 @multitable @columnfractions .15 .70
4676 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
4677 nor a negative integer.
4678 @end multitable
4679
4680 @item @emph{Return value}:
4681 The return value is of type @code{REAL} of the same kind as @var{X}.
4682
4683 @item @emph{Example}:
4684 @smallexample
4685 program test_gamma
4686   real :: x = 1.0
4687   x = gamma(x) ! returns 1.0
4688 end program test_gamma
4689 @end smallexample
4690
4691 @item @emph{Specific names}:
4692 @multitable @columnfractions .20 .20 .20 .25
4693 @item Name             @tab Argument         @tab Return type       @tab Standard
4694 @item @code{GAMMA(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
4695 @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
4696 @end multitable
4697
4698 @item @emph{See also}:
4699 Logarithm of the Gamma function: @ref{LOG_GAMMA}
4700
4701 @end table
4702
4703
4704
4705 @node GERROR
4706 @section @code{GERROR} --- Get last system error message
4707 @fnindex GERROR
4708 @cindex system, error handling
4709
4710 @table @asis
4711 @item @emph{Description}:
4712 Returns the system error message corresponding to the last system error.
4713 This resembles the functionality of @code{strerror(3)} in C.
4714
4715 @item @emph{Standard}:
4716 GNU extension
4717
4718 @item @emph{Class}:
4719 Subroutine
4720
4721 @item @emph{Syntax}:
4722 @code{CALL GERROR(RESULT)}
4723
4724 @item @emph{Arguments}:
4725 @multitable @columnfractions .15 .70
4726 @item @var{RESULT}  @tab Shall of type @code{CHARACTER} and of default
4727 @end multitable
4728
4729 @item @emph{Example}:
4730 @smallexample
4731 PROGRAM test_gerror
4732   CHARACTER(len=100) :: msg
4733   CALL gerror(msg)
4734   WRITE(*,*) msg
4735 END PROGRAM
4736 @end smallexample
4737
4738 @item @emph{See also}:
4739 @ref{IERRNO}, @ref{PERROR}
4740 @end table
4741
4742
4743
4744 @node GETARG
4745 @section @code{GETARG} --- Get command line arguments
4746 @fnindex GETARG
4747 @cindex command-line arguments
4748 @cindex arguments, to program
4749
4750 @table @asis
4751 @item @emph{Description}:
4752 Retrieve the @var{POS}-th argument that was passed on the
4753 command line when the containing program was invoked.
4754
4755 This intrinsic routine is provided for backwards compatibility with 
4756 GNU Fortran 77.  In new code, programmers should consider the use of 
4757 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003 
4758 standard.
4759
4760 @item @emph{Standard}:
4761 GNU extension
4762
4763 @item @emph{Class}:
4764 Subroutine
4765
4766 @item @emph{Syntax}:
4767 @code{CALL GETARG(POS, VALUE)}
4768
4769 @item @emph{Arguments}:
4770 @multitable @columnfractions .15 .70
4771 @item @var{POS}   @tab Shall be of type @code{INTEGER} and not wider than
4772 the default integer kind; @math{@var{POS} \geq 0}
4773 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
4774 kind.
4775 @item @var{VALUE} @tab Shall be of type @code{CHARACTER}. 
4776 @end multitable
4777
4778 @item @emph{Return value}:
4779 After @code{GETARG} returns, the @var{VALUE} argument holds the
4780 @var{POS}th command line argument. If @var{VALUE} can not hold the
4781 argument, it is truncated to fit the length of @var{VALUE}. If there are
4782 less than @var{POS} arguments specified at the command line, @var{VALUE}
4783 will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
4784 to the name of the program (on systems that support this feature).
4785
4786 @item @emph{Example}:
4787 @smallexample
4788 PROGRAM test_getarg
4789   INTEGER :: i
4790   CHARACTER(len=32) :: arg
4791
4792   DO i = 1, iargc()
4793     CALL getarg(i, arg)
4794     WRITE (*,*) arg
4795   END DO
4796 END PROGRAM
4797 @end smallexample
4798
4799 @item @emph{See also}:
4800 GNU Fortran 77 compatibility function: @ref{IARGC}
4801
4802 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
4803 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4804 @end table
4805
4806
4807
4808 @node GET_COMMAND
4809 @section @code{GET_COMMAND} --- Get the entire command line
4810 @fnindex GET_COMMAND
4811 @cindex command-line arguments
4812 @cindex arguments, to program
4813
4814 @table @asis
4815 @item @emph{Description}:
4816 Retrieve the entire command line that was used to invoke the program.
4817
4818 @item @emph{Standard}:
4819 Fortran 2003 and later
4820
4821 @item @emph{Class}:
4822 Subroutine
4823
4824 @item @emph{Syntax}:
4825 @code{CALL GET_COMMAND(COMMAND)}
4826
4827 @item @emph{Arguments}:
4828 @multitable @columnfractions .15 .70
4829 @item @var{COMMAND} @tab Shall be of type @code{CHARACTER} and of default
4830 kind.
4831 @end multitable
4832
4833 @item @emph{Return value}:
4834 Stores the entire command line that was used to invoke the program in
4835 @var{COMMAND}. If @var{COMMAND} is not large enough, the command will be
4836 truncated. 
4837
4838 @item @emph{Example}:
4839 @smallexample
4840 PROGRAM test_get_command
4841   CHARACTER(len=255) :: cmd
4842   CALL get_command(cmd)
4843   WRITE (*,*) TRIM(cmd)
4844 END PROGRAM
4845 @end smallexample
4846
4847 @item @emph{See also}:
4848 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4849 @end table
4850
4851
4852
4853 @node GET_COMMAND_ARGUMENT
4854 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4855 @fnindex GET_COMMAND_ARGUMENT
4856 @cindex command-line arguments
4857 @cindex arguments, to program
4858
4859 @table @asis
4860 @item @emph{Description}:
4861 Retrieve the @var{NUMBER}-th argument that was passed on the
4862 command line when the containing program was invoked.
4863
4864 @item @emph{Standard}:
4865 Fortran 2003 and later
4866
4867 @item @emph{Class}:
4868 Subroutine
4869
4870 @item @emph{Syntax}:
4871 @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
4872
4873 @item @emph{Arguments}:
4874 @multitable @columnfractions .15 .70
4875 @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER(4)},
4876                         @math{@var{NUMBER} \geq 0}
4877 @item @var{VALUE}  @tab Shall be a scalar of type @code{CHARACTER}
4878                         and of default kind.
4879 @item @var{LENGTH} @tab (Option) Shall be a scalar of type @code{INTEGER(4)}. 
4880 @item @var{STATUS} @tab (Option) Shall be a scalar of type @code{INTEGER(4)}. 
4881 @end multitable
4882
4883 @item @emph{Return value}:
4884 After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the 
4885 @var{NUMBER}-th command line argument. If @var{VALUE} can not hold the argument, it is 
4886 truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
4887 arguments specified at the command line, @var{VALUE} will be filled with blanks. 
4888 If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on systems
4889 that support this feature). The @var{LENGTH} argument contains the length of the
4890 @var{NUMBER}-th command line argument. If the argument retrival fails, @var{STATUS}
4891 is a positiv number; if @var{VALUE} contains a truncated command line argument,
4892 @var{STATUS} is -1; and otherwise the @var{STATUS} is zero.
4893
4894 @item @emph{Example}:
4895 @smallexample
4896 PROGRAM test_get_command_argument
4897   INTEGER :: i
4898   CHARACTER(len=32) :: arg
4899
4900   i = 0
4901   DO
4902     CALL get_command_argument(i, arg)
4903     IF (LEN_TRIM(arg) == 0) EXIT
4904
4905     WRITE (*,*) TRIM(arg)
4906     i = i+1
4907   END DO
4908 END PROGRAM
4909 @end smallexample
4910
4911 @item @emph{See also}:
4912 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4913 @end table
4914
4915
4916
4917 @node GETCWD
4918 @section @code{GETCWD} --- Get current working directory
4919 @fnindex GETCWD
4920 @cindex system, working directory
4921
4922 @table @asis
4923 @item @emph{Description}:
4924 Get current working directory.
4925
4926 This intrinsic is provided in both subroutine and function forms; however,
4927 only one form can be used in any given program unit.
4928
4929 @item @emph{Standard}:
4930 GNU extension
4931
4932 @item @emph{Class}:
4933 Subroutine, function
4934
4935 @item @emph{Syntax}:
4936 @code{CALL GETCWD(C [, STATUS])}
4937
4938 @item @emph{Arguments}:
4939 @multitable @columnfractions .15 .70
4940 @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
4941 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success, 
4942                         a system specific and nonzero error code otherwise.
4943 @end multitable
4944
4945 @item @emph{Example}:
4946 @smallexample
4947 PROGRAM test_getcwd
4948   CHARACTER(len=255) :: cwd
4949   CALL getcwd(cwd)
4950   WRITE(*,*) TRIM(cwd)
4951 END PROGRAM
4952 @end smallexample
4953
4954 @item @emph{See also}:
4955 @ref{CHDIR}
4956 @end table
4957
4958
4959
4960 @node GETENV
4961 @section @code{GETENV} --- Get an environmental variable
4962 @fnindex GETENV
4963 @cindex environment variable
4964
4965 @table @asis
4966 @item @emph{Description}:
4967 Get the @var{VALUE} of the environmental variable @var{NAME}.
4968
4969 This intrinsic routine is provided for backwards compatibility with 
4970 GNU Fortran 77.  In new code, programmers should consider the use of 
4971 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4972 2003 standard.
4973
4974 @item @emph{Standard}:
4975 GNU extension
4976
4977 @item @emph{Class}:
4978 Subroutine
4979
4980 @item @emph{Syntax}:
4981 @code{CALL GETENV(NAME, VALUE)}
4982
4983 @item @emph{Arguments}:
4984 @multitable @columnfractions .15 .70
4985 @item @var{NAME}  @tab Shall be of type @code{CHARACTER} and of default kind.
4986 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
4987 @end multitable
4988
4989 @item @emph{Return value}:
4990 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
4991 not large enough to hold the data, it is truncated. If @var{NAME}
4992 is not set, @var{VALUE} will be filled with blanks.
4993
4994 @item @emph{Example}:
4995 @smallexample
4996 PROGRAM test_getenv
4997   CHARACTER(len=255) :: homedir
4998   CALL getenv("HOME", homedir)
4999   WRITE (*,*) TRIM(homedir)
5000 END PROGRAM
5001 @end smallexample
5002
5003 @item @emph{See also}:
5004 @ref{GET_ENVIRONMENT_VARIABLE}
5005 @end table
5006
5007
5008
5009 @node GET_ENVIRONMENT_VARIABLE
5010 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
5011 @fnindex GET_ENVIRONMENT_VARIABLE
5012 @cindex environment variable
5013
5014 @table @asis
5015 @item @emph{Description}:
5016 Get the @var{VALUE} of the environmental variable @var{NAME}.
5017
5018 @item @emph{Standard}:
5019 Fortran 2003 and later
5020
5021 @item @emph{Class}:
5022 Subroutine
5023
5024 @item @emph{Syntax}:
5025 @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
5026
5027 @item @emph{Arguments}:
5028 @multitable @columnfractions .15 .70
5029 @item @var{NAME}      @tab Shall be a scalar of type @code{CHARACTER(1)}. 
5030 @item @var{VALUE}     @tab Shall be a scalar of type @code{CHARACTER(1)}. 
5031 @item @var{LENGTH}    @tab Shall be a scalar of type @code{INTEGER(4)}. 
5032 @item @var{STATUS}    @tab Shall be a scalar of type @code{INTEGER(4)}. 
5033 @item @var{TRIM_NAME} @tab Shall be a scalar of type @code{LOGICAL(4)}. 
5034 @end multitable
5035
5036 @item @emph{Return value}:
5037 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
5038 not large enough to hold the data, it is truncated. If @var{NAME}
5039 is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
5040 contains the length needed for storing the environment variable @var{NAME}
5041 or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
5042 but too short for the environment variable; it is 1 if the environment
5043 variable does not exist and 2 if the processor does not support environment
5044 variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
5045 present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
5046 are significant; otherwise they are not part of the environment variable
5047 name.
5048
5049 @item @emph{Example}:
5050 @smallexample
5051 PROGRAM test_getenv
5052   CHARACTER(len=255) :: homedir
5053   CALL get_environment_variable("HOME", homedir)
5054   WRITE (*,*) TRIM(homedir)
5055 END PROGRAM
5056 @end smallexample
5057 @end table
5058
5059
5060
5061 @node GETGID
5062 @section @code{GETGID} --- Group ID function
5063 @fnindex GETGID
5064 @cindex system, group id
5065
5066 @table @asis
5067 @item @emph{Description}:
5068 Returns the numerical group ID of the current process.
5069
5070 @item @emph{Standard}:
5071 GNU extension
5072
5073 @item @emph{Class}:
5074 Function
5075
5076 @item @emph{Syntax}:
5077 @code{RESULT = GETGID()}
5078
5079 @item @emph{Return value}:
5080 The return value of @code{GETGID} is an @code{INTEGER} of the default
5081 kind.
5082
5083
5084 @item @emph{Example}:
5085 See @code{GETPID} for an example.
5086
5087 @item @emph{See also}:
5088 @ref{GETPID}, @ref{GETUID}
5089 @end table
5090
5091
5092
5093 @node GETLOG
5094 @section @code{GETLOG} --- Get login name
5095 @fnindex GETLOG
5096 @cindex system, login name
5097 @cindex login name
5098
5099 @table @asis
5100 @item @emph{Description}:
5101 Gets the username under which the program is running.
5102
5103 @item @emph{Standard}:
5104 GNU extension
5105
5106 @item @emph{Class}:
5107 Subroutine
5108
5109 @item @emph{Syntax}:
5110 @code{CALL GETLOG(C)}
5111
5112 @item @emph{Arguments}:
5113 @multitable @columnfractions .15 .70
5114 @item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
5115 @end multitable
5116
5117 @item @emph{Return value}:
5118 Stores the current user name in @var{LOGIN}.  (On systems where POSIX
5119 functions @code{geteuid} and @code{getpwuid} are not available, and 
5120 the @code{getlogin} function is not implemented either, this will
5121 return a blank string.)
5122
5123 @item @emph{Example}:
5124 @smallexample
5125 PROGRAM TEST_GETLOG
5126   CHARACTER(32) :: login
5127   CALL GETLOG(login)
5128   WRITE(*,*) login
5129 END PROGRAM
5130 @end smallexample
5131
5132 @item @emph{See also}:
5133 @ref{GETUID}
5134 @end table
5135
5136
5137
5138 @node GETPID
5139 @section @code{GETPID} --- Process ID function
5140 @fnindex GETPID
5141 @cindex system, process id
5142 @cindex process id
5143
5144 @table @asis
5145 @item @emph{Description}:
5146 Returns the numerical process identifier of the current process.
5147
5148 @item @emph{Standard}:
5149 GNU extension
5150
5151 @item @emph{Class}:
5152 Function
5153
5154 @item @emph{Syntax}:
5155 @code{RESULT = GETPID()}
5156
5157 @item @emph{Return value}:
5158 The return value of @code{GETPID} is an @code{INTEGER} of the default
5159 kind.
5160
5161
5162 @item @emph{Example}:
5163 @smallexample
5164 program info
5165   print *, "The current process ID is ", getpid()
5166   print *, "Your numerical user ID is ", getuid()
5167   print *, "Your numerical group ID is ", getgid()
5168 end program info
5169 @end smallexample
5170
5171 @item @emph{See also}:
5172 @ref{GETGID}, @ref{GETUID}
5173 @end table
5174
5175
5176
5177 @node GETUID
5178 @section @code{GETUID} --- User ID function
5179 @fnindex GETUID
5180 @cindex system, user id
5181 @cindex user id
5182
5183 @table @asis
5184 @item @emph{Description}:
5185 Returns the numerical user ID of the current process.
5186
5187 @item @emph{Standard}:
5188 GNU extension
5189
5190 @item @emph{Class}:
5191 Function
5192
5193 @item @emph{Syntax}:
5194 @code{RESULT = GETUID()}
5195
5196 @item @emph{Return value}:
5197 The return value of @code{GETUID} is an @code{INTEGER} of the default
5198 kind.
5199
5200
5201 @item @emph{Example}:
5202 See @code{GETPID} for an example.
5203
5204 @item @emph{See also}:
5205 @ref{GETPID}, @ref{GETLOG}
5206 @end table
5207
5208
5209
5210 @node GMTIME
5211 @section @code{GMTIME} --- Convert time to GMT info
5212 @fnindex GMTIME
5213 @cindex time, conversion to GMT info
5214
5215 @table @asis
5216 @item @emph{Description}:
5217 Given a system time value @var{TIME} (as provided by the @code{TIME8()}
5218 intrinsic), fills @var{VALUES} with values extracted from it appropriate
5219 to the UTC time zone (Universal Coordinated Time, also known in some
5220 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
5221
5222 @item @emph{Standard}:
5223 GNU extension
5224
5225 @item @emph{Class}:
5226 Subroutine
5227
5228 @item @emph{Syntax}:
5229 @code{CALL GMTIME(TIME, VALUES)}
5230
5231 @item @emph{Arguments}:
5232 @multitable @columnfractions .15 .70
5233 @item @var{TIME}   @tab An @code{INTEGER} scalar expression
5234                         corresponding to a system time, with 
5235                         @code{INTENT(IN)}.
5236 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
5237                         with @code{INTENT(OUT)}.
5238 @end multitable
5239
5240 @item @emph{Return value}:
5241 The elements of @var{VALUES} are assigned as follows:
5242 @enumerate
5243 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
5244       seconds
5245 @item Minutes after the hour, range 0--59
5246 @item Hours past midnight, range 0--23
5247 @item Day of month, range 0--31
5248 @item Number of months since January, range 0--12
5249 @item Years since 1900
5250 @item Number of days since Sunday, range 0--6
5251 @item Days since January 1
5252 @item Daylight savings indicator: positive if daylight savings is in
5253       effect, zero if not, and negative if the information is not
5254       available.
5255 @end enumerate
5256
5257 @item @emph{See also}:
5258 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
5259
5260 @end table
5261
5262
5263
5264 @node HOSTNM
5265 @section @code{HOSTNM} --- Get system host name
5266 @fnindex HOSTNM
5267 @cindex system, host name
5268
5269 @table @asis
5270 @item @emph{Description}:
5271 Retrieves the host name of the system on which the program is running.
5272
5273 This intrinsic is provided in both subroutine and function forms; however,
5274 only one form can be used in any given program unit.
5275
5276 @item @emph{Standard}:
5277 GNU extension
5278
5279 @item @emph{Class}:
5280 Subroutine, function
5281
5282 @item @emph{Syntax}:
5283 @multitable @columnfractions .80
5284 @item @code{CALL HOSTNM(C [, STATUS])}
5285 @item @code{STATUS = HOSTNM(NAME)}
5286 @end multitable
5287
5288 @item @emph{Arguments}:
5289 @multitable @columnfractions .15 .70
5290 @item @var{C}    @tab Shall of type @code{CHARACTER} and of default kind.
5291 @item @var{STATUS}  @tab (Optional) status flag of type @code{INTEGER}.
5292                          Returns 0 on success, or a system specific error
5293                          code otherwise.
5294 @end multitable
5295
5296 @item @emph{Return value}:
5297 In either syntax, @var{NAME} is set to the current hostname if it can
5298 be obtained, or to a blank string otherwise.
5299
5300 @end table
5301
5302
5303
5304 @node HUGE
5305 @section @code{HUGE} --- Largest number of a kind
5306 @fnindex HUGE
5307 @cindex limits, largest number
5308 @cindex model representation, largest number
5309
5310 @table @asis
5311 @item @emph{Description}:
5312 @code{HUGE(X)} returns the largest number that is not an infinity in
5313 the model of the type of @code{X}.
5314
5315 @item @emph{Standard}:
5316 Fortran 95 and later
5317
5318 @item @emph{Class}:
5319 Inquiry function
5320
5321 @item @emph{Syntax}:
5322 @code{RESULT = HUGE(X)}
5323
5324 @item @emph{Arguments}:
5325 @multitable @columnfractions .15 .70
5326 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
5327 @end multitable
5328
5329 @item @emph{Return value}:
5330 The return value is of the same type and kind as @var{X}
5331
5332 @item @emph{Example}:
5333 @smallexample
5334 program test_huge_tiny
5335   print *, huge(0), huge(0.0), huge(0.0d0)
5336   print *, tiny(0.0), tiny(0.0d0)
5337 end program test_huge_tiny
5338 @end smallexample
5339 @end table
5340
5341
5342
5343 @node HYPOT
5344 @section @code{HYPOT} --- Euclidean distance function
5345 @fnindex HYPOT
5346 @cindex Euclidean distance
5347
5348 @table @asis
5349 @item @emph{Description}:
5350 @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
5351 @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
5352
5353 @item @emph{Standard}:
5354 Fortran 2008 and later
5355
5356 @item @emph{Class}:
5357 Elemental function
5358
5359 @item @emph{Syntax}:
5360 @code{RESULT = HYPOT(X, Y)}
5361
5362 @item @emph{Arguments}:
5363 @multitable @columnfractions .15 .70
5364 @item @var{X} @tab The type shall be @code{REAL}.
5365 @item @var{Y} @tab The type and kind type parameter shall be the same as
5366 @var{X}.
5367 @end multitable
5368
5369 @item @emph{Return value}:
5370 The return value has the same type and kind type parameter as @var{X}.
5371
5372 @item @emph{Example}:
5373 @smallexample
5374 program test_hypot
5375   real(4) :: x = 1.e0_4, y = 0.5e0_4
5376   x = hypot(x,y)
5377 end program test_hypot
5378 @end smallexample
5379 @end table
5380
5381
5382
5383 @node IACHAR
5384 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence 
5385 @fnindex IACHAR
5386 @cindex @acronym{ASCII} collating sequence
5387 @cindex collating sequence, @acronym{ASCII}
5388 @cindex conversion, to integer
5389
5390 @table @asis
5391 @item @emph{Description}:
5392 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
5393 in the first character position of @code{C}.
5394
5395 @item @emph{Standard}:
5396 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
5397
5398 @item @emph{Class}:
5399 Elemental function
5400
5401 @item @emph{Syntax}:
5402 @code{RESULT = IACHAR(C [, KIND])}
5403
5404 @item @emph{Arguments}:
5405 @multitable @columnfractions .15 .70
5406 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5407 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5408                       expression indicating the kind parameter of
5409                       the result.
5410 @end multitable
5411
5412 @item @emph{Return value}:
5413 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5414 @var{KIND} is absent, the return value is of default integer kind.
5415
5416 @item @emph{Example}:
5417 @smallexample
5418 program test_iachar
5419   integer i
5420   i = iachar(' ')
5421 end program test_iachar
5422 @end smallexample
5423
5424 @item @emph{Note}:
5425 See @ref{ICHAR} for a discussion of converting between numerical values
5426 and formatted string representations.
5427
5428 @item @emph{See also}:
5429 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
5430
5431 @end table
5432
5433
5434
5435 @node IAND
5436 @section @code{IAND} --- Bitwise logical and
5437 @fnindex IAND
5438 @cindex bitwise logical and
5439 @cindex logical and, bitwise
5440
5441 @table @asis
5442 @item @emph{Description}:
5443 Bitwise logical @code{AND}.
5444
5445 @item @emph{Standard}:
5446 Fortran 95 and later
5447
5448 @item @emph{Class}:
5449 Elemental function
5450
5451 @item @emph{Syntax}:
5452 @code{RESULT = IAND(I, J)}
5453
5454 @item @emph{Arguments}:
5455 @multitable @columnfractions .15 .70
5456 @item @var{I} @tab The type shall be @code{INTEGER}.
5457 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
5458 kind as @var{I}.  (As a GNU extension, different kinds are also 
5459 permitted.)
5460 @end multitable
5461
5462 @item @emph{Return value}:
5463 The return type is @code{INTEGER}, of the same kind as the
5464 arguments.  (If the argument kinds differ, it is of the same kind as
5465 the larger argument.)
5466
5467 @item @emph{Example}:
5468 @smallexample
5469 PROGRAM test_iand
5470   INTEGER :: a, b
5471   DATA a / Z'F' /, b / Z'3' /
5472   WRITE (*,*) IAND(a, b)
5473 END PROGRAM
5474 @end smallexample
5475
5476 @item @emph{See also}:
5477 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5478
5479 @end table
5480
5481
5482
5483 @node IARGC
5484 @section @code{IARGC} --- Get the number of command line arguments
5485 @fnindex IARGC
5486 @cindex command-line arguments
5487 @cindex command-line arguments, number of
5488 @cindex arguments, to program
5489
5490 @table @asis
5491 @item @emph{Description}:
5492 @code{IARGC()} returns the number of arguments passed on the
5493 command line when the containing program was invoked.
5494
5495 This intrinsic routine is provided for backwards compatibility with 
5496 GNU Fortran 77.  In new code, programmers should consider the use of 
5497 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003 
5498 standard.
5499
5500 @item @emph{Standard}:
5501 GNU extension
5502
5503 @item @emph{Class}:
5504 Function
5505
5506 @item @emph{Syntax}:
5507 @code{RESULT = IARGC()}
5508
5509 @item @emph{Arguments}:
5510 None.
5511
5512 @item @emph{Return value}:
5513 The number of command line arguments, type @code{INTEGER(4)}.
5514
5515 @item @emph{Example}:
5516 See @ref{GETARG}
5517
5518 @item @emph{See also}:
5519 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
5520
5521 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
5522 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
5523 @end table
5524
5525
5526
5527 @node IBCLR
5528 @section @code{IBCLR} --- Clear bit
5529 @fnindex IBCLR
5530 @cindex bits, unset
5531 @cindex bits, clear
5532
5533 @table @asis
5534 @item @emph{Description}:
5535 @code{IBCLR} returns the value of @var{I} with the bit at position
5536 @var{POS} set to zero.
5537
5538 @item @emph{Standard}:
5539 Fortran 95 and later
5540
5541 @item @emph{Class}:
5542 Elemental function
5543
5544 @item @emph{Syntax}:
5545 @code{RESULT = IBCLR(I, POS)}
5546
5547 @item @emph{Arguments}:
5548 @multitable @columnfractions .15 .70
5549 @item @var{I} @tab The type shall be @code{INTEGER}.
5550 @item @var{POS} @tab The type shall be @code{INTEGER}.
5551 @end multitable
5552
5553 @item @emph{Return value}:
5554 The return value is of type @code{INTEGER} and of the same kind as
5555 @var{I}.
5556
5557 @item @emph{See also}:
5558 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
5559
5560 @end table
5561
5562
5563
5564 @node IBITS
5565 @section @code{IBITS} --- Bit extraction
5566 @fnindex IBITS
5567 @cindex bits, get
5568 @cindex bits, extract
5569
5570 @table @asis
5571 @item @emph{Description}:
5572 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
5573 starting from bit position @var{POS} and extending left for @var{LEN}
5574 bits.  The result is right-justified and the remaining bits are
5575 zeroed.  The value of @code{POS+LEN} must be less than or equal to the
5576 value @code{BIT_SIZE(I)}.
5577
5578 @item @emph{Standard}:
5579 Fortran 95 and later
5580
5581 @item @emph{Class}:
5582 Elemental function
5583
5584 @item @emph{Syntax}:
5585 @code{RESULT = IBITS(I, POS, LEN)}
5586
5587 @item @emph{Arguments}:
5588 @multitable @columnfractions .15 .70
5589 @item @var{I}   @tab The type shall be @code{INTEGER}.
5590 @item @var{POS} @tab The type shall be @code{INTEGER}.
5591 @item @var{LEN} @tab The type shall be @code{INTEGER}.
5592 @end multitable
5593
5594 @item @emph{Return value}:
5595 The return value is of type @code{INTEGER} and of the same kind as
5596 @var{I}.
5597
5598 @item @emph{See also}:
5599 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
5600 @end table
5601
5602
5603
5604 @node IBSET
5605 @section @code{IBSET} --- Set bit
5606 @fnindex IBSET
5607 @cindex bits, set
5608
5609 @table @asis
5610 @item @emph{Description}:
5611 @code{IBSET} returns the value of @var{I} with the bit at position
5612 @var{POS} set to one.
5613
5614 @item @emph{Standard}:
5615 Fortran 95 and later
5616
5617 @item @emph{Class}:
5618 Elemental function
5619
5620 @item @emph{Syntax}:
5621 @code{RESULT = IBSET(I, POS)}
5622
5623 @item @emph{Arguments}:
5624 @multitable @columnfractions .15 .70
5625 @item @var{I} @tab The type shall be @code{INTEGER}.
5626 @item @var{POS} @tab The type shall be @code{INTEGER}.
5627 @end multitable
5628
5629 @item @emph{Return value}:
5630 The return value is of type @code{INTEGER} and of the same kind as
5631 @var{I}.
5632
5633 @item @emph{See also}:
5634 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
5635
5636 @end table
5637
5638
5639
5640 @node ICHAR
5641 @section @code{ICHAR} --- Character-to-integer conversion function
5642 @fnindex ICHAR
5643 @cindex conversion, to integer
5644
5645 @table @asis
5646 @item @emph{Description}:
5647 @code{ICHAR(C)} returns the code for the character in the first character
5648 position of @code{C} in the system's native character set.
5649 The correspondence between characters and their codes is not necessarily
5650 the same across different GNU Fortran implementations.
5651
5652 @item @emph{Standard}:
5653 Fortan 95 and later, with @var{KIND} argument Fortran 2003 and later
5654
5655 @item @emph{Class}:
5656 Elemental function
5657
5658 @item @emph{Syntax}:
5659 @code{RESULT = ICHAR(C [, KIND])}
5660
5661 @item @emph{Arguments}:
5662 @multitable @columnfractions .15 .70
5663 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5664 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5665                       expression indicating the kind parameter of
5666                       the result.
5667 @end multitable
5668
5669 @item @emph{Return value}:
5670 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5671 @var{KIND} is absent, the return value is of default integer kind.
5672
5673 @item @emph{Example}:
5674 @smallexample
5675 program test_ichar
5676   integer i
5677   i = ichar(' ')
5678 end program test_ichar
5679 @end smallexample
5680
5681 @item @emph{Note}:
5682 No intrinsic exists to convert between a numeric value and a formatted
5683 character string representation -- for instance, given the
5684 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
5685 @code{REAL} value with the value 154, or vice versa. Instead, this
5686 functionality is provided by internal-file I/O, as in the following
5687 example:
5688 @smallexample
5689 program read_val
5690   integer value
5691   character(len=10) string, string2
5692   string = '154'
5693   
5694   ! Convert a string to a numeric value
5695   read (string,'(I10)') value
5696   print *, value
5697   
5698   ! Convert a value to a formatted string
5699   write (string2,'(I10)') value
5700   print *, string2
5701 end program read_val
5702 @end smallexample
5703
5704 @item @emph{See also}:
5705 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
5706
5707 @end table
5708
5709
5710
5711 @node IDATE
5712 @section @code{IDATE} --- Get current local time subroutine (day/month/year) 
5713 @fnindex IDATE
5714 @cindex date, current
5715 @cindex current date
5716
5717 @table @asis
5718 @item @emph{Description}:
5719 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the  
5720 current local time. The day (in the range 1-31), month (in the range 1-12), 
5721 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively. 
5722 The year has four significant digits.
5723
5724 @item @emph{Standard}:
5725 GNU extension
5726
5727 @item @emph{Class}:
5728 Subroutine
5729
5730 @item @emph{Syntax}:
5731 @code{CALL IDATE(VALUES)}
5732
5733 @item @emph{Arguments}:
5734 @multitable @columnfractions .15 .70
5735 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
5736 the kind shall be the default integer kind.
5737 @end multitable
5738
5739 @item @emph{Return value}:
5740 Does not return.
5741
5742 @item @emph{Example}:
5743 @smallexample
5744 program test_idate
5745   integer, dimension(3) :: tarray
5746   call idate(tarray)
5747   print *, tarray(1)
5748   print *, tarray(2)
5749   print *, tarray(3)
5750 end program test_idate
5751 @end smallexample
5752 @end table
5753
5754
5755
5756 @node IEOR
5757 @section @code{IEOR} --- Bitwise logical exclusive or
5758 @fnindex IEOR
5759 @cindex bitwise logical exclusive or
5760 @cindex logical exclusive or, bitwise
5761
5762 @table @asis
5763 @item @emph{Description}:
5764 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
5765 @var{J}.
5766
5767 @item @emph{Standard}:
5768 Fortran 95 and later
5769
5770 @item @emph{Class}:
5771 Elemental function
5772
5773 @item @emph{Syntax}:
5774 @code{RESULT = IEOR(I, J)}
5775
5776 @item @emph{Arguments}:
5777 @multitable @columnfractions .15 .70
5778 @item @var{I} @tab The type shall be @code{INTEGER}.
5779 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
5780 kind as @var{I}.  (As a GNU extension, different kinds are also 
5781 permitted.)
5782 @end multitable
5783
5784 @item @emph{Return value}:
5785 The return type is @code{INTEGER}, of the same kind as the
5786 arguments.  (If the argument kinds differ, it is of the same kind as
5787 the larger argument.)
5788
5789 @item @emph{See also}:
5790 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5791 @end table
5792
5793
5794
5795 @node IERRNO
5796 @section @code{IERRNO} --- Get the last system error number
5797 @fnindex IERRNO
5798 @cindex system, error handling
5799
5800 @table @asis
5801 @item @emph{Description}:
5802 Returns the last system error number, as given by the C @code{errno()}
5803 function.
5804
5805 @item @emph{Standard}:
5806 GNU extension
5807
5808 @item @emph{Class}:
5809 Function
5810
5811 @item @emph{Syntax}:
5812 @code{RESULT = IERRNO()}
5813
5814 @item @emph{Arguments}:
5815 None.
5816
5817 @item @emph{Return value}:
5818 The return value is of type @code{INTEGER} and of the default integer
5819 kind.
5820
5821 @item @emph{See also}:
5822 @ref{PERROR}
5823 @end table
5824
5825
5826
5827 @node INDEX intrinsic
5828 @section @code{INDEX} --- Position of a substring within a string
5829 @fnindex INDEX
5830 @cindex substring position
5831 @cindex string, find substring
5832
5833 @table @asis
5834 @item @emph{Description}:
5835 Returns the position of the start of the first occurrence of string
5836 @var{SUBSTRING} as a substring in @var{STRING}, counting from one.  If
5837 @var{SUBSTRING} is not present in @var{STRING}, zero is returned.  If 
5838 the @var{BACK} argument is present and true, the return value is the
5839 start of the last occurrence rather than the first.
5840
5841 @item @emph{Standard}:
5842 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
5843
5844 @item @emph{Class}:
5845 Elemental function
5846
5847 @item @emph{Syntax}:
5848 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
5849
5850 @item @emph{Arguments}:
5851 @multitable @columnfractions .15 .70
5852 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
5853 @code{INTENT(IN)}
5854 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
5855 @code{INTENT(IN)}
5856 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
5857 @code{INTENT(IN)}
5858 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5859                       expression indicating the kind parameter of
5860                       the result.
5861 @end multitable
5862
5863 @item @emph{Return value}:
5864 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5865 @var{KIND} is absent, the return value is of default integer kind.
5866
5867 @item @emph{See also}:
5868 @ref{SCAN}, @ref{VERIFY}
5869 @end table
5870
5871
5872
5873 @node INT
5874 @section @code{INT} --- Convert to integer type
5875 @fnindex INT
5876 @fnindex IFIX
5877 @fnindex IDINT
5878 @cindex conversion, to integer
5879
5880 @table @asis
5881 @item @emph{Description}:
5882 Convert to integer type
5883
5884 @item @emph{Standard}:
5885 Fortran 77 and later
5886
5887 @item @emph{Class}:
5888 Elemental function
5889
5890 @item @emph{Syntax}:
5891 @code{RESULT = INT(A [, KIND))}
5892
5893 @item @emph{Arguments}:
5894 @multitable @columnfractions .15 .70
5895 @item @var{A}    @tab Shall be of type @code{INTEGER},
5896                       @code{REAL}, or @code{COMPLEX}.
5897 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5898                       expression indicating the kind parameter of
5899                       the result.
5900 @end multitable
5901
5902 @item @emph{Return value}:
5903 These functions return a @code{INTEGER} variable or array under 
5904 the following rules: 
5905
5906 @table @asis
5907 @item (A)
5908 If @var{A} is of type @code{INTEGER}, @code{INT(A) = A} 
5909 @item (B)
5910 If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} equals @code{0}. 
5911 If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed 
5912 the range of @var{A} and whose sign is the same as the sign of @var{A}.
5913 @item (C)
5914 If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
5915 @end table
5916
5917 @item @emph{Example}:
5918 @smallexample
5919 program test_int
5920   integer :: i = 42
5921   complex :: z = (-3.7, 1.0)
5922   print *, int(i)
5923   print *, int(z), int(z,8)
5924 end program
5925 @end smallexample
5926
5927 @item @emph{Specific names}:
5928 @multitable @columnfractions .20 .20 .20 .25
5929 @item Name             @tab Argument            @tab Return type       @tab Standard
5930 @item @code{IFIX(A)}   @tab @code{REAL(4) A}    @tab @code{INTEGER}    @tab Fortran 77 and later
5931 @item @code{IDINT(A)}  @tab @code{REAL(8) A}    @tab @code{INTEGER}    @tab Fortran 77 and later
5932 @end multitable
5933
5934 @end table
5935
5936
5937
5938 @node INT2
5939 @section @code{INT2} --- Convert to 16-bit integer type
5940 @fnindex INT2
5941 @fnindex SHORT
5942 @cindex conversion, to integer
5943
5944 @table @asis
5945 @item @emph{Description}:
5946 Convert to a @code{KIND=2} integer type. This is equivalent to the
5947 standard @code{INT} intrinsic with an optional argument of
5948 @code{KIND=2}, and is only included for backwards compatibility.
5949
5950 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
5951
5952 @item @emph{Standard}:
5953 GNU extension
5954
5955 @item @emph{Class}:
5956 Elemental function
5957
5958 @item @emph{Syntax}:
5959 @code{RESULT = INT2(A)}
5960
5961 @item @emph{Arguments}:
5962 @multitable @columnfractions .15 .70
5963 @item @var{A}    @tab Shall be of type @code{INTEGER},
5964                       @code{REAL}, or @code{COMPLEX}.
5965 @end multitable
5966
5967 @item @emph{Return value}:
5968 The return value is a @code{INTEGER(2)} variable.
5969
5970 @item @emph{See also}:
5971 @ref{INT}, @ref{INT8}, @ref{LONG}
5972 @end table
5973
5974
5975
5976 @node INT8
5977 @section @code{INT8} --- Convert to 64-bit integer type
5978 @fnindex INT8
5979 @cindex conversion, to integer
5980
5981 @table @asis
5982 @item @emph{Description}:
5983 Convert to a @code{KIND=8} integer type. This is equivalent to the
5984 standard @code{INT} intrinsic with an optional argument of
5985 @code{KIND=8}, and is only included for backwards compatibility.
5986
5987 @item @emph{Standard}:
5988 GNU extension
5989
5990 @item @emph{Class}:
5991 Elemental function
5992
5993 @item @emph{Syntax}:
5994 @code{RESULT = INT8(A)}
5995
5996 @item @emph{Arguments}:
5997 @multitable @columnfractions .15 .70
5998 @item @var{A}    @tab Shall be of type @code{INTEGER},
5999                       @code{REAL}, or @code{COMPLEX}.
6000 @end multitable
6001
6002 @item @emph{Return value}:
6003 The return value is a @code{INTEGER(8)} variable.
6004
6005 @item @emph{See also}:
6006 @ref{INT}, @ref{INT2}, @ref{LONG}
6007 @end table
6008
6009
6010
6011 @node IOR
6012 @section @code{IOR} --- Bitwise logical or
6013 @fnindex IOR
6014 @cindex bitwise logical or
6015 @cindex logical or, bitwise
6016
6017 @table @asis
6018 @item @emph{Description}:
6019 @code{IOR} returns the bitwise boolean inclusive-OR of @var{I} and
6020 @var{J}.
6021
6022 @item @emph{Standard}:
6023 Fortran 95 and later
6024
6025 @item @emph{Class}:
6026 Elemental function
6027
6028 @item @emph{Syntax}:
6029 @code{RESULT = IOR(I, J)}
6030
6031 @item @emph{Arguments}:
6032 @multitable @columnfractions .15 .70
6033 @item @var{I} @tab The type shall be @code{INTEGER}.
6034 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6035 kind as @var{I}.  (As a GNU extension, different kinds are also 
6036 permitted.)
6037 @end multitable
6038
6039 @item @emph{Return value}:
6040 The return type is @code{INTEGER}, of the same kind as the
6041 arguments.  (If the argument kinds differ, it is of the same kind as
6042 the larger argument.)
6043
6044 @item @emph{See also}:
6045 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6046 @end table
6047
6048
6049
6050 @node IRAND
6051 @section @code{IRAND} --- Integer pseudo-random number
6052 @fnindex IRAND
6053 @cindex random number generation
6054
6055 @table @asis
6056 @item @emph{Description}:
6057 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
6058 distribution between 0 and a system-dependent limit (which is in most
6059 cases 2147483647). If @var{FLAG} is 0, the next number
6060 in the current sequence is returned; if @var{FLAG} is 1, the generator
6061 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
6062 it is used as a new seed with @code{SRAND}.
6063
6064 This intrinsic routine is provided for backwards compatibility with
6065 GNU Fortran 77. It implements a simple modulo generator as provided 
6066 by @command{g77}. For new code, one should consider the use of 
6067 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
6068
6069 @item @emph{Standard}:
6070 GNU extension
6071
6072 @item @emph{Class}:
6073 Function
6074
6075 @item @emph{Syntax}:
6076 @code{RESULT = IRAND(I)}
6077
6078 @item @emph{Arguments}:
6079 @multitable @columnfractions .15 .70
6080 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
6081 @end multitable
6082
6083 @item @emph{Return value}:
6084 The return value is of @code{INTEGER(kind=4)} type.
6085
6086 @item @emph{Example}:
6087 @smallexample
6088 program test_irand
6089   integer,parameter :: seed = 86456
6090   
6091   call srand(seed)
6092   print *, irand(), irand(), irand(), irand()
6093   print *, irand(seed), irand(), irand(), irand()
6094 end program test_irand
6095 @end smallexample
6096
6097 @end table
6098
6099
6100
6101 @node IS_IOSTAT_END
6102 @section @code{IS_IOSTAT_END} --- Test for end-of-file value
6103 @fnindex IS_IOSTAT_END
6104 @cindex IOSTAT, end of file
6105
6106 @table @asis
6107 @item @emph{Description}:
6108 @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
6109 status ``end of file''. The function is equivalent to comparing the variable
6110 with the @code{IOSTAT_END} parameter of the intrinsic module
6111 @code{ISO_FORTRAN_ENV}.
6112
6113 @item @emph{Standard}:
6114 Fortran 2003 and later
6115
6116 @item @emph{Class}:
6117 Elemental function
6118
6119 @item @emph{Syntax}:
6120 @code{RESULT = IS_IOSTAT_END(I)}
6121
6122 @item @emph{Arguments}:
6123 @multitable @columnfractions .15 .70
6124 @item @var{I} @tab Shall be of the type @code{INTEGER}.
6125 @end multitable
6126
6127 @item @emph{Return value}:
6128 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6129 @var{I} has the value which indicates an end of file condition for
6130 IOSTAT= specifiers, and is @code{.FALSE.} otherwise.
6131
6132 @item @emph{Example}:
6133 @smallexample
6134 PROGRAM iostat
6135   IMPLICIT NONE
6136   INTEGER :: stat, i
6137   OPEN(88, FILE='test.dat')
6138   READ(88, *, IOSTAT=stat) i
6139   IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
6140 END PROGRAM
6141 @end smallexample
6142 @end table
6143
6144
6145
6146 @node IS_IOSTAT_EOR
6147 @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
6148 @fnindex IS_IOSTAT_EOR
6149 @cindex IOSTAT, end of record
6150
6151 @table @asis
6152 @item @emph{Description}:
6153 @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
6154 status ``end of record''. The function is equivalent to comparing the
6155 variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
6156 @code{ISO_FORTRAN_ENV}.
6157
6158 @item @emph{Standard}:
6159 Fortran 2003 and later
6160
6161 @item @emph{Class}:
6162 Elemental function
6163
6164 @item @emph{Syntax}:
6165 @code{RESULT = IS_IOSTAT_EOR(I)}
6166
6167 @item @emph{Arguments}:
6168 @multitable @columnfractions .15 .70
6169 @item @var{I} @tab Shall be of the type @code{INTEGER}.
6170 @end multitable
6171
6172 @item @emph{Return value}:
6173 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6174 @var{I} has the value which indicates an end of file condition for
6175 IOSTAT= specifiers, and is @code{.FALSE.} otherwise.
6176
6177 @item @emph{Example}:
6178 @smallexample
6179 PROGRAM iostat
6180   IMPLICIT NONE
6181   INTEGER :: stat, i(50)
6182   OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
6183   READ(88, IOSTAT=stat) i
6184   IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
6185 END PROGRAM
6186 @end smallexample
6187 @end table
6188
6189
6190
6191 @node ISATTY
6192 @section @code{ISATTY} --- Whether a unit is a terminal device.
6193 @fnindex ISATTY
6194 @cindex system, terminal
6195
6196 @table @asis
6197 @item @emph{Description}:
6198 Determine whether a unit is connected to a terminal device.
6199
6200 @item @emph{Standard}:
6201 GNU extension
6202
6203 @item @emph{Class}:
6204 Function
6205
6206 @item @emph{Syntax}:
6207 @code{RESULT = ISATTY(UNIT)}
6208
6209 @item @emph{Arguments}:
6210 @multitable @columnfractions .15 .70
6211 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
6212 @end multitable
6213
6214 @item @emph{Return value}:
6215 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal 
6216 device, @code{.FALSE.} otherwise.
6217
6218 @item @emph{Example}:
6219 @smallexample
6220 PROGRAM test_isatty
6221   INTEGER(kind=1) :: unit
6222   DO unit = 1, 10
6223     write(*,*) isatty(unit=unit)
6224   END DO
6225 END PROGRAM
6226 @end smallexample
6227 @item @emph{See also}:
6228 @ref{TTYNAM}
6229 @end table
6230
6231
6232
6233 @node ISHFT
6234 @section @code{ISHFT} --- Shift bits
6235 @fnindex ISHFT
6236 @cindex bits, shift
6237
6238 @table @asis
6239 @item @emph{Description}:
6240 @code{ISHFT} returns a value corresponding to @var{I} with all of the
6241 bits shifted @var{SHIFT} places.  A value of @var{SHIFT} greater than
6242 zero corresponds to a left shift, a value of zero corresponds to no
6243 shift, and a value less than zero corresponds to a right shift.  If the
6244 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
6245 value is undefined.  Bits shifted out from the left end or right end are
6246 lost; zeros are shifted in from the opposite end.
6247
6248 @item @emph{Standard}:
6249 Fortran 95 and later
6250
6251 @item @emph{Class}:
6252 Elemental function
6253
6254 @item @emph{Syntax}:
6255 @code{RESULT = ISHFT(I, SHIFT)}
6256
6257 @item @emph{Arguments}:
6258 @multitable @columnfractions .15 .70
6259 @item @var{I} @tab The type shall be @code{INTEGER}.
6260 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
6261 @end multitable
6262
6263 @item @emph{Return value}:
6264 The return value is of type @code{INTEGER} and of the same kind as
6265 @var{I}.
6266
6267 @item @emph{See also}:
6268 @ref{ISHFTC}
6269 @end table
6270
6271
6272
6273 @node ISHFTC
6274 @section @code{ISHFTC} --- Shift bits circularly
6275 @fnindex ISHFTC
6276 @cindex bits, shift circular
6277
6278 @table @asis
6279 @item @emph{Description}:
6280 @code{ISHFTC} returns a value corresponding to @var{I} with the
6281 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
6282 is, bits shifted out one end are shifted into the opposite end.  A value
6283 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
6284 zero corresponds to no shift, and a value less than zero corresponds to
6285 a right shift.  The absolute value of @var{SHIFT} must be less than
6286 @var{SIZE}.  If the @var{SIZE} argument is omitted, it is taken to be
6287 equivalent to @code{BIT_SIZE(I)}.
6288
6289 @item @emph{Standard}:
6290 Fortran 95 and later
6291
6292 @item @emph{Class}:
6293 Elemental function
6294
6295 @item @emph{Syntax}:
6296 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
6297
6298 @item @emph{Arguments}:
6299 @multitable @columnfractions .15 .70
6300 @item @var{I} @tab The type shall be @code{INTEGER}.
6301 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
6302 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
6303 the value must be greater than zero and less than or equal to
6304 @code{BIT_SIZE(I)}.
6305 @end multitable
6306
6307 @item @emph{Return value}:
6308 The return value is of type @code{INTEGER} and of the same kind as
6309 @var{I}.
6310
6311 @item @emph{See also}:
6312 @ref{ISHFT}
6313 @end table
6314
6315
6316
6317 @node ISNAN
6318 @section @code{ISNAN} --- Test for a NaN
6319 @fnindex ISNAN
6320 @cindex IEEE, ISNAN
6321
6322 @table @asis
6323 @item @emph{Description}:
6324 @code{ISNAN} tests whether a floating-point value is an IEEE
6325 Not-a-Number (NaN).
6326 @item @emph{Standard}:
6327 GNU extension
6328
6329 @item @emph{Class}:
6330 Elemental function
6331
6332 @item @emph{Syntax}:
6333 @code{ISNAN(X)}
6334
6335 @item @emph{Arguments}:
6336 @multitable @columnfractions .15 .70
6337 @item @var{X} @tab Variable of the type @code{REAL}.
6338
6339 @end multitable
6340
6341 @item @emph{Return value}:
6342 Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
6343 if @var{X} is a NaN and @code{FALSE} otherwise.
6344
6345 @item @emph{Example}:
6346 @smallexample
6347 program test_nan
6348   implicit none
6349   real :: x
6350   x = -1.0
6351   x = sqrt(x)
6352   if (isnan(x)) stop '"x" is a NaN'
6353 end program test_nan
6354 @end smallexample
6355 @end table
6356
6357
6358
6359 @node ITIME
6360 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds) 
6361 @fnindex ITIME
6362 @cindex time, current
6363 @cindex current time
6364
6365 @table @asis
6366 @item @emph{Description}:
6367 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the  
6368 current local time. The hour (in the range 1-24), minute (in the range 1-60), 
6369 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES}, 
6370 respectively.
6371
6372 @item @emph{Standard}:
6373 GNU extension
6374
6375 @item @emph{Class}:
6376 Subroutine
6377
6378 @item @emph{Syntax}:
6379 @code{CALL ITIME(VALUES)}
6380
6381 @item @emph{Arguments}:
6382 @multitable @columnfractions .15 .70
6383 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
6384 and the kind shall be the default integer kind.
6385 @end multitable
6386
6387 @item @emph{Return value}:
6388 Does not return.
6389
6390
6391 @item @emph{Example}:
6392 @smallexample
6393 program test_itime
6394   integer, dimension(3) :: tarray
6395   call itime(tarray)
6396   print *, tarray(1)
6397   print *, tarray(2)
6398   print *, tarray(3)
6399 end program test_itime
6400 @end smallexample
6401 @end table
6402
6403
6404
6405 @node KILL
6406 @section @code{KILL} --- Send a signal to a process
6407 @fnindex KILL
6408
6409 @table @asis
6410 @item @emph{Description}:
6411 @item @emph{Standard}:
6412 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
6413 See @code{kill(2)}.
6414
6415 This intrinsic is provided in both subroutine and function forms; however,
6416 only one form can be used in any given program unit.
6417
6418 @item @emph{Class}:
6419 Subroutine, function
6420
6421 @item @emph{Syntax}:
6422 @code{CALL KILL(C, VALUE [, STATUS])}
6423
6424 @item @emph{Arguments}:
6425 @multitable @columnfractions .15 .70
6426 @item @var{C} @tab Shall be a scalar @code{INTEGER}, with
6427 @code{INTENT(IN)}
6428 @item @var{VALUE} @tab Shall be a scalar @code{INTEGER}, with
6429 @code{INTENT(IN)}
6430 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
6431                         @code{INTEGER(8)}. Returns 0 on success, or a
6432                         system-specific error code otherwise.
6433 @end multitable
6434
6435 @item @emph{See also}:
6436 @ref{ABORT}, @ref{EXIT}
6437 @end table
6438
6439
6440
6441 @node KIND
6442 @section @code{KIND} --- Kind of an entity
6443 @fnindex KIND
6444 @cindex kind
6445
6446 @table @asis
6447 @item @emph{Description}:
6448 @code{KIND(X)} returns the kind value of the entity @var{X}.
6449
6450 @item @emph{Standard}:
6451 Fortran 95 and later
6452
6453 @item @emph{Class}:
6454 Inquiry function
6455
6456 @item @emph{Syntax}:
6457 @code{K = KIND(X)}
6458
6459 @item @emph{Arguments}:
6460 @multitable @columnfractions .15 .70
6461 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
6462 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
6463 @end multitable
6464
6465 @item @emph{Return value}:
6466 The return value is a scalar of type @code{INTEGER} and of the default
6467 integer kind.
6468
6469 @item @emph{Example}:
6470 @smallexample
6471 program test_kind
6472   integer,parameter :: kc = kind(' ')
6473   integer,parameter :: kl = kind(.true.)
6474
6475   print *, "The default character kind is ", kc
6476   print *, "The default logical kind is ", kl
6477 end program test_kind
6478 @end smallexample
6479
6480 @end table
6481
6482
6483
6484 @node LBOUND
6485 @section @code{LBOUND} --- Lower dimension bounds of an array
6486 @fnindex LBOUND
6487 @cindex array, lower bound
6488
6489 @table @asis
6490 @item @emph{Description}:
6491 Returns the lower bounds of an array, or a single lower bound
6492 along the @var{DIM} dimension.
6493 @item @emph{Standard}:
6494 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6495
6496 @item @emph{Class}:
6497 Inquiry function
6498
6499 @item @emph{Syntax}:
6500 @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
6501
6502 @item @emph{Arguments}:
6503 @multitable @columnfractions .15 .70
6504 @item @var{ARRAY} @tab Shall be an array, of any type.
6505 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
6506 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6507                       expression indicating the kind parameter of
6508                       the result.
6509 @end multitable
6510
6511 @item @emph{Return value}:
6512 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6513 @var{KIND} is absent, the return value is of default integer kind.
6514 If @var{DIM} is absent, the result is an array of the lower bounds of
6515 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
6516 corresponding to the lower bound of the array along that dimension.  If
6517 @var{ARRAY} is an expression rather than a whole array or array
6518 structure component, or if it has a zero extent along the relevant
6519 dimension, the lower bound is taken to be 1.
6520
6521 @item @emph{See also}:
6522 @ref{UBOUND}
6523 @end table
6524
6525
6526
6527 @node LEN
6528 @section @code{LEN} --- Length of a character entity
6529 @fnindex LEN
6530 @cindex string, length
6531
6532 @table @asis
6533 @item @emph{Description}:
6534 Returns the length of a character string.  If @var{STRING} is an array,
6535 the length of an element of @var{STRING} is returned.  Note that
6536 @var{STRING} need not be defined when this intrinsic is invoked, since
6537 only the length, not the content, of @var{STRING} is needed.
6538
6539 @item @emph{Standard}:
6540 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
6541
6542 @item @emph{Class}:
6543 Inquiry function
6544
6545 @item @emph{Syntax}:
6546 @code{L = LEN(STRING [, KIND])}
6547
6548 @item @emph{Arguments}:
6549 @multitable @columnfractions .15 .70
6550 @item @var{STRING} @tab Shall be a scalar or array of type
6551 @code{CHARACTER}, with @code{INTENT(IN)}
6552 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6553                       expression indicating the kind parameter of
6554                       the result.
6555 @end multitable
6556
6557 @item @emph{Return value}:
6558 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6559 @var{KIND} is absent, the return value is of default integer kind.
6560
6561 @item @emph{See also}:
6562 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
6563 @end table
6564
6565
6566
6567 @node LEN_TRIM
6568 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
6569 @fnindex LEN_TRIM
6570 @cindex string, length, without trailing whitespace
6571
6572 @table @asis
6573 @item @emph{Description}:
6574 Returns the length of a character string, ignoring any trailing blanks.
6575
6576 @item @emph{Standard}:
6577 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6578
6579 @item @emph{Class}:
6580 Elemental function
6581
6582 @item @emph{Syntax}:
6583 @code{RESULT = LEN_TRIM(STRING [, KIND])}
6584
6585 @item @emph{Arguments}:
6586 @multitable @columnfractions .15 .70
6587 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
6588 with @code{INTENT(IN)}
6589 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6590                       expression indicating the kind parameter of
6591                       the result.
6592 @end multitable
6593
6594 @item @emph{Return value}:
6595 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6596 @var{KIND} is absent, the return value is of default integer kind.
6597
6598 @item @emph{See also}:
6599 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
6600 @end table
6601
6602
6603
6604 @node LGE
6605 @section @code{LGE} --- Lexical greater than or equal
6606 @fnindex LGE
6607 @cindex lexical comparison of strings
6608 @cindex string, comparison
6609
6610 @table @asis
6611 @item @emph{Description}:
6612 Determines whether one string is lexically greater than or equal to
6613 another string, where the two strings are interpreted as containing
6614 ASCII character codes.  If the String A and String B are not the same
6615 length, the shorter is compared as if spaces were appended to it to form
6616 a value that has the same length as the longer.
6617
6618 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6619 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6620 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6621 that the latter use the processor's character ordering (which is not
6622 ASCII on some targets), whereas the former always use the ASCII
6623 ordering.
6624
6625 @item @emph{Standard}:
6626 Fortran 77 and later
6627
6628 @item @emph{Class}:
6629 Elemental function
6630
6631 @item @emph{Syntax}:
6632 @code{RESULT = LGE(STRING_A, STRING_B)}
6633
6634 @item @emph{Arguments}:
6635 @multitable @columnfractions .15 .70
6636 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6637 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6638 @end multitable
6639
6640 @item @emph{Return value}:
6641 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
6642 otherwise, based on the ASCII ordering.
6643
6644 @item @emph{See also}:
6645 @ref{LGT}, @ref{LLE}, @ref{LLT}
6646 @end table
6647
6648
6649
6650 @node LGT
6651 @section @code{LGT} --- Lexical greater than
6652 @fnindex LGT
6653 @cindex lexical comparison of strings
6654 @cindex string, comparison
6655
6656 @table @asis
6657 @item @emph{Description}:
6658 Determines whether one string is lexically greater than another string,
6659 where the two strings are interpreted as containing ASCII character
6660 codes.  If the String A and String B are not the same length, the
6661 shorter is compared as if spaces were appended to it to form a value
6662 that has the same length as the longer.
6663
6664 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6665 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6666 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6667 that the latter use the processor's character ordering (which is not
6668 ASCII on some targets), whereas the former always use the ASCII
6669 ordering.
6670
6671 @item @emph{Standard}:
6672 Fortran 77 and later
6673
6674 @item @emph{Class}:
6675 Elemental function
6676
6677 @item @emph{Syntax}:
6678 @code{RESULT = LGT(STRING_A, STRING_B)}
6679
6680 @item @emph{Arguments}:
6681 @multitable @columnfractions .15 .70
6682 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6683 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6684 @end multitable
6685
6686 @item @emph{Return value}:
6687 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
6688 otherwise, based on the ASCII ordering.
6689
6690 @item @emph{See also}:
6691 @ref{LGE}, @ref{LLE}, @ref{LLT}
6692 @end table
6693
6694
6695
6696 @node LINK
6697 @section @code{LINK} --- Create a hard link
6698 @fnindex LINK
6699 @cindex file system, create link
6700 @cindex file system, hard link
6701
6702 @table @asis
6703 @item @emph{Description}:
6704 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
6705 character (@code{CHAR(0)}) can be used to mark the end of the names in
6706 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
6707 names are ignored.  If the @var{STATUS} argument is supplied, it
6708 contains 0 on success or a nonzero error code upon return; see
6709 @code{link(2)}.
6710
6711 This intrinsic is provided in both subroutine and function forms;
6712 however, only one form can be used in any given program unit.
6713
6714 @item @emph{Standard}:
6715 GNU extension
6716
6717 @item @emph{Class}:
6718 Subroutine, function
6719
6720 @item @emph{Syntax}:
6721 @multitable @columnfractions .80
6722 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
6723 @item @code{STATUS = LINK(PATH1, PATH2)}
6724 @end multitable
6725
6726 @item @emph{Arguments}:
6727 @multitable @columnfractions .15 .70
6728 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
6729 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
6730 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
6731 @end multitable
6732
6733 @item @emph{See also}:
6734 @ref{SYMLNK}, @ref{UNLINK}
6735 @end table
6736
6737
6738
6739 @node LLE
6740 @section @code{LLE} --- Lexical less than or equal
6741 @fnindex LLE
6742 @cindex lexical comparison of strings
6743 @cindex string, comparison
6744
6745 @table @asis
6746 @item @emph{Description}:
6747 Determines whether one string is lexically less than or equal to another
6748 string, where the two strings are interpreted as containing ASCII
6749 character codes.  If the String A and String B are not the same length,
6750 the shorter is compared as if spaces were appended to it to form a value
6751 that has the same length as the longer.
6752
6753 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6754 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6755 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6756 that the latter use the processor's character ordering (which is not
6757 ASCII on some targets), whereas the former always use the ASCII
6758 ordering.
6759
6760 @item @emph{Standard}:
6761 Fortran 77 and later
6762
6763 @item @emph{Class}:
6764 Elemental function
6765
6766 @item @emph{Syntax}:
6767 @code{RESULT = LLE(STRING_A, STRING_B)}
6768
6769 @item @emph{Arguments}:
6770 @multitable @columnfractions .15 .70
6771 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6772 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6773 @end multitable
6774
6775 @item @emph{Return value}:
6776 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
6777 otherwise, based on the ASCII ordering.
6778
6779 @item @emph{See also}:
6780 @ref{LGE}, @ref{LGT}, @ref{LLT}
6781 @end table
6782
6783
6784
6785 @node LLT
6786 @section @code{LLT} --- Lexical less than
6787 @fnindex LLT
6788 @cindex lexical comparison of strings
6789 @cindex string, comparison
6790
6791 @table @asis
6792 @item @emph{Description}:
6793 Determines whether one string is lexically less than another string,
6794 where the two strings are interpreted as containing ASCII character
6795 codes.  If the String A and String B are not the same length, the
6796 shorter is compared as if spaces were appended to it to form a value
6797 that has the same length as the longer.
6798
6799 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6800 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6801 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6802 that the latter use the processor's character ordering (which is not
6803 ASCII on some targets), whereas the former always use the ASCII
6804 ordering.
6805
6806 @item @emph{Standard}:
6807 Fortran 77 and later
6808
6809 @item @emph{Class}:
6810 Elemental function
6811
6812 @item @emph{Syntax}:
6813 @code{RESULT = LLT(STRING_A, STRING_B)}
6814
6815 @item @emph{Arguments}:
6816 @multitable @columnfractions .15 .70
6817 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6818 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6819 @end multitable
6820
6821 @item @emph{Return value}:
6822 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
6823 otherwise, based on the ASCII ordering.
6824
6825 @item @emph{See also}:
6826 @ref{LGE}, @ref{LGT}, @ref{LLE}
6827 @end table
6828
6829
6830
6831 @node LNBLNK
6832 @section @code{LNBLNK} --- Index of the last non-blank character in a string
6833 @fnindex LNBLNK
6834 @cindex string, find non-blank character
6835
6836 @table @asis
6837 @item @emph{Description}:
6838 Returns the length of a character string, ignoring any trailing blanks.
6839 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
6840 included for backwards compatibility.
6841
6842 @item @emph{Standard}:
6843 GNU extension
6844
6845 @item @emph{Class}:
6846 Elemental function
6847
6848 @item @emph{Syntax}:
6849 @code{RESULT = LNBLNK(STRING)}
6850
6851 @item @emph{Arguments}:
6852 @multitable @columnfractions .15 .70
6853 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
6854 with @code{INTENT(IN)}
6855 @end multitable
6856
6857 @item @emph{Return value}:
6858 The return value is of @code{INTEGER(kind=4)} type.
6859
6860 @item @emph{See also}:
6861 @ref{INDEX intrinsic}, @ref{LEN_TRIM}
6862 @end table
6863
6864
6865
6866 @node LOC
6867 @section @code{LOC} --- Returns the address of a variable
6868 @fnindex LOC
6869 @cindex location of a variable in memory
6870
6871 @table @asis
6872 @item @emph{Description}:
6873 @code{LOC(X)} returns the address of @var{X} as an integer.
6874
6875 @item @emph{Standard}:
6876 GNU extension
6877
6878 @item @emph{Class}:
6879 Inquiry function
6880
6881 @item @emph{Syntax}:
6882 @code{RESULT = LOC(X)}
6883
6884 @item @emph{Arguments}:
6885 @multitable @columnfractions .15 .70
6886 @item @var{X} @tab Variable of any type.
6887 @end multitable
6888
6889 @item @emph{Return value}:
6890 The return value is of type @code{INTEGER}, with a @code{KIND}
6891 corresponding to the size (in bytes) of a memory address on the target
6892 machine.
6893
6894 @item @emph{Example}:
6895 @smallexample
6896 program test_loc
6897   integer :: i
6898   real :: r
6899   i = loc(r)
6900   print *, i
6901 end program test_loc
6902 @end smallexample
6903 @end table
6904
6905
6906
6907 @node LOG
6908 @section @code{LOG} --- Logarithm function
6909 @fnindex LOG
6910 @fnindex ALOG
6911 @fnindex DLOG
6912 @fnindex CLOG
6913 @fnindex ZLOG
6914 @fnindex CDLOG
6915 @cindex exponential function, inverse
6916 @cindex logarithmic function
6917
6918 @table @asis
6919 @item @emph{Description}:
6920 @code{LOG(X)} computes the logarithm of @var{X}.
6921
6922 @item @emph{Standard}:
6923 Fortran 77 and later
6924
6925 @item @emph{Class}:
6926 Elemental function
6927
6928 @item @emph{Syntax}:
6929 @code{RESULT = LOG(X)}
6930
6931 @item @emph{Arguments}:
6932 @multitable @columnfractions .15 .70
6933 @item @var{X} @tab The type shall be @code{REAL} or
6934 @code{COMPLEX}.
6935 @end multitable
6936
6937 @item @emph{Return value}:
6938 The return value is of type @code{REAL} or @code{COMPLEX}.
6939 The kind type parameter is the same as @var{X}.
6940
6941 @item @emph{Example}:
6942 @smallexample
6943 program test_log
6944   real(8) :: x = 1.0_8
6945   complex :: z = (1.0, 2.0)
6946   x = log(x)
6947   z = log(z)
6948 end program test_log
6949 @end smallexample
6950
6951 @item @emph{Specific names}:
6952 @multitable @columnfractions .20 .20 .20 .25
6953 @item Name            @tab Argument          @tab Return type       @tab Standard
6954 @item @code{ALOG(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab f95, gnu
6955 @item @code{DLOG(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
6956 @item @code{CLOG(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
6957 @item @code{ZLOG(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
6958 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
6959 @end multitable
6960 @end table
6961
6962
6963
6964 @node LOG10
6965 @section @code{LOG10} --- Base 10 logarithm function
6966 @fnindex LOG10
6967 @fnindex ALOG10
6968 @fnindex DLOG10
6969 @cindex exponential function, inverse
6970 @cindex logarithmic function
6971
6972 @table @asis
6973 @item @emph{Description}:
6974 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
6975
6976 @item @emph{Standard}:
6977 Fortran 77 and later
6978
6979 @item @emph{Class}:
6980 Elemental function
6981
6982 @item @emph{Syntax}:
6983 @code{RESULT = LOG10(X)}
6984
6985 @item @emph{Arguments}:
6986 @multitable @columnfractions .15 .70
6987 @item @var{X} @tab The type shall be @code{REAL}.
6988 @end multitable
6989
6990 @item @emph{Return value}:
6991 The return value is of type @code{REAL} or @code{COMPLEX}.
6992 The kind type parameter is the same as @var{X}.
6993
6994 @item @emph{Example}:
6995 @smallexample
6996 program test_log10
6997   real(8) :: x = 10.0_8
6998   x = log10(x)
6999 end program test_log10
7000 @end smallexample
7001
7002 @item @emph{Specific names}:
7003 @multitable @columnfractions .20 .20 .20 .25
7004 @item Name            @tab Argument          @tab Return type       @tab Standard
7005 @item @code{ALOG10(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
7006 @item @code{DLOG10(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
7007 @end multitable
7008 @end table
7009
7010
7011
7012 @node LOG_GAMMA
7013 @section @code{LOG_GAMMA} --- Logarithm of the Gamma function
7014 @fnindex LOG_GAMMA
7015 @fnindex LGAMMA
7016 @fnindex ALGAMA
7017 @fnindex DLGAMA
7018 @cindex Gamma function, logarithm of
7019
7020 @table @asis
7021 @item @emph{Description}:
7022 @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
7023 of the Gamma (@math{\Gamma}) function.
7024
7025 @item @emph{Standard}:
7026 Fortran 2008 and later
7027
7028 @item @emph{Class}:
7029 Elemental function
7030
7031 @item @emph{Syntax}:
7032 @code{X = LOG_GAMMA(X)}
7033
7034 @item @emph{Arguments}:
7035 @multitable @columnfractions .15 .70
7036 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
7037 nor a negative integer.
7038 @end multitable
7039
7040 @item @emph{Return value}:
7041 The return value is of type @code{REAL} of the same kind as @var{X}.
7042
7043 @item @emph{Example}:
7044 @smallexample
7045 program test_log_gamma
7046   real :: x = 1.0
7047   x = lgamma(x) ! returns 0.0
7048 end program test_log_gamma
7049 @end smallexample
7050
7051 @item @emph{Specific names}:
7052 @multitable @columnfractions .20 .20 .20 .25
7053 @item Name             @tab Argument         @tab Return type       @tab Standard
7054 @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
7055 @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
7056 @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
7057 @end multitable
7058
7059 @item @emph{See also}:
7060 Gamma function: @ref{GAMMA}
7061
7062 @end table
7063
7064
7065
7066 @node LOGICAL
7067 @section @code{LOGICAL} --- Convert to logical type
7068 @fnindex LOGICAL
7069 @cindex conversion, to logical
7070
7071 @table @asis
7072 @item @emph{Description}:
7073 Converts one kind of @code{LOGICAL} variable to another.
7074
7075 @item @emph{Standard}:
7076 Fortran 95 and later
7077
7078 @item @emph{Class}:
7079 Elemental function
7080
7081 @item @emph{Syntax}:
7082 @code{RESULT = LOGICAL(L [, KIND])}
7083
7084 @item @emph{Arguments}:
7085 @multitable @columnfractions .15 .70
7086 @item @var{L}    @tab The type shall be @code{LOGICAL}.
7087 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7088                       expression indicating the kind parameter of
7089                       the result.
7090 @end multitable
7091
7092 @item @emph{Return value}:
7093 The return value is a @code{LOGICAL} value equal to @var{L}, with a
7094 kind corresponding to @var{KIND}, or of the default logical kind if
7095 @var{KIND} is not given.
7096
7097 @item @emph{See also}:
7098 @ref{INT}, @ref{REAL}, @ref{CMPLX}
7099 @end table
7100
7101
7102
7103 @node LONG
7104 @section @code{LONG} --- Convert to integer type
7105 @fnindex LONG
7106 @cindex conversion, to integer
7107
7108 @table @asis
7109 @item @emph{Description}:
7110 Convert to a @code{KIND=4} integer type, which is the same size as a C
7111 @code{long} integer.  This is equivalent to the standard @code{INT}
7112 intrinsic with an optional argument of @code{KIND=4}, and is only
7113 included for backwards compatibility.
7114
7115 @item @emph{Standard}:
7116 GNU extension
7117
7118 @item @emph{Class}:
7119 Elemental function
7120
7121 @item @emph{Syntax}:
7122 @code{RESULT = LONG(A)}
7123
7124 @item @emph{Arguments}:
7125 @multitable @columnfractions .15 .70
7126 @item @var{A}    @tab Shall be of type @code{INTEGER},
7127                       @code{REAL}, or @code{COMPLEX}.
7128 @end multitable
7129
7130 @item @emph{Return value}:
7131 The return value is a @code{INTEGER(4)} variable.
7132
7133 @item @emph{See also}:
7134 @ref{INT}, @ref{INT2}, @ref{INT8}
7135 @end table
7136
7137
7138
7139 @node LSHIFT
7140 @section @code{LSHIFT} --- Left shift bits
7141 @fnindex LSHIFT
7142 @cindex bits, shift left
7143
7144 @table @asis
7145 @item @emph{Description}:
7146 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
7147 bits shifted left by @var{SHIFT} places.  If the absolute value of
7148 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined. 
7149 Bits shifted out from the left end are lost; zeros are shifted in from
7150 the opposite end.
7151
7152 This function has been superseded by the @code{ISHFT} intrinsic, which
7153 is standard in Fortran 95 and later.
7154
7155 @item @emph{Standard}:
7156 GNU extension
7157
7158 @item @emph{Class}:
7159 Elemental function
7160
7161 @item @emph{Syntax}:
7162 @code{RESULT = LSHIFT(I, SHIFT)}
7163
7164 @item @emph{Arguments}:
7165 @multitable @columnfractions .15 .70
7166 @item @var{I} @tab The type shall be @code{INTEGER}.
7167 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
7168 @end multitable
7169
7170 @item @emph{Return value}:
7171 The return value is of type @code{INTEGER} and of the same kind as
7172 @var{I}.
7173
7174 @item @emph{See also}:
7175 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
7176
7177 @end table
7178
7179
7180
7181 @node LSTAT
7182 @section @code{LSTAT} --- Get file status
7183 @fnindex LSTAT
7184 @cindex file system, file status
7185
7186 @table @asis
7187 @item @emph{Description}:
7188 @code{LSTAT} is identical to @ref{STAT}, except that if path is a symbolic link, 
7189 then the link itself is statted, not the file that it refers to.
7190
7191 The elements in @code{BUFF} are the same as described by @ref{STAT}.
7192
7193 This intrinsic is provided in both subroutine and function forms; however,
7194 only one form can be used in any given program unit.
7195
7196 @item @emph{Standard}:
7197 GNU extension
7198
7199 @item @emph{Class}:
7200 Subroutine, function
7201
7202 @item @emph{Syntax}:
7203 @code{CALL LSTAT(FILE, BUFF [, STATUS])}
7204
7205 @item @emph{Arguments}:
7206 @multitable @columnfractions .15 .70
7207 @item @var{FILE}   @tab The type shall be @code{CHARACTER} of the default
7208 kind, a valid path within the file system.
7209 @item @var{BUFF}   @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
7210 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
7211 Returns 0 on success and a system specific error code otherwise.
7212 @end multitable
7213
7214 @item @emph{Example}:
7215 See @ref{STAT} for an example.
7216
7217 @item @emph{See also}:
7218 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
7219 @end table
7220
7221
7222
7223 @node LTIME
7224 @section @code{LTIME} --- Convert time to local time info
7225 @fnindex LTIME
7226 @cindex time, conversion to local time info
7227
7228 @table @asis
7229 @item @emph{Description}:
7230 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
7231 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
7232 to the local time zone using @code{localtime(3)}.
7233
7234 @item @emph{Standard}:
7235 GNU extension
7236
7237 @item @emph{Class}:
7238 Subroutine
7239
7240 @item @emph{Syntax}:
7241 @code{CALL LTIME(STIME, TARRAY)}
7242
7243 @item @emph{Arguments}:
7244 @multitable @columnfractions .15 .70
7245 @item @var{STIME}  @tab An @code{INTEGER} scalar expression
7246                         corresponding to a system time, with 
7247                         @code{INTENT(IN)}.
7248 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
7249                         with @code{INTENT(OUT)}.
7250 @end multitable
7251
7252 @item @emph{Return value}:
7253 The elements of @var{TARRAY} are assigned as follows:
7254 @enumerate
7255 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
7256       seconds
7257 @item Minutes after the hour, range 0--59
7258 @item Hours past midnight, range 0--23
7259 @item Day of month, range 0--31
7260 @item Number of months since January, range 0--12
7261 @item Years since 1900
7262 @item Number of days since Sunday, range 0--6
7263 @item Days since January 1
7264 @item Daylight savings indicator: positive if daylight savings is in
7265       effect, zero if not, and negative if the information is not
7266       available.
7267 @end enumerate
7268
7269 @item @emph{See also}:
7270 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
7271
7272 @end table
7273
7274
7275
7276 @node MALLOC
7277 @section @code{MALLOC} --- Allocate dynamic memory
7278 @fnindex MALLOC
7279 @cindex pointer, cray
7280
7281 @table @asis
7282 @item @emph{Description}:
7283 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
7284 returns the address of the allocated memory. The @code{MALLOC} intrinsic
7285 is an extension intended to be used with Cray pointers, and is provided
7286 in GNU Fortran to allow the user to compile legacy code. For new code
7287 using Fortran 95 pointers, the memory allocation intrinsic is
7288 @code{ALLOCATE}.
7289
7290 @item @emph{Standard}:
7291 GNU extension
7292
7293 @item @emph{Class}:
7294 Function
7295
7296 @item @emph{Syntax}:
7297 @code{PTR = MALLOC(SIZE)}
7298
7299 @item @emph{Arguments}:
7300 @multitable @columnfractions .15 .70
7301 @item @var{SIZE} @tab The type shall be @code{INTEGER}.
7302 @end multitable
7303
7304 @item @emph{Return value}:
7305 The return value is of type @code{INTEGER(K)}, with @var{K} such that
7306 variables of type @code{INTEGER(K)} have the same size as
7307 C pointers (@code{sizeof(void *)}).
7308
7309 @item @emph{Example}:
7310 The following example demonstrates the use of @code{MALLOC} and
7311 @code{FREE} with Cray pointers. This example is intended to run on
7312 32-bit systems, where the default integer kind is suitable to store
7313 pointers; on 64-bit systems, ptr_x would need to be declared as
7314 @code{integer(kind=8)}.
7315
7316 @smallexample
7317 program test_malloc
7318   integer i
7319   integer ptr_x
7320   real*8 x(*), z
7321   pointer(ptr_x,x)
7322
7323   ptr_x = malloc(20*8)
7324   do i = 1, 20
7325     x(i) = sqrt(1.0d0 / i)
7326   end do
7327   z = 0
7328   do i = 1, 20
7329     z = z + x(i)
7330     print *, z
7331   end do
7332   call free(ptr_x)
7333 end program test_malloc
7334 @end smallexample
7335
7336 @item @emph{See also}:
7337 @ref{FREE}
7338 @end table
7339
7340
7341
7342 @node MATMUL
7343 @section @code{MATMUL} --- matrix multiplication
7344 @fnindex MATMUL
7345 @cindex matrix multiplication
7346 @cindex product, matrix
7347
7348 @table @asis
7349 @item @emph{Description}:
7350 Performs a matrix multiplication on numeric or logical arguments.
7351
7352 @item @emph{Standard}:
7353 Fortran 95 and later
7354
7355 @item @emph{Class}:
7356 Transformational function
7357
7358 @item @emph{Syntax}:
7359 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
7360
7361 @item @emph{Arguments}:
7362 @multitable @columnfractions .15 .70
7363 @item @var{MATRIX_A} @tab An array of @code{INTEGER},
7364                           @code{REAL}, @code{COMPLEX}, or
7365                           @code{LOGICAL} type, with a rank of
7366                           one or two.
7367 @item @var{MATRIX_B} @tab An array of @code{INTEGER},
7368                           @code{REAL}, or @code{COMPLEX} type if
7369                           @var{MATRIX_A} is of a numeric type;
7370                           otherwise, an array of @code{LOGICAL}
7371                           type. The rank shall be one or two, and the
7372                           first (or only) dimension of @var{MATRIX_B}
7373                           shall be equal to the last (or only)
7374                           dimension of @var{MATRIX_A}.
7375 @end multitable
7376
7377 @item @emph{Return value}:
7378 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}.  The type and
7379 kind of the result follow the usual type and kind promotion rules, as
7380 for the @code{*} or @code{.AND.} operators.
7381
7382 @item @emph{See also}:
7383 @end table
7384
7385
7386
7387 @node MAX
7388 @section @code{MAX} --- Maximum value of an argument list
7389 @fnindex MAX
7390 @fnindex MAX0
7391 @fnindex AMAX0
7392 @fnindex MAX1
7393 @fnindex AMAX1
7394 @fnindex DMAX1
7395 @cindex maximum value
7396
7397 @table @asis
7398 @item @emph{Description}:
7399 Returns the argument with the largest (most positive) value.
7400
7401 @item @emph{Standard}:
7402 Fortran 77 and later
7403
7404 @item @emph{Class}:
7405 Elemental function
7406
7407 @item @emph{Syntax}:
7408 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
7409
7410 @item @emph{Arguments}:
7411 @multitable @columnfractions .15 .70
7412 @item @var{A1}          @tab The type shall be @code{INTEGER} or
7413                              @code{REAL}.
7414 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
7415                              as @var{A1}.  (As a GNU extension, 
7416                              arguments of different kinds are
7417                              permitted.)
7418 @end multitable
7419
7420 @item @emph{Return value}:
7421 The return value corresponds to the maximum value among the arguments,
7422 and has the same type and kind as the first argument.
7423
7424 @item @emph{Specific names}:
7425 @multitable @columnfractions .20 .20 .20 .25
7426 @item Name             @tab Argument            @tab Return type         @tab Standard
7427 @item @code{MAX0(I)}   @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)}   @tab Fortran 77 and later
7428 @item @code{AMAX0(I)}  @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
7429 @item @code{MAX1(X)}   @tab @code{REAL X}    @tab @code{INT(MAX(X))}  @tab Fortran 77 and later
7430 @item @code{AMAX1(X)}  @tab @code{REAL(4)    X} @tab @code{REAL(4)}      @tab Fortran 77 and later
7431 @item @code{DMAX1(X)}  @tab @code{REAL(8)    X} @tab @code{REAL(8)}      @tab Fortran 77 and later
7432 @end multitable
7433
7434 @item @emph{See also}:
7435 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
7436
7437 @end table
7438
7439
7440
7441 @node MAXEXPONENT
7442 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
7443 @fnindex MAXEXPONENT
7444 @cindex model representation, maximum exponent
7445
7446 @table @asis
7447 @item @emph{Description}:
7448 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
7449 type of @code{X}.
7450
7451 @item @emph{Standard}:
7452 Fortran 95 and later
7453
7454 @item @emph{Class}:
7455 Inquiry function
7456
7457 @item @emph{Syntax}:
7458 @code{RESULT = MAXEXPONENT(X)}
7459
7460 @item @emph{Arguments}:
7461 @multitable @columnfractions .15 .70
7462 @item @var{X} @tab Shall be of type @code{REAL}.
7463 @end multitable
7464
7465 @item @emph{Return value}:
7466 The return value is of type @code{INTEGER} and of the default integer
7467 kind.
7468
7469 @item @emph{Example}:
7470 @smallexample
7471 program exponents
7472   real(kind=4) :: x
7473   real(kind=8) :: y
7474
7475   print *, minexponent(x), maxexponent(x)
7476   print *, minexponent(y), maxexponent(y)
7477 end program exponents
7478 @end smallexample
7479 @end table
7480
7481
7482
7483 @node MAXLOC
7484 @section @code{MAXLOC} --- Location of the maximum value within an array
7485 @fnindex MAXLOC
7486 @cindex array, location of maximum element
7487
7488 @table @asis
7489 @item @emph{Description}:
7490 Determines the location of the element in the array with the maximum
7491 value, or, if the @var{DIM} argument is supplied, determines the
7492 locations of the maximum element along each row of the array in the
7493 @var{DIM} direction.  If @var{MASK} is present, only the elements for
7494 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
7495 element in the array has the maximum value, the location returned is
7496 that of the first such element in array element order.  If the array has
7497 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
7498 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
7499 and all of the elements of @var{MASK} along a given row are zero, the
7500 result value for that row is zero.
7501
7502 @item @emph{Standard}:
7503 Fortran 95 and later
7504
7505 @item @emph{Class}:
7506 Transformational function
7507
7508 @item @emph{Syntax}:
7509 @multitable @columnfractions .80
7510 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
7511 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
7512 @end multitable
7513
7514 @item @emph{Arguments}:
7515 @multitable @columnfractions .15 .70
7516 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
7517                        @code{REAL}, or @code{CHARACTER}.
7518 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
7519                        @code{INTEGER}, with a value between one
7520                        and the rank of @var{ARRAY}, inclusive.  It
7521                        may not be an optional dummy argument.
7522 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
7523                        and conformable with @var{ARRAY}.
7524 @end multitable
7525
7526 @item @emph{Return value}:
7527 If @var{DIM} is absent, the result is a rank-one array with a length
7528 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
7529 is an array with a rank one less than the rank of @var{ARRAY}, and a
7530 size corresponding to the size of @var{ARRAY} with the @var{DIM}
7531 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
7532 of one, the result is a scalar.  In all cases, the result is of default
7533 @code{INTEGER} type.
7534
7535 @item @emph{See also}:
7536 @ref{MAX}, @ref{MAXVAL}
7537
7538 @end table
7539
7540
7541
7542 @node MAXVAL
7543 @section @code{MAXVAL} --- Maximum value of an array
7544 @fnindex MAXVAL
7545 @cindex array, maximum value
7546 @cindex maximum value
7547
7548 @table @asis
7549 @item @emph{Description}:
7550 Determines the maximum value of the elements in an array value, or, if
7551 the @var{DIM} argument is supplied, determines the maximum value along
7552 each row of the array in the @var{DIM} direction.  If @var{MASK} is
7553 present, only the elements for which @var{MASK} is @code{.TRUE.} are
7554 considered.  If the array has zero size, or all of the elements of
7555 @var{MASK} are @code{.FALSE.}, then the result is the most negative
7556 number of the type and kind of @var{ARRAY} if @var{ARRAY} is numeric, or
7557 a string of nulls if @var{ARRAY} is of character type.
7558
7559 @item @emph{Standard}:
7560 Fortran 95 and later
7561
7562 @item @emph{Class}:
7563 Transformational function
7564
7565 @item @emph{Syntax}:
7566 @multitable @columnfractions .80
7567 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
7568 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
7569 @end multitable
7570
7571 @item @emph{Arguments}:
7572 @multitable @columnfractions .15 .70
7573 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
7574                        @code{REAL}, or @code{CHARACTER}.
7575 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
7576                        @code{INTEGER}, with a value between one
7577                        and the rank of @var{ARRAY}, inclusive.  It
7578                        may not be an optional dummy argument.
7579 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
7580                        and conformable with @var{ARRAY}.
7581 @end multitable
7582
7583 @item @emph{Return value}:
7584 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
7585 is a scalar.  If @var{DIM} is present, the result is an array with a
7586 rank one less than the rank of @var{ARRAY}, and a size corresponding to
7587 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
7588 cases, the result is of the same type and kind as @var{ARRAY}.
7589
7590 @item @emph{See also}:
7591 @ref{MAX}, @ref{MAXLOC}
7592 @end table
7593
7594
7595
7596 @node MCLOCK
7597 @section @code{MCLOCK} --- Time function
7598 @fnindex MCLOCK
7599 @cindex time, clock ticks
7600 @cindex clock ticks
7601
7602 @table @asis
7603 @item @emph{Description}:
7604 Returns the number of clock ticks since the start of the process, based
7605 on the UNIX function @code{clock(3)}.
7606
7607 This intrinsic is not fully portable, such as to systems with 32-bit
7608 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
7609 the values returned by this intrinsic might be, or become, negative, or
7610 numerically less than previous values, during a single run of the
7611 compiled program.
7612
7613 @item @emph{Standard}:
7614 GNU extension
7615
7616 @item @emph{Class}:
7617 Function
7618
7619 @item @emph{Syntax}:
7620 @code{RESULT = MCLOCK()}
7621
7622 @item @emph{Return value}:
7623 The return value is a scalar of type @code{INTEGER(4)}, equal to the
7624 number of clock ticks since the start of the process, or @code{-1} if
7625 the system does not support @code{clock(3)}.
7626
7627 @item @emph{See also}:
7628 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
7629
7630 @end table
7631
7632
7633
7634 @node MCLOCK8
7635 @section @code{MCLOCK8} --- Time function (64-bit)
7636 @fnindex MCLOCK8
7637 @cindex time, clock ticks
7638 @cindex clock ticks
7639
7640 @table @asis
7641 @item @emph{Description}:
7642 Returns the number of clock ticks since the start of the process, based
7643 on the UNIX function @code{clock(3)}.
7644
7645 @emph{Warning:} this intrinsic does not increase the range of the timing
7646 values over that returned by @code{clock(3)}. On a system with a 32-bit
7647 @code{clock(3)}, @code{MCLOCK8()} will return a 32-bit value, even though
7648 it is converted to a 64-bit @code{INTEGER(8)} value. That means
7649 overflows of the 32-bit value can still occur. Therefore, the values
7650 returned by this intrinsic might be or become negative or numerically
7651 less than previous values during a single run of the compiled program.
7652
7653 @item @emph{Standard}:
7654 GNU extension
7655
7656 @item @emph{Class}:
7657 Function
7658
7659 @item @emph{Syntax}:
7660 @code{RESULT = MCLOCK8()}
7661
7662 @item @emph{Return value}:
7663 The return value is a scalar of type @code{INTEGER(8)}, equal to the
7664 number of clock ticks since the start of the process, or @code{-1} if
7665 the system does not support @code{clock(3)}.
7666
7667 @item @emph{See also}:
7668 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
7669
7670 @end table
7671
7672
7673
7674 @node MERGE
7675 @section @code{MERGE} --- Merge variables
7676 @fnindex MERGE
7677 @cindex array, merge arrays
7678 @cindex array, combine arrays
7679
7680 @table @asis
7681 @item @emph{Description}:
7682 Select values from two arrays according to a logical mask.  The result
7683 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
7684 @var{FSOURCE} if it is @code{.FALSE.}.
7685
7686 @item @emph{Standard}:
7687 Fortran 95 and later
7688
7689 @item @emph{Class}:
7690 Elemental function
7691
7692 @item @emph{Syntax}:
7693 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
7694
7695 @item @emph{Arguments}:
7696 @multitable @columnfractions .15 .70
7697 @item @var{TSOURCE} @tab May be of any type.
7698 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
7699                          as @var{TSOURCE}.
7700 @item @var{MASK}    @tab Shall be of type @code{LOGICAL}.
7701 @end multitable
7702
7703 @item @emph{Return value}:
7704 The result is of the same type and type parameters as @var{TSOURCE}.
7705
7706 @end table
7707
7708
7709
7710 @node MIN
7711 @section @code{MIN} --- Minimum value of an argument list
7712 @fnindex MIN
7713 @fnindex MIN0
7714 @fnindex AMIN0
7715 @fnindex MIN1
7716 @fnindex AMIN1
7717 @fnindex DMIN1
7718 @cindex minimum value
7719
7720 @table @asis
7721 @item @emph{Description}:
7722 Returns the argument with the smallest (most negative) value.
7723
7724 @item @emph{Standard}:
7725 Fortran 77 and later
7726
7727 @item @emph{Class}:
7728 Elemental function
7729
7730 @item @emph{Syntax}:
7731 @code{RESULT = MIN(A1, A2 [, A3, ...])}
7732
7733 @item @emph{Arguments}:
7734 @multitable @columnfractions .15 .70
7735 @item @var{A1}          @tab The type shall be @code{INTEGER} or
7736                              @code{REAL}.
7737 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
7738                              as @var{A1}.  (As a GNU extension, 
7739                              arguments of different kinds are
7740                              permitted.)
7741 @end multitable
7742
7743 @item @emph{Return value}:
7744 The return value corresponds to the maximum value among the arguments,
7745 and has the same type and kind as the first argument.
7746
7747 @item @emph{Specific names}:
7748 @multitable @columnfractions .20 .20 .20 .25
7749 @item Name             @tab Argument            @tab Return type         @tab Standard
7750 @item @code{MIN0(I)}   @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)}   @tab Fortran 77 and later
7751 @item @code{AMIN0(I)}  @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab Fortran 77 and later
7752 @item @code{MIN1(X)}   @tab @code{REAL X}    @tab @code{INT(MIN(X))}  @tab Fortran 77 and later
7753 @item @code{AMIN1(X)}  @tab @code{REAL(4)    X} @tab @code{REAL(4)}      @tab Fortran 77 and later
7754 @item @code{DMIN1(X)}  @tab @code{REAL(8)    X} @tab @code{REAL(8)}      @tab Fortran 77 and later
7755 @end multitable
7756
7757 @item @emph{See also}:
7758 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
7759 @end table
7760
7761
7762
7763 @node MINEXPONENT
7764 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
7765 @fnindex MINEXPONENT
7766 @cindex model representation, minimum exponent
7767
7768 @table @asis
7769 @item @emph{Description}:
7770 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
7771 type of @code{X}.
7772
7773 @item @emph{Standard}:
7774 Fortran 95 and later
7775
7776 @item @emph{Class}:
7777 Inquiry function
7778
7779 @item @emph{Syntax}:
7780 @code{RESULT = MINEXPONENT(X)}
7781
7782 @item @emph{Arguments}:
7783 @multitable @columnfractions .15 .70
7784 @item @var{X} @tab Shall be of type @code{REAL}.
7785 @end multitable
7786
7787 @item @emph{Return value}:
7788 The return value is of type @code{INTEGER} and of the default integer
7789 kind.
7790
7791 @item @emph{Example}:
7792 See @code{MAXEXPONENT} for an example.
7793 @end table
7794
7795
7796
7797 @node MINLOC
7798 @section @code{MINLOC} --- Location of the minimum value within an array
7799 @fnindex MINLOC
7800 @cindex array, location of minimum element
7801
7802 @table @asis
7803 @item @emph{Description}:
7804 Determines the location of the element in the array with the minimum
7805 value, or, if the @var{DIM} argument is supplied, determines the
7806 locations of the minimum element along each row of the array in the
7807 @var{DIM} direction.  If @var{MASK} is present, only the elements for
7808 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
7809 element in the array has the minimum value, the location returned is
7810 that of the first such element in array element order.  If the array has
7811 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
7812 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
7813 and all of the elements of @var{MASK} along a given row are zero, the
7814 result value for that row is zero.
7815
7816 @item @emph{Standard}:
7817 Fortran 95 and later
7818
7819 @item @emph{Class}:
7820 Transformational function
7821
7822 @item @emph{Syntax}:
7823 @multitable @columnfractions .80
7824 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
7825 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
7826 @end multitable
7827
7828 @item @emph{Arguments}:
7829 @multitable @columnfractions .15 .70
7830 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
7831                        @code{REAL}, or @code{CHARACTER}.
7832 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
7833                        @code{INTEGER}, with a value between one
7834                        and the rank of @var{ARRAY}, inclusive.  It
7835                        may not be an optional dummy argument.
7836 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
7837                        and conformable with @var{ARRAY}.
7838 @end multitable
7839
7840 @item @emph{Return value}:
7841 If @var{DIM} is absent, the result is a rank-one array with a length
7842 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
7843 is an array with a rank one less than the rank of @var{ARRAY}, and a
7844 size corresponding to the size of @var{ARRAY} with the @var{DIM}
7845 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
7846 of one, the result is a scalar.  In all cases, the result is of default
7847 @code{INTEGER} type.
7848
7849 @item @emph{See also}:
7850 @ref{MIN}, @ref{MINVAL}
7851
7852 @end table
7853
7854
7855
7856 @node MINVAL
7857 @section @code{MINVAL} --- Minimum value of an array
7858 @fnindex MINVAL
7859 @cindex array, minimum value
7860 @cindex minimum value
7861
7862 @table @asis
7863 @item @emph{Description}:
7864 Determines the minimum value of the elements in an array value, or, if
7865 the @var{DIM} argument is supplied, determines the minimum value along
7866 each row of the array in the @var{DIM} direction.  If @var{MASK} is
7867 present, only the elements for which @var{MASK} is @code{.TRUE.} are
7868 considered.  If the array has zero size, or all of the elements of
7869 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
7870 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
7871 @var{ARRAY} is of character type.
7872
7873 @item @emph{Standard}:
7874 Fortran 95 and later
7875
7876 @item @emph{Class}:
7877 Transformational function
7878
7879 @item @emph{Syntax}:
7880 @multitable @columnfractions .80
7881 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
7882 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
7883 @end multitable
7884
7885 @item @emph{Arguments}:
7886 @multitable @columnfractions .15 .70
7887 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
7888                        @code{REAL}, or @code{CHARACTER}.
7889 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
7890                        @code{INTEGER}, with a value between one
7891                        and the rank of @var{ARRAY}, inclusive.  It
7892                        may not be an optional dummy argument.
7893 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
7894                        and conformable with @var{ARRAY}.
7895 @end multitable
7896
7897 @item @emph{Return value}:
7898 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
7899 is a scalar.  If @var{DIM} is present, the result is an array with a
7900 rank one less than the rank of @var{ARRAY}, and a size corresponding to
7901 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
7902 cases, the result is of the same type and kind as @var{ARRAY}.
7903
7904 @item @emph{See also}:
7905 @ref{MIN}, @ref{MINLOC}
7906
7907 @end table
7908
7909
7910
7911 @node MOD
7912 @section @code{MOD} --- Remainder function
7913 @fnindex MOD
7914 @fnindex AMOD
7915 @fnindex DMOD
7916 @cindex remainder
7917 @cindex division, remainder
7918
7919 @table @asis
7920 @item @emph{Description}:
7921 @code{MOD(A,P)} computes the remainder of the division of A by P@. It is
7922 calculated as @code{A - (INT(A/P) * P)}.
7923
7924 @item @emph{Standard}:
7925 Fortran 77 and later
7926
7927 @item @emph{Class}:
7928 Elemental function
7929
7930 @item @emph{Syntax}:
7931 @code{RESULT = MOD(A, P)}
7932
7933 @item @emph{Arguments}:
7934 @multitable @columnfractions .15 .70
7935 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
7936 @item @var{P} @tab Shall be a scalar of the same type as @var{A} and not
7937 equal to zero
7938 @end multitable
7939
7940 @item @emph{Return value}:
7941 The kind of the return value is the result of cross-promoting
7942 the kinds of the arguments.
7943
7944 @item @emph{Example}:
7945 @smallexample
7946 program test_mod
7947   print *, mod(17,3)
7948   print *, mod(17.5,5.5)
7949   print *, mod(17.5d0,5.5)
7950   print *, mod(17.5,5.5d0)
7951
7952   print *, mod(-17,3)
7953   print *, mod(-17.5,5.5)
7954   print *, mod(-17.5d0,5.5)
7955   print *, mod(-17.5,5.5d0)
7956
7957   print *, mod(17,-3)
7958   print *, mod(17.5,-5.5)
7959   print *, mod(17.5d0,-5.5)
7960   print *, mod(17.5,-5.5d0)
7961 end program test_mod
7962 @end smallexample
7963
7964 @item @emph{Specific names}:
7965 @multitable @columnfractions .20 .20 .20 .25
7966 @item Name             @tab Arguments      @tab Return type    @tab Standard
7967 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab Fortran 95 and later
7968 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab Fortran 95 and later
7969 @end multitable
7970 @end table
7971
7972
7973
7974 @node MODULO
7975 @section @code{MODULO} --- Modulo function
7976 @fnindex MODULO
7977 @cindex modulo
7978 @cindex division, modulo
7979
7980 @table @asis
7981 @item @emph{Description}:
7982 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
7983
7984 @item @emph{Standard}:
7985 Fortran 95 and later
7986
7987 @item @emph{Class}:
7988 Elemental function
7989
7990 @item @emph{Syntax}:
7991 @code{RESULT = MODULO(A, P)}
7992
7993 @item @emph{Arguments}:
7994 @multitable @columnfractions .15 .70
7995 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
7996 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
7997 @end multitable
7998
7999 @item @emph{Return value}:
8000 The type and kind of the result are those of the arguments.
8001 @table @asis
8002 @item If @var{A} and @var{P} are of type @code{INTEGER}:
8003 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
8004 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
8005 (exclusive).
8006 @item If @var{A} and @var{P} are of type @code{REAL}:
8007 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
8008 @end table
8009 In all cases, if @var{P} is zero the result is processor-dependent.
8010
8011 @item @emph{Example}:
8012 @smallexample
8013 program test_modulo
8014   print *, modulo(17,3)
8015   print *, modulo(17.5,5.5)
8016
8017   print *, modulo(-17,3)
8018   print *, modulo(-17.5,5.5)
8019
8020   print *, modulo(17,-3)
8021   print *, modulo(17.5,-5.5)
8022 end program
8023 @end smallexample
8024
8025 @end table
8026
8027
8028
8029 @node MOVE_ALLOC
8030 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
8031 @fnindex MOVE_ALLOC
8032 @cindex moving allocation
8033 @cindex allocation, moving
8034
8035 @table @asis
8036 @item @emph{Description}:
8037 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
8038 @var{DEST}.  @var{SRC} will become deallocated in the process.
8039
8040 @item @emph{Standard}:
8041 Fortran 2003 and later
8042
8043 @item @emph{Class}:
8044 Subroutine
8045
8046 @item @emph{Syntax}:
8047 @code{CALL MOVE_ALLOC(SRC, DEST)}
8048
8049 @item @emph{Arguments}:
8050 @multitable @columnfractions .15 .70
8051 @item @var{SRC}  @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
8052                       of any type and kind.
8053 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
8054                       of the same type, kind and rank as @var{SRC}
8055 @end multitable
8056
8057 @item @emph{Return value}:
8058 None
8059
8060 @item @emph{Example}:
8061 @smallexample
8062 program test_move_alloc
8063     integer, allocatable :: a(:), b(:)
8064
8065     allocate(a(3))
8066     a = [ 1, 2, 3 ]
8067     call move_alloc(a, b)
8068     print *, allocated(a), allocated(b)
8069     print *, b
8070 end program test_move_alloc
8071 @end smallexample
8072 @end table
8073
8074
8075
8076 @node MVBITS
8077 @section @code{MVBITS} --- Move bits from one integer to another
8078 @fnindex MVBITS
8079 @cindex bits, move
8080
8081 @table @asis
8082 @item @emph{Description}:
8083 Moves @var{LEN} bits from positions @var{FROMPOS} through
8084 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
8085 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
8086 affected by the movement of bits is unchanged. The values of
8087 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
8088 @code{BIT_SIZE(FROM)}.
8089
8090 @item @emph{Standard}:
8091 Fortran 95 and later
8092
8093 @item @emph{Class}:
8094 Elemental subroutine
8095
8096 @item @emph{Syntax}:
8097 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
8098
8099 @item @emph{Arguments}:
8100 @multitable @columnfractions .15 .70
8101 @item @var{FROM}    @tab The type shall be @code{INTEGER}.
8102 @item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
8103 @item @var{LEN}     @tab The type shall be @code{INTEGER}.
8104 @item @var{TO}      @tab The type shall be @code{INTEGER}, of the
8105                          same kind as @var{FROM}.
8106 @item @var{TOPOS}   @tab The type shall be @code{INTEGER}.
8107 @end multitable
8108
8109 @item @emph{See also}:
8110 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
8111 @end table
8112
8113
8114
8115 @node NEAREST
8116 @section @code{NEAREST} --- Nearest representable number
8117 @fnindex NEAREST
8118 @cindex real number, nearest different
8119 @cindex floating point, nearest different
8120
8121 @table @asis
8122 @item @emph{Description}:
8123 @code{NEAREST(X, S)} returns the processor-representable number nearest
8124 to @code{X} in the direction indicated by the sign of @code{S}.
8125
8126 @item @emph{Standard}:
8127 Fortran 95 and later
8128
8129 @item @emph{Class}:
8130 Elemental function
8131
8132 @item @emph{Syntax}:
8133 @code{RESULT = NEAREST(X, S)}
8134
8135 @item @emph{Arguments}:
8136 @multitable @columnfractions .15 .70
8137 @item @var{X} @tab Shall be of type @code{REAL}.
8138 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
8139 not equal to zero.
8140 @end multitable
8141
8142 @item @emph{Return value}:
8143 The return value is of the same type as @code{X}. If @code{S} is
8144 positive, @code{NEAREST} returns the processor-representable number
8145 greater than @code{X} and nearest to it. If @code{S} is negative,
8146 @code{NEAREST} returns the processor-representable number smaller than
8147 @code{X} and nearest to it.
8148
8149 @item @emph{Example}:
8150 @smallexample
8151 program test_nearest
8152   real :: x, y
8153   x = nearest(42.0, 1.0)
8154   y = nearest(42.0, -1.0)
8155   write (*,"(3(G20.15))") x, y, x - y
8156 end program test_nearest
8157 @end smallexample
8158 @end table
8159
8160
8161
8162 @node NEW_LINE
8163 @section @code{NEW_LINE} --- New line character
8164 @fnindex NEW_LINE
8165 @cindex newline
8166 @cindex output, newline
8167
8168 @table @asis
8169 @item @emph{Description}:
8170 @code{NEW_LINE(C)} returns the new-line character.
8171
8172 @item @emph{Standard}:
8173 Fortran 2003 and later
8174
8175 @item @emph{Class}:
8176 Inquiry function
8177
8178 @item @emph{Syntax}:
8179 @code{RESULT = NEW_LINE(C)}
8180
8181 @item @emph{Arguments}:
8182 @multitable @columnfractions .15 .70
8183 @item @var{C}    @tab The argument shall be a scalar or array of the
8184                       type @code{CHARACTER}.
8185 @end multitable
8186
8187 @item @emph{Return value}:
8188 Returns a @var{CHARACTER} scalar of length one with the new-line character of
8189 the same kind as parameter @var{C}.
8190
8191 @item @emph{Example}:
8192 @smallexample
8193 program newline
8194   implicit none
8195   write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
8196 end program newline
8197 @end smallexample
8198 @end table
8199
8200
8201
8202 @node NINT
8203 @section @code{NINT} --- Nearest whole number
8204 @fnindex NINT
8205 @fnindex IDNINT
8206 @cindex rounding, nearest whole number
8207
8208 @table @asis
8209 @item @emph{Description}:
8210 @code{NINT(X)} rounds its argument to the nearest whole number.
8211
8212 @item @emph{Standard}:
8213 Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
8214
8215 @item @emph{Class}:
8216 Elemental function
8217
8218 @item @emph{Syntax}:
8219 @code{RESULT = NINT(X [, KIND])}
8220
8221 @item @emph{Arguments}:
8222 @multitable @columnfractions .15 .70
8223 @item @var{X}    @tab The type of the argument shall be @code{REAL}.
8224 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8225                       expression indicating the kind parameter of
8226                       the result.
8227 @end multitable
8228
8229 @item @emph{Return value}:
8230 Returns @var{A} with the fractional portion of its magnitude eliminated by
8231 rounding to the nearest whole number and with its sign preserved,
8232 converted to an @code{INTEGER} of the default kind.
8233
8234 @item @emph{Example}:
8235 @smallexample
8236 program test_nint
8237   real(4) x4
8238   real(8) x8
8239   x4 = 1.234E0_4
8240   x8 = 4.321_8
8241   print *, nint(x4), idnint(x8)
8242 end program test_nint
8243 @end smallexample
8244
8245 @item @emph{Specific names}:
8246 @multitable @columnfractions .25 .25 .25
8247 @item Name             @tab Argument         @tab Standard
8248 @item @code{IDNINT(X)} @tab @code{REAL(8)}   @tab Fortran 95 and later
8249 @end multitable
8250
8251 @item @emph{See also}:
8252 @ref{CEILING}, @ref{FLOOR}
8253
8254 @end table
8255
8256
8257
8258 @node NOT
8259 @section @code{NOT} --- Logical negation
8260 @fnindex NOT
8261 @cindex bits, negate
8262 @cindex bitwise logical not
8263 @cindex logical not, bitwise
8264
8265 @table @asis
8266 @item @emph{Description}:
8267 @code{NOT} returns the bitwise boolean inverse of @var{I}.
8268
8269 @item @emph{Standard}:
8270 Fortran 95 and later
8271
8272 @item @emph{Class}:
8273 Elemental function
8274
8275 @item @emph{Syntax}:
8276 @code{RESULT = NOT(I)}
8277
8278 @item @emph{Arguments}:
8279 @multitable @columnfractions .15 .70
8280 @item @var{I} @tab The type shall be @code{INTEGER}.
8281 @end multitable
8282
8283 @item @emph{Return value}:
8284 The return type is @code{INTEGER}, of the same kind as the
8285 argument.
8286
8287 @item @emph{See also}:
8288 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
8289
8290 @end table
8291
8292
8293
8294 @node NULL
8295 @section @code{NULL} --- Function that returns an disassociated pointer
8296 @fnindex NULL
8297 @cindex pointer, status
8298 @cindex pointer, disassociated
8299
8300 @table @asis
8301 @item @emph{Description}:
8302 Returns a disassociated pointer.
8303
8304 If @var{MOLD} is present, a dissassociated pointer of the same type is
8305 returned, otherwise the type is determined by context.
8306
8307 In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
8308 includes cases where it is required.
8309
8310 @item @emph{Standard}:
8311 Fortran 95 and later
8312
8313 @item @emph{Class}:
8314 Transformational function
8315
8316 @item @emph{Syntax}:
8317 @code{PTR => NULL([MOLD])}
8318
8319 @item @emph{Arguments}:
8320 @multitable @columnfractions .15 .70
8321 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
8322 status and of any type.
8323 @end multitable
8324
8325 @item @emph{Return value}:
8326 A disassociated pointer.
8327
8328 @item @emph{Example}:
8329 @smallexample
8330 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
8331 @end smallexample
8332
8333 @item @emph{See also}:
8334 @ref{ASSOCIATED}
8335 @end table
8336
8337
8338
8339 @node OR
8340 @section @code{OR} --- Bitwise logical OR
8341 @fnindex OR
8342 @cindex bitwise logical or
8343 @cindex logical or, bitwise
8344
8345 @table @asis
8346 @item @emph{Description}:
8347 Bitwise logical @code{OR}.
8348
8349 This intrinsic routine is provided for backwards compatibility with 
8350 GNU Fortran 77.  For integer arguments, programmers should consider
8351 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
8352
8353 @item @emph{Standard}:
8354 GNU extension
8355
8356 @item @emph{Class}:
8357 Function
8358
8359 @item @emph{Syntax}:
8360 @code{RESULT = OR(X, Y)}
8361
8362 @item @emph{Arguments}:
8363 @multitable @columnfractions .15 .70
8364 @item @var{X} @tab The type shall be either a scalar @code{INTEGER}
8365 type or a scalar @code{LOGICAL} type.
8366 @item @var{Y} @tab The type shall be the same as the type of @var{X}.
8367 @end multitable
8368
8369 @item @emph{Return value}:
8370 The return type is either a scalar @code{INTEGER} or a scalar
8371 @code{LOGICAL}.  If the kind type parameters differ, then the
8372 smaller kind type is implicitly converted to larger kind, and the 
8373 return has the larger kind.
8374
8375 @item @emph{Example}:
8376 @smallexample
8377 PROGRAM test_or
8378   LOGICAL :: T = .TRUE., F = .FALSE.
8379   INTEGER :: a, b
8380   DATA a / Z'F' /, b / Z'3' /
8381
8382   WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
8383   WRITE (*,*) OR(a, b)
8384 END PROGRAM
8385 @end smallexample
8386
8387 @item @emph{See also}:
8388 Fortran 95 elemental function: @ref{IOR}
8389 @end table
8390
8391
8392
8393 @node PACK
8394 @section @code{PACK} --- Pack an array into an array of rank one
8395 @fnindex PACK
8396 @cindex array, packing
8397 @cindex array, reduce dimension
8398 @cindex array, gather elements
8399
8400 @table @asis
8401 @item @emph{Description}:
8402 Stores the elements of @var{ARRAY} in an array of rank one.
8403
8404 The beginning of the resulting array is made up of elements whose @var{MASK} 
8405 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
8406 @var{VECTOR}.
8407
8408 @item @emph{Standard}:
8409 Fortran 95 and later
8410
8411 @item @emph{Class}:
8412 Transformational function
8413
8414 @item @emph{Syntax}:
8415 @code{RESULT = PACK(ARRAY, MASK[,VECTOR]}
8416
8417 @item @emph{Arguments}:
8418 @multitable @columnfractions .15 .70
8419 @item @var{ARRAY}  @tab Shall be an array of any type.
8420 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL} and 
8421 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL} 
8422 scalar.
8423 @item @var{VECTOR} @tab (Optional) shall be an array of the same type 
8424 as @var{ARRAY} and of rank one. If present, the number of elements in 
8425 @var{VECTOR} shall be equal to or greater than the number of true elements 
8426 in @var{MASK}. If @var{MASK} is scalar, the number of elements in 
8427 @var{VECTOR} shall be equal to or greater than the number of elements in
8428 @var{ARRAY}.
8429 @end multitable
8430
8431 @item @emph{Return value}:
8432 The result is an array of rank one and the same type as that of @var{ARRAY}.
8433 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
8434 number of @code{TRUE} values in @var{MASK} otherwise.
8435
8436 @item @emph{Example}:
8437 Gathering nonzero elements from an array:
8438 @smallexample
8439 PROGRAM test_pack_1
8440   INTEGER :: m(6)
8441   m = (/ 1, 0, 0, 0, 5, 0 /)
8442   WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0)  ! "1 5"
8443 END PROGRAM
8444 @end smallexample
8445
8446 Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
8447 @smallexample
8448 PROGRAM test_pack_2
8449   INTEGER :: m(4)
8450   m = (/ 1, 0, 0, 2 /)
8451   WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /))  ! "1 2 3 4"
8452 END PROGRAM
8453 @end smallexample
8454
8455 @item @emph{See also}:
8456 @ref{UNPACK}
8457 @end table
8458
8459
8460
8461 @node PERROR
8462 @section @code{PERROR} --- Print system error message
8463 @fnindex PERROR
8464 @cindex system, error handling
8465
8466 @table @asis
8467 @item @emph{Description}:
8468 Prints (on the C @code{stderr} stream) a newline-terminated error
8469 message corresponding to the last system error. This is prefixed by
8470 @var{STRING}, a colon and a space. See @code{perror(3)}.
8471
8472 @item @emph{Standard}:
8473 GNU extension
8474
8475 @item @emph{Class}:
8476 Subroutine
8477
8478 @item @emph{Syntax}:
8479 @code{CALL PERROR(STRING)}
8480
8481 @item @emph{Arguments}:
8482 @multitable @columnfractions .15 .70
8483 @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
8484 default kind.
8485 @end multitable
8486
8487 @item @emph{See also}:
8488 @ref{IERRNO}
8489 @end table
8490
8491
8492
8493 @node PRECISION
8494 @section @code{PRECISION} --- Decimal precision of a real kind
8495 @fnindex PRECISION
8496 @cindex model representation, precision
8497
8498 @table @asis
8499 @item @emph{Description}:
8500 @code{PRECISION(X)} returns the decimal precision in the model of the
8501 type of @code{X}.
8502
8503 @item @emph{Standard}:
8504 Fortran 95 and later
8505
8506 @item @emph{Class}:
8507 Inquiry function
8508
8509 @item @emph{Syntax}:
8510 @code{RESULT = PRECISION(X)}
8511
8512 @item @emph{Arguments}:
8513 @multitable @columnfractions .15 .70
8514 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
8515 @end multitable
8516
8517 @item @emph{Return value}:
8518 The return value is of type @code{INTEGER} and of the default integer
8519 kind.
8520
8521 @item @emph{Example}:
8522 @smallexample
8523 program prec_and_range
8524   real(kind=4) :: x(2)
8525   complex(kind=8) :: y
8526
8527   print *, precision(x), range(x)
8528   print *, precision(y), range(y)
8529 end program prec_and_range
8530 @end smallexample
8531 @end table
8532
8533
8534
8535 @node PRESENT
8536 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
8537 @fnindex PRESENT
8538
8539 @table @asis
8540 @item @emph{Description}:
8541 Determines whether an optional dummy argument is present.
8542
8543 @item @emph{Standard}:
8544 Fortran 95 and later
8545
8546 @item @emph{Class}:
8547 Inquiry function
8548
8549 @item @emph{Syntax}:
8550 @code{RESULT = PRESENT(A)}
8551
8552 @item @emph{Arguments}:
8553 @multitable @columnfractions .15 .70
8554 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
8555 value, or a dummy procedure. It shall be the name of an optional dummy argument
8556 accessible within the current subroutine or function.
8557 @end multitable
8558
8559 @item @emph{Return value}:
8560 Returns either @code{TRUE} if the optional argument @var{A} is present, or
8561 @code{FALSE} otherwise.
8562
8563 @item @emph{Example}:
8564 @smallexample
8565 PROGRAM test_present
8566   WRITE(*,*) f(), f(42)      ! "F T"
8567 CONTAINS
8568   LOGICAL FUNCTION f(x)
8569     INTEGER, INTENT(IN), OPTIONAL :: x
8570     f = PRESENT(x)
8571   END FUNCTION
8572 END PROGRAM
8573 @end smallexample
8574 @end table
8575
8576
8577
8578 @node PRODUCT
8579 @section @code{PRODUCT} --- Product of array elements
8580 @fnindex PRODUCT
8581 @cindex array, product
8582 @cindex array, multiply elements
8583 @cindex array, conditionally multiply elements
8584 @cindex multiply array elements
8585
8586 @table @asis
8587 @item @emph{Description}:
8588 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
8589 the corresponding element in @var{MASK} is @code{TRUE}.
8590
8591 @item @emph{Standard}:
8592 Fortran 95 and later
8593
8594 @item @emph{Class}:
8595 Transformational function
8596
8597 @item @emph{Syntax}:
8598 @code{RESULT = PRODUCT(ARRAY[, MASK])}
8599 @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
8600
8601 @item @emph{Arguments}:
8602 @multitable @columnfractions .15 .70
8603 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
8604 @code{REAL} or @code{COMPLEX}.
8605 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
8606 @code{INTEGER} with a value in the range from 1 to n, where n 
8607 equals the rank of @var{ARRAY}.
8608 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
8609 and either be a scalar or an array of the same shape as @var{ARRAY}.
8610 @end multitable
8611
8612 @item @emph{Return value}:
8613 The result is of the same type as @var{ARRAY}.
8614
8615 If @var{DIM} is absent, a scalar with the product of all elements in 
8616 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals 
8617 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with 
8618 dimension @var{DIM} dropped is returned.
8619
8620
8621 @item @emph{Example}:
8622 @smallexample
8623 PROGRAM test_product
8624   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
8625   print *, PRODUCT(x)                    ! all elements, product = 120
8626   print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
8627 END PROGRAM
8628 @end smallexample
8629
8630 @item @emph{See also}:
8631 @ref{SUM}
8632 @end table
8633
8634
8635
8636 @node RADIX
8637 @section @code{RADIX} --- Base of a model number
8638 @fnindex RADIX
8639 @cindex model representation, base
8640 @cindex model representation, radix
8641
8642 @table @asis
8643 @item @emph{Description}:
8644 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
8645
8646 @item @emph{Standard}:
8647 Fortran 95 and later
8648
8649 @item @emph{Class}:
8650 Inquiry function
8651
8652 @item @emph{Syntax}:
8653 @code{RESULT = RADIX(X)}
8654
8655 @item @emph{Arguments}:
8656 @multitable @columnfractions .15 .70
8657 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
8658 @end multitable
8659
8660 @item @emph{Return value}:
8661 The return value is a scalar of type @code{INTEGER} and of the default
8662 integer kind.
8663
8664 @item @emph{Example}:
8665 @smallexample
8666 program test_radix
8667   print *, "The radix for the default integer kind is", radix(0)
8668   print *, "The radix for the default real kind is", radix(0.0)
8669 end program test_radix
8670 @end smallexample
8671
8672 @end table
8673
8674
8675
8676 @node RAN
8677 @section @code{RAN} --- Real pseudo-random number
8678 @fnindex RAN
8679 @cindex random number generation
8680
8681 @table @asis
8682 @item @emph{Description}:
8683 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
8684 provided as an alias for @code{RAND}.  See @ref{RAND} for complete
8685 documentation.
8686
8687 @item @emph{Standard}:
8688 GNU extension
8689
8690 @item @emph{Class}:
8691 Function
8692
8693 @item @emph{See also}:
8694 @ref{RAND}, @ref{RANDOM_NUMBER}
8695 @end table
8696
8697
8698
8699 @node RAND
8700 @section @code{RAND} --- Real pseudo-random number
8701 @fnindex RAND
8702 @cindex random number generation
8703
8704 @table @asis
8705 @item @emph{Description}:
8706 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
8707 distribution between 0 and 1. If @var{FLAG} is 0, the next number
8708 in the current sequence is returned; if @var{FLAG} is 1, the generator
8709 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
8710 it is used as a new seed with @code{SRAND}.
8711
8712 This intrinsic routine is provided for backwards compatibility with
8713 GNU Fortran 77. It implements a simple modulo generator as provided 
8714 by @command{g77}. For new code, one should consider the use of 
8715 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
8716
8717 @item @emph{Standard}:
8718 GNU extension
8719
8720 @item @emph{Class}:
8721 Function
8722
8723 @item @emph{Syntax}:
8724 @code{RESULT = RAND(FLAG)}
8725
8726 @item @emph{Arguments}:
8727 @multitable @columnfractions .15 .70
8728 @item @var{FLAG} @tab Shall be a scalar @code{INTEGER} of kind 4.
8729 @end multitable
8730
8731 @item @emph{Return value}:
8732 The return value is of @code{REAL} type and the default kind.
8733
8734 @item @emph{Example}:
8735 @smallexample
8736 program test_rand
8737   integer,parameter :: seed = 86456
8738   
8739   call srand(seed)
8740   print *, rand(), rand(), rand(), rand()
8741   print *, rand(seed), rand(), rand(), rand()
8742 end program test_rand
8743 @end smallexample
8744
8745 @item @emph{See also}:
8746 @ref{SRAND}, @ref{RANDOM_NUMBER}
8747
8748 @end table
8749
8750
8751
8752 @node RANDOM_NUMBER
8753 @section @code{RANDOM_NUMBER} --- Pseudo-random number
8754 @fnindex RANDOM_NUMBER
8755 @cindex random number generation
8756
8757 @table @asis
8758 @item @emph{Description}:
8759 Returns a single pseudorandom number or an array of pseudorandom numbers
8760 from the uniform distribution over the range @math{ 0 \leq x < 1}.
8761
8762 The runtime-library implements George Marsaglia's KISS (Keep It Simple 
8763 Stupid) random number generator (RNG). This RNG combines:
8764 @enumerate
8765 @item The congruential generator @math{x(n) = 69069 \cdot x(n-1) + 1327217885}
8766 with a period of @math{2^{32}},
8767 @item A 3-shift shift-register generator with a period of @math{2^{32} - 1},
8768 @item  Two 16-bit multiply-with-carry generators with a period of
8769 @math{597273182964842497 > 2^{59}}.
8770 @end enumerate
8771 The overall period exceeds @math{2^{123}}.
8772
8773 Please note, this RNG is thread safe if used within OpenMP directives,
8774 i.e., its state will be consistent while called from multiple threads.
8775 However, the KISS generator does not create random numbers in parallel 
8776 from multiple sources, but in sequence from a single source. If an
8777 OpenMP-enabled application heavily relies on random numbers, one should 
8778 consider employing a dedicated parallel random number generator instead.
8779
8780 @item @emph{Standard}:
8781 Fortran 95 and later
8782
8783 @item @emph{Class}:
8784 Subroutine
8785
8786 @item @emph{Syntax}:
8787 @code{RANDOM_NUMBER(HARVEST)}
8788
8789 @item @emph{Arguments}:
8790 @multitable @columnfractions .15 .70
8791 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
8792 @end multitable
8793
8794 @item @emph{Example}:
8795 @smallexample
8796 program test_random_number
8797   REAL :: r(5,5)
8798   CALL init_random_seed()         ! see example of RANDOM_SEED
8799   CALL RANDOM_NUMBER(r)
8800 end program
8801 @end smallexample
8802
8803 @item @emph{See also}:
8804 @ref{RANDOM_SEED}
8805 @end table
8806
8807
8808
8809 @node RANDOM_SEED
8810 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
8811 @fnindex RANDOM_SEED
8812 @cindex random number generation, seeding
8813 @cindex seeding a random number generator
8814
8815 @table @asis
8816 @item @emph{Description}:
8817 Restarts or queries the state of the pseudorandom number generator used by 
8818 @code{RANDOM_NUMBER}.
8819
8820 If @code{RANDOM_SEED} is called without arguments, it is initialized to
8821 a default state. The example below shows how to initialize the random 
8822 seed based on the system's time.
8823
8824 @item @emph{Standard}:
8825 Fortran 95 and later
8826
8827 @item @emph{Class}:
8828 Subroutine
8829
8830 @item @emph{Syntax}:
8831 @code{CALL RANDOM_SEED(SIZE, PUT, GET)}
8832
8833 @item @emph{Arguments}:
8834 @multitable @columnfractions .15 .70
8835 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default 
8836 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size 
8837 of the arrays used with the @var{PUT} and @var{GET} arguments.
8838 @item @var{PUT}  @tab (Optional) Shall be an array of type default 
8839 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of 
8840 the array must be larger than or equal to the number returned by the 
8841 @var{SIZE} argument.
8842 @item @var{GET}  @tab (Optional) Shall be an array of type default 
8843 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size 
8844 of the array must be larger than or equal to the number returned by 
8845 the @var{SIZE} argument.
8846 @end multitable
8847
8848 @item @emph{Example}:
8849 @smallexample
8850 SUBROUTINE init_random_seed()
8851   INTEGER :: i, n, clock
8852   INTEGER, DIMENSION(:), ALLOCATABLE :: seed
8853
8854   CALL RANDOM_SEED(size = n)
8855   ALLOCATE(seed(n))
8856
8857   CALL SYSTEM_CLOCK(COUNT=clock)
8858
8859   seed = clock + 37 * (/ (i - 1, i = 1, n) /)
8860   CALL RANDOM_SEED(PUT = seed)
8861
8862   DEALLOCATE(seed)
8863 END SUBROUTINE
8864 @end smallexample
8865
8866 @item @emph{See also}:
8867 @ref{RANDOM_NUMBER}
8868 @end table
8869
8870
8871
8872 @node RANGE
8873 @section @code{RANGE} --- Decimal exponent range of a real kind
8874 @fnindex RANGE
8875 @cindex model representation, range
8876
8877 @table @asis
8878 @item @emph{Description}:
8879 @code{RANGE(X)} returns the decimal exponent range in the model of the
8880 type of @code{X}.
8881
8882 @item @emph{Standard}:
8883 Fortran 95 and later
8884
8885 @item @emph{Class}:
8886 Inquiry function
8887
8888 @item @emph{Syntax}:
8889 @code{RESULT = RANGE(X)}
8890
8891 @item @emph{Arguments}:
8892 @multitable @columnfractions .15 .70
8893 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
8894 @end multitable
8895
8896 @item @emph{Return value}:
8897 The return value is of type @code{INTEGER} and of the default integer
8898 kind.
8899
8900 @item @emph{Example}:
8901 See @code{PRECISION} for an example.
8902 @end table
8903
8904
8905
8906 @node REAL
8907 @section @code{REAL} --- Convert to real type 
8908 @fnindex REAL
8909 @fnindex REALPART
8910 @cindex conversion, to real
8911 @cindex complex numbers, real part
8912
8913 @table @asis
8914 @item @emph{Description}:
8915 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type.  The
8916 @code{REALPART(X)} function is provided for compatibility with @command{g77},
8917 and its use is strongly discouraged.
8918
8919 @item @emph{Standard}:
8920 Fortran 77 and later
8921
8922 @item @emph{Class}:
8923 Elemental function
8924
8925 @item @emph{Syntax}:
8926 @multitable @columnfractions .80
8927 @item @code{RESULT = REAL(X [, KIND])}
8928 @item @code{RESULT = REALPART(Z)}
8929 @end multitable
8930
8931 @item @emph{Arguments}:
8932 @multitable @columnfractions .15 .70
8933 @item @var{X}    @tab Shall be @code{INTEGER}, @code{REAL}, or
8934                       @code{COMPLEX}.
8935 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8936                       expression indicating the kind parameter of
8937                       the result.
8938 @end multitable
8939
8940 @item @emph{Return value}:
8941 These functions return a @code{REAL} variable or array under
8942 the following rules: 
8943
8944 @table @asis
8945 @item (A)
8946 @code{REAL(X)} is converted to a default real type if @var{X} is an 
8947 integer or real variable.
8948 @item (B)
8949 @code{REAL(X)} is converted to a real type with the kind type parameter
8950 of @var{X} if @var{X} is a complex variable.
8951 @item (C)
8952 @code{REAL(X, KIND)} is converted to a real type with kind type
8953 parameter @var{KIND} if @var{X} is a complex, integer, or real
8954 variable.
8955 @end table
8956
8957 @item @emph{Example}:
8958 @smallexample
8959 program test_real
8960   complex :: x = (1.0, 2.0)
8961   print *, real(x), real(x,8), realpart(x)
8962 end program test_real
8963 @end smallexample
8964
8965 @item @emph{See also}:
8966 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
8967
8968 @end table
8969
8970
8971
8972 @node RENAME
8973 @section @code{RENAME} --- Rename a file
8974 @fnindex RENAME
8975 @cindex file system, rename file
8976
8977 @table @asis
8978 @item @emph{Description}:
8979 Renames a file from file @var{PATH1} to @var{PATH2}. A null
8980 character (@code{CHAR(0)}) can be used to mark the end of the names in
8981 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
8982 names are ignored.  If the @var{STATUS} argument is supplied, it
8983 contains 0 on success or a nonzero error code upon return; see
8984 @code{rename(2)}.
8985
8986 This intrinsic is provided in both subroutine and function forms;
8987 however, only one form can be used in any given program unit.
8988
8989 @item @emph{Standard}:
8990 GNU extension
8991
8992 @item @emph{Class}:
8993 Subroutine, function
8994
8995 @item @emph{Syntax}:
8996 @multitable @columnfractions .80
8997 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
8998 @item @code{STATUS = RENAME(PATH1, PATH2)}
8999 @end multitable
9000
9001 @item @emph{Arguments}:
9002 @multitable @columnfractions .15 .70
9003 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
9004 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
9005 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9006 @end multitable
9007
9008 @item @emph{See also}:
9009 @ref{LINK}
9010
9011 @end table
9012
9013
9014
9015 @node REPEAT
9016 @section @code{REPEAT} --- Repeated string concatenation 
9017 @fnindex REPEAT
9018 @cindex string, repeat
9019 @cindex string, concatenate
9020
9021 @table @asis
9022 @item @emph{Description}:
9023 Concatenates @var{NCOPIES} copies of a string.
9024
9025 @item @emph{Standard}:
9026 Fortran 95 and later
9027
9028 @item @emph{Class}:
9029 Transformational function
9030
9031 @item @emph{Syntax}:
9032 @code{RESULT = REPEAT(STRING, NCOPIES)}
9033
9034 @item @emph{Arguments}:
9035 @multitable @columnfractions .15 .70
9036 @item @var{STRING}  @tab Shall be scalar and of type @code{CHARACTER}.
9037 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
9038 @end multitable
9039
9040 @item @emph{Return value}:
9041 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies 
9042 of @var{STRING}.
9043
9044 @item @emph{Example}:
9045 @smallexample
9046 program test_repeat
9047   write(*,*) repeat("x", 5)   ! "xxxxx"
9048 end program
9049 @end smallexample
9050 @end table
9051
9052
9053
9054 @node RESHAPE
9055 @section @code{RESHAPE} --- Function to reshape an array
9056 @fnindex RESHAPE
9057 @cindex array, change dimensions
9058 @cindex array, transmogrify
9059
9060 @table @asis
9061 @item @emph{Description}:
9062 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
9063 the new array may be padded with elements from @var{PAD} or permuted
9064 as defined by @var{ORDER}.
9065
9066 @item @emph{Standard}:
9067 Fortran 95 and later
9068
9069 @item @emph{Class}:
9070 Transformational function
9071
9072 @item @emph{Syntax}:
9073 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
9074
9075 @item @emph{Arguments}:
9076 @multitable @columnfractions .15 .70
9077 @item @var{SOURCE} @tab Shall be an array of any type.
9078 @item @var{SHAPE}  @tab Shall be of type @code{INTEGER} and an 
9079 array of rank one. Its values must be positive or zero.
9080 @item @var{PAD}    @tab (Optional) shall be an array of the same 
9081 type as @var{SOURCE}.
9082 @item @var{ORDER}  @tab (Optional) shall be of type @code{INTEGER}
9083 and an array of the same shape as @var{SHAPE}. Its values shall
9084 be a permutation of the numbers from 1 to n, where n is the size of 
9085 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
9086 be assumed.
9087 @end multitable
9088
9089 @item @emph{Return value}:
9090 The result is an array of shape @var{SHAPE} with the same type as 
9091 @var{SOURCE}. 
9092
9093 @item @emph{Example}:
9094 @smallexample
9095 PROGRAM test_reshape
9096   INTEGER, DIMENSION(4) :: x
9097   WRITE(*,*) SHAPE(x)                       ! prints "4"
9098   WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/)))    ! prints "2 2"
9099 END PROGRAM
9100 @end smallexample
9101
9102 @item @emph{See also}:
9103 @ref{SHAPE}
9104 @end table
9105
9106
9107
9108 @node RRSPACING
9109 @section @code{RRSPACING} --- Reciprocal of the relative spacing
9110 @fnindex RRSPACING
9111 @cindex real number, relative spacing
9112 @cindex floating point, relative spacing
9113
9114
9115 @table @asis
9116 @item @emph{Description}:
9117 @code{RRSPACING(X)} returns the  reciprocal of the relative spacing of
9118 model numbers near @var{X}.
9119
9120 @item @emph{Standard}:
9121 Fortran 95 and later
9122
9123 @item @emph{Class}:
9124 Elemental function
9125
9126 @item @emph{Syntax}:
9127 @code{RESULT = RRSPACING(X)}
9128
9129 @item @emph{Arguments}:
9130 @multitable @columnfractions .15 .70
9131 @item @var{X} @tab Shall be of type @code{REAL}.
9132 @end multitable
9133
9134 @item @emph{Return value}:
9135 The return value is of the same type and kind as @var{X}.
9136 The value returned is equal to
9137 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
9138
9139 @item @emph{See also}:
9140 @ref{SPACING}
9141 @end table
9142
9143
9144
9145 @node RSHIFT
9146 @section @code{RSHIFT} --- Right shift bits
9147 @fnindex RSHIFT
9148 @cindex bits, shift right
9149
9150 @table @asis
9151 @item @emph{Description}:
9152 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
9153 bits shifted right by @var{SHIFT} places.  If the absolute value of
9154 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined. 
9155 Bits shifted out from the left end are lost; zeros are shifted in from
9156 the opposite end.
9157
9158 This function has been superseded by the @code{ISHFT} intrinsic, which
9159 is standard in Fortran 95 and later.
9160
9161 @item @emph{Standard}:
9162 GNU extension
9163
9164 @item @emph{Class}:
9165 Elemental function
9166
9167 @item @emph{Syntax}:
9168 @code{RESULT = RSHIFT(I, SHIFT)}
9169
9170 @item @emph{Arguments}:
9171 @multitable @columnfractions .15 .70
9172 @item @var{I} @tab The type shall be @code{INTEGER}.
9173 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
9174 @end multitable
9175
9176 @item @emph{Return value}:
9177 The return value is of type @code{INTEGER} and of the same kind as
9178 @var{I}.
9179
9180 @item @emph{See also}:
9181 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
9182
9183 @end table
9184
9185
9186
9187 @node SCALE
9188 @section @code{SCALE} --- Scale a real value
9189 @fnindex SCALE
9190 @cindex real number, scale
9191 @cindex floating point, scale
9192
9193 @table @asis
9194 @item @emph{Description}:
9195 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
9196
9197 @item @emph{Standard}:
9198 Fortran 95 and later
9199
9200 @item @emph{Class}:
9201 Elemental function
9202
9203 @item @emph{Syntax}:
9204 @code{RESULT = SCALE(X, I)}
9205
9206 @item @emph{Arguments}:
9207 @multitable @columnfractions .15 .70
9208 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
9209 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
9210 @end multitable
9211
9212 @item @emph{Return value}:
9213 The return value is of the same type and kind as @var{X}.
9214 Its value is @code{X * RADIX(X)**I}.
9215
9216 @item @emph{Example}:
9217 @smallexample
9218 program test_scale
9219   real :: x = 178.1387e-4
9220   integer :: i = 5
9221   print *, scale(x,i), x*radix(x)**i
9222 end program test_scale
9223 @end smallexample
9224
9225 @end table
9226
9227
9228
9229 @node SCAN
9230 @section @code{SCAN} --- Scan a string for the presence of a set of characters
9231 @fnindex SCAN
9232 @cindex string, find subset
9233
9234 @table @asis
9235 @item @emph{Description}:
9236 Scans a @var{STRING} for any of the characters in a @var{SET} 
9237 of characters.
9238
9239 If @var{BACK} is either absent or equals @code{FALSE}, this function
9240 returns the position of the leftmost character of @var{STRING} that is
9241 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
9242 is returned. If no character of @var{SET} is found in @var{STRING}, the 
9243 result is zero.
9244
9245 @item @emph{Standard}:
9246 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
9247
9248 @item @emph{Class}:
9249 Elemental function
9250
9251 @item @emph{Syntax}:
9252 @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
9253
9254 @item @emph{Arguments}:
9255 @multitable @columnfractions .15 .70
9256 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
9257 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
9258 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
9259 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
9260                         expression indicating the kind parameter of
9261                       the result.
9262 @end multitable
9263
9264 @item @emph{Return value}:
9265 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9266 @var{KIND} is absent, the return value is of default integer kind.
9267
9268 @item @emph{Example}:
9269 @smallexample
9270 PROGRAM test_scan
9271   WRITE(*,*) SCAN("FORTRAN", "AO")          ! 2, found 'O'
9272   WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.)  ! 6, found 'A'
9273   WRITE(*,*) SCAN("FORTRAN", "C++")         ! 0, found none
9274 END PROGRAM
9275 @end smallexample
9276
9277 @item @emph{See also}:
9278 @ref{INDEX intrinsic}, @ref{VERIFY}
9279 @end table
9280
9281
9282
9283 @node SECNDS
9284 @section @code{SECNDS} --- Time function
9285 @fnindex SECNDS
9286 @cindex time, elapsed
9287 @cindex elapsed time
9288
9289 @table @asis
9290 @item @emph{Description}:
9291 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
9292 @var{X} is a reference time, also in seconds. If this is zero, the time in
9293 seconds from midnight is returned. This function is non-standard and its
9294 use is discouraged.
9295
9296 @item @emph{Standard}:
9297 GNU extension
9298
9299 @item @emph{Class}:
9300 Function
9301
9302 @item @emph{Syntax}:
9303 @code{RESULT = SECNDS (X)}
9304
9305 @item @emph{Arguments}:
9306 @multitable @columnfractions .15 .70
9307 @item @var{T}     @tab Shall be of type @code{REAL(4)}.
9308 @item @var{X}     @tab Shall be of type @code{REAL(4)}.
9309 @end multitable
9310
9311 @item @emph{Return value}:
9312 None
9313
9314 @item @emph{Example}:
9315 @smallexample
9316 program test_secnds
9317     integer :: i
9318     real(4) :: t1, t2
9319     print *, secnds (0.0)   ! seconds since midnight
9320     t1 = secnds (0.0)       ! reference time
9321     do i = 1, 10000000      ! do something
9322     end do
9323     t2 = secnds (t1)        ! elapsed time
9324     print *, "Something took ", t2, " seconds."
9325 end program test_secnds
9326 @end smallexample
9327 @end table
9328
9329
9330
9331 @node SECOND
9332 @section @code{SECOND} --- CPU time function
9333 @fnindex SECOND
9334 @cindex time, elapsed
9335 @cindex elapsed time
9336
9337 @table @asis
9338 @item @emph{Description}:
9339 Returns a @code{REAL(4)} value representing the elapsed CPU time in
9340 seconds.  This provides the same functionality as the standard
9341 @code{CPU_TIME} intrinsic, and is only included for backwards
9342 compatibility.
9343
9344 This intrinsic is provided in both subroutine and function forms;
9345 however, only one form can be used in any given program unit.
9346
9347 @item @emph{Standard}:
9348 GNU extension
9349
9350 @item @emph{Class}:
9351 Subroutine, function
9352
9353 @item @emph{Syntax}:
9354 @multitable @columnfractions .80
9355 @item @code{CALL SECOND(TIME)}
9356 @item @code{TIME = SECOND()}
9357 @end multitable
9358
9359 @item @emph{Arguments}:
9360 @multitable @columnfractions .15 .70
9361 @item @var{TIME}  @tab Shall be of type @code{REAL(4)}.
9362 @end multitable
9363
9364 @item @emph{Return value}:
9365 In either syntax, @var{TIME} is set to the process's current runtime in
9366 seconds.
9367
9368 @item @emph{See also}:
9369 @ref{CPU_TIME}
9370
9371 @end table
9372
9373
9374
9375 @node SELECTED_CHAR_KIND
9376 @section @code{SELECTED_CHAR_KIND} --- Choose character kind
9377 @fnindex SELECTED_CHAR_KIND
9378 @cindex character kind
9379 @cindex kind, character
9380
9381 @table @asis
9382 @item @emph{Description}:
9383
9384 @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
9385 set named @var{NAME}, if a character set with such a name is supported,
9386 or @math{-1} otherwise. Currently, supported character sets include
9387 ``ASCII'' and ``DEFAULT'', which are equivalent.
9388
9389 @item @emph{Standard}:
9390 Fortran 2003 and later
9391
9392 @item @emph{Class}:
9393 Transformational function
9394
9395 @item @emph{Syntax}:
9396 @code{RESULT = SELECTED_CHAR_KIND(NAME)}
9397
9398 @item @emph{Arguments}:
9399 @multitable @columnfractions .15 .70
9400 @item @var{NAME} @tab Shall be a scalar and of the default character type.
9401 @end multitable
9402
9403 @item @emph{Example}:
9404 @smallexample
9405 program ascii_kind
9406   integer,parameter :: ascii = selected_char_kind("ascii")
9407   character(kind=ascii, len=26) :: s
9408
9409   s = ascii_"abcdefghijklmnopqrstuvwxyz"
9410   print *, s
9411 end program ascii_kind
9412 @end smallexample
9413 @end table
9414
9415
9416
9417 @node SELECTED_INT_KIND
9418 @section @code{SELECTED_INT_KIND} --- Choose integer kind
9419 @fnindex SELECTED_INT_KIND
9420 @cindex integer kind
9421 @cindex kind, integer
9422
9423 @table @asis
9424 @item @emph{Description}:
9425 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
9426 type that can represent all values ranging from @math{-10^I} (exclusive)
9427 to @math{10^I} (exclusive). If there is no integer kind that accommodates
9428 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
9429
9430 @item @emph{Standard}:
9431 Fortran 95 and later
9432
9433 @item @emph{Class}:
9434 Transformational function
9435
9436 @item @emph{Syntax}:
9437 @code{RESULT = SELECTED_INT_KIND(I)}
9438
9439 @item @emph{Arguments}:
9440 @multitable @columnfractions .15 .70
9441 @item @var{I} @tab Shall be a scalar and of type @code{INTEGER}.
9442 @end multitable
9443
9444 @item @emph{Example}:
9445 @smallexample
9446 program large_integers
9447   integer,parameter :: k5 = selected_int_kind(5)
9448   integer,parameter :: k15 = selected_int_kind(15)
9449   integer(kind=k5) :: i5
9450   integer(kind=k15) :: i15
9451
9452   print *, huge(i5), huge(i15)
9453
9454   ! The following inequalities are always true
9455   print *, huge(i5) >= 10_k5**5-1
9456   print *, huge(i15) >= 10_k15**15-1
9457 end program large_integers
9458 @end smallexample
9459 @end table
9460
9461
9462
9463 @node SELECTED_REAL_KIND
9464 @section @code{SELECTED_REAL_KIND} --- Choose real kind
9465 @fnindex SELECTED_REAL_KIND
9466 @cindex real kind
9467 @cindex kind, real
9468
9469 @table @asis
9470 @item @emph{Description}:
9471 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
9472 with decimal precision greater of at least @code{P} digits and exponent
9473 range greater at least @code{R}. 
9474
9475 @item @emph{Standard}:
9476 Fortran 95 and later
9477
9478 @item @emph{Class}:
9479 Transformational function
9480
9481 @item @emph{Syntax}:
9482 @code{RESULT = SELECTED_REAL_KIND(P, R)}
9483
9484 @item @emph{Arguments}:
9485 @multitable @columnfractions .15 .70
9486 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
9487 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
9488 @end multitable
9489 At least one argument shall be present.
9490
9491 @item @emph{Return value}:
9492
9493 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
9494 a real data type with decimal precision of at least @code{P} digits and a
9495 decimal exponent range of at least @code{R}. If more than one real data
9496 type meet the criteria, the kind of the data type with the smallest
9497 decimal precision is returned. If no real data type matches the criteria,
9498 the result is
9499 @table @asis
9500 @item -1 if the processor does not support a real data type with a
9501 precision greater than or equal to @code{P}
9502 @item -2 if the processor does not support a real type with an exponent
9503 range greater than or equal to @code{R}
9504 @item -3 if neither is supported.
9505 @end table
9506
9507 @item @emph{Example}:
9508 @smallexample
9509 program real_kinds
9510   integer,parameter :: p6 = selected_real_kind(6)
9511   integer,parameter :: p10r100 = selected_real_kind(10,100)
9512   integer,parameter :: r400 = selected_real_kind(r=400)
9513   real(kind=p6) :: x
9514   real(kind=p10r100) :: y
9515   real(kind=r400) :: z
9516
9517   print *, precision(x), range(x)
9518   print *, precision(y), range(y)
9519   print *, precision(z), range(z)
9520 end program real_kinds
9521 @end smallexample
9522 @end table
9523
9524
9525
9526 @node SET_EXPONENT
9527 @section @code{SET_EXPONENT} --- Set the exponent of the model
9528 @fnindex SET_EXPONENT
9529 @cindex real number, set exponent
9530 @cindex floating point, set exponent
9531
9532 @table @asis
9533 @item @emph{Description}:
9534 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
9535 is that that of @var{X} and whose exponent part is @var{I}.
9536
9537 @item @emph{Standard}:
9538 Fortran 95 and later
9539
9540 @item @emph{Class}:
9541 Elemental function
9542
9543 @item @emph{Syntax}:
9544 @code{RESULT = SET_EXPONENT(X, I)}
9545
9546 @item @emph{Arguments}:
9547 @multitable @columnfractions .15 .70
9548 @item @var{X} @tab Shall be of type @code{REAL}.
9549 @item @var{I} @tab Shall be of type @code{INTEGER}.
9550 @end multitable
9551
9552 @item @emph{Return value}:
9553 The return value is of the same type and kind as @var{X}.
9554 The real number whose fractional part
9555 is that that of @var{X} and whose exponent part if @var{I} is returned;
9556 it is @code{FRACTION(X) * RADIX(X)**I}.
9557
9558 @item @emph{Example}:
9559 @smallexample
9560 PROGRAM test_setexp
9561   REAL :: x = 178.1387e-4
9562   INTEGER :: i = 17
9563   PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
9564 END PROGRAM
9565 @end smallexample
9566
9567 @end table
9568
9569
9570
9571 @node SHAPE
9572 @section @code{SHAPE} --- Determine the shape of an array
9573 @fnindex SHAPE
9574 @cindex array, shape
9575
9576 @table @asis
9577 @item @emph{Description}:
9578 Determines the shape of an array.
9579
9580 @item @emph{Standard}:
9581 Fortran 95 and later
9582
9583 @item @emph{Class}:
9584 Inquiry function
9585
9586 @item @emph{Syntax}:
9587 @code{RESULT = SHAPE(SOURCE)}
9588
9589 @item @emph{Arguments}:
9590 @multitable @columnfractions .15 .70
9591 @item @var{SOURCE} @tab Shall be an array or scalar of any type. 
9592 If @var{SOURCE} is a pointer it must be associated and allocatable 
9593 arrays must be allocated.
9594 @end multitable
9595
9596 @item @emph{Return value}:
9597 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE} 
9598 has dimensions. The elements of the resulting array correspond to the extend
9599 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
9600 the result is the rank one array of size zero.
9601
9602 @item @emph{Example}:
9603 @smallexample
9604 PROGRAM test_shape
9605   INTEGER, DIMENSION(-1:1, -1:2) :: A
9606   WRITE(*,*) SHAPE(A)             ! (/ 3, 4 /)
9607   WRITE(*,*) SIZE(SHAPE(42))      ! (/ /)
9608 END PROGRAM
9609 @end smallexample
9610
9611 @item @emph{See also}:
9612 @ref{RESHAPE}, @ref{SIZE}
9613 @end table
9614
9615
9616
9617 @node SIGN
9618 @section @code{SIGN} --- Sign copying function
9619 @fnindex SIGN
9620 @fnindex ISIGN
9621 @fnindex DSIGN
9622 @cindex sign copying
9623
9624 @table @asis
9625 @item @emph{Description}:
9626 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
9627
9628 @item @emph{Standard}:
9629 Fortran 77 and later
9630
9631 @item @emph{Class}:
9632 Elemental function
9633
9634 @item @emph{Syntax}:
9635 @code{RESULT = SIGN(A, B)}
9636
9637 @item @emph{Arguments}:
9638 @multitable @columnfractions .15 .70
9639 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
9640 @item @var{B} @tab Shall be of the same type and kind as @var{A}
9641 @end multitable
9642
9643 @item @emph{Return value}:
9644 The kind of the return value is that of @var{A} and @var{B}.
9645 If @math{B\ge 0} then the result is @code{ABS(A)}, else
9646 it is @code{-ABS(A)}.
9647
9648 @item @emph{Example}:
9649 @smallexample
9650 program test_sign
9651   print *, sign(-12,1)
9652   print *, sign(-12,0)
9653   print *, sign(-12,-1)
9654
9655   print *, sign(-12.,1.)
9656   print *, sign(-12.,0.)
9657   print *, sign(-12.,-1.)
9658 end program test_sign
9659 @end smallexample
9660
9661 @item @emph{Specific names}:
9662 @multitable @columnfractions .20 .20 .20 .25
9663 @item Name              @tab Arguments      @tab Return type    @tab Standard
9664 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
9665 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
9666 @end multitable
9667 @end table
9668
9669
9670
9671 @node SIGNAL
9672 @section @code{SIGNAL} --- Signal handling subroutine (or function)
9673 @fnindex SIGNAL
9674 @cindex system, signal handling
9675
9676 @table @asis
9677 @item @emph{Description}:
9678 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
9679 @var{HANDLER} to be executed with a single integer argument when signal
9680 @var{NUMBER} occurs.  If @var{HANDLER} is an integer, it can be used to
9681 turn off handling of signal @var{NUMBER} or revert to its default
9682 action.  See @code{signal(2)}.
9683
9684 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
9685 is supplied, it is set to the value returned by @code{signal(2)}.
9686
9687 @item @emph{Standard}:
9688 GNU extension
9689
9690 @item @emph{Class}:
9691 Subroutine, function
9692
9693 @item @emph{Syntax}:
9694 @multitable @columnfractions .80
9695 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
9696 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
9697 @end multitable
9698
9699 @item @emph{Arguments}:
9700 @multitable @columnfractions .15 .70
9701 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
9702 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
9703 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
9704 @code{INTEGER}. It is @code{INTENT(IN)}.
9705 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
9706 integer. It has @code{INTENT(OUT)}.
9707 @end multitable
9708
9709 @item @emph{Return value}:
9710 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
9711
9712 @item @emph{Example}:
9713 @smallexample
9714 program test_signal
9715   intrinsic signal
9716   external handler_print
9717
9718   call signal (12, handler_print)
9719   call signal (10, 1)
9720
9721   call sleep (30)
9722 end program test_signal
9723 @end smallexample
9724 @end table
9725
9726
9727
9728 @node SIN
9729 @section @code{SIN} --- Sine function 
9730 @fnindex SIN
9731 @fnindex DSIN
9732 @fnindex CSIN
9733 @fnindex ZSIN
9734 @fnindex CDSIN
9735 @cindex trigonometric function, sine
9736 @cindex sine
9737
9738 @table @asis
9739 @item @emph{Description}:
9740 @code{SIN(X)} computes the sine of @var{X}.
9741
9742 @item @emph{Standard}:
9743 Fortran 77 and later
9744
9745 @item @emph{Class}:
9746 Elemental function
9747
9748 @item @emph{Syntax}:
9749 @code{RESULT = SIN(X)}
9750
9751 @item @emph{Arguments}:
9752 @multitable @columnfractions .15 .70
9753 @item @var{X} @tab The type shall be @code{REAL} or
9754 @code{COMPLEX}.
9755 @end multitable
9756
9757 @item @emph{Return value}:
9758 The return value has same type and kind as @var{X}.
9759
9760 @item @emph{Example}:
9761 @smallexample
9762 program test_sin
9763   real :: x = 0.0
9764   x = sin(x)
9765 end program test_sin
9766 @end smallexample
9767
9768 @item @emph{Specific names}:
9769 @multitable @columnfractions .20 .20 .20 .25
9770 @item Name            @tab Argument          @tab Return type       @tab Standard
9771 @item @code{DSIN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
9772 @item @code{CSIN(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
9773 @item @code{ZSIN(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
9774 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
9775 @end multitable
9776
9777 @item @emph{See also}:
9778 @ref{ASIN}
9779 @end table
9780
9781
9782
9783 @node SINH
9784 @section @code{SINH} --- Hyperbolic sine function 
9785 @fnindex SINH
9786 @fnindex DSINH
9787 @cindex hyperbolic sine
9788 @cindex hyperbolic function, sine
9789 @cindex sine, hyperbolic
9790
9791 @table @asis
9792 @item @emph{Description}:
9793 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
9794
9795 @item @emph{Standard}:
9796 Fortran 95 and later
9797
9798 @item @emph{Class}:
9799 Elemental function
9800
9801 @item @emph{Syntax}:
9802 @code{RESULT = SINH(X)}
9803
9804 @item @emph{Arguments}:
9805 @multitable @columnfractions .15 .70
9806 @item @var{X} @tab The type shall be @code{REAL}.
9807 @end multitable
9808
9809 @item @emph{Return value}:
9810 The return value is of type @code{REAL}.
9811
9812 @item @emph{Example}:
9813 @smallexample
9814 program test_sinh
9815   real(8) :: x = - 1.0_8
9816   x = sinh(x)
9817 end program test_sinh
9818 @end smallexample
9819
9820 @item @emph{Specific names}:
9821 @multitable @columnfractions .20 .20 .20 .25
9822 @item Name            @tab Argument          @tab Return type       @tab Standard
9823 @item @code{DSINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
9824 @end multitable
9825
9826 @item @emph{See also}:
9827 @ref{ASINH}
9828 @end table
9829
9830
9831
9832 @node SIZE
9833 @section @code{SIZE} --- Determine the size of an array
9834 @fnindex SIZE
9835 @cindex array, size
9836 @cindex array, number of elements
9837 @cindex array, count elements
9838
9839 @table @asis
9840 @item @emph{Description}:
9841 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
9842 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
9843
9844 @item @emph{Standard}:
9845 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
9846
9847 @item @emph{Class}:
9848 Inquiry function
9849
9850 @item @emph{Syntax}:
9851 @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
9852
9853 @item @emph{Arguments}:
9854 @multitable @columnfractions .15 .70
9855 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
9856 a pointer it must be associated and allocatable arrays must be allocated.
9857 @item @var{DIM}   @tab (Optional) shall be a scalar of type @code{INTEGER} 
9858 and its value shall be in the range from 1 to n, where n equals the rank 
9859 of @var{ARRAY}.
9860 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9861                       expression indicating the kind parameter of
9862                       the result.
9863 @end multitable
9864
9865 @item @emph{Return value}:
9866 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9867 @var{KIND} is absent, the return value is of default integer kind.
9868
9869 @item @emph{Example}:
9870 @smallexample
9871 PROGRAM test_size
9872   WRITE(*,*) SIZE((/ 1, 2 /))    ! 2
9873 END PROGRAM
9874 @end smallexample
9875
9876 @item @emph{See also}:
9877 @ref{SHAPE}, @ref{RESHAPE}
9878 @end table
9879
9880
9881 @node SIZEOF
9882 @section @code{SIZEOF} --- Size in bytes of an expression
9883 @fnindex SIZEOF
9884 @cindex expression size
9885 @cindex size of an expression
9886
9887 @table @asis
9888 @item @emph{Description}:
9889 @code{SIZEOF(X)} calculates the number of bytes of storage the
9890 expression @code{X} occupies.
9891
9892 @item @emph{Standard}:
9893 GNU extension
9894
9895 @item @emph{Class}:
9896 Intrinsic function
9897
9898 @item @emph{Syntax}:
9899 @code{N = SIZEOF(X)}
9900
9901 @item @emph{Arguments}:
9902 @multitable @columnfractions .15 .70
9903 @item @var{X} @tab The argument shall be of any type, rank or shape.
9904 @end multitable
9905
9906 @item @emph{Return value}:
9907 The return value is of type integer and of the system-dependent kind
9908 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
9909 number of bytes occupied by the argument.  If the argument has the
9910 @code{POINTER} attribute, the number of bytes of the storage area pointed
9911 to is returned.  If the argument is of a derived type with @code{POINTER}
9912 or @code{ALLOCATABLE} components, the return value doesn't account for
9913 the sizes of the data pointed to by these components.
9914
9915 @item @emph{Example}:
9916 @smallexample
9917    integer :: i
9918    real :: r, s(5)
9919    print *, (sizeof(s)/sizeof(r) == 5)
9920    end
9921 @end smallexample
9922 The example will print @code{.TRUE.} unless you are using a platform
9923 where default @code{REAL} variables are unusually padded.
9924
9925 @item @emph{See also}:
9926 @ref{C_SIZEOF}
9927 @end table
9928
9929
9930 @node SLEEP
9931 @section @code{SLEEP} --- Sleep for the specified number of seconds
9932 @fnindex SLEEP
9933 @cindex delayed execution
9934
9935 @table @asis
9936 @item @emph{Description}:
9937 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
9938
9939 @item @emph{Standard}:
9940 GNU extension
9941
9942 @item @emph{Class}:
9943 Subroutine
9944
9945 @item @emph{Syntax}:
9946 @code{CALL SLEEP(SECONDS)}
9947
9948 @item @emph{Arguments}:
9949 @multitable @columnfractions .15 .70
9950 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
9951 @end multitable
9952
9953 @item @emph{Example}:
9954 @smallexample
9955 program test_sleep
9956   call sleep(5)
9957 end
9958 @end smallexample
9959 @end table
9960
9961
9962
9963 @node SNGL
9964 @section @code{SNGL} --- Convert double precision real to default real
9965 @fnindex SNGL
9966 @cindex conversion, to real
9967
9968 @table @asis
9969 @item @emph{Description}:
9970 @code{SNGL(A)} converts the double precision real @var{A}
9971 to a default real value. This is an archaic form of @code{REAL}
9972 that is specific to one type for @var{A}.
9973
9974 @item @emph{Standard}:
9975 Fortran 77 and later
9976
9977 @item @emph{Class}:
9978 Elemental function
9979
9980 @item @emph{Syntax}:
9981 @code{RESULT = SNGL(A)}
9982
9983 @item @emph{Arguments}:
9984 @multitable @columnfractions .15 .70
9985 @item @var{A} @tab The type shall be a double precision @code{REAL}.
9986 @end multitable
9987
9988 @item @emph{Return value}:
9989 The return value is of type default @code{REAL}.
9990
9991 @item @emph{See also}:
9992 @ref{DBLE}
9993 @end table
9994
9995
9996
9997 @node SPACING
9998 @section @code{SPACING} --- Smallest distance between two numbers of a given type
9999 @fnindex SPACING
10000 @cindex real number, relative spacing
10001 @cindex floating point, relative spacing
10002
10003 @table @asis
10004 @item @emph{Description}:
10005 Determines the distance between the argument @var{X} and the nearest 
10006 adjacent number of the same type.
10007
10008 @item @emph{Standard}:
10009 Fortran 95 and later
10010
10011 @item @emph{Class}:
10012 Elemental function
10013
10014 @item @emph{Syntax}:
10015 @code{RESULT = SPACING(X)}
10016
10017 @item @emph{Arguments}:
10018 @multitable @columnfractions .15 .70
10019 @item @var{X} @tab Shall be of type @code{REAL}.
10020 @end multitable
10021
10022 @item @emph{Return value}:
10023 The result is of the same type as the input argument @var{X}.
10024
10025 @item @emph{Example}:
10026 @smallexample
10027 PROGRAM test_spacing
10028   INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
10029   INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
10030
10031   WRITE(*,*) spacing(1.0_SGL)      ! "1.1920929E-07"          on i686
10032   WRITE(*,*) spacing(1.0_DBL)      ! "2.220446049250313E-016" on i686
10033 END PROGRAM
10034 @end smallexample
10035
10036 @item @emph{See also}:
10037 @ref{RRSPACING}
10038 @end table
10039
10040
10041
10042 @node SPREAD
10043 @section @code{SPREAD} --- Add a dimension to an array
10044 @fnindex SPREAD
10045 @cindex array, increase dimension
10046 @cindex array, duplicate elements
10047 @cindex array, duplicate dimensions
10048
10049 @table @asis
10050 @item @emph{Description}:
10051 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified 
10052 dimension @var{DIM}.
10053
10054 @item @emph{Standard}:
10055 Fortran 95 and later
10056
10057 @item @emph{Class}:
10058 Transformational function
10059
10060 @item @emph{Syntax}:
10061 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
10062
10063 @item @emph{Arguments}:
10064 @multitable @columnfractions .15 .70
10065 @item @var{SOURCE}  @tab Shall be a scalar or an array of any type and 
10066 a rank less than seven.
10067 @item @var{DIM}     @tab Shall be a scalar of type @code{INTEGER} with a 
10068 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
10069 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
10070 @end multitable
10071
10072 @item @emph{Return value}:
10073 The result is an array of the same type as @var{SOURCE} and has rank n+1
10074 where n equals the rank of @var{SOURCE}.
10075
10076 @item @emph{Example}:
10077 @smallexample
10078 PROGRAM test_spread
10079   INTEGER :: a = 1, b(2) = (/ 1, 2 /)
10080   WRITE(*,*) SPREAD(A, 1, 2)            ! "1 1"
10081   WRITE(*,*) SPREAD(B, 1, 2)            ! "1 1 2 2"
10082 END PROGRAM
10083 @end smallexample
10084
10085 @item @emph{See also}:
10086 @ref{UNPACK}
10087 @end table
10088
10089
10090
10091 @node SQRT
10092 @section @code{SQRT} --- Square-root function
10093 @fnindex SQRT
10094 @fnindex DSQRT
10095 @fnindex CSQRT
10096 @fnindex ZSQRT
10097 @fnindex CDSQRT
10098 @cindex root
10099 @cindex square-root
10100
10101 @table @asis
10102 @item @emph{Description}:
10103 @code{SQRT(X)} computes the square root of @var{X}.
10104
10105 @item @emph{Standard}:
10106 Fortran 77 and later
10107
10108 @item @emph{Class}:
10109 Elemental function
10110
10111 @item @emph{Syntax}:
10112 @code{RESULT = SQRT(X)}
10113
10114 @item @emph{Arguments}:
10115 @multitable @columnfractions .15 .70
10116 @item @var{X} @tab The type shall be @code{REAL} or
10117 @code{COMPLEX}.
10118 @end multitable
10119
10120 @item @emph{Return value}:
10121 The return value is of type @code{REAL} or @code{COMPLEX}.
10122 The kind type parameter is the same as @var{X}.
10123
10124 @item @emph{Example}:
10125 @smallexample
10126 program test_sqrt
10127   real(8) :: x = 2.0_8
10128   complex :: z = (1.0, 2.0)
10129   x = sqrt(x)
10130   z = sqrt(z)
10131 end program test_sqrt
10132 @end smallexample
10133
10134 @item @emph{Specific names}:
10135 @multitable @columnfractions .20 .20 .20 .25
10136 @item Name             @tab Argument             @tab Return type          @tab Standard
10137 @item @code{DSQRT(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}       @tab Fortran 95 and later
10138 @item @code{CSQRT(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab Fortran 95 and later
10139 @item @code{ZSQRT(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
10140 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
10141 @end multitable
10142 @end table
10143
10144
10145
10146 @node SRAND
10147 @section @code{SRAND} --- Reinitialize the random number generator
10148 @fnindex SRAND
10149 @cindex random number generation, seeding
10150 @cindex seeding a random number generator
10151
10152 @table @asis
10153 @item @emph{Description}:
10154 @code{SRAND} reinitializes the pseudo-random number generator
10155 called by @code{RAND} and @code{IRAND}. The new seed used by the
10156 generator is specified by the required argument @var{SEED}.
10157
10158 @item @emph{Standard}:
10159 GNU extension
10160
10161 @item @emph{Class}:
10162 Subroutine
10163
10164 @item @emph{Syntax}:
10165 @code{CALL SRAND(SEED)}
10166
10167 @item @emph{Arguments}:
10168 @multitable @columnfractions .15 .70
10169 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
10170 @end multitable
10171
10172 @item @emph{Return value}:
10173 Does not return.
10174
10175 @item @emph{Example}:
10176 See @code{RAND} and @code{IRAND} for examples.
10177
10178 @item @emph{Notes}:
10179 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
10180 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
10181 to generate pseudo-random numbers. Please note that in
10182 GNU Fortran, these two sets of intrinsics (@code{RAND},
10183 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
10184 @code{RANDOM_SEED} on the other hand) access two independent
10185 pseudo-random number generators.
10186
10187 @item @emph{See also}:
10188 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
10189
10190 @end table
10191
10192
10193
10194 @node STAT
10195 @section @code{STAT} --- Get file status
10196 @fnindex STAT
10197 @cindex file system, file status
10198
10199 @table @asis
10200 @item @emph{Description}:
10201 This function returns information about a file. No permissions are required on 
10202 the file itself, but execute (search) permission is required on all of the 
10203 directories in path that lead to the file.
10204
10205 The elements that are obtained and stored in the array @code{BUFF}:
10206 @multitable @columnfractions .15 .70
10207 @item @code{buff(1)}   @tab  Device ID 
10208 @item @code{buff(2)}   @tab  Inode number 
10209 @item @code{buff(3)}   @tab  File mode 
10210 @item @code{buff(4)}   @tab  Number of links 
10211 @item @code{buff(5)}   @tab  Owner's uid 
10212 @item @code{buff(6)}   @tab  Owner's gid 
10213 @item @code{buff(7)}   @tab  ID of device containing directory entry for file (0 if not available) 
10214 @item @code{buff(8)}   @tab  File size (bytes) 
10215 @item @code{buff(9)}   @tab  Last access time 
10216 @item @code{buff(10)}  @tab  Last modification time 
10217 @item @code{buff(11)}  @tab  Last file status change time 
10218 @item @code{buff(12)}  @tab  Preferred I/O block size (-1 if not available) 
10219 @item @code{buff(13)}  @tab  Number of blocks allocated (-1 if not available)
10220 @end multitable
10221
10222 Not all these elements are relevant on all systems. 
10223 If an element is not relevant, it is returned as 0.
10224
10225 This intrinsic is provided in both subroutine and function forms; however,
10226 only one form can be used in any given program unit.
10227
10228 @item @emph{Standard}:
10229 GNU extension
10230
10231 @item @emph{Class}:
10232 Subroutine, function
10233
10234 @item @emph{Syntax}:
10235 @code{CALL STAT(FILE,BUFF[,STATUS])}
10236
10237 @item @emph{Arguments}:
10238 @multitable @columnfractions .15 .70
10239 @item @var{FILE}   @tab The type shall be @code{CHARACTER}, of the
10240 default kind and a valid path within the file system.
10241 @item @var{BUFF}   @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
10242 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
10243                         on success and a system specific error code otherwise.
10244 @end multitable
10245
10246 @item @emph{Example}:
10247 @smallexample
10248 PROGRAM test_stat
10249   INTEGER, DIMENSION(13) :: buff
10250   INTEGER :: status
10251
10252   CALL STAT("/etc/passwd", buff, status)
10253
10254   IF (status == 0) THEN
10255     WRITE (*, FMT="('Device ID:',               T30, I19)") buff(1)
10256     WRITE (*, FMT="('Inode number:',            T30, I19)") buff(2)
10257     WRITE (*, FMT="('File mode (octal):',       T30, O19)") buff(3)
10258     WRITE (*, FMT="('Number of links:',         T30, I19)") buff(4)
10259     WRITE (*, FMT="('Owner''s uid:',            T30, I19)") buff(5)
10260     WRITE (*, FMT="('Owner''s gid:',            T30, I19)") buff(6)
10261     WRITE (*, FMT="('Device where located:',    T30, I19)") buff(7)
10262     WRITE (*, FMT="('File size:',               T30, I19)") buff(8)
10263     WRITE (*, FMT="('Last access time:',        T30, A19)") CTIME(buff(9))
10264     WRITE (*, FMT="('Last modification time',   T30, A19)") CTIME(buff(10))
10265     WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
10266     WRITE (*, FMT="('Preferred block size:',    T30, I19)") buff(12)
10267     WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
10268   END IF
10269 END PROGRAM
10270 @end smallexample
10271
10272 @item @emph{See also}:
10273 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
10274 @end table
10275
10276
10277
10278 @node SUM
10279 @section @code{SUM} --- Sum of array elements
10280 @fnindex SUM
10281 @cindex array, sum
10282 @cindex array, add elements
10283 @cindex array, conditionally add elements
10284 @cindex sum array elements
10285
10286 @table @asis
10287 @item @emph{Description}:
10288 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
10289 the corresponding element in @var{MASK} is @code{TRUE}.
10290
10291 @item @emph{Standard}:
10292 Fortran 95 and later
10293
10294 @item @emph{Class}:
10295 Transformational function
10296
10297 @item @emph{Syntax}:
10298 @code{RESULT = SUM(ARRAY[, MASK])}
10299 @code{RESULT = SUM(ARRAY, DIM[, MASK])}
10300
10301 @item @emph{Arguments}:
10302 @multitable @columnfractions .15 .70
10303 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
10304 @code{REAL} or @code{COMPLEX}.
10305 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
10306 @code{INTEGER} with a value in the range from 1 to n, where n 
10307 equals the rank of @var{ARRAY}.
10308 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
10309 and either be a scalar or an array of the same shape as @var{ARRAY}.
10310 @end multitable
10311
10312 @item @emph{Return value}:
10313 The result is of the same type as @var{ARRAY}.
10314
10315 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
10316 is returned. Otherwise, an array of rank n-1, where n equals the rank of 
10317 @var{ARRAY},and a shape similar to that of @var{ARRAY} with dimension @var{DIM} 
10318 dropped is returned.
10319
10320 @item @emph{Example}:
10321 @smallexample
10322 PROGRAM test_sum
10323   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
10324   print *, SUM(x)                        ! all elements, sum = 15
10325   print *, SUM(x, MASK=MOD(x, 2)==1)     ! odd elements, sum = 9
10326 END PROGRAM
10327 @end smallexample
10328
10329 @item @emph{See also}:
10330 @ref{PRODUCT}
10331 @end table
10332
10333
10334
10335 @node SYMLNK
10336 @section @code{SYMLNK} --- Create a symbolic link
10337 @fnindex SYMLNK
10338 @cindex file system, create link
10339 @cindex file system, soft link
10340
10341 @table @asis
10342 @item @emph{Description}:
10343 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
10344 character (@code{CHAR(0)}) can be used to mark the end of the names in
10345 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
10346 names are ignored.  If the @var{STATUS} argument is supplied, it
10347 contains 0 on success or a nonzero error code upon return; see
10348 @code{symlink(2)}.  If the system does not supply @code{symlink(2)}, 
10349 @code{ENOSYS} is returned.
10350
10351 This intrinsic is provided in both subroutine and function forms;
10352 however, only one form can be used in any given program unit.
10353
10354 @item @emph{Standard}:
10355 GNU extension
10356
10357 @item @emph{Class}:
10358 Subroutine, function
10359
10360 @item @emph{Syntax}:
10361 @multitable @columnfractions .80
10362 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
10363 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
10364 @end multitable
10365
10366 @item @emph{Arguments}:
10367 @multitable @columnfractions .15 .70
10368 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
10369 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
10370 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10371 @end multitable
10372
10373 @item @emph{See also}:
10374 @ref{LINK}, @ref{UNLINK}
10375
10376 @end table
10377
10378
10379
10380 @node SYSTEM
10381 @section @code{SYSTEM} --- Execute a shell command
10382 @fnindex SYSTEM
10383 @cindex system, system call
10384
10385 @table @asis
10386 @item @emph{Description}:
10387 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
10388 argument @var{STATUS} is present, it contains the value returned by
10389 @code{system(3)}, which is presumably 0 if the shell command succeeded.
10390 Note that which shell is used to invoke the command is system-dependent
10391 and environment-dependent.
10392
10393 This intrinsic is provided in both subroutine and function forms;
10394 however, only one form can be used in any given program unit.
10395
10396 @item @emph{Standard}:
10397 GNU extension
10398
10399 @item @emph{Class}:
10400 Subroutine, function
10401
10402 @item @emph{Syntax}:
10403 @multitable @columnfractions .80
10404 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
10405 @item @code{STATUS = SYSTEM(COMMAND)}
10406 @end multitable
10407
10408 @item @emph{Arguments}:
10409 @multitable @columnfractions .15 .70
10410 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
10411 @item @var{STATUS}  @tab (Optional) Shall be of default @code{INTEGER} type.
10412 @end multitable
10413
10414 @item @emph{See also}:
10415 @end table
10416
10417
10418
10419 @node SYSTEM_CLOCK
10420 @section @code{SYSTEM_CLOCK} --- Time function
10421 @fnindex SYSTEM_CLOCK
10422 @cindex time, clock ticks
10423 @cindex clock ticks
10424
10425 @table @asis
10426 @item @emph{Description}:
10427 Determines the @var{COUNT} of milliseconds of wall clock time since 
10428 the Epoch (00:00:00 UTC, January 1, 1970) modulo @var{COUNT_MAX}, 
10429 @var{COUNT_RATE} determines the number of clock ticks per second.
10430 @var{COUNT_RATE} and @var{COUNT_MAX} are constant and specific to 
10431 @command{gfortran}.
10432
10433 If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and
10434 @var{COUNT_RATE} and @var{COUNT_MAX} are set to zero 
10435
10436 @item @emph{Standard}:
10437 Fortran 95 and later
10438
10439 @item @emph{Class}:
10440 Subroutine
10441
10442 @item @emph{Syntax}:
10443 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
10444
10445 @item @emph{Arguments}:
10446 @item @emph{Arguments}:
10447 @multitable @columnfractions .15 .70
10448 @item @var{COUNT}      @tab (Optional) shall be a scalar of type default 
10449 @code{INTEGER} with @code{INTENT(OUT)}.
10450 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type default 
10451 @code{INTEGER} with @code{INTENT(OUT)}.
10452 @item @var{COUNT_MAX}  @tab (Optional) shall be a scalar of type default 
10453 @code{INTEGER} with @code{INTENT(OUT)}.
10454 @end multitable
10455
10456 @item @emph{Example}:
10457 @smallexample
10458 PROGRAM test_system_clock
10459   INTEGER :: count, count_rate, count_max
10460   CALL SYSTEM_CLOCK(count, count_rate, count_max)
10461   WRITE(*,*) count, count_rate, count_max
10462 END PROGRAM
10463 @end smallexample
10464
10465 @item @emph{See also}:
10466 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
10467 @end table
10468
10469
10470
10471 @node TAN
10472 @section @code{TAN} --- Tangent function
10473 @fnindex TAN
10474 @fnindex DTAN
10475 @cindex trigonometric function, tangent
10476 @cindex tangent
10477
10478 @table @asis
10479 @item @emph{Description}:
10480 @code{TAN(X)} computes the tangent of @var{X}.
10481
10482 @item @emph{Standard}:
10483 Fortran 77 and later
10484
10485 @item @emph{Class}:
10486 Elemental function
10487
10488 @item @emph{Syntax}:
10489 @code{RESULT = TAN(X)}
10490
10491 @item @emph{Arguments}:
10492 @multitable @columnfractions .15 .70
10493 @item @var{X} @tab The type shall be @code{REAL}.
10494 @end multitable
10495
10496 @item @emph{Return value}:
10497 The return value is of type @code{REAL}.  The kind type parameter is
10498 the same as @var{X}.
10499
10500 @item @emph{Example}:
10501 @smallexample
10502 program test_tan
10503   real(8) :: x = 0.165_8
10504   x = tan(x)
10505 end program test_tan
10506 @end smallexample
10507
10508 @item @emph{Specific names}:
10509 @multitable @columnfractions .20 .20 .20 .25
10510 @item Name            @tab Argument          @tab Return type       @tab Standard
10511 @item @code{DTAN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
10512 @end multitable
10513
10514 @item @emph{See also}:
10515 @ref{ATAN}
10516 @end table
10517
10518
10519
10520 @node TANH
10521 @section @code{TANH} --- Hyperbolic tangent function 
10522 @fnindex TANH
10523 @fnindex DTANH
10524 @cindex hyperbolic tangent
10525 @cindex hyperbolic function, tangent
10526 @cindex tangent, hyperbolic
10527
10528 @table @asis
10529 @item @emph{Description}:
10530 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
10531
10532 @item @emph{Standard}:
10533 Fortran 77 and later
10534
10535 @item @emph{Class}:
10536 Elemental function
10537
10538 @item @emph{Syntax}:
10539 @code{X = TANH(X)}
10540
10541 @item @emph{Arguments}:
10542 @multitable @columnfractions .15 .70
10543 @item @var{X} @tab The type shall be @code{REAL}.
10544 @end multitable
10545
10546 @item @emph{Return value}:
10547 The return value is of type @code{REAL} and lies in the range
10548 @math{ - 1 \leq tanh(x) \leq 1 }.
10549
10550 @item @emph{Example}:
10551 @smallexample
10552 program test_tanh
10553   real(8) :: x = 2.1_8
10554   x = tanh(x)
10555 end program test_tanh
10556 @end smallexample
10557
10558 @item @emph{Specific names}:
10559 @multitable @columnfractions .20 .20 .20 .25
10560 @item Name            @tab Argument          @tab Return type       @tab Standard
10561 @item @code{DTANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
10562 @end multitable
10563
10564 @item @emph{See also}:
10565 @ref{ATANH}
10566 @end table
10567
10568
10569
10570 @node TIME
10571 @section @code{TIME} --- Time function
10572 @fnindex TIME
10573 @cindex time, current
10574 @cindex current time
10575
10576 @table @asis
10577 @item @emph{Description}:
10578 Returns the current time encoded as an integer (in the manner of the
10579 UNIX function @code{time(3)}). This value is suitable for passing to
10580 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
10581
10582 This intrinsic is not fully portable, such as to systems with 32-bit
10583 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
10584 the values returned by this intrinsic might be, or become, negative, or
10585 numerically less than previous values, during a single run of the
10586 compiled program.
10587
10588 See @ref{TIME8}, for information on a similar intrinsic that might be
10589 portable to more GNU Fortran implementations, though to fewer Fortran
10590 compilers.
10591
10592 @item @emph{Standard}:
10593 GNU extension
10594
10595 @item @emph{Class}:
10596 Function
10597
10598 @item @emph{Syntax}:
10599 @code{RESULT = TIME()}
10600
10601 @item @emph{Return value}:
10602 The return value is a scalar of type @code{INTEGER(4)}.
10603
10604 @item @emph{See also}:
10605 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
10606
10607 @end table
10608
10609
10610
10611 @node TIME8
10612 @section @code{TIME8} --- Time function (64-bit)
10613 @fnindex TIME8
10614 @cindex time, current
10615 @cindex current time
10616
10617 @table @asis
10618 @item @emph{Description}:
10619 Returns the current time encoded as an integer (in the manner of the
10620 UNIX function @code{time(3)}). This value is suitable for passing to
10621 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
10622
10623 @emph{Warning:} this intrinsic does not increase the range of the timing
10624 values over that returned by @code{time(3)}. On a system with a 32-bit
10625 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
10626 it is converted to a 64-bit @code{INTEGER(8)} value. That means
10627 overflows of the 32-bit value can still occur. Therefore, the values
10628 returned by this intrinsic might be or become negative or numerically
10629 less than previous values during a single run of the compiled program.
10630
10631 @item @emph{Standard}:
10632 GNU extension
10633
10634 @item @emph{Class}:
10635 Function
10636
10637 @item @emph{Syntax}:
10638 @code{RESULT = TIME8()}
10639
10640 @item @emph{Return value}:
10641 The return value is a scalar of type @code{INTEGER(8)}.
10642
10643 @item @emph{See also}:
10644 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
10645
10646 @end table
10647
10648
10649
10650 @node TINY
10651 @section @code{TINY} --- Smallest positive number of a real kind
10652 @fnindex TINY
10653 @cindex limits, smallest number
10654 @cindex model representation, smallest number
10655
10656 @table @asis
10657 @item @emph{Description}:
10658 @code{TINY(X)} returns the smallest positive (non zero) number
10659 in the model of the type of @code{X}.
10660
10661 @item @emph{Standard}:
10662 Fortran 95 and later
10663
10664 @item @emph{Class}:
10665 Inquiry function
10666
10667 @item @emph{Syntax}:
10668 @code{RESULT = TINY(X)}
10669
10670 @item @emph{Arguments}:
10671 @multitable @columnfractions .15 .70
10672 @item @var{X} @tab Shall be of type @code{REAL}.
10673 @end multitable
10674
10675 @item @emph{Return value}:
10676 The return value is of the same type and kind as @var{X}
10677
10678 @item @emph{Example}:
10679 See @code{HUGE} for an example.
10680 @end table
10681
10682
10683
10684 @node TRANSFER
10685 @section @code{TRANSFER} --- Transfer bit patterns
10686 @fnindex TRANSFER
10687 @cindex bits, move
10688 @cindex type cast
10689
10690 @table @asis
10691 @item @emph{Description}:
10692 Interprets the bitwise representation of @var{SOURCE} in memory as if it
10693 is the representation of a variable or array of the same type and type
10694 parameters as @var{MOLD}.
10695
10696 This is approximately equivalent to the C concept of @emph{casting} one
10697 type to another.
10698
10699 @item @emph{Standard}:
10700 Fortran 95 and later
10701
10702 @item @emph{Class}:
10703 Transformational function
10704
10705 @item @emph{Syntax}:
10706 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
10707
10708 @item @emph{Arguments}:
10709 @multitable @columnfractions .15 .70
10710 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
10711 @item @var{MOLD}   @tab Shall be a scalar or an array of any type.
10712 @item @var{SIZE}   @tab (Optional) shall be a scalar of type 
10713 @code{INTEGER}.
10714 @end multitable
10715
10716 @item @emph{Return value}:
10717 The result has the same type as @var{MOLD}, with the bit level
10718 representation of @var{SOURCE}.  If @var{SIZE} is present, the result is
10719 a one-dimensional array of length @var{SIZE}.  If @var{SIZE} is absent
10720 but @var{MOLD} is an array (of any size or shape), the result is a one-
10721 dimensional array of the minimum length needed to contain the entirety
10722 of the bitwise representation of @var{SOURCE}.   If @var{SIZE} is absent
10723 and @var{MOLD} is a scalar, the result is a scalar.
10724
10725 If the bitwise representation of the result is longer than that of
10726 @var{SOURCE}, then the leading bits of the result correspond to those of
10727 @var{SOURCE} and any trailing bits are filled arbitrarily.
10728
10729 When the resulting bit representation does not correspond to a valid
10730 representation of a variable of the same type as @var{MOLD}, the results
10731 are undefined, and subsequent operations on the result cannot be
10732 guaranteed to produce sensible behavior.  For example, it is possible to
10733 create @code{LOGICAL} variables for which @code{@var{VAR}} and
10734 @code{.NOT.@var{VAR}} both appear to be true.
10735
10736 @item @emph{Example}:
10737 @smallexample
10738 PROGRAM test_transfer
10739   integer :: x = 2143289344
10740   print *, transfer(x, 1.0)    ! prints "NaN" on i686
10741 END PROGRAM
10742 @end smallexample
10743 @end table
10744
10745
10746
10747 @node TRANSPOSE
10748 @section @code{TRANSPOSE} --- Transpose an array of rank two
10749 @fnindex TRANSPOSE
10750 @cindex array, transpose
10751 @cindex matrix, transpose
10752 @cindex transpose
10753
10754 @table @asis
10755 @item @emph{Description}:
10756 Transpose an array of rank two. Element (i, j) of the result has the value 
10757 @code{MATRIX(j, i)}, for all i, j.
10758
10759 @item @emph{Standard}:
10760 Fortran 95 and later
10761
10762 @item @emph{Class}:
10763 Transformational function
10764
10765 @item @emph{Syntax}:
10766 @code{RESULT = TRANSPOSE(MATRIX)}
10767
10768 @item @emph{Arguments}:
10769 @multitable @columnfractions .15 .70
10770 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
10771 @end multitable
10772
10773 @item @emph{Return value}:
10774 The result has the same type as @var{MATRIX}, and has shape 
10775 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
10776 @end table
10777
10778
10779
10780 @node TRIM
10781 @section @code{TRIM} --- Remove trailing blank characters of a string
10782 @fnindex TRIM
10783 @cindex string, remove trailing whitespace
10784
10785 @table @asis
10786 @item @emph{Description}:
10787 Removes trailing blank characters of a string.
10788
10789 @item @emph{Standard}:
10790 Fortran 95 and later
10791
10792 @item @emph{Class}:
10793 Transformational function
10794
10795 @item @emph{Syntax}:
10796 @code{RESULT = TRIM(STRING)}
10797
10798 @item @emph{Arguments}:
10799 @multitable @columnfractions .15 .70
10800 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
10801 @end multitable
10802
10803 @item @emph{Return value}:
10804 A scalar of type @code{CHARACTER} which length is that of @var{STRING}
10805 less the number of trailing blanks.
10806
10807 @item @emph{Example}:
10808 @smallexample
10809 PROGRAM test_trim
10810   CHARACTER(len=10), PARAMETER :: s = "GFORTRAN  "
10811   WRITE(*,*) LEN(s), LEN(TRIM(s))  ! "10 8", with/without trailing blanks
10812 END PROGRAM
10813 @end smallexample
10814
10815 @item @emph{See also}:
10816 @ref{ADJUSTL}, @ref{ADJUSTR}
10817 @end table
10818
10819
10820
10821 @node TTYNAM
10822 @section @code{TTYNAM} --- Get the name of a terminal device.
10823 @fnindex TTYNAM
10824 @cindex system, terminal
10825
10826 @table @asis
10827 @item @emph{Description}:
10828 Get the name of a terminal device. For more information, 
10829 see @code{ttyname(3)}.
10830
10831 This intrinsic is provided in both subroutine and function forms; 
10832 however, only one form can be used in any given program unit. 
10833
10834 @item @emph{Standard}:
10835 GNU extension
10836
10837 @item @emph{Class}:
10838 Subroutine, function
10839
10840 @item @emph{Syntax}:
10841 @multitable @columnfractions .80
10842 @item @code{CALL TTYNAM(UNIT, NAME)}
10843 @item @code{NAME = TTYNAM(UNIT)}
10844 @end multitable
10845
10846 @item @emph{Arguments}:
10847 @multitable @columnfractions .15 .70
10848 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
10849 @item @var{NAME} @tab Shall be of type @code{CHARACTER}.
10850 @end multitable
10851
10852 @item @emph{Example}:
10853 @smallexample
10854 PROGRAM test_ttynam
10855   INTEGER :: unit
10856   DO unit = 1, 10
10857     IF (isatty(unit=unit)) write(*,*) ttynam(unit)
10858   END DO
10859 END PROGRAM
10860 @end smallexample
10861
10862 @item @emph{See also}:
10863 @ref{ISATTY}
10864 @end table
10865
10866
10867
10868 @node UBOUND
10869 @section @code{UBOUND} --- Upper dimension bounds of an array
10870 @fnindex UBOUND
10871 @cindex array, upper bound
10872
10873 @table @asis
10874 @item @emph{Description}:
10875 Returns the upper bounds of an array, or a single upper bound
10876 along the @var{DIM} dimension.
10877 @item @emph{Standard}:
10878 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
10879
10880 @item @emph{Class}:
10881 Inquiry function
10882
10883 @item @emph{Syntax}:
10884 @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
10885
10886 @item @emph{Arguments}:
10887 @multitable @columnfractions .15 .70
10888 @item @var{ARRAY} @tab Shall be an array, of any type.
10889 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
10890 @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
10891                      expression indicating the kind parameter of
10892                      the result.
10893 @end multitable
10894
10895 @item @emph{Return value}:
10896 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
10897 @var{KIND} is absent, the return value is of default integer kind.
10898 If @var{DIM} is absent, the result is an array of the upper bounds of
10899 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
10900 corresponding to the upper bound of the array along that dimension.  If
10901 @var{ARRAY} is an expression rather than a whole array or array
10902 structure component, or if it has a zero extent along the relevant
10903 dimension, the upper bound is taken to be the number of elements along
10904 the relevant dimension.
10905
10906 @item @emph{See also}:
10907 @ref{LBOUND}
10908 @end table
10909
10910
10911
10912 @node UMASK
10913 @section @code{UMASK} --- Set the file creation mask
10914 @fnindex UMASK
10915 @cindex file system, file creation mask
10916
10917 @table @asis
10918 @item @emph{Description}:
10919 Sets the file creation mask to @var{MASK} and returns the old value in
10920 argument @var{OLD} if it is supplied. See @code{umask(2)}.
10921
10922 @item @emph{Standard}:
10923 GNU extension
10924
10925 @item @emph{Class}:
10926 Subroutine
10927
10928 @item @emph{Syntax}:
10929 @code{CALL UMASK(MASK [, OLD])}
10930
10931 @item @emph{Arguments}:
10932 @multitable @columnfractions .15 .70
10933 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
10934 @item @var{MASK} @tab (Optional) Shall be a scalar of type
10935                       @code{INTEGER}.
10936 @end multitable
10937
10938 @end table
10939
10940
10941
10942 @node UNLINK
10943 @section @code{UNLINK} --- Remove a file from the file system
10944 @fnindex UNLINK
10945 @cindex file system, remove file
10946
10947 @table @asis
10948 @item @emph{Description}:
10949 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
10950 used to mark the end of the name in @var{PATH}; otherwise, trailing
10951 blanks in the file name are ignored.  If the @var{STATUS} argument is
10952 supplied, it contains 0 on success or a nonzero error code upon return;
10953 see @code{unlink(2)}.
10954
10955 This intrinsic is provided in both subroutine and function forms;
10956 however, only one form can be used in any given program unit.
10957
10958 @item @emph{Standard}:
10959 GNU extension
10960
10961 @item @emph{Class}:
10962 Subroutine, function
10963
10964 @item @emph{Syntax}:
10965 @multitable @columnfractions .80
10966 @item @code{CALL UNLINK(PATH [, STATUS])}
10967 @item @code{STATUS = UNLINK(PATH)}
10968 @end multitable
10969
10970 @item @emph{Arguments}:
10971 @multitable @columnfractions .15 .70
10972 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
10973 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10974 @end multitable
10975
10976 @item @emph{See also}:
10977 @ref{LINK}, @ref{SYMLNK}
10978 @end table
10979
10980
10981
10982 @node UNPACK
10983 @section @code{UNPACK} --- Unpack an array of rank one into an array
10984 @fnindex UNPACK
10985 @cindex array, unpacking
10986 @cindex array, increase dimension
10987 @cindex array, scatter elements
10988
10989 @table @asis
10990 @item @emph{Description}:
10991 Store the elements of @var{VECTOR} in an array of higher rank.
10992
10993 @item @emph{Standard}:
10994 Fortran 95 and later
10995
10996 @item @emph{Class}:
10997 Transformational function
10998
10999 @item @emph{Syntax}:
11000 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
11001
11002 @item @emph{Arguments}:
11003 @multitable @columnfractions .15 .70
11004 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It 
11005 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
11006 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL}.
11007 @item @var{FIELD}  @tab Shall be of the same type as @var{VECTOR} and have
11008 the same shape as @var{MASK}.
11009 @end multitable
11010
11011 @item @emph{Return value}:
11012 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
11013 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
11014
11015 @item @emph{Example}:
11016 @smallexample
11017 PROGRAM test_unpack
11018   integer :: vector(2)  = (/1,1/)
11019   logical :: mask(4)  = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
11020   integer :: field(2,2) = 0, unity(2,2)
11021
11022   ! result: unity matrix
11023   unity = unpack(vector, reshape(mask, (/2,2/)), field)
11024 END PROGRAM
11025 @end smallexample
11026
11027 @item @emph{See also}:
11028 @ref{PACK}, @ref{SPREAD}
11029 @end table
11030
11031
11032
11033 @node VERIFY
11034 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
11035 @fnindex VERIFY
11036 @cindex string, find missing set
11037
11038 @table @asis
11039 @item @emph{Description}:
11040 Verifies that all the characters in a @var{SET} are present in a @var{STRING}.
11041
11042 If @var{BACK} is either absent or equals @code{FALSE}, this function
11043 returns the position of the leftmost character of @var{STRING} that is
11044 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
11045 is returned. If all characters of @var{SET} are found in @var{STRING}, the 
11046 result is zero.
11047
11048 @item @emph{Standard}:
11049 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
11050
11051 @item @emph{Class}:
11052 Elemental function
11053
11054 @item @emph{Syntax}:
11055 @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
11056
11057 @item @emph{Arguments}:
11058 @multitable @columnfractions .15 .70
11059 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
11060 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
11061 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
11062 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
11063                         expression indicating the kind parameter of
11064                         the result.
11065 @end multitable
11066
11067 @item @emph{Return value}:
11068 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11069 @var{KIND} is absent, the return value is of default integer kind.
11070
11071 @item @emph{Example}:
11072 @smallexample
11073 PROGRAM test_verify
11074   WRITE(*,*) VERIFY("FORTRAN", "AO")           ! 1, found 'F'
11075   WRITE(*,*) VERIFY("FORTRAN", "FOO")          ! 3, found 'R'
11076   WRITE(*,*) VERIFY("FORTRAN", "C++")          ! 1, found 'F'
11077   WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.)  ! 7, found 'N'
11078   WRITE(*,*) VERIFY("FORTRAN", "FORTRAN")      ! 0' found none
11079 END PROGRAM
11080 @end smallexample
11081
11082 @item @emph{See also}:
11083 @ref{SCAN}, @ref{INDEX intrinsic}
11084 @end table
11085
11086
11087
11088 @node XOR
11089 @section @code{XOR} --- Bitwise logical exclusive OR
11090 @fnindex XOR
11091 @cindex bitwise logical exclusive or
11092 @cindex logical exclusive or, bitwise
11093
11094 @table @asis
11095 @item @emph{Description}:
11096 Bitwise logical exclusive or. 
11097
11098 This intrinsic routine is provided for backwards compatibility with 
11099 GNU Fortran 77.  For integer arguments, programmers should consider
11100 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
11101
11102 @item @emph{Standard}:
11103 GNU extension
11104
11105 @item @emph{Class}:
11106 Function
11107
11108 @item @emph{Syntax}:
11109 @code{RESULT = XOR(X, Y)}
11110
11111 @item @emph{Arguments}:
11112 @multitable @columnfractions .15 .70
11113 @item @var{X} @tab The type shall be either  a scalar @code{INTEGER}
11114 type or a scalar @code{LOGICAL} type.
11115 @item @var{Y} @tab The type shall be the same as the type of @var{I}.
11116 @end multitable
11117
11118 @item @emph{Return value}:
11119 The return type is either a scalar @code{INTEGER} or a scalar
11120 @code{LOGICAL}.  If the kind type parameters differ, then the
11121 smaller kind type is implicitly converted to larger kind, and the 
11122 return has the larger kind.
11123
11124 @item @emph{Example}:
11125 @smallexample
11126 PROGRAM test_xor
11127   LOGICAL :: T = .TRUE., F = .FALSE.
11128   INTEGER :: a, b
11129   DATA a / Z'F' /, b / Z'3' /
11130
11131   WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
11132   WRITE (*,*) XOR(a, b)
11133 END PROGRAM
11134 @end smallexample
11135
11136 @item @emph{See also}:
11137 Fortran 95 elemental function: @ref{IEOR}
11138 @end table
11139
11140
11141
11142 @node Intrinsic Modules
11143 @chapter Intrinsic Modules
11144 @cindex intrinsic Modules
11145
11146 @c @node ISO_FORTRAN_ENV
11147 @section @code{ISO_FORTRAN_ENV}
11148 @table @asis
11149 @item @emph{Standard}:
11150 Fortran 2003 and later
11151 @end table
11152
11153 The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
11154 named constants:
11155
11156 @table @asis
11157 @item @code{CHARACTER_STORAGE_SIZE}:
11158 Size in bits of the character storage unit.
11159
11160 @item @code{ERROR_UNIT}:
11161 Identifies the preconnected unit used for error reporting.
11162
11163 @item @code{FILE_STORAGE_SIZE}:
11164 Size in bits of the file-storage unit.
11165
11166 @item @code{INPUT_UNIT}:
11167 Identifies the preconnected unit identified by the asterisk
11168 (@code{*}) in @code{READ} statement.
11169
11170 @item @code{IOSTAT_END}:
11171 The value assigned to the variable passed to the IOSTAT= specifier of
11172 an input/output statement if an end-of-file condition occurred.
11173
11174 @item @code{IOSTAT_EOR}:
11175 The value assigned to the variable passed to the IOSTAT= specifier of
11176 an input/output statement if an end-of-record condition occurred.
11177
11178 @item @code{NUMERIC_STORAGE_SIZE}:
11179 The size in bits of the numeric storage unit.
11180
11181 @item @code{OUTPUT_UNIT}:
11182 Identifies the preconnected unit identified by the asterisk
11183 (@code{*}) in @code{WRITE} statement.
11184 @end table
11185
11186 @c @node ISO_C_BINDING
11187 @section @code{ISO_C_BINDING}
11188 @table @asis
11189 @item @emph{Standard}:
11190 Fortran 2003 and later, GNU extensions
11191 @end table
11192
11193 The following intrinsic procedures are provided by the module; their
11194 definition can be found in the section Intrinsic Procedures of this
11195 manual.
11196
11197 @table @asis
11198 @item @code{C_ASSOCIATED}
11199 @item @code{C_F_POINTER}
11200 @item @code{C_F_PROCPOINTER}
11201 @item @code{C_FUNLOC}
11202 @item @code{C_LOC}
11203 @end table
11204
11205 The @code{ISO_C_BINDING} module provides the following named constants of the
11206 type integer, which can be used as KIND type parameter. Note that GNU
11207 Fortran currently does not support the @code{C_INT_FAST...} KIND type
11208 parameters (marked by an asterisk (@code{*}) in the list below).
11209 The @code{C_INT_FAST...} parameters have therefore the value @math{-2}
11210 and cannot be used as KIND type parameter of the @code{INTEGER} type.
11211
11212 In addition to the integer named constants required by the Fortran 2003 
11213 standard, GNU Fortran provides as an extension named constants for the 
11214 128-bit integer types supported by the C compiler: @code{C_INT128_T, 
11215 C_INT_LEAST128_T, C_INT_FAST128_T}.
11216
11217 @multitable @columnfractions .15 .35 .35 .35
11218 @item Fortran Type  @tab Named constant         @tab C type                                @tab Extension
11219 @item @code{INTEGER}@tab @code{C_INT}           @tab @code{int}
11220 @item @code{INTEGER}@tab @code{C_SHORT}         @tab @code{short int}
11221 @item @code{INTEGER}@tab @code{C_LONG}          @tab @code{long int}
11222 @item @code{INTEGER}@tab @code{C_LONG_LONG}     @tab @code{long long int}
11223 @item @code{INTEGER}@tab @code{C_SIGNED_CHAR}   @tab @code{signed char}/@code{unsigned char}
11224 @item @code{INTEGER}@tab @code{C_SIZE_T}        @tab @code{size_t}
11225 @item @code{INTEGER}@tab @code{C_INT8_T}        @tab @code{int8_t}
11226 @item @code{INTEGER}@tab @code{C_INT16_T}       @tab @code{int16_t}
11227 @item @code{INTEGER}@tab @code{C_INT32_T}       @tab @code{int32_t}
11228 @item @code{INTEGER}@tab @code{C_INT64_T}       @tab @code{int64_t}
11229 @item @code{INTEGER}@tab @code{C_INT128_T}       @tab @code{int128_t}                      @tab Ext.
11230 @item @code{INTEGER}@tab @code{C_INT_LEAST8_T}  @tab @code{int_least8_t}
11231 @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
11232 @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
11233 @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
11234 @item @code{INTEGER}@tab @code{C_INT_LEAST128_T} @tab @code{int_least128_t}                @tab Ext.
11235 @item @code{INTEGER}@tab @code{C_INT_FAST8_T}*  @tab @code{int_fast8_t}
11236 @item @code{INTEGER}@tab @code{C_INT_FAST16_T}* @tab @code{int_fast16_t}
11237 @item @code{INTEGER}@tab @code{C_INT_FAST32_T}* @tab @code{int_fast32_t}
11238 @item @code{INTEGER}@tab @code{C_INT_FAST64_T}* @tab @code{int_fast64_t}
11239 @item @code{INTEGER}@tab @code{C_INT_FAST128_T}* @tab @code{int_fast128_t}                 @tab Ext.
11240 @item @code{INTEGER}@tab @code{C_INTMAX_T}      @tab @code{intmax_t}
11241 @item @code{INTEGER}@tab @code{C_INTPTR_T}      @tab @code{intptr_t}
11242 @item @code{REAL}   @tab @code{C_FLOAT}         @tab @code{float}
11243 @item @code{REAL}   @tab @code{C_DOUBLE}        @tab @code{double}
11244 @item @code{REAL}   @tab @code{C_LONG_DOUBLE}   @tab @code{long double}
11245 @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
11246 @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
11247 @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
11248 @item @code{LOGICAL}@tab @code{C_BOOL}          @tab @code{_Bool}
11249 @item @code{CHARACTER}@tab @code{C_CHAR}        @tab @code{char}
11250 @end multitable
11251
11252 Additionally, the following @code{(CHARACTER(KIND=C_CHAR)} are
11253 defined.
11254
11255 @multitable @columnfractions .20 .45 .15
11256 @item Name                     @tab C definition    @tab Value
11257 @item @code{C_NULL_CHAR}       @tab null character  @tab @code{'\0'}
11258 @item @code{C_ALERT}           @tab alert           @tab @code{'\a'}
11259 @item @code{C_BACKSPACE}       @tab backspace       @tab @code{'\b'}
11260 @item @code{C_FORM_FEED}       @tab form feed       @tab @code{'\f'}
11261 @item @code{C_NEW_LINE}        @tab new line        @tab @code{'\n'}
11262 @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
11263 @item @code{C_HORIZONTAL_TAB}  @tab horizontal tab  @tab @code{'\t'}
11264 @item @code{C_VERTICAL_TAB}    @tab vertical tab    @tab @code{'\v'}
11265 @end multitable
11266
11267 @c @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
11268 @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
11269 @table @asis
11270 @item @emph{Standard}:
11271 OpenMP Application Program Interface v2.5
11272 @end table
11273
11274
11275 The OpenMP Fortran runtime library routines are provided both in
11276 a form of two Fortran 90 modules, named @code{OMP_LIB} and 
11277 @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
11278 @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
11279 in the @ref{Top,,Introduction,libgomp,GNU OpenMP runtime library} manual,
11280 the named constants defined in the @code{OMP_LIB_KINDS} module are listed
11281 below.
11282
11283 For details refer to the actual
11284 @uref{http://www.openmp.org/drupal/mp-documents/spec25.pdf,
11285 OpenMP Application Program Interface v2.5}.
11286
11287 @code{OMP_LIB_KINDS} provides the following scalar default-integer
11288 named constants:
11289
11290 @table @asis
11291 @item @code{omp_integer_kind}
11292 @item @code{omp_logical_kind}
11293 @item @code{omp_lock_kind}
11294 @item @code{omp_nest_lock_kind}
11295 @end table