OSDN Git Service

2010-08-19 Tobias Burnus <burnus@net-b.de>
[pf3gnuchains/gcc-fork.git] / gcc / fortran / intrinsic.texi
1 @ignore
2 Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc.
4 This is part of the GNU Fortran manual.   
5 For copying conditions, see the file gfortran.texi.
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.3 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,     Inverse hyperbolic cosine 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,     Inverse hyperbolic sine 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,     Inverse hyperbolic tangent function
64 * @code{BESSEL_J0}:     BESSEL_J0, Bessel function of the first kind of order 0
65 * @code{BESSEL_J1}:     BESSEL_J1, Bessel function of the first kind of order 1
66 * @code{BESSEL_JN}:     BESSEL_JN, Bessel function of the first kind
67 * @code{BESSEL_Y0}:     BESSEL_Y0, Bessel function of the second kind of order 0
68 * @code{BESSEL_Y1}:     BESSEL_Y1, Bessel function of the second kind of order 1
69 * @code{BESSEL_YN}:     BESSEL_YN, Bessel function of the second kind
70 * @code{BIT_SIZE}:      BIT_SIZE,  Bit size inquiry function
71 * @code{BTEST}:         BTEST,     Bit test function
72 * @code{C_ASSOCIATED}:  C_ASSOCIATED, Status of a C pointer
73 * @code{C_F_POINTER}:   C_F_POINTER, Convert C into Fortran pointer
74 * @code{C_F_PROCPOINTER}: C_F_PROCPOINTER, Convert C into Fortran procedure pointer
75 * @code{C_FUNLOC}:      C_FUNLOC,  Obtain the C address of a procedure
76 * @code{C_LOC}:         C_LOC,     Obtain the C address of an object
77 * @code{C_SIZEOF}:      C_SIZEOF,  Size in bytes of an expression
78 * @code{CEILING}:       CEILING,   Integer ceiling function
79 * @code{CHAR}:          CHAR,      Integer-to-character conversion function
80 * @code{CHDIR}:         CHDIR,     Change working directory
81 * @code{CHMOD}:         CHMOD,     Change access permissions of files
82 * @code{CMPLX}:         CMPLX,     Complex conversion function
83 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
84 * @code{COMPLEX}:       COMPLEX,   Complex conversion function
85 * @code{CONJG}:         CONJG,     Complex conjugate function
86 * @code{COS}:           COS,       Cosine function
87 * @code{COSH}:          COSH,      Hyperbolic cosine function
88 * @code{COUNT}:         COUNT,     Count occurrences of TRUE in an array
89 * @code{CPU_TIME}:      CPU_TIME,  CPU time subroutine
90 * @code{CSHIFT}:        CSHIFT,    Circular shift elements of an array
91 * @code{CTIME}:         CTIME,     Subroutine (or function) to convert a time into a string
92 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
93 * @code{DBLE}:          DBLE,      Double precision conversion function
94 * @code{DCMPLX}:        DCMPLX,    Double complex conversion function
95 * @code{DIGITS}:        DIGITS,    Significant digits function
96 * @code{DIM}:           DIM,       Positive difference
97 * @code{DOT_PRODUCT}:   DOT_PRODUCT, Dot product function
98 * @code{DPROD}:         DPROD,     Double product function
99 * @code{DREAL}:         DREAL,     Double real part function
100 * @code{DTIME}:         DTIME,     Execution time subroutine (or function)
101 * @code{EOSHIFT}:       EOSHIFT,   End-off shift elements of an array
102 * @code{EPSILON}:       EPSILON,   Epsilon function
103 * @code{ERF}:           ERF,       Error function
104 * @code{ERFC}:          ERFC,      Complementary error function
105 * @code{ERFC_SCALED}:   ERFC_SCALED, Exponentially-scaled complementary error function
106 * @code{ETIME}:         ETIME,     Execution time subroutine (or function)
107 * @code{EXIT}:          EXIT,      Exit the program with status.
108 * @code{EXP}:           EXP,       Exponential function
109 * @code{EXPONENT}:      EXPONENT,  Exponent function
110 * @code{EXTENDS_TYPE_OF}: EXTENDS_TYPE_OF,  Query dynamic type for extension
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{FLOOR}:         FLOOR,     Integer floor function
115 * @code{FLUSH}:         FLUSH,     Flush I/O unit(s)
116 * @code{FNUM}:          FNUM,      File number function
117 * @code{FPUT}:          FPUT,      Write a single character in stream mode to stdout
118 * @code{FPUTC}:         FPUTC,     Write a single character in stream mode
119 * @code{FRACTION}:      FRACTION,  Fractional part of the model representation
120 * @code{FREE}:          FREE,      Memory de-allocation subroutine
121 * @code{FSEEK}:         FSEEK,     Low level file positioning subroutine
122 * @code{FSTAT}:         FSTAT,     Get file status
123 * @code{FTELL}:         FTELL,     Current stream position
124 * @code{GAMMA}:         GAMMA,     Gamma function
125 * @code{GERROR}:        GERROR,    Get last system error message
126 * @code{GETARG}:        GETARG,    Get command line arguments
127 * @code{GET_COMMAND}:   GET_COMMAND, Get the entire command line
128 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
129 * @code{GETCWD}:        GETCWD,    Get current working directory
130 * @code{GETENV}:        GETENV,    Get an environmental variable
131 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
132 * @code{GETGID}:        GETGID,    Group ID function
133 * @code{GETLOG}:        GETLOG,    Get login name
134 * @code{GETPID}:        GETPID,    Process ID function
135 * @code{GETUID}:        GETUID,    User ID function
136 * @code{GMTIME}:        GMTIME,    Convert time to GMT info
137 * @code{HOSTNM}:        HOSTNM,    Get system host name
138 * @code{HUGE}:          HUGE,      Largest number of a kind
139 * @code{HYPOT}:         HYPOT,     Euclidian distance function
140 * @code{IACHAR}:        IACHAR,    Code in @acronym{ASCII} collating sequence
141 * @code{IAND}:          IAND,      Bitwise logical and
142 * @code{IARGC}:         IARGC,     Get the number of command line arguments
143 * @code{IBCLR}:         IBCLR,     Clear bit
144 * @code{IBITS}:         IBITS,     Bit extraction
145 * @code{IBSET}:         IBSET,     Set bit
146 * @code{ICHAR}:         ICHAR,     Character-to-integer conversion function
147 * @code{IDATE}:         IDATE,     Current local time (day/month/year)
148 * @code{IEOR}:          IEOR,      Bitwise logical exclusive or
149 * @code{IERRNO}:        IERRNO,    Function to get the last system error number
150 * @code{INDEX}:         INDEX intrinsic, Position of a substring within a string
151 * @code{INT}:           INT,       Convert to integer type
152 * @code{INT2}:          INT2,      Convert to 16-bit integer type
153 * @code{INT8}:          INT8,      Convert to 64-bit integer type
154 * @code{IOR}:           IOR,       Bitwise logical or
155 * @code{IRAND}:         IRAND,     Integer pseudo-random number
156 * @code{IMAGE_INDEX}:   IMAGE_INDEX, Cosubscript to image index convertion
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{LCOBOUND}:      LCOBOUND,  Lower codimension bounds of an array
168 * @code{LEADZ}:         LEADZ,     Number of leading zero bits of an integer
169 * @code{LEN}:           LEN,       Length of a character entity
170 * @code{LEN_TRIM}:      LEN_TRIM,  Length of a character entity without trailing blank characters
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{LOG_GAMMA}:     LOG_GAMMA, Logarithm of the Gamma function
181 * @code{LOGICAL}:       LOGICAL,   Convert to logical type
182 * @code{LONG}:          LONG,      Convert to integer type
183 * @code{LSHIFT}:        LSHIFT,    Left shift bits
184 * @code{LSTAT}:         LSTAT,     Get file status
185 * @code{LTIME}:         LTIME,     Convert time to local time info
186 * @code{MALLOC}:        MALLOC,    Dynamic memory allocation function
187 * @code{MATMUL}:        MATMUL,    matrix multiplication
188 * @code{MAX}:           MAX,       Maximum value of an argument list
189 * @code{MAXEXPONENT}:   MAXEXPONENT, Maximum exponent of a real kind
190 * @code{MAXLOC}:        MAXLOC,    Location of the maximum value within an array
191 * @code{MAXVAL}:        MAXVAL,    Maximum value of an array
192 * @code{MCLOCK}:        MCLOCK,    Time function
193 * @code{MCLOCK8}:       MCLOCK8,   Time function (64-bit)
194 * @code{MERGE}:         MERGE,     Merge arrays
195 * @code{MIN}:           MIN,       Minimum value of an argument list
196 * @code{MINEXPONENT}:   MINEXPONENT, Minimum exponent of a real kind
197 * @code{MINLOC}:        MINLOC,    Location of the minimum value within an array
198 * @code{MINVAL}:        MINVAL,    Minimum value of an array
199 * @code{MOD}:           MOD,       Remainder function
200 * @code{MODULO}:        MODULO,    Modulo function
201 * @code{MOVE_ALLOC}:    MOVE_ALLOC, Move allocation from one object to another
202 * @code{MVBITS}:        MVBITS,    Move bits from one integer to another
203 * @code{NEAREST}:       NEAREST,   Nearest representable number
204 * @code{NEW_LINE}:      NEW_LINE,  New line character
205 * @code{NINT}:          NINT,      Nearest whole number
206 * @code{NOT}:           NOT,       Logical negation
207 * @code{NULL}:          NULL,      Function that returns an disassociated pointer
208 * @code{NUM_IMAGES}:    NUM_IMAGES, Number of images
209 * @code{OR}:            OR,        Bitwise logical OR
210 * @code{PACK}:          PACK,      Pack an array into an array of rank one
211 * @code{PERROR}:        PERROR,    Print system error message
212 * @code{PRECISION}:     PRECISION, Decimal precision of a real kind
213 * @code{PRESENT}:       PRESENT,   Determine whether an optional dummy argument is specified
214 * @code{PRODUCT}:       PRODUCT,   Product of array elements
215 * @code{RADIX}:         RADIX,     Base of a data model
216 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
217 * @code{RANDOM_SEED}:   RANDOM_SEED, Initialize a pseudo-random number sequence
218 * @code{RAND}:          RAND,      Real pseudo-random number
219 * @code{RANGE}:         RANGE,     Decimal exponent range
220 * @code{RAN}:           RAN,       Real pseudo-random number
221 * @code{REAL}:          REAL,      Convert to real type 
222 * @code{RENAME}:        RENAME,    Rename a file
223 * @code{REPEAT}:        REPEAT,    Repeated string concatenation
224 * @code{RESHAPE}:       RESHAPE,   Function to reshape an array
225 * @code{RRSPACING}:     RRSPACING, Reciprocal of the relative spacing
226 * @code{RSHIFT}:        RSHIFT,    Right shift bits
227 * @code{SAME_TYPE_AS}:  SAME_TYPE_AS,  Query dynamic types for equality
228 * @code{SCALE}:         SCALE,     Scale a real value
229 * @code{SCAN}:          SCAN,      Scan a string for the presence of a set of characters
230 * @code{SECNDS}:        SECNDS,    Time function
231 * @code{SECOND}:        SECOND,    CPU time function
232 * @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND,  Choose character kind
233 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND,  Choose integer kind
234 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND,  Choose real kind
235 * @code{SET_EXPONENT}:  SET_EXPONENT, Set the exponent of the model
236 * @code{SHAPE}:         SHAPE,     Determine the shape of an array
237 * @code{SIGN}:          SIGN,      Sign copying function
238 * @code{SIGNAL}:        SIGNAL,    Signal handling subroutine (or function)
239 * @code{SIN}:           SIN,       Sine function
240 * @code{SINH}:          SINH,      Hyperbolic sine function
241 * @code{SIZE}:          SIZE,      Function to determine the size of an array
242 * @code{SIZEOF}:        SIZEOF,    Determine the size in bytes of an expression
243 * @code{SLEEP}:         SLEEP,     Sleep for the specified number of seconds
244 * @code{SPACING}:       SPACING,   Smallest distance between two numbers of a given type
245 * @code{SPREAD}:        SPREAD,    Add a dimension to an array 
246 * @code{SQRT}:          SQRT,      Square-root function
247 * @code{SRAND}:         SRAND,     Reinitialize the random number generator
248 * @code{STAT}:          STAT,      Get file status
249 * @code{STORAGE_SIZE}:  STORAGE_SIZE, Storage size in bits
250 * @code{SUM}:           SUM,       Sum of array elements
251 * @code{SYMLNK}:        SYMLNK,    Create a symbolic link
252 * @code{SYSTEM}:        SYSTEM,    Execute a shell command
253 * @code{SYSTEM_CLOCK}:  SYSTEM_CLOCK, Time function
254 * @code{TAN}:           TAN,       Tangent function
255 * @code{TANH}:          TANH,      Hyperbolic tangent function
256 * @code{THIS_IMAGE}:    THIS_IMAGE, Cosubscript index of this image
257 * @code{TIME}:          TIME,      Time function
258 * @code{TIME8}:         TIME8,     Time function (64-bit)
259 * @code{TINY}:          TINY,      Smallest positive number of a real kind
260 * @code{TRAILZ}:        TRAILZ,    Number of trailing zero bits of an integer
261 * @code{TRANSFER}:      TRANSFER,  Transfer bit patterns
262 * @code{TRANSPOSE}:     TRANSPOSE, Transpose an array of rank two
263 * @code{TRIM}:          TRIM,      Remove trailing blank characters of a string
264 * @code{TTYNAM}:        TTYNAM,    Get the name of a terminal device.
265 * @code{UBOUND}:        UBOUND,    Upper dimension bounds of an array
266 * @code{UCOBOUND}:      UCOBOUND,  Upper codimension bounds of an array
267 * @code{UMASK}:         UMASK,     Set the file creation mask
268 * @code{UNLINK}:        UNLINK,    Remove a file from the file system
269 * @code{UNPACK}:        UNPACK,    Unpack an array of rank one into an array
270 * @code{VERIFY}:        VERIFY,    Scan a string for the absence of a set of characters
271 * @code{XOR}:           XOR,       Bitwise logical exclusive or
272 @end menu
273
274 @node Introduction to Intrinsics
275 @section Introduction to intrinsic procedures
276
277 The intrinsic procedures provided by GNU Fortran include all of the
278 intrinsic procedures required by the Fortran 95 standard, a set of
279 intrinsic procedures for backwards compatibility with G77, and a
280 selection of intrinsic procedures from the Fortran 2003 and Fortran 2008
281 standards.  Any conflict between a description here and a description in
282 either the Fortran 95 standard, the Fortran 2003 standard or the Fortran
283 2008 standard is unintentional, and the standard(s) should be considered
284 authoritative.
285
286 The enumeration of the @code{KIND} type parameter is processor defined in
287 the Fortran 95 standard.  GNU Fortran defines the default integer type and
288 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
289 respectively.  The standard mandates that both data types shall have
290 another kind, which have more precision.  On typical target architectures
291 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
292 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
293 In the description of generic intrinsic procedures, the kind type parameter
294 will be specified by @code{KIND=*}, and in the description of specific
295 names for an intrinsic procedure the kind type parameter will be explicitly
296 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}).  Finally, for
297 brevity the optional @code{KIND=} syntax will be omitted.
298
299 Many of the intrinsic procedures take one or more optional arguments.
300 This document follows the convention used in the Fortran 95 standard,
301 and denotes such arguments by square brackets.
302
303 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
304 which can be used to restrict the set of intrinsic procedures to a 
305 given standard.  By default, @command{gfortran} sets the @option{-std=gnu}
306 option, and so all intrinsic procedures described here are accepted.  There
307 is one caveat.  For a select group of intrinsic procedures, @command{g77}
308 implemented both a function and a subroutine.  Both classes 
309 have been implemented in @command{gfortran} for backwards compatibility
310 with @command{g77}.  It is noted here that these functions and subroutines
311 cannot be intermixed in a given subprogram.  In the descriptions that follow,
312 the applicable standard for each intrinsic procedure is noted.
313
314
315
316 @node ABORT
317 @section @code{ABORT} --- Abort the program
318 @fnindex ABORT
319 @cindex program termination, with core dump
320 @cindex terminate program, with core dump
321 @cindex core, dump
322
323 @table @asis
324 @item @emph{Description}:
325 @code{ABORT} causes immediate termination of the program.  On operating
326 systems that support a core dump, @code{ABORT} will produce a core dump even if
327 the option @option{-fno-dump-core} is in effect, which is suitable for debugging
328 purposes.
329 @c TODO: Check if this (with -fno-dump-core) is correct.
330
331 @item @emph{Standard}:
332 GNU extension
333
334 @item @emph{Class}:
335 Subroutine
336
337 @item @emph{Syntax}:
338 @code{CALL ABORT}
339
340 @item @emph{Return value}:
341 Does not return.
342
343 @item @emph{Example}:
344 @smallexample
345 program test_abort
346   integer :: i = 1, j = 2
347   if (i /= j) call abort
348 end program test_abort
349 @end smallexample
350
351 @item @emph{See also}:
352 @ref{EXIT}, @ref{KILL}
353
354 @end table
355
356
357
358 @node ABS
359 @section @code{ABS} --- Absolute value
360 @fnindex ABS
361 @fnindex CABS
362 @fnindex DABS
363 @fnindex IABS
364 @fnindex ZABS
365 @fnindex CDABS
366 @cindex absolute value
367
368 @table @asis
369 @item @emph{Description}:
370 @code{ABS(A)} computes the absolute value of @code{A}.
371
372 @item @emph{Standard}:
373 Fortran 77 and later, has overloads that are GNU extensions
374
375 @item @emph{Class}:
376 Elemental function
377
378 @item @emph{Syntax}:
379 @code{RESULT = ABS(A)}
380
381 @item @emph{Arguments}:
382 @multitable @columnfractions .15 .70
383 @item @var{A} @tab The type of the argument shall be an @code{INTEGER},
384 @code{REAL}, or @code{COMPLEX}.
385 @end multitable
386
387 @item @emph{Return value}:
388 The return value is of the same type and
389 kind as the argument except the return value is @code{REAL} for a
390 @code{COMPLEX} argument.
391
392 @item @emph{Example}:
393 @smallexample
394 program test_abs
395   integer :: i = -1
396   real :: x = -1.e0
397   complex :: z = (-1.e0,0.e0)
398   i = abs(i)
399   x = abs(x)
400   x = abs(z)
401 end program test_abs
402 @end smallexample
403
404 @item @emph{Specific names}:
405 @multitable @columnfractions .20 .20 .20 .25
406 @item Name            @tab Argument            @tab Return type       @tab Standard
407 @item @code{ABS(A)}   @tab @code{REAL(4) A}    @tab @code{REAL(4)}    @tab Fortran 77 and later
408 @item @code{CABS(A)}  @tab @code{COMPLEX(4) A} @tab @code{REAL(4)}    @tab Fortran 77 and later
409 @item @code{DABS(A)}  @tab @code{REAL(8) A}    @tab @code{REAL(8)}    @tab Fortran 77 and later
410 @item @code{IABS(A)}  @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab Fortran 77 and later
411 @item @code{ZABS(A)}  @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
412 @item @code{CDABS(A)} @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
413 @end multitable
414 @end table
415
416
417
418 @node ACCESS
419 @section @code{ACCESS} --- Checks file access modes
420 @fnindex ACCESS
421 @cindex file system, access mode
422
423 @table @asis
424 @item @emph{Description}:
425 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME} 
426 exists, is readable, writable or executable. Except for the
427 executable check, @code{ACCESS} can be replaced by
428 Fortran 95's @code{INQUIRE}.
429
430 @item @emph{Standard}:
431 GNU extension
432
433 @item @emph{Class}:
434 Inquiry function
435
436 @item @emph{Syntax}:
437 @code{RESULT = ACCESS(NAME, MODE)}
438
439 @item @emph{Arguments}:
440 @multitable @columnfractions .15 .70
441 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
442 file name. Tailing blank are ignored unless the character @code{achar(0)}
443 is present, then all characters up to and excluding @code{achar(0)} are
444 used as file name.
445 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the
446 file access mode, may be any concatenation of @code{"r"} (readable),
447 @code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check
448 for existence.
449 @end multitable
450
451 @item @emph{Return value}:
452 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
453 accessible in the given mode; otherwise or if an invalid argument
454 has been given for @code{MODE} the value @code{1} is returned.
455
456 @item @emph{Example}:
457 @smallexample
458 program access_test
459   implicit none
460   character(len=*), parameter :: file  = 'test.dat'
461   character(len=*), parameter :: file2 = 'test.dat  '//achar(0)
462   if(access(file,' ') == 0) print *, trim(file),' is exists'
463   if(access(file,'r') == 0) print *, trim(file),' is readable'
464   if(access(file,'w') == 0) print *, trim(file),' is writable'
465   if(access(file,'x') == 0) print *, trim(file),' is executable'
466   if(access(file2,'rwx') == 0) &
467     print *, trim(file2),' is readable, writable and executable'
468 end program access_test
469 @end smallexample
470 @item @emph{Specific names}:
471 @item @emph{See also}:
472
473 @end table
474
475
476
477 @node ACHAR
478 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence 
479 @fnindex ACHAR
480 @cindex @acronym{ASCII} collating sequence
481 @cindex collating sequence, @acronym{ASCII}
482
483 @table @asis
484 @item @emph{Description}:
485 @code{ACHAR(I)} returns the character located at position @code{I}
486 in the @acronym{ASCII} collating sequence.
487
488 @item @emph{Standard}:
489 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
490
491 @item @emph{Class}:
492 Elemental function
493
494 @item @emph{Syntax}:
495 @code{RESULT = ACHAR(I [, KIND])}
496
497 @item @emph{Arguments}:
498 @multitable @columnfractions .15 .70
499 @item @var{I}    @tab The type shall be @code{INTEGER}.
500 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
501 expression indicating the kind parameter of the result.
502 @end multitable
503
504 @item @emph{Return value}:
505 The return value is of type @code{CHARACTER} with a length of one.
506 If the @var{KIND} argument is present, the return value is of the
507 specified kind and of the default kind otherwise.
508
509 @item @emph{Example}:
510 @smallexample
511 program test_achar
512   character c
513   c = achar(32)
514 end program test_achar
515 @end smallexample
516
517 @item @emph{Note}:
518 See @ref{ICHAR} for a discussion of converting between numerical values
519 and formatted string representations.
520
521 @item @emph{See also}:
522 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
523
524 @end table
525
526
527
528 @node ACOS
529 @section @code{ACOS} --- Arccosine function 
530 @fnindex ACOS
531 @fnindex DACOS
532 @cindex trigonometric function, cosine, inverse
533 @cindex cosine, inverse
534
535 @table @asis
536 @item @emph{Description}:
537 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
538
539 @item @emph{Standard}:
540 Fortran 77 and later, for a complex argument Fortran 2008 or later
541
542 @item @emph{Class}:
543 Elemental function
544
545 @item @emph{Syntax}:
546 @code{RESULT = ACOS(X)}
547
548 @item @emph{Arguments}:
549 @multitable @columnfractions .15 .70
550 @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
551 less than or equal to one - or the type shall be @code{COMPLEX}.
552 @end multitable
553
554 @item @emph{Return value}:
555 The return value is of the same type and kind as @var{X}.
556 The real part of the result is in radians and lies in the range
557 @math{0 \leq \Re \acos(x) \leq \pi}.
558
559 @item @emph{Example}:
560 @smallexample
561 program test_acos
562   real(8) :: x = 0.866_8
563   x = acos(x)
564 end program test_acos
565 @end smallexample
566
567 @item @emph{Specific names}:
568 @multitable @columnfractions .20 .20 .20 .25
569 @item Name            @tab Argument         @tab Return type     @tab Standard
570 @item @code{ACOS(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}  @tab Fortran 77 and later
571 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}  @tab Fortran 77 and later
572 @end multitable
573
574 @item @emph{See also}:
575 Inverse function: @ref{COS}
576
577 @end table
578
579
580
581 @node ACOSH
582 @section @code{ACOSH} --- Inverse hyperbolic cosine function
583 @fnindex ACOSH
584 @fnindex DACOSH
585 @cindex area hyperbolic cosine
586 @cindex inverse hyperbolic cosine
587 @cindex hyperbolic function, cosine, inverse
588 @cindex cosine, hyperbolic, inverse
589
590 @table @asis
591 @item @emph{Description}:
592 @code{ACOSH(X)} computes the inverse hyperbolic cosine of @var{X}.
593
594 @item @emph{Standard}:
595 Fortran 2008 and later
596
597 @item @emph{Class}:
598 Elemental function
599
600 @item @emph{Syntax}:
601 @code{RESULT = ACOSH(X)}
602
603 @item @emph{Arguments}:
604 @multitable @columnfractions .15 .70
605 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
606 @end multitable
607
608 @item @emph{Return value}:
609 The return value has the same type and kind as @var{X}. If @var{X} is
610 complex, the imaginary part of the result is in radians and lies between
611 @math{ 0 \leq \Im \acosh(x) \leq \pi}.
612
613 @item @emph{Example}:
614 @smallexample
615 PROGRAM test_acosh
616   REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
617   WRITE (*,*) ACOSH(x)
618 END PROGRAM
619 @end smallexample
620
621 @item @emph{Specific names}:
622 @multitable @columnfractions .20 .20 .20 .25
623 @item Name             @tab Argument          @tab Return type       @tab Standard
624 @item @code{DACOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
625 @end multitable
626
627 @item @emph{See also}:
628 Inverse function: @ref{COSH}
629 @end table
630
631
632
633 @node ADJUSTL
634 @section @code{ADJUSTL} --- Left adjust a string 
635 @fnindex ADJUSTL
636 @cindex string, adjust left
637 @cindex adjust string
638
639 @table @asis
640 @item @emph{Description}:
641 @code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
642 Spaces are inserted at the end of the string as needed.
643
644 @item @emph{Standard}:
645 Fortran 90 and later
646
647 @item @emph{Class}:
648 Elemental function
649
650 @item @emph{Syntax}:
651 @code{RESULT = ADJUSTL(STRING)}
652
653 @item @emph{Arguments}:
654 @multitable @columnfractions .15 .70
655 @item @var{STRING} @tab The type shall be @code{CHARACTER}.
656 @end multitable
657
658 @item @emph{Return value}:
659 The return value is of type @code{CHARACTER} and of the same kind as
660 @var{STRING} where leading spaces are removed and the same number of
661 spaces are inserted on the end of @var{STRING}.
662
663 @item @emph{Example}:
664 @smallexample
665 program test_adjustl
666   character(len=20) :: str = '   gfortran'
667   str = adjustl(str)
668   print *, str
669 end program test_adjustl
670 @end smallexample
671
672 @item @emph{See also}:
673 @ref{ADJUSTR}, @ref{TRIM}
674 @end table
675
676
677
678 @node ADJUSTR
679 @section @code{ADJUSTR} --- Right adjust a string 
680 @fnindex ADJUSTR
681 @cindex string, adjust right
682 @cindex adjust string
683
684 @table @asis
685 @item @emph{Description}:
686 @code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
687 Spaces are inserted at the start of the string as needed.
688
689 @item @emph{Standard}:
690 Fortran 95 and later
691
692 @item @emph{Class}:
693 Elemental function
694
695 @item @emph{Syntax}:
696 @code{RESULT = ADJUSTR(STRING)}
697
698 @item @emph{Arguments}:
699 @multitable @columnfractions .15 .70
700 @item @var{STR} @tab The type shall be @code{CHARACTER}.
701 @end multitable
702
703 @item @emph{Return value}:
704 The return value is of type @code{CHARACTER} and of the same kind as
705 @var{STRING} where trailing spaces are removed and the same number of
706 spaces are inserted at the start of @var{STRING}.
707
708 @item @emph{Example}:
709 @smallexample
710 program test_adjustr
711   character(len=20) :: str = 'gfortran'
712   str = adjustr(str)
713   print *, str
714 end program test_adjustr
715 @end smallexample
716
717 @item @emph{See also}:
718 @ref{ADJUSTL}, @ref{TRIM}
719 @end table
720
721
722
723 @node AIMAG
724 @section @code{AIMAG} --- Imaginary part of complex number  
725 @fnindex AIMAG
726 @fnindex DIMAG
727 @fnindex IMAG
728 @fnindex IMAGPART
729 @cindex complex numbers, imaginary part
730
731 @table @asis
732 @item @emph{Description}:
733 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
734 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
735 for compatibility with @command{g77}, and their use in new code is 
736 strongly discouraged.
737
738 @item @emph{Standard}:
739 Fortran 77 and later, has overloads that are GNU extensions
740
741 @item @emph{Class}:
742 Elemental function
743
744 @item @emph{Syntax}:
745 @code{RESULT = AIMAG(Z)}
746
747 @item @emph{Arguments}:
748 @multitable @columnfractions .15 .70
749 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
750 @end multitable
751
752 @item @emph{Return value}:
753 The return value is of type @code{REAL} with the
754 kind type parameter of the argument.
755
756 @item @emph{Example}:
757 @smallexample
758 program test_aimag
759   complex(4) z4
760   complex(8) z8
761   z4 = cmplx(1.e0_4, 0.e0_4)
762   z8 = cmplx(0.e0_8, 1.e0_8)
763   print *, aimag(z4), dimag(z8)
764 end program test_aimag
765 @end smallexample
766
767 @item @emph{Specific names}:
768 @multitable @columnfractions .20 .20 .20 .25
769 @item Name               @tab Argument            @tab Return type     @tab Standard
770 @item @code{AIMAG(Z)}    @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
771 @item @code{DIMAG(Z)}    @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)}  @tab GNU extension
772 @item @code{IMAG(Z)}     @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
773 @item @code{IMAGPART(Z)} @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
774 @end multitable
775 @end table
776
777
778
779 @node AINT
780 @section @code{AINT} --- Truncate to a whole number
781 @fnindex AINT
782 @fnindex DINT
783 @cindex floor
784 @cindex rounding, floor
785
786 @table @asis
787 @item @emph{Description}:
788 @code{AINT(A [, KIND])} truncates its argument to a whole number.
789
790 @item @emph{Standard}:
791 Fortran 77 and later
792
793 @item @emph{Class}:
794 Elemental function
795
796 @item @emph{Syntax}:
797 @code{RESULT = AINT(A [, KIND])} 
798
799 @item @emph{Arguments}:
800 @multitable @columnfractions .15 .70
801 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
802 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
803 expression indicating the kind parameter of the result.
804 @end multitable
805
806 @item @emph{Return value}:
807 The return value is of type @code{REAL} with the kind type parameter of the
808 argument if the optional @var{KIND} is absent; otherwise, the kind
809 type parameter will be given by @var{KIND}.  If the magnitude of 
810 @var{X} is less than one, @code{AINT(X)} returns zero.  If the
811 magnitude is equal to or greater than one then it returns the largest
812 whole number that does not exceed its magnitude.  The sign is the same
813 as the sign of @var{X}. 
814
815 @item @emph{Example}:
816 @smallexample
817 program test_aint
818   real(4) x4
819   real(8) x8
820   x4 = 1.234E0_4
821   x8 = 4.321_8
822   print *, aint(x4), dint(x8)
823   x8 = aint(x4,8)
824 end program test_aint
825 @end smallexample
826
827 @item @emph{Specific names}:
828 @multitable @columnfractions .20 .20 .20 .25
829 @item Name           @tab Argument         @tab Return type      @tab Standard
830 @item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)}   @tab Fortran 77 and later
831 @item @code{DINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)}   @tab Fortran 77 and later
832 @end multitable
833 @end table
834
835
836
837 @node ALARM
838 @section @code{ALARM} --- Execute a routine after a given delay
839 @fnindex ALARM
840 @cindex delayed execution
841
842 @table @asis
843 @item @emph{Description}:
844 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
845 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
846 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
847 supplied, it will be returned with the number of seconds remaining until
848 any previously scheduled alarm was due to be delivered, or zero if there
849 was no previously scheduled alarm.
850
851 @item @emph{Standard}:
852 GNU extension
853
854 @item @emph{Class}:
855 Subroutine
856
857 @item @emph{Syntax}:
858 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
859
860 @item @emph{Arguments}:
861 @multitable @columnfractions .15 .70
862 @item @var{SECONDS} @tab The type of the argument shall be a scalar
863 @code{INTEGER}. It is @code{INTENT(IN)}.
864 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
865 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar 
866 values may be either @code{SIG_IGN=1} to ignore the alarm generated 
867 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
868 @item @var{STATUS}  @tab (Optional) @var{STATUS} shall be a scalar
869 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
870 @end multitable
871
872 @item @emph{Example}:
873 @smallexample
874 program test_alarm
875   external handler_print
876   integer i
877   call alarm (3, handler_print, i)
878   print *, i
879   call sleep(10)
880 end program test_alarm
881 @end smallexample
882 This will cause the external routine @var{handler_print} to be called
883 after 3 seconds.
884 @end table
885
886
887
888 @node ALL
889 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true 
890 @fnindex ALL
891 @cindex array, apply condition
892 @cindex array, condition testing
893
894 @table @asis
895 @item @emph{Description}:
896 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
897 in the array along dimension @var{DIM}.
898
899 @item @emph{Standard}:
900 Fortran 95 and later
901
902 @item @emph{Class}:
903 Transformational function
904
905 @item @emph{Syntax}:
906 @code{RESULT = ALL(MASK [, DIM])}
907
908 @item @emph{Arguments}:
909 @multitable @columnfractions .15 .70
910 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
911 it shall not be scalar.
912 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
913 with a value that lies between one and the rank of @var{MASK}.
914 @end multitable
915
916 @item @emph{Return value}:
917 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where
918 the kind type parameter is the same as the kind type parameter of
919 @var{MASK}.  If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
920 an array with the rank of @var{MASK} minus 1.  The shape is determined from
921 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
922
923 @table @asis
924 @item (A)
925 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
926 It also is true if @var{MASK} has zero size; otherwise, it is false.
927 @item (B)
928 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
929 to @code{ALL(MASK)}.  If the rank is greater than one, then @code{ALL(MASK,DIM)}
930 is determined by applying @code{ALL} to the array sections.
931 @end table
932
933 @item @emph{Example}:
934 @smallexample
935 program test_all
936   logical l
937   l = all((/.true., .true., .true./))
938   print *, l
939   call section
940   contains
941     subroutine section
942       integer a(2,3), b(2,3)
943       a = 1
944       b = 1
945       b(2,2) = 2
946       print *, all(a .eq. b, 1)
947       print *, all(a .eq. b, 2)
948     end subroutine section
949 end program test_all
950 @end smallexample
951 @end table
952
953
954
955 @node ALLOCATED
956 @section @code{ALLOCATED} --- Status of an allocatable entity
957 @fnindex ALLOCATED
958 @cindex allocation, status
959
960 @table @asis
961 @item @emph{Description}:
962 @code{ALLOCATED(ARRAY)} and @code{ALLOCATED(SCALAR)} check the allocation
963 status of @var{ARRAY} and @var{SCALAR}, respectively.
964
965 @item @emph{Standard}:
966 Fortran 95 and later.  Note, the @code{SCALAR=} keyword and allocatable
967 scalar entities are available in Fortran 2003 and later.
968
969 @item @emph{Class}:
970 Inquiry function
971
972 @item @emph{Syntax}:
973 @code{RESULT = ALLOCATED(ARRAY)} or @code{RESULT = ALLOCATED(SCALAR)} 
974
975 @item @emph{Arguments}:
976 @multitable @columnfractions .15 .70
977 @item @var{ARRAY}    @tab The argument shall be an @code{ALLOCATABLE} array.
978 @item @var{SCALAR}   @tab The argument shall be an @code{ALLOCATABLE} scalar.
979 @end multitable
980
981 @item @emph{Return value}:
982 The return value is a scalar @code{LOGICAL} with the default logical
983 kind type parameter.  If the argument is allocated, then the result is
984 @code{.TRUE.}; otherwise, it returns @code{.FALSE.} 
985
986 @item @emph{Example}:
987 @smallexample
988 program test_allocated
989   integer :: i = 4
990   real(4), allocatable :: x(:)
991   if (.not. allocated(x)) allocate(x(i))
992 end program test_allocated
993 @end smallexample
994 @end table
995
996
997
998 @node AND
999 @section @code{AND} --- Bitwise logical AND
1000 @fnindex AND
1001 @cindex bitwise logical and
1002 @cindex logical and, bitwise
1003
1004 @table @asis
1005 @item @emph{Description}:
1006 Bitwise logical @code{AND}.
1007
1008 This intrinsic routine is provided for backwards compatibility with 
1009 GNU Fortran 77.  For integer arguments, programmers should consider
1010 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
1011
1012 @item @emph{Standard}:
1013 GNU extension
1014
1015 @item @emph{Class}:
1016 Function
1017
1018 @item @emph{Syntax}:
1019 @code{RESULT = AND(I, J)}
1020
1021 @item @emph{Arguments}:
1022 @multitable @columnfractions .15 .70
1023 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
1024 type or a scalar @code{LOGICAL} type.
1025 @item @var{J} @tab The type shall be the same as the type of @var{I}.
1026 @end multitable
1027
1028 @item @emph{Return value}:
1029 The return type is either a scalar @code{INTEGER} or a scalar
1030 @code{LOGICAL}.  If the kind type parameters differ, then the
1031 smaller kind type is implicitly converted to larger kind, and the 
1032 return has the larger kind.
1033
1034 @item @emph{Example}:
1035 @smallexample
1036 PROGRAM test_and
1037   LOGICAL :: T = .TRUE., F = .FALSE.
1038   INTEGER :: a, b
1039   DATA a / Z'F' /, b / Z'3' /
1040
1041   WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1042   WRITE (*,*) AND(a, b)
1043 END PROGRAM
1044 @end smallexample
1045
1046 @item @emph{See also}:
1047 Fortran 95 elemental function: @ref{IAND}
1048 @end table
1049
1050
1051
1052 @node ANINT
1053 @section @code{ANINT} --- Nearest whole number
1054 @fnindex ANINT
1055 @fnindex DNINT
1056 @cindex ceiling
1057 @cindex rounding, ceiling
1058
1059 @table @asis
1060 @item @emph{Description}:
1061 @code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1062
1063 @item @emph{Standard}:
1064 Fortran 77 and later
1065
1066 @item @emph{Class}:
1067 Elemental function
1068
1069 @item @emph{Syntax}:
1070 @code{RESULT = ANINT(A [, KIND])}
1071
1072 @item @emph{Arguments}:
1073 @multitable @columnfractions .15 .70
1074 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
1075 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
1076 expression indicating the kind parameter of the result.
1077 @end multitable
1078
1079 @item @emph{Return value}:
1080 The return value is of type real with the kind type parameter of the
1081 argument if the optional @var{KIND} is absent; otherwise, the kind
1082 type parameter will be given by @var{KIND}.  If @var{A} is greater than
1083 zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}.  If @var{A} is
1084 less than or equal to zero then it returns @code{AINT(X-0.5)}.
1085
1086 @item @emph{Example}:
1087 @smallexample
1088 program test_anint
1089   real(4) x4
1090   real(8) x8
1091   x4 = 1.234E0_4
1092   x8 = 4.321_8
1093   print *, anint(x4), dnint(x8)
1094   x8 = anint(x4,8)
1095 end program test_anint
1096 @end smallexample
1097
1098 @item @emph{Specific names}:
1099 @multitable @columnfractions .20 .20 .20 .25
1100 @item Name            @tab Argument         @tab Return type      @tab Standard
1101 @item @code{AINT(A)}  @tab @code{REAL(4) A} @tab @code{REAL(4)}   @tab Fortran 77 and later
1102 @item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)}   @tab Fortran 77 and later
1103 @end multitable
1104 @end table
1105
1106
1107
1108 @node ANY
1109 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true 
1110 @fnindex ANY
1111 @cindex array, apply condition
1112 @cindex array, condition testing
1113
1114 @table @asis
1115 @item @emph{Description}:
1116 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1117 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1118
1119 @item @emph{Standard}:
1120 Fortran 95 and later
1121
1122 @item @emph{Class}:
1123 Transformational function
1124
1125 @item @emph{Syntax}:
1126 @code{RESULT = ANY(MASK [, DIM])}
1127
1128 @item @emph{Arguments}:
1129 @multitable @columnfractions .15 .70
1130 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1131 it shall not be scalar.
1132 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
1133 with a value that lies between one and the rank of @var{MASK}.
1134 @end multitable
1135
1136 @item @emph{Return value}:
1137 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1138 the kind type parameter is the same as the kind type parameter of
1139 @var{MASK}.  If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1140 an array with the rank of @var{MASK} minus 1.  The shape is determined from
1141 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
1142
1143 @table @asis
1144 @item (A)
1145 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1146 otherwise, it is false.  It also is false if @var{MASK} has zero size.
1147 @item (B)
1148 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1149 to @code{ANY(MASK)}.  If the rank is greater than one, then @code{ANY(MASK,DIM)}
1150 is determined by applying @code{ANY} to the array sections.
1151 @end table
1152
1153 @item @emph{Example}:
1154 @smallexample
1155 program test_any
1156   logical l
1157   l = any((/.true., .true., .true./))
1158   print *, l
1159   call section
1160   contains
1161     subroutine section
1162       integer a(2,3), b(2,3)
1163       a = 1
1164       b = 1
1165       b(2,2) = 2
1166       print *, any(a .eq. b, 1)
1167       print *, any(a .eq. b, 2)
1168     end subroutine section
1169 end program test_any
1170 @end smallexample
1171 @end table
1172
1173
1174
1175 @node ASIN
1176 @section @code{ASIN} --- Arcsine function 
1177 @fnindex ASIN
1178 @fnindex DASIN
1179 @cindex trigonometric function, sine, inverse
1180 @cindex sine, inverse
1181
1182 @table @asis
1183 @item @emph{Description}:
1184 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1185
1186 @item @emph{Standard}:
1187 Fortran 77 and later, for a complex argument Fortran 2008 or later
1188
1189 @item @emph{Class}:
1190 Elemental function
1191
1192 @item @emph{Syntax}:
1193 @code{RESULT = ASIN(X)}
1194
1195 @item @emph{Arguments}:
1196 @multitable @columnfractions .15 .70
1197 @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1198 less than or equal to one - or be @code{COMPLEX}.
1199 @end multitable
1200
1201 @item @emph{Return value}:
1202 The return value is of the same type and kind as @var{X}.
1203 The real part of the result is in radians and lies in the range
1204 @math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}.
1205
1206 @item @emph{Example}:
1207 @smallexample
1208 program test_asin
1209   real(8) :: x = 0.866_8
1210   x = asin(x)
1211 end program test_asin
1212 @end smallexample
1213
1214 @item @emph{Specific names}:
1215 @multitable @columnfractions .20 .20 .20 .25
1216 @item Name            @tab Argument          @tab Return type       @tab Standard
1217 @item @code{ASIN(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
1218 @item @code{DASIN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1219 @end multitable
1220
1221 @item @emph{See also}:
1222 Inverse function: @ref{SIN}
1223
1224 @end table
1225
1226
1227
1228 @node ASINH
1229 @section @code{ASINH} --- Inverse hyperbolic sine function
1230 @fnindex ASINH
1231 @fnindex DASINH
1232 @cindex area hyperbolic sine
1233 @cindex inverse hyperbolic sine
1234 @cindex hyperbolic function, sine, inverse
1235 @cindex sine, hyperbolic, inverse
1236
1237 @table @asis
1238 @item @emph{Description}:
1239 @code{ASINH(X)} computes the inverse hyperbolic sine of @var{X}.
1240
1241 @item @emph{Standard}:
1242 Fortran 2008 and later
1243
1244 @item @emph{Class}:
1245 Elemental function
1246
1247 @item @emph{Syntax}:
1248 @code{RESULT = ASINH(X)}
1249
1250 @item @emph{Arguments}:
1251 @multitable @columnfractions .15 .70
1252 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1253 @end multitable
1254
1255 @item @emph{Return value}:
1256 The return value is of the same type and kind as  @var{X}. If @var{X} is
1257 complex, the imaginary part of the result is in radians and lies between
1258 @math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}.
1259
1260 @item @emph{Example}:
1261 @smallexample
1262 PROGRAM test_asinh
1263   REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1264   WRITE (*,*) ASINH(x)
1265 END PROGRAM
1266 @end smallexample
1267
1268 @item @emph{Specific names}:
1269 @multitable @columnfractions .20 .20 .20 .25
1270 @item Name             @tab Argument          @tab Return type       @tab Standard
1271 @item @code{DASINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension.
1272 @end multitable
1273
1274 @item @emph{See also}:
1275 Inverse function: @ref{SINH}
1276 @end table
1277
1278
1279
1280 @node ASSOCIATED
1281 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair 
1282 @fnindex ASSOCIATED
1283 @cindex pointer, status
1284 @cindex association status
1285
1286 @table @asis
1287 @item @emph{Description}:
1288 @code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1289 @var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
1290
1291 @item @emph{Standard}:
1292 Fortran 95 and later
1293
1294 @item @emph{Class}:
1295 Inquiry function
1296
1297 @item @emph{Syntax}:
1298 @code{RESULT = ASSOCIATED(POINTER [, TARGET])}
1299
1300 @item @emph{Arguments}:
1301 @multitable @columnfractions .15 .70
1302 @item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1303 and it can be of any type.
1304 @item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1305 a target.  It must have the same type, kind type parameter, and
1306 array rank as @var{POINTER}.
1307 @end multitable
1308 The association status of neither @var{POINTER} nor @var{TARGET} shall be
1309 undefined.
1310
1311 @item @emph{Return value}:
1312 @code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
1313 There are several cases:
1314 @table @asis
1315 @item (A) When the optional @var{TARGET} is not present then
1316 @code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1317 @item (B) If @var{TARGET} is present and a scalar target, the result is true if
1318 @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
1319 disassociated, the result is false.
1320 @item (C) If @var{TARGET} is present and an array target, the result is true if
1321 @var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1322 are arrays whose elements are not zero-sized storage sequences, and
1323 @var{TARGET} and @var{POINTER} occupy the same storage units in array element
1324 order.
1325 As in case(B), the result is false, if @var{POINTER} is disassociated.
1326 @item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1327 if @var{TARGET} is associated with @var{POINTER}, the target associated with
1328 @var{TARGET} are not zero-sized storage sequences and occupy the same storage
1329 units.
1330 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1331 @item (E) If @var{TARGET} is present and an array pointer, the result is true if
1332 target associated with @var{POINTER} and the target associated with @var{TARGET}
1333 have the same shape, are not zero-sized arrays, are arrays whose elements are
1334 not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1335 the same storage units in array element order.
1336 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1337 @end table
1338
1339 @item @emph{Example}:
1340 @smallexample
1341 program test_associated
1342    implicit none
1343    real, target  :: tgt(2) = (/1., 2./)
1344    real, pointer :: ptr(:)
1345    ptr => tgt
1346    if (associated(ptr)     .eqv. .false.) call abort
1347    if (associated(ptr,tgt) .eqv. .false.) call abort
1348 end program test_associated
1349 @end smallexample
1350
1351 @item @emph{See also}:
1352 @ref{NULL}
1353 @end table
1354
1355
1356
1357 @node ATAN
1358 @section @code{ATAN} --- Arctangent function 
1359 @fnindex ATAN
1360 @fnindex DATAN
1361 @cindex trigonometric function, tangent, inverse
1362 @cindex tangent, inverse
1363
1364 @table @asis
1365 @item @emph{Description}:
1366 @code{ATAN(X)} computes the arctangent of @var{X}.
1367
1368 @item @emph{Standard}:
1369 Fortran 77 and later, for a complex argument and for two arguments
1370 Fortran 2008 or later
1371
1372 @item @emph{Class}:
1373 Elemental function
1374
1375 @item @emph{Syntax}:
1376 @code{RESULT = ATAN(X)}
1377 @code{RESULT = ATAN(Y, X)}
1378
1379 @item @emph{Arguments}:
1380 @multitable @columnfractions .15 .70
1381 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1382 if @var{Y} is present, @var{X} shall be REAL.
1383 @item @var{Y} shall be of the same type and kind as @var{X}.
1384 @end multitable
1385
1386 @item @emph{Return value}:
1387 The return value is of the same type and kind as @var{X}.
1388 If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}.
1389 Otherwise, it the arcus tangent of @var{X}, where the real part of
1390 the result is in radians and lies in the range
1391 @math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}.
1392
1393 @item @emph{Example}:
1394 @smallexample
1395 program test_atan
1396   real(8) :: x = 2.866_8
1397   x = atan(x)
1398 end program test_atan
1399 @end smallexample
1400
1401 @item @emph{Specific names}:
1402 @multitable @columnfractions .20 .20 .20 .25
1403 @item Name            @tab Argument          @tab Return type       @tab Standard
1404 @item @code{ATAN(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
1405 @item @code{DATAN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1406 @end multitable
1407
1408 @item @emph{See also}:
1409 Inverse function: @ref{TAN}
1410
1411 @end table
1412
1413
1414
1415 @node ATAN2
1416 @section @code{ATAN2} --- Arctangent function 
1417 @fnindex ATAN2
1418 @fnindex DATAN2
1419 @cindex trigonometric function, tangent, inverse
1420 @cindex tangent, inverse
1421
1422 @table @asis
1423 @item @emph{Description}:
1424 @code{ATAN2(Y, X)} computes the principal value of the argument
1425 function of the complex number @math{X + i Y}. This function can
1426 be used to transform from carthesian into polar coordinates and
1427 allows to determine the angle in the correct quadrant.
1428
1429 @item @emph{Standard}:
1430 Fortran 77 and later
1431
1432 @item @emph{Class}:
1433 Elemental function
1434
1435 @item @emph{Syntax}:
1436 @code{RESULT = ATAN2(Y, X)}
1437
1438 @item @emph{Arguments}:
1439 @multitable @columnfractions .15 .70
1440 @item @var{Y} @tab The type shall be @code{REAL}.
1441 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1442 If @var{Y} is zero, then @var{X} must be nonzero.
1443 @end multitable
1444
1445 @item @emph{Return value}:
1446 The return value has the same type and kind type parameter as @var{Y}.
1447 It is the principal value of the complex number @math{X + i Y}.  If
1448 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1449 The sign is positive if @var{Y} is positive.  If @var{Y} is zero, then
1450 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1451 is negative.  Finally, if @var{X} is zero, then the magnitude of the result
1452 is @math{\pi/2}.
1453
1454 @item @emph{Example}:
1455 @smallexample
1456 program test_atan2
1457   real(4) :: x = 1.e0_4, y = 0.5e0_4
1458   x = atan2(y,x)
1459 end program test_atan2
1460 @end smallexample
1461
1462 @item @emph{Specific names}:
1463 @multitable @columnfractions .20 .20 .20 .25
1464 @item Name                @tab Argument            @tab Return type    @tab Standard
1465 @item @code{ATAN2(X, Y)}  @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
1466 @item @code{DATAN2(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
1467 @end multitable
1468 @end table
1469
1470
1471
1472 @node ATANH
1473 @section @code{ATANH} --- Inverse hyperbolic tangent function
1474 @fnindex ATANH
1475 @fnindex DATANH
1476 @cindex area hyperbolic tangent
1477 @cindex inverse hyperbolic tangent
1478 @cindex hyperbolic function, tangent, inverse
1479 @cindex tangent, hyperbolic, inverse
1480
1481 @table @asis
1482 @item @emph{Description}:
1483 @code{ATANH(X)} computes the inverse hyperbolic tangent of @var{X}.
1484
1485 @item @emph{Standard}:
1486 Fortran 2008 and later
1487
1488 @item @emph{Class}:
1489 Elemental function
1490
1491 @item @emph{Syntax}:
1492 @code{RESULT = ATANH(X)}
1493
1494 @item @emph{Arguments}:
1495 @multitable @columnfractions .15 .70
1496 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1497 @end multitable
1498
1499 @item @emph{Return value}:
1500 The return value has same type and kind as @var{X}. If @var{X} is
1501 complex, the imaginary part of the result is in radians and lies between
1502 @math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}.
1503
1504 @item @emph{Example}:
1505 @smallexample
1506 PROGRAM test_atanh
1507   REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1508   WRITE (*,*) ATANH(x)
1509 END PROGRAM
1510 @end smallexample
1511
1512 @item @emph{Specific names}:
1513 @multitable @columnfractions .20 .20 .20 .25
1514 @item Name             @tab Argument          @tab Return type       @tab Standard
1515 @item @code{DATANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1516 @end multitable
1517
1518 @item @emph{See also}:
1519 Inverse function: @ref{TANH}
1520 @end table
1521
1522
1523
1524 @node BESSEL_J0
1525 @section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
1526 @fnindex BESSEL_J0
1527 @fnindex BESJ0
1528 @fnindex DBESJ0
1529 @cindex Bessel function, first kind
1530
1531 @table @asis
1532 @item @emph{Description}:
1533 @code{BESSEL_J0(X)} computes the Bessel function of the first kind of
1534 order 0 of @var{X}. This function is available under the name
1535 @code{BESJ0} as a GNU extension.
1536
1537 @item @emph{Standard}:
1538 Fortran 2008 and later
1539
1540 @item @emph{Class}:
1541 Elemental function
1542
1543 @item @emph{Syntax}:
1544 @code{RESULT = BESSEL_J0(X)}
1545
1546 @item @emph{Arguments}:
1547 @multitable @columnfractions .15 .70
1548 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1549 @end multitable
1550
1551 @item @emph{Return value}:
1552 The return value is of type @code{REAL} and lies in the
1553 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
1554 kind as @var{X}.
1555
1556 @item @emph{Example}:
1557 @smallexample
1558 program test_besj0
1559   real(8) :: x = 0.0_8
1560   x = bessel_j0(x)
1561 end program test_besj0
1562 @end smallexample
1563
1564 @item @emph{Specific names}:
1565 @multitable @columnfractions .20 .20 .20 .25
1566 @item Name            @tab Argument          @tab Return type       @tab Standard
1567 @item @code{DBESJ0(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}   @tab GNU extension
1568 @end multitable
1569 @end table
1570
1571
1572
1573 @node BESSEL_J1
1574 @section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
1575 @fnindex BESSEL_J1
1576 @fnindex BESJ1
1577 @fnindex DBESJ1
1578 @cindex Bessel function, first kind
1579
1580 @table @asis
1581 @item @emph{Description}:
1582 @code{BESSEL_J1(X)} computes the Bessel function of the first kind of
1583 order 1 of @var{X}. This function is available under the name
1584 @code{BESJ1} as a GNU extension.
1585
1586 @item @emph{Standard}:
1587 Fortran 2008
1588
1589 @item @emph{Class}:
1590 Elemental function
1591
1592 @item @emph{Syntax}:
1593 @code{RESULT = BESSEL_J1(X)}
1594
1595 @item @emph{Arguments}:
1596 @multitable @columnfractions .15 .70
1597 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1598 @end multitable
1599
1600 @item @emph{Return value}:
1601 The return value is of type @code{REAL} and it lies in the
1602 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
1603 kind as @var{X}.
1604
1605 @item @emph{Example}:
1606 @smallexample
1607 program test_besj1
1608   real(8) :: x = 1.0_8
1609   x = bessel_j1(x)
1610 end program test_besj1
1611 @end smallexample
1612
1613 @item @emph{Specific names}:
1614 @multitable @columnfractions .20 .20 .20 .25
1615 @item Name             @tab Argument          @tab Return type       @tab Standard
1616 @item @code{DBESJ1(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1617 @end multitable
1618 @end table
1619
1620
1621
1622 @node BESSEL_JN
1623 @section @code{BESSEL_JN} --- Bessel function of the first kind
1624 @fnindex BESSEL_JN
1625 @fnindex BESJN
1626 @fnindex DBESJN
1627 @cindex Bessel function, first kind
1628
1629 @table @asis
1630 @item @emph{Description}:
1631 @code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
1632 order @var{N} of @var{X}. This function is available under the name
1633 @code{BESJN} as a GNU extension.  If @var{N} and @var{X} are arrays,
1634 their ranks and shapes shall conform.  
1635
1636 @code{BESSEL_JN(N1, N2, X)} returns an array with the Bessel functions
1637 of the first kind of the orders @var{N1} to @var{N2}.
1638
1639 @item @emph{Standard}:
1640 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
1641
1642 @item @emph{Class}:
1643 Elemental function, except for the tranformational function
1644 @code{BESSEL_JN(N1, N2, X)}
1645
1646 @item @emph{Syntax}:
1647 @code{RESULT = BESSEL_JN(N, X)}
1648 @code{RESULT = BESSEL_JN(N1, N2, X)}
1649
1650 @item @emph{Arguments}:
1651 @multitable @columnfractions .15 .70
1652 @item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER}.
1653 @item @var{N1} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
1654 @item @var{N2} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
1655 @item @var{X} @tab Shall be a scalar or an array of type  @code{REAL};
1656 for @code{BESSEL_JN(N1, N2, X)} it shall be scalar.
1657 @end multitable
1658
1659 @item @emph{Return value}:
1660 The return value is a scalar of type @code{REAL}. It has the same
1661 kind as @var{X}.
1662
1663 @item @emph{Note}:
1664 The transformational function uses a recurrance algorithm which might,
1665 for some values of @var{X}, lead to different results than calls to
1666 the elemental function.
1667
1668 @item @emph{Example}:
1669 @smallexample
1670 program test_besjn
1671   real(8) :: x = 1.0_8
1672   x = bessel_jn(5,x)
1673 end program test_besjn
1674 @end smallexample
1675
1676 @item @emph{Specific names}:
1677 @multitable @columnfractions .20 .20 .20 .25
1678 @item Name                @tab Argument            @tab Return type       @tab Standard
1679 @item @code{DBESJN(N, X)} @tab @code{INTEGER N}    @tab @code{REAL(8)}    @tab GNU extension
1680 @item                     @tab @code{REAL(8) X}    @tab                   @tab
1681 @end multitable
1682 @end table
1683
1684
1685
1686 @node BESSEL_Y0
1687 @section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
1688 @fnindex BESSEL_Y0
1689 @fnindex BESY0
1690 @fnindex DBESY0
1691 @cindex Bessel function, second kind
1692
1693 @table @asis
1694 @item @emph{Description}:
1695 @code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
1696 order 0 of @var{X}. This function is available under the name
1697 @code{BESY0} as a GNU extension.
1698
1699 @item @emph{Standard}:
1700 Fortran 2008 and later
1701
1702 @item @emph{Class}:
1703 Elemental function
1704
1705 @item @emph{Syntax}:
1706 @code{RESULT = BESSEL_Y0(X)}
1707
1708 @item @emph{Arguments}:
1709 @multitable @columnfractions .15 .70
1710 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1711 @end multitable
1712
1713 @item @emph{Return value}:
1714 The return value is a scalar of type @code{REAL}. It has the same
1715 kind as @var{X}.
1716
1717 @item @emph{Example}:
1718 @smallexample
1719 program test_besy0
1720   real(8) :: x = 0.0_8
1721   x = bessel_y0(x)
1722 end program test_besy0
1723 @end smallexample
1724
1725 @item @emph{Specific names}:
1726 @multitable @columnfractions .20 .20 .20 .25
1727 @item Name            @tab Argument          @tab Return type       @tab Standard
1728 @item @code{DBESY0(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1729 @end multitable
1730 @end table
1731
1732
1733
1734 @node BESSEL_Y1
1735 @section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
1736 @fnindex BESSEL_Y1
1737 @fnindex BESY1
1738 @fnindex DBESY1
1739 @cindex Bessel function, second kind
1740
1741 @table @asis
1742 @item @emph{Description}:
1743 @code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
1744 order 1 of @var{X}. This function is available under the name
1745 @code{BESY1} as a GNU extension.
1746
1747 @item @emph{Standard}:
1748 Fortran 2008 and later
1749
1750 @item @emph{Class}:
1751 Elemental function
1752
1753 @item @emph{Syntax}:
1754 @code{RESULT = BESSEL_Y1(X)}
1755
1756 @item @emph{Arguments}:
1757 @multitable @columnfractions .15 .70
1758 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1759 @end multitable
1760
1761 @item @emph{Return value}:
1762 The return value is a scalar of type @code{REAL}. It has the same
1763 kind as @var{X}.
1764
1765 @item @emph{Example}:
1766 @smallexample
1767 program test_besy1
1768   real(8) :: x = 1.0_8
1769   x = bessel_y1(x)
1770 end program test_besy1
1771 @end smallexample
1772
1773 @item @emph{Specific names}:
1774 @multitable @columnfractions .20 .20 .20 .25
1775 @item Name            @tab Argument          @tab Return type       @tab Standard
1776 @item @code{DBESY1(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1777 @end multitable
1778 @end table
1779
1780
1781
1782 @node BESSEL_YN
1783 @section @code{BESSEL_YN} --- Bessel function of the second kind
1784 @fnindex BESSEL_YN
1785 @fnindex BESYN
1786 @fnindex DBESYN
1787 @cindex Bessel function, second kind
1788
1789 @table @asis
1790 @item @emph{Description}:
1791 @code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
1792 order @var{N} of @var{X}. This function is available under the name
1793 @code{BESYN} as a GNU extension.  If @var{N} and @var{X} are arrays,
1794 their ranks and shapes shall conform.  
1795
1796 @code{BESSEL_YN(N1, N2, X)} returns an array with the Bessel functions
1797 of the first kind of the orders @var{N1} to @var{N2}.
1798
1799 @item @emph{Standard}:
1800 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
1801
1802 @item @emph{Class}:
1803 Elemental function, except for the tranformational function
1804 @code{BESSEL_YN(N1, N2, X)}
1805
1806 @item @emph{Syntax}:
1807 @code{RESULT = BESSEL_YN(N, X)}
1808 @code{RESULT = BESSEL_YN(N1, N2, X)}
1809
1810 @item @emph{Arguments}:
1811 @multitable @columnfractions .15 .70
1812 @item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER} .
1813 @item @var{N1} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
1814 @item @var{N2} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
1815 @item @var{X} @tab Shall be a scalar or an array of type  @code{REAL};
1816 for @code{BESSEL_YN(N1, N2, X)} it shall be scalar.
1817 @end multitable
1818
1819 @item @emph{Return value}:
1820 The return value is a scalar of type @code{REAL}. It has the same
1821 kind as @var{X}.
1822
1823 @item @emph{Note}:
1824 The transformational function uses a recurrance algorithm which might,
1825 for some values of @var{X}, lead to different results than calls to
1826 the elemental function.
1827
1828 @item @emph{Example}:
1829 @smallexample
1830 program test_besyn
1831   real(8) :: x = 1.0_8
1832   x = bessel_yn(5,x)
1833 end program test_besyn
1834 @end smallexample
1835
1836 @item @emph{Specific names}:
1837 @multitable @columnfractions .20 .20 .20 .25
1838 @item Name               @tab Argument            @tab Return type     @tab Standard
1839 @item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)}  @tab GNU extension
1840 @item                    @tab @code{REAL(8) X} @tab                 @tab 
1841 @end multitable
1842 @end table
1843
1844
1845
1846 @node BIT_SIZE
1847 @section @code{BIT_SIZE} --- Bit size inquiry function
1848 @fnindex BIT_SIZE
1849 @cindex bits, number of
1850 @cindex size of a variable, in bits
1851
1852 @table @asis
1853 @item @emph{Description}:
1854 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1855 represented by the type of @var{I}.  The result of @code{BIT_SIZE(I)} is
1856 independent of the actual value of @var{I}.
1857
1858 @item @emph{Standard}:
1859 Fortran 95 and later
1860
1861 @item @emph{Class}:
1862 Inquiry function
1863
1864 @item @emph{Syntax}:
1865 @code{RESULT = BIT_SIZE(I)}
1866
1867 @item @emph{Arguments}:
1868 @multitable @columnfractions .15 .70
1869 @item @var{I} @tab The type shall be @code{INTEGER}.
1870 @end multitable
1871
1872 @item @emph{Return value}:
1873 The return value is of type @code{INTEGER}
1874
1875 @item @emph{Example}:
1876 @smallexample
1877 program test_bit_size
1878     integer :: i = 123
1879     integer :: size
1880     size = bit_size(i)
1881     print *, size
1882 end program test_bit_size
1883 @end smallexample
1884 @end table
1885
1886
1887
1888 @node BTEST
1889 @section @code{BTEST} --- Bit test function
1890 @fnindex BTEST
1891 @cindex bits, testing
1892
1893 @table @asis
1894 @item @emph{Description}:
1895 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1896 in @var{I} is set.  The counting of the bits starts at 0.
1897
1898 @item @emph{Standard}:
1899 Fortran 95 and later
1900
1901 @item @emph{Class}:
1902 Elemental function
1903
1904 @item @emph{Syntax}:
1905 @code{RESULT = BTEST(I, POS)}
1906
1907 @item @emph{Arguments}:
1908 @multitable @columnfractions .15 .70
1909 @item @var{I} @tab The type shall be @code{INTEGER}.
1910 @item @var{POS} @tab The type shall be @code{INTEGER}.
1911 @end multitable
1912
1913 @item @emph{Return value}:
1914 The return value is of type @code{LOGICAL}
1915
1916 @item @emph{Example}:
1917 @smallexample
1918 program test_btest
1919     integer :: i = 32768 + 1024 + 64
1920     integer :: pos
1921     logical :: bool
1922     do pos=0,16
1923         bool = btest(i, pos) 
1924         print *, pos, bool
1925     end do
1926 end program test_btest
1927 @end smallexample
1928 @end table
1929
1930
1931 @node C_ASSOCIATED
1932 @section @code{C_ASSOCIATED} --- Status of a C pointer
1933 @fnindex C_ASSOCIATED
1934 @cindex association status, C pointer
1935 @cindex pointer, C association status
1936
1937 @table @asis
1938 @item @emph{Description}:
1939 @code{C_ASSOCIATED(c_prt_1[, c_ptr_2])} determines the status of the C pointer
1940 @var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
1941
1942 @item @emph{Standard}:
1943 Fortran 2003 and later
1944
1945 @item @emph{Class}:
1946 Inquiry function
1947
1948 @item @emph{Syntax}:
1949 @code{RESULT = C_ASSOCIATED(c_prt_1[, c_ptr_2])}
1950
1951 @item @emph{Arguments}:
1952 @multitable @columnfractions .15 .70
1953 @item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
1954 @item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
1955 @end multitable
1956
1957 @item @emph{Return value}:
1958 The return value is of type @code{LOGICAL}; it is @code{.false.} if either
1959 @var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
1960 point to different addresses.
1961
1962 @item @emph{Example}:
1963 @smallexample
1964 subroutine association_test(a,b)
1965   use iso_c_binding, only: c_associated, c_loc, c_ptr
1966   implicit none
1967   real, pointer :: a
1968   type(c_ptr) :: b
1969   if(c_associated(b, c_loc(a))) &
1970      stop 'b and a do not point to same target'
1971 end subroutine association_test
1972 @end smallexample
1973
1974 @item @emph{See also}:
1975 @ref{C_LOC}, @ref{C_FUNLOC}
1976 @end table
1977
1978
1979 @node C_FUNLOC
1980 @section @code{C_FUNLOC} --- Obtain the C address of a procedure
1981 @fnindex C_FUNLOC
1982 @cindex pointer, C address of procedures
1983
1984 @table @asis
1985 @item @emph{Description}:
1986 @code{C_FUNLOC(x)} determines the C address of the argument.
1987
1988 @item @emph{Standard}:
1989 Fortran 2003 and later
1990
1991 @item @emph{Class}:
1992 Inquiry function
1993
1994 @item @emph{Syntax}:
1995 @code{RESULT = C_FUNLOC(x)}
1996
1997 @item @emph{Arguments}:
1998 @multitable @columnfractions .15 .70
1999 @item @var{x} @tab Interoperable function or pointer to such function.
2000 @end multitable
2001
2002 @item @emph{Return value}:
2003 The return value is of type @code{C_FUNPTR} and contains the C address
2004 of the argument.
2005
2006 @item @emph{Example}:
2007 @smallexample
2008 module x
2009   use iso_c_binding
2010   implicit none
2011 contains
2012   subroutine sub(a) bind(c)
2013     real(c_float) :: a
2014     a = sqrt(a)+5.0
2015   end subroutine sub
2016 end module x
2017 program main
2018   use iso_c_binding
2019   use x
2020   implicit none
2021   interface
2022     subroutine my_routine(p) bind(c,name='myC_func')
2023       import :: c_funptr
2024       type(c_funptr), intent(in) :: p
2025     end subroutine
2026   end interface
2027   call my_routine(c_funloc(sub))
2028 end program main
2029 @end smallexample
2030
2031 @item @emph{See also}:
2032 @ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2033 @end table
2034
2035
2036 @node C_F_PROCPOINTER
2037 @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
2038 @fnindex C_F_PROCPOINTER
2039 @cindex pointer, C address of pointers
2040
2041 @table @asis
2042 @item @emph{Description}:
2043 @code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
2044 @var{CPTR} to the Fortran procedure pointer @var{FPTR}.
2045
2046 @item @emph{Standard}:
2047 Fortran 2003 and later
2048
2049 @item @emph{Class}:
2050 Subroutine
2051
2052 @item @emph{Syntax}:
2053 @code{CALL C_F_PROCPOINTER(cptr, fptr)}
2054
2055 @item @emph{Arguments}:
2056 @multitable @columnfractions .15 .70
2057 @item @var{CPTR}  @tab scalar of the type @code{C_FUNPTR}. It is
2058 @code{INTENT(IN)}.
2059 @item @var{FPTR}  @tab procedure pointer interoperable with @var{cptr}. It is
2060 @code{INTENT(OUT)}.
2061 @end multitable
2062
2063 @item @emph{Example}:
2064 @smallexample
2065 program main
2066   use iso_c_binding
2067   implicit none
2068   abstract interface
2069     function func(a)
2070       import :: c_float
2071       real(c_float), intent(in) :: a
2072       real(c_float) :: func
2073     end function
2074   end interface
2075   interface
2076      function getIterFunc() bind(c,name="getIterFunc")
2077        import :: c_funptr
2078        type(c_funptr) :: getIterFunc
2079      end function
2080   end interface
2081   type(c_funptr) :: cfunptr
2082   procedure(func), pointer :: myFunc
2083   cfunptr = getIterFunc()
2084   call c_f_procpointer(cfunptr, myFunc)
2085 end program main
2086 @end smallexample
2087
2088 @item @emph{See also}:
2089 @ref{C_LOC}, @ref{C_F_POINTER}
2090 @end table
2091
2092
2093 @node C_F_POINTER
2094 @section @code{C_F_POINTER} --- Convert C into Fortran pointer
2095 @fnindex C_F_POINTER
2096 @cindex pointer, convert C to Fortran
2097
2098 @table @asis
2099 @item @emph{Description}:
2100 @code{C_F_POINTER(CPTR, FPTR[, SHAPE])} Assign the target the C pointer
2101 @var{CPTR} to the Fortran pointer @var{FPTR} and specify its
2102 shape.
2103
2104 @item @emph{Standard}:
2105 Fortran 2003 and later
2106
2107 @item @emph{Class}:
2108 Subroutine
2109
2110 @item @emph{Syntax}:
2111 @code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
2112
2113 @item @emph{Arguments}:
2114 @multitable @columnfractions .15 .70
2115 @item @var{CPTR}  @tab scalar of the type @code{C_PTR}. It is
2116 @code{INTENT(IN)}.
2117 @item @var{FPTR}  @tab pointer interoperable with @var{cptr}. It is
2118 @code{INTENT(OUT)}.
2119 @item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
2120 with @code{INTENT(IN)}. It shall be present
2121 if and only if @var{fptr} is an array. The size
2122 must be equal to the rank of @var{fptr}.
2123 @end multitable
2124
2125 @item @emph{Example}:
2126 @smallexample
2127 program main
2128   use iso_c_binding
2129   implicit none
2130   interface
2131     subroutine my_routine(p) bind(c,name='myC_func')
2132       import :: c_ptr
2133       type(c_ptr), intent(out) :: p
2134     end subroutine
2135   end interface
2136   type(c_ptr) :: cptr
2137   real,pointer :: a(:)
2138   call my_routine(cptr)
2139   call c_f_pointer(cptr, a, [12])
2140 end program main
2141 @end smallexample
2142
2143 @item @emph{See also}:
2144 @ref{C_LOC}, @ref{C_F_PROCPOINTER}
2145 @end table
2146
2147
2148 @node C_LOC
2149 @section @code{C_LOC} --- Obtain the C address of an object
2150 @fnindex C_LOC
2151 @cindex procedure pointer, convert C to Fortran
2152
2153 @table @asis
2154 @item @emph{Description}:
2155 @code{C_LOC(X)} determines the C address of the argument.
2156
2157 @item @emph{Standard}:
2158 Fortran 2003 and later
2159
2160 @item @emph{Class}:
2161 Inquiry function
2162
2163 @item @emph{Syntax}:
2164 @code{RESULT = C_LOC(X)}
2165
2166 @item @emph{Arguments}:
2167 @multitable @columnfractions .10 .75
2168 @item @var{X} @tab  Shall have either the POINTER or TARGET attribute. It shall not be a coindexed object. It shall either be a variable with interoperable type and kind type parameters, or be a scalar, nonpolymorphic variable with no length type parameters.
2169
2170 @end multitable
2171
2172 @item @emph{Return value}:
2173 The return value is of type @code{C_PTR} and contains the C address
2174 of the argument.
2175
2176 @item @emph{Example}:
2177 @smallexample
2178 subroutine association_test(a,b)
2179   use iso_c_binding, only: c_associated, c_loc, c_ptr
2180   implicit none
2181   real, pointer :: a
2182   type(c_ptr) :: b
2183   if(c_associated(b, c_loc(a))) &
2184      stop 'b and a do not point to same target'
2185 end subroutine association_test
2186 @end smallexample
2187
2188 @item @emph{See also}:
2189 @ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2190 @end table
2191
2192
2193 @node C_SIZEOF
2194 @section @code{C_SIZEOF} --- Size in bytes of an expression
2195 @fnindex C_SIZEOF
2196 @cindex expression size
2197 @cindex size of an expression
2198
2199 @table @asis
2200 @item @emph{Description}:
2201 @code{C_SIZEOF(X)} calculates the number of bytes of storage the
2202 expression @code{X} occupies.
2203
2204 @item @emph{Standard}:
2205 Fortran 2008
2206
2207 @item @emph{Class}:
2208 Intrinsic function
2209
2210 @item @emph{Syntax}:
2211 @code{N = C_SIZEOF(X)}
2212
2213 @item @emph{Arguments}:
2214 @multitable @columnfractions .15 .70
2215 @item @var{X} @tab The argument shall be an interoperable data entity.
2216 @end multitable
2217
2218 @item @emph{Return value}:
2219 The return value is of type integer and of the system-dependent kind
2220 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
2221 number of bytes occupied by the argument.  If the argument has the
2222 @code{POINTER} attribute, the number of bytes of the storage area pointed
2223 to is returned.  If the argument is of a derived type with @code{POINTER}
2224 or @code{ALLOCATABLE} components, the return value doesn't account for
2225 the sizes of the data pointed to by these components.
2226
2227 @item @emph{Example}:
2228 @smallexample
2229    use iso_c_binding
2230    integer(c_int) :: i
2231    real(c_float) :: r, s(5)
2232    print *, (c_sizeof(s)/c_sizeof(r) == 5)
2233    end
2234 @end smallexample
2235 The example will print @code{.TRUE.} unless you are using a platform
2236 where default @code{REAL} variables are unusually padded.
2237
2238 @item @emph{See also}:
2239 @ref{SIZEOF}, @ref{STORAGE_SIZE}
2240 @end table
2241
2242
2243 @node CEILING
2244 @section @code{CEILING} --- Integer ceiling function
2245 @fnindex CEILING
2246 @cindex ceiling
2247 @cindex rounding, ceiling
2248
2249 @table @asis
2250 @item @emph{Description}:
2251 @code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
2252
2253 @item @emph{Standard}:
2254 Fortran 95 and later
2255
2256 @item @emph{Class}:
2257 Elemental function
2258
2259 @item @emph{Syntax}:
2260 @code{RESULT = CEILING(A [, KIND])}
2261
2262 @item @emph{Arguments}:
2263 @multitable @columnfractions .15 .70
2264 @item @var{A} @tab The type shall be @code{REAL}.
2265 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2266 expression indicating the kind parameter of the result.
2267 @end multitable
2268
2269 @item @emph{Return value}:
2270 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
2271 and a default-kind @code{INTEGER} otherwise.
2272
2273 @item @emph{Example}:
2274 @smallexample
2275 program test_ceiling
2276     real :: x = 63.29
2277     real :: y = -63.59
2278     print *, ceiling(x) ! returns 64
2279     print *, ceiling(y) ! returns -63
2280 end program test_ceiling
2281 @end smallexample
2282
2283 @item @emph{See also}:
2284 @ref{FLOOR}, @ref{NINT}
2285
2286 @end table
2287
2288
2289
2290 @node CHAR
2291 @section @code{CHAR} --- Character conversion function
2292 @fnindex CHAR
2293 @cindex conversion, to character
2294
2295 @table @asis
2296 @item @emph{Description}:
2297 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
2298
2299 @item @emph{Standard}:
2300 Fortran 77 and later
2301
2302 @item @emph{Class}:
2303 Elemental function
2304
2305 @item @emph{Syntax}:
2306 @code{RESULT = CHAR(I [, KIND])}
2307
2308 @item @emph{Arguments}:
2309 @multitable @columnfractions .15 .70
2310 @item @var{I} @tab The type shall be @code{INTEGER}.
2311 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2312 expression indicating the kind parameter of the result.
2313 @end multitable
2314
2315 @item @emph{Return value}:
2316 The return value is of type @code{CHARACTER(1)}
2317
2318 @item @emph{Example}:
2319 @smallexample
2320 program test_char
2321     integer :: i = 74
2322     character(1) :: c
2323     c = char(i)
2324     print *, i, c ! returns 'J'
2325 end program test_char
2326 @end smallexample
2327
2328 @item @emph{Specific names}:
2329 @multitable @columnfractions .20 .20 .20 .25
2330 @item Name           @tab Argument         @tab Return type             @tab Standard
2331 @item @code{CHAR(I)} @tab @code{INTEGER I} @tab @code{CHARACTER(LEN=1)} @tab F77 and later
2332 @end multitable
2333
2334 @item @emph{Note}:
2335 See @ref{ICHAR} for a discussion of converting between numerical values
2336 and formatted string representations.
2337
2338 @item @emph{See also}:
2339 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
2340
2341 @end table
2342
2343
2344
2345 @node CHDIR
2346 @section @code{CHDIR} --- Change working directory
2347 @fnindex CHDIR
2348 @cindex system, working directory
2349
2350 @table @asis
2351 @item @emph{Description}:
2352 Change current working directory to a specified path.
2353
2354 This intrinsic is provided in both subroutine and function forms; however,
2355 only one form can be used in any given program unit.
2356
2357 @item @emph{Standard}:
2358 GNU extension
2359
2360 @item @emph{Class}:
2361 Subroutine, function
2362
2363 @item @emph{Syntax}:
2364 @multitable @columnfractions .80
2365 @item @code{CALL CHDIR(NAME [, STATUS])}
2366 @item @code{STATUS = CHDIR(NAME)}
2367 @end multitable
2368
2369 @item @emph{Arguments}:
2370 @multitable @columnfractions .15 .70
2371 @item @var{NAME}   @tab The type shall be @code{CHARACTER} of default
2372 kind and shall specify a valid path within the file system.
2373 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
2374 kind.  Returns 0 on success, and a system specific and nonzero error code
2375 otherwise.
2376 @end multitable
2377
2378 @item @emph{Example}:
2379 @smallexample
2380 PROGRAM test_chdir
2381   CHARACTER(len=255) :: path
2382   CALL getcwd(path)
2383   WRITE(*,*) TRIM(path)
2384   CALL chdir("/tmp")
2385   CALL getcwd(path)
2386   WRITE(*,*) TRIM(path)
2387 END PROGRAM
2388 @end smallexample
2389
2390 @item @emph{See also}:
2391 @ref{GETCWD}
2392 @end table
2393
2394
2395
2396 @node CHMOD
2397 @section @code{CHMOD} --- Change access permissions of files
2398 @fnindex CHMOD
2399 @cindex file system, change access mode
2400
2401 @table @asis
2402 @item @emph{Description}:
2403 @code{CHMOD} changes the permissions of a file. This function invokes
2404 @code{/bin/chmod} and might therefore not work on all platforms.
2405
2406 This intrinsic is provided in both subroutine and function forms; however,
2407 only one form can be used in any given program unit.
2408
2409 @item @emph{Standard}:
2410 GNU extension
2411
2412 @item @emph{Class}:
2413 Subroutine, function
2414
2415 @item @emph{Syntax}:
2416 @multitable @columnfractions .80
2417 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
2418 @item @code{STATUS = CHMOD(NAME, MODE)}
2419 @end multitable
2420
2421 @item @emph{Arguments}:
2422 @multitable @columnfractions .15 .70
2423
2424 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
2425 file name. Trailing blanks are ignored unless the character
2426 @code{achar(0)} is present, then all characters up to and excluding
2427 @code{achar(0)} are used as the file name.
2428
2429 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
2430 file permission. @var{MODE} uses the same syntax as the @var{MODE}
2431 argument of @code{/bin/chmod}.
2432
2433 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
2434 @code{0} on success and nonzero otherwise.
2435 @end multitable
2436
2437 @item @emph{Return value}:
2438 In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
2439 otherwise.
2440
2441 @item @emph{Example}:
2442 @code{CHMOD} as subroutine
2443 @smallexample
2444 program chmod_test
2445   implicit none
2446   integer :: status
2447   call chmod('test.dat','u+x',status)
2448   print *, 'Status: ', status
2449 end program chmod_test
2450 @end smallexample
2451 @code{CHMOD} as function:
2452 @smallexample
2453 program chmod_test
2454   implicit none
2455   integer :: status
2456   status = chmod('test.dat','u+x')
2457   print *, 'Status: ', status
2458 end program chmod_test
2459 @end smallexample
2460
2461 @end table
2462
2463
2464
2465 @node CMPLX
2466 @section @code{CMPLX} --- Complex conversion function
2467 @fnindex CMPLX
2468 @cindex complex numbers, conversion to
2469 @cindex conversion, to complex
2470
2471 @table @asis
2472 @item @emph{Description}:
2473 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
2474 the real component.  If @var{Y} is present it is converted to the imaginary
2475 component.  If @var{Y} is not present then the imaginary component is set to
2476 0.0.  If @var{X} is complex then @var{Y} must not be present.
2477
2478 @item @emph{Standard}:
2479 Fortran 77 and later
2480
2481 @item @emph{Class}:
2482 Elemental function
2483
2484 @item @emph{Syntax}:
2485 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2486
2487 @item @emph{Arguments}:
2488 @multitable @columnfractions .15 .70
2489 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
2490 or @code{COMPLEX}.
2491 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2492 @code{COMPLEX}.)  May be @code{INTEGER} or @code{REAL}.
2493 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2494 expression indicating the kind parameter of the result.
2495 @end multitable
2496
2497 @item @emph{Return value}:
2498 The return value is of @code{COMPLEX} type, with a kind equal to
2499 @var{KIND} if it is specified.  If @var{KIND} is not specified, the
2500 result is of the default @code{COMPLEX} kind, regardless of the kinds of
2501 @var{X} and @var{Y}. 
2502
2503 @item @emph{Example}:
2504 @smallexample
2505 program test_cmplx
2506     integer :: i = 42
2507     real :: x = 3.14
2508     complex :: z
2509     z = cmplx(i, x)
2510     print *, z, cmplx(x)
2511 end program test_cmplx
2512 @end smallexample
2513
2514 @item @emph{See also}:
2515 @ref{COMPLEX}
2516 @end table
2517
2518
2519
2520 @node COMMAND_ARGUMENT_COUNT
2521 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2522 @fnindex COMMAND_ARGUMENT_COUNT
2523 @cindex command-line arguments
2524 @cindex command-line arguments, number of
2525 @cindex arguments, to program
2526
2527 @table @asis
2528 @item @emph{Description}:
2529 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2530 command line when the containing program was invoked.
2531
2532 @item @emph{Standard}:
2533 Fortran 2003 and later
2534
2535 @item @emph{Class}:
2536 Inquiry function
2537
2538 @item @emph{Syntax}:
2539 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2540
2541 @item @emph{Arguments}:
2542 @multitable @columnfractions .15 .70
2543 @item None
2544 @end multitable
2545
2546 @item @emph{Return value}:
2547 The return value is an @code{INTEGER} of default kind.
2548
2549 @item @emph{Example}:
2550 @smallexample
2551 program test_command_argument_count
2552     integer :: count
2553     count = command_argument_count()
2554     print *, count
2555 end program test_command_argument_count
2556 @end smallexample
2557
2558 @item @emph{See also}:
2559 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2560 @end table
2561
2562
2563
2564 @node COMPLEX
2565 @section @code{COMPLEX} --- Complex conversion function
2566 @fnindex COMPLEX
2567 @cindex complex numbers, conversion to
2568 @cindex conversion, to complex
2569
2570 @table @asis
2571 @item @emph{Description}:
2572 @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
2573 to the real component and @var{Y} is converted to the imaginary
2574 component.
2575
2576 @item @emph{Standard}:
2577 GNU extension
2578
2579 @item @emph{Class}:
2580 Elemental function
2581
2582 @item @emph{Syntax}:
2583 @code{RESULT = COMPLEX(X, Y)}
2584
2585 @item @emph{Arguments}:
2586 @multitable @columnfractions .15 .70
2587 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
2588 @item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
2589 @end multitable
2590
2591 @item @emph{Return value}:
2592 If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
2593 value is of default @code{COMPLEX} type.
2594
2595 If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
2596 type and one is of @code{INTEGER} type, then the return value is of
2597 @code{COMPLEX} type with a kind equal to that of the @code{REAL}
2598 argument with the highest precision.  
2599
2600 @item @emph{Example}:
2601 @smallexample
2602 program test_complex
2603     integer :: i = 42
2604     real :: x = 3.14
2605     print *, complex(i, x)
2606 end program test_complex
2607 @end smallexample
2608
2609 @item @emph{See also}:
2610 @ref{CMPLX}
2611 @end table
2612
2613
2614
2615 @node CONJG
2616 @section @code{CONJG} --- Complex conjugate function 
2617 @fnindex CONJG
2618 @fnindex DCONJG
2619 @cindex complex conjugate
2620
2621 @table @asis
2622 @item @emph{Description}:
2623 @code{CONJG(Z)} returns the conjugate of @var{Z}.  If @var{Z} is @code{(x, y)}
2624 then the result is @code{(x, -y)}
2625
2626 @item @emph{Standard}:
2627 Fortran 77 and later, has overloads that are GNU extensions
2628
2629 @item @emph{Class}:
2630 Elemental function
2631
2632 @item @emph{Syntax}:
2633 @code{Z = CONJG(Z)}
2634
2635 @item @emph{Arguments}:
2636 @multitable @columnfractions .15 .70
2637 @item @var{Z} @tab The type shall be @code{COMPLEX}.
2638 @end multitable
2639
2640 @item @emph{Return value}:
2641 The return value is of type @code{COMPLEX}.
2642
2643 @item @emph{Example}:
2644 @smallexample
2645 program test_conjg
2646     complex :: z = (2.0, 3.0)
2647     complex(8) :: dz = (2.71_8, -3.14_8)
2648     z= conjg(z)
2649     print *, z
2650     dz = dconjg(dz)
2651     print *, dz
2652 end program test_conjg
2653 @end smallexample
2654
2655 @item @emph{Specific names}:
2656 @multitable @columnfractions .20 .20 .20 .25
2657 @item Name             @tab Argument             @tab Return type       @tab Standard
2658 @item @code{CONJG(Z)}  @tab @code{COMPLEX Z}     @tab @code{COMPLEX}    @tab GNU extension
2659 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z}  @tab @code{COMPLEX(8)} @tab GNU extension
2660 @end multitable
2661 @end table
2662
2663
2664
2665 @node COS
2666 @section @code{COS} --- Cosine function 
2667 @fnindex COS
2668 @fnindex DCOS
2669 @fnindex CCOS
2670 @fnindex ZCOS
2671 @fnindex CDCOS
2672 @cindex trigonometric function, cosine
2673 @cindex cosine
2674
2675 @table @asis
2676 @item @emph{Description}:
2677 @code{COS(X)} computes the cosine of @var{X}.
2678
2679 @item @emph{Standard}:
2680 Fortran 77 and later, has overloads that are GNU extensions
2681
2682 @item @emph{Class}:
2683 Elemental function
2684
2685 @item @emph{Syntax}:
2686 @code{RESULT = COS(X)}
2687
2688 @item @emph{Arguments}:
2689 @multitable @columnfractions .15 .70
2690 @item @var{X} @tab The type shall be @code{REAL} or
2691 @code{COMPLEX}.
2692 @end multitable
2693
2694 @item @emph{Return value}:
2695 The return value is of the same type and kind as @var{X}. The real part
2696 of the result is in radians. If @var{X} is of the type @code{REAL},
2697 the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}.
2698
2699 @item @emph{Example}:
2700 @smallexample
2701 program test_cos
2702   real :: x = 0.0
2703   x = cos(x)
2704 end program test_cos
2705 @end smallexample
2706
2707 @item @emph{Specific names}:
2708 @multitable @columnfractions .20 .20 .20 .25
2709 @item Name            @tab Argument            @tab Return type       @tab Standard
2710 @item @code{COS(X)}  n@tab @code{REAL(4) X}    @tab @code{REAL(4)}    @tab Fortran 77 and later
2711 @item @code{DCOS(X)}  @tab @code{REAL(8) X}    @tab @code{REAL(8)}    @tab Fortran 77 and later
2712 @item @code{CCOS(X)}  @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
2713 @item @code{ZCOS(X)}  @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2714 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2715 @end multitable
2716
2717 @item @emph{See also}:
2718 Inverse function: @ref{ACOS}
2719
2720 @end table
2721
2722
2723
2724 @node COSH
2725 @section @code{COSH} --- Hyperbolic cosine function 
2726 @fnindex COSH
2727 @fnindex DCOSH
2728 @cindex hyperbolic cosine
2729 @cindex hyperbolic function, cosine
2730 @cindex cosine, hyperbolic
2731
2732 @table @asis
2733 @item @emph{Description}:
2734 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2735
2736 @item @emph{Standard}:
2737 Fortran 77 and later, for a complex argument Fortran 2008 or later
2738
2739 @item @emph{Class}:
2740 Elemental function
2741
2742 @item @emph{Syntax}:
2743 @code{X = COSH(X)}
2744
2745 @item @emph{Arguments}:
2746 @multitable @columnfractions .15 .70
2747 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
2748 @end multitable
2749
2750 @item @emph{Return value}:
2751 The return value has same type and kind as @var{X}. If @var{X} is
2752 complex, the imaginary part of the result is in radians. If @var{X}
2753 is @code{REAL}, the return value has a lower bound of one,
2754 @math{\cosh (x) \geq 1}.
2755
2756 @item @emph{Example}:
2757 @smallexample
2758 program test_cosh
2759   real(8) :: x = 1.0_8
2760   x = cosh(x)
2761 end program test_cosh
2762 @end smallexample
2763
2764 @item @emph{Specific names}:
2765 @multitable @columnfractions .20 .20 .20 .25
2766 @item Name            @tab Argument          @tab Return type       @tab Standard
2767 @item @code{COSH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
2768 @item @code{DCOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
2769 @end multitable
2770
2771 @item @emph{See also}:
2772 Inverse function: @ref{ACOSH}
2773
2774 @end table
2775
2776
2777
2778 @node COUNT
2779 @section @code{COUNT} --- Count function
2780 @fnindex COUNT
2781 @cindex array, conditionally count elements
2782 @cindex array, element counting
2783 @cindex array, number of elements
2784
2785 @table @asis
2786 @item @emph{Description}:
2787
2788 Counts the number of @code{.TRUE.} elements in a logical @var{MASK},
2789 or, if the @var{DIM} argument is supplied, counts the number of
2790 elements along each row of the array in the @var{DIM} direction.
2791 If the array has zero size, or all of the elements of @var{MASK} are
2792 @code{.FALSE.}, then the result is @code{0}.
2793
2794 @item @emph{Standard}:
2795 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
2796
2797 @item @emph{Class}:
2798 Transformational function
2799
2800 @item @emph{Syntax}:
2801 @code{RESULT = COUNT(MASK [, DIM, KIND])}
2802
2803 @item @emph{Arguments}:
2804 @multitable @columnfractions .15 .70
2805 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2806 @item @var{DIM}  @tab (Optional) The type shall be @code{INTEGER}.
2807 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2808 expression indicating the kind parameter of the result.
2809 @end multitable
2810
2811 @item @emph{Return value}:
2812 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
2813 @var{KIND} is absent, the return value is of default integer kind.
2814 If @var{DIM} is present, the result is an array with a rank one less
2815 than the rank of @var{ARRAY}, and a size corresponding to the shape
2816 of @var{ARRAY} with the @var{DIM} dimension removed.
2817
2818 @item @emph{Example}:
2819 @smallexample
2820 program test_count
2821     integer, dimension(2,3) :: a, b
2822     logical, dimension(2,3) :: mask
2823     a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2824     b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2825     print '(3i3)', a(1,:)
2826     print '(3i3)', a(2,:)
2827     print *
2828     print '(3i3)', b(1,:)
2829     print '(3i3)', b(2,:)
2830     print *
2831     mask = a.ne.b
2832     print '(3l3)', mask(1,:)
2833     print '(3l3)', mask(2,:)
2834     print *
2835     print '(3i3)', count(mask)
2836     print *
2837     print '(3i3)', count(mask, 1)
2838     print *
2839     print '(3i3)', count(mask, 2)
2840 end program test_count
2841 @end smallexample
2842 @end table
2843
2844
2845
2846 @node CPU_TIME
2847 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2848 @fnindex CPU_TIME
2849 @cindex time, elapsed
2850
2851 @table @asis
2852 @item @emph{Description}:
2853 Returns a @code{REAL} value representing the elapsed CPU time in
2854 seconds.  This is useful for testing segments of code to determine
2855 execution time.
2856
2857 If a time source is available, time will be reported with microsecond
2858 resolution. If no time source is available, @var{TIME} is set to
2859 @code{-1.0}.
2860
2861 Note that @var{TIME} may contain a, system dependent, arbitrary offset
2862 and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
2863 value is meaningless, only differences between subsequent calls to
2864 this subroutine, as shown in the example below, should be used.
2865
2866
2867 @item @emph{Standard}:
2868 Fortran 95 and later
2869
2870 @item @emph{Class}:
2871 Subroutine
2872
2873 @item @emph{Syntax}:
2874 @code{CALL CPU_TIME(TIME)}
2875
2876 @item @emph{Arguments}:
2877 @multitable @columnfractions .15 .70
2878 @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2879 @end multitable
2880
2881 @item @emph{Return value}:
2882 None
2883
2884 @item @emph{Example}:
2885 @smallexample
2886 program test_cpu_time
2887     real :: start, finish
2888     call cpu_time(start)
2889         ! put code to test here
2890     call cpu_time(finish)
2891     print '("Time = ",f6.3," seconds.")',finish-start
2892 end program test_cpu_time
2893 @end smallexample
2894
2895 @item @emph{See also}:
2896 @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
2897 @end table
2898
2899
2900
2901 @node CSHIFT
2902 @section @code{CSHIFT} --- Circular shift elements of an array
2903 @fnindex CSHIFT
2904 @cindex array, shift circularly
2905 @cindex array, permutation
2906 @cindex array, rotate
2907
2908 @table @asis
2909 @item @emph{Description}:
2910 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2911 @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is omitted it is
2912 taken to be @code{1}.  @var{DIM} is a scalar of type @code{INTEGER} in the
2913 range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}.
2914 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2915 by @var{SHIFT} places.  If rank is greater than one, then all complete rank one
2916 sections of @var{ARRAY} along the given dimension are shifted.  Elements
2917 shifted out one end of each rank one section are shifted back in the other end.
2918
2919 @item @emph{Standard}:
2920 Fortran 95 and later
2921
2922 @item @emph{Class}:
2923 Transformational function
2924
2925 @item @emph{Syntax}:
2926 @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
2927
2928 @item @emph{Arguments}:
2929 @multitable @columnfractions .15 .70
2930 @item @var{ARRAY}  @tab Shall be an array of any type.
2931 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
2932 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
2933 @end multitable
2934
2935 @item @emph{Return value}:
2936 Returns an array of same type and rank as the @var{ARRAY} argument.
2937
2938 @item @emph{Example}:
2939 @smallexample
2940 program test_cshift
2941     integer, dimension(3,3) :: a
2942     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2943     print '(3i3)', a(1,:)
2944     print '(3i3)', a(2,:)
2945     print '(3i3)', a(3,:)    
2946     a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2947     print *
2948     print '(3i3)', a(1,:)
2949     print '(3i3)', a(2,:)
2950     print '(3i3)', a(3,:)
2951 end program test_cshift
2952 @end smallexample
2953 @end table
2954
2955
2956
2957 @node CTIME
2958 @section @code{CTIME} --- Convert a time into a string
2959 @fnindex CTIME
2960 @cindex time, conversion to string
2961 @cindex conversion, to string
2962
2963 @table @asis
2964 @item @emph{Description}:
2965 @code{CTIME} converts a system time value, such as returned by
2966 @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14 1995}.
2967
2968 This intrinsic is provided in both subroutine and function forms; however,
2969 only one form can be used in any given program unit.
2970
2971 @item @emph{Standard}:
2972 GNU extension
2973
2974 @item @emph{Class}:
2975 Subroutine, function
2976
2977 @item @emph{Syntax}:
2978 @multitable @columnfractions .80
2979 @item @code{CALL CTIME(TIME, RESULT)}.
2980 @item @code{RESULT = CTIME(TIME)}, (not recommended).
2981 @end multitable
2982
2983 @item @emph{Arguments}:
2984 @multitable @columnfractions .15 .70
2985 @item @var{TIME}    @tab The type shall be of type @code{INTEGER(KIND=8)}.
2986 @item @var{RESULT}  @tab The type shall be of type @code{CHARACTER} and
2987 of default kind.
2988 @end multitable
2989
2990 @item @emph{Return value}:
2991 The converted date and time as a string.
2992
2993 @item @emph{Example}:
2994 @smallexample
2995 program test_ctime
2996     integer(8) :: i
2997     character(len=30) :: date
2998     i = time8()
2999
3000     ! Do something, main part of the program
3001     
3002     call ctime(i,date)
3003     print *, 'Program was started on ', date
3004 end program test_ctime
3005 @end smallexample
3006
3007 @item @emph{See Also}:
3008 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
3009 @end table
3010
3011
3012
3013 @node DATE_AND_TIME
3014 @section @code{DATE_AND_TIME} --- Date and time subroutine
3015 @fnindex DATE_AND_TIME
3016 @cindex date, current
3017 @cindex current date
3018 @cindex time, current
3019 @cindex current time
3020
3021 @table @asis
3022 @item @emph{Description}:
3023 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
3024 time information from the real-time system clock.  @var{DATE} is
3025 @code{INTENT(OUT)} and has form ccyymmdd.  @var{TIME} is @code{INTENT(OUT)} and
3026 has form hhmmss.sss.  @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
3027 representing the difference with respect to Coordinated Universal Time (UTC).
3028 Unavailable time and date parameters return blanks.
3029
3030 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
3031
3032 @multitable @columnfractions .15 .30 .40
3033 @item @tab @code{VALUE(1)}: @tab The year
3034 @item @tab @code{VALUE(2)}: @tab The month
3035 @item @tab @code{VALUE(3)}: @tab The day of the month
3036 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
3037 @item @tab @code{VALUE(5)}: @tab The hour of the day
3038 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
3039 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
3040 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
3041 @end multitable
3042
3043 @item @emph{Standard}:
3044 Fortran 95 and later
3045
3046 @item @emph{Class}:
3047 Subroutine
3048
3049 @item @emph{Syntax}:
3050 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
3051
3052 @item @emph{Arguments}:
3053 @multitable @columnfractions .15 .70
3054 @item @var{DATE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
3055 or larger, and of default kind.
3056 @item @var{TIME}  @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
3057 or larger, and of default kind.
3058 @item @var{ZONE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
3059 or larger, and of default kind.
3060 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
3061 @end multitable
3062
3063 @item @emph{Return value}:
3064 None
3065
3066 @item @emph{Example}:
3067 @smallexample
3068 program test_time_and_date
3069     character(8)  :: date
3070     character(10) :: time
3071     character(5)  :: zone
3072     integer,dimension(8) :: values
3073     ! using keyword arguments
3074     call date_and_time(date,time,zone,values)
3075     call date_and_time(DATE=date,ZONE=zone)
3076     call date_and_time(TIME=time)
3077     call date_and_time(VALUES=values)
3078     print '(a,2x,a,2x,a)', date, time, zone
3079     print '(8i5))', values
3080 end program test_time_and_date
3081 @end smallexample
3082
3083 @item @emph{See also}:
3084 @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
3085 @end table
3086
3087
3088
3089 @node DBLE
3090 @section @code{DBLE} --- Double conversion function 
3091 @fnindex DBLE
3092 @cindex conversion, to real
3093
3094 @table @asis
3095 @item @emph{Description}:
3096 @code{DBLE(A)} Converts @var{A} to double precision real type.
3097
3098 @item @emph{Standard}:
3099 Fortran 77 and later
3100
3101 @item @emph{Class}:
3102 Elemental function
3103
3104 @item @emph{Syntax}:
3105 @code{RESULT = DBLE(A)}
3106
3107 @item @emph{Arguments}:
3108 @multitable @columnfractions .15 .70
3109 @item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
3110 or @code{COMPLEX}.
3111 @end multitable
3112
3113 @item @emph{Return value}:
3114 The return value is of type double precision real.
3115
3116 @item @emph{Example}:
3117 @smallexample
3118 program test_dble
3119     real    :: x = 2.18
3120     integer :: i = 5
3121     complex :: z = (2.3,1.14)
3122     print *, dble(x), dble(i), dble(z)
3123 end program test_dble
3124 @end smallexample
3125
3126 @item @emph{See also}:
3127 @ref{REAL}
3128 @end table
3129
3130
3131
3132 @node DCMPLX
3133 @section @code{DCMPLX} --- Double complex conversion function
3134 @fnindex DCMPLX
3135 @cindex complex numbers, conversion to
3136 @cindex conversion, to complex
3137
3138 @table @asis
3139 @item @emph{Description}:
3140 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
3141 converted to the real component.  If @var{Y} is present it is converted to the
3142 imaginary component.  If @var{Y} is not present then the imaginary component is
3143 set to 0.0.  If @var{X} is complex then @var{Y} must not be present.
3144
3145 @item @emph{Standard}:
3146 GNU extension
3147
3148 @item @emph{Class}:
3149 Elemental function
3150
3151 @item @emph{Syntax}:
3152 @code{RESULT = DCMPLX(X [, Y])}
3153
3154 @item @emph{Arguments}:
3155 @multitable @columnfractions .15 .70
3156 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
3157 or @code{COMPLEX}.
3158 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
3159 @code{INTEGER} or @code{REAL}. 
3160 @end multitable
3161
3162 @item @emph{Return value}:
3163 The return value is of type @code{COMPLEX(8)}
3164
3165 @item @emph{Example}:
3166 @smallexample
3167 program test_dcmplx
3168     integer :: i = 42
3169     real :: x = 3.14
3170     complex :: z
3171     z = cmplx(i, x)
3172     print *, dcmplx(i)
3173     print *, dcmplx(x)
3174     print *, dcmplx(z)
3175     print *, dcmplx(x,i)
3176 end program test_dcmplx
3177 @end smallexample
3178 @end table
3179
3180
3181 @node DIGITS
3182 @section @code{DIGITS} --- Significant binary digits function
3183 @fnindex DIGITS
3184 @cindex model representation, significant digits
3185
3186 @table @asis
3187 @item @emph{Description}:
3188 @code{DIGITS(X)} returns the number of significant binary digits of the internal
3189 model representation of @var{X}.  For example, on a system using a 32-bit
3190 floating point representation, a default real number would likely return 24.
3191
3192 @item @emph{Standard}:
3193 Fortran 95 and later
3194
3195 @item @emph{Class}:
3196 Inquiry function
3197
3198 @item @emph{Syntax}:
3199 @code{RESULT = DIGITS(X)}
3200
3201 @item @emph{Arguments}:
3202 @multitable @columnfractions .15 .70
3203 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
3204 @end multitable
3205
3206 @item @emph{Return value}:
3207 The return value is of type @code{INTEGER}.
3208
3209 @item @emph{Example}:
3210 @smallexample
3211 program test_digits
3212     integer :: i = 12345
3213     real :: x = 3.143
3214     real(8) :: y = 2.33
3215     print *, digits(i)
3216     print *, digits(x)
3217     print *, digits(y)
3218 end program test_digits
3219 @end smallexample
3220 @end table
3221
3222
3223
3224 @node DIM
3225 @section @code{DIM} --- Positive difference
3226 @fnindex DIM
3227 @fnindex IDIM
3228 @fnindex DDIM
3229 @cindex positive difference
3230
3231 @table @asis
3232 @item @emph{Description}:
3233 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
3234 otherwise returns zero.
3235
3236 @item @emph{Standard}:
3237 Fortran 77 and later
3238
3239 @item @emph{Class}:
3240 Elemental function
3241
3242 @item @emph{Syntax}:
3243 @code{RESULT = DIM(X, Y)}
3244
3245 @item @emph{Arguments}:
3246 @multitable @columnfractions .15 .70
3247 @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
3248 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
3249 @end multitable
3250
3251 @item @emph{Return value}:
3252 The return value is of type @code{INTEGER} or @code{REAL}.
3253
3254 @item @emph{Example}:
3255 @smallexample
3256 program test_dim
3257     integer :: i
3258     real(8) :: x
3259     i = dim(4, 15)
3260     x = dim(4.345_8, 2.111_8)
3261     print *, i
3262     print *, x
3263 end program test_dim
3264 @end smallexample
3265
3266 @item @emph{Specific names}:
3267 @multitable @columnfractions .20 .20 .20 .25
3268 @item Name             @tab Argument               @tab Return type       @tab Standard
3269 @item @code{DIM(X,Y)}  @tab @code{REAL(4) X, Y}    @tab @code{REAL(4)}    @tab Fortran 77 and later
3270 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X, Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
3271 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X, Y}    @tab @code{REAL(8)}    @tab Fortran 77 and later
3272 @end multitable
3273 @end table
3274
3275
3276
3277 @node DOT_PRODUCT
3278 @section @code{DOT_PRODUCT} --- Dot product function
3279 @fnindex DOT_PRODUCT
3280 @cindex dot product
3281 @cindex vector product
3282 @cindex product, vector
3283
3284 @table @asis
3285 @item @emph{Description}:
3286 @code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
3287 of two vectors @var{VECTOR_A} and @var{VECTOR_B}.  The two vectors may be
3288 either numeric or logical and must be arrays of rank one and of equal size. If
3289 the vectors are @code{INTEGER} or @code{REAL}, the result is
3290 @code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
3291 is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
3292 the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.  
3293
3294 @item @emph{Standard}:
3295 Fortran 95 and later
3296
3297 @item @emph{Class}:
3298 Transformational function
3299
3300 @item @emph{Syntax}:
3301 @code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
3302
3303 @item @emph{Arguments}:
3304 @multitable @columnfractions .15 .70
3305 @item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
3306 @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.
3307 @end multitable
3308
3309 @item @emph{Return value}:
3310 If the arguments are numeric, the return value is a scalar of numeric type,
3311 @code{INTEGER}, @code{REAL}, or @code{COMPLEX}.  If the arguments are
3312 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
3313
3314 @item @emph{Example}:
3315 @smallexample
3316 program test_dot_prod
3317     integer, dimension(3) :: a, b
3318     a = (/ 1, 2, 3 /)
3319     b = (/ 4, 5, 6 /)
3320     print '(3i3)', a
3321     print *
3322     print '(3i3)', b
3323     print *
3324     print *, dot_product(a,b)
3325 end program test_dot_prod
3326 @end smallexample
3327 @end table
3328
3329
3330
3331 @node DPROD
3332 @section @code{DPROD} --- Double product function
3333 @fnindex DPROD
3334 @cindex product, double-precision
3335
3336 @table @asis
3337 @item @emph{Description}:
3338 @code{DPROD(X,Y)} returns the product @code{X*Y}.
3339
3340 @item @emph{Standard}:
3341 Fortran 77 and later
3342
3343 @item @emph{Class}:
3344 Elemental function
3345
3346 @item @emph{Syntax}:
3347 @code{RESULT = DPROD(X, Y)}
3348
3349 @item @emph{Arguments}:
3350 @multitable @columnfractions .15 .70
3351 @item @var{X} @tab The type shall be @code{REAL}.
3352 @item @var{Y} @tab The type shall be @code{REAL}.
3353 @end multitable
3354
3355 @item @emph{Return value}:
3356 The return value is of type @code{REAL(8)}.
3357
3358 @item @emph{Example}:
3359 @smallexample
3360 program test_dprod
3361     real :: x = 5.2
3362     real :: y = 2.3
3363     real(8) :: d
3364     d = dprod(x,y)
3365     print *, d
3366 end program test_dprod
3367 @end smallexample
3368
3369 @item @emph{Specific names}:
3370 @multitable @columnfractions .20 .20 .20 .25
3371 @item Name              @tab Argument               @tab Return type       @tab Standard
3372 @item @code{DPROD(X,Y)} @tab @code{REAL(4) X, Y}    @tab @code{REAL(4)}    @tab Fortran 77 and later
3373 @end multitable
3374
3375 @end table
3376
3377
3378 @node DREAL
3379 @section @code{DREAL} --- Double real part function
3380 @fnindex DREAL
3381 @cindex complex numbers, real part
3382
3383 @table @asis
3384 @item @emph{Description}:
3385 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
3386
3387 @item @emph{Standard}:
3388 GNU extension
3389
3390 @item @emph{Class}:
3391 Elemental function
3392
3393 @item @emph{Syntax}:
3394 @code{RESULT = DREAL(A)}
3395
3396 @item @emph{Arguments}:
3397 @multitable @columnfractions .15 .70
3398 @item @var{A} @tab The type shall be @code{COMPLEX(8)}.
3399 @end multitable
3400
3401 @item @emph{Return value}:
3402 The return value is of type @code{REAL(8)}.
3403
3404 @item @emph{Example}:
3405 @smallexample
3406 program test_dreal
3407     complex(8) :: z = (1.3_8,7.2_8)
3408     print *, dreal(z)
3409 end program test_dreal
3410 @end smallexample
3411
3412 @item @emph{See also}:
3413 @ref{AIMAG}
3414
3415 @end table
3416
3417
3418
3419 @node DTIME
3420 @section @code{DTIME} --- Execution time subroutine (or function)
3421 @fnindex DTIME
3422 @cindex time, elapsed
3423 @cindex elapsed time
3424
3425 @table @asis
3426 @item @emph{Description}:
3427 @code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime
3428 since the start of the process's execution in @var{TIME}.  @var{VALUES}
3429 returns the user and system components of this time in @code{VALUES(1)} and
3430 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) +
3431 VALUES(2)}.
3432
3433 Subsequent invocations of @code{DTIME} return values accumulated since the
3434 previous invocation.
3435
3436 On some systems, the underlying timings are represented using types with
3437 sufficiently small limits that overflows (wrap around) are possible, such as
3438 32-bit types. Therefore, the values returned by this intrinsic might be, or
3439 become, negative, or numerically less than previous values, during a single
3440 run of the compiled program.
3441
3442 Please note, that this implementation is thread safe if used within OpenMP
3443 directives, i.e., its state will be consistent while called from multiple
3444 threads. However, if @code{DTIME} is called from multiple threads, the result
3445 is still the time since the last invocation. This may not give the intended
3446 results. If possible, use @code{CPU_TIME} instead.
3447
3448 This intrinsic is provided in both subroutine and function forms; however,
3449 only one form can be used in any given program unit.
3450
3451 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
3452
3453 @multitable @columnfractions .15 .30 .40
3454 @item @tab @code{VALUES(1)}: @tab User time in seconds.
3455 @item @tab @code{VALUES(2)}: @tab System time in seconds.
3456 @item @tab @code{TIME}: @tab Run time since start in seconds.
3457 @end multitable
3458
3459 @item @emph{Standard}:
3460 GNU extension
3461
3462 @item @emph{Class}:
3463 Subroutine, function
3464
3465 @item @emph{Syntax}:
3466 @multitable @columnfractions .80
3467 @item @code{CALL DTIME(VALUES, TIME)}.
3468 @item @code{TIME = DTIME(VALUES)}, (not recommended).
3469 @end multitable
3470
3471 @item @emph{Arguments}:
3472 @multitable @columnfractions .15 .70
3473 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
3474 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
3475 @end multitable
3476
3477 @item @emph{Return value}:
3478 Elapsed time in seconds since the last invocation or since the start of program
3479 execution if not called before.
3480
3481 @item @emph{Example}:
3482 @smallexample
3483 program test_dtime
3484     integer(8) :: i, j
3485     real, dimension(2) :: tarray
3486     real :: result
3487     call dtime(tarray, result)
3488     print *, result
3489     print *, tarray(1)
3490     print *, tarray(2)   
3491     do i=1,100000000    ! Just a delay
3492         j = i * i - i
3493     end do
3494     call dtime(tarray, result)
3495     print *, result
3496     print *, tarray(1)
3497     print *, tarray(2)
3498 end program test_dtime
3499 @end smallexample
3500
3501 @item @emph{See also}:
3502 @ref{CPU_TIME}
3503
3504 @end table
3505
3506
3507
3508 @node EOSHIFT
3509 @section @code{EOSHIFT} --- End-off shift elements of an array
3510 @fnindex EOSHIFT
3511 @cindex array, shift
3512
3513 @table @asis
3514 @item @emph{Description}:
3515 @code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
3516 elements of @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is
3517 omitted it is taken to be @code{1}.  @var{DIM} is a scalar of type
3518 @code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the
3519 rank of @var{ARRAY}.  If the rank of @var{ARRAY} is one, then all elements of
3520 @var{ARRAY} are shifted by @var{SHIFT} places.  If rank is greater than one,
3521 then all complete rank one sections of @var{ARRAY} along the given dimension are
3522 shifted.  Elements shifted out one end of each rank one section are dropped.  If
3523 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
3524 is copied back in the other end.  If @var{BOUNDARY} is not present then the
3525 following are copied in depending on the type of @var{ARRAY}.
3526
3527 @multitable @columnfractions .15 .80
3528 @item @emph{Array Type} @tab @emph{Boundary Value}
3529 @item Numeric  @tab 0 of the type and kind of @var{ARRAY}.
3530 @item Logical  @tab @code{.FALSE.}.
3531 @item Character(@var{len}) @tab @var{len} blanks.
3532 @end multitable
3533
3534 @item @emph{Standard}:
3535 Fortran 95 and later
3536
3537 @item @emph{Class}:
3538 Transformational function
3539
3540 @item @emph{Syntax}:
3541 @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
3542
3543 @item @emph{Arguments}:
3544 @multitable @columnfractions .15 .70
3545 @item @var{ARRAY}  @tab May be any type, not scalar.
3546 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
3547 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}. 
3548 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
3549 @end multitable
3550
3551 @item @emph{Return value}:
3552 Returns an array of same type and rank as the @var{ARRAY} argument.
3553
3554 @item @emph{Example}:
3555 @smallexample
3556 program test_eoshift
3557     integer, dimension(3,3) :: a
3558     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3559     print '(3i3)', a(1,:)
3560     print '(3i3)', a(2,:)
3561     print '(3i3)', a(3,:)    
3562     a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3563     print *
3564     print '(3i3)', a(1,:)
3565     print '(3i3)', a(2,:)
3566     print '(3i3)', a(3,:)
3567 end program test_eoshift
3568 @end smallexample
3569 @end table
3570
3571
3572
3573 @node EPSILON
3574 @section @code{EPSILON} --- Epsilon function
3575 @fnindex EPSILON
3576 @cindex model representation, epsilon
3577
3578 @table @asis
3579 @item @emph{Description}:
3580 @code{EPSILON(X)} returns the smallest number @var{E} of the same kind
3581 as @var{X} such that @math{1 + E > 1}.
3582
3583 @item @emph{Standard}:
3584 Fortran 95 and later
3585
3586 @item @emph{Class}:
3587 Inquiry function
3588
3589 @item @emph{Syntax}:
3590 @code{RESULT = EPSILON(X)}
3591
3592 @item @emph{Arguments}:
3593 @multitable @columnfractions .15 .70
3594 @item @var{X} @tab The type shall be @code{REAL}.
3595 @end multitable
3596
3597 @item @emph{Return value}:
3598 The return value is of same type as the argument.
3599
3600 @item @emph{Example}:
3601 @smallexample
3602 program test_epsilon
3603     real :: x = 3.143
3604     real(8) :: y = 2.33
3605     print *, EPSILON(x)
3606     print *, EPSILON(y)
3607 end program test_epsilon
3608 @end smallexample
3609 @end table
3610
3611
3612
3613 @node ERF
3614 @section @code{ERF} --- Error function 
3615 @fnindex ERF
3616 @cindex error function
3617
3618 @table @asis
3619 @item @emph{Description}:
3620 @code{ERF(X)} computes the error function of @var{X}.
3621
3622 @item @emph{Standard}:
3623 Fortran 2008 and later
3624
3625 @item @emph{Class}:
3626 Elemental function
3627
3628 @item @emph{Syntax}:
3629 @code{RESULT = ERF(X)}
3630
3631 @item @emph{Arguments}:
3632 @multitable @columnfractions .15 .70
3633 @item @var{X} @tab The type shall be @code{REAL}.
3634 @end multitable
3635
3636 @item @emph{Return value}:
3637 The return value is of type @code{REAL}, of the same kind as
3638 @var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
3639
3640 @item @emph{Example}:
3641 @smallexample
3642 program test_erf
3643   real(8) :: x = 0.17_8
3644   x = erf(x)
3645 end program test_erf
3646 @end smallexample
3647
3648 @item @emph{Specific names}:
3649 @multitable @columnfractions .20 .20 .20 .25
3650 @item Name            @tab Argument          @tab Return type       @tab Standard
3651 @item @code{DERF(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
3652 @end multitable
3653 @end table
3654
3655
3656
3657 @node ERFC
3658 @section @code{ERFC} --- Error function 
3659 @fnindex ERFC
3660 @cindex error function, complementary
3661
3662 @table @asis
3663 @item @emph{Description}:
3664 @code{ERFC(X)} computes the complementary error function of @var{X}.
3665
3666 @item @emph{Standard}:
3667 Fortran 2008 and later
3668
3669 @item @emph{Class}:
3670 Elemental function
3671
3672 @item @emph{Syntax}:
3673 @code{RESULT = ERFC(X)}
3674
3675 @item @emph{Arguments}:
3676 @multitable @columnfractions .15 .70
3677 @item @var{X} @tab The type shall be @code{REAL}.
3678 @end multitable
3679
3680 @item @emph{Return value}:
3681 The return value is of type @code{REAL} and of the same kind as @var{X}.
3682 It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
3683
3684 @item @emph{Example}:
3685 @smallexample
3686 program test_erfc
3687   real(8) :: x = 0.17_8
3688   x = erfc(x)
3689 end program test_erfc
3690 @end smallexample
3691
3692 @item @emph{Specific names}:
3693 @multitable @columnfractions .20 .20 .20 .25
3694 @item Name            @tab Argument          @tab Return type       @tab Standard
3695 @item @code{DERFC(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
3696 @end multitable
3697 @end table
3698
3699
3700
3701 @node ERFC_SCALED
3702 @section @code{ERFC_SCALED} --- Error function 
3703 @fnindex ERFC_SCALED
3704 @cindex error function, complementary, exponentially-scaled
3705
3706 @table @asis
3707 @item @emph{Description}:
3708 @code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
3709 error function of @var{X}.
3710
3711 @item @emph{Standard}:
3712 Fortran 2008 and later
3713
3714 @item @emph{Class}:
3715 Elemental function
3716
3717 @item @emph{Syntax}:
3718 @code{RESULT = ERFC_SCALED(X)}
3719
3720 @item @emph{Arguments}:
3721 @multitable @columnfractions .15 .70
3722 @item @var{X} @tab The type shall be @code{REAL}.
3723 @end multitable
3724
3725 @item @emph{Return value}:
3726 The return value is of type @code{REAL} and of the same kind as @var{X}.
3727
3728 @item @emph{Example}:
3729 @smallexample
3730 program test_erfc_scaled
3731   real(8) :: x = 0.17_8
3732   x = erfc_scaled(x)
3733 end program test_erfc_scaled
3734 @end smallexample
3735 @end table
3736
3737
3738
3739 @node ETIME
3740 @section @code{ETIME} --- Execution time subroutine (or function)
3741 @fnindex ETIME
3742 @cindex time, elapsed
3743
3744 @table @asis
3745 @item @emph{Description}:
3746 @code{ETIME(VALUES, TIME)} returns the number of seconds of runtime
3747 since the start of the process's execution in @var{TIME}.  @var{VALUES}
3748 returns the user and system components of this time in @code{VALUES(1)} and
3749 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}.
3750
3751 On some systems, the underlying timings are represented using types with
3752 sufficiently small limits that overflows (wrap around) are possible, such as
3753 32-bit types. Therefore, the values returned by this intrinsic might be, or
3754 become, negative, or numerically less than previous values, during a single
3755 run of the compiled program.
3756
3757 This intrinsic is provided in both subroutine and function forms; however,
3758 only one form can be used in any given program unit.
3759
3760 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
3761
3762 @multitable @columnfractions .15 .30 .60
3763 @item @tab @code{VALUES(1)}: @tab User time in seconds.
3764 @item @tab @code{VALUES(2)}: @tab System time in seconds.
3765 @item @tab @code{TIME}: @tab Run time since start in seconds.
3766 @end multitable
3767
3768 @item @emph{Standard}:
3769 GNU extension
3770
3771 @item @emph{Class}:
3772 Subroutine, function
3773
3774 @item @emph{Syntax}:
3775 @multitable @columnfractions .80
3776 @item @code{CALL ETIME(VALUES, TIME)}.
3777 @item @code{TIME = ETIME(VALUES)}, (not recommended).
3778 @end multitable
3779
3780 @item @emph{Arguments}:
3781 @multitable @columnfractions .15 .70
3782 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
3783 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
3784 @end multitable
3785
3786 @item @emph{Return value}:
3787 Elapsed time in seconds since the start of program execution.
3788
3789 @item @emph{Example}:
3790 @smallexample
3791 program test_etime
3792     integer(8) :: i, j
3793     real, dimension(2) :: tarray
3794     real :: result
3795     call ETIME(tarray, result)
3796     print *, result
3797     print *, tarray(1)
3798     print *, tarray(2)   
3799     do i=1,100000000    ! Just a delay
3800         j = i * i - i
3801     end do
3802     call ETIME(tarray, result)
3803     print *, result
3804     print *, tarray(1)
3805     print *, tarray(2)
3806 end program test_etime
3807 @end smallexample
3808
3809 @item @emph{See also}:
3810 @ref{CPU_TIME}
3811
3812 @end table
3813
3814
3815
3816 @node EXIT
3817 @section @code{EXIT} --- Exit the program with status. 
3818 @fnindex EXIT
3819 @cindex program termination
3820 @cindex terminate program
3821
3822 @table @asis
3823 @item @emph{Description}:
3824 @code{EXIT} causes immediate termination of the program with status.  If status
3825 is omitted it returns the canonical @emph{success} for the system.  All Fortran
3826 I/O units are closed. 
3827
3828 @item @emph{Standard}:
3829 GNU extension
3830
3831 @item @emph{Class}:
3832 Subroutine
3833
3834 @item @emph{Syntax}:
3835 @code{CALL EXIT([STATUS])}
3836
3837 @item @emph{Arguments}:
3838 @multitable @columnfractions .15 .70
3839 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
3840 @end multitable
3841
3842 @item @emph{Return value}:
3843 @code{STATUS} is passed to the parent process on exit.
3844
3845 @item @emph{Example}:
3846 @smallexample
3847 program test_exit
3848   integer :: STATUS = 0
3849   print *, 'This program is going to exit.'
3850   call EXIT(STATUS)
3851 end program test_exit
3852 @end smallexample
3853
3854 @item @emph{See also}:
3855 @ref{ABORT}, @ref{KILL}
3856 @end table
3857
3858
3859
3860 @node EXP
3861 @section @code{EXP} --- Exponential function 
3862 @fnindex EXP
3863 @fnindex DEXP
3864 @fnindex CEXP
3865 @fnindex ZEXP
3866 @fnindex CDEXP
3867 @cindex exponential function
3868 @cindex logarithmic function, inverse
3869
3870 @table @asis
3871 @item @emph{Description}:
3872 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3873
3874 @item @emph{Standard}:
3875 Fortran 77 and later, has overloads that are GNU extensions
3876
3877 @item @emph{Class}:
3878 Elemental function
3879
3880 @item @emph{Syntax}:
3881 @code{RESULT = EXP(X)}
3882
3883 @item @emph{Arguments}:
3884 @multitable @columnfractions .15 .70
3885 @item @var{X} @tab The type shall be @code{REAL} or
3886 @code{COMPLEX}.
3887 @end multitable
3888
3889 @item @emph{Return value}:
3890 The return value has same type and kind as @var{X}.
3891
3892 @item @emph{Example}:
3893 @smallexample
3894 program test_exp
3895   real :: x = 1.0
3896   x = exp(x)
3897 end program test_exp
3898 @end smallexample
3899
3900 @item @emph{Specific names}:
3901 @multitable @columnfractions .20 .20 .20 .25
3902 @item Name            @tab Argument             @tab Return type         @tab Standard
3903 @item @code{EXP(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}      @tab Fortran 77 and later
3904 @item @code{DEXP(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}      @tab Fortran 77 and later
3905 @item @code{CEXP(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}   @tab Fortran 77 and later
3906 @item @code{ZEXP(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
3907 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
3908 @end multitable
3909 @end table
3910
3911
3912
3913 @node EXPONENT
3914 @section @code{EXPONENT} --- Exponent function 
3915 @fnindex EXPONENT
3916 @cindex real number, exponent
3917 @cindex floating point, exponent
3918
3919 @table @asis
3920 @item @emph{Description}:
3921 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3922 is zero the value returned is zero. 
3923
3924 @item @emph{Standard}:
3925 Fortran 95 and later
3926
3927 @item @emph{Class}:
3928 Elemental function
3929
3930 @item @emph{Syntax}:
3931 @code{RESULT = EXPONENT(X)}
3932
3933 @item @emph{Arguments}:
3934 @multitable @columnfractions .15 .70
3935 @item @var{X} @tab The type shall be @code{REAL}.
3936 @end multitable
3937
3938 @item @emph{Return value}:
3939 The return value is of type default @code{INTEGER}.
3940
3941 @item @emph{Example}:
3942 @smallexample
3943 program test_exponent
3944   real :: x = 1.0
3945   integer :: i
3946   i = exponent(x)
3947   print *, i
3948   print *, exponent(0.0)
3949 end program test_exponent
3950 @end smallexample
3951 @end table
3952
3953
3954
3955 @node EXTENDS_TYPE_OF
3956 @section @code{EXTENDS_TYPE_OF} ---  Query dynamic type for extension
3957 @fnindex EXTENDS_TYPE_OF
3958
3959 @table @asis
3960 @item @emph{Description}:
3961 Query dynamic type for extension.
3962
3963 @item @emph{Standard}:
3964 Fortran 2003 and later
3965
3966 @item @emph{Class}:
3967 Inquiry function
3968
3969 @item @emph{Syntax}:
3970 @code{RESULT = EXTENDS_TYPE_OF(A, MOLD)}
3971
3972 @item @emph{Arguments}:
3973 @multitable @columnfractions .15 .70
3974 @item @var{A} @tab Shall be an object of extensible declared type or
3975 unlimited polymorphic. 
3976 @item @var{MOLD} @tab Shall be an object of extensible declared type or
3977 unlimited polymorphic. 
3978 @end multitable
3979
3980 @item @emph{Return value}:
3981 The return value is a scalar of type default logical. It is true if and only if
3982 the dynamic type of A is an extension type of the dynamic type of MOLD.
3983
3984
3985 @item @emph{See also}:
3986 @ref{SAME_TYPE_AS}
3987 @end table
3988
3989
3990
3991 @node FDATE
3992 @section @code{FDATE} --- Get the current time as a string
3993 @fnindex FDATE
3994 @cindex time, current
3995 @cindex current time
3996 @cindex date, current
3997 @cindex current date
3998
3999 @table @asis
4000 @item @emph{Description}:
4001 @code{FDATE(DATE)} returns the current date (using the same format as
4002 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
4003 TIME())}.
4004
4005 This intrinsic is provided in both subroutine and function forms; however,
4006 only one form can be used in any given program unit.
4007
4008 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable of the
4009 default kind.
4010
4011 @item @emph{Standard}:
4012 GNU extension
4013
4014 @item @emph{Class}:
4015 Subroutine, function
4016
4017 @item @emph{Syntax}:
4018 @multitable @columnfractions .80
4019 @item @code{CALL FDATE(DATE)}.
4020 @item @code{DATE = FDATE()}, (not recommended).
4021 @end multitable
4022
4023 @item @emph{Arguments}:
4024 @multitable @columnfractions .15 .70
4025 @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
4026 default kind
4027 @end multitable
4028
4029 @item @emph{Return value}:
4030 The current date as a string.
4031
4032 @item @emph{Example}:
4033 @smallexample
4034 program test_fdate
4035     integer(8) :: i, j
4036     character(len=30) :: date
4037     call fdate(date)
4038     print *, 'Program started on ', date
4039     do i = 1, 100000000 ! Just a delay
4040         j = i * i - i
4041     end do
4042     call fdate(date)
4043     print *, 'Program ended on ', date
4044 end program test_fdate
4045 @end smallexample
4046 @end table
4047
4048
4049
4050 @node FGET
4051 @section @code{FGET} --- Read a single character in stream mode from stdin 
4052 @fnindex FGET
4053 @cindex read character, stream mode
4054 @cindex stream mode, read character
4055 @cindex file operation, read character
4056
4057 @table @asis
4058 @item @emph{Description}:
4059 Read a single character in stream mode from stdin by bypassing normal 
4060 formatted output. Stream I/O should not be mixed with normal record-oriented 
4061 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4062
4063 This intrinsic is provided in both subroutine and function forms; however,
4064 only one form can be used in any given program unit.
4065
4066 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4067 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4068 Programmers should consider the use of new stream IO feature in new code 
4069 for future portability. See also @ref{Fortran 2003 status}.
4070
4071 @item @emph{Standard}:
4072 GNU extension
4073
4074 @item @emph{Class}:
4075 Subroutine, function
4076
4077 @item @emph{Syntax}:
4078 @code{CALL FGET(C [, STATUS])}
4079
4080 @item @emph{Arguments}:
4081 @multitable @columnfractions .15 .70
4082 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4083 kind.
4084 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4085 Returns 0 on success, -1 on end-of-file, and a system specific positive
4086 error code otherwise.
4087 @end multitable
4088
4089 @item @emph{Example}:
4090 @smallexample
4091 PROGRAM test_fget
4092   INTEGER, PARAMETER :: strlen = 100
4093   INTEGER :: status, i = 1
4094   CHARACTER(len=strlen) :: str = ""
4095
4096   WRITE (*,*) 'Enter text:'
4097   DO
4098     CALL fget(str(i:i), status)
4099     if (status /= 0 .OR. i > strlen) exit
4100     i = i + 1
4101   END DO
4102   WRITE (*,*) TRIM(str)
4103 END PROGRAM
4104 @end smallexample
4105
4106 @item @emph{See also}:
4107 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
4108 @end table
4109
4110
4111
4112 @node FGETC
4113 @section @code{FGETC} --- Read a single character in stream mode
4114 @fnindex FGETC
4115 @cindex read character, stream mode
4116 @cindex stream mode, read character
4117 @cindex file operation, read character
4118
4119 @table @asis
4120 @item @emph{Description}:
4121 Read a single character in stream mode by bypassing normal formatted output. 
4122 Stream I/O should not be mixed with normal record-oriented (formatted or 
4123 unformatted) I/O on the same unit; the results are unpredictable.
4124
4125 This intrinsic is provided in both subroutine and function forms; however,
4126 only one form can be used in any given program unit.
4127
4128 Note that the @code{FGET} intrinsic is provided for backwards compatibility
4129 with @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4130 Programmers should consider the use of new stream IO feature in new code 
4131 for future portability. See also @ref{Fortran 2003 status}.
4132
4133 @item @emph{Standard}:
4134 GNU extension
4135
4136 @item @emph{Class}:
4137 Subroutine, function
4138
4139 @item @emph{Syntax}:
4140 @code{CALL FGETC(UNIT, C [, STATUS])}
4141
4142 @item @emph{Arguments}:
4143 @multitable @columnfractions .15 .70
4144 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4145 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4146 kind.
4147 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4148 Returns 0 on success, -1 on end-of-file and a system specific positive
4149 error code otherwise.
4150 @end multitable
4151
4152 @item @emph{Example}:
4153 @smallexample
4154 PROGRAM test_fgetc
4155   INTEGER :: fd = 42, status
4156   CHARACTER :: c
4157
4158   OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
4159   DO
4160     CALL fgetc(fd, c, status)
4161     IF (status /= 0) EXIT
4162     call fput(c)
4163   END DO
4164   CLOSE(UNIT=fd)
4165 END PROGRAM
4166 @end smallexample
4167
4168 @item @emph{See also}:
4169 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
4170 @end table
4171
4172
4173
4174 @node FLOOR
4175 @section @code{FLOOR} --- Integer floor function
4176 @fnindex FLOOR
4177 @cindex floor
4178 @cindex rounding, floor
4179
4180 @table @asis
4181 @item @emph{Description}:
4182 @code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
4183
4184 @item @emph{Standard}:
4185 Fortran 95 and later
4186
4187 @item @emph{Class}:
4188 Elemental function
4189
4190 @item @emph{Syntax}:
4191 @code{RESULT = FLOOR(A [, KIND])}
4192
4193 @item @emph{Arguments}:
4194 @multitable @columnfractions .15 .70
4195 @item @var{A} @tab The type shall be @code{REAL}.
4196 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
4197 expression indicating the kind parameter of the result.
4198 @end multitable
4199
4200 @item @emph{Return value}:
4201 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
4202 and of default-kind @code{INTEGER} otherwise.
4203
4204 @item @emph{Example}:
4205 @smallexample
4206 program test_floor
4207     real :: x = 63.29
4208     real :: y = -63.59
4209     print *, floor(x) ! returns 63
4210     print *, floor(y) ! returns -64
4211 end program test_floor
4212 @end smallexample
4213
4214 @item @emph{See also}:
4215 @ref{CEILING}, @ref{NINT}
4216
4217 @end table
4218
4219
4220
4221 @node FLUSH
4222 @section @code{FLUSH} --- Flush I/O unit(s)
4223 @fnindex FLUSH
4224 @cindex file operation, flush
4225
4226 @table @asis
4227 @item @emph{Description}:
4228 Flushes Fortran unit(s) currently open for output. Without the optional
4229 argument, all units are flushed, otherwise just the unit specified.
4230
4231 @item @emph{Standard}:
4232 GNU extension
4233
4234 @item @emph{Class}:
4235 Subroutine
4236
4237 @item @emph{Syntax}:
4238 @code{CALL FLUSH(UNIT)}
4239
4240 @item @emph{Arguments}:
4241 @multitable @columnfractions .15 .70
4242 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
4243 @end multitable
4244
4245 @item @emph{Note}:
4246 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
4247 statement that should be preferred over the @code{FLUSH} intrinsic.
4248
4249 The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement
4250 have identical effect: they flush the runtime library's I/O buffer so
4251 that the data becomes visible to other processes. This does not guarantee
4252 that the data is committed to disk.
4253
4254 On POSIX systems, you can request that all data is transferred  to  the
4255 storage device by calling the @code{fsync} function, with the POSIX file
4256 descriptor of the I/O unit as argument (retrieved with GNU intrinsic
4257 @code{FNUM}). The following example shows how:
4258
4259 @smallexample
4260   ! Declare the interface for POSIX fsync function
4261   interface
4262     function fsync (fd) bind(c,name="fsync")
4263     use iso_c_binding, only: c_int
4264       integer(c_int), value :: fd
4265       integer(c_int) :: fsync
4266     end function fsync
4267   end interface
4268
4269   ! Variable declaration
4270   integer :: ret
4271
4272   ! Opening unit 10
4273   open (10,file="foo")
4274
4275   ! ...
4276   ! Perform I/O on unit 10
4277   ! ...
4278
4279   ! Flush and sync
4280   flush(10)
4281   ret = fsync(fnum(10))
4282
4283   ! Handle possible error
4284   if (ret /= 0) stop "Error calling FSYNC"
4285 @end smallexample
4286
4287 @end table
4288
4289
4290
4291 @node FNUM
4292 @section @code{FNUM} --- File number function
4293 @fnindex FNUM
4294 @cindex file operation, file number
4295
4296 @table @asis
4297 @item @emph{Description}:
4298 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
4299 open Fortran I/O unit @code{UNIT}.
4300
4301 @item @emph{Standard}:
4302 GNU extension
4303
4304 @item @emph{Class}:
4305 Function
4306
4307 @item @emph{Syntax}:
4308 @code{RESULT = FNUM(UNIT)}
4309
4310 @item @emph{Arguments}:
4311 @multitable @columnfractions .15 .70
4312 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
4313 @end multitable
4314
4315 @item @emph{Return value}:
4316 The return value is of type @code{INTEGER}
4317
4318 @item @emph{Example}:
4319 @smallexample
4320 program test_fnum
4321   integer :: i
4322   open (unit=10, status = "scratch")
4323   i = fnum(10)
4324   print *, i
4325   close (10)
4326 end program test_fnum
4327 @end smallexample
4328 @end table
4329
4330
4331
4332 @node FPUT
4333 @section @code{FPUT} --- Write a single character in stream mode to stdout 
4334 @fnindex FPUT
4335 @cindex write character, stream mode
4336 @cindex stream mode, write character
4337 @cindex file operation, write character
4338
4339 @table @asis
4340 @item @emph{Description}:
4341 Write a single character in stream mode to stdout by bypassing normal 
4342 formatted output. Stream I/O should not be mixed with normal record-oriented 
4343 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4344
4345 This intrinsic is provided in both subroutine and function forms; however,
4346 only one form can be used in any given program unit.
4347
4348 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4349 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4350 Programmers should consider the use of new stream IO feature in new code 
4351 for future portability. See also @ref{Fortran 2003 status}.
4352
4353 @item @emph{Standard}:
4354 GNU extension
4355
4356 @item @emph{Class}:
4357 Subroutine, function
4358
4359 @item @emph{Syntax}:
4360 @code{CALL FPUT(C [, STATUS])}
4361
4362 @item @emph{Arguments}:
4363 @multitable @columnfractions .15 .70
4364 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4365 kind.
4366 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4367 Returns 0 on success, -1 on end-of-file and a system specific positive
4368 error code otherwise.
4369 @end multitable
4370
4371 @item @emph{Example}:
4372 @smallexample
4373 PROGRAM test_fput
4374   CHARACTER(len=10) :: str = "gfortran"
4375   INTEGER :: i
4376   DO i = 1, len_trim(str)
4377     CALL fput(str(i:i))
4378   END DO
4379 END PROGRAM
4380 @end smallexample
4381
4382 @item @emph{See also}:
4383 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
4384 @end table
4385
4386
4387
4388 @node FPUTC
4389 @section @code{FPUTC} --- Write a single character in stream mode
4390 @fnindex FPUTC
4391 @cindex write character, stream mode
4392 @cindex stream mode, write character
4393 @cindex file operation, write character
4394
4395 @table @asis
4396 @item @emph{Description}:
4397 Write a single character in stream mode by bypassing normal formatted 
4398 output. Stream I/O should not be mixed with normal record-oriented 
4399 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4400
4401 This intrinsic is provided in both subroutine and function forms; however,
4402 only one form can be used in any given program unit.
4403
4404 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4405 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4406 Programmers should consider the use of new stream IO feature in new code 
4407 for future portability. See also @ref{Fortran 2003 status}.
4408
4409 @item @emph{Standard}:
4410 GNU extension
4411
4412 @item @emph{Class}:
4413 Subroutine, function
4414
4415 @item @emph{Syntax}:
4416 @code{CALL FPUTC(UNIT, C [, STATUS])}
4417
4418 @item @emph{Arguments}:
4419 @multitable @columnfractions .15 .70
4420 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4421 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4422 kind.
4423 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4424 Returns 0 on success, -1 on end-of-file and a system specific positive
4425 error code otherwise.
4426 @end multitable
4427
4428 @item @emph{Example}:
4429 @smallexample
4430 PROGRAM test_fputc
4431   CHARACTER(len=10) :: str = "gfortran"
4432   INTEGER :: fd = 42, i
4433
4434   OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
4435   DO i = 1, len_trim(str)
4436     CALL fputc(fd, str(i:i))
4437   END DO
4438   CLOSE(fd)
4439 END PROGRAM
4440 @end smallexample
4441
4442 @item @emph{See also}:
4443 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
4444 @end table
4445
4446
4447
4448 @node FRACTION
4449 @section @code{FRACTION} --- Fractional part of the model representation
4450 @fnindex FRACTION
4451 @cindex real number, fraction
4452 @cindex floating point, fraction
4453
4454 @table @asis
4455 @item @emph{Description}:
4456 @code{FRACTION(X)} returns the fractional part of the model
4457 representation of @code{X}.
4458
4459 @item @emph{Standard}:
4460 Fortran 95 and later
4461
4462 @item @emph{Class}:
4463 Elemental function
4464
4465 @item @emph{Syntax}:
4466 @code{Y = FRACTION(X)}
4467
4468 @item @emph{Arguments}:
4469 @multitable @columnfractions .15 .70
4470 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
4471 @end multitable
4472
4473 @item @emph{Return value}:
4474 The return value is of the same type and kind as the argument.
4475 The fractional part of the model representation of @code{X} is returned;
4476 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
4477
4478 @item @emph{Example}:
4479 @smallexample
4480 program test_fraction
4481   real :: x
4482   x = 178.1387e-4
4483   print *, fraction(x), x * radix(x)**(-exponent(x))
4484 end program test_fraction
4485 @end smallexample
4486
4487 @end table
4488
4489
4490
4491 @node FREE
4492 @section @code{FREE} --- Frees memory
4493 @fnindex FREE
4494 @cindex pointer, cray
4495
4496 @table @asis
4497 @item @emph{Description}:
4498 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
4499 intrinsic is an extension intended to be used with Cray pointers, and is
4500 provided in GNU Fortran to allow user to compile legacy code. For
4501 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
4502 @code{DEALLOCATE}.
4503
4504 @item @emph{Standard}:
4505 GNU extension
4506
4507 @item @emph{Class}:
4508 Subroutine
4509
4510 @item @emph{Syntax}:
4511 @code{CALL FREE(PTR)}
4512
4513 @item @emph{Arguments}:
4514 @multitable @columnfractions .15 .70
4515 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
4516 location of the memory that should be de-allocated.
4517 @end multitable
4518
4519 @item @emph{Return value}:
4520 None
4521
4522 @item @emph{Example}:
4523 See @code{MALLOC} for an example.
4524
4525 @item @emph{See also}:
4526 @ref{MALLOC}
4527 @end table
4528
4529
4530
4531 @node FSEEK
4532 @section @code{FSEEK} --- Low level file positioning subroutine
4533 @fnindex FSEEK
4534 @cindex file operation, seek
4535 @cindex file operation, position
4536
4537 @table @asis
4538 @item @emph{Description}:
4539 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE} 
4540 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
4541 if set to 1, @var{OFFSET} is taken to be relative to the current position 
4542 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
4543 On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek 
4544 fails silently.
4545
4546 This intrinsic routine is not fully backwards compatible with @command{g77}. 
4547 In @command{g77}, the @code{FSEEK} takes a statement label instead of a 
4548 @var{STATUS} variable. If FSEEK is used in old code, change
4549 @smallexample
4550   CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
4551 @end smallexample 
4552 to
4553 @smallexample
4554   INTEGER :: status
4555   CALL FSEEK(UNIT, OFFSET, WHENCE, status)
4556   IF (status /= 0) GOTO label
4557 @end smallexample 
4558
4559 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
4560 Programmers should consider the use of new stream IO feature in new code 
4561 for future portability. See also @ref{Fortran 2003 status}.
4562
4563 @item @emph{Standard}:
4564 GNU extension
4565
4566 @item @emph{Class}:
4567 Subroutine
4568
4569 @item @emph{Syntax}:
4570 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
4571
4572 @item @emph{Arguments}:
4573 @multitable @columnfractions .15 .70
4574 @item @var{UNIT}   @tab Shall be a scalar of type @code{INTEGER}.
4575 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
4576 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
4577 Its value shall be either 0, 1 or 2.
4578 @item @var{STATUS} @tab (Optional) shall be a scalar of type 
4579 @code{INTEGER(4)}.
4580 @end multitable
4581
4582 @item @emph{Example}:
4583 @smallexample
4584 PROGRAM test_fseek
4585   INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
4586   INTEGER :: fd, offset, ierr
4587
4588   ierr   = 0
4589   offset = 5
4590   fd     = 10
4591
4592   OPEN(UNIT=fd, FILE="fseek.test")
4593   CALL FSEEK(fd, offset, SEEK_SET, ierr)  ! move to OFFSET
4594   print *, FTELL(fd), ierr
4595
4596   CALL FSEEK(fd, 0, SEEK_END, ierr)       ! move to end
4597   print *, FTELL(fd), ierr
4598
4599   CALL FSEEK(fd, 0, SEEK_SET, ierr)       ! move to beginning
4600   print *, FTELL(fd), ierr
4601
4602   CLOSE(UNIT=fd)
4603 END PROGRAM
4604 @end smallexample
4605
4606 @item @emph{See also}:
4607 @ref{FTELL}
4608 @end table
4609
4610
4611
4612 @node FSTAT
4613 @section @code{FSTAT} --- Get file status
4614 @fnindex FSTAT
4615 @cindex file system, file status
4616
4617 @table @asis
4618 @item @emph{Description}:
4619 @code{FSTAT} is identical to @ref{STAT}, except that information about an 
4620 already opened file is obtained.
4621
4622 The elements in @code{VALUES} are the same as described by @ref{STAT}.
4623
4624 This intrinsic is provided in both subroutine and function forms; however,
4625 only one form can be used in any given program unit.
4626
4627 @item @emph{Standard}:
4628 GNU extension
4629
4630 @item @emph{Class}:
4631 Subroutine, function
4632
4633 @item @emph{Syntax}:
4634 @code{CALL FSTAT(UNIT, VALUES [, STATUS])}
4635
4636 @item @emph{Arguments}:
4637 @multitable @columnfractions .15 .70
4638 @item @var{UNIT}   @tab An open I/O unit number of type @code{INTEGER}.
4639 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
4640 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
4641 on success and a system specific error code otherwise.
4642 @end multitable
4643
4644 @item @emph{Example}:
4645 See @ref{STAT} for an example.
4646
4647 @item @emph{See also}:
4648 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
4649 @end table
4650
4651
4652
4653 @node FTELL
4654 @section @code{FTELL} --- Current stream position
4655 @fnindex FTELL
4656 @cindex file operation, position
4657
4658 @table @asis
4659 @item @emph{Description}:
4660 Retrieves the current position within an open file.
4661
4662 This intrinsic is provided in both subroutine and function forms; however,
4663 only one form can be used in any given program unit.
4664
4665 @item @emph{Standard}:
4666 GNU extension
4667
4668 @item @emph{Class}:
4669 Subroutine, function
4670
4671 @item @emph{Syntax}:
4672 @multitable @columnfractions .80
4673 @item @code{CALL FTELL(UNIT, OFFSET)}
4674 @item @code{OFFSET = FTELL(UNIT)}
4675 @end multitable
4676
4677 @item @emph{Arguments}:
4678 @multitable @columnfractions .15 .70
4679 @item @var{OFFSET}  @tab Shall of type @code{INTEGER}.
4680 @item @var{UNIT}    @tab Shall of type @code{INTEGER}.
4681 @end multitable
4682
4683 @item @emph{Return value}:
4684 In either syntax, @var{OFFSET} is set to the current offset of unit
4685 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
4686
4687 @item @emph{Example}:
4688 @smallexample
4689 PROGRAM test_ftell
4690   INTEGER :: i
4691   OPEN(10, FILE="temp.dat")
4692   CALL ftell(10,i)
4693   WRITE(*,*) i
4694 END PROGRAM
4695 @end smallexample
4696
4697 @item @emph{See also}:
4698 @ref{FSEEK}
4699 @end table
4700
4701
4702
4703 @node GAMMA
4704 @section @code{GAMMA} --- Gamma function
4705 @fnindex GAMMA
4706 @fnindex DGAMMA
4707 @cindex Gamma function
4708 @cindex Factorial function
4709
4710 @table @asis
4711 @item @emph{Description}:
4712 @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
4713 integer values of @var{X} the Gamma function simplifies to the factorial
4714 function @math{\Gamma(x)=(x-1)!}.
4715
4716 @tex
4717 $$
4718 \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
4719 $$
4720 @end tex
4721
4722 @item @emph{Standard}:
4723 Fortran 2008 and later
4724
4725 @item @emph{Class}:
4726 Elemental function
4727
4728 @item @emph{Syntax}:
4729 @code{X = GAMMA(X)}
4730
4731 @item @emph{Arguments}:
4732 @multitable @columnfractions .15 .70
4733 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
4734 nor a negative integer.
4735 @end multitable
4736
4737 @item @emph{Return value}:
4738 The return value is of type @code{REAL} of the same kind as @var{X}.
4739
4740 @item @emph{Example}:
4741 @smallexample
4742 program test_gamma
4743   real :: x = 1.0
4744   x = gamma(x) ! returns 1.0
4745 end program test_gamma
4746 @end smallexample
4747
4748 @item @emph{Specific names}:
4749 @multitable @columnfractions .20 .20 .20 .25
4750 @item Name             @tab Argument         @tab Return type       @tab Standard
4751 @item @code{GAMMA(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
4752 @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
4753 @end multitable
4754
4755 @item @emph{See also}:
4756 Logarithm of the Gamma function: @ref{LOG_GAMMA}
4757
4758 @end table
4759
4760
4761
4762 @node GERROR
4763 @section @code{GERROR} --- Get last system error message
4764 @fnindex GERROR
4765 @cindex system, error handling
4766
4767 @table @asis
4768 @item @emph{Description}:
4769 Returns the system error message corresponding to the last system error.
4770 This resembles the functionality of @code{strerror(3)} in C.
4771
4772 @item @emph{Standard}:
4773 GNU extension
4774
4775 @item @emph{Class}:
4776 Subroutine
4777
4778 @item @emph{Syntax}:
4779 @code{CALL GERROR(RESULT)}
4780
4781 @item @emph{Arguments}:
4782 @multitable @columnfractions .15 .70
4783 @item @var{RESULT}  @tab Shall of type @code{CHARACTER} and of default
4784 @end multitable
4785
4786 @item @emph{Example}:
4787 @smallexample
4788 PROGRAM test_gerror
4789   CHARACTER(len=100) :: msg
4790   CALL gerror(msg)
4791   WRITE(*,*) msg
4792 END PROGRAM
4793 @end smallexample
4794
4795 @item @emph{See also}:
4796 @ref{IERRNO}, @ref{PERROR}
4797 @end table
4798
4799
4800
4801 @node GETARG
4802 @section @code{GETARG} --- Get command line arguments
4803 @fnindex GETARG
4804 @cindex command-line arguments
4805 @cindex arguments, to program
4806
4807 @table @asis
4808 @item @emph{Description}:
4809 Retrieve the @var{POS}-th argument that was passed on the
4810 command line when the containing program was invoked.
4811
4812 This intrinsic routine is provided for backwards compatibility with 
4813 GNU Fortran 77.  In new code, programmers should consider the use of 
4814 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003 
4815 standard.
4816
4817 @item @emph{Standard}:
4818 GNU extension
4819
4820 @item @emph{Class}:
4821 Subroutine
4822
4823 @item @emph{Syntax}:
4824 @code{CALL GETARG(POS, VALUE)}
4825
4826 @item @emph{Arguments}:
4827 @multitable @columnfractions .15 .70
4828 @item @var{POS}   @tab Shall be of type @code{INTEGER} and not wider than
4829 the default integer kind; @math{@var{POS} \geq 0}
4830 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
4831 kind.
4832 @item @var{VALUE} @tab Shall be of type @code{CHARACTER}. 
4833 @end multitable
4834
4835 @item @emph{Return value}:
4836 After @code{GETARG} returns, the @var{VALUE} argument holds the
4837 @var{POS}th command line argument. If @var{VALUE} can not hold the
4838 argument, it is truncated to fit the length of @var{VALUE}. If there are
4839 less than @var{POS} arguments specified at the command line, @var{VALUE}
4840 will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
4841 to the name of the program (on systems that support this feature).
4842
4843 @item @emph{Example}:
4844 @smallexample
4845 PROGRAM test_getarg
4846   INTEGER :: i
4847   CHARACTER(len=32) :: arg
4848
4849   DO i = 1, iargc()
4850     CALL getarg(i, arg)
4851     WRITE (*,*) arg
4852   END DO
4853 END PROGRAM
4854 @end smallexample
4855
4856 @item @emph{See also}:
4857 GNU Fortran 77 compatibility function: @ref{IARGC}
4858
4859 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
4860 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4861 @end table
4862
4863
4864
4865 @node GET_COMMAND
4866 @section @code{GET_COMMAND} --- Get the entire command line
4867 @fnindex GET_COMMAND
4868 @cindex command-line arguments
4869 @cindex arguments, to program
4870
4871 @table @asis
4872 @item @emph{Description}:
4873 Retrieve the entire command line that was used to invoke the program.
4874
4875 @item @emph{Standard}:
4876 Fortran 2003 and later
4877
4878 @item @emph{Class}:
4879 Subroutine
4880
4881 @item @emph{Syntax}:
4882 @code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])}
4883
4884 @item @emph{Arguments}:
4885 @multitable @columnfractions .15 .70
4886 @item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and
4887 of default kind.
4888 @item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of
4889 default kind.
4890 @item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of
4891 default kind.
4892 @end multitable
4893
4894 @item @emph{Return value}:
4895 If @var{COMMAND} is present, stores the entire command line that was used
4896 to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is
4897 assigned the length of the command line. If @var{STATUS} is present, it
4898 is assigned 0 upon success of the command, -1 if @var{COMMAND} is too
4899 short to store the command line, or a positive value in case of an error.
4900
4901 @item @emph{Example}:
4902 @smallexample
4903 PROGRAM test_get_command
4904   CHARACTER(len=255) :: cmd
4905   CALL get_command(cmd)
4906   WRITE (*,*) TRIM(cmd)
4907 END PROGRAM
4908 @end smallexample
4909
4910 @item @emph{See also}:
4911 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4912 @end table
4913
4914
4915
4916 @node GET_COMMAND_ARGUMENT
4917 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4918 @fnindex GET_COMMAND_ARGUMENT
4919 @cindex command-line arguments
4920 @cindex arguments, to program
4921
4922 @table @asis
4923 @item @emph{Description}:
4924 Retrieve the @var{NUMBER}-th argument that was passed on the
4925 command line when the containing program was invoked.
4926
4927 @item @emph{Standard}:
4928 Fortran 2003 and later
4929
4930 @item @emph{Class}:
4931 Subroutine
4932
4933 @item @emph{Syntax}:
4934 @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
4935
4936 @item @emph{Arguments}:
4937 @multitable @columnfractions .15 .70
4938 @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of
4939 default kind, @math{@var{NUMBER} \geq 0}
4940 @item @var{VALUE}  @tab Shall be a scalar of type @code{CHARACTER}
4941 and of default kind.
4942 @item @var{LENGTH} @tab (Option) Shall be a scalar of type @code{INTEGER}
4943 and of default kind.
4944 @item @var{STATUS} @tab (Option) Shall be a scalar of type @code{INTEGER}
4945 and of default kind.
4946 @end multitable
4947
4948 @item @emph{Return value}:
4949 After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the 
4950 @var{NUMBER}-th command line argument. If @var{VALUE} can not hold the argument, it is 
4951 truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
4952 arguments specified at the command line, @var{VALUE} will be filled with blanks. 
4953 If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on
4954 systems that support this feature). The @var{LENGTH} argument contains the
4955 length of the @var{NUMBER}-th command line argument. If the argument retrieval
4956 fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated
4957 command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is
4958 zero.
4959
4960 @item @emph{Example}:
4961 @smallexample
4962 PROGRAM test_get_command_argument
4963   INTEGER :: i
4964   CHARACTER(len=32) :: arg
4965
4966   i = 0
4967   DO
4968     CALL get_command_argument(i, arg)
4969     IF (LEN_TRIM(arg) == 0) EXIT
4970
4971     WRITE (*,*) TRIM(arg)
4972     i = i+1
4973   END DO
4974 END PROGRAM
4975 @end smallexample
4976
4977 @item @emph{See also}:
4978 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4979 @end table
4980
4981
4982
4983 @node GETCWD
4984 @section @code{GETCWD} --- Get current working directory
4985 @fnindex GETCWD
4986 @cindex system, working directory
4987
4988 @table @asis
4989 @item @emph{Description}:
4990 Get current working directory.
4991
4992 This intrinsic is provided in both subroutine and function forms; however,
4993 only one form can be used in any given program unit.
4994
4995 @item @emph{Standard}:
4996 GNU extension
4997
4998 @item @emph{Class}:
4999 Subroutine, function
5000
5001 @item @emph{Syntax}:
5002 @code{CALL GETCWD(C [, STATUS])}
5003
5004 @item @emph{Arguments}:
5005 @multitable @columnfractions .15 .70
5006 @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
5007 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success, 
5008 a system specific and nonzero error code otherwise.
5009 @end multitable
5010
5011 @item @emph{Example}:
5012 @smallexample
5013 PROGRAM test_getcwd
5014   CHARACTER(len=255) :: cwd
5015   CALL getcwd(cwd)
5016   WRITE(*,*) TRIM(cwd)
5017 END PROGRAM
5018 @end smallexample
5019
5020 @item @emph{See also}:
5021 @ref{CHDIR}
5022 @end table
5023
5024
5025
5026 @node GETENV
5027 @section @code{GETENV} --- Get an environmental variable
5028 @fnindex GETENV
5029 @cindex environment variable
5030
5031 @table @asis
5032 @item @emph{Description}:
5033 Get the @var{VALUE} of the environmental variable @var{NAME}.
5034
5035 This intrinsic routine is provided for backwards compatibility with 
5036 GNU Fortran 77.  In new code, programmers should consider the use of 
5037 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
5038 2003 standard.
5039
5040 @item @emph{Standard}:
5041 GNU extension
5042
5043 @item @emph{Class}:
5044 Subroutine
5045
5046 @item @emph{Syntax}:
5047 @code{CALL GETENV(NAME, VALUE)}
5048
5049 @item @emph{Arguments}:
5050 @multitable @columnfractions .15 .70
5051 @item @var{NAME}  @tab Shall be of type @code{CHARACTER} and of default kind.
5052 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
5053 @end multitable
5054
5055 @item @emph{Return value}:
5056 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
5057 not large enough to hold the data, it is truncated. If @var{NAME}
5058 is not set, @var{VALUE} will be filled with blanks.
5059
5060 @item @emph{Example}:
5061 @smallexample
5062 PROGRAM test_getenv
5063   CHARACTER(len=255) :: homedir
5064   CALL getenv("HOME", homedir)
5065   WRITE (*,*) TRIM(homedir)
5066 END PROGRAM
5067 @end smallexample
5068
5069 @item @emph{See also}:
5070 @ref{GET_ENVIRONMENT_VARIABLE}
5071 @end table
5072
5073
5074
5075 @node GET_ENVIRONMENT_VARIABLE
5076 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
5077 @fnindex GET_ENVIRONMENT_VARIABLE
5078 @cindex environment variable
5079
5080 @table @asis
5081 @item @emph{Description}:
5082 Get the @var{VALUE} of the environmental variable @var{NAME}.
5083
5084 @item @emph{Standard}:
5085 Fortran 2003 and later
5086
5087 @item @emph{Class}:
5088 Subroutine
5089
5090 @item @emph{Syntax}:
5091 @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
5092
5093 @item @emph{Arguments}:
5094 @multitable @columnfractions .15 .70
5095 @item @var{NAME}      @tab Shall be a scalar of type @code{CHARACTER}
5096 and of default kind.
5097 @item @var{VALUE}     @tab Shall be a scalar of type @code{CHARACTER}
5098 and of default kind.
5099 @item @var{LENGTH}    @tab Shall be a scalar of type @code{INTEGER}
5100 and of default kind.
5101 @item @var{STATUS}    @tab Shall be a scalar of type @code{INTEGER}
5102 and of default kind.
5103 @item @var{TRIM_NAME} @tab Shall be a scalar of type @code{LOGICAL}
5104 and of default kind.
5105 @end multitable
5106
5107 @item @emph{Return value}:
5108 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
5109 not large enough to hold the data, it is truncated. If @var{NAME}
5110 is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
5111 contains the length needed for storing the environment variable @var{NAME}
5112 or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
5113 but too short for the environment variable; it is 1 if the environment
5114 variable does not exist and 2 if the processor does not support environment
5115 variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
5116 present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
5117 are significant; otherwise they are not part of the environment variable
5118 name.
5119
5120 @item @emph{Example}:
5121 @smallexample
5122 PROGRAM test_getenv
5123   CHARACTER(len=255) :: homedir
5124   CALL get_environment_variable("HOME", homedir)
5125   WRITE (*,*) TRIM(homedir)
5126 END PROGRAM
5127 @end smallexample
5128 @end table
5129
5130
5131
5132 @node GETGID
5133 @section @code{GETGID} --- Group ID function
5134 @fnindex GETGID
5135 @cindex system, group id
5136
5137 @table @asis
5138 @item @emph{Description}:
5139 Returns the numerical group ID of the current process.
5140
5141 @item @emph{Standard}:
5142 GNU extension
5143
5144 @item @emph{Class}:
5145 Function
5146
5147 @item @emph{Syntax}:
5148 @code{RESULT = GETGID()}
5149
5150 @item @emph{Return value}:
5151 The return value of @code{GETGID} is an @code{INTEGER} of the default
5152 kind.
5153
5154
5155 @item @emph{Example}:
5156 See @code{GETPID} for an example.
5157
5158 @item @emph{See also}:
5159 @ref{GETPID}, @ref{GETUID}
5160 @end table
5161
5162
5163
5164 @node GETLOG
5165 @section @code{GETLOG} --- Get login name
5166 @fnindex GETLOG
5167 @cindex system, login name
5168 @cindex login name
5169
5170 @table @asis
5171 @item @emph{Description}:
5172 Gets the username under which the program is running.
5173
5174 @item @emph{Standard}:
5175 GNU extension
5176
5177 @item @emph{Class}:
5178 Subroutine
5179
5180 @item @emph{Syntax}:
5181 @code{CALL GETLOG(C)}
5182
5183 @item @emph{Arguments}:
5184 @multitable @columnfractions .15 .70
5185 @item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
5186 @end multitable
5187
5188 @item @emph{Return value}:
5189 Stores the current user name in @var{LOGIN}.  (On systems where POSIX
5190 functions @code{geteuid} and @code{getpwuid} are not available, and 
5191 the @code{getlogin} function is not implemented either, this will
5192 return a blank string.)
5193
5194 @item @emph{Example}:
5195 @smallexample
5196 PROGRAM TEST_GETLOG
5197   CHARACTER(32) :: login
5198   CALL GETLOG(login)
5199   WRITE(*,*) login
5200 END PROGRAM
5201 @end smallexample
5202
5203 @item @emph{See also}:
5204 @ref{GETUID}
5205 @end table
5206
5207
5208
5209 @node GETPID
5210 @section @code{GETPID} --- Process ID function
5211 @fnindex GETPID
5212 @cindex system, process id
5213 @cindex process id
5214
5215 @table @asis
5216 @item @emph{Description}:
5217 Returns the numerical process identifier of the current process.
5218
5219 @item @emph{Standard}:
5220 GNU extension
5221
5222 @item @emph{Class}:
5223 Function
5224
5225 @item @emph{Syntax}:
5226 @code{RESULT = GETPID()}
5227
5228 @item @emph{Return value}:
5229 The return value of @code{GETPID} is an @code{INTEGER} of the default
5230 kind.
5231
5232
5233 @item @emph{Example}:
5234 @smallexample
5235 program info
5236   print *, "The current process ID is ", getpid()
5237   print *, "Your numerical user ID is ", getuid()
5238   print *, "Your numerical group ID is ", getgid()
5239 end program info
5240 @end smallexample
5241
5242 @item @emph{See also}:
5243 @ref{GETGID}, @ref{GETUID}
5244 @end table
5245
5246
5247
5248 @node GETUID
5249 @section @code{GETUID} --- User ID function
5250 @fnindex GETUID
5251 @cindex system, user id
5252 @cindex user id
5253
5254 @table @asis
5255 @item @emph{Description}:
5256 Returns the numerical user ID of the current process.
5257
5258 @item @emph{Standard}:
5259 GNU extension
5260
5261 @item @emph{Class}:
5262 Function
5263
5264 @item @emph{Syntax}:
5265 @code{RESULT = GETUID()}
5266
5267 @item @emph{Return value}:
5268 The return value of @code{GETUID} is an @code{INTEGER} of the default
5269 kind.
5270
5271
5272 @item @emph{Example}:
5273 See @code{GETPID} for an example.
5274
5275 @item @emph{See also}:
5276 @ref{GETPID}, @ref{GETLOG}
5277 @end table
5278
5279
5280
5281 @node GMTIME
5282 @section @code{GMTIME} --- Convert time to GMT info
5283 @fnindex GMTIME
5284 @cindex time, conversion to GMT info
5285
5286 @table @asis
5287 @item @emph{Description}:
5288 Given a system time value @var{TIME} (as provided by the @code{TIME8()}
5289 intrinsic), fills @var{VALUES} with values extracted from it appropriate
5290 to the UTC time zone (Universal Coordinated Time, also known in some
5291 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
5292
5293 @item @emph{Standard}:
5294 GNU extension
5295
5296 @item @emph{Class}:
5297 Subroutine
5298
5299 @item @emph{Syntax}:
5300 @code{CALL GMTIME(TIME, VALUES)}
5301
5302 @item @emph{Arguments}:
5303 @multitable @columnfractions .15 .70
5304 @item @var{TIME}   @tab An @code{INTEGER} scalar expression
5305 corresponding to a system time, with @code{INTENT(IN)}.
5306 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
5307 with @code{INTENT(OUT)}.
5308 @end multitable
5309
5310 @item @emph{Return value}:
5311 The elements of @var{VALUES} are assigned as follows:
5312 @enumerate
5313 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
5314 seconds
5315 @item Minutes after the hour, range 0--59
5316 @item Hours past midnight, range 0--23
5317 @item Day of month, range 0--31
5318 @item Number of months since January, range 0--12
5319 @item Years since 1900
5320 @item Number of days since Sunday, range 0--6
5321 @item Days since January 1
5322 @item Daylight savings indicator: positive if daylight savings is in
5323 effect, zero if not, and negative if the information is not available.
5324 @end enumerate
5325
5326 @item @emph{See also}:
5327 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
5328
5329 @end table
5330
5331
5332
5333 @node HOSTNM
5334 @section @code{HOSTNM} --- Get system host name
5335 @fnindex HOSTNM
5336 @cindex system, host name
5337
5338 @table @asis
5339 @item @emph{Description}:
5340 Retrieves the host name of the system on which the program is running.
5341
5342 This intrinsic is provided in both subroutine and function forms; however,
5343 only one form can be used in any given program unit.
5344
5345 @item @emph{Standard}:
5346 GNU extension
5347
5348 @item @emph{Class}:
5349 Subroutine, function
5350
5351 @item @emph{Syntax}:
5352 @multitable @columnfractions .80
5353 @item @code{CALL HOSTNM(C [, STATUS])}
5354 @item @code{STATUS = HOSTNM(NAME)}
5355 @end multitable
5356
5357 @item @emph{Arguments}:
5358 @multitable @columnfractions .15 .70
5359 @item @var{C}    @tab Shall of type @code{CHARACTER} and of default kind.
5360 @item @var{STATUS}  @tab (Optional) status flag of type @code{INTEGER}.
5361 Returns 0 on success, or a system specific error code otherwise.
5362 @end multitable
5363
5364 @item @emph{Return value}:
5365 In either syntax, @var{NAME} is set to the current hostname if it can
5366 be obtained, or to a blank string otherwise.
5367
5368 @end table
5369
5370
5371
5372 @node HUGE
5373 @section @code{HUGE} --- Largest number of a kind
5374 @fnindex HUGE
5375 @cindex limits, largest number
5376 @cindex model representation, largest number
5377
5378 @table @asis
5379 @item @emph{Description}:
5380 @code{HUGE(X)} returns the largest number that is not an infinity in
5381 the model of the type of @code{X}.
5382
5383 @item @emph{Standard}:
5384 Fortran 95 and later
5385
5386 @item @emph{Class}:
5387 Inquiry function
5388
5389 @item @emph{Syntax}:
5390 @code{RESULT = HUGE(X)}
5391
5392 @item @emph{Arguments}:
5393 @multitable @columnfractions .15 .70
5394 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
5395 @end multitable
5396
5397 @item @emph{Return value}:
5398 The return value is of the same type and kind as @var{X}
5399
5400 @item @emph{Example}:
5401 @smallexample
5402 program test_huge_tiny
5403   print *, huge(0), huge(0.0), huge(0.0d0)
5404   print *, tiny(0.0), tiny(0.0d0)
5405 end program test_huge_tiny
5406 @end smallexample
5407 @end table
5408
5409
5410
5411 @node HYPOT
5412 @section @code{HYPOT} --- Euclidean distance function
5413 @fnindex HYPOT
5414 @cindex Euclidean distance
5415
5416 @table @asis
5417 @item @emph{Description}:
5418 @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
5419 @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
5420
5421 @item @emph{Standard}:
5422 Fortran 2008 and later
5423
5424 @item @emph{Class}:
5425 Elemental function
5426
5427 @item @emph{Syntax}:
5428 @code{RESULT = HYPOT(X, Y)}
5429
5430 @item @emph{Arguments}:
5431 @multitable @columnfractions .15 .70
5432 @item @var{X} @tab The type shall be @code{REAL}.
5433 @item @var{Y} @tab The type and kind type parameter shall be the same as
5434 @var{X}.
5435 @end multitable
5436
5437 @item @emph{Return value}:
5438 The return value has the same type and kind type parameter as @var{X}.
5439
5440 @item @emph{Example}:
5441 @smallexample
5442 program test_hypot
5443   real(4) :: x = 1.e0_4, y = 0.5e0_4
5444   x = hypot(x,y)
5445 end program test_hypot
5446 @end smallexample
5447 @end table
5448
5449
5450
5451 @node IACHAR
5452 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence 
5453 @fnindex IACHAR
5454 @cindex @acronym{ASCII} collating sequence
5455 @cindex collating sequence, @acronym{ASCII}
5456 @cindex conversion, to integer
5457
5458 @table @asis
5459 @item @emph{Description}:
5460 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
5461 in the first character position of @code{C}.
5462
5463 @item @emph{Standard}:
5464 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
5465
5466 @item @emph{Class}:
5467 Elemental function
5468
5469 @item @emph{Syntax}:
5470 @code{RESULT = IACHAR(C [, KIND])}
5471
5472 @item @emph{Arguments}:
5473 @multitable @columnfractions .15 .70
5474 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5475 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5476 expression indicating the kind parameter of the result.
5477 @end multitable
5478
5479 @item @emph{Return value}:
5480 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5481 @var{KIND} is absent, the return value is of default integer kind.
5482
5483 @item @emph{Example}:
5484 @smallexample
5485 program test_iachar
5486   integer i
5487   i = iachar(' ')
5488 end program test_iachar
5489 @end smallexample
5490
5491 @item @emph{Note}:
5492 See @ref{ICHAR} for a discussion of converting between numerical values
5493 and formatted string representations.
5494
5495 @item @emph{See also}:
5496 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
5497
5498 @end table
5499
5500
5501
5502 @node IAND
5503 @section @code{IAND} --- Bitwise logical and
5504 @fnindex IAND
5505 @cindex bitwise logical and
5506 @cindex logical and, bitwise
5507
5508 @table @asis
5509 @item @emph{Description}:
5510 Bitwise logical @code{AND}.
5511
5512 @item @emph{Standard}:
5513 Fortran 95 and later
5514
5515 @item @emph{Class}:
5516 Elemental function
5517
5518 @item @emph{Syntax}:
5519 @code{RESULT = IAND(I, J)}
5520
5521 @item @emph{Arguments}:
5522 @multitable @columnfractions .15 .70
5523 @item @var{I} @tab The type shall be @code{INTEGER}.
5524 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
5525 kind as @var{I}.  (As a GNU extension, different kinds are also 
5526 permitted.)
5527 @end multitable
5528
5529 @item @emph{Return value}:
5530 The return type is @code{INTEGER}, of the same kind as the
5531 arguments.  (If the argument kinds differ, it is of the same kind as
5532 the larger argument.)
5533
5534 @item @emph{Example}:
5535 @smallexample
5536 PROGRAM test_iand
5537   INTEGER :: a, b
5538   DATA a / Z'F' /, b / Z'3' /
5539   WRITE (*,*) IAND(a, b)
5540 END PROGRAM
5541 @end smallexample
5542
5543 @item @emph{See also}:
5544 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5545
5546 @end table
5547
5548
5549
5550 @node IARGC
5551 @section @code{IARGC} --- Get the number of command line arguments
5552 @fnindex IARGC
5553 @cindex command-line arguments
5554 @cindex command-line arguments, number of
5555 @cindex arguments, to program
5556
5557 @table @asis
5558 @item @emph{Description}:
5559 @code{IARGC()} returns the number of arguments passed on the
5560 command line when the containing program was invoked.
5561
5562 This intrinsic routine is provided for backwards compatibility with 
5563 GNU Fortran 77.  In new code, programmers should consider the use of 
5564 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003 
5565 standard.
5566
5567 @item @emph{Standard}:
5568 GNU extension
5569
5570 @item @emph{Class}:
5571 Function
5572
5573 @item @emph{Syntax}:
5574 @code{RESULT = IARGC()}
5575
5576 @item @emph{Arguments}:
5577 None.
5578
5579 @item @emph{Return value}:
5580 The number of command line arguments, type @code{INTEGER(4)}.
5581
5582 @item @emph{Example}:
5583 See @ref{GETARG}
5584
5585 @item @emph{See also}:
5586 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
5587
5588 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
5589 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
5590 @end table
5591
5592
5593
5594 @node IBCLR
5595 @section @code{IBCLR} --- Clear bit
5596 @fnindex IBCLR
5597 @cindex bits, unset
5598 @cindex bits, clear
5599
5600 @table @asis
5601 @item @emph{Description}:
5602 @code{IBCLR} returns the value of @var{I} with the bit at position
5603 @var{POS} set to zero.
5604
5605 @item @emph{Standard}:
5606 Fortran 95 and later
5607
5608 @item @emph{Class}:
5609 Elemental function
5610
5611 @item @emph{Syntax}:
5612 @code{RESULT = IBCLR(I, POS)}
5613
5614 @item @emph{Arguments}:
5615 @multitable @columnfractions .15 .70
5616 @item @var{I} @tab The type shall be @code{INTEGER}.
5617 @item @var{POS} @tab The type shall be @code{INTEGER}.
5618 @end multitable
5619
5620 @item @emph{Return value}:
5621 The return value is of type @code{INTEGER} and of the same kind as
5622 @var{I}.
5623
5624 @item @emph{See also}:
5625 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
5626
5627 @end table
5628
5629
5630
5631 @node IBITS
5632 @section @code{IBITS} --- Bit extraction
5633 @fnindex IBITS
5634 @cindex bits, get
5635 @cindex bits, extract
5636
5637 @table @asis
5638 @item @emph{Description}:
5639 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
5640 starting from bit position @var{POS} and extending left for @var{LEN}
5641 bits.  The result is right-justified and the remaining bits are
5642 zeroed.  The value of @code{POS+LEN} must be less than or equal to the
5643 value @code{BIT_SIZE(I)}.
5644
5645 @item @emph{Standard}:
5646 Fortran 95 and later
5647
5648 @item @emph{Class}:
5649 Elemental function
5650
5651 @item @emph{Syntax}:
5652 @code{RESULT = IBITS(I, POS, LEN)}
5653
5654 @item @emph{Arguments}:
5655 @multitable @columnfractions .15 .70
5656 @item @var{I}   @tab The type shall be @code{INTEGER}.
5657 @item @var{POS} @tab The type shall be @code{INTEGER}.
5658 @item @var{LEN} @tab The type shall be @code{INTEGER}.
5659 @end multitable
5660
5661 @item @emph{Return value}:
5662 The return value is of type @code{INTEGER} and of the same kind as
5663 @var{I}.
5664
5665 @item @emph{See also}:
5666 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
5667 @end table
5668
5669
5670
5671 @node IBSET
5672 @section @code{IBSET} --- Set bit
5673 @fnindex IBSET
5674 @cindex bits, set
5675
5676 @table @asis
5677 @item @emph{Description}:
5678 @code{IBSET} returns the value of @var{I} with the bit at position
5679 @var{POS} set to one.
5680
5681 @item @emph{Standard}:
5682 Fortran 95 and later
5683
5684 @item @emph{Class}:
5685 Elemental function
5686
5687 @item @emph{Syntax}:
5688 @code{RESULT = IBSET(I, POS)}
5689
5690 @item @emph{Arguments}:
5691 @multitable @columnfractions .15 .70
5692 @item @var{I} @tab The type shall be @code{INTEGER}.
5693 @item @var{POS} @tab The type shall be @code{INTEGER}.
5694 @end multitable
5695
5696 @item @emph{Return value}:
5697 The return value is of type @code{INTEGER} and of the same kind as
5698 @var{I}.
5699
5700 @item @emph{See also}:
5701 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
5702
5703 @end table
5704
5705
5706
5707 @node ICHAR
5708 @section @code{ICHAR} --- Character-to-integer conversion function
5709 @fnindex ICHAR
5710 @cindex conversion, to integer
5711
5712 @table @asis
5713 @item @emph{Description}:
5714 @code{ICHAR(C)} returns the code for the character in the first character
5715 position of @code{C} in the system's native character set.
5716 The correspondence between characters and their codes is not necessarily
5717 the same across different GNU Fortran implementations.
5718
5719 @item @emph{Standard}:
5720 Fortan 95 and later, with @var{KIND} argument Fortran 2003 and later
5721
5722 @item @emph{Class}:
5723 Elemental function
5724
5725 @item @emph{Syntax}:
5726 @code{RESULT = ICHAR(C [, KIND])}
5727
5728 @item @emph{Arguments}:
5729 @multitable @columnfractions .15 .70
5730 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5731 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5732 expression indicating the kind parameter of the result.
5733 @end multitable
5734
5735 @item @emph{Return value}:
5736 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5737 @var{KIND} is absent, the return value is of default integer kind.
5738
5739 @item @emph{Example}:
5740 @smallexample
5741 program test_ichar
5742   integer i
5743   i = ichar(' ')
5744 end program test_ichar
5745 @end smallexample
5746
5747 @item @emph{Specific names}:
5748 @multitable @columnfractions .20 .20 .20 .25
5749 @item Name             @tab Argument             @tab Return type       @tab Standard
5750 @item @code{ICHAR(C)}  @tab @code{CHARACTER C}   @tab @code{INTEGER(4)}    @tab Fortran 77 and later
5751 @end multitable
5752
5753 @item @emph{Note}:
5754 No intrinsic exists to convert between a numeric value and a formatted
5755 character string representation -- for instance, given the
5756 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
5757 @code{REAL} value with the value 154, or vice versa. Instead, this
5758 functionality is provided by internal-file I/O, as in the following
5759 example:
5760 @smallexample
5761 program read_val
5762   integer value
5763   character(len=10) string, string2
5764   string = '154'
5765   
5766   ! Convert a string to a numeric value
5767   read (string,'(I10)') value
5768   print *, value
5769   
5770   ! Convert a value to a formatted string
5771   write (string2,'(I10)') value
5772   print *, string2
5773 end program read_val
5774 @end smallexample
5775
5776 @item @emph{See also}:
5777 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
5778
5779 @end table
5780
5781
5782
5783 @node IDATE
5784 @section @code{IDATE} --- Get current local time subroutine (day/month/year) 
5785 @fnindex IDATE
5786 @cindex date, current
5787 @cindex current date
5788
5789 @table @asis
5790 @item @emph{Description}:
5791 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the  
5792 current local time. The day (in the range 1-31), month (in the range 1-12), 
5793 and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively. 
5794 The year has four significant digits.
5795
5796 @item @emph{Standard}:
5797 GNU extension
5798
5799 @item @emph{Class}:
5800 Subroutine
5801
5802 @item @emph{Syntax}:
5803 @code{CALL IDATE(VALUES)}
5804
5805 @item @emph{Arguments}:
5806 @multitable @columnfractions .15 .70
5807 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
5808 the kind shall be the default integer kind.
5809 @end multitable
5810
5811 @item @emph{Return value}:
5812 Does not return anything.
5813
5814 @item @emph{Example}:
5815 @smallexample
5816 program test_idate
5817   integer, dimension(3) :: tarray
5818   call idate(tarray)
5819   print *, tarray(1)
5820   print *, tarray(2)
5821   print *, tarray(3)
5822 end program test_idate
5823 @end smallexample
5824 @end table
5825
5826
5827
5828 @node IEOR
5829 @section @code{IEOR} --- Bitwise logical exclusive or
5830 @fnindex IEOR
5831 @cindex bitwise logical exclusive or
5832 @cindex logical exclusive or, bitwise
5833
5834 @table @asis
5835 @item @emph{Description}:
5836 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
5837 @var{J}.
5838
5839 @item @emph{Standard}:
5840 Fortran 95 and later
5841
5842 @item @emph{Class}:
5843 Elemental function
5844
5845 @item @emph{Syntax}:
5846 @code{RESULT = IEOR(I, J)}
5847
5848 @item @emph{Arguments}:
5849 @multitable @columnfractions .15 .70
5850 @item @var{I} @tab The type shall be @code{INTEGER}.
5851 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
5852 kind as @var{I}.  (As a GNU extension, different kinds are also 
5853 permitted.)
5854 @end multitable
5855
5856 @item @emph{Return value}:
5857 The return type is @code{INTEGER}, of the same kind as the
5858 arguments.  (If the argument kinds differ, it is of the same kind as
5859 the larger argument.)
5860
5861 @item @emph{See also}:
5862 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5863 @end table
5864
5865
5866
5867 @node IERRNO
5868 @section @code{IERRNO} --- Get the last system error number
5869 @fnindex IERRNO
5870 @cindex system, error handling
5871
5872 @table @asis
5873 @item @emph{Description}:
5874 Returns the last system error number, as given by the C @code{errno()}
5875 function.
5876
5877 @item @emph{Standard}:
5878 GNU extension
5879
5880 @item @emph{Class}:
5881 Function
5882
5883 @item @emph{Syntax}:
5884 @code{RESULT = IERRNO()}
5885
5886 @item @emph{Arguments}:
5887 None.
5888
5889 @item @emph{Return value}:
5890 The return value is of type @code{INTEGER} and of the default integer
5891 kind.
5892
5893 @item @emph{See also}:
5894 @ref{PERROR}
5895 @end table
5896
5897
5898
5899 @node INDEX intrinsic
5900 @section @code{INDEX} --- Position of a substring within a string
5901 @fnindex INDEX
5902 @cindex substring position
5903 @cindex string, find substring
5904
5905 @table @asis
5906 @item @emph{Description}:
5907 Returns the position of the start of the first occurrence of string
5908 @var{SUBSTRING} as a substring in @var{STRING}, counting from one.  If
5909 @var{SUBSTRING} is not present in @var{STRING}, zero is returned.  If 
5910 the @var{BACK} argument is present and true, the return value is the
5911 start of the last occurrence rather than the first.
5912
5913 @item @emph{Standard}:
5914 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
5915
5916 @item @emph{Class}:
5917 Elemental function
5918
5919 @item @emph{Syntax}:
5920 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
5921
5922 @item @emph{Arguments}:
5923 @multitable @columnfractions .15 .70
5924 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
5925 @code{INTENT(IN)}
5926 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
5927 @code{INTENT(IN)}
5928 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
5929 @code{INTENT(IN)}
5930 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5931 expression indicating the kind parameter of the result.
5932 @end multitable
5933
5934 @item @emph{Return value}:
5935 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5936 @var{KIND} is absent, the return value is of default integer kind.
5937
5938 @item @emph{Specific names}:
5939 @multitable @columnfractions .20 .20 .20 .25
5940 @item Name                            @tab Argument           @tab Return type       @tab Standard
5941 @item @code{INDEX(STRING, SUBSTRING)} @tab @code{CHARACTER}   @tab @code{INTEGER(4)} @tab Fortran 77 and later
5942 @end multitable
5943
5944 @item @emph{See also}:
5945 @ref{SCAN}, @ref{VERIFY}
5946 @end table
5947
5948
5949
5950 @node INT
5951 @section @code{INT} --- Convert to integer type
5952 @fnindex INT
5953 @fnindex IFIX
5954 @fnindex IDINT
5955 @cindex conversion, to integer
5956
5957 @table @asis
5958 @item @emph{Description}:
5959 Convert to integer type
5960
5961 @item @emph{Standard}:
5962 Fortran 77 and later
5963
5964 @item @emph{Class}:
5965 Elemental function
5966
5967 @item @emph{Syntax}:
5968 @code{RESULT = INT(A [, KIND))}
5969
5970 @item @emph{Arguments}:
5971 @multitable @columnfractions .15 .70
5972 @item @var{A}    @tab Shall be of type @code{INTEGER},
5973 @code{REAL}, or @code{COMPLEX}.
5974 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5975 expression indicating the kind parameter of the result.
5976 @end multitable
5977
5978 @item @emph{Return value}:
5979 These functions return a @code{INTEGER} variable or array under 
5980 the following rules: 
5981
5982 @table @asis
5983 @item (A)
5984 If @var{A} is of type @code{INTEGER}, @code{INT(A) = A} 
5985 @item (B)
5986 If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} equals @code{0}. 
5987 If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed 
5988 the range of @var{A} and whose sign is the same as the sign of @var{A}.
5989 @item (C)
5990 If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
5991 @end table
5992
5993 @item @emph{Example}:
5994 @smallexample
5995 program test_int
5996   integer :: i = 42
5997   complex :: z = (-3.7, 1.0)
5998   print *, int(i)
5999   print *, int(z), int(z,8)
6000 end program
6001 @end smallexample
6002
6003 @item @emph{Specific names}:
6004 @multitable @columnfractions .20 .20 .20 .25
6005 @item Name            @tab Argument          @tab Return type       @tab Standard
6006 @item @code{INT(A)}   @tab @code{REAL(4) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
6007 @item @code{IFIX(A)}  @tab @code{REAL(4) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
6008 @item @code{IDINT(A)} @tab @code{REAL(8) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
6009 @end multitable
6010
6011 @end table
6012
6013
6014 @node INT2
6015 @section @code{INT2} --- Convert to 16-bit integer type
6016 @fnindex INT2
6017 @fnindex SHORT
6018 @cindex conversion, to integer
6019
6020 @table @asis
6021 @item @emph{Description}:
6022 Convert to a @code{KIND=2} integer type. This is equivalent to the
6023 standard @code{INT} intrinsic with an optional argument of
6024 @code{KIND=2}, and is only included for backwards compatibility.
6025
6026 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
6027
6028 @item @emph{Standard}:
6029 GNU extension
6030
6031 @item @emph{Class}:
6032 Elemental function
6033
6034 @item @emph{Syntax}:
6035 @code{RESULT = INT2(A)}
6036
6037 @item @emph{Arguments}:
6038 @multitable @columnfractions .15 .70
6039 @item @var{A}    @tab Shall be of type @code{INTEGER},
6040 @code{REAL}, or @code{COMPLEX}.
6041 @end multitable
6042
6043 @item @emph{Return value}:
6044 The return value is a @code{INTEGER(2)} variable.
6045
6046 @item @emph{See also}:
6047 @ref{INT}, @ref{INT8}, @ref{LONG}
6048 @end table
6049
6050
6051
6052 @node INT8
6053 @section @code{INT8} --- Convert to 64-bit integer type
6054 @fnindex INT8
6055 @cindex conversion, to integer
6056
6057 @table @asis
6058 @item @emph{Description}:
6059 Convert to a @code{KIND=8} integer type. This is equivalent to the
6060 standard @code{INT} intrinsic with an optional argument of
6061 @code{KIND=8}, and is only included for backwards compatibility.
6062
6063 @item @emph{Standard}:
6064 GNU extension
6065
6066 @item @emph{Class}:
6067 Elemental function
6068
6069 @item @emph{Syntax}:
6070 @code{RESULT = INT8(A)}
6071
6072 @item @emph{Arguments}:
6073 @multitable @columnfractions .15 .70
6074 @item @var{A}    @tab Shall be of type @code{INTEGER},
6075 @code{REAL}, or @code{COMPLEX}.
6076 @end multitable
6077
6078 @item @emph{Return value}:
6079 The return value is a @code{INTEGER(8)} variable.
6080
6081 @item @emph{See also}:
6082 @ref{INT}, @ref{INT2}, @ref{LONG}
6083 @end table
6084
6085
6086
6087 @node IOR
6088 @section @code{IOR} --- Bitwise logical or
6089 @fnindex IOR
6090 @cindex bitwise logical or
6091 @cindex logical or, bitwise
6092
6093 @table @asis
6094 @item @emph{Description}:
6095 @code{IOR} returns the bitwise boolean inclusive-OR of @var{I} and
6096 @var{J}.
6097
6098 @item @emph{Standard}:
6099 Fortran 95 and later
6100
6101 @item @emph{Class}:
6102 Elemental function
6103
6104 @item @emph{Syntax}:
6105 @code{RESULT = IOR(I, J)}
6106
6107 @item @emph{Arguments}:
6108 @multitable @columnfractions .15 .70
6109 @item @var{I} @tab The type shall be @code{INTEGER}.
6110 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6111 kind as @var{I}.  (As a GNU extension, different kinds are also 
6112 permitted.)
6113 @end multitable
6114
6115 @item @emph{Return value}:
6116 The return type is @code{INTEGER}, of the same kind as the
6117 arguments.  (If the argument kinds differ, it is of the same kind as
6118 the larger argument.)
6119
6120 @item @emph{See also}:
6121 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6122 @end table
6123
6124
6125
6126 @node IRAND
6127 @section @code{IRAND} --- Integer pseudo-random number
6128 @fnindex IRAND
6129 @cindex random number generation
6130
6131 @table @asis
6132 @item @emph{Description}:
6133 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
6134 distribution between 0 and a system-dependent limit (which is in most
6135 cases 2147483647). If @var{FLAG} is 0, the next number
6136 in the current sequence is returned; if @var{FLAG} is 1, the generator
6137 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
6138 it is used as a new seed with @code{SRAND}.
6139
6140 This intrinsic routine is provided for backwards compatibility with
6141 GNU Fortran 77. It implements a simple modulo generator as provided 
6142 by @command{g77}. For new code, one should consider the use of 
6143 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
6144
6145 @item @emph{Standard}:
6146 GNU extension
6147
6148 @item @emph{Class}:
6149 Function
6150
6151 @item @emph{Syntax}:
6152 @code{RESULT = IRAND(I)}
6153
6154 @item @emph{Arguments}:
6155 @multitable @columnfractions .15 .70
6156 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
6157 @end multitable
6158
6159 @item @emph{Return value}:
6160 The return value is of @code{INTEGER(kind=4)} type.
6161
6162 @item @emph{Example}:
6163 @smallexample
6164 program test_irand
6165   integer,parameter :: seed = 86456
6166   
6167   call srand(seed)
6168   print *, irand(), irand(), irand(), irand()
6169   print *, irand(seed), irand(), irand(), irand()
6170 end program test_irand
6171 @end smallexample
6172
6173 @end table
6174
6175
6176
6177 @node IMAGE_INDEX
6178 @section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index
6179 @fnindex IMAGE_INDEX
6180 @cindex coarray, IMAGE_INDEX
6181 @cindex images, cosubscript to image index conversion
6182
6183 @table @asis
6184 @item @emph{Description}:
6185 Returns the image index belonging to a cosubscript.
6186
6187 @item @emph{Standard}:
6188 Fortran 2008 and later
6189
6190 @item @emph{Class}:
6191 Inquiry function.
6192
6193 @item @emph{Syntax}:
6194 @code{RESULT = IMAGE_INDEX(COARRAY, SUB)}
6195
6196 @item @emph{Arguments}: None.
6197 @multitable @columnfractions .15 .70
6198 @item @var{COARRAY} @tab Coarray of any type.
6199 @item @var{SUB}     @tab default integer rank-1 array of a size equal to
6200 the corank of @var{COARRAY}.
6201 @end multitable
6202
6203
6204 @item @emph{Return value}:
6205 Scalar default integer with the value of the image index which corresponds
6206 to the cosubscripts. For invalid cosubscripts the result is zero.
6207
6208 @item @emph{Example}:
6209 @smallexample
6210 INTEGER :: array[2,-1:4,8,*]
6211 ! Writes  28 (or 0 if there are fewer than 28 images)
6212 WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1])
6213 @end smallexample
6214
6215 @item @emph{See also}:
6216 @ref{THIS_IMAGE}, @ref{NUM_IMAGES}
6217 @end table
6218
6219
6220
6221 @node IS_IOSTAT_END
6222 @section @code{IS_IOSTAT_END} --- Test for end-of-file value
6223 @fnindex IS_IOSTAT_END
6224 @cindex IOSTAT, end of file
6225
6226 @table @asis
6227 @item @emph{Description}:
6228 @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
6229 status ``end of file''. The function is equivalent to comparing the variable
6230 with the @code{IOSTAT_END} parameter of the intrinsic module
6231 @code{ISO_FORTRAN_ENV}.
6232
6233 @item @emph{Standard}:
6234 Fortran 2003 and later
6235
6236 @item @emph{Class}:
6237 Elemental function
6238
6239 @item @emph{Syntax}:
6240 @code{RESULT = IS_IOSTAT_END(I)}
6241
6242 @item @emph{Arguments}:
6243 @multitable @columnfractions .15 .70
6244 @item @var{I} @tab Shall be of the type @code{INTEGER}.
6245 @end multitable
6246
6247 @item @emph{Return value}:
6248 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6249 @var{I} has the value which indicates an end of file condition for
6250 IOSTAT= specifiers, and is @code{.FALSE.} otherwise.
6251
6252 @item @emph{Example}:
6253 @smallexample
6254 PROGRAM iostat
6255   IMPLICIT NONE
6256   INTEGER :: stat, i
6257   OPEN(88, FILE='test.dat')
6258   READ(88, *, IOSTAT=stat) i
6259   IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
6260 END PROGRAM
6261 @end smallexample
6262 @end table
6263
6264
6265
6266 @node IS_IOSTAT_EOR
6267 @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
6268 @fnindex IS_IOSTAT_EOR
6269 @cindex IOSTAT, end of record
6270
6271 @table @asis
6272 @item @emph{Description}:
6273 @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
6274 status ``end of record''. The function is equivalent to comparing the
6275 variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
6276 @code{ISO_FORTRAN_ENV}.
6277
6278 @item @emph{Standard}:
6279 Fortran 2003 and later
6280
6281 @item @emph{Class}:
6282 Elemental function
6283
6284 @item @emph{Syntax}:
6285 @code{RESULT = IS_IOSTAT_EOR(I)}
6286
6287 @item @emph{Arguments}:
6288 @multitable @columnfractions .15 .70
6289 @item @var{I} @tab Shall be of the type @code{INTEGER}.
6290 @end multitable
6291
6292 @item @emph{Return value}:
6293 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6294 @var{I} has the value which indicates an end of file condition for
6295 IOSTAT= specifiers, and is @code{.FALSE.} otherwise.
6296
6297 @item @emph{Example}:
6298 @smallexample
6299 PROGRAM iostat
6300   IMPLICIT NONE
6301   INTEGER :: stat, i(50)
6302   OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
6303   READ(88, IOSTAT=stat) i
6304   IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
6305 END PROGRAM
6306 @end smallexample
6307 @end table
6308
6309
6310
6311 @node ISATTY
6312 @section @code{ISATTY} --- Whether a unit is a terminal device.
6313 @fnindex ISATTY
6314 @cindex system, terminal
6315
6316 @table @asis
6317 @item @emph{Description}:
6318 Determine whether a unit is connected to a terminal device.
6319
6320 @item @emph{Standard}:
6321 GNU extension
6322
6323 @item @emph{Class}:
6324 Function
6325
6326 @item @emph{Syntax}:
6327 @code{RESULT = ISATTY(UNIT)}
6328
6329 @item @emph{Arguments}:
6330 @multitable @columnfractions .15 .70
6331 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
6332 @end multitable
6333
6334 @item @emph{Return value}:
6335 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal 
6336 device, @code{.FALSE.} otherwise.
6337
6338 @item @emph{Example}:
6339 @smallexample
6340 PROGRAM test_isatty
6341   INTEGER(kind=1) :: unit
6342   DO unit = 1, 10
6343     write(*,*) isatty(unit=unit)
6344   END DO
6345 END PROGRAM
6346 @end smallexample
6347 @item @emph{See also}:
6348 @ref{TTYNAM}
6349 @end table
6350
6351
6352
6353 @node ISHFT
6354 @section @code{ISHFT} --- Shift bits
6355 @fnindex ISHFT
6356 @cindex bits, shift
6357
6358 @table @asis
6359 @item @emph{Description}:
6360 @code{ISHFT} returns a value corresponding to @var{I} with all of the
6361 bits shifted @var{SHIFT} places.  A value of @var{SHIFT} greater than
6362 zero corresponds to a left shift, a value of zero corresponds to no
6363 shift, and a value less than zero corresponds to a right shift.  If the
6364 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
6365 value is undefined.  Bits shifted out from the left end or right end are
6366 lost; zeros are shifted in from the opposite end.
6367
6368 @item @emph{Standard}:
6369 Fortran 95 and later
6370
6371 @item @emph{Class}:
6372 Elemental function
6373
6374 @item @emph{Syntax}:
6375 @code{RESULT = ISHFT(I, SHIFT)}
6376
6377 @item @emph{Arguments}:
6378 @multitable @columnfractions .15 .70
6379 @item @var{I} @tab The type shall be @code{INTEGER}.
6380 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
6381 @end multitable
6382
6383 @item @emph{Return value}:
6384 The return value is of type @code{INTEGER} and of the same kind as
6385 @var{I}.
6386
6387 @item @emph{See also}:
6388 @ref{ISHFTC}
6389 @end table
6390
6391
6392
6393 @node ISHFTC
6394 @section @code{ISHFTC} --- Shift bits circularly
6395 @fnindex ISHFTC
6396 @cindex bits, shift circular
6397
6398 @table @asis
6399 @item @emph{Description}:
6400 @code{ISHFTC} returns a value corresponding to @var{I} with the
6401 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
6402 is, bits shifted out one end are shifted into the opposite end.  A value
6403 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
6404 zero corresponds to no shift, and a value less than zero corresponds to
6405 a right shift.  The absolute value of @var{SHIFT} must be less than
6406 @var{SIZE}.  If the @var{SIZE} argument is omitted, it is taken to be
6407 equivalent to @code{BIT_SIZE(I)}.
6408
6409 @item @emph{Standard}:
6410 Fortran 95 and later
6411
6412 @item @emph{Class}:
6413 Elemental function
6414
6415 @item @emph{Syntax}:
6416 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
6417
6418 @item @emph{Arguments}:
6419 @multitable @columnfractions .15 .70
6420 @item @var{I} @tab The type shall be @code{INTEGER}.
6421 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
6422 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
6423 the value must be greater than zero and less than or equal to
6424 @code{BIT_SIZE(I)}.
6425 @end multitable
6426
6427 @item @emph{Return value}:
6428 The return value is of type @code{INTEGER} and of the same kind as
6429 @var{I}.
6430
6431 @item @emph{See also}:
6432 @ref{ISHFT}
6433 @end table
6434
6435
6436
6437 @node ISNAN
6438 @section @code{ISNAN} --- Test for a NaN
6439 @fnindex ISNAN
6440 @cindex IEEE, ISNAN
6441
6442 @table @asis
6443 @item @emph{Description}:
6444 @code{ISNAN} tests whether a floating-point value is an IEEE
6445 Not-a-Number (NaN).
6446 @item @emph{Standard}:
6447 GNU extension
6448
6449 @item @emph{Class}:
6450 Elemental function
6451
6452 @item @emph{Syntax}:
6453 @code{ISNAN(X)}
6454
6455 @item @emph{Arguments}:
6456 @multitable @columnfractions .15 .70
6457 @item @var{X} @tab Variable of the type @code{REAL}.
6458
6459 @end multitable
6460
6461 @item @emph{Return value}:
6462 Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
6463 if @var{X} is a NaN and @code{FALSE} otherwise.
6464
6465 @item @emph{Example}:
6466 @smallexample
6467 program test_nan
6468   implicit none
6469   real :: x
6470   x = -1.0
6471   x = sqrt(x)
6472   if (isnan(x)) stop '"x" is a NaN'
6473 end program test_nan
6474 @end smallexample
6475 @end table
6476
6477
6478
6479 @node ITIME
6480 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds) 
6481 @fnindex ITIME
6482 @cindex time, current
6483 @cindex current time
6484
6485 @table @asis
6486 @item @emph{Description}:
6487 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the  
6488 current local time. The hour (in the range 1-24), minute (in the range 1-60), 
6489 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES}, 
6490 respectively.
6491
6492 @item @emph{Standard}:
6493 GNU extension
6494
6495 @item @emph{Class}:
6496 Subroutine
6497
6498 @item @emph{Syntax}:
6499 @code{CALL ITIME(VALUES)}
6500
6501 @item @emph{Arguments}:
6502 @multitable @columnfractions .15 .70
6503 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
6504 and the kind shall be the default integer kind.
6505 @end multitable
6506
6507 @item @emph{Return value}:
6508 Does not return anything.
6509
6510
6511 @item @emph{Example}:
6512 @smallexample
6513 program test_itime
6514   integer, dimension(3) :: tarray
6515   call itime(tarray)
6516   print *, tarray(1)
6517   print *, tarray(2)
6518   print *, tarray(3)
6519 end program test_itime
6520 @end smallexample
6521 @end table
6522
6523
6524
6525 @node KILL
6526 @section @code{KILL} --- Send a signal to a process
6527 @fnindex KILL
6528
6529 @table @asis
6530 @item @emph{Description}:
6531 @item @emph{Standard}:
6532 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
6533 See @code{kill(2)}.
6534
6535 This intrinsic is provided in both subroutine and function forms; however,
6536 only one form can be used in any given program unit.
6537
6538 @item @emph{Class}:
6539 Subroutine, function
6540
6541 @item @emph{Syntax}:
6542 @code{CALL KILL(C, VALUE [, STATUS])}
6543
6544 @item @emph{Arguments}:
6545 @multitable @columnfractions .15 .70
6546 @item @var{C} @tab Shall be a scalar @code{INTEGER}, with
6547 @code{INTENT(IN)}
6548 @item @var{VALUE} @tab Shall be a scalar @code{INTEGER}, with
6549 @code{INTENT(IN)}
6550 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
6551 @code{INTEGER(8)}. Returns 0 on success, or a system-specific error code
6552 otherwise.
6553 @end multitable
6554
6555 @item @emph{See also}:
6556 @ref{ABORT}, @ref{EXIT}
6557 @end table
6558
6559
6560
6561 @node KIND
6562 @section @code{KIND} --- Kind of an entity
6563 @fnindex KIND
6564 @cindex kind
6565
6566 @table @asis
6567 @item @emph{Description}:
6568 @code{KIND(X)} returns the kind value of the entity @var{X}.
6569
6570 @item @emph{Standard}:
6571 Fortran 95 and later
6572
6573 @item @emph{Class}:
6574 Inquiry function
6575
6576 @item @emph{Syntax}:
6577 @code{K = KIND(X)}
6578
6579 @item @emph{Arguments}:
6580 @multitable @columnfractions .15 .70
6581 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
6582 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
6583 @end multitable
6584
6585 @item @emph{Return value}:
6586 The return value is a scalar of type @code{INTEGER} and of the default
6587 integer kind.
6588
6589 @item @emph{Example}:
6590 @smallexample
6591 program test_kind
6592   integer,parameter :: kc = kind(' ')
6593   integer,parameter :: kl = kind(.true.)
6594
6595   print *, "The default character kind is ", kc
6596   print *, "The default logical kind is ", kl
6597 end program test_kind
6598 @end smallexample
6599
6600 @end table
6601
6602
6603
6604 @node LBOUND
6605 @section @code{LBOUND} --- Lower dimension bounds of an array
6606 @fnindex LBOUND
6607 @cindex array, lower bound
6608
6609 @table @asis
6610 @item @emph{Description}:
6611 Returns the lower bounds of an array, or a single lower bound
6612 along the @var{DIM} dimension.
6613 @item @emph{Standard}:
6614 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6615
6616 @item @emph{Class}:
6617 Inquiry function
6618
6619 @item @emph{Syntax}:
6620 @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
6621
6622 @item @emph{Arguments}:
6623 @multitable @columnfractions .15 .70
6624 @item @var{ARRAY} @tab Shall be an array, of any type.
6625 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
6626 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6627 expression indicating the kind parameter of the result.
6628 @end multitable
6629
6630 @item @emph{Return value}:
6631 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6632 @var{KIND} is absent, the return value is of default integer kind.
6633 If @var{DIM} is absent, the result is an array of the lower bounds of
6634 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
6635 corresponding to the lower bound of the array along that dimension.  If
6636 @var{ARRAY} is an expression rather than a whole array or array
6637 structure component, or if it has a zero extent along the relevant
6638 dimension, the lower bound is taken to be 1.
6639
6640 @item @emph{See also}:
6641 @ref{UBOUND}, @ref{LCOBOUND}
6642 @end table
6643
6644
6645
6646 @node LCOBOUND
6647 @section @code{LCOBOUND} --- Lower codimension bounds of an array
6648 @fnindex LCOBOUND
6649 @cindex coarray, lower bound
6650
6651 @table @asis
6652 @item @emph{Description}:
6653 Returns the lower bounds of a coarray, or a single lower cobound
6654 along the @var{DIM} codimension.
6655 @item @emph{Standard}:
6656 Fortran 2008 and later
6657
6658 @item @emph{Class}:
6659 Inquiry function
6660
6661 @item @emph{Syntax}:
6662 @code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])}
6663
6664 @item @emph{Arguments}:
6665 @multitable @columnfractions .15 .70
6666 @item @var{ARRAY} @tab Shall be an coarray, of any type.
6667 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
6668 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6669 expression indicating the kind parameter of the result.
6670 @end multitable
6671
6672 @item @emph{Return value}:
6673 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6674 @var{KIND} is absent, the return value is of default integer kind.
6675 If @var{DIM} is absent, the result is an array of the lower cobounds of
6676 @var{COARRAY}.  If @var{DIM} is present, the result is a scalar
6677 corresponding to the lower cobound of the array along that codimension.
6678
6679 @item @emph{See also}:
6680 @ref{UCOBOUND}, @ref{LBOUND}
6681 @end table
6682
6683
6684
6685 @node LEADZ
6686 @section @code{LEADZ} --- Number of leading zero bits of an integer
6687 @fnindex LEADZ
6688 @cindex zero bits
6689
6690 @table @asis
6691 @item @emph{Description}:
6692 @code{LEADZ} returns the number of leading zero bits of an integer.
6693
6694 @item @emph{Standard}:
6695 Fortran 2008 and later
6696
6697 @item @emph{Class}:
6698 Elemental function
6699
6700 @item @emph{Syntax}:
6701 @code{RESULT = LEADZ(I)}
6702
6703 @item @emph{Arguments}:
6704 @multitable @columnfractions .15 .70
6705 @item @var{I} @tab Shall be of type @code{INTEGER}.
6706 @end multitable
6707
6708 @item @emph{Return value}:
6709 The type of the return value is the default @code{INTEGER}.
6710 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
6711
6712 @item @emph{Example}:
6713 @smallexample
6714 PROGRAM test_leadz
6715   WRITE (*,*) LEADZ(1)  ! prints 8 if BITSIZE(I) has the value 32
6716 END PROGRAM
6717 @end smallexample
6718
6719 @item @emph{See also}:
6720 @ref{BIT_SIZE}, @ref{TRAILZ}
6721 @end table
6722
6723
6724
6725 @node LEN
6726 @section @code{LEN} --- Length of a character entity
6727 @fnindex LEN
6728 @cindex string, length
6729
6730 @table @asis
6731 @item @emph{Description}:
6732 Returns the length of a character string.  If @var{STRING} is an array,
6733 the length of an element of @var{STRING} is returned.  Note that
6734 @var{STRING} need not be defined when this intrinsic is invoked, since
6735 only the length, not the content, of @var{STRING} is needed.
6736
6737 @item @emph{Standard}:
6738 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
6739
6740 @item @emph{Class}:
6741 Inquiry function
6742
6743 @item @emph{Syntax}:
6744 @code{L = LEN(STRING [, KIND])}
6745
6746 @item @emph{Arguments}:
6747 @multitable @columnfractions .15 .70
6748 @item @var{STRING} @tab Shall be a scalar or array of type
6749 @code{CHARACTER}, with @code{INTENT(IN)}
6750 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6751 expression indicating the kind parameter of the result.
6752 @end multitable
6753
6754 @item @emph{Return value}:
6755 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6756 @var{KIND} is absent, the return value is of default integer kind.
6757
6758
6759 @item @emph{Specific names}:
6760 @multitable @columnfractions .20 .20 .20 .25
6761 @item Name               @tab Argument          @tab Return type       @tab Standard
6762 @item @code{LEN(STRING)} @tab @code{CHARACTER}  @tab @code{INTEGER}    @tab Fortran 77 and later
6763 @end multitable
6764
6765
6766 @item @emph{See also}:
6767 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
6768 @end table
6769
6770
6771
6772 @node LEN_TRIM
6773 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
6774 @fnindex LEN_TRIM
6775 @cindex string, length, without trailing whitespace
6776
6777 @table @asis
6778 @item @emph{Description}:
6779 Returns the length of a character string, ignoring any trailing blanks.
6780
6781 @item @emph{Standard}:
6782 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6783
6784 @item @emph{Class}:
6785 Elemental function
6786
6787 @item @emph{Syntax}:
6788 @code{RESULT = LEN_TRIM(STRING [, KIND])}
6789
6790 @item @emph{Arguments}:
6791 @multitable @columnfractions .15 .70
6792 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
6793 with @code{INTENT(IN)}
6794 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6795 expression indicating the kind parameter of the result.
6796 @end multitable
6797
6798 @item @emph{Return value}:
6799 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6800 @var{KIND} is absent, the return value is of default integer kind.
6801
6802 @item @emph{See also}:
6803 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
6804 @end table
6805
6806
6807
6808 @node LGE
6809 @section @code{LGE} --- Lexical greater than or equal
6810 @fnindex LGE
6811 @cindex lexical comparison of strings
6812 @cindex string, comparison
6813
6814 @table @asis
6815 @item @emph{Description}:
6816 Determines whether one string is lexically greater than or equal to
6817 another string, where the two strings are interpreted as containing
6818 ASCII character codes.  If the String A and String B are not the same
6819 length, the shorter is compared as if spaces were appended to it to form
6820 a value that has the same length as the longer.
6821
6822 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6823 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6824 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6825 that the latter use the processor's character ordering (which is not
6826 ASCII on some targets), whereas the former always use the ASCII
6827 ordering.
6828
6829 @item @emph{Standard}:
6830 Fortran 77 and later
6831
6832 @item @emph{Class}:
6833 Elemental function
6834
6835 @item @emph{Syntax}:
6836 @code{RESULT = LGE(STRING_A, STRING_B)}
6837
6838 @item @emph{Arguments}:
6839 @multitable @columnfractions .15 .70
6840 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6841 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6842 @end multitable
6843
6844 @item @emph{Return value}:
6845 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
6846 otherwise, based on the ASCII ordering.
6847
6848 @item @emph{Specific names}:
6849 @multitable @columnfractions .20 .20 .20 .25
6850 @item Name                           @tab Argument          @tab Return type       @tab Standard
6851 @item @code{LGE(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
6852 @end multitable
6853
6854 @item @emph{See also}:
6855 @ref{LGT}, @ref{LLE}, @ref{LLT}
6856 @end table
6857
6858
6859
6860 @node LGT
6861 @section @code{LGT} --- Lexical greater than
6862 @fnindex LGT
6863 @cindex lexical comparison of strings
6864 @cindex string, comparison
6865
6866 @table @asis
6867 @item @emph{Description}:
6868 Determines whether one string is lexically greater than another string,
6869 where the two strings are interpreted as containing ASCII character
6870 codes.  If the String A and String B are not the same length, the
6871 shorter is compared as if spaces were appended to it to form a value
6872 that has the same length as the longer.
6873
6874 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6875 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6876 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6877 that the latter use the processor's character ordering (which is not
6878 ASCII on some targets), whereas the former always use the ASCII
6879 ordering.
6880
6881 @item @emph{Standard}:
6882 Fortran 77 and later
6883
6884 @item @emph{Class}:
6885 Elemental function
6886
6887 @item @emph{Syntax}:
6888 @code{RESULT = LGT(STRING_A, STRING_B)}
6889
6890 @item @emph{Arguments}:
6891 @multitable @columnfractions .15 .70
6892 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6893 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6894 @end multitable
6895
6896 @item @emph{Return value}:
6897 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
6898 otherwise, based on the ASCII ordering.
6899
6900 @item @emph{Specific names}:
6901 @multitable @columnfractions .20 .20 .20 .25
6902 @item Name                           @tab Argument          @tab Return type       @tab Standard
6903 @item @code{LGT(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
6904 @end multitable
6905
6906 @item @emph{See also}:
6907 @ref{LGE}, @ref{LLE}, @ref{LLT}
6908 @end table
6909
6910
6911
6912 @node LINK
6913 @section @code{LINK} --- Create a hard link
6914 @fnindex LINK
6915 @cindex file system, create link
6916 @cindex file system, hard link
6917
6918 @table @asis
6919 @item @emph{Description}:
6920 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
6921 character (@code{CHAR(0)}) can be used to mark the end of the names in
6922 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
6923 names are ignored.  If the @var{STATUS} argument is supplied, it
6924 contains 0 on success or a nonzero error code upon return; see
6925 @code{link(2)}.
6926
6927 This intrinsic is provided in both subroutine and function forms;
6928 however, only one form can be used in any given program unit.
6929
6930 @item @emph{Standard}:
6931 GNU extension
6932
6933 @item @emph{Class}:
6934 Subroutine, function
6935
6936 @item @emph{Syntax}:
6937 @multitable @columnfractions .80
6938 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
6939 @item @code{STATUS = LINK(PATH1, PATH2)}
6940 @end multitable
6941
6942 @item @emph{Arguments}:
6943 @multitable @columnfractions .15 .70
6944 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
6945 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
6946 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
6947 @end multitable
6948
6949 @item @emph{See also}:
6950 @ref{SYMLNK}, @ref{UNLINK}
6951 @end table
6952
6953
6954
6955 @node LLE
6956 @section @code{LLE} --- Lexical less than or equal
6957 @fnindex LLE
6958 @cindex lexical comparison of strings
6959 @cindex string, comparison
6960
6961 @table @asis
6962 @item @emph{Description}:
6963 Determines whether one string is lexically less than or equal to another
6964 string, where the two strings are interpreted as containing ASCII
6965 character codes.  If the String A and String B are not the same length,
6966 the shorter is compared as if spaces were appended to it to form a value
6967 that has the same length as the longer.
6968
6969 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6970 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6971 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6972 that the latter use the processor's character ordering (which is not
6973 ASCII on some targets), whereas the former always use the ASCII
6974 ordering.
6975
6976 @item @emph{Standard}:
6977 Fortran 77 and later
6978
6979 @item @emph{Class}:
6980 Elemental function
6981
6982 @item @emph{Syntax}:
6983 @code{RESULT = LLE(STRING_A, STRING_B)}
6984
6985 @item @emph{Arguments}:
6986 @multitable @columnfractions .15 .70
6987 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6988 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6989 @end multitable
6990
6991 @item @emph{Return value}:
6992 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
6993 otherwise, based on the ASCII ordering.
6994
6995 @item @emph{Specific names}:
6996 @multitable @columnfractions .20 .20 .20 .25
6997 @item Name                           @tab Argument          @tab Return type       @tab Standard
6998 @item @code{LLE(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
6999 @end multitable
7000
7001 @item @emph{See also}:
7002 @ref{LGE}, @ref{LGT}, @ref{LLT}
7003 @end table
7004
7005
7006
7007 @node LLT
7008 @section @code{LLT} --- Lexical less than
7009 @fnindex LLT
7010 @cindex lexical comparison of strings
7011 @cindex string, comparison
7012
7013 @table @asis
7014 @item @emph{Description}:
7015 Determines whether one string is lexically less than another string,
7016 where the two strings are interpreted as containing ASCII character
7017 codes.  If the String A and String B are not the same length, the
7018 shorter is compared as if spaces were appended to it to form a value
7019 that has the same length as the longer.
7020
7021 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7022 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7023 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7024 that the latter use the processor's character ordering (which is not
7025 ASCII on some targets), whereas the former always use the ASCII
7026 ordering.
7027
7028 @item @emph{Standard}:
7029 Fortran 77 and later
7030
7031 @item @emph{Class}:
7032 Elemental function
7033
7034 @item @emph{Syntax}:
7035 @code{RESULT = LLT(STRING_A, STRING_B)}
7036
7037 @item @emph{Arguments}:
7038 @multitable @columnfractions .15 .70
7039 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7040 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7041 @end multitable
7042
7043 @item @emph{Return value}:
7044 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
7045 otherwise, based on the ASCII ordering.
7046
7047 @item @emph{Specific names}:
7048 @multitable @columnfractions .20 .20 .20 .25
7049 @item Name                           @tab Argument          @tab Return type       @tab Standard
7050 @item @code{LLT(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
7051 @end multitable
7052
7053 @item @emph{See also}:
7054 @ref{LGE}, @ref{LGT}, @ref{LLE}
7055 @end table
7056
7057
7058
7059 @node LNBLNK
7060 @section @code{LNBLNK} --- Index of the last non-blank character in a string
7061 @fnindex LNBLNK
7062 @cindex string, find non-blank character
7063
7064 @table @asis
7065 @item @emph{Description}:
7066 Returns the length of a character string, ignoring any trailing blanks.
7067 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
7068 included for backwards compatibility.
7069
7070 @item @emph{Standard}:
7071 GNU extension
7072
7073 @item @emph{Class}:
7074 Elemental function
7075
7076 @item @emph{Syntax}:
7077 @code{RESULT = LNBLNK(STRING)}
7078
7079 @item @emph{Arguments}:
7080 @multitable @columnfractions .15 .70
7081 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
7082 with @code{INTENT(IN)}
7083 @end multitable
7084
7085 @item @emph{Return value}:
7086 The return value is of @code{INTEGER(kind=4)} type.
7087
7088 @item @emph{See also}:
7089 @ref{INDEX intrinsic}, @ref{LEN_TRIM}
7090 @end table
7091
7092
7093
7094 @node LOC
7095 @section @code{LOC} --- Returns the address of a variable
7096 @fnindex LOC
7097 @cindex location of a variable in memory
7098
7099 @table @asis
7100 @item @emph{Description}:
7101 @code{LOC(X)} returns the address of @var{X} as an integer.
7102
7103 @item @emph{Standard}:
7104 GNU extension
7105
7106 @item @emph{Class}:
7107 Inquiry function
7108
7109 @item @emph{Syntax}:
7110 @code{RESULT = LOC(X)}
7111
7112 @item @emph{Arguments}:
7113 @multitable @columnfractions .15 .70
7114 @item @var{X} @tab Variable of any type.
7115 @end multitable
7116
7117 @item @emph{Return value}:
7118 The return value is of type @code{INTEGER}, with a @code{KIND}
7119 corresponding to the size (in bytes) of a memory address on the target
7120 machine.
7121
7122 @item @emph{Example}:
7123 @smallexample
7124 program test_loc
7125   integer :: i
7126   real :: r
7127   i = loc(r)
7128   print *, i
7129 end program test_loc
7130 @end smallexample
7131 @end table
7132
7133
7134
7135 @node LOG
7136 @section @code{LOG} --- Logarithm function
7137 @fnindex LOG
7138 @fnindex ALOG
7139 @fnindex DLOG
7140 @fnindex CLOG
7141 @fnindex ZLOG
7142 @fnindex CDLOG
7143 @cindex exponential function, inverse
7144 @cindex logarithmic function
7145
7146 @table @asis
7147 @item @emph{Description}:
7148 @code{LOG(X)} computes the logarithm of @var{X}.
7149
7150 @item @emph{Standard}:
7151 Fortran 77 and later
7152
7153 @item @emph{Class}:
7154 Elemental function
7155
7156 @item @emph{Syntax}:
7157 @code{RESULT = LOG(X)}
7158
7159 @item @emph{Arguments}:
7160 @multitable @columnfractions .15 .70
7161 @item @var{X} @tab The type shall be @code{REAL} or
7162 @code{COMPLEX}.
7163 @end multitable
7164
7165 @item @emph{Return value}:
7166 The return value is of type @code{REAL} or @code{COMPLEX}.
7167 The kind type parameter is the same as @var{X}.
7168 If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range
7169 @math{-\pi \leq \omega \leq \pi}.
7170
7171 @item @emph{Example}:
7172 @smallexample
7173 program test_log
7174   real(8) :: x = 1.0_8
7175   complex :: z = (1.0, 2.0)
7176   x = log(x)
7177   z = log(z)
7178 end program test_log
7179 @end smallexample
7180
7181 @item @emph{Specific names}:
7182 @multitable @columnfractions .20 .20 .20 .25
7183 @item Name            @tab Argument          @tab Return type       @tab Standard
7184 @item @code{ALOG(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab f95, gnu
7185 @item @code{DLOG(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
7186 @item @code{CLOG(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
7187 @item @code{ZLOG(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
7188 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
7189 @end multitable
7190 @end table
7191
7192
7193
7194 @node LOG10
7195 @section @code{LOG10} --- Base 10 logarithm function
7196 @fnindex LOG10
7197 @fnindex ALOG10
7198 @fnindex DLOG10
7199 @cindex exponential function, inverse
7200 @cindex logarithmic function
7201
7202 @table @asis
7203 @item @emph{Description}:
7204 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
7205
7206 @item @emph{Standard}:
7207 Fortran 77 and later
7208
7209 @item @emph{Class}:
7210 Elemental function
7211
7212 @item @emph{Syntax}:
7213 @code{RESULT = LOG10(X)}
7214
7215 @item @emph{Arguments}:
7216 @multitable @columnfractions .15 .70
7217 @item @var{X} @tab The type shall be @code{REAL}.
7218 @end multitable
7219
7220 @item @emph{Return value}:
7221 The return value is of type @code{REAL} or @code{COMPLEX}.
7222 The kind type parameter is the same as @var{X}.
7223
7224 @item @emph{Example}:
7225 @smallexample
7226 program test_log10
7227   real(8) :: x = 10.0_8
7228   x = log10(x)
7229 end program test_log10
7230 @end smallexample
7231
7232 @item @emph{Specific names}:
7233 @multitable @columnfractions .20 .20 .20 .25
7234 @item Name            @tab Argument          @tab Return type       @tab Standard
7235 @item @code{ALOG10(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
7236 @item @code{DLOG10(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
7237 @end multitable
7238 @end table
7239
7240
7241
7242 @node LOG_GAMMA
7243 @section @code{LOG_GAMMA} --- Logarithm of the Gamma function
7244 @fnindex LOG_GAMMA
7245 @fnindex LGAMMA
7246 @fnindex ALGAMA
7247 @fnindex DLGAMA
7248 @cindex Gamma function, logarithm of
7249
7250 @table @asis
7251 @item @emph{Description}:
7252 @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
7253 of the Gamma (@math{\Gamma}) function.
7254
7255 @item @emph{Standard}:
7256 Fortran 2008 and later
7257
7258 @item @emph{Class}:
7259 Elemental function
7260
7261 @item @emph{Syntax}:
7262 @code{X = LOG_GAMMA(X)}
7263
7264 @item @emph{Arguments}:
7265 @multitable @columnfractions .15 .70
7266 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
7267 nor a negative integer.
7268 @end multitable
7269
7270 @item @emph{Return value}:
7271 The return value is of type @code{REAL} of the same kind as @var{X}.
7272
7273 @item @emph{Example}:
7274 @smallexample
7275 program test_log_gamma
7276   real :: x = 1.0
7277   x = lgamma(x) ! returns 0.0
7278 end program test_log_gamma
7279 @end smallexample
7280
7281 @item @emph{Specific names}:
7282 @multitable @columnfractions .20 .20 .20 .25
7283 @item Name             @tab Argument         @tab Return type       @tab Standard
7284 @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
7285 @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
7286 @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
7287 @end multitable
7288
7289 @item @emph{See also}:
7290 Gamma function: @ref{GAMMA}
7291
7292 @end table
7293
7294
7295
7296 @node LOGICAL
7297 @section @code{LOGICAL} --- Convert to logical type
7298 @fnindex LOGICAL
7299 @cindex conversion, to logical
7300
7301 @table @asis
7302 @item @emph{Description}:
7303 Converts one kind of @code{LOGICAL} variable to another.
7304
7305 @item @emph{Standard}:
7306 Fortran 95 and later
7307
7308 @item @emph{Class}:
7309 Elemental function
7310
7311 @item @emph{Syntax}:
7312 @code{RESULT = LOGICAL(L [, KIND])}
7313
7314 @item @emph{Arguments}:
7315 @multitable @columnfractions .15 .70
7316 @item @var{L}    @tab The type shall be @code{LOGICAL}.
7317 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7318 expression indicating the kind parameter of the result.
7319 @end multitable
7320
7321 @item @emph{Return value}:
7322 The return value is a @code{LOGICAL} value equal to @var{L}, with a
7323 kind corresponding to @var{KIND}, or of the default logical kind if
7324 @var{KIND} is not given.
7325
7326 @item @emph{See also}:
7327 @ref{INT}, @ref{REAL}, @ref{CMPLX}
7328 @end table
7329
7330
7331
7332 @node LONG
7333 @section @code{LONG} --- Convert to integer type
7334 @fnindex LONG
7335 @cindex conversion, to integer
7336
7337 @table @asis
7338 @item @emph{Description}:
7339 Convert to a @code{KIND=4} integer type, which is the same size as a C
7340 @code{long} integer.  This is equivalent to the standard @code{INT}
7341 intrinsic with an optional argument of @code{KIND=4}, and is only
7342 included for backwards compatibility.
7343
7344 @item @emph{Standard}:
7345 GNU extension
7346
7347 @item @emph{Class}:
7348 Elemental function
7349
7350 @item @emph{Syntax}:
7351 @code{RESULT = LONG(A)}
7352
7353 @item @emph{Arguments}:
7354 @multitable @columnfractions .15 .70
7355 @item @var{A}    @tab Shall be of type @code{INTEGER},
7356 @code{REAL}, or @code{COMPLEX}.
7357 @end multitable
7358
7359 @item @emph{Return value}:
7360 The return value is a @code{INTEGER(4)} variable.
7361
7362 @item @emph{See also}:
7363 @ref{INT}, @ref{INT2}, @ref{INT8}
7364 @end table
7365
7366
7367
7368 @node LSHIFT
7369 @section @code{LSHIFT} --- Left shift bits
7370 @fnindex LSHIFT
7371 @cindex bits, shift left
7372
7373 @table @asis
7374 @item @emph{Description}:
7375 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
7376 bits shifted left by @var{SHIFT} places.  If the absolute value of
7377 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined. 
7378 Bits shifted out from the left end are lost; zeros are shifted in from
7379 the opposite end.
7380
7381 This function has been superseded by the @code{ISHFT} intrinsic, which
7382 is standard in Fortran 95 and later.
7383
7384 @item @emph{Standard}:
7385 GNU extension
7386
7387 @item @emph{Class}:
7388 Elemental function
7389
7390 @item @emph{Syntax}:
7391 @code{RESULT = LSHIFT(I, SHIFT)}
7392
7393 @item @emph{Arguments}:
7394 @multitable @columnfractions .15 .70
7395 @item @var{I} @tab The type shall be @code{INTEGER}.
7396 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
7397 @end multitable
7398
7399 @item @emph{Return value}:
7400 The return value is of type @code{INTEGER} and of the same kind as
7401 @var{I}.
7402
7403 @item @emph{See also}:
7404 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
7405
7406 @end table
7407
7408
7409
7410 @node LSTAT
7411 @section @code{LSTAT} --- Get file status
7412 @fnindex LSTAT
7413 @cindex file system, file status
7414
7415 @table @asis
7416 @item @emph{Description}:
7417 @code{LSTAT} is identical to @ref{STAT}, except that if path is a
7418 symbolic link, then the link itself is statted, not the file that it
7419 refers to.
7420
7421 The elements in @code{VALUES} are the same as described by @ref{STAT}.
7422
7423 This intrinsic is provided in both subroutine and function forms;
7424 however, only one form can be used in any given program unit.
7425
7426 @item @emph{Standard}:
7427 GNU extension
7428
7429 @item @emph{Class}:
7430 Subroutine, function
7431
7432 @item @emph{Syntax}:
7433 @code{CALL LSTAT(NAME, VALUES [, STATUS])}
7434
7435 @item @emph{Arguments}:
7436 @multitable @columnfractions .15 .70
7437 @item @var{NAME}   @tab The type shall be @code{CHARACTER} of the default
7438 kind, a valid path within the file system.
7439 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
7440 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
7441 Returns 0 on success and a system specific error code otherwise.
7442 @end multitable
7443
7444 @item @emph{Example}:
7445 See @ref{STAT} for an example.
7446
7447 @item @emph{See also}:
7448 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
7449 @end table
7450
7451
7452
7453 @node LTIME
7454 @section @code{LTIME} --- Convert time to local time info
7455 @fnindex LTIME
7456 @cindex time, conversion to local time info
7457
7458 @table @asis
7459 @item @emph{Description}:
7460 Given a system time value @var{TIME} (as provided by the @code{TIME8()}
7461 intrinsic), fills @var{VALUES} with values extracted from it appropriate
7462 to the local time zone using @code{localtime(3)}.
7463
7464 @item @emph{Standard}:
7465 GNU extension
7466
7467 @item @emph{Class}:
7468 Subroutine
7469
7470 @item @emph{Syntax}:
7471 @code{CALL LTIME(TIME, VALUES)}
7472
7473 @item @emph{Arguments}:
7474 @multitable @columnfractions .15 .70
7475 @item @var{TIME}  @tab An @code{INTEGER} scalar expression
7476 corresponding to a system time, with @code{INTENT(IN)}.
7477 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
7478 with @code{INTENT(OUT)}.
7479 @end multitable
7480
7481 @item @emph{Return value}:
7482 The elements of @var{VALUES} are assigned as follows:
7483 @enumerate
7484 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
7485 seconds
7486 @item Minutes after the hour, range 0--59
7487 @item Hours past midnight, range 0--23
7488 @item Day of month, range 0--31
7489 @item Number of months since January, range 0--12
7490 @item Years since 1900
7491 @item Number of days since Sunday, range 0--6
7492 @item Days since January 1
7493 @item Daylight savings indicator: positive if daylight savings is in
7494 effect, zero if not, and negative if the information is not available.
7495 @end enumerate
7496
7497 @item @emph{See also}:
7498 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
7499
7500 @end table
7501
7502
7503
7504 @node MALLOC
7505 @section @code{MALLOC} --- Allocate dynamic memory
7506 @fnindex MALLOC
7507 @cindex pointer, cray
7508
7509 @table @asis
7510 @item @emph{Description}:
7511 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
7512 returns the address of the allocated memory. The @code{MALLOC} intrinsic
7513 is an extension intended to be used with Cray pointers, and is provided
7514 in GNU Fortran to allow the user to compile legacy code. For new code
7515 using Fortran 95 pointers, the memory allocation intrinsic is
7516 @code{ALLOCATE}.
7517
7518 @item @emph{Standard}:
7519 GNU extension
7520
7521 @item @emph{Class}:
7522 Function
7523
7524 @item @emph{Syntax}:
7525 @code{PTR = MALLOC(SIZE)}
7526
7527 @item @emph{Arguments}:
7528 @multitable @columnfractions .15 .70
7529 @item @var{SIZE} @tab The type shall be @code{INTEGER}.
7530 @end multitable
7531
7532 @item @emph{Return value}:
7533 The return value is of type @code{INTEGER(K)}, with @var{K} such that
7534 variables of type @code{INTEGER(K)} have the same size as
7535 C pointers (@code{sizeof(void *)}).
7536
7537 @item @emph{Example}:
7538 The following example demonstrates the use of @code{MALLOC} and
7539 @code{FREE} with Cray pointers.
7540
7541 @smallexample
7542 program test_malloc
7543   implicit none
7544   integer i
7545   real*8 x(*), z
7546   pointer(ptr_x,x)
7547
7548   ptr_x = malloc(20*8)
7549   do i = 1, 20
7550     x(i) = sqrt(1.0d0 / i)
7551   end do
7552   z = 0
7553   do i = 1, 20
7554     z = z + x(i)
7555     print *, z
7556   end do
7557   call free(ptr_x)
7558 end program test_malloc
7559 @end smallexample
7560
7561 @item @emph{See also}:
7562 @ref{FREE}
7563 @end table
7564
7565
7566
7567 @node MATMUL
7568 @section @code{MATMUL} --- matrix multiplication
7569 @fnindex MATMUL
7570 @cindex matrix multiplication
7571 @cindex product, matrix
7572
7573 @table @asis
7574 @item @emph{Description}:
7575 Performs a matrix multiplication on numeric or logical arguments.
7576
7577 @item @emph{Standard}:
7578 Fortran 95 and later
7579
7580 @item @emph{Class}:
7581 Transformational function
7582
7583 @item @emph{Syntax}:
7584 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
7585
7586 @item @emph{Arguments}:
7587 @multitable @columnfractions .15 .70
7588 @item @var{MATRIX_A} @tab An array of @code{INTEGER},
7589 @code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of
7590 one or two.
7591 @item @var{MATRIX_B} @tab An array of @code{INTEGER},
7592 @code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric
7593 type; otherwise, an array of @code{LOGICAL} type. The rank shall be one
7594 or two, and the first (or only) dimension of @var{MATRIX_B} shall be
7595 equal to the last (or only) dimension of @var{MATRIX_A}.
7596 @end multitable
7597
7598 @item @emph{Return value}:
7599 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}.  The type and
7600 kind of the result follow the usual type and kind promotion rules, as
7601 for the @code{*} or @code{.AND.} operators.
7602
7603 @item @emph{See also}:
7604 @end table
7605
7606
7607
7608 @node MAX
7609 @section @code{MAX} --- Maximum value of an argument list
7610 @fnindex MAX
7611 @fnindex MAX0
7612 @fnindex AMAX0
7613 @fnindex MAX1
7614 @fnindex AMAX1
7615 @fnindex DMAX1
7616 @cindex maximum value
7617
7618 @table @asis
7619 @item @emph{Description}:
7620 Returns the argument with the largest (most positive) value.
7621
7622 @item @emph{Standard}:
7623 Fortran 77 and later
7624
7625 @item @emph{Class}:
7626 Elemental function
7627
7628 @item @emph{Syntax}:
7629 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
7630
7631 @item @emph{Arguments}:
7632 @multitable @columnfractions .15 .70
7633 @item @var{A1}          @tab The type shall be @code{INTEGER} or
7634 @code{REAL}.
7635 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
7636 as @var{A1}.  (As a GNU extension, arguments of different kinds are
7637 permitted.)
7638 @end multitable
7639
7640 @item @emph{Return value}:
7641 The return value corresponds to the maximum value among the arguments,
7642 and has the same type and kind as the first argument.
7643
7644 @item @emph{Specific names}:
7645 @multitable @columnfractions .20 .20 .20 .25
7646 @item Name             @tab Argument             @tab Return type         @tab Standard
7647 @item @code{MAX0(A1)}  @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)}   @tab Fortran 77 and later
7648 @item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
7649 @item @code{MAX1(A1)}  @tab @code{REAL A1}       @tab @code{INT(MAX(X))}  @tab Fortran 77 and later
7650 @item @code{AMAX1(A1)} @tab @code{REAL(4) A1}    @tab @code{REAL(4)}      @tab Fortran 77 and later
7651 @item @code{DMAX1(A1)} @tab @code{REAL(8) A1}    @tab @code{REAL(8)}      @tab Fortran 77 and later
7652 @end multitable
7653
7654 @item @emph{See also}:
7655 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
7656
7657 @end table
7658
7659
7660
7661 @node MAXEXPONENT
7662 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
7663 @fnindex MAXEXPONENT
7664 @cindex model representation, maximum exponent
7665
7666 @table @asis
7667 @item @emph{Description}:
7668 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
7669 type of @code{X}.
7670
7671 @item @emph{Standard}:
7672 Fortran 95 and later
7673
7674 @item @emph{Class}:
7675 Inquiry function
7676
7677 @item @emph{Syntax}:
7678 @code{RESULT = MAXEXPONENT(X)}
7679
7680 @item @emph{Arguments}:
7681 @multitable @columnfractions .15 .70
7682 @item @var{X} @tab Shall be of type @code{REAL}.
7683 @end multitable
7684
7685 @item @emph{Return value}:
7686 The return value is of type @code{INTEGER} and of the default integer
7687 kind.
7688
7689 @item @emph{Example}:
7690 @smallexample
7691 program exponents
7692   real(kind=4) :: x
7693   real(kind=8) :: y
7694
7695   print *, minexponent(x), maxexponent(x)
7696   print *, minexponent(y), maxexponent(y)
7697 end program exponents
7698 @end smallexample
7699 @end table
7700
7701
7702
7703 @node MAXLOC
7704 @section @code{MAXLOC} --- Location of the maximum value within an array
7705 @fnindex MAXLOC
7706 @cindex array, location of maximum element
7707
7708 @table @asis
7709 @item @emph{Description}:
7710 Determines the location of the element in the array with the maximum
7711 value, or, if the @var{DIM} argument is supplied, determines the
7712 locations of the maximum element along each row of the array in the
7713 @var{DIM} direction.  If @var{MASK} is present, only the elements for
7714 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
7715 element in the array has the maximum value, the location returned is
7716 that of the first such element in array element order.  If the array has
7717 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
7718 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
7719 and all of the elements of @var{MASK} along a given row are zero, the
7720 result value for that row is zero.
7721
7722 @item @emph{Standard}:
7723 Fortran 95 and later
7724
7725 @item @emph{Class}:
7726 Transformational function
7727
7728 @item @emph{Syntax}:
7729 @multitable @columnfractions .80
7730 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
7731 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
7732 @end multitable
7733
7734 @item @emph{Arguments}:
7735 @multitable @columnfractions .15 .70
7736 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
7737 @code{REAL}.
7738 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
7739 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
7740 inclusive.  It may not be an optional dummy argument.
7741 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
7742 and conformable with @var{ARRAY}.
7743 @end multitable
7744
7745 @item @emph{Return value}:
7746 If @var{DIM} is absent, the result is a rank-one array with a length
7747 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
7748 is an array with a rank one less than the rank of @var{ARRAY}, and a
7749 size corresponding to the size of @var{ARRAY} with the @var{DIM}
7750 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
7751 of one, the result is a scalar.  In all cases, the result is of default
7752 @code{INTEGER} type.
7753
7754 @item @emph{See also}:
7755 @ref{MAX}, @ref{MAXVAL}
7756
7757 @end table
7758
7759
7760
7761 @node MAXVAL
7762 @section @code{MAXVAL} --- Maximum value of an array
7763 @fnindex MAXVAL
7764 @cindex array, maximum value
7765 @cindex maximum value
7766
7767 @table @asis
7768 @item @emph{Description}:
7769 Determines the maximum value of the elements in an array value, or, if
7770 the @var{DIM} argument is supplied, determines the maximum value along
7771 each row of the array in the @var{DIM} direction.  If @var{MASK} is
7772 present, only the elements for which @var{MASK} is @code{.TRUE.} are
7773 considered.  If the array has zero size, or all of the elements of
7774 @var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)}
7775 if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character
7776 type.
7777
7778 @item @emph{Standard}:
7779 Fortran 95 and later
7780
7781 @item @emph{Class}:
7782 Transformational function
7783
7784 @item @emph{Syntax}:
7785 @multitable @columnfractions .80
7786 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
7787 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
7788 @end multitable
7789
7790 @item @emph{Arguments}:
7791 @multitable @columnfractions .15 .70
7792 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
7793 @code{REAL}.
7794 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
7795 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
7796 inclusive.  It may not be an optional dummy argument.
7797 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
7798 and conformable with @var{ARRAY}.
7799 @end multitable
7800
7801 @item @emph{Return value}:
7802 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
7803 is a scalar.  If @var{DIM} is present, the result is an array with a
7804 rank one less than the rank of @var{ARRAY}, and a size corresponding to
7805 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
7806 cases, the result is of the same type and kind as @var{ARRAY}.
7807
7808 @item @emph{See also}:
7809 @ref{MAX}, @ref{MAXLOC}
7810 @end table
7811
7812
7813
7814 @node MCLOCK
7815 @section @code{MCLOCK} --- Time function
7816 @fnindex MCLOCK
7817 @cindex time, clock ticks
7818 @cindex clock ticks
7819
7820 @table @asis
7821 @item @emph{Description}:
7822 Returns the number of clock ticks since the start of the process, based
7823 on the UNIX function @code{clock(3)}.
7824
7825 This intrinsic is not fully portable, such as to systems with 32-bit
7826 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
7827 the values returned by this intrinsic might be, or become, negative, or
7828 numerically less than previous values, during a single run of the
7829 compiled program.
7830
7831 @item @emph{Standard}:
7832 GNU extension
7833
7834 @item @emph{Class}:
7835 Function
7836
7837 @item @emph{Syntax}:
7838 @code{RESULT = MCLOCK()}
7839
7840 @item @emph{Return value}:
7841 The return value is a scalar of type @code{INTEGER(4)}, equal to the
7842 number of clock ticks since the start of the process, or @code{-1} if
7843 the system does not support @code{clock(3)}.
7844
7845 @item @emph{See also}:
7846 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
7847
7848 @end table
7849
7850
7851
7852 @node MCLOCK8
7853 @section @code{MCLOCK8} --- Time function (64-bit)
7854 @fnindex MCLOCK8
7855 @cindex time, clock ticks
7856 @cindex clock ticks
7857
7858 @table @asis
7859 @item @emph{Description}:
7860 Returns the number of clock ticks since the start of the process, based
7861 on the UNIX function @code{clock(3)}.
7862
7863 @emph{Warning:} this intrinsic does not increase the range of the timing
7864 values over that returned by @code{clock(3)}. On a system with a 32-bit
7865 @code{clock(3)}, @code{MCLOCK8()} will return a 32-bit value, even though
7866 it is converted to a 64-bit @code{INTEGER(8)} value. That means
7867 overflows of the 32-bit value can still occur. Therefore, the values
7868 returned by this intrinsic might be or become negative or numerically
7869 less than previous values during a single run of the compiled program.
7870
7871 @item @emph{Standard}:
7872 GNU extension
7873
7874 @item @emph{Class}:
7875 Function
7876
7877 @item @emph{Syntax}:
7878 @code{RESULT = MCLOCK8()}
7879
7880 @item @emph{Return value}:
7881 The return value is a scalar of type @code{INTEGER(8)}, equal to the
7882 number of clock ticks since the start of the process, or @code{-1} if
7883 the system does not support @code{clock(3)}.
7884
7885 @item @emph{See also}:
7886 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
7887
7888 @end table
7889
7890
7891
7892 @node MERGE
7893 @section @code{MERGE} --- Merge variables
7894 @fnindex MERGE
7895 @cindex array, merge arrays
7896 @cindex array, combine arrays
7897
7898 @table @asis
7899 @item @emph{Description}:
7900 Select values from two arrays according to a logical mask.  The result
7901 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
7902 @var{FSOURCE} if it is @code{.FALSE.}.
7903
7904 @item @emph{Standard}:
7905 Fortran 95 and later
7906
7907 @item @emph{Class}:
7908 Elemental function
7909
7910 @item @emph{Syntax}:
7911 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
7912
7913 @item @emph{Arguments}:
7914 @multitable @columnfractions .15 .70
7915 @item @var{TSOURCE} @tab May be of any type.
7916 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
7917 as @var{TSOURCE}.
7918 @item @var{MASK}    @tab Shall be of type @code{LOGICAL}.
7919 @end multitable
7920
7921 @item @emph{Return value}:
7922 The result is of the same type and type parameters as @var{TSOURCE}.
7923
7924 @end table
7925
7926
7927
7928 @node MIN
7929 @section @code{MIN} --- Minimum value of an argument list
7930 @fnindex MIN
7931 @fnindex MIN0
7932 @fnindex AMIN0
7933 @fnindex MIN1
7934 @fnindex AMIN1
7935 @fnindex DMIN1
7936 @cindex minimum value
7937
7938 @table @asis
7939 @item @emph{Description}:
7940 Returns the argument with the smallest (most negative) value.
7941
7942 @item @emph{Standard}:
7943 Fortran 77 and later
7944
7945 @item @emph{Class}:
7946 Elemental function
7947
7948 @item @emph{Syntax}:
7949 @code{RESULT = MIN(A1, A2 [, A3, ...])}
7950
7951 @item @emph{Arguments}:
7952 @multitable @columnfractions .15 .70
7953 @item @var{A1}          @tab The type shall be @code{INTEGER} or
7954 @code{REAL}.
7955 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
7956 as @var{A1}.  (As a GNU extension, arguments of different kinds are
7957 permitted.)
7958 @end multitable
7959
7960 @item @emph{Return value}:
7961 The return value corresponds to the maximum value among the arguments,
7962 and has the same type and kind as the first argument.
7963
7964 @item @emph{Specific names}:
7965 @multitable @columnfractions .20 .20 .20 .25
7966 @item Name              @tab Argument             @tab Return type        @tab Standard
7967 @item @code{MIN0(A1)}   @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)}  @tab Fortran 77 and later
7968 @item @code{AMIN0(A1)}  @tab @code{INTEGER(4) A1} @tab @code{REAL(4)}     @tab Fortran 77 and later
7969 @item @code{MIN1(A1)}   @tab @code{REAL A1}       @tab @code{INTEGER(4)}  @tab Fortran 77 and later
7970 @item @code{AMIN1(A1)}  @tab @code{REAL(4) A1}    @tab @code{REAL(4)}     @tab Fortran 77 and later
7971 @item @code{DMIN1(A1)}  @tab @code{REAL(8) A1}    @tab @code{REAL(8)}     @tab Fortran 77 and later
7972 @end multitable
7973
7974 @item @emph{See also}:
7975 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
7976 @end table
7977
7978
7979
7980 @node MINEXPONENT
7981 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
7982 @fnindex MINEXPONENT
7983 @cindex model representation, minimum exponent
7984
7985 @table @asis
7986 @item @emph{Description}:
7987 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
7988 type of @code{X}.
7989
7990 @item @emph{Standard}:
7991 Fortran 95 and later
7992
7993 @item @emph{Class}:
7994 Inquiry function
7995
7996 @item @emph{Syntax}:
7997 @code{RESULT = MINEXPONENT(X)}
7998
7999 @item @emph{Arguments}:
8000 @multitable @columnfractions .15 .70
8001 @item @var{X} @tab Shall be of type @code{REAL}.
8002 @end multitable
8003
8004 @item @emph{Return value}:
8005 The return value is of type @code{INTEGER} and of the default integer
8006 kind.
8007
8008 @item @emph{Example}:
8009 See @code{MAXEXPONENT} for an example.
8010 @end table
8011
8012
8013
8014 @node MINLOC
8015 @section @code{MINLOC} --- Location of the minimum value within an array
8016 @fnindex MINLOC
8017 @cindex array, location of minimum element
8018
8019 @table @asis
8020 @item @emph{Description}:
8021 Determines the location of the element in the array with the minimum
8022 value, or, if the @var{DIM} argument is supplied, determines the
8023 locations of the minimum element along each row of the array in the
8024 @var{DIM} direction.  If @var{MASK} is present, only the elements for
8025 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
8026 element in the array has the minimum value, the location returned is
8027 that of the first such element in array element order.  If the array has
8028 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
8029 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
8030 and all of the elements of @var{MASK} along a given row are zero, the
8031 result value for that row is zero.
8032
8033 @item @emph{Standard}:
8034 Fortran 95 and later
8035
8036 @item @emph{Class}:
8037 Transformational function
8038
8039 @item @emph{Syntax}:
8040 @multitable @columnfractions .80
8041 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
8042 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
8043 @end multitable
8044
8045 @item @emph{Arguments}:
8046 @multitable @columnfractions .15 .70
8047 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8048 @code{REAL}.
8049 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8050 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8051 inclusive.  It may not be an optional dummy argument.
8052 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8053 and conformable with @var{ARRAY}.
8054 @end multitable
8055
8056 @item @emph{Return value}:
8057 If @var{DIM} is absent, the result is a rank-one array with a length
8058 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
8059 is an array with a rank one less than the rank of @var{ARRAY}, and a
8060 size corresponding to the size of @var{ARRAY} with the @var{DIM}
8061 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
8062 of one, the result is a scalar.  In all cases, the result is of default
8063 @code{INTEGER} type.
8064
8065 @item @emph{See also}:
8066 @ref{MIN}, @ref{MINVAL}
8067
8068 @end table
8069
8070
8071
8072 @node MINVAL
8073 @section @code{MINVAL} --- Minimum value of an array
8074 @fnindex MINVAL
8075 @cindex array, minimum value
8076 @cindex minimum value
8077
8078 @table @asis
8079 @item @emph{Description}:
8080 Determines the minimum value of the elements in an array value, or, if
8081 the @var{DIM} argument is supplied, determines the minimum value along
8082 each row of the array in the @var{DIM} direction.  If @var{MASK} is
8083 present, only the elements for which @var{MASK} is @code{.TRUE.} are
8084 considered.  If the array has zero size, or all of the elements of
8085 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
8086 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
8087 @var{ARRAY} is of character type.
8088
8089 @item @emph{Standard}:
8090 Fortran 95 and later
8091
8092 @item @emph{Class}:
8093 Transformational function
8094
8095 @item @emph{Syntax}:
8096 @multitable @columnfractions .80
8097 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
8098 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
8099 @end multitable
8100
8101 @item @emph{Arguments}:
8102 @multitable @columnfractions .15 .70
8103 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8104 @code{REAL}.
8105 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8106 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8107 inclusive.  It may not be an optional dummy argument.
8108 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8109 and conformable with @var{ARRAY}.
8110 @end multitable
8111
8112 @item @emph{Return value}:
8113 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
8114 is a scalar.  If @var{DIM} is present, the result is an array with a
8115 rank one less than the rank of @var{ARRAY}, and a size corresponding to
8116 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
8117 cases, the result is of the same type and kind as @var{ARRAY}.
8118
8119 @item @emph{See also}:
8120 @ref{MIN}, @ref{MINLOC}
8121
8122 @end table
8123
8124
8125
8126 @node MOD
8127 @section @code{MOD} --- Remainder function
8128 @fnindex MOD
8129 @fnindex AMOD
8130 @fnindex DMOD
8131 @cindex remainder
8132 @cindex division, remainder
8133
8134 @table @asis
8135 @item @emph{Description}:
8136 @code{MOD(A,P)} computes the remainder of the division of A by P@. It is
8137 calculated as @code{A - (INT(A/P) * P)}.
8138
8139 @item @emph{Standard}:
8140 Fortran 77 and later
8141
8142 @item @emph{Class}:
8143 Elemental function
8144
8145 @item @emph{Syntax}:
8146 @code{RESULT = MOD(A, P)}
8147
8148 @item @emph{Arguments}:
8149 @multitable @columnfractions .15 .70
8150 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
8151 @item @var{P} @tab Shall be a scalar of the same type as @var{A} and not
8152 equal to zero
8153 @end multitable
8154
8155 @item @emph{Return value}:
8156 The kind of the return value is the result of cross-promoting
8157 the kinds of the arguments.
8158
8159 @item @emph{Example}:
8160 @smallexample
8161 program test_mod
8162   print *, mod(17,3)
8163   print *, mod(17.5,5.5)
8164   print *, mod(17.5d0,5.5)
8165   print *, mod(17.5,5.5d0)
8166
8167   print *, mod(-17,3)
8168   print *, mod(-17.5,5.5)
8169   print *, mod(-17.5d0,5.5)
8170   print *, mod(-17.5,5.5d0)
8171
8172   print *, mod(17,-3)
8173   print *, mod(17.5,-5.5)
8174   print *, mod(17.5d0,-5.5)
8175   print *, mod(17.5,-5.5d0)
8176 end program test_mod
8177 @end smallexample
8178
8179 @item @emph{Specific names}:
8180 @multitable @columnfractions .20 .20 .20 .25
8181 @item Name             @tab Arguments          @tab Return type    @tab Standard
8182 @item @code{MOD(A,P)}  @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 95 and later
8183 @item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 95 and later
8184 @item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 95 and later
8185 @end multitable
8186 @end table
8187
8188
8189
8190 @node MODULO
8191 @section @code{MODULO} --- Modulo function
8192 @fnindex MODULO
8193 @cindex modulo
8194 @cindex division, modulo
8195
8196 @table @asis
8197 @item @emph{Description}:
8198 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
8199
8200 @item @emph{Standard}:
8201 Fortran 95 and later
8202
8203 @item @emph{Class}:
8204 Elemental function
8205
8206 @item @emph{Syntax}:
8207 @code{RESULT = MODULO(A, P)}
8208
8209 @item @emph{Arguments}:
8210 @multitable @columnfractions .15 .70
8211 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
8212 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
8213 @end multitable
8214
8215 @item @emph{Return value}:
8216 The type and kind of the result are those of the arguments.
8217 @table @asis
8218 @item If @var{A} and @var{P} are of type @code{INTEGER}:
8219 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
8220 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
8221 (exclusive).
8222 @item If @var{A} and @var{P} are of type @code{REAL}:
8223 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
8224 @end table
8225 In all cases, if @var{P} is zero the result is processor-dependent.
8226
8227 @item @emph{Example}:
8228 @smallexample
8229 program test_modulo
8230   print *, modulo(17,3)
8231   print *, modulo(17.5,5.5)
8232
8233   print *, modulo(-17,3)
8234   print *, modulo(-17.5,5.5)
8235
8236   print *, modulo(17,-3)
8237   print *, modulo(17.5,-5.5)
8238 end program
8239 @end smallexample
8240
8241 @end table
8242
8243
8244
8245 @node MOVE_ALLOC
8246 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
8247 @fnindex MOVE_ALLOC
8248 @cindex moving allocation
8249 @cindex allocation, moving
8250
8251 @table @asis
8252 @item @emph{Description}:
8253 @code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
8254 @var{TO}.  @var{FROM} will become deallocated in the process.
8255
8256 @item @emph{Standard}:
8257 Fortran 2003 and later
8258
8259 @item @emph{Class}:
8260 Subroutine
8261
8262 @item @emph{Syntax}:
8263 @code{CALL MOVE_ALLOC(FROM, TO)}
8264
8265 @item @emph{Arguments}:
8266 @multitable @columnfractions .15 .70
8267 @item @var{FROM}  @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
8268 of any type and kind.
8269 @item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
8270 of the same type, kind and rank as @var{FROM}.
8271 @end multitable
8272
8273 @item @emph{Return value}:
8274 None
8275
8276 @item @emph{Example}:
8277 @smallexample
8278 program test_move_alloc
8279     integer, allocatable :: a(:), b(:)
8280
8281     allocate(a(3))
8282     a = [ 1, 2, 3 ]
8283     call move_alloc(a, b)
8284     print *, allocated(a), allocated(b)
8285     print *, b
8286 end program test_move_alloc
8287 @end smallexample
8288 @end table
8289
8290
8291
8292 @node MVBITS
8293 @section @code{MVBITS} --- Move bits from one integer to another
8294 @fnindex MVBITS
8295 @cindex bits, move
8296
8297 @table @asis
8298 @item @emph{Description}:
8299 Moves @var{LEN} bits from positions @var{FROMPOS} through
8300 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
8301 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
8302 affected by the movement of bits is unchanged. The values of
8303 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
8304 @code{BIT_SIZE(FROM)}.
8305
8306 @item @emph{Standard}:
8307 Fortran 95 and later
8308
8309 @item @emph{Class}:
8310 Elemental subroutine
8311
8312 @item @emph{Syntax}:
8313 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
8314
8315 @item @emph{Arguments}:
8316 @multitable @columnfractions .15 .70
8317 @item @var{FROM}    @tab The type shall be @code{INTEGER}.
8318 @item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
8319 @item @var{LEN}     @tab The type shall be @code{INTEGER}.
8320 @item @var{TO}      @tab The type shall be @code{INTEGER}, of the
8321 same kind as @var{FROM}.
8322 @item @var{TOPOS}   @tab The type shall be @code{INTEGER}.
8323 @end multitable
8324
8325 @item @emph{See also}:
8326 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
8327 @end table
8328
8329
8330
8331 @node NEAREST
8332 @section @code{NEAREST} --- Nearest representable number
8333 @fnindex NEAREST
8334 @cindex real number, nearest different
8335 @cindex floating point, nearest different
8336
8337 @table @asis
8338 @item @emph{Description}:
8339 @code{NEAREST(X, S)} returns the processor-representable number nearest
8340 to @code{X} in the direction indicated by the sign of @code{S}.
8341
8342 @item @emph{Standard}:
8343 Fortran 95 and later
8344
8345 @item @emph{Class}:
8346 Elemental function
8347
8348 @item @emph{Syntax}:
8349 @code{RESULT = NEAREST(X, S)}
8350
8351 @item @emph{Arguments}:
8352 @multitable @columnfractions .15 .70
8353 @item @var{X} @tab Shall be of type @code{REAL}.
8354 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
8355 not equal to zero.
8356 @end multitable
8357
8358 @item @emph{Return value}:
8359 The return value is of the same type as @code{X}. If @code{S} is
8360 positive, @code{NEAREST} returns the processor-representable number
8361 greater than @code{X} and nearest to it. If @code{S} is negative,
8362 @code{NEAREST} returns the processor-representable number smaller than
8363 @code{X} and nearest to it.
8364
8365 @item @emph{Example}:
8366 @smallexample
8367 program test_nearest
8368   real :: x, y
8369   x = nearest(42.0, 1.0)
8370   y = nearest(42.0, -1.0)
8371   write (*,"(3(G20.15))") x, y, x - y
8372 end program test_nearest
8373 @end smallexample
8374 @end table
8375
8376
8377
8378 @node NEW_LINE
8379 @section @code{NEW_LINE} --- New line character
8380 @fnindex NEW_LINE
8381 @cindex newline
8382 @cindex output, newline
8383
8384 @table @asis
8385 @item @emph{Description}:
8386 @code{NEW_LINE(C)} returns the new-line character.
8387
8388 @item @emph{Standard}:
8389 Fortran 2003 and later
8390
8391 @item @emph{Class}:
8392 Inquiry function
8393
8394 @item @emph{Syntax}:
8395 @code{RESULT = NEW_LINE(C)}
8396
8397 @item @emph{Arguments}:
8398 @multitable @columnfractions .15 .70
8399 @item @var{C}    @tab The argument shall be a scalar or array of the
8400 type @code{CHARACTER}.
8401 @end multitable
8402
8403 @item @emph{Return value}:
8404 Returns a @var{CHARACTER} scalar of length one with the new-line character of
8405 the same kind as parameter @var{C}.
8406
8407 @item @emph{Example}:
8408 @smallexample
8409 program newline
8410   implicit none
8411   write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
8412 end program newline
8413 @end smallexample
8414 @end table
8415
8416
8417
8418 @node NINT
8419 @section @code{NINT} --- Nearest whole number
8420 @fnindex NINT
8421 @fnindex IDNINT
8422 @cindex rounding, nearest whole number
8423
8424 @table @asis
8425 @item @emph{Description}:
8426 @code{NINT(A)} rounds its argument to the nearest whole number.
8427
8428 @item @emph{Standard}:
8429 Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
8430
8431 @item @emph{Class}:
8432 Elemental function
8433
8434 @item @emph{Syntax}:
8435 @code{RESULT = NINT(A [, KIND])}
8436
8437 @item @emph{Arguments}:
8438 @multitable @columnfractions .15 .70
8439 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
8440 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8441 expression indicating the kind parameter of the result.
8442 @end multitable
8443
8444 @item @emph{Return value}:
8445 Returns @var{A} with the fractional portion of its magnitude eliminated by
8446 rounding to the nearest whole number and with its sign preserved,
8447 converted to an @code{INTEGER} of the default kind.
8448
8449 @item @emph{Example}:
8450 @smallexample
8451 program test_nint
8452   real(4) x4
8453   real(8) x8
8454   x4 = 1.234E0_4
8455   x8 = 4.321_8
8456   print *, nint(x4), idnint(x8)
8457 end program test_nint
8458 @end smallexample
8459
8460 @item @emph{Specific names}:
8461 @multitable @columnfractions .20 .20 .20 .25
8462 @item Name             @tab Argument           @tab Return Type     @tab Standard
8463 @item @code{NINT(A)}   @tab @code{REAL(4) A}   @tab  @code{INTEGER} @tab Fortran 95 and later
8464 @item @code{IDNINT(A)} @tab @code{REAL(8) A}   @tab  @code{INTEGER} @tab Fortran 95 and later
8465 @end multitable
8466
8467 @item @emph{See also}:
8468 @ref{CEILING}, @ref{FLOOR}
8469
8470 @end table
8471
8472
8473
8474 @node NOT
8475 @section @code{NOT} --- Logical negation
8476 @fnindex NOT
8477 @cindex bits, negate
8478 @cindex bitwise logical not
8479 @cindex logical not, bitwise
8480
8481 @table @asis
8482 @item @emph{Description}:
8483 @code{NOT} returns the bitwise boolean inverse of @var{I}.
8484
8485 @item @emph{Standard}:
8486 Fortran 95 and later
8487
8488 @item @emph{Class}:
8489 Elemental function
8490
8491 @item @emph{Syntax}:
8492 @code{RESULT = NOT(I)}
8493
8494 @item @emph{Arguments}:
8495 @multitable @columnfractions .15 .70
8496 @item @var{I} @tab The type shall be @code{INTEGER}.
8497 @end multitable
8498
8499 @item @emph{Return value}:
8500 The return type is @code{INTEGER}, of the same kind as the
8501 argument.
8502
8503 @item @emph{See also}:
8504 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
8505
8506 @end table
8507
8508
8509
8510 @node NULL
8511 @section @code{NULL} --- Function that returns an disassociated pointer
8512 @fnindex NULL
8513 @cindex pointer, status
8514 @cindex pointer, disassociated
8515
8516 @table @asis
8517 @item @emph{Description}:
8518 Returns a disassociated pointer.
8519
8520 If @var{MOLD} is present, a dissassociated pointer of the same type is
8521 returned, otherwise the type is determined by context.
8522
8523 In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
8524 includes cases where it is required.
8525
8526 @item @emph{Standard}:
8527 Fortran 95 and later
8528
8529 @item @emph{Class}:
8530 Transformational function
8531
8532 @item @emph{Syntax}:
8533 @code{PTR => NULL([MOLD])}
8534
8535 @item @emph{Arguments}:
8536 @multitable @columnfractions .15 .70
8537 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
8538 status and of any type.
8539 @end multitable
8540
8541 @item @emph{Return value}:
8542 A disassociated pointer.
8543
8544 @item @emph{Example}:
8545 @smallexample
8546 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
8547 @end smallexample
8548
8549 @item @emph{See also}:
8550 @ref{ASSOCIATED}
8551 @end table
8552
8553
8554
8555 @node NUM_IMAGES
8556 @section @code{NUM_IMAGES} --- Function that returns the number of images
8557 @fnindex NUM_IMAGES
8558 @cindex coarray, NUM_IMAGES
8559 @cindex images, number of
8560
8561 @table @asis
8562 @item @emph{Description}:
8563 Returns the number of images.
8564
8565 @item @emph{Standard}:
8566 Fortran 2008 and later
8567
8568 @item @emph{Class}:
8569 Transformational function
8570
8571 @item @emph{Syntax}:
8572 @code{RESULT = NUM_IMAGES()}
8573
8574 @item @emph{Arguments}: None.
8575
8576 @item @emph{Return value}:
8577 Scalar default-kind integer.
8578
8579 @item @emph{Example}:
8580 @smallexample
8581 INTEGER :: value[*]
8582 INTEGER :: i
8583 value = THIS_IMAGE()
8584 SYNC ALL
8585 IF (THIS_IMAGE() == 1) THEN
8586   DO i = 1, NUM_IMAGES()
8587     WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
8588   END DO
8589 END IF
8590 @end smallexample
8591
8592 @item @emph{See also}:
8593 @ref{THIS_IMAGE}, @ref{IMAGE_INDEX}
8594 @end table
8595
8596
8597
8598 @node OR
8599 @section @code{OR} --- Bitwise logical OR
8600 @fnindex OR
8601 @cindex bitwise logical or
8602 @cindex logical or, bitwise
8603
8604 @table @asis
8605 @item @emph{Description}:
8606 Bitwise logical @code{OR}.
8607
8608 This intrinsic routine is provided for backwards compatibility with 
8609 GNU Fortran 77.  For integer arguments, programmers should consider
8610 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
8611
8612 @item @emph{Standard}:
8613 GNU extension
8614
8615 @item @emph{Class}:
8616 Function
8617
8618 @item @emph{Syntax}:
8619 @code{RESULT = OR(I, J)}
8620
8621 @item @emph{Arguments}:
8622 @multitable @columnfractions .15 .70
8623 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
8624 type or a scalar @code{LOGICAL} type.
8625 @item @var{J} @tab The type shall be the same as the type of @var{J}.
8626 @end multitable
8627
8628 @item @emph{Return value}:
8629 The return type is either a scalar @code{INTEGER} or a scalar
8630 @code{LOGICAL}.  If the kind type parameters differ, then the
8631 smaller kind type is implicitly converted to larger kind, and the 
8632 return has the larger kind.
8633
8634 @item @emph{Example}:
8635 @smallexample
8636 PROGRAM test_or
8637   LOGICAL :: T = .TRUE., F = .FALSE.
8638   INTEGER :: a, b
8639   DATA a / Z'F' /, b / Z'3' /
8640
8641   WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
8642   WRITE (*,*) OR(a, b)
8643 END PROGRAM
8644 @end smallexample
8645
8646 @item @emph{See also}:
8647 Fortran 95 elemental function: @ref{IOR}
8648 @end table
8649
8650
8651
8652 @node PACK
8653 @section @code{PACK} --- Pack an array into an array of rank one
8654 @fnindex PACK
8655 @cindex array, packing
8656 @cindex array, reduce dimension
8657 @cindex array, gather elements
8658
8659 @table @asis
8660 @item @emph{Description}:
8661 Stores the elements of @var{ARRAY} in an array of rank one.
8662
8663 The beginning of the resulting array is made up of elements whose @var{MASK} 
8664 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
8665 @var{VECTOR}.
8666
8667 @item @emph{Standard}:
8668 Fortran 95 and later
8669
8670 @item @emph{Class}:
8671 Transformational function
8672
8673 @item @emph{Syntax}:
8674 @code{RESULT = PACK(ARRAY, MASK[,VECTOR]}
8675
8676 @item @emph{Arguments}:
8677 @multitable @columnfractions .15 .70
8678 @item @var{ARRAY}  @tab Shall be an array of any type.
8679 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL} and 
8680 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL} 
8681 scalar.
8682 @item @var{VECTOR} @tab (Optional) shall be an array of the same type 
8683 as @var{ARRAY} and of rank one. If present, the number of elements in 
8684 @var{VECTOR} shall be equal to or greater than the number of true elements 
8685 in @var{MASK}. If @var{MASK} is scalar, the number of elements in 
8686 @var{VECTOR} shall be equal to or greater than the number of elements in
8687 @var{ARRAY}.
8688 @end multitable
8689
8690 @item @emph{Return value}:
8691 The result is an array of rank one and the same type as that of @var{ARRAY}.
8692 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
8693 number of @code{TRUE} values in @var{MASK} otherwise.
8694
8695 @item @emph{Example}:
8696 Gathering nonzero elements from an array:
8697 @smallexample
8698 PROGRAM test_pack_1
8699   INTEGER :: m(6)
8700   m = (/ 1, 0, 0, 0, 5, 0 /)
8701   WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0)  ! "1 5"
8702 END PROGRAM
8703 @end smallexample
8704
8705 Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
8706 @smallexample
8707 PROGRAM test_pack_2
8708   INTEGER :: m(4)
8709   m = (/ 1, 0, 0, 2 /)
8710   WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /))  ! "1 2 3 4"
8711 END PROGRAM
8712 @end smallexample
8713
8714 @item @emph{See also}:
8715 @ref{UNPACK}
8716 @end table
8717
8718
8719
8720 @node PERROR
8721 @section @code{PERROR} --- Print system error message
8722 @fnindex PERROR
8723 @cindex system, error handling
8724
8725 @table @asis
8726 @item @emph{Description}:
8727 Prints (on the C @code{stderr} stream) a newline-terminated error
8728 message corresponding to the last system error. This is prefixed by
8729 @var{STRING}, a colon and a space. See @code{perror(3)}.
8730
8731 @item @emph{Standard}:
8732 GNU extension
8733
8734 @item @emph{Class}:
8735 Subroutine
8736
8737 @item @emph{Syntax}:
8738 @code{CALL PERROR(STRING)}
8739
8740 @item @emph{Arguments}:
8741 @multitable @columnfractions .15 .70
8742 @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
8743 default kind.
8744 @end multitable
8745
8746 @item @emph{See also}:
8747 @ref{IERRNO}
8748 @end table
8749
8750
8751
8752 @node PRECISION
8753 @section @code{PRECISION} --- Decimal precision of a real kind
8754 @fnindex PRECISION
8755 @cindex model representation, precision
8756
8757 @table @asis
8758 @item @emph{Description}:
8759 @code{PRECISION(X)} returns the decimal precision in the model of the
8760 type of @code{X}.
8761
8762 @item @emph{Standard}:
8763 Fortran 95 and later
8764
8765 @item @emph{Class}:
8766 Inquiry function
8767
8768 @item @emph{Syntax}:
8769 @code{RESULT = PRECISION(X)}
8770
8771 @item @emph{Arguments}:
8772 @multitable @columnfractions .15 .70
8773 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
8774 @end multitable
8775
8776 @item @emph{Return value}:
8777 The return value is of type @code{INTEGER} and of the default integer
8778 kind.
8779
8780 @item @emph{See also}:
8781 @ref{SELECTED_REAL_KIND}, @ref{RANGE}
8782
8783 @item @emph{Example}:
8784 @smallexample
8785 program prec_and_range
8786   real(kind=4) :: x(2)
8787   complex(kind=8) :: y
8788
8789   print *, precision(x), range(x)
8790   print *, precision(y), range(y)
8791 end program prec_and_range
8792 @end smallexample
8793 @end table
8794
8795
8796
8797 @node PRESENT
8798 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
8799 @fnindex PRESENT
8800
8801 @table @asis
8802 @item @emph{Description}:
8803 Determines whether an optional dummy argument is present.
8804
8805 @item @emph{Standard}:
8806 Fortran 95 and later
8807
8808 @item @emph{Class}:
8809 Inquiry function
8810
8811 @item @emph{Syntax}:
8812 @code{RESULT = PRESENT(A)}
8813
8814 @item @emph{Arguments}:
8815 @multitable @columnfractions .15 .70
8816 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
8817 value, or a dummy procedure. It shall be the name of an optional dummy argument
8818 accessible within the current subroutine or function.
8819 @end multitable
8820
8821 @item @emph{Return value}:
8822 Returns either @code{TRUE} if the optional argument @var{A} is present, or
8823 @code{FALSE} otherwise.
8824
8825 @item @emph{Example}:
8826 @smallexample
8827 PROGRAM test_present
8828   WRITE(*,*) f(), f(42)      ! "F T"
8829 CONTAINS
8830   LOGICAL FUNCTION f(x)
8831     INTEGER, INTENT(IN), OPTIONAL :: x
8832     f = PRESENT(x)
8833   END FUNCTION
8834 END PROGRAM
8835 @end smallexample
8836 @end table
8837
8838
8839
8840 @node PRODUCT
8841 @section @code{PRODUCT} --- Product of array elements
8842 @fnindex PRODUCT
8843 @cindex array, product
8844 @cindex array, multiply elements
8845 @cindex array, conditionally multiply elements
8846 @cindex multiply array elements
8847
8848 @table @asis
8849 @item @emph{Description}:
8850 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
8851 the corresponding element in @var{MASK} is @code{TRUE}.
8852
8853 @item @emph{Standard}:
8854 Fortran 95 and later
8855
8856 @item @emph{Class}:
8857 Transformational function
8858
8859 @item @emph{Syntax}:
8860 @multitable @columnfractions .80
8861 @item @code{RESULT = PRODUCT(ARRAY[, MASK])}
8862 @item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
8863 @end multitable
8864
8865 @item @emph{Arguments}:
8866 @multitable @columnfractions .15 .70
8867 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
8868 @code{REAL} or @code{COMPLEX}.
8869 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
8870 @code{INTEGER} with a value in the range from 1 to n, where n 
8871 equals the rank of @var{ARRAY}.
8872 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
8873 and either be a scalar or an array of the same shape as @var{ARRAY}.
8874 @end multitable
8875
8876 @item @emph{Return value}:
8877 The result is of the same type as @var{ARRAY}.
8878
8879 If @var{DIM} is absent, a scalar with the product of all elements in 
8880 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals 
8881 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with 
8882 dimension @var{DIM} dropped is returned.
8883
8884
8885 @item @emph{Example}:
8886 @smallexample
8887 PROGRAM test_product
8888   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
8889   print *, PRODUCT(x)                    ! all elements, product = 120
8890   print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
8891 END PROGRAM
8892 @end smallexample
8893
8894 @item @emph{See also}:
8895 @ref{SUM}
8896 @end table
8897
8898
8899
8900 @node RADIX
8901 @section @code{RADIX} --- Base of a model number
8902 @fnindex RADIX
8903 @cindex model representation, base
8904 @cindex model representation, radix
8905
8906 @table @asis
8907 @item @emph{Description}:
8908 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
8909
8910 @item @emph{Standard}:
8911 Fortran 95 and later
8912
8913 @item @emph{Class}:
8914 Inquiry function
8915
8916 @item @emph{Syntax}:
8917 @code{RESULT = RADIX(X)}
8918
8919 @item @emph{Arguments}:
8920 @multitable @columnfractions .15 .70
8921 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
8922 @end multitable
8923
8924 @item @emph{Return value}:
8925 The return value is a scalar of type @code{INTEGER} and of the default
8926 integer kind.
8927
8928 @item @emph{See also}:
8929 @ref{SELECTED_REAL_KIND}
8930
8931 @item @emph{Example}:
8932 @smallexample
8933 program test_radix
8934   print *, "The radix for the default integer kind is", radix(0)
8935   print *, "The radix for the default real kind is", radix(0.0)
8936 end program test_radix
8937 @end smallexample
8938
8939 @end table
8940
8941
8942
8943 @node RAN
8944 @section @code{RAN} --- Real pseudo-random number
8945 @fnindex RAN
8946 @cindex random number generation
8947
8948 @table @asis
8949 @item @emph{Description}:
8950 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
8951 provided as an alias for @code{RAND}.  See @ref{RAND} for complete
8952 documentation.
8953
8954 @item @emph{Standard}:
8955 GNU extension
8956
8957 @item @emph{Class}:
8958 Function
8959
8960 @item @emph{See also}:
8961 @ref{RAND}, @ref{RANDOM_NUMBER}
8962 @end table
8963
8964
8965
8966 @node RAND
8967 @section @code{RAND} --- Real pseudo-random number
8968 @fnindex RAND
8969 @cindex random number generation
8970
8971 @table @asis
8972 @item @emph{Description}:
8973 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
8974 distribution between 0 and 1. If @var{FLAG} is 0, the next number
8975 in the current sequence is returned; if @var{FLAG} is 1, the generator
8976 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
8977 it is used as a new seed with @code{SRAND}.
8978
8979 This intrinsic routine is provided for backwards compatibility with
8980 GNU Fortran 77. It implements a simple modulo generator as provided 
8981 by @command{g77}. For new code, one should consider the use of 
8982 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
8983
8984 @item @emph{Standard}:
8985 GNU extension
8986
8987 @item @emph{Class}:
8988 Function
8989
8990 @item @emph{Syntax}:
8991 @code{RESULT = RAND(I)}
8992
8993 @item @emph{Arguments}:
8994 @multitable @columnfractions .15 .70
8995 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
8996 @end multitable
8997
8998 @item @emph{Return value}:
8999 The return value is of @code{REAL} type and the default kind.
9000
9001 @item @emph{Example}:
9002 @smallexample
9003 program test_rand
9004   integer,parameter :: seed = 86456
9005   
9006   call srand(seed)
9007   print *, rand(), rand(), rand(), rand()
9008   print *, rand(seed), rand(), rand(), rand()
9009 end program test_rand
9010 @end smallexample
9011
9012 @item @emph{See also}:
9013 @ref{SRAND}, @ref{RANDOM_NUMBER}
9014
9015 @end table
9016
9017
9018
9019 @node RANDOM_NUMBER
9020 @section @code{RANDOM_NUMBER} --- Pseudo-random number
9021 @fnindex RANDOM_NUMBER
9022 @cindex random number generation
9023
9024 @table @asis
9025 @item @emph{Description}:
9026 Returns a single pseudorandom number or an array of pseudorandom numbers
9027 from the uniform distribution over the range @math{ 0 \leq x < 1}.
9028
9029 The runtime-library implements George Marsaglia's KISS (Keep It Simple 
9030 Stupid) random number generator (RNG). This RNG combines:
9031 @enumerate
9032 @item The congruential generator @math{x(n) = 69069 \cdot x(n-1) + 1327217885}
9033 with a period of @math{2^{32}},
9034 @item A 3-shift shift-register generator with a period of @math{2^{32} - 1},
9035 @item  Two 16-bit multiply-with-carry generators with a period of
9036 @math{597273182964842497 > 2^{59}}.
9037 @end enumerate
9038 The overall period exceeds @math{2^{123}}.
9039
9040 Please note, this RNG is thread safe if used within OpenMP directives,
9041 i.e., its state will be consistent while called from multiple threads.
9042 However, the KISS generator does not create random numbers in parallel 
9043 from multiple sources, but in sequence from a single source. If an
9044 OpenMP-enabled application heavily relies on random numbers, one should 
9045 consider employing a dedicated parallel random number generator instead.
9046
9047 @item @emph{Standard}:
9048 Fortran 95 and later
9049
9050 @item @emph{Class}:
9051 Subroutine
9052
9053 @item @emph{Syntax}:
9054 @code{RANDOM_NUMBER(HARVEST)}
9055
9056 @item @emph{Arguments}:
9057 @multitable @columnfractions .15 .70
9058 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
9059 @end multitable
9060
9061 @item @emph{Example}:
9062 @smallexample
9063 program test_random_number
9064   REAL :: r(5,5)
9065   CALL init_random_seed()         ! see example of RANDOM_SEED
9066   CALL RANDOM_NUMBER(r)
9067 end program
9068 @end smallexample
9069
9070 @item @emph{See also}:
9071 @ref{RANDOM_SEED}
9072 @end table
9073
9074
9075
9076 @node RANDOM_SEED
9077 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
9078 @fnindex RANDOM_SEED
9079 @cindex random number generation, seeding
9080 @cindex seeding a random number generator
9081
9082 @table @asis
9083 @item @emph{Description}:
9084 Restarts or queries the state of the pseudorandom number generator used by 
9085 @code{RANDOM_NUMBER}.
9086
9087 If @code{RANDOM_SEED} is called without arguments, it is initialized to
9088 a default state. The example below shows how to initialize the random 
9089 seed based on the system's time.
9090
9091 @item @emph{Standard}:
9092 Fortran 95 and later
9093
9094 @item @emph{Class}:
9095 Subroutine
9096
9097 @item @emph{Syntax}:
9098 @code{CALL RANDOM_SEED([SIZE, PUT, GET])}
9099
9100 @item @emph{Arguments}:
9101 @multitable @columnfractions .15 .70
9102 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default 
9103 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size 
9104 of the arrays used with the @var{PUT} and @var{GET} arguments.
9105 @item @var{PUT}  @tab (Optional) Shall be an array of type default 
9106 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of 
9107 the array must be larger than or equal to the number returned by the 
9108 @var{SIZE} argument.
9109 @item @var{GET}  @tab (Optional) Shall be an array of type default 
9110 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size 
9111 of the array must be larger than or equal to the number returned by 
9112 the @var{SIZE} argument.
9113 @end multitable
9114
9115 @item @emph{Example}:
9116 @smallexample
9117 SUBROUTINE init_random_seed()
9118   INTEGER :: i, n, clock
9119   INTEGER, DIMENSION(:), ALLOCATABLE :: seed
9120
9121   CALL RANDOM_SEED(size = n)
9122   ALLOCATE(seed(n))
9123
9124   CALL SYSTEM_CLOCK(COUNT=clock)
9125
9126   seed = clock + 37 * (/ (i - 1, i = 1, n) /)
9127   CALL RANDOM_SEED(PUT = seed)
9128
9129   DEALLOCATE(seed)
9130 END SUBROUTINE
9131 @end smallexample
9132
9133 @item @emph{See also}:
9134 @ref{RANDOM_NUMBER}
9135 @end table
9136
9137
9138
9139 @node RANGE
9140 @section @code{RANGE} --- Decimal exponent range
9141 @fnindex RANGE
9142 @cindex model representation, range
9143
9144 @table @asis
9145 @item @emph{Description}:
9146 @code{RANGE(X)} returns the decimal exponent range in the model of the
9147 type of @code{X}.
9148
9149 @item @emph{Standard}:
9150 Fortran 95 and later
9151
9152 @item @emph{Class}:
9153 Inquiry function
9154
9155 @item @emph{Syntax}:
9156 @code{RESULT = RANGE(X)}
9157
9158 @item @emph{Arguments}:
9159 @multitable @columnfractions .15 .70
9160 @item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL}
9161 or @code{COMPLEX}.
9162 @end multitable
9163
9164 @item @emph{Return value}:
9165 The return value is of type @code{INTEGER} and of the default integer
9166 kind.
9167
9168 @item @emph{See also}:
9169 @ref{SELECTED_REAL_KIND}, @ref{PRECISION}
9170
9171 @item @emph{Example}:
9172 See @code{PRECISION} for an example.
9173 @end table
9174
9175
9176
9177 @node REAL
9178 @section @code{REAL} --- Convert to real type 
9179 @fnindex REAL
9180 @fnindex REALPART
9181 @fnindex FLOAT
9182 @fnindex DFLOAT
9183 @fnindex SNGL
9184 @cindex conversion, to real
9185 @cindex complex numbers, real part
9186
9187 @table @asis
9188 @item @emph{Description}:
9189 @code{REAL(A [, KIND])} converts its argument @var{A} to a real type.  The
9190 @code{REALPART} function is provided for compatibility with @command{g77},
9191 and its use is strongly discouraged.
9192
9193 @item @emph{Standard}:
9194 Fortran 77 and later
9195
9196 @item @emph{Class}:
9197 Elemental function
9198
9199 @item @emph{Syntax}:
9200 @multitable @columnfractions .80
9201 @item @code{RESULT = REAL(A [, KIND])}
9202 @item @code{RESULT = REALPART(Z)}
9203 @end multitable
9204
9205 @item @emph{Arguments}:
9206 @multitable @columnfractions .15 .70
9207 @item @var{A}    @tab Shall be @code{INTEGER}, @code{REAL}, or
9208 @code{COMPLEX}.
9209 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9210 expression indicating the kind parameter of the result.
9211 @end multitable
9212
9213 @item @emph{Return value}:
9214 These functions return a @code{REAL} variable or array under
9215 the following rules: 
9216
9217 @table @asis
9218 @item (A)
9219 @code{REAL(A)} is converted to a default real type if @var{A} is an 
9220 integer or real variable.
9221 @item (B)
9222 @code{REAL(A)} is converted to a real type with the kind type parameter
9223 of @var{A} if @var{A} is a complex variable.
9224 @item (C)
9225 @code{REAL(A, KIND)} is converted to a real type with kind type
9226 parameter @var{KIND} if @var{A} is a complex, integer, or real
9227 variable.
9228 @end table
9229
9230 @item @emph{Example}:
9231 @smallexample
9232 program test_real
9233   complex :: x = (1.0, 2.0)
9234   print *, real(x), real(x,8), realpart(x)
9235 end program test_real
9236 @end smallexample
9237
9238 @item @emph{Specific names}:
9239 @multitable @columnfractions .20 .20 .20 .25
9240 @item Name             @tab Argument           @tab Return type     @tab Standard
9241 @item @code{FLOAT(A)}  @tab @code{INTEGER(4)}  @tab @code{REAL(4)}  @tab Fortran 77 and later
9242 @item @code{DFLOAT(A)} @tab @code{INTEGER(4)}  @tab @code{REAL(8)}  @tab GNU extension
9243 @item @code{SNGL(A)}   @tab @code{INTEGER(8)}  @tab @code{REAL(4)}  @tab Fortran 77 and later
9244 @end multitable
9245
9246
9247 @item @emph{See also}:
9248 @ref{DBLE}
9249
9250 @end table
9251
9252
9253
9254 @node RENAME
9255 @section @code{RENAME} --- Rename a file
9256 @fnindex RENAME
9257 @cindex file system, rename file
9258
9259 @table @asis
9260 @item @emph{Description}:
9261 Renames a file from file @var{PATH1} to @var{PATH2}. A null
9262 character (@code{CHAR(0)}) can be used to mark the end of the names in
9263 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
9264 names are ignored.  If the @var{STATUS} argument is supplied, it
9265 contains 0 on success or a nonzero error code upon return; see
9266 @code{rename(2)}.
9267
9268 This intrinsic is provided in both subroutine and function forms;
9269 however, only one form can be used in any given program unit.
9270
9271 @item @emph{Standard}:
9272 GNU extension
9273
9274 @item @emph{Class}:
9275 Subroutine, function
9276
9277 @item @emph{Syntax}:
9278 @multitable @columnfractions .80
9279 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
9280 @item @code{STATUS = RENAME(PATH1, PATH2)}
9281 @end multitable
9282
9283 @item @emph{Arguments}:
9284 @multitable @columnfractions .15 .70
9285 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
9286 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
9287 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9288 @end multitable
9289
9290 @item @emph{See also}:
9291 @ref{LINK}
9292
9293 @end table
9294
9295
9296
9297 @node REPEAT
9298 @section @code{REPEAT} --- Repeated string concatenation 
9299 @fnindex REPEAT
9300 @cindex string, repeat
9301 @cindex string, concatenate
9302
9303 @table @asis
9304 @item @emph{Description}:
9305 Concatenates @var{NCOPIES} copies of a string.
9306
9307 @item @emph{Standard}:
9308 Fortran 95 and later
9309
9310 @item @emph{Class}:
9311 Transformational function
9312
9313 @item @emph{Syntax}:
9314 @code{RESULT = REPEAT(STRING, NCOPIES)}
9315
9316 @item @emph{Arguments}:
9317 @multitable @columnfractions .15 .70
9318 @item @var{STRING}  @tab Shall be scalar and of type @code{CHARACTER}.
9319 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
9320 @end multitable
9321
9322 @item @emph{Return value}:
9323 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies 
9324 of @var{STRING}.
9325
9326 @item @emph{Example}:
9327 @smallexample
9328 program test_repeat
9329   write(*,*) repeat("x", 5)   ! "xxxxx"
9330 end program
9331 @end smallexample
9332 @end table
9333
9334
9335
9336 @node RESHAPE
9337 @section @code{RESHAPE} --- Function to reshape an array
9338 @fnindex RESHAPE
9339 @cindex array, change dimensions
9340 @cindex array, transmogrify
9341
9342 @table @asis
9343 @item @emph{Description}:
9344 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
9345 the new array may be padded with elements from @var{PAD} or permuted
9346 as defined by @var{ORDER}.
9347
9348 @item @emph{Standard}:
9349 Fortran 95 and later
9350
9351 @item @emph{Class}:
9352 Transformational function
9353
9354 @item @emph{Syntax}:
9355 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
9356
9357 @item @emph{Arguments}:
9358 @multitable @columnfractions .15 .70
9359 @item @var{SOURCE} @tab Shall be an array of any type.
9360 @item @var{SHAPE}  @tab Shall be of type @code{INTEGER} and an 
9361 array of rank one. Its values must be positive or zero.
9362 @item @var{PAD}    @tab (Optional) shall be an array of the same 
9363 type as @var{SOURCE}.
9364 @item @var{ORDER}  @tab (Optional) shall be of type @code{INTEGER}
9365 and an array of the same shape as @var{SHAPE}. Its values shall
9366 be a permutation of the numbers from 1 to n, where n is the size of 
9367 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
9368 be assumed.
9369 @end multitable
9370
9371 @item @emph{Return value}:
9372 The result is an array of shape @var{SHAPE} with the same type as 
9373 @var{SOURCE}. 
9374
9375 @item @emph{Example}:
9376 @smallexample
9377 PROGRAM test_reshape
9378   INTEGER, DIMENSION(4) :: x
9379   WRITE(*,*) SHAPE(x)                       ! prints "4"
9380   WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/)))    ! prints "2 2"
9381 END PROGRAM
9382 @end smallexample
9383
9384 @item @emph{See also}:
9385 @ref{SHAPE}
9386 @end table
9387
9388
9389
9390 @node RRSPACING
9391 @section @code{RRSPACING} --- Reciprocal of the relative spacing
9392 @fnindex RRSPACING
9393 @cindex real number, relative spacing
9394 @cindex floating point, relative spacing
9395
9396
9397 @table @asis
9398 @item @emph{Description}:
9399 @code{RRSPACING(X)} returns the  reciprocal of the relative spacing of
9400 model numbers near @var{X}.
9401
9402 @item @emph{Standard}:
9403 Fortran 95 and later
9404
9405 @item @emph{Class}:
9406 Elemental function
9407
9408 @item @emph{Syntax}:
9409 @code{RESULT = RRSPACING(X)}
9410
9411 @item @emph{Arguments}:
9412 @multitable @columnfractions .15 .70
9413 @item @var{X} @tab Shall be of type @code{REAL}.
9414 @end multitable
9415
9416 @item @emph{Return value}:
9417 The return value is of the same type and kind as @var{X}.
9418 The value returned is equal to
9419 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
9420
9421 @item @emph{See also}:
9422 @ref{SPACING}
9423 @end table
9424
9425
9426
9427 @node RSHIFT
9428 @section @code{RSHIFT} --- Right shift bits
9429 @fnindex RSHIFT
9430 @cindex bits, shift right
9431
9432 @table @asis
9433 @item @emph{Description}:
9434 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
9435 bits shifted right by @var{SHIFT} places.  If the absolute value of
9436 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined. 
9437 Bits shifted out from the left end are lost; zeros are shifted in from
9438 the opposite end.
9439
9440 This function has been superseded by the @code{ISHFT} intrinsic, which
9441 is standard in Fortran 95 and later.
9442
9443 @item @emph{Standard}:
9444 GNU extension
9445
9446 @item @emph{Class}:
9447 Elemental function
9448
9449 @item @emph{Syntax}:
9450 @code{RESULT = RSHIFT(I, SHIFT)}
9451
9452 @item @emph{Arguments}:
9453 @multitable @columnfractions .15 .70
9454 @item @var{I} @tab The type shall be @code{INTEGER}.
9455 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
9456 @end multitable
9457
9458 @item @emph{Return value}:
9459 The return value is of type @code{INTEGER} and of the same kind as
9460 @var{I}.
9461
9462 @item @emph{See also}:
9463 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
9464
9465 @end table
9466
9467
9468
9469 @node SAME_TYPE_AS
9470 @section @code{SAME_TYPE_AS} ---  Query dynamic types for equality
9471 @fnindex SAME_TYPE_AS
9472
9473 @table @asis
9474 @item @emph{Description}:
9475 Query dynamic types for equality.
9476
9477 @item @emph{Standard}:
9478 Fortran 2003 and later
9479
9480 @item @emph{Class}:
9481 Inquiry function
9482
9483 @item @emph{Syntax}:
9484 @code{RESULT = SAME_TYPE_AS(A, B)}
9485
9486 @item @emph{Arguments}:
9487 @multitable @columnfractions .15 .70
9488 @item @var{A} @tab Shall be an object of extensible declared type or
9489 unlimited polymorphic.
9490 @item @var{B} @tab Shall be an object of extensible declared type or
9491 unlimited polymorphic.
9492 @end multitable
9493
9494 @item @emph{Return value}:
9495 The return value is a scalar of type default logical. It is true if and
9496 only if the dynamic type of A is the same as the dynamic type of B.
9497
9498 @item @emph{See also}:
9499 @ref{EXTENDS_TYPE_OF}
9500
9501 @end table
9502
9503
9504
9505 @node SCALE
9506 @section @code{SCALE} --- Scale a real value
9507 @fnindex SCALE
9508 @cindex real number, scale
9509 @cindex floating point, scale
9510
9511 @table @asis
9512 @item @emph{Description}:
9513 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
9514
9515 @item @emph{Standard}:
9516 Fortran 95 and later
9517
9518 @item @emph{Class}:
9519 Elemental function
9520
9521 @item @emph{Syntax}:
9522 @code{RESULT = SCALE(X, I)}
9523
9524 @item @emph{Arguments}:
9525 @multitable @columnfractions .15 .70
9526 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
9527 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
9528 @end multitable
9529
9530 @item @emph{Return value}:
9531 The return value is of the same type and kind as @var{X}.
9532 Its value is @code{X * RADIX(X)**I}.
9533
9534 @item @emph{Example}:
9535 @smallexample
9536 program test_scale
9537   real :: x = 178.1387e-4
9538   integer :: i = 5
9539   print *, scale(x,i), x*radix(x)**i
9540 end program test_scale
9541 @end smallexample
9542
9543 @end table
9544
9545
9546
9547 @node SCAN
9548 @section @code{SCAN} --- Scan a string for the presence of a set of characters
9549 @fnindex SCAN
9550 @cindex string, find subset
9551
9552 @table @asis
9553 @item @emph{Description}:
9554 Scans a @var{STRING} for any of the characters in a @var{SET} 
9555 of characters.
9556
9557 If @var{BACK} is either absent or equals @code{FALSE}, this function
9558 returns the position of the leftmost character of @var{STRING} that is
9559 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
9560 is returned. If no character of @var{SET} is found in @var{STRING}, the 
9561 result is zero.
9562
9563 @item @emph{Standard}:
9564 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
9565
9566 @item @emph{Class}:
9567 Elemental function
9568
9569 @item @emph{Syntax}:
9570 @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
9571
9572 @item @emph{Arguments}:
9573 @multitable @columnfractions .15 .70
9574 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
9575 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
9576 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
9577 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
9578 expression indicating the kind parameter of the result.
9579 @end multitable
9580
9581 @item @emph{Return value}:
9582 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9583 @var{KIND} is absent, the return value is of default integer kind.
9584
9585 @item @emph{Example}:
9586 @smallexample
9587 PROGRAM test_scan
9588   WRITE(*,*) SCAN("FORTRAN", "AO")          ! 2, found 'O'
9589   WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.)  ! 6, found 'A'
9590   WRITE(*,*) SCAN("FORTRAN", "C++")         ! 0, found none
9591 END PROGRAM
9592 @end smallexample
9593
9594 @item @emph{See also}:
9595 @ref{INDEX intrinsic}, @ref{VERIFY}
9596 @end table
9597
9598
9599
9600 @node SECNDS
9601 @section @code{SECNDS} --- Time function
9602 @fnindex SECNDS
9603 @cindex time, elapsed
9604 @cindex elapsed time
9605
9606 @table @asis
9607 @item @emph{Description}:
9608 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
9609 @var{X} is a reference time, also in seconds. If this is zero, the time in
9610 seconds from midnight is returned. This function is non-standard and its
9611 use is discouraged.
9612
9613 @item @emph{Standard}:
9614 GNU extension
9615
9616 @item @emph{Class}:
9617 Function
9618
9619 @item @emph{Syntax}:
9620 @code{RESULT = SECNDS (X)}
9621
9622 @item @emph{Arguments}:
9623 @multitable @columnfractions .15 .70
9624 @item @var{T}     @tab Shall be of type @code{REAL(4)}.
9625 @item @var{X}     @tab Shall be of type @code{REAL(4)}.
9626 @end multitable
9627
9628 @item @emph{Return value}:
9629 None
9630
9631 @item @emph{Example}:
9632 @smallexample
9633 program test_secnds
9634     integer :: i
9635     real(4) :: t1, t2
9636     print *, secnds (0.0)   ! seconds since midnight
9637     t1 = secnds (0.0)       ! reference time
9638     do i = 1, 10000000      ! do something
9639     end do
9640     t2 = secnds (t1)        ! elapsed time
9641     print *, "Something took ", t2, " seconds."
9642 end program test_secnds
9643 @end smallexample
9644 @end table
9645
9646
9647
9648 @node SECOND
9649 @section @code{SECOND} --- CPU time function
9650 @fnindex SECOND
9651 @cindex time, elapsed
9652 @cindex elapsed time
9653
9654 @table @asis
9655 @item @emph{Description}:
9656 Returns a @code{REAL(4)} value representing the elapsed CPU time in
9657 seconds.  This provides the same functionality as the standard
9658 @code{CPU_TIME} intrinsic, and is only included for backwards
9659 compatibility.
9660
9661 This intrinsic is provided in both subroutine and function forms;
9662 however, only one form can be used in any given program unit.
9663
9664 @item @emph{Standard}:
9665 GNU extension
9666
9667 @item @emph{Class}:
9668 Subroutine, function
9669
9670 @item @emph{Syntax}:
9671 @multitable @columnfractions .80
9672 @item @code{CALL SECOND(TIME)}
9673 @item @code{TIME = SECOND()}
9674 @end multitable
9675
9676 @item @emph{Arguments}:
9677 @multitable @columnfractions .15 .70
9678 @item @var{TIME}  @tab Shall be of type @code{REAL(4)}.
9679 @end multitable
9680
9681 @item @emph{Return value}:
9682 In either syntax, @var{TIME} is set to the process's current runtime in
9683 seconds.
9684
9685 @item @emph{See also}:
9686 @ref{CPU_TIME}
9687
9688 @end table
9689
9690
9691
9692 @node SELECTED_CHAR_KIND
9693 @section @code{SELECTED_CHAR_KIND} --- Choose character kind
9694 @fnindex SELECTED_CHAR_KIND
9695 @cindex character kind
9696 @cindex kind, character
9697
9698 @table @asis
9699 @item @emph{Description}:
9700
9701 @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
9702 set named @var{NAME}, if a character set with such a name is supported,
9703 or @math{-1} otherwise. Currently, supported character sets include
9704 ``ASCII'' and ``DEFAULT'', which are equivalent, and ``ISO_10646''
9705 (Universal Character Set, UCS-4) which is commonly known as Unicode.
9706
9707 @item @emph{Standard}:
9708 Fortran 2003 and later
9709
9710 @item @emph{Class}:
9711 Transformational function
9712
9713 @item @emph{Syntax}:
9714 @code{RESULT = SELECTED_CHAR_KIND(NAME)}
9715
9716 @item @emph{Arguments}:
9717 @multitable @columnfractions .15 .70
9718 @item @var{NAME} @tab Shall be a scalar and of the default character type.
9719 @end multitable
9720
9721 @item @emph{Example}:
9722 @smallexample
9723 program character_kind
9724   use iso_fortran_env
9725   implicit none
9726   integer, parameter :: ascii = selected_char_kind ("ascii")
9727   integer, parameter :: ucs4  = selected_char_kind ('ISO_10646')
9728
9729   character(kind=ascii, len=26) :: alphabet
9730   character(kind=ucs4,  len=30) :: hello_world
9731
9732   alphabet = ascii_"abcdefghijklmnopqrstuvwxyz"
9733   hello_world = ucs4_'Hello World and Ni Hao -- ' &
9734                 // char (int (z'4F60'), ucs4)     &
9735                 // char (int (z'597D'), ucs4)
9736
9737   write (*,*) alphabet
9738
9739   open (output_unit, encoding='UTF-8')
9740   write (*,*) trim (hello_world)
9741 end program character_kind
9742 @end smallexample
9743 @end table
9744
9745
9746
9747 @node SELECTED_INT_KIND
9748 @section @code{SELECTED_INT_KIND} --- Choose integer kind
9749 @fnindex SELECTED_INT_KIND
9750 @cindex integer kind
9751 @cindex kind, integer
9752
9753 @table @asis
9754 @item @emph{Description}:
9755 @code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer
9756 type that can represent all values ranging from @math{-10^R} (exclusive)
9757 to @math{10^R} (exclusive). If there is no integer kind that accommodates
9758 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
9759
9760 @item @emph{Standard}:
9761 Fortran 95 and later
9762
9763 @item @emph{Class}:
9764 Transformational function
9765
9766 @item @emph{Syntax}:
9767 @code{RESULT = SELECTED_INT_KIND(R)}
9768
9769 @item @emph{Arguments}:
9770 @multitable @columnfractions .15 .70
9771 @item @var{R} @tab Shall be a scalar and of type @code{INTEGER}.
9772 @end multitable
9773
9774 @item @emph{Example}:
9775 @smallexample
9776 program large_integers
9777   integer,parameter :: k5 = selected_int_kind(5)
9778   integer,parameter :: k15 = selected_int_kind(15)
9779   integer(kind=k5) :: i5
9780   integer(kind=k15) :: i15
9781
9782   print *, huge(i5), huge(i15)
9783
9784   ! The following inequalities are always true
9785   print *, huge(i5) >= 10_k5**5-1
9786   print *, huge(i15) >= 10_k15**15-1
9787 end program large_integers
9788 @end smallexample
9789 @end table
9790
9791
9792
9793 @node SELECTED_REAL_KIND
9794 @section @code{SELECTED_REAL_KIND} --- Choose real kind
9795 @fnindex SELECTED_REAL_KIND
9796 @cindex real kind
9797 @cindex kind, real
9798 @cindex radix, real
9799
9800 @table @asis
9801 @item @emph{Description}:
9802 @code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type
9803 with decimal precision of at least @code{P} digits, exponent range of
9804 at least @code{R}, and with a radix of @code{RADIX}.
9805
9806 @item @emph{Standard}:
9807 Fortran 95 and later, with @code{RADIX} Fortran 2008 or later
9808
9809 @item @emph{Class}:
9810 Transformational function
9811
9812 @item @emph{Syntax}:
9813 @code{RESULT = SELECTED_REAL_KIND([P, R, RADIX])}
9814
9815 @item @emph{Arguments}:
9816 @multitable @columnfractions .15 .70
9817 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
9818 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
9819 @item @var{RADIX} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
9820 @end multitable
9821 Before Fortran 2008, at least one of the arguments @var{R} or @var{P} shall
9822 be present; since Fortran 2008, they are assumed to be zero if absent.
9823
9824 @item @emph{Return value}:
9825
9826 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
9827 a real data type with decimal precision of at least @code{P} digits, a
9828 decimal exponent range of at least @code{R}, and with the requested
9829 @code{RADIX}. If the @code{RADIX} parameter is absent, real kinds with
9830 any radix can be returned. If more than one real data type meet the
9831 criteria, the kind of the data type with the smallest decimal precision
9832 is returned. If no real data type matches the criteria, the result is
9833 @table @asis
9834 @item -1 if the processor does not support a real data type with a
9835 precision greater than or equal to @code{P}, but the @code{R} and
9836 @code{RADIX} requirements can be fulfilled
9837 @item -2 if the processor does not support a real type with an exponent
9838 range greater than or equal to @code{R}, but @code{P} and @code{RADIX}
9839 are fulfillable
9840 @item -3 if @code{RADIX} but not @code{P} and @code{R} requirements
9841 are fulfillable
9842 @item -4 if @code{RADIX} and either @code{P} or @code{R} requirements
9843 are fulfillable
9844 @item -5 if there is no real type with the given @code{RADIX}
9845 @end table
9846
9847 @item @emph{See also}:
9848 @ref{PRECISION}, @ref{RANGE}, @ref{RADIX}
9849
9850 @item @emph{Example}:
9851 @smallexample
9852 program real_kinds
9853   integer,parameter :: p6 = selected_real_kind(6)
9854   integer,parameter :: p10r100 = selected_real_kind(10,100)
9855   integer,parameter :: r400 = selected_real_kind(r=400)
9856   real(kind=p6) :: x
9857   real(kind=p10r100) :: y
9858   real(kind=r400) :: z
9859
9860   print *, precision(x), range(x)
9861   print *, precision(y), range(y)
9862   print *, precision(z), range(z)
9863 end program real_kinds
9864 @end smallexample
9865 @end table
9866
9867
9868
9869 @node SET_EXPONENT
9870 @section @code{SET_EXPONENT} --- Set the exponent of the model
9871 @fnindex SET_EXPONENT
9872 @cindex real number, set exponent
9873 @cindex floating point, set exponent
9874
9875 @table @asis
9876 @item @emph{Description}:
9877 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
9878 is that that of @var{X} and whose exponent part is @var{I}.
9879
9880 @item @emph{Standard}:
9881 Fortran 95 and later
9882
9883 @item @emph{Class}:
9884 Elemental function
9885
9886 @item @emph{Syntax}:
9887 @code{RESULT = SET_EXPONENT(X, I)}
9888
9889 @item @emph{Arguments}:
9890 @multitable @columnfractions .15 .70
9891 @item @var{X} @tab Shall be of type @code{REAL}.
9892 @item @var{I} @tab Shall be of type @code{INTEGER}.
9893 @end multitable
9894
9895 @item @emph{Return value}:
9896 The return value is of the same type and kind as @var{X}.
9897 The real number whose fractional part
9898 is that that of @var{X} and whose exponent part if @var{I} is returned;
9899 it is @code{FRACTION(X) * RADIX(X)**I}.
9900
9901 @item @emph{Example}:
9902 @smallexample
9903 PROGRAM test_setexp
9904   REAL :: x = 178.1387e-4
9905   INTEGER :: i = 17
9906   PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
9907 END PROGRAM
9908 @end smallexample
9909
9910 @end table
9911
9912
9913
9914 @node SHAPE
9915 @section @code{SHAPE} --- Determine the shape of an array
9916 @fnindex SHAPE
9917 @cindex array, shape
9918
9919 @table @asis
9920 @item @emph{Description}:
9921 Determines the shape of an array.
9922
9923 @item @emph{Standard}:
9924 Fortran 95 and later
9925
9926 @item @emph{Class}:
9927 Inquiry function
9928
9929 @item @emph{Syntax}:
9930 @code{RESULT = SHAPE(SOURCE)}
9931
9932 @item @emph{Arguments}:
9933 @multitable @columnfractions .15 .70
9934 @item @var{SOURCE} @tab Shall be an array or scalar of any type. 
9935 If @var{SOURCE} is a pointer it must be associated and allocatable 
9936 arrays must be allocated.
9937 @end multitable
9938
9939 @item @emph{Return value}:
9940 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE} 
9941 has dimensions. The elements of the resulting array correspond to the extend
9942 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
9943 the result is the rank one array of size zero.
9944
9945 @item @emph{Example}:
9946 @smallexample
9947 PROGRAM test_shape
9948   INTEGER, DIMENSION(-1:1, -1:2) :: A
9949   WRITE(*,*) SHAPE(A)             ! (/ 3, 4 /)
9950   WRITE(*,*) SIZE(SHAPE(42))      ! (/ /)
9951 END PROGRAM
9952 @end smallexample
9953
9954 @item @emph{See also}:
9955 @ref{RESHAPE}, @ref{SIZE}
9956 @end table
9957
9958
9959
9960 @node SIGN
9961 @section @code{SIGN} --- Sign copying function
9962 @fnindex SIGN
9963 @fnindex ISIGN
9964 @fnindex DSIGN
9965 @cindex sign copying
9966
9967 @table @asis
9968 @item @emph{Description}:
9969 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
9970
9971 @item @emph{Standard}:
9972 Fortran 77 and later
9973
9974 @item @emph{Class}:
9975 Elemental function
9976
9977 @item @emph{Syntax}:
9978 @code{RESULT = SIGN(A, B)}
9979
9980 @item @emph{Arguments}:
9981 @multitable @columnfractions .15 .70
9982 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
9983 @item @var{B} @tab Shall be of the same type and kind as @var{A}
9984 @end multitable
9985
9986 @item @emph{Return value}:
9987 The kind of the return value is that of @var{A} and @var{B}.
9988 If @math{B\ge 0} then the result is @code{ABS(A)}, else
9989 it is @code{-ABS(A)}.
9990
9991 @item @emph{Example}:
9992 @smallexample
9993 program test_sign
9994   print *, sign(-12,1)
9995   print *, sign(-12,0)
9996   print *, sign(-12,-1)
9997
9998   print *, sign(-12.,1.)
9999   print *, sign(-12.,0.)
10000   print *, sign(-12.,-1.)
10001 end program test_sign
10002 @end smallexample
10003
10004 @item @emph{Specific names}:
10005 @multitable @columnfractions .20 .20 .20 .25
10006 @item Name              @tab Arguments              @tab Return type       @tab Standard
10007 @item @code{SIGN(A,B)}  @tab @code{REAL(4) A, B}    @tab @code{REAL(4)}    @tab f77, gnu
10008 @item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab f77, gnu
10009 @item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B}    @tab @code{REAL(8)}    @tab f77, gnu
10010 @end multitable
10011 @end table
10012
10013
10014
10015 @node SIGNAL
10016 @section @code{SIGNAL} --- Signal handling subroutine (or function)
10017 @fnindex SIGNAL
10018 @cindex system, signal handling
10019
10020 @table @asis
10021 @item @emph{Description}:
10022 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
10023 @var{HANDLER} to be executed with a single integer argument when signal
10024 @var{NUMBER} occurs.  If @var{HANDLER} is an integer, it can be used to
10025 turn off handling of signal @var{NUMBER} or revert to its default
10026 action.  See @code{signal(2)}.
10027
10028 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
10029 is supplied, it is set to the value returned by @code{signal(2)}.
10030
10031 @item @emph{Standard}:
10032 GNU extension
10033
10034 @item @emph{Class}:
10035 Subroutine, function
10036
10037 @item @emph{Syntax}:
10038 @multitable @columnfractions .80
10039 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
10040 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
10041 @end multitable
10042
10043 @item @emph{Arguments}:
10044 @multitable @columnfractions .15 .70
10045 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
10046 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
10047 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
10048 @code{INTEGER}. It is @code{INTENT(IN)}.
10049 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
10050 integer. It has @code{INTENT(OUT)}.
10051 @end multitable
10052 @c TODO: What should the interface of the handler be?  Does it take arguments?
10053
10054 @item @emph{Return value}:
10055 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
10056
10057 @item @emph{Example}:
10058 @smallexample
10059 program test_signal
10060   intrinsic signal
10061   external handler_print
10062
10063   call signal (12, handler_print)
10064   call signal (10, 1)
10065
10066   call sleep (30)
10067 end program test_signal
10068 @end smallexample
10069 @end table
10070
10071
10072
10073 @node SIN
10074 @section @code{SIN} --- Sine function 
10075 @fnindex SIN
10076 @fnindex DSIN
10077 @fnindex CSIN
10078 @fnindex ZSIN
10079 @fnindex CDSIN
10080 @cindex trigonometric function, sine
10081 @cindex sine
10082
10083 @table @asis
10084 @item @emph{Description}:
10085 @code{SIN(X)} computes the sine of @var{X}.
10086
10087 @item @emph{Standard}:
10088 Fortran 77 and later
10089
10090 @item @emph{Class}:
10091 Elemental function
10092
10093 @item @emph{Syntax}:
10094 @code{RESULT = SIN(X)}
10095
10096 @item @emph{Arguments}:
10097 @multitable @columnfractions .15 .70
10098 @item @var{X} @tab The type shall be @code{REAL} or
10099 @code{COMPLEX}.
10100 @end multitable
10101
10102 @item @emph{Return value}:
10103 The return value has same type and kind as @var{X}.
10104
10105 @item @emph{Example}:
10106 @smallexample
10107 program test_sin
10108   real :: x = 0.0
10109   x = sin(x)
10110 end program test_sin
10111 @end smallexample
10112
10113 @item @emph{Specific names}:
10114 @multitable @columnfractions .20 .20 .20 .25
10115 @item Name            @tab Argument             @tab Return type       @tab Standard
10116 @item @code{SIN(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}    @tab f77, gnu
10117 @item @code{DSIN(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}    @tab f95, gnu
10118 @item @code{CSIN(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)} @tab f95, gnu
10119 @item @code{ZSIN(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)} @tab f95, gnu
10120 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)} @tab f95, gnu
10121 @end multitable
10122
10123 @item @emph{See also}:
10124 @ref{ASIN}
10125 @end table
10126
10127
10128
10129 @node SINH
10130 @section @code{SINH} --- Hyperbolic sine function 
10131 @fnindex SINH
10132 @fnindex DSINH
10133 @cindex hyperbolic sine
10134 @cindex hyperbolic function, sine
10135 @cindex sine, hyperbolic
10136
10137 @table @asis
10138 @item @emph{Description}:
10139 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
10140
10141 @item @emph{Standard}:
10142 Fortran 95 and later, for a complex argument Fortran 2008 or later
10143
10144 @item @emph{Class}:
10145 Elemental function
10146
10147 @item @emph{Syntax}:
10148 @code{RESULT = SINH(X)}
10149
10150 @item @emph{Arguments}:
10151 @multitable @columnfractions .15 .70
10152 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
10153 @end multitable
10154
10155 @item @emph{Return value}:
10156 The return value has same type and kind as @var{X}.
10157
10158 @item @emph{Example}:
10159 @smallexample
10160 program test_sinh
10161   real(8) :: x = - 1.0_8
10162   x = sinh(x)
10163 end program test_sinh
10164 @end smallexample
10165
10166 @item @emph{Specific names}:
10167 @multitable @columnfractions .20 .20 .20 .25
10168 @item Name            @tab Argument          @tab Return type       @tab Standard
10169 @item @code{SINH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
10170 @item @code{DSINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
10171 @end multitable
10172
10173 @item @emph{See also}:
10174 @ref{ASINH}
10175 @end table
10176
10177
10178
10179 @node SIZE
10180 @section @code{SIZE} --- Determine the size of an array
10181 @fnindex SIZE
10182 @cindex array, size
10183 @cindex array, number of elements
10184 @cindex array, count elements
10185
10186 @table @asis
10187 @item @emph{Description}:
10188 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
10189 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
10190
10191 @item @emph{Standard}:
10192 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
10193
10194 @item @emph{Class}:
10195 Inquiry function
10196
10197 @item @emph{Syntax}:
10198 @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
10199
10200 @item @emph{Arguments}:
10201 @multitable @columnfractions .15 .70
10202 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
10203 a pointer it must be associated and allocatable arrays must be allocated.
10204 @item @var{DIM}   @tab (Optional) shall be a scalar of type @code{INTEGER} 
10205 and its value shall be in the range from 1 to n, where n equals the rank 
10206 of @var{ARRAY}.
10207 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10208 expression indicating the kind parameter of the result.
10209 @end multitable
10210
10211 @item @emph{Return value}:
10212 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
10213 @var{KIND} is absent, the return value is of default integer kind.
10214
10215 @item @emph{Example}:
10216 @smallexample
10217 PROGRAM test_size
10218   WRITE(*,*) SIZE((/ 1, 2 /))    ! 2
10219 END PROGRAM
10220 @end smallexample
10221
10222 @item @emph{See also}:
10223 @ref{SHAPE}, @ref{RESHAPE}
10224 @end table
10225
10226
10227 @node SIZEOF
10228 @section @code{SIZEOF} --- Size in bytes of an expression
10229 @fnindex SIZEOF
10230 @cindex expression size
10231 @cindex size of an expression
10232
10233 @table @asis
10234 @item @emph{Description}:
10235 @code{SIZEOF(X)} calculates the number of bytes of storage the
10236 expression @code{X} occupies.
10237
10238 @item @emph{Standard}:
10239 GNU extension
10240
10241 @item @emph{Class}:
10242 Intrinsic function
10243
10244 @item @emph{Syntax}:
10245 @code{N = SIZEOF(X)}
10246
10247 @item @emph{Arguments}:
10248 @multitable @columnfractions .15 .70
10249 @item @var{X} @tab The argument shall be of any type, rank or shape.
10250 @end multitable
10251
10252 @item @emph{Return value}:
10253 The return value is of type integer and of the system-dependent kind
10254 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
10255 number of bytes occupied by the argument.  If the argument has the
10256 @code{POINTER} attribute, the number of bytes of the storage area pointed
10257 to is returned.  If the argument is of a derived type with @code{POINTER}
10258 or @code{ALLOCATABLE} components, the return value doesn't account for
10259 the sizes of the data pointed to by these components. If the argument is
10260 polymorphic, the size according to the declared type is returned.
10261
10262 @item @emph{Example}:
10263 @smallexample
10264    integer :: i
10265    real :: r, s(5)
10266    print *, (sizeof(s)/sizeof(r) == 5)
10267    end
10268 @end smallexample
10269 The example will print @code{.TRUE.} unless you are using a platform
10270 where default @code{REAL} variables are unusually padded.
10271
10272 @item @emph{See also}:
10273 @ref{C_SIZEOF}, @ref{STORAGE_SIZE}
10274 @end table
10275
10276
10277 @node SLEEP
10278 @section @code{SLEEP} --- Sleep for the specified number of seconds
10279 @fnindex SLEEP
10280 @cindex delayed execution
10281
10282 @table @asis
10283 @item @emph{Description}:
10284 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
10285
10286 @item @emph{Standard}:
10287 GNU extension
10288
10289 @item @emph{Class}:
10290 Subroutine
10291
10292 @item @emph{Syntax}:
10293 @code{CALL SLEEP(SECONDS)}
10294
10295 @item @emph{Arguments}:
10296 @multitable @columnfractions .15 .70
10297 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
10298 @end multitable
10299
10300 @item @emph{Example}:
10301 @smallexample
10302 program test_sleep
10303   call sleep(5)
10304 end
10305 @end smallexample
10306 @end table
10307
10308
10309
10310 @node SPACING
10311 @section @code{SPACING} --- Smallest distance between two numbers of a given type
10312 @fnindex SPACING
10313 @cindex real number, relative spacing
10314 @cindex floating point, relative spacing
10315
10316 @table @asis
10317 @item @emph{Description}:
10318 Determines the distance between the argument @var{X} and the nearest 
10319 adjacent number of the same type.
10320
10321 @item @emph{Standard}:
10322 Fortran 95 and later
10323
10324 @item @emph{Class}:
10325 Elemental function
10326
10327 @item @emph{Syntax}:
10328 @code{RESULT = SPACING(X)}
10329
10330 @item @emph{Arguments}:
10331 @multitable @columnfractions .15 .70
10332 @item @var{X} @tab Shall be of type @code{REAL}.
10333 @end multitable
10334
10335 @item @emph{Return value}:
10336 The result is of the same type as the input argument @var{X}.
10337
10338 @item @emph{Example}:
10339 @smallexample
10340 PROGRAM test_spacing
10341   INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
10342   INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
10343
10344   WRITE(*,*) spacing(1.0_SGL)      ! "1.1920929E-07"          on i686
10345   WRITE(*,*) spacing(1.0_DBL)      ! "2.220446049250313E-016" on i686
10346 END PROGRAM
10347 @end smallexample
10348
10349 @item @emph{See also}:
10350 @ref{RRSPACING}
10351 @end table
10352
10353
10354
10355 @node SPREAD
10356 @section @code{SPREAD} --- Add a dimension to an array
10357 @fnindex SPREAD
10358 @cindex array, increase dimension
10359 @cindex array, duplicate elements
10360 @cindex array, duplicate dimensions
10361
10362 @table @asis
10363 @item @emph{Description}:
10364 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified 
10365 dimension @var{DIM}.
10366
10367 @item @emph{Standard}:
10368 Fortran 95 and later
10369
10370 @item @emph{Class}:
10371 Transformational function
10372
10373 @item @emph{Syntax}:
10374 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
10375
10376 @item @emph{Arguments}:
10377 @multitable @columnfractions .15 .70
10378 @item @var{SOURCE}  @tab Shall be a scalar or an array of any type and 
10379 a rank less than seven.
10380 @item @var{DIM}     @tab Shall be a scalar of type @code{INTEGER} with a 
10381 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
10382 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
10383 @end multitable
10384
10385 @item @emph{Return value}:
10386 The result is an array of the same type as @var{SOURCE} and has rank n+1
10387 where n equals the rank of @var{SOURCE}.
10388
10389 @item @emph{Example}:
10390 @smallexample
10391 PROGRAM test_spread
10392   INTEGER :: a = 1, b(2) = (/ 1, 2 /)
10393   WRITE(*,*) SPREAD(A, 1, 2)            ! "1 1"
10394   WRITE(*,*) SPREAD(B, 1, 2)            ! "1 1 2 2"
10395 END PROGRAM
10396 @end smallexample
10397
10398 @item @emph{See also}:
10399 @ref{UNPACK}
10400 @end table
10401
10402
10403
10404 @node SQRT
10405 @section @code{SQRT} --- Square-root function
10406 @fnindex SQRT
10407 @fnindex DSQRT
10408 @fnindex CSQRT
10409 @fnindex ZSQRT
10410 @fnindex CDSQRT
10411 @cindex root
10412 @cindex square-root
10413
10414 @table @asis
10415 @item @emph{Description}:
10416 @code{SQRT(X)} computes the square root of @var{X}.
10417
10418 @item @emph{Standard}:
10419 Fortran 77 and later
10420
10421 @item @emph{Class}:
10422 Elemental function
10423
10424 @item @emph{Syntax}:
10425 @code{RESULT = SQRT(X)}
10426
10427 @item @emph{Arguments}:
10428 @multitable @columnfractions .15 .70
10429 @item @var{X} @tab The type shall be @code{REAL} or
10430 @code{COMPLEX}.
10431 @end multitable
10432
10433 @item @emph{Return value}:
10434 The return value is of type @code{REAL} or @code{COMPLEX}.
10435 The kind type parameter is the same as @var{X}.
10436
10437 @item @emph{Example}:
10438 @smallexample
10439 program test_sqrt
10440   real(8) :: x = 2.0_8
10441   complex :: z = (1.0, 2.0)
10442   x = sqrt(x)
10443   z = sqrt(z)
10444 end program test_sqrt
10445 @end smallexample
10446
10447 @item @emph{Specific names}:
10448 @multitable @columnfractions .20 .20 .20 .25
10449 @item Name             @tab Argument             @tab Return type          @tab Standard
10450 @item @code{SQRT(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}       @tab Fortran 95 and later
10451 @item @code{DSQRT(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}       @tab Fortran 95 and later
10452 @item @code{CSQRT(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab Fortran 95 and later
10453 @item @code{ZSQRT(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
10454 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
10455 @end multitable
10456 @end table
10457
10458
10459
10460 @node SRAND
10461 @section @code{SRAND} --- Reinitialize the random number generator
10462 @fnindex SRAND
10463 @cindex random number generation, seeding
10464 @cindex seeding a random number generator
10465
10466 @table @asis
10467 @item @emph{Description}:
10468 @code{SRAND} reinitializes the pseudo-random number generator
10469 called by @code{RAND} and @code{IRAND}. The new seed used by the
10470 generator is specified by the required argument @var{SEED}.
10471
10472 @item @emph{Standard}:
10473 GNU extension
10474
10475 @item @emph{Class}:
10476 Subroutine
10477
10478 @item @emph{Syntax}:
10479 @code{CALL SRAND(SEED)}
10480
10481 @item @emph{Arguments}:
10482 @multitable @columnfractions .15 .70
10483 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
10484 @end multitable
10485
10486 @item @emph{Return value}:
10487 Does not return anything.
10488
10489 @item @emph{Example}:
10490 See @code{RAND} and @code{IRAND} for examples.
10491
10492 @item @emph{Notes}:
10493 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
10494 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
10495 to generate pseudo-random numbers. Please note that in
10496 GNU Fortran, these two sets of intrinsics (@code{RAND},
10497 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
10498 @code{RANDOM_SEED} on the other hand) access two independent
10499 pseudo-random number generators.
10500
10501 @item @emph{See also}:
10502 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
10503
10504 @end table
10505
10506
10507
10508 @node STAT
10509 @section @code{STAT} --- Get file status
10510 @fnindex STAT
10511 @cindex file system, file status
10512
10513 @table @asis
10514 @item @emph{Description}:
10515 This function returns information about a file. No permissions are required on 
10516 the file itself, but execute (search) permission is required on all of the 
10517 directories in path that lead to the file.
10518
10519 The elements that are obtained and stored in the array @code{VALUES}:
10520 @multitable @columnfractions .15 .70
10521 @item @code{VALUES(1)}   @tab  Device ID 
10522 @item @code{VALUES(2)}   @tab  Inode number 
10523 @item @code{VALUES(3)}   @tab  File mode 
10524 @item @code{VALUES(4)}   @tab  Number of links 
10525 @item @code{VALUES(5)}   @tab  Owner's uid 
10526 @item @code{VALUES(6)}   @tab  Owner's gid 
10527 @item @code{VALUES(7)}   @tab  ID of device containing directory entry for file (0 if not available) 
10528 @item @code{VALUES(8)}   @tab  File size (bytes) 
10529 @item @code{VALUES(9)}   @tab  Last access time 
10530 @item @code{VALUES(10)}  @tab  Last modification time 
10531 @item @code{VALUES(11)}  @tab  Last file status change time 
10532 @item @code{VALUES(12)}  @tab  Preferred I/O block size (-1 if not available) 
10533 @item @code{VALUES(13)}  @tab  Number of blocks allocated (-1 if not available)
10534 @end multitable
10535
10536 Not all these elements are relevant on all systems. 
10537 If an element is not relevant, it is returned as 0.
10538
10539 This intrinsic is provided in both subroutine and function forms; however,
10540 only one form can be used in any given program unit.
10541
10542 @item @emph{Standard}:
10543 GNU extension
10544
10545 @item @emph{Class}:
10546 Subroutine, function
10547
10548 @item @emph{Syntax}:
10549 @code{CALL STAT(NAME, VALUES [, STATUS])}
10550
10551 @item @emph{Arguments}:
10552 @multitable @columnfractions .15 .70
10553 @item @var{NAME}   @tab The type shall be @code{CHARACTER}, of the
10554 default kind and a valid path within the file system.
10555 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
10556 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
10557 on success and a system specific error code otherwise.
10558 @end multitable
10559
10560 @item @emph{Example}:
10561 @smallexample
10562 PROGRAM test_stat
10563   INTEGER, DIMENSION(13) :: buff
10564   INTEGER :: status
10565
10566   CALL STAT("/etc/passwd", buff, status)
10567
10568   IF (status == 0) THEN
10569     WRITE (*, FMT="('Device ID:',               T30, I19)") buff(1)
10570     WRITE (*, FMT="('Inode number:',            T30, I19)") buff(2)
10571     WRITE (*, FMT="('File mode (octal):',       T30, O19)") buff(3)
10572     WRITE (*, FMT="('Number of links:',         T30, I19)") buff(4)
10573     WRITE (*, FMT="('Owner''s uid:',            T30, I19)") buff(5)
10574     WRITE (*, FMT="('Owner''s gid:',            T30, I19)") buff(6)
10575     WRITE (*, FMT="('Device where located:',    T30, I19)") buff(7)
10576     WRITE (*, FMT="('File size:',               T30, I19)") buff(8)
10577     WRITE (*, FMT="('Last access time:',        T30, A19)") CTIME(buff(9))
10578     WRITE (*, FMT="('Last modification time',   T30, A19)") CTIME(buff(10))
10579     WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
10580     WRITE (*, FMT="('Preferred block size:',    T30, I19)") buff(12)
10581     WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
10582   END IF
10583 END PROGRAM
10584 @end smallexample
10585
10586 @item @emph{See also}:
10587 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
10588 @end table
10589
10590
10591
10592 @node STORAGE_SIZE
10593 @section @code{STORAGE_SIZE} --- Storage size in bits
10594 @fnindex STORAGE_SIZE
10595 @cindex storage size
10596
10597 @table @asis
10598 @item @emph{Description}:
10599 Returns the storage size of argument @var{A} in bits.
10600 @item @emph{Standard}:
10601 Fortran 2008 and later
10602 @item @emph{Class}:
10603 Inquiry function
10604 @item @emph{Syntax}:
10605 @code{RESULT = STORAGE_SIZE(A [, KIND])}
10606
10607 @item @emph{Arguments}:
10608 @multitable @columnfractions .15 .70
10609 @item @var{A} @tab Shall be a scalar or array of any type.
10610 @item @var{KIND} @tab (Optional) shall be a scalar integer constant expression.
10611 @end multitable
10612
10613 @item @emph{Return Value}:
10614 The result is a scalar integer with the kind type parameter specified by KIND (or default integer type if KIND is missing). The result value is the size expressed in bits for an element of an array that
10615 has the dynamic type and type parameters of A.
10616
10617 @item @emph{See also}:
10618 @ref{C_SIZEOF}, @ref{SIZEOF}
10619 @end table
10620
10621
10622
10623 @node SUM
10624 @section @code{SUM} --- Sum of array elements
10625 @fnindex SUM
10626 @cindex array, sum
10627 @cindex array, add elements
10628 @cindex array, conditionally add elements
10629 @cindex sum array elements
10630
10631 @table @asis
10632 @item @emph{Description}:
10633 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
10634 the corresponding element in @var{MASK} is @code{TRUE}.
10635
10636 @item @emph{Standard}:
10637 Fortran 95 and later
10638
10639 @item @emph{Class}:
10640 Transformational function
10641
10642 @item @emph{Syntax}:
10643 @multitable @columnfractions .80
10644 @item @code{RESULT = SUM(ARRAY[, MASK])}
10645 @item @code{RESULT = SUM(ARRAY, DIM[, MASK])}
10646 @end multitable
10647
10648 @item @emph{Arguments}:
10649 @multitable @columnfractions .15 .70
10650 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
10651 @code{REAL} or @code{COMPLEX}.
10652 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
10653 @code{INTEGER} with a value in the range from 1 to n, where n 
10654 equals the rank of @var{ARRAY}.
10655 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
10656 and either be a scalar or an array of the same shape as @var{ARRAY}.
10657 @end multitable
10658
10659 @item @emph{Return value}:
10660 The result is of the same type as @var{ARRAY}.
10661
10662 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
10663 is returned. Otherwise, an array of rank n-1, where n equals the rank of 
10664 @var{ARRAY}, and a shape similar to that of @var{ARRAY} with dimension @var{DIM} 
10665 dropped is returned.
10666
10667 @item @emph{Example}:
10668 @smallexample
10669 PROGRAM test_sum
10670   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
10671   print *, SUM(x)                        ! all elements, sum = 15
10672   print *, SUM(x, MASK=MOD(x, 2)==1)     ! odd elements, sum = 9
10673 END PROGRAM
10674 @end smallexample
10675
10676 @item @emph{See also}:
10677 @ref{PRODUCT}
10678 @end table
10679
10680
10681
10682 @node SYMLNK
10683 @section @code{SYMLNK} --- Create a symbolic link
10684 @fnindex SYMLNK
10685 @cindex file system, create link
10686 @cindex file system, soft link
10687
10688 @table @asis
10689 @item @emph{Description}:
10690 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
10691 character (@code{CHAR(0)}) can be used to mark the end of the names in
10692 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
10693 names are ignored.  If the @var{STATUS} argument is supplied, it
10694 contains 0 on success or a nonzero error code upon return; see
10695 @code{symlink(2)}.  If the system does not supply @code{symlink(2)}, 
10696 @code{ENOSYS} is returned.
10697
10698 This intrinsic is provided in both subroutine and function forms;
10699 however, only one form can be used in any given program unit.
10700
10701 @item @emph{Standard}:
10702 GNU extension
10703
10704 @item @emph{Class}:
10705 Subroutine, function
10706
10707 @item @emph{Syntax}:
10708 @multitable @columnfractions .80
10709 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
10710 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
10711 @end multitable
10712
10713 @item @emph{Arguments}:
10714 @multitable @columnfractions .15 .70
10715 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
10716 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
10717 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10718 @end multitable
10719
10720 @item @emph{See also}:
10721 @ref{LINK}, @ref{UNLINK}
10722
10723 @end table
10724
10725
10726
10727 @node SYSTEM
10728 @section @code{SYSTEM} --- Execute a shell command
10729 @fnindex SYSTEM
10730 @cindex system, system call
10731
10732 @table @asis
10733 @item @emph{Description}:
10734 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
10735 argument @var{STATUS} is present, it contains the value returned by
10736 @code{system(3)}, which is presumably 0 if the shell command succeeded.
10737 Note that which shell is used to invoke the command is system-dependent
10738 and environment-dependent.
10739
10740 This intrinsic is provided in both subroutine and function forms;
10741 however, only one form can be used in any given program unit.
10742
10743 @item @emph{Standard}:
10744 GNU extension
10745
10746 @item @emph{Class}:
10747 Subroutine, function
10748
10749 @item @emph{Syntax}:
10750 @multitable @columnfractions .80
10751 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
10752 @item @code{STATUS = SYSTEM(COMMAND)}
10753 @end multitable
10754
10755 @item @emph{Arguments}:
10756 @multitable @columnfractions .15 .70
10757 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
10758 @item @var{STATUS}  @tab (Optional) Shall be of default @code{INTEGER} type.
10759 @end multitable
10760
10761 @item @emph{See also}:
10762 @end table
10763
10764
10765
10766 @node SYSTEM_CLOCK
10767 @section @code{SYSTEM_CLOCK} --- Time function
10768 @fnindex SYSTEM_CLOCK
10769 @cindex time, clock ticks
10770 @cindex clock ticks
10771
10772 @table @asis
10773 @item @emph{Description}:
10774 Determines the @var{COUNT} of milliseconds of wall clock time since 
10775 the Epoch (00:00:00 UTC, January 1, 1970) modulo @var{COUNT_MAX}, 
10776 @var{COUNT_RATE} determines the number of clock ticks per second.
10777 @var{COUNT_RATE} and @var{COUNT_MAX} are constant and specific to 
10778 @command{gfortran}.
10779
10780 If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and
10781 @var{COUNT_RATE} and @var{COUNT_MAX} are set to zero 
10782
10783 @item @emph{Standard}:
10784 Fortran 95 and later
10785
10786 @item @emph{Class}:
10787 Subroutine
10788
10789 @item @emph{Syntax}:
10790 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
10791
10792 @item @emph{Arguments}:
10793 @multitable @columnfractions .15 .70
10794 @item @var{COUNT}      @tab (Optional) shall be a scalar of type default 
10795 @code{INTEGER} with @code{INTENT(OUT)}.
10796 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type default 
10797 @code{INTEGER} with @code{INTENT(OUT)}.
10798 @item @var{COUNT_MAX}  @tab (Optional) shall be a scalar of type default 
10799 @code{INTEGER} with @code{INTENT(OUT)}.
10800 @end multitable
10801
10802 @item @emph{Example}:
10803 @smallexample
10804 PROGRAM test_system_clock
10805   INTEGER :: count, count_rate, count_max
10806   CALL SYSTEM_CLOCK(count, count_rate, count_max)
10807   WRITE(*,*) count, count_rate, count_max
10808 END PROGRAM
10809 @end smallexample
10810
10811 @item @emph{See also}:
10812 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
10813 @end table
10814
10815
10816
10817 @node TAN
10818 @section @code{TAN} --- Tangent function
10819 @fnindex TAN
10820 @fnindex DTAN
10821 @cindex trigonometric function, tangent
10822 @cindex tangent
10823
10824 @table @asis
10825 @item @emph{Description}:
10826 @code{TAN(X)} computes the tangent of @var{X}.
10827
10828 @item @emph{Standard}:
10829 Fortran 77 and later, for a complex argument Fortran 2008 or later
10830
10831 @item @emph{Class}:
10832 Elemental function
10833
10834 @item @emph{Syntax}:
10835 @code{RESULT = TAN(X)}
10836
10837 @item @emph{Arguments}:
10838 @multitable @columnfractions .15 .70
10839 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
10840 @end multitable
10841
10842 @item @emph{Return value}:
10843 The return value has same type and kind as @var{X}.
10844
10845 @item @emph{Example}:
10846 @smallexample
10847 program test_tan
10848   real(8) :: x = 0.165_8
10849   x = tan(x)
10850 end program test_tan
10851 @end smallexample
10852
10853 @item @emph{Specific names}:
10854 @multitable @columnfractions .20 .20 .20 .25
10855 @item Name            @tab Argument          @tab Return type     @tab Standard
10856 @item @code{TAN(X)}   @tab @code{REAL(4) X}  @tab @code{REAL(4)}  @tab Fortran 95 and later
10857 @item @code{DTAN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}  @tab Fortran 95 and later
10858 @end multitable
10859
10860 @item @emph{See also}:
10861 @ref{ATAN}
10862 @end table
10863
10864
10865
10866 @node TANH
10867 @section @code{TANH} --- Hyperbolic tangent function 
10868 @fnindex TANH
10869 @fnindex DTANH
10870 @cindex hyperbolic tangent
10871 @cindex hyperbolic function, tangent
10872 @cindex tangent, hyperbolic
10873
10874 @table @asis
10875 @item @emph{Description}:
10876 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
10877
10878 @item @emph{Standard}:
10879 Fortran 77 and later, for a complex argument Fortran 2008 or later
10880
10881 @item @emph{Class}:
10882 Elemental function
10883
10884 @item @emph{Syntax}:
10885 @code{X = TANH(X)}
10886
10887 @item @emph{Arguments}:
10888 @multitable @columnfractions .15 .70
10889 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
10890 @end multitable
10891
10892 @item @emph{Return value}:
10893 The return value has same type and kind as @var{X}. If @var{X} is
10894 complex, the imaginary part of the result is in radians. If @var{X}
10895 is @code{REAL}, the return value lies in the range
10896 @math{ - 1 \leq tanh(x) \leq 1 }.
10897
10898 @item @emph{Example}:
10899 @smallexample
10900 program test_tanh
10901   real(8) :: x = 2.1_8
10902   x = tanh(x)
10903 end program test_tanh
10904 @end smallexample
10905
10906 @item @emph{Specific names}:
10907 @multitable @columnfractions .20 .20 .20 .25
10908 @item Name            @tab Argument          @tab Return type       @tab Standard
10909 @item @code{TANH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
10910 @item @code{DTANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
10911 @end multitable
10912
10913 @item @emph{See also}:
10914 @ref{ATANH}
10915 @end table
10916
10917
10918
10919 @node THIS_IMAGE
10920 @section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image
10921 @fnindex THIS_IMAGE
10922 @cindex coarray, THIS_IMAGE
10923 @cindex images, index of this image
10924
10925 @table @asis
10926 @item @emph{Description}:
10927 Returns the cosubscript for this image.
10928
10929 @item @emph{Standard}:
10930 Fortran 2008 and later
10931
10932 @item @emph{Class}:
10933 Transformational function
10934
10935 @item @emph{Syntax}:
10936 @multitable @columnfractions .80
10937 @item @code{RESULT = THIS_IMAGE()}
10938 @item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])}
10939 @end multitable
10940
10941 @item @emph{Arguments}:
10942 @multitable @columnfractions .15 .70
10943 @item @var{COARRAY} @tab Coarray of any type  (optional; if @var{DIM}
10944 present, required).
10945 @item @var{DIM}     @tab default integer scalar (optional). If present,
10946 @var{DIM} shall be between one and the corank of @var{COARRAY}.
10947 @end multitable
10948
10949
10950 @item @emph{Return value}:
10951 Default integer. If @var{COARRAY} is not present, it is scalar and its value
10952 is the index of the invoking image. Otherwise, if @var{DIM} is not present,
10953 a rank-1 array with corank elements is returned, containing the cosubscripts
10954 for @var{COARRAY} specifying the invoking image. If @var{DIM} is present,
10955 a scalar is returned, with the value of the @var{DIM} element of
10956 @code{THIS_IMAGE(COARRAY)}.
10957
10958 @item @emph{Example}:
10959 @smallexample
10960 INTEGER :: value[*]
10961 INTEGER :: i
10962 value = THIS_IMAGE()
10963 SYNC ALL
10964 IF (THIS_IMAGE() == 1) THEN
10965   DO i = 1, NUM_IMAGES()
10966     WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
10967   END DO
10968 END IF
10969 @end smallexample
10970
10971 @item @emph{See also}:
10972 @ref{NUM_IMAGES}, @ref{IMAGE_INDEX}
10973 @end table
10974
10975
10976
10977 @node TIME
10978 @section @code{TIME} --- Time function
10979 @fnindex TIME
10980 @cindex time, current
10981 @cindex current time
10982
10983 @table @asis
10984 @item @emph{Description}:
10985 Returns the current time encoded as an integer (in the manner of the
10986 UNIX function @code{time(3)}). This value is suitable for passing to
10987 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
10988
10989 This intrinsic is not fully portable, such as to systems with 32-bit
10990 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
10991 the values returned by this intrinsic might be, or become, negative, or
10992 numerically less than previous values, during a single run of the
10993 compiled program.
10994
10995 See @ref{TIME8}, for information on a similar intrinsic that might be
10996 portable to more GNU Fortran implementations, though to fewer Fortran
10997 compilers.
10998
10999 @item @emph{Standard}:
11000 GNU extension
11001
11002 @item @emph{Class}:
11003 Function
11004
11005 @item @emph{Syntax}:
11006 @code{RESULT = TIME()}
11007
11008 @item @emph{Return value}:
11009 The return value is a scalar of type @code{INTEGER(4)}.
11010
11011 @item @emph{See also}:
11012 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
11013
11014 @end table
11015
11016
11017
11018 @node TIME8
11019 @section @code{TIME8} --- Time function (64-bit)
11020 @fnindex TIME8
11021 @cindex time, current
11022 @cindex current time
11023
11024 @table @asis
11025 @item @emph{Description}:
11026 Returns the current time encoded as an integer (in the manner of the
11027 UNIX function @code{time(3)}). This value is suitable for passing to
11028 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
11029
11030 @emph{Warning:} this intrinsic does not increase the range of the timing
11031 values over that returned by @code{time(3)}. On a system with a 32-bit
11032 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
11033 it is converted to a 64-bit @code{INTEGER(8)} value. That means
11034 overflows of the 32-bit value can still occur. Therefore, the values
11035 returned by this intrinsic might be or become negative or numerically
11036 less than previous values during a single run of the compiled program.
11037
11038 @item @emph{Standard}:
11039 GNU extension
11040
11041 @item @emph{Class}:
11042 Function
11043
11044 @item @emph{Syntax}:
11045 @code{RESULT = TIME8()}
11046
11047 @item @emph{Return value}:
11048 The return value is a scalar of type @code{INTEGER(8)}.
11049
11050 @item @emph{See also}:
11051 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
11052
11053 @end table
11054
11055
11056
11057 @node TINY
11058 @section @code{TINY} --- Smallest positive number of a real kind
11059 @fnindex TINY
11060 @cindex limits, smallest number
11061 @cindex model representation, smallest number
11062
11063 @table @asis
11064 @item @emph{Description}:
11065 @code{TINY(X)} returns the smallest positive (non zero) number
11066 in the model of the type of @code{X}.
11067
11068 @item @emph{Standard}:
11069 Fortran 95 and later
11070
11071 @item @emph{Class}:
11072 Inquiry function
11073
11074 @item @emph{Syntax}:
11075 @code{RESULT = TINY(X)}
11076
11077 @item @emph{Arguments}:
11078 @multitable @columnfractions .15 .70
11079 @item @var{X} @tab Shall be of type @code{REAL}.
11080 @end multitable
11081
11082 @item @emph{Return value}:
11083 The return value is of the same type and kind as @var{X}
11084
11085 @item @emph{Example}:
11086 See @code{HUGE} for an example.
11087 @end table
11088
11089
11090
11091 @node TRAILZ
11092 @section @code{TRAILZ} --- Number of trailing zero bits of an integer
11093 @fnindex TRAILZ
11094 @cindex zero bits
11095
11096 @table @asis
11097 @item @emph{Description}:
11098 @code{TRAILZ} returns the number of trailing zero bits of an integer.
11099
11100 @item @emph{Standard}:
11101 Fortran 2008 and later
11102
11103 @item @emph{Class}:
11104 Elemental function
11105
11106 @item @emph{Syntax}:
11107 @code{RESULT = TRAILZ(I)}
11108
11109 @item @emph{Arguments}:
11110 @multitable @columnfractions .15 .70
11111 @item @var{I} @tab Shall be of type @code{INTEGER}.
11112 @end multitable
11113
11114 @item @emph{Return value}:
11115 The type of the return value is the default @code{INTEGER}.
11116 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
11117
11118 @item @emph{Example}:
11119 @smallexample
11120 PROGRAM test_trailz
11121   WRITE (*,*) TRAILZ(8)  ! prints 3
11122 END PROGRAM
11123 @end smallexample
11124
11125 @item @emph{See also}:
11126 @ref{BIT_SIZE}, @ref{LEADZ}
11127 @end table
11128
11129
11130
11131 @node TRANSFER
11132 @section @code{TRANSFER} --- Transfer bit patterns
11133 @fnindex TRANSFER
11134 @cindex bits, move
11135 @cindex type cast
11136
11137 @table @asis
11138 @item @emph{Description}:
11139 Interprets the bitwise representation of @var{SOURCE} in memory as if it
11140 is the representation of a variable or array of the same type and type
11141 parameters as @var{MOLD}.
11142
11143 This is approximately equivalent to the C concept of @emph{casting} one
11144 type to another.
11145
11146 @item @emph{Standard}:
11147 Fortran 95 and later
11148
11149 @item @emph{Class}:
11150 Transformational function
11151
11152 @item @emph{Syntax}:
11153 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
11154
11155 @item @emph{Arguments}:
11156 @multitable @columnfractions .15 .70
11157 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
11158 @item @var{MOLD}   @tab Shall be a scalar or an array of any type.
11159 @item @var{SIZE}   @tab (Optional) shall be a scalar of type 
11160 @code{INTEGER}.
11161 @end multitable
11162
11163 @item @emph{Return value}:
11164 The result has the same type as @var{MOLD}, with the bit level
11165 representation of @var{SOURCE}.  If @var{SIZE} is present, the result is
11166 a one-dimensional array of length @var{SIZE}.  If @var{SIZE} is absent
11167 but @var{MOLD} is an array (of any size or shape), the result is a one-
11168 dimensional array of the minimum length needed to contain the entirety
11169 of the bitwise representation of @var{SOURCE}.   If @var{SIZE} is absent
11170 and @var{MOLD} is a scalar, the result is a scalar.
11171
11172 If the bitwise representation of the result is longer than that of
11173 @var{SOURCE}, then the leading bits of the result correspond to those of
11174 @var{SOURCE} and any trailing bits are filled arbitrarily.
11175
11176 When the resulting bit representation does not correspond to a valid
11177 representation of a variable of the same type as @var{MOLD}, the results
11178 are undefined, and subsequent operations on the result cannot be
11179 guaranteed to produce sensible behavior.  For example, it is possible to
11180 create @code{LOGICAL} variables for which @code{@var{VAR}} and
11181 @code{.NOT.@var{VAR}} both appear to be true.
11182
11183 @item @emph{Example}:
11184 @smallexample
11185 PROGRAM test_transfer
11186   integer :: x = 2143289344
11187   print *, transfer(x, 1.0)    ! prints "NaN" on i686
11188 END PROGRAM
11189 @end smallexample
11190 @end table
11191
11192
11193
11194 @node TRANSPOSE
11195 @section @code{TRANSPOSE} --- Transpose an array of rank two
11196 @fnindex TRANSPOSE
11197 @cindex array, transpose
11198 @cindex matrix, transpose
11199 @cindex transpose
11200
11201 @table @asis
11202 @item @emph{Description}:
11203 Transpose an array of rank two. Element (i, j) of the result has the value 
11204 @code{MATRIX(j, i)}, for all i, j.
11205
11206 @item @emph{Standard}:
11207 Fortran 95 and later
11208
11209 @item @emph{Class}:
11210 Transformational function
11211
11212 @item @emph{Syntax}:
11213 @code{RESULT = TRANSPOSE(MATRIX)}
11214
11215 @item @emph{Arguments}:
11216 @multitable @columnfractions .15 .70
11217 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
11218 @end multitable
11219
11220 @item @emph{Return value}:
11221 The result has the same type as @var{MATRIX}, and has shape 
11222 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
11223 @end table
11224
11225
11226
11227 @node TRIM
11228 @section @code{TRIM} --- Remove trailing blank characters of a string
11229 @fnindex TRIM
11230 @cindex string, remove trailing whitespace
11231
11232 @table @asis
11233 @item @emph{Description}:
11234 Removes trailing blank characters of a string.
11235
11236 @item @emph{Standard}:
11237 Fortran 95 and later
11238
11239 @item @emph{Class}:
11240 Transformational function
11241
11242 @item @emph{Syntax}:
11243 @code{RESULT = TRIM(STRING)}
11244
11245 @item @emph{Arguments}:
11246 @multitable @columnfractions .15 .70
11247 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
11248 @end multitable
11249
11250 @item @emph{Return value}:
11251 A scalar of type @code{CHARACTER} which length is that of @var{STRING}
11252 less the number of trailing blanks.
11253
11254 @item @emph{Example}:
11255 @smallexample
11256 PROGRAM test_trim
11257   CHARACTER(len=10), PARAMETER :: s = "GFORTRAN  "
11258   WRITE(*,*) LEN(s), LEN(TRIM(s))  ! "10 8", with/without trailing blanks
11259 END PROGRAM
11260 @end smallexample
11261
11262 @item @emph{See also}:
11263 @ref{ADJUSTL}, @ref{ADJUSTR}
11264 @end table
11265
11266
11267
11268 @node TTYNAM
11269 @section @code{TTYNAM} --- Get the name of a terminal device.
11270 @fnindex TTYNAM
11271 @cindex system, terminal
11272
11273 @table @asis
11274 @item @emph{Description}:
11275 Get the name of a terminal device. For more information, 
11276 see @code{ttyname(3)}.
11277
11278 This intrinsic is provided in both subroutine and function forms; 
11279 however, only one form can be used in any given program unit. 
11280
11281 @item @emph{Standard}:
11282 GNU extension
11283
11284 @item @emph{Class}:
11285 Subroutine, function
11286
11287 @item @emph{Syntax}:
11288 @multitable @columnfractions .80
11289 @item @code{CALL TTYNAM(UNIT, NAME)}
11290 @item @code{NAME = TTYNAM(UNIT)}
11291 @end multitable
11292
11293 @item @emph{Arguments}:
11294 @multitable @columnfractions .15 .70
11295 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
11296 @item @var{NAME} @tab Shall be of type @code{CHARACTER}.
11297 @end multitable
11298
11299 @item @emph{Example}:
11300 @smallexample
11301 PROGRAM test_ttynam
11302   INTEGER :: unit
11303   DO unit = 1, 10
11304     IF (isatty(unit=unit)) write(*,*) ttynam(unit)
11305   END DO
11306 END PROGRAM
11307 @end smallexample
11308
11309 @item @emph{See also}:
11310 @ref{ISATTY}
11311 @end table
11312
11313
11314
11315 @node UBOUND
11316 @section @code{UBOUND} --- Upper dimension bounds of an array
11317 @fnindex UBOUND
11318 @cindex array, upper bound
11319
11320 @table @asis
11321 @item @emph{Description}:
11322 Returns the upper bounds of an array, or a single upper bound
11323 along the @var{DIM} dimension.
11324 @item @emph{Standard}:
11325 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
11326
11327 @item @emph{Class}:
11328 Inquiry function
11329
11330 @item @emph{Syntax}:
11331 @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
11332
11333 @item @emph{Arguments}:
11334 @multitable @columnfractions .15 .70
11335 @item @var{ARRAY} @tab Shall be an array, of any type.
11336 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
11337 @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
11338 expression indicating the kind parameter of the result.
11339 @end multitable
11340
11341 @item @emph{Return value}:
11342 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11343 @var{KIND} is absent, the return value is of default integer kind.
11344 If @var{DIM} is absent, the result is an array of the upper bounds of
11345 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
11346 corresponding to the upper bound of the array along that dimension.  If
11347 @var{ARRAY} is an expression rather than a whole array or array
11348 structure component, or if it has a zero extent along the relevant
11349 dimension, the upper bound is taken to be the number of elements along
11350 the relevant dimension.
11351
11352 @item @emph{See also}:
11353 @ref{LBOUND}, @ref{LCOBOUND}
11354 @end table
11355
11356
11357
11358 @node UCOBOUND
11359 @section @code{UCOBOUND} --- Upper codimension bounds of an array
11360 @fnindex UCOBOUND
11361 @cindex coarray, upper bound
11362
11363 @table @asis
11364 @item @emph{Description}:
11365 Returns the upper cobounds of a coarray, or a single upper cobound
11366 along the @var{DIM} codimension.
11367 @item @emph{Standard}:
11368 Fortran 2008 and later
11369
11370 @item @emph{Class}:
11371 Inquiry function
11372
11373 @item @emph{Syntax}:
11374 @code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])}
11375
11376 @item @emph{Arguments}:
11377 @multitable @columnfractions .15 .70
11378 @item @var{ARRAY} @tab Shall be an coarray, of any type.
11379 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
11380 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
11381 expression indicating the kind parameter of the result.
11382 @end multitable
11383
11384 @item @emph{Return value}:
11385 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11386 @var{KIND} is absent, the return value is of default integer kind.
11387 If @var{DIM} is absent, the result is an array of the lower cobounds of
11388 @var{COARRAY}.  If @var{DIM} is present, the result is a scalar
11389 corresponding to the lower cobound of the array along that codimension.
11390
11391 @item @emph{See also}:
11392 @ref{LCOBOUND}, @ref{LBOUND}
11393 @end table
11394
11395
11396
11397 @node UMASK
11398 @section @code{UMASK} --- Set the file creation mask
11399 @fnindex UMASK
11400 @cindex file system, file creation mask
11401
11402 @table @asis
11403 @item @emph{Description}:
11404 Sets the file creation mask to @var{MASK}. If called as a function, it
11405 returns the old value. If called as a subroutine and argument @var{OLD}
11406 if it is supplied, it is set to the old value. See @code{umask(2)}.
11407
11408 @item @emph{Standard}:
11409 GNU extension
11410
11411 @item @emph{Class}:
11412 Subroutine, function
11413
11414 @item @emph{Syntax}:
11415 @code{CALL UMASK(MASK [, OLD])}
11416 @code{OLD = UMASK(MASK)}
11417
11418 @item @emph{Arguments}:
11419 @multitable @columnfractions .15 .70
11420 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
11421 @item @var{OLD} @tab (Optional) Shall be a scalar of type
11422 @code{INTEGER}.
11423 @end multitable
11424
11425 @end table
11426
11427
11428
11429 @node UNLINK
11430 @section @code{UNLINK} --- Remove a file from the file system
11431 @fnindex UNLINK
11432 @cindex file system, remove file
11433
11434 @table @asis
11435 @item @emph{Description}:
11436 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
11437 used to mark the end of the name in @var{PATH}; otherwise, trailing
11438 blanks in the file name are ignored.  If the @var{STATUS} argument is
11439 supplied, it contains 0 on success or a nonzero error code upon return;
11440 see @code{unlink(2)}.
11441
11442 This intrinsic is provided in both subroutine and function forms;
11443 however, only one form can be used in any given program unit.
11444
11445 @item @emph{Standard}:
11446 GNU extension
11447
11448 @item @emph{Class}:
11449 Subroutine, function
11450
11451 @item @emph{Syntax}:
11452 @multitable @columnfractions .80
11453 @item @code{CALL UNLINK(PATH [, STATUS])}
11454 @item @code{STATUS = UNLINK(PATH)}
11455 @end multitable
11456
11457 @item @emph{Arguments}:
11458 @multitable @columnfractions .15 .70
11459 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
11460 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
11461 @end multitable
11462
11463 @item @emph{See also}:
11464 @ref{LINK}, @ref{SYMLNK}
11465 @end table
11466
11467
11468
11469 @node UNPACK
11470 @section @code{UNPACK} --- Unpack an array of rank one into an array
11471 @fnindex UNPACK
11472 @cindex array, unpacking
11473 @cindex array, increase dimension
11474 @cindex array, scatter elements
11475
11476 @table @asis
11477 @item @emph{Description}:
11478 Store the elements of @var{VECTOR} in an array of higher rank.
11479
11480 @item @emph{Standard}:
11481 Fortran 95 and later
11482
11483 @item @emph{Class}:
11484 Transformational function
11485
11486 @item @emph{Syntax}:
11487 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
11488
11489 @item @emph{Arguments}:
11490 @multitable @columnfractions .15 .70
11491 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It 
11492 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
11493 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL}.
11494 @item @var{FIELD}  @tab Shall be of the same type as @var{VECTOR} and have
11495 the same shape as @var{MASK}.
11496 @end multitable
11497
11498 @item @emph{Return value}:
11499 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
11500 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
11501
11502 @item @emph{Example}:
11503 @smallexample
11504 PROGRAM test_unpack
11505   integer :: vector(2)  = (/1,1/)
11506   logical :: mask(4)  = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
11507   integer :: field(2,2) = 0, unity(2,2)
11508
11509   ! result: unity matrix
11510   unity = unpack(vector, reshape(mask, (/2,2/)), field)
11511 END PROGRAM
11512 @end smallexample
11513
11514 @item @emph{See also}:
11515 @ref{PACK}, @ref{SPREAD}
11516 @end table
11517
11518
11519
11520 @node VERIFY
11521 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
11522 @fnindex VERIFY
11523 @cindex string, find missing set
11524
11525 @table @asis
11526 @item @emph{Description}:
11527 Verifies that all the characters in a @var{SET} are present in a @var{STRING}.
11528
11529 If @var{BACK} is either absent or equals @code{FALSE}, this function
11530 returns the position of the leftmost character of @var{STRING} that is
11531 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
11532 is returned. If all characters of @var{SET} are found in @var{STRING}, the 
11533 result is zero.
11534
11535 @item @emph{Standard}:
11536 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
11537
11538 @item @emph{Class}:
11539 Elemental function
11540
11541 @item @emph{Syntax}:
11542 @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
11543
11544 @item @emph{Arguments}:
11545 @multitable @columnfractions .15 .70
11546 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
11547 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
11548 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
11549 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
11550 expression indicating the kind parameter of the result.
11551 @end multitable
11552
11553 @item @emph{Return value}:
11554 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11555 @var{KIND} is absent, the return value is of default integer kind.
11556
11557 @item @emph{Example}:
11558 @smallexample
11559 PROGRAM test_verify
11560   WRITE(*,*) VERIFY("FORTRAN", "AO")           ! 1, found 'F'
11561   WRITE(*,*) VERIFY("FORTRAN", "FOO")          ! 3, found 'R'
11562   WRITE(*,*) VERIFY("FORTRAN", "C++")          ! 1, found 'F'
11563   WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.)  ! 7, found 'N'
11564   WRITE(*,*) VERIFY("FORTRAN", "FORTRAN")      ! 0' found none
11565 END PROGRAM
11566 @end smallexample
11567
11568 @item @emph{See also}:
11569 @ref{SCAN}, @ref{INDEX intrinsic}
11570 @end table
11571
11572
11573
11574 @node XOR
11575 @section @code{XOR} --- Bitwise logical exclusive OR
11576 @fnindex XOR
11577 @cindex bitwise logical exclusive or
11578 @cindex logical exclusive or, bitwise
11579
11580 @table @asis
11581 @item @emph{Description}:
11582 Bitwise logical exclusive or. 
11583
11584 This intrinsic routine is provided for backwards compatibility with 
11585 GNU Fortran 77.  For integer arguments, programmers should consider
11586 the use of the @ref{IEOR} intrinsic and for logical arguments the
11587 @code{.NEQV.} operator, which are both defined by the Fortran standard.
11588
11589 @item @emph{Standard}:
11590 GNU extension
11591
11592 @item @emph{Class}:
11593 Function
11594
11595 @item @emph{Syntax}:
11596 @code{RESULT = XOR(I, J)}
11597
11598 @item @emph{Arguments}:
11599 @multitable @columnfractions .15 .70
11600 @item @var{I} @tab The type shall be either  a scalar @code{INTEGER}
11601 type or a scalar @code{LOGICAL} type.
11602 @item @var{J} @tab The type shall be the same as the type of @var{I}.
11603 @end multitable
11604
11605 @item @emph{Return value}:
11606 The return type is either a scalar @code{INTEGER} or a scalar
11607 @code{LOGICAL}.  If the kind type parameters differ, then the
11608 smaller kind type is implicitly converted to larger kind, and the 
11609 return has the larger kind.
11610
11611 @item @emph{Example}:
11612 @smallexample
11613 PROGRAM test_xor
11614   LOGICAL :: T = .TRUE., F = .FALSE.
11615   INTEGER :: a, b
11616   DATA a / Z'F' /, b / Z'3' /
11617
11618   WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
11619   WRITE (*,*) XOR(a, b)
11620 END PROGRAM
11621 @end smallexample
11622
11623 @item @emph{See also}:
11624 Fortran 95 elemental function: @ref{IEOR}
11625 @end table
11626
11627
11628
11629 @node Intrinsic Modules
11630 @chapter Intrinsic Modules
11631 @cindex intrinsic Modules
11632
11633 @menu
11634 * ISO_FORTRAN_ENV::
11635 * ISO_C_BINDING::
11636 * OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
11637 @end menu
11638
11639 @node ISO_FORTRAN_ENV
11640 @section @code{ISO_FORTRAN_ENV}
11641 @table @asis
11642 @item @emph{Standard}:
11643 Fortran 2003 and later, except when otherwise noted
11644 @end table
11645
11646 The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
11647 named constants:
11648
11649 @table @asis
11650 @item @code{ATOMIC_INT_KIND}:
11651 Default-kind integer constant to be used as kind parameter when defining
11652 integer variables used in atomic operations. (Fortran 2008 or later.)
11653
11654 @item @code{ATOMIC_LOGICAL_KIND}:
11655 Default-kind integer constant to be used as kind parameter when defining
11656 logical variables used in atomic operations. (Fortran 2008 or later.)
11657
11658 @item @code{CHARACTER_STORAGE_SIZE}:
11659 Size in bits of the character storage unit.
11660
11661 @item @code{ERROR_UNIT}:
11662 Identifies the preconnected unit used for error reporting.
11663
11664 @item @code{FILE_STORAGE_SIZE}:
11665 Size in bits of the file-storage unit.
11666
11667 @item @code{INPUT_UNIT}:
11668 Identifies the preconnected unit identified by the asterisk
11669 (@code{*}) in @code{READ} statement.
11670
11671 @item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}:
11672 Kind type parameters to specify an INTEGER type with a storage
11673 size of 16, 32, and 64 bits. It is negative if a target platform
11674 does not support the particular kind. (Fortran 2008 or later.)
11675
11676 @item @code{IOSTAT_END}:
11677 The value assigned to the variable passed to the IOSTAT= specifier of
11678 an input/output statement if an end-of-file condition occurred.
11679
11680 @item @code{IOSTAT_EOR}:
11681 The value assigned to the variable passed to the IOSTAT= specifier of
11682 an input/output statement if an end-of-record condition occurred.
11683
11684 @item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}:
11685 Scalar default-integer constant, used by @code{INQUIRE} for the
11686 IOSTAT= specifier to denote an that a unit number identifies an
11687 internal unit. (Fortran 2008 or later.)
11688
11689 @item @code{NUMERIC_STORAGE_SIZE}:
11690 The size in bits of the numeric storage unit.
11691
11692 @item @code{OUTPUT_UNIT}:
11693 Identifies the preconnected unit identified by the asterisk
11694 (@code{*}) in @code{WRITE} statement.
11695
11696 @item @code{REAL32}, @code{REAL64}, @code{REAL128}:
11697 Kind type parameters to specify a REAL type with a storage
11698 size of 32, 64, and 128 bits. It is negative if a target platform
11699 does not support the particular kind. (Fortran 2008 or later.)
11700
11701 @item @code{STAT_LOCKED}:
11702 Scalar default-integer constant used as STAT= return value by @code{LOCK} to
11703 denote that the lock variable is locked by the executing image. (Fortran 2008
11704 or later.)
11705
11706 @item @code{STAT_LOCKED_OTHER_IMAGE}:
11707 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
11708 denote that the lock variable is locked by another image. (Fortran 2008 or
11709 later.)
11710
11711 @item @code{STAT_STOPPED_IMAGE}:
11712 Positive, scalar default-integer constant used as STAT= return value if the
11713 argument in the statement requires synchronisation with an image, which has
11714 initiated the termination of the execution. (Fortran 2008 or later.)
11715
11716 @item @code{STAT_UNLOCKED}:
11717 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
11718 denote that the lock variable is unlocked. (Fortran 2008 or later.)
11719 @end table
11720
11721
11722
11723 @node ISO_C_BINDING
11724 @section @code{ISO_C_BINDING}
11725 @table @asis
11726 @item @emph{Standard}:
11727 Fortran 2003 and later, GNU extensions
11728 @end table
11729
11730 The following intrinsic procedures are provided by the module; their
11731 definition can be found in the section Intrinsic Procedures of this
11732 manual.
11733
11734 @table @asis
11735 @item @code{C_ASSOCIATED}
11736 @item @code{C_F_POINTER}
11737 @item @code{C_F_PROCPOINTER}
11738 @item @code{C_FUNLOC}
11739 @item @code{C_LOC}
11740 @end table
11741 @c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
11742 @c don't really know why.
11743
11744 The @code{ISO_C_BINDING} module provides the following named constants of
11745 type default integer, which can be used as KIND type parameters.
11746
11747 In addition to the integer named constants required by the Fortran 2003 
11748 standard, GNU Fortran provides as an extension named constants for the 
11749 128-bit integer types supported by the C compiler: @code{C_INT128_T, 
11750 C_INT_LEAST128_T, C_INT_FAST128_T}.
11751
11752 @multitable @columnfractions .15 .35 .35 .35
11753 @item Fortran Type  @tab Named constant         @tab C type                                @tab Extension
11754 @item @code{INTEGER}@tab @code{C_INT}           @tab @code{int}
11755 @item @code{INTEGER}@tab @code{C_SHORT}         @tab @code{short int}
11756 @item @code{INTEGER}@tab @code{C_LONG}          @tab @code{long int}
11757 @item @code{INTEGER}@tab @code{C_LONG_LONG}     @tab @code{long long int}
11758 @item @code{INTEGER}@tab @code{C_SIGNED_CHAR}   @tab @code{signed char}/@code{unsigned char}
11759 @item @code{INTEGER}@tab @code{C_SIZE_T}        @tab @code{size_t}
11760 @item @code{INTEGER}@tab @code{C_INT8_T}        @tab @code{int8_t}
11761 @item @code{INTEGER}@tab @code{C_INT16_T}       @tab @code{int16_t}
11762 @item @code{INTEGER}@tab @code{C_INT32_T}       @tab @code{int32_t}
11763 @item @code{INTEGER}@tab @code{C_INT64_T}       @tab @code{int64_t}
11764 @item @code{INTEGER}@tab @code{C_INT128_T}      @tab @code{int128_t}                      @tab Ext.
11765 @item @code{INTEGER}@tab @code{C_INT_LEAST8_T}  @tab @code{int_least8_t}
11766 @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
11767 @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
11768 @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
11769 @item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t}                @tab Ext.
11770 @item @code{INTEGER}@tab @code{C_INT_FAST8_T}   @tab @code{int_fast8_t}
11771 @item @code{INTEGER}@tab @code{C_INT_FAST16_T}  @tab @code{int_fast16_t}
11772 @item @code{INTEGER}@tab @code{C_INT_FAST32_T}  @tab @code{int_fast32_t}
11773 @item @code{INTEGER}@tab @code{C_INT_FAST64_T}  @tab @code{int_fast64_t}
11774 @item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t}                 @tab Ext.
11775 @item @code{INTEGER}@tab @code{C_INTMAX_T}      @tab @code{intmax_t}
11776 @item @code{INTEGER}@tab @code{C_INTPTR_T}      @tab @code{intptr_t}
11777 @item @code{REAL}   @tab @code{C_FLOAT}         @tab @code{float}
11778 @item @code{REAL}   @tab @code{C_DOUBLE}        @tab @code{double}
11779 @item @code{REAL}   @tab @code{C_LONG_DOUBLE}   @tab @code{long double}
11780 @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
11781 @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
11782 @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
11783 @item @code{LOGICAL}@tab @code{C_BOOL}          @tab @code{_Bool}
11784 @item @code{CHARACTER}@tab @code{C_CHAR}        @tab @code{char}
11785 @end multitable
11786
11787 Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)}
11788 are defined.
11789
11790 @multitable @columnfractions .20 .45 .15
11791 @item Name                     @tab C definition    @tab Value
11792 @item @code{C_NULL_CHAR}       @tab null character  @tab @code{'\0'}
11793 @item @code{C_ALERT}           @tab alert           @tab @code{'\a'}
11794 @item @code{C_BACKSPACE}       @tab backspace       @tab @code{'\b'}
11795 @item @code{C_FORM_FEED}       @tab form feed       @tab @code{'\f'}
11796 @item @code{C_NEW_LINE}        @tab new line        @tab @code{'\n'}
11797 @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
11798 @item @code{C_HORIZONTAL_TAB}  @tab horizontal tab  @tab @code{'\t'}
11799 @item @code{C_VERTICAL_TAB}    @tab vertical tab    @tab @code{'\v'}
11800 @end multitable
11801
11802 Moreover, the following two named constants are defined:
11803
11804 @multitable @columnfractions .20 .80
11805 @item Name                 @tab Type
11806 @item @code{C_NULL_PTR}    @tab @code{C_PTR}
11807 @item @code{C_NULL_FUNPTR} @tab @code{C_FUNPTR}
11808 @end multitable
11809
11810 Both are equivalent to the value @code{NULL} in C.
11811
11812 @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
11813 @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
11814 @table @asis
11815 @item @emph{Standard}:
11816 OpenMP Application Program Interface v3.0
11817 @end table
11818
11819
11820 The OpenMP Fortran runtime library routines are provided both in
11821 a form of two Fortran 90 modules, named @code{OMP_LIB} and 
11822 @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
11823 @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
11824 in the @ref{Top,,Introduction,libgomp,GNU OpenMP runtime library} manual,
11825 the named constants defined in the @code{OMP_LIB_KINDS} module are listed
11826 below.
11827
11828 For details refer to the actual
11829 @uref{http://www.openmp.org/mp-documents/spec30.pdf,
11830 OpenMP Application Program Interface v3.0}.
11831
11832 @code{OMP_LIB_KINDS} provides the following scalar default-integer
11833 named constants:
11834
11835 @table @asis
11836 @item @code{omp_integer_kind}
11837 @item @code{omp_logical_kind}
11838 @item @code{omp_lock_kind}
11839 @item @code{omp_nest_lock_kind}
11840 @item @code{omp_sched_kind}
11841 @end table