OSDN Git Service

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