OSDN Git Service

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