OSDN Git Service

09f52782ab9c080fe5c8065cfb906832978eccb0
[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{BGE}:           BGE,       Bitwise greater than or equal to
71 * @code{BGT}:           BGT,       Bitwise greater than
72 * @code{BIT_SIZE}:      BIT_SIZE,  Bit size inquiry function
73 * @code{BLE}:           BLE,       Bitwise less than or equal to
74 * @code{BLT}:           BLT,       Bitwise less than
75 * @code{BTEST}:         BTEST,     Bit test function
76 * @code{C_ASSOCIATED}:  C_ASSOCIATED, Status of a C pointer
77 * @code{C_F_POINTER}:   C_F_POINTER, Convert C into Fortran pointer
78 * @code{C_F_PROCPOINTER}: C_F_PROCPOINTER, Convert C into Fortran procedure pointer
79 * @code{C_FUNLOC}:      C_FUNLOC,  Obtain the C address of a procedure
80 * @code{C_LOC}:         C_LOC,     Obtain the C address of an object
81 * @code{C_SIZEOF}:      C_SIZEOF,  Size in bytes of an expression
82 * @code{CEILING}:       CEILING,   Integer ceiling function
83 * @code{CHAR}:          CHAR,      Integer-to-character conversion function
84 * @code{CHDIR}:         CHDIR,     Change working directory
85 * @code{CHMOD}:         CHMOD,     Change access permissions of files
86 * @code{CMPLX}:         CMPLX,     Complex conversion function
87 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
88 * @code{COMPLEX}:       COMPLEX,   Complex conversion function
89 * @code{COMPILER_VERSION}: COMPILER_VERSION, Compiler version string
90 * @code{COMPILER_OPTIONS}: COMPILER_OPTIONS, Options passed to the compiler
91 * @code{CONJG}:         CONJG,     Complex conjugate function
92 * @code{COS}:           COS,       Cosine function
93 * @code{COSH}:          COSH,      Hyperbolic cosine function
94 * @code{COUNT}:         COUNT,     Count occurrences of TRUE in an array
95 * @code{CPU_TIME}:      CPU_TIME,  CPU time subroutine
96 * @code{CSHIFT}:        CSHIFT,    Circular shift elements of an array
97 * @code{CTIME}:         CTIME,     Subroutine (or function) to convert a time into a string
98 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
99 * @code{DBLE}:          DBLE,      Double precision conversion function
100 * @code{DCMPLX}:        DCMPLX,    Double complex conversion function
101 * @code{DIGITS}:        DIGITS,    Significant digits function
102 * @code{DIM}:           DIM,       Positive difference
103 * @code{DOT_PRODUCT}:   DOT_PRODUCT, Dot product function
104 * @code{DPROD}:         DPROD,     Double product function
105 * @code{DREAL}:         DREAL,     Double real part function
106 * @code{DSHIFTL}:       DSHIFTL,   Combined left shift
107 * @code{DSHIFTR}:       DSHIFTR,   Combined right shift
108 * @code{DTIME}:         DTIME,     Execution time subroutine (or function)
109 * @code{EOSHIFT}:       EOSHIFT,   End-off shift elements of an array
110 * @code{EPSILON}:       EPSILON,   Epsilon function
111 * @code{ERF}:           ERF,       Error function
112 * @code{ERFC}:          ERFC,      Complementary error function
113 * @code{ERFC_SCALED}:   ERFC_SCALED, Exponentially-scaled complementary error function
114 * @code{ETIME}:         ETIME,     Execution time subroutine (or function)
115 * @code{EXECUTE_COMMAND_LINE}: EXECUTE_COMMAND_LINE, Execute a shell command
116 * @code{EXIT}:          EXIT,      Exit the program with status.
117 * @code{EXP}:           EXP,       Exponential function
118 * @code{EXPONENT}:      EXPONENT,  Exponent function
119 * @code{EXTENDS_TYPE_OF}: EXTENDS_TYPE_OF,  Query dynamic type for extension
120 * @code{FDATE}:         FDATE,     Subroutine (or function) to get the current time as a string
121 * @code{FGET}:          FGET,      Read a single character in stream mode from stdin
122 * @code{FGETC}:         FGETC,     Read a single character in stream mode
123 * @code{FLOOR}:         FLOOR,     Integer floor function
124 * @code{FLUSH}:         FLUSH,     Flush I/O unit(s)
125 * @code{FNUM}:          FNUM,      File number function
126 * @code{FPUT}:          FPUT,      Write a single character in stream mode to stdout
127 * @code{FPUTC}:         FPUTC,     Write a single character in stream mode
128 * @code{FRACTION}:      FRACTION,  Fractional part of the model representation
129 * @code{FREE}:          FREE,      Memory de-allocation subroutine
130 * @code{FSEEK}:         FSEEK,     Low level file positioning subroutine
131 * @code{FSTAT}:         FSTAT,     Get file status
132 * @code{FTELL}:         FTELL,     Current stream position
133 * @code{GAMMA}:         GAMMA,     Gamma function
134 * @code{GERROR}:        GERROR,    Get last system error message
135 * @code{GETARG}:        GETARG,    Get command line arguments
136 * @code{GET_COMMAND}:   GET_COMMAND, Get the entire command line
137 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
138 * @code{GETCWD}:        GETCWD,    Get current working directory
139 * @code{GETENV}:        GETENV,    Get an environmental variable
140 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
141 * @code{GETGID}:        GETGID,    Group ID function
142 * @code{GETLOG}:        GETLOG,    Get login name
143 * @code{GETPID}:        GETPID,    Process ID function
144 * @code{GETUID}:        GETUID,    User ID function
145 * @code{GMTIME}:        GMTIME,    Convert time to GMT info
146 * @code{HOSTNM}:        HOSTNM,    Get system host name
147 * @code{HUGE}:          HUGE,      Largest number of a kind
148 * @code{HYPOT}:         HYPOT,     Euclidean distance function
149 * @code{IACHAR}:        IACHAR,    Code in @acronym{ASCII} collating sequence
150 * @code{IALL}:          IALL,      Bitwise AND of array elements
151 * @code{IAND}:          IAND,      Bitwise logical and
152 * @code{IANY}:          IANY,      Bitwise OR of array elements
153 * @code{IARGC}:         IARGC,     Get the number of command line arguments
154 * @code{IBCLR}:         IBCLR,     Clear bit
155 * @code{IBITS}:         IBITS,     Bit extraction
156 * @code{IBSET}:         IBSET,     Set bit
157 * @code{ICHAR}:         ICHAR,     Character-to-integer conversion function
158 * @code{IDATE}:         IDATE,     Current local time (day/month/year)
159 * @code{IEOR}:          IEOR,      Bitwise logical exclusive or
160 * @code{IERRNO}:        IERRNO,    Function to get the last system error number
161 * @code{IMAGE_INDEX}:   IMAGE_INDEX, Cosubscript to image index conversion
162 * @code{INDEX}:         INDEX intrinsic, Position of a substring within a string
163 * @code{INT}:           INT,       Convert to integer type
164 * @code{INT2}:          INT2,      Convert to 16-bit integer type
165 * @code{INT8}:          INT8,      Convert to 64-bit integer type
166 * @code{IOR}:           IOR,       Bitwise logical or
167 * @code{IPARITY}:       IPARITY,   Bitwise XOR of array elements
168 * @code{IRAND}:         IRAND,     Integer pseudo-random number
169 * @code{IS_IOSTAT_END}:  IS_IOSTAT_END, Test for end-of-file value
170 * @code{IS_IOSTAT_EOR}:  IS_IOSTAT_EOR, Test for end-of-record value
171 * @code{ISATTY}:        ISATTY,    Whether a unit is a terminal device
172 * @code{ISHFT}:         ISHFT,     Shift bits
173 * @code{ISHFTC}:        ISHFTC,    Shift bits circularly
174 * @code{ISNAN}:         ISNAN,     Tests for a NaN
175 * @code{ITIME}:         ITIME,     Current local time (hour/minutes/seconds)
176 * @code{KILL}:          KILL,      Send a signal to a process
177 * @code{KIND}:          KIND,      Kind of an entity
178 * @code{LBOUND}:        LBOUND,    Lower dimension bounds of an array
179 * @code{LCOBOUND}:      LCOBOUND,  Lower codimension bounds of an array
180 * @code{LEADZ}:         LEADZ,     Number of leading zero bits of an integer
181 * @code{LEN}:           LEN,       Length of a character entity
182 * @code{LEN_TRIM}:      LEN_TRIM,  Length of a character entity without trailing blank characters
183 * @code{LGE}:           LGE,       Lexical greater than or equal
184 * @code{LGT}:           LGT,       Lexical greater than
185 * @code{LINK}:          LINK,      Create a hard link
186 * @code{LLE}:           LLE,       Lexical less than or equal
187 * @code{LLT}:           LLT,       Lexical less than
188 * @code{LNBLNK}:        LNBLNK,    Index of the last non-blank character in a string
189 * @code{LOC}:           LOC,       Returns the address of a variable
190 * @code{LOG}:           LOG,       Logarithm function
191 * @code{LOG10}:         LOG10,     Base 10 logarithm function 
192 * @code{LOG_GAMMA}:     LOG_GAMMA, Logarithm of the Gamma function
193 * @code{LOGICAL}:       LOGICAL,   Convert to logical type
194 * @code{LONG}:          LONG,      Convert to integer type
195 * @code{LSHIFT}:        LSHIFT,    Left shift bits
196 * @code{LSTAT}:         LSTAT,     Get file status
197 * @code{LTIME}:         LTIME,     Convert time to local time info
198 * @code{MALLOC}:        MALLOC,    Dynamic memory allocation function
199 * @code{MASKL}:         MASKL,     Left justified mask
200 * @code{MASKR}:         MASKR,     Right justified mask
201 * @code{MATMUL}:        MATMUL,    matrix multiplication
202 * @code{MAX}:           MAX,       Maximum value of an argument list
203 * @code{MAXEXPONENT}:   MAXEXPONENT, Maximum exponent of a real kind
204 * @code{MAXLOC}:        MAXLOC,    Location of the maximum value within an array
205 * @code{MAXVAL}:        MAXVAL,    Maximum value of an array
206 * @code{MCLOCK}:        MCLOCK,    Time function
207 * @code{MCLOCK8}:       MCLOCK8,   Time function (64-bit)
208 * @code{MERGE}:         MERGE,     Merge arrays
209 * @code{MERGE_BITS}:    MERGE_BITS, Merge of bits under mask
210 * @code{MIN}:           MIN,       Minimum value of an argument list
211 * @code{MINEXPONENT}:   MINEXPONENT, Minimum exponent of a real kind
212 * @code{MINLOC}:        MINLOC,    Location of the minimum value within an array
213 * @code{MINVAL}:        MINVAL,    Minimum value of an array
214 * @code{MOD}:           MOD,       Remainder function
215 * @code{MODULO}:        MODULO,    Modulo function
216 * @code{MOVE_ALLOC}:    MOVE_ALLOC, Move allocation from one object to another
217 * @code{MVBITS}:        MVBITS,    Move bits from one integer to another
218 * @code{NEAREST}:       NEAREST,   Nearest representable number
219 * @code{NEW_LINE}:      NEW_LINE,  New line character
220 * @code{NINT}:          NINT,      Nearest whole number
221 * @code{NORM2}:         NORM2,     Euclidean vector norm
222 * @code{NOT}:           NOT,       Logical negation
223 * @code{NULL}:          NULL,      Function that returns an disassociated pointer
224 * @code{NUM_IMAGES}:    NUM_IMAGES, Number of images
225 * @code{OR}:            OR,        Bitwise logical OR
226 * @code{PACK}:          PACK,      Pack an array into an array of rank one
227 * @code{PARITY}:        PARITY,    Reduction with exclusive OR
228 * @code{PERROR}:        PERROR,    Print system error message
229 * @code{POPCNT}:        POPCNT,    Number of bits set
230 * @code{POPPAR}:        POPPAR,    Parity of the number of bits set
231 * @code{PRECISION}:     PRECISION, Decimal precision of a real kind
232 * @code{PRESENT}:       PRESENT,   Determine whether an optional dummy argument is specified
233 * @code{PRODUCT}:       PRODUCT,   Product of array elements
234 * @code{RADIX}:         RADIX,     Base of a data model
235 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
236 * @code{RANDOM_SEED}:   RANDOM_SEED, Initialize a pseudo-random number sequence
237 * @code{RAND}:          RAND,      Real pseudo-random number
238 * @code{RANGE}:         RANGE,     Decimal exponent range
239 * @code{RAN}:           RAN,       Real pseudo-random number
240 * @code{REAL}:          REAL,      Convert to real type 
241 * @code{RENAME}:        RENAME,    Rename a file
242 * @code{REPEAT}:        REPEAT,    Repeated string concatenation
243 * @code{RESHAPE}:       RESHAPE,   Function to reshape an array
244 * @code{RRSPACING}:     RRSPACING, Reciprocal of the relative spacing
245 * @code{RSHIFT}:        RSHIFT,    Right shift bits
246 * @code{SAME_TYPE_AS}:  SAME_TYPE_AS,  Query dynamic types for equality
247 * @code{SCALE}:         SCALE,     Scale a real value
248 * @code{SCAN}:          SCAN,      Scan a string for the presence of a set of characters
249 * @code{SECNDS}:        SECNDS,    Time function
250 * @code{SECOND}:        SECOND,    CPU time function
251 * @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND,  Choose character kind
252 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND,  Choose integer kind
253 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND,  Choose real kind
254 * @code{SET_EXPONENT}:  SET_EXPONENT, Set the exponent of the model
255 * @code{SHAPE}:         SHAPE,     Determine the shape of an array
256 * @code{SHIFTA}:        SHIFTA,    Right shift with fill
257 * @code{SHIFTL}:        SHIFTL,    Left shift
258 * @code{SHIFTR}:        SHIFTR,    Right shift
259 * @code{SIGN}:          SIGN,      Sign copying function
260 * @code{SIGNAL}:        SIGNAL,    Signal handling subroutine (or function)
261 * @code{SIN}:           SIN,       Sine function
262 * @code{SINH}:          SINH,      Hyperbolic sine function
263 * @code{SIZE}:          SIZE,      Function to determine the size of an array
264 * @code{SIZEOF}:        SIZEOF,    Determine the size in bytes of an expression
265 * @code{SLEEP}:         SLEEP,     Sleep for the specified number of seconds
266 * @code{SPACING}:       SPACING,   Smallest distance between two numbers of a given type
267 * @code{SPREAD}:        SPREAD,    Add a dimension to an array 
268 * @code{SQRT}:          SQRT,      Square-root function
269 * @code{SRAND}:         SRAND,     Reinitialize the random number generator
270 * @code{STAT}:          STAT,      Get file status
271 * @code{STORAGE_SIZE}:  STORAGE_SIZE, Storage size in bits
272 * @code{SUM}:           SUM,       Sum of array elements
273 * @code{SYMLNK}:        SYMLNK,    Create a symbolic link
274 * @code{SYSTEM}:        SYSTEM,    Execute a shell command
275 * @code{SYSTEM_CLOCK}:  SYSTEM_CLOCK, Time function
276 * @code{TAN}:           TAN,       Tangent function
277 * @code{TANH}:          TANH,      Hyperbolic tangent function
278 * @code{THIS_IMAGE}:    THIS_IMAGE, Cosubscript index of this image
279 * @code{TIME}:          TIME,      Time function
280 * @code{TIME8}:         TIME8,     Time function (64-bit)
281 * @code{TINY}:          TINY,      Smallest positive number of a real kind
282 * @code{TRAILZ}:        TRAILZ,    Number of trailing zero bits of an integer
283 * @code{TRANSFER}:      TRANSFER,  Transfer bit patterns
284 * @code{TRANSPOSE}:     TRANSPOSE, Transpose an array of rank two
285 * @code{TRIM}:          TRIM,      Remove trailing blank characters of a string
286 * @code{TTYNAM}:        TTYNAM,    Get the name of a terminal device.
287 * @code{UBOUND}:        UBOUND,    Upper dimension bounds of an array
288 * @code{UCOBOUND}:      UCOBOUND,  Upper codimension bounds of an array
289 * @code{UMASK}:         UMASK,     Set the file creation mask
290 * @code{UNLINK}:        UNLINK,    Remove a file from the file system
291 * @code{UNPACK}:        UNPACK,    Unpack an array of rank one into an array
292 * @code{VERIFY}:        VERIFY,    Scan a string for the absence of a set of characters
293 * @code{XOR}:           XOR,       Bitwise logical exclusive or
294 @end menu
295
296 @node Introduction to Intrinsics
297 @section Introduction to intrinsic procedures
298
299 The intrinsic procedures provided by GNU Fortran include all of the
300 intrinsic procedures required by the Fortran 95 standard, a set of
301 intrinsic procedures for backwards compatibility with G77, and a
302 selection of intrinsic procedures from the Fortran 2003 and Fortran 2008
303 standards.  Any conflict between a description here and a description in
304 either the Fortran 95 standard, the Fortran 2003 standard or the Fortran
305 2008 standard is unintentional, and the standard(s) should be considered
306 authoritative.
307
308 The enumeration of the @code{KIND} type parameter is processor defined in
309 the Fortran 95 standard.  GNU Fortran defines the default integer type and
310 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
311 respectively.  The standard mandates that both data types shall have
312 another kind, which have more precision.  On typical target architectures
313 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
314 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
315 In the description of generic intrinsic procedures, the kind type parameter
316 will be specified by @code{KIND=*}, and in the description of specific
317 names for an intrinsic procedure the kind type parameter will be explicitly
318 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}).  Finally, for
319 brevity the optional @code{KIND=} syntax will be omitted.
320
321 Many of the intrinsic procedures take one or more optional arguments.
322 This document follows the convention used in the Fortran 95 standard,
323 and denotes such arguments by square brackets.
324
325 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
326 which can be used to restrict the set of intrinsic procedures to a 
327 given standard.  By default, @command{gfortran} sets the @option{-std=gnu}
328 option, and so all intrinsic procedures described here are accepted.  There
329 is one caveat.  For a select group of intrinsic procedures, @command{g77}
330 implemented both a function and a subroutine.  Both classes 
331 have been implemented in @command{gfortran} for backwards compatibility
332 with @command{g77}.  It is noted here that these functions and subroutines
333 cannot be intermixed in a given subprogram.  In the descriptions that follow,
334 the applicable standard for each intrinsic procedure is noted.
335
336
337
338 @node ABORT
339 @section @code{ABORT} --- Abort the program
340 @fnindex ABORT
341 @cindex program termination, with core dump
342 @cindex terminate program, with core dump
343 @cindex core, dump
344
345 @table @asis
346 @item @emph{Description}:
347 @code{ABORT} causes immediate termination of the program.  On operating
348 systems that support a core dump, @code{ABORT} will produce a core dump even if
349 the option @option{-fno-dump-core} is in effect, which is suitable for debugging
350 purposes.
351 @c TODO: Check if this (with -fno-dump-core) is correct.
352
353 @item @emph{Standard}:
354 GNU extension
355
356 @item @emph{Class}:
357 Subroutine
358
359 @item @emph{Syntax}:
360 @code{CALL ABORT}
361
362 @item @emph{Return value}:
363 Does not return.
364
365 @item @emph{Example}:
366 @smallexample
367 program test_abort
368   integer :: i = 1, j = 2
369   if (i /= j) call abort
370 end program test_abort
371 @end smallexample
372
373 @item @emph{See also}:
374 @ref{EXIT}, @ref{KILL}
375
376 @end table
377
378
379
380 @node ABS
381 @section @code{ABS} --- Absolute value
382 @fnindex ABS
383 @fnindex CABS
384 @fnindex DABS
385 @fnindex IABS
386 @fnindex ZABS
387 @fnindex CDABS
388 @cindex absolute value
389
390 @table @asis
391 @item @emph{Description}:
392 @code{ABS(A)} computes the absolute value of @code{A}.
393
394 @item @emph{Standard}:
395 Fortran 77 and later, has overloads that are GNU extensions
396
397 @item @emph{Class}:
398 Elemental function
399
400 @item @emph{Syntax}:
401 @code{RESULT = ABS(A)}
402
403 @item @emph{Arguments}:
404 @multitable @columnfractions .15 .70
405 @item @var{A} @tab The type of the argument shall be an @code{INTEGER},
406 @code{REAL}, or @code{COMPLEX}.
407 @end multitable
408
409 @item @emph{Return value}:
410 The return value is of the same type and
411 kind as the argument except the return value is @code{REAL} for a
412 @code{COMPLEX} argument.
413
414 @item @emph{Example}:
415 @smallexample
416 program test_abs
417   integer :: i = -1
418   real :: x = -1.e0
419   complex :: z = (-1.e0,0.e0)
420   i = abs(i)
421   x = abs(x)
422   x = abs(z)
423 end program test_abs
424 @end smallexample
425
426 @item @emph{Specific names}:
427 @multitable @columnfractions .20 .20 .20 .25
428 @item Name            @tab Argument            @tab Return type       @tab Standard
429 @item @code{ABS(A)}   @tab @code{REAL(4) A}    @tab @code{REAL(4)}    @tab Fortran 77 and later
430 @item @code{CABS(A)}  @tab @code{COMPLEX(4) A} @tab @code{REAL(4)}    @tab Fortran 77 and later
431 @item @code{DABS(A)}  @tab @code{REAL(8) A}    @tab @code{REAL(8)}    @tab Fortran 77 and later
432 @item @code{IABS(A)}  @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab Fortran 77 and later
433 @item @code{ZABS(A)}  @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
434 @item @code{CDABS(A)} @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
435 @end multitable
436 @end table
437
438
439
440 @node ACCESS
441 @section @code{ACCESS} --- Checks file access modes
442 @fnindex ACCESS
443 @cindex file system, access mode
444
445 @table @asis
446 @item @emph{Description}:
447 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME} 
448 exists, is readable, writable or executable. Except for the
449 executable check, @code{ACCESS} can be replaced by
450 Fortran 95's @code{INQUIRE}.
451
452 @item @emph{Standard}:
453 GNU extension
454
455 @item @emph{Class}:
456 Inquiry function
457
458 @item @emph{Syntax}:
459 @code{RESULT = ACCESS(NAME, MODE)}
460
461 @item @emph{Arguments}:
462 @multitable @columnfractions .15 .70
463 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
464 file name. Tailing blank are ignored unless the character @code{achar(0)}
465 is present, then all characters up to and excluding @code{achar(0)} are
466 used as file name.
467 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the
468 file access mode, may be any concatenation of @code{"r"} (readable),
469 @code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check
470 for existence.
471 @end multitable
472
473 @item @emph{Return value}:
474 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
475 accessible in the given mode; otherwise or if an invalid argument
476 has been given for @code{MODE} the value @code{1} is returned.
477
478 @item @emph{Example}:
479 @smallexample
480 program access_test
481   implicit none
482   character(len=*), parameter :: file  = 'test.dat'
483   character(len=*), parameter :: file2 = 'test.dat  '//achar(0)
484   if(access(file,' ') == 0) print *, trim(file),' is exists'
485   if(access(file,'r') == 0) print *, trim(file),' is readable'
486   if(access(file,'w') == 0) print *, trim(file),' is writable'
487   if(access(file,'x') == 0) print *, trim(file),' is executable'
488   if(access(file2,'rwx') == 0) &
489     print *, trim(file2),' is readable, writable and executable'
490 end program access_test
491 @end smallexample
492 @item @emph{Specific names}:
493 @item @emph{See also}:
494
495 @end table
496
497
498
499 @node ACHAR
500 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence 
501 @fnindex ACHAR
502 @cindex @acronym{ASCII} collating sequence
503 @cindex collating sequence, @acronym{ASCII}
504
505 @table @asis
506 @item @emph{Description}:
507 @code{ACHAR(I)} returns the character located at position @code{I}
508 in the @acronym{ASCII} collating sequence.
509
510 @item @emph{Standard}:
511 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
512
513 @item @emph{Class}:
514 Elemental function
515
516 @item @emph{Syntax}:
517 @code{RESULT = ACHAR(I [, KIND])}
518
519 @item @emph{Arguments}:
520 @multitable @columnfractions .15 .70
521 @item @var{I}    @tab The type shall be @code{INTEGER}.
522 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
523 expression indicating the kind parameter of the result.
524 @end multitable
525
526 @item @emph{Return value}:
527 The return value is of type @code{CHARACTER} with a length of one.
528 If the @var{KIND} argument is present, the return value is of the
529 specified kind and of the default kind otherwise.
530
531 @item @emph{Example}:
532 @smallexample
533 program test_achar
534   character c
535   c = achar(32)
536 end program test_achar
537 @end smallexample
538
539 @item @emph{Note}:
540 See @ref{ICHAR} for a discussion of converting between numerical values
541 and formatted string representations.
542
543 @item @emph{See also}:
544 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
545
546 @end table
547
548
549
550 @node ACOS
551 @section @code{ACOS} --- Arccosine function 
552 @fnindex ACOS
553 @fnindex DACOS
554 @cindex trigonometric function, cosine, inverse
555 @cindex cosine, inverse
556
557 @table @asis
558 @item @emph{Description}:
559 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
560
561 @item @emph{Standard}:
562 Fortran 77 and later, for a complex argument Fortran 2008 or later
563
564 @item @emph{Class}:
565 Elemental function
566
567 @item @emph{Syntax}:
568 @code{RESULT = ACOS(X)}
569
570 @item @emph{Arguments}:
571 @multitable @columnfractions .15 .70
572 @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
573 less than or equal to one - or the type shall be @code{COMPLEX}.
574 @end multitable
575
576 @item @emph{Return value}:
577 The return value is of the same type and kind as @var{X}.
578 The real part of the result is in radians and lies in the range
579 @math{0 \leq \Re \acos(x) \leq \pi}.
580
581 @item @emph{Example}:
582 @smallexample
583 program test_acos
584   real(8) :: x = 0.866_8
585   x = acos(x)
586 end program test_acos
587 @end smallexample
588
589 @item @emph{Specific names}:
590 @multitable @columnfractions .20 .20 .20 .25
591 @item Name            @tab Argument         @tab Return type     @tab Standard
592 @item @code{ACOS(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}  @tab Fortran 77 and later
593 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}  @tab Fortran 77 and later
594 @end multitable
595
596 @item @emph{See also}:
597 Inverse function: @ref{COS}
598
599 @end table
600
601
602
603 @node ACOSH
604 @section @code{ACOSH} --- Inverse hyperbolic cosine function
605 @fnindex ACOSH
606 @fnindex DACOSH
607 @cindex area hyperbolic cosine
608 @cindex inverse hyperbolic cosine
609 @cindex hyperbolic function, cosine, inverse
610 @cindex cosine, hyperbolic, inverse
611
612 @table @asis
613 @item @emph{Description}:
614 @code{ACOSH(X)} computes the inverse hyperbolic cosine of @var{X}.
615
616 @item @emph{Standard}:
617 Fortran 2008 and later
618
619 @item @emph{Class}:
620 Elemental function
621
622 @item @emph{Syntax}:
623 @code{RESULT = ACOSH(X)}
624
625 @item @emph{Arguments}:
626 @multitable @columnfractions .15 .70
627 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
628 @end multitable
629
630 @item @emph{Return value}:
631 The return value has the same type and kind as @var{X}. If @var{X} is
632 complex, the imaginary part of the result is in radians and lies between
633 @math{ 0 \leq \Im \acosh(x) \leq \pi}.
634
635 @item @emph{Example}:
636 @smallexample
637 PROGRAM test_acosh
638   REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
639   WRITE (*,*) ACOSH(x)
640 END PROGRAM
641 @end smallexample
642
643 @item @emph{Specific names}:
644 @multitable @columnfractions .20 .20 .20 .25
645 @item Name             @tab Argument          @tab Return type       @tab Standard
646 @item @code{DACOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
647 @end multitable
648
649 @item @emph{See also}:
650 Inverse function: @ref{COSH}
651 @end table
652
653
654
655 @node ADJUSTL
656 @section @code{ADJUSTL} --- Left adjust a string 
657 @fnindex ADJUSTL
658 @cindex string, adjust left
659 @cindex adjust string
660
661 @table @asis
662 @item @emph{Description}:
663 @code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
664 Spaces are inserted at the end of the string as needed.
665
666 @item @emph{Standard}:
667 Fortran 90 and later
668
669 @item @emph{Class}:
670 Elemental function
671
672 @item @emph{Syntax}:
673 @code{RESULT = ADJUSTL(STRING)}
674
675 @item @emph{Arguments}:
676 @multitable @columnfractions .15 .70
677 @item @var{STRING} @tab The type shall be @code{CHARACTER}.
678 @end multitable
679
680 @item @emph{Return value}:
681 The return value is of type @code{CHARACTER} and of the same kind as
682 @var{STRING} where leading spaces are removed and the same number of
683 spaces are inserted on the end of @var{STRING}.
684
685 @item @emph{Example}:
686 @smallexample
687 program test_adjustl
688   character(len=20) :: str = '   gfortran'
689   str = adjustl(str)
690   print *, str
691 end program test_adjustl
692 @end smallexample
693
694 @item @emph{See also}:
695 @ref{ADJUSTR}, @ref{TRIM}
696 @end table
697
698
699
700 @node ADJUSTR
701 @section @code{ADJUSTR} --- Right adjust a string 
702 @fnindex ADJUSTR
703 @cindex string, adjust right
704 @cindex adjust string
705
706 @table @asis
707 @item @emph{Description}:
708 @code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
709 Spaces are inserted at the start of the string as needed.
710
711 @item @emph{Standard}:
712 Fortran 95 and later
713
714 @item @emph{Class}:
715 Elemental function
716
717 @item @emph{Syntax}:
718 @code{RESULT = ADJUSTR(STRING)}
719
720 @item @emph{Arguments}:
721 @multitable @columnfractions .15 .70
722 @item @var{STR} @tab The type shall be @code{CHARACTER}.
723 @end multitable
724
725 @item @emph{Return value}:
726 The return value is of type @code{CHARACTER} and of the same kind as
727 @var{STRING} where trailing spaces are removed and the same number of
728 spaces are inserted at the start of @var{STRING}.
729
730 @item @emph{Example}:
731 @smallexample
732 program test_adjustr
733   character(len=20) :: str = 'gfortran'
734   str = adjustr(str)
735   print *, str
736 end program test_adjustr
737 @end smallexample
738
739 @item @emph{See also}:
740 @ref{ADJUSTL}, @ref{TRIM}
741 @end table
742
743
744
745 @node AIMAG
746 @section @code{AIMAG} --- Imaginary part of complex number  
747 @fnindex AIMAG
748 @fnindex DIMAG
749 @fnindex IMAG
750 @fnindex IMAGPART
751 @cindex complex numbers, imaginary part
752
753 @table @asis
754 @item @emph{Description}:
755 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
756 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
757 for compatibility with @command{g77}, and their use in new code is 
758 strongly discouraged.
759
760 @item @emph{Standard}:
761 Fortran 77 and later, has overloads that are GNU extensions
762
763 @item @emph{Class}:
764 Elemental function
765
766 @item @emph{Syntax}:
767 @code{RESULT = AIMAG(Z)}
768
769 @item @emph{Arguments}:
770 @multitable @columnfractions .15 .70
771 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
772 @end multitable
773
774 @item @emph{Return value}:
775 The return value is of type @code{REAL} with the
776 kind type parameter of the argument.
777
778 @item @emph{Example}:
779 @smallexample
780 program test_aimag
781   complex(4) z4
782   complex(8) z8
783   z4 = cmplx(1.e0_4, 0.e0_4)
784   z8 = cmplx(0.e0_8, 1.e0_8)
785   print *, aimag(z4), dimag(z8)
786 end program test_aimag
787 @end smallexample
788
789 @item @emph{Specific names}:
790 @multitable @columnfractions .20 .20 .20 .25
791 @item Name               @tab Argument            @tab Return type     @tab Standard
792 @item @code{AIMAG(Z)}    @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
793 @item @code{DIMAG(Z)}    @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)}  @tab GNU extension
794 @item @code{IMAG(Z)}     @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
795 @item @code{IMAGPART(Z)} @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
796 @end multitable
797 @end table
798
799
800
801 @node AINT
802 @section @code{AINT} --- Truncate to a whole number
803 @fnindex AINT
804 @fnindex DINT
805 @cindex floor
806 @cindex rounding, floor
807
808 @table @asis
809 @item @emph{Description}:
810 @code{AINT(A [, KIND])} truncates its argument to a whole number.
811
812 @item @emph{Standard}:
813 Fortran 77 and later
814
815 @item @emph{Class}:
816 Elemental function
817
818 @item @emph{Syntax}:
819 @code{RESULT = AINT(A [, KIND])} 
820
821 @item @emph{Arguments}:
822 @multitable @columnfractions .15 .70
823 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
824 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
825 expression indicating the kind parameter of the result.
826 @end multitable
827
828 @item @emph{Return value}:
829 The return value is of type @code{REAL} with the kind type parameter of the
830 argument if the optional @var{KIND} is absent; otherwise, the kind
831 type parameter will be given by @var{KIND}.  If the magnitude of 
832 @var{X} is less than one, @code{AINT(X)} returns zero.  If the
833 magnitude is equal to or greater than one then it returns the largest
834 whole number that does not exceed its magnitude.  The sign is the same
835 as the sign of @var{X}. 
836
837 @item @emph{Example}:
838 @smallexample
839 program test_aint
840   real(4) x4
841   real(8) x8
842   x4 = 1.234E0_4
843   x8 = 4.321_8
844   print *, aint(x4), dint(x8)
845   x8 = aint(x4,8)
846 end program test_aint
847 @end smallexample
848
849 @item @emph{Specific names}:
850 @multitable @columnfractions .20 .20 .20 .25
851 @item Name           @tab Argument         @tab Return type      @tab Standard
852 @item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)}   @tab Fortran 77 and later
853 @item @code{DINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)}   @tab Fortran 77 and later
854 @end multitable
855 @end table
856
857
858
859 @node ALARM
860 @section @code{ALARM} --- Execute a routine after a given delay
861 @fnindex ALARM
862 @cindex delayed execution
863
864 @table @asis
865 @item @emph{Description}:
866 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
867 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
868 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
869 supplied, it will be returned with the number of seconds remaining until
870 any previously scheduled alarm was due to be delivered, or zero if there
871 was no previously scheduled alarm.
872
873 @item @emph{Standard}:
874 GNU extension
875
876 @item @emph{Class}:
877 Subroutine
878
879 @item @emph{Syntax}:
880 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
881
882 @item @emph{Arguments}:
883 @multitable @columnfractions .15 .70
884 @item @var{SECONDS} @tab The type of the argument shall be a scalar
885 @code{INTEGER}. It is @code{INTENT(IN)}.
886 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
887 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar 
888 values may be either @code{SIG_IGN=1} to ignore the alarm generated 
889 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
890 @item @var{STATUS}  @tab (Optional) @var{STATUS} shall be a scalar
891 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
892 @end multitable
893
894 @item @emph{Example}:
895 @smallexample
896 program test_alarm
897   external handler_print
898   integer i
899   call alarm (3, handler_print, i)
900   print *, i
901   call sleep(10)
902 end program test_alarm
903 @end smallexample
904 This will cause the external routine @var{handler_print} to be called
905 after 3 seconds.
906 @end table
907
908
909
910 @node ALL
911 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true 
912 @fnindex ALL
913 @cindex array, apply condition
914 @cindex array, condition testing
915
916 @table @asis
917 @item @emph{Description}:
918 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
919 in the array along dimension @var{DIM}.
920
921 @item @emph{Standard}:
922 Fortran 95 and later
923
924 @item @emph{Class}:
925 Transformational function
926
927 @item @emph{Syntax}:
928 @code{RESULT = ALL(MASK [, DIM])}
929
930 @item @emph{Arguments}:
931 @multitable @columnfractions .15 .70
932 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
933 it shall not be scalar.
934 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
935 with a value that lies between one and the rank of @var{MASK}.
936 @end multitable
937
938 @item @emph{Return value}:
939 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where
940 the kind type parameter is the same as the kind type parameter of
941 @var{MASK}.  If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
942 an array with the rank of @var{MASK} minus 1.  The shape is determined from
943 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
944
945 @table @asis
946 @item (A)
947 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
948 It also is true if @var{MASK} has zero size; otherwise, it is false.
949 @item (B)
950 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
951 to @code{ALL(MASK)}.  If the rank is greater than one, then @code{ALL(MASK,DIM)}
952 is determined by applying @code{ALL} to the array sections.
953 @end table
954
955 @item @emph{Example}:
956 @smallexample
957 program test_all
958   logical l
959   l = all((/.true., .true., .true./))
960   print *, l
961   call section
962   contains
963     subroutine section
964       integer a(2,3), b(2,3)
965       a = 1
966       b = 1
967       b(2,2) = 2
968       print *, all(a .eq. b, 1)
969       print *, all(a .eq. b, 2)
970     end subroutine section
971 end program test_all
972 @end smallexample
973 @end table
974
975
976
977 @node ALLOCATED
978 @section @code{ALLOCATED} --- Status of an allocatable entity
979 @fnindex ALLOCATED
980 @cindex allocation, status
981
982 @table @asis
983 @item @emph{Description}:
984 @code{ALLOCATED(ARRAY)} and @code{ALLOCATED(SCALAR)} check the allocation
985 status of @var{ARRAY} and @var{SCALAR}, respectively.
986
987 @item @emph{Standard}:
988 Fortran 95 and later.  Note, the @code{SCALAR=} keyword and allocatable
989 scalar entities are available in Fortran 2003 and later.
990
991 @item @emph{Class}:
992 Inquiry function
993
994 @item @emph{Syntax}:
995 @code{RESULT = ALLOCATED(ARRAY)} or @code{RESULT = ALLOCATED(SCALAR)} 
996
997 @item @emph{Arguments}:
998 @multitable @columnfractions .15 .70
999 @item @var{ARRAY}    @tab The argument shall be an @code{ALLOCATABLE} array.
1000 @item @var{SCALAR}   @tab The argument shall be an @code{ALLOCATABLE} scalar.
1001 @end multitable
1002
1003 @item @emph{Return value}:
1004 The return value is a scalar @code{LOGICAL} with the default logical
1005 kind type parameter.  If the argument is allocated, then the result is
1006 @code{.TRUE.}; otherwise, it returns @code{.FALSE.} 
1007
1008 @item @emph{Example}:
1009 @smallexample
1010 program test_allocated
1011   integer :: i = 4
1012   real(4), allocatable :: x(:)
1013   if (.not. allocated(x)) allocate(x(i))
1014 end program test_allocated
1015 @end smallexample
1016 @end table
1017
1018
1019
1020 @node AND
1021 @section @code{AND} --- Bitwise logical AND
1022 @fnindex AND
1023 @cindex bitwise logical and
1024 @cindex logical and, bitwise
1025
1026 @table @asis
1027 @item @emph{Description}:
1028 Bitwise logical @code{AND}.
1029
1030 This intrinsic routine is provided for backwards compatibility with 
1031 GNU Fortran 77.  For integer arguments, programmers should consider
1032 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
1033
1034 @item @emph{Standard}:
1035 GNU extension
1036
1037 @item @emph{Class}:
1038 Function
1039
1040 @item @emph{Syntax}:
1041 @code{RESULT = AND(I, J)}
1042
1043 @item @emph{Arguments}:
1044 @multitable @columnfractions .15 .70
1045 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
1046 type or a scalar @code{LOGICAL} type.
1047 @item @var{J} @tab The type shall be the same as the type of @var{I}.
1048 @end multitable
1049
1050 @item @emph{Return value}:
1051 The return type is either a scalar @code{INTEGER} or a scalar
1052 @code{LOGICAL}.  If the kind type parameters differ, then the
1053 smaller kind type is implicitly converted to larger kind, and the 
1054 return has the larger kind.
1055
1056 @item @emph{Example}:
1057 @smallexample
1058 PROGRAM test_and
1059   LOGICAL :: T = .TRUE., F = .FALSE.
1060   INTEGER :: a, b
1061   DATA a / Z'F' /, b / Z'3' /
1062
1063   WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1064   WRITE (*,*) AND(a, b)
1065 END PROGRAM
1066 @end smallexample
1067
1068 @item @emph{See also}:
1069 Fortran 95 elemental function: @ref{IAND}
1070 @end table
1071
1072
1073
1074 @node ANINT
1075 @section @code{ANINT} --- Nearest whole number
1076 @fnindex ANINT
1077 @fnindex DNINT
1078 @cindex ceiling
1079 @cindex rounding, ceiling
1080
1081 @table @asis
1082 @item @emph{Description}:
1083 @code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1084
1085 @item @emph{Standard}:
1086 Fortran 77 and later
1087
1088 @item @emph{Class}:
1089 Elemental function
1090
1091 @item @emph{Syntax}:
1092 @code{RESULT = ANINT(A [, KIND])}
1093
1094 @item @emph{Arguments}:
1095 @multitable @columnfractions .15 .70
1096 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
1097 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
1098 expression indicating the kind parameter of the result.
1099 @end multitable
1100
1101 @item @emph{Return value}:
1102 The return value is of type real with the kind type parameter of the
1103 argument if the optional @var{KIND} is absent; otherwise, the kind
1104 type parameter will be given by @var{KIND}.  If @var{A} is greater than
1105 zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}.  If @var{A} is
1106 less than or equal to zero then it returns @code{AINT(X-0.5)}.
1107
1108 @item @emph{Example}:
1109 @smallexample
1110 program test_anint
1111   real(4) x4
1112   real(8) x8
1113   x4 = 1.234E0_4
1114   x8 = 4.321_8
1115   print *, anint(x4), dnint(x8)
1116   x8 = anint(x4,8)
1117 end program test_anint
1118 @end smallexample
1119
1120 @item @emph{Specific names}:
1121 @multitable @columnfractions .20 .20 .20 .25
1122 @item Name            @tab Argument         @tab Return type      @tab Standard
1123 @item @code{AINT(A)}  @tab @code{REAL(4) A} @tab @code{REAL(4)}   @tab Fortran 77 and later
1124 @item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)}   @tab Fortran 77 and later
1125 @end multitable
1126 @end table
1127
1128
1129
1130 @node ANY
1131 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true 
1132 @fnindex ANY
1133 @cindex array, apply condition
1134 @cindex array, condition testing
1135
1136 @table @asis
1137 @item @emph{Description}:
1138 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1139 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1140
1141 @item @emph{Standard}:
1142 Fortran 95 and later
1143
1144 @item @emph{Class}:
1145 Transformational function
1146
1147 @item @emph{Syntax}:
1148 @code{RESULT = ANY(MASK [, DIM])}
1149
1150 @item @emph{Arguments}:
1151 @multitable @columnfractions .15 .70
1152 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1153 it shall not be scalar.
1154 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
1155 with a value that lies between one and the rank of @var{MASK}.
1156 @end multitable
1157
1158 @item @emph{Return value}:
1159 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1160 the kind type parameter is the same as the kind type parameter of
1161 @var{MASK}.  If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1162 an array with the rank of @var{MASK} minus 1.  The shape is determined from
1163 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
1164
1165 @table @asis
1166 @item (A)
1167 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1168 otherwise, it is false.  It also is false if @var{MASK} has zero size.
1169 @item (B)
1170 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1171 to @code{ANY(MASK)}.  If the rank is greater than one, then @code{ANY(MASK,DIM)}
1172 is determined by applying @code{ANY} to the array sections.
1173 @end table
1174
1175 @item @emph{Example}:
1176 @smallexample
1177 program test_any
1178   logical l
1179   l = any((/.true., .true., .true./))
1180   print *, l
1181   call section
1182   contains
1183     subroutine section
1184       integer a(2,3), b(2,3)
1185       a = 1
1186       b = 1
1187       b(2,2) = 2
1188       print *, any(a .eq. b, 1)
1189       print *, any(a .eq. b, 2)
1190     end subroutine section
1191 end program test_any
1192 @end smallexample
1193 @end table
1194
1195
1196
1197 @node ASIN
1198 @section @code{ASIN} --- Arcsine function 
1199 @fnindex ASIN
1200 @fnindex DASIN
1201 @cindex trigonometric function, sine, inverse
1202 @cindex sine, inverse
1203
1204 @table @asis
1205 @item @emph{Description}:
1206 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1207
1208 @item @emph{Standard}:
1209 Fortran 77 and later, for a complex argument Fortran 2008 or later
1210
1211 @item @emph{Class}:
1212 Elemental function
1213
1214 @item @emph{Syntax}:
1215 @code{RESULT = ASIN(X)}
1216
1217 @item @emph{Arguments}:
1218 @multitable @columnfractions .15 .70
1219 @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1220 less than or equal to one - or be @code{COMPLEX}.
1221 @end multitable
1222
1223 @item @emph{Return value}:
1224 The return value is of the same type and kind as @var{X}.
1225 The real part of the result is in radians and lies in the range
1226 @math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}.
1227
1228 @item @emph{Example}:
1229 @smallexample
1230 program test_asin
1231   real(8) :: x = 0.866_8
1232   x = asin(x)
1233 end program test_asin
1234 @end smallexample
1235
1236 @item @emph{Specific names}:
1237 @multitable @columnfractions .20 .20 .20 .25
1238 @item Name            @tab Argument          @tab Return type       @tab Standard
1239 @item @code{ASIN(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
1240 @item @code{DASIN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1241 @end multitable
1242
1243 @item @emph{See also}:
1244 Inverse function: @ref{SIN}
1245
1246 @end table
1247
1248
1249
1250 @node ASINH
1251 @section @code{ASINH} --- Inverse hyperbolic sine function
1252 @fnindex ASINH
1253 @fnindex DASINH
1254 @cindex area hyperbolic sine
1255 @cindex inverse hyperbolic sine
1256 @cindex hyperbolic function, sine, inverse
1257 @cindex sine, hyperbolic, inverse
1258
1259 @table @asis
1260 @item @emph{Description}:
1261 @code{ASINH(X)} computes the inverse hyperbolic sine of @var{X}.
1262
1263 @item @emph{Standard}:
1264 Fortran 2008 and later
1265
1266 @item @emph{Class}:
1267 Elemental function
1268
1269 @item @emph{Syntax}:
1270 @code{RESULT = ASINH(X)}
1271
1272 @item @emph{Arguments}:
1273 @multitable @columnfractions .15 .70
1274 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1275 @end multitable
1276
1277 @item @emph{Return value}:
1278 The return value is of the same type and kind as  @var{X}. If @var{X} is
1279 complex, the imaginary part of the result is in radians and lies between
1280 @math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}.
1281
1282 @item @emph{Example}:
1283 @smallexample
1284 PROGRAM test_asinh
1285   REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1286   WRITE (*,*) ASINH(x)
1287 END PROGRAM
1288 @end smallexample
1289
1290 @item @emph{Specific names}:
1291 @multitable @columnfractions .20 .20 .20 .25
1292 @item Name             @tab Argument          @tab Return type       @tab Standard
1293 @item @code{DASINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension.
1294 @end multitable
1295
1296 @item @emph{See also}:
1297 Inverse function: @ref{SINH}
1298 @end table
1299
1300
1301
1302 @node ASSOCIATED
1303 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair 
1304 @fnindex ASSOCIATED
1305 @cindex pointer, status
1306 @cindex association status
1307
1308 @table @asis
1309 @item @emph{Description}:
1310 @code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1311 @var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
1312
1313 @item @emph{Standard}:
1314 Fortran 95 and later
1315
1316 @item @emph{Class}:
1317 Inquiry function
1318
1319 @item @emph{Syntax}:
1320 @code{RESULT = ASSOCIATED(POINTER [, TARGET])}
1321
1322 @item @emph{Arguments}:
1323 @multitable @columnfractions .15 .70
1324 @item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1325 and it can be of any type.
1326 @item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1327 a target.  It must have the same type, kind type parameter, and
1328 array rank as @var{POINTER}.
1329 @end multitable
1330 The association status of neither @var{POINTER} nor @var{TARGET} shall be
1331 undefined.
1332
1333 @item @emph{Return value}:
1334 @code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
1335 There are several cases:
1336 @table @asis
1337 @item (A) When the optional @var{TARGET} is not present then
1338 @code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1339 @item (B) If @var{TARGET} is present and a scalar target, the result is true if
1340 @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
1341 disassociated, the result is false.
1342 @item (C) If @var{TARGET} is present and an array target, the result is true if
1343 @var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1344 are arrays whose elements are not zero-sized storage sequences, and
1345 @var{TARGET} and @var{POINTER} occupy the same storage units in array element
1346 order.
1347 As in case(B), the result is false, if @var{POINTER} is disassociated.
1348 @item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1349 if @var{TARGET} is associated with @var{POINTER}, the target associated with
1350 @var{TARGET} are not zero-sized storage sequences and occupy the same storage
1351 units.
1352 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1353 @item (E) If @var{TARGET} is present and an array pointer, the result is true if
1354 target associated with @var{POINTER} and the target associated with @var{TARGET}
1355 have the same shape, are not zero-sized arrays, are arrays whose elements are
1356 not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1357 the same storage units in array element order.
1358 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1359 @end table
1360
1361 @item @emph{Example}:
1362 @smallexample
1363 program test_associated
1364    implicit none
1365    real, target  :: tgt(2) = (/1., 2./)
1366    real, pointer :: ptr(:)
1367    ptr => tgt
1368    if (associated(ptr)     .eqv. .false.) call abort
1369    if (associated(ptr,tgt) .eqv. .false.) call abort
1370 end program test_associated
1371 @end smallexample
1372
1373 @item @emph{See also}:
1374 @ref{NULL}
1375 @end table
1376
1377
1378
1379 @node ATAN
1380 @section @code{ATAN} --- Arctangent function 
1381 @fnindex ATAN
1382 @fnindex DATAN
1383 @cindex trigonometric function, tangent, inverse
1384 @cindex tangent, inverse
1385
1386 @table @asis
1387 @item @emph{Description}:
1388 @code{ATAN(X)} computes the arctangent of @var{X}.
1389
1390 @item @emph{Standard}:
1391 Fortran 77 and later, for a complex argument and for two arguments
1392 Fortran 2008 or later
1393
1394 @item @emph{Class}:
1395 Elemental function
1396
1397 @item @emph{Syntax}:
1398 @code{RESULT = ATAN(X)}
1399 @code{RESULT = ATAN(Y, X)}
1400
1401 @item @emph{Arguments}:
1402 @multitable @columnfractions .15 .70
1403 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1404 if @var{Y} is present, @var{X} shall be REAL.
1405 @item @var{Y} shall be of the same type and kind as @var{X}.
1406 @end multitable
1407
1408 @item @emph{Return value}:
1409 The return value is of the same type and kind as @var{X}.
1410 If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}.
1411 Otherwise, it the arcus tangent of @var{X}, where the real part of
1412 the result is in radians and lies in the range
1413 @math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}.
1414
1415 @item @emph{Example}:
1416 @smallexample
1417 program test_atan
1418   real(8) :: x = 2.866_8
1419   x = atan(x)
1420 end program test_atan
1421 @end smallexample
1422
1423 @item @emph{Specific names}:
1424 @multitable @columnfractions .20 .20 .20 .25
1425 @item Name            @tab Argument          @tab Return type       @tab Standard
1426 @item @code{ATAN(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
1427 @item @code{DATAN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1428 @end multitable
1429
1430 @item @emph{See also}:
1431 Inverse function: @ref{TAN}
1432
1433 @end table
1434
1435
1436
1437 @node ATAN2
1438 @section @code{ATAN2} --- Arctangent function 
1439 @fnindex ATAN2
1440 @fnindex DATAN2
1441 @cindex trigonometric function, tangent, inverse
1442 @cindex tangent, inverse
1443
1444 @table @asis
1445 @item @emph{Description}:
1446 @code{ATAN2(Y, X)} computes the principal value of the argument
1447 function of the complex number @math{X + i Y}. This function can
1448 be used to transform from Cartesian into polar coordinates and
1449 allows to determine the angle in the correct quadrant.
1450
1451 @item @emph{Standard}:
1452 Fortran 77 and later
1453
1454 @item @emph{Class}:
1455 Elemental function
1456
1457 @item @emph{Syntax}:
1458 @code{RESULT = ATAN2(Y, X)}
1459
1460 @item @emph{Arguments}:
1461 @multitable @columnfractions .15 .70
1462 @item @var{Y} @tab The type shall be @code{REAL}.
1463 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1464 If @var{Y} is zero, then @var{X} must be nonzero.
1465 @end multitable
1466
1467 @item @emph{Return value}:
1468 The return value has the same type and kind type parameter as @var{Y}.
1469 It is the principal value of the complex number @math{X + i Y}.  If
1470 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1471 The sign is positive if @var{Y} is positive.  If @var{Y} is zero, then
1472 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1473 is negative.  Finally, if @var{X} is zero, then the magnitude of the result
1474 is @math{\pi/2}.
1475
1476 @item @emph{Example}:
1477 @smallexample
1478 program test_atan2
1479   real(4) :: x = 1.e0_4, y = 0.5e0_4
1480   x = atan2(y,x)
1481 end program test_atan2
1482 @end smallexample
1483
1484 @item @emph{Specific names}:
1485 @multitable @columnfractions .20 .20 .20 .25
1486 @item Name                @tab Argument            @tab Return type    @tab Standard
1487 @item @code{ATAN2(X, Y)}  @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
1488 @item @code{DATAN2(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
1489 @end multitable
1490 @end table
1491
1492
1493
1494 @node ATANH
1495 @section @code{ATANH} --- Inverse hyperbolic tangent function
1496 @fnindex ATANH
1497 @fnindex DATANH
1498 @cindex area hyperbolic tangent
1499 @cindex inverse hyperbolic tangent
1500 @cindex hyperbolic function, tangent, inverse
1501 @cindex tangent, hyperbolic, inverse
1502
1503 @table @asis
1504 @item @emph{Description}:
1505 @code{ATANH(X)} computes the inverse hyperbolic tangent of @var{X}.
1506
1507 @item @emph{Standard}:
1508 Fortran 2008 and later
1509
1510 @item @emph{Class}:
1511 Elemental function
1512
1513 @item @emph{Syntax}:
1514 @code{RESULT = ATANH(X)}
1515
1516 @item @emph{Arguments}:
1517 @multitable @columnfractions .15 .70
1518 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1519 @end multitable
1520
1521 @item @emph{Return value}:
1522 The return value has same type and kind as @var{X}. If @var{X} is
1523 complex, the imaginary part of the result is in radians and lies between
1524 @math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}.
1525
1526 @item @emph{Example}:
1527 @smallexample
1528 PROGRAM test_atanh
1529   REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1530   WRITE (*,*) ATANH(x)
1531 END PROGRAM
1532 @end smallexample
1533
1534 @item @emph{Specific names}:
1535 @multitable @columnfractions .20 .20 .20 .25
1536 @item Name             @tab Argument          @tab Return type       @tab Standard
1537 @item @code{DATANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1538 @end multitable
1539
1540 @item @emph{See also}:
1541 Inverse function: @ref{TANH}
1542 @end table
1543
1544
1545
1546 @node BESSEL_J0
1547 @section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
1548 @fnindex BESSEL_J0
1549 @fnindex BESJ0
1550 @fnindex DBESJ0
1551 @cindex Bessel function, first kind
1552
1553 @table @asis
1554 @item @emph{Description}:
1555 @code{BESSEL_J0(X)} computes the Bessel function of the first kind of
1556 order 0 of @var{X}. This function is available under the name
1557 @code{BESJ0} as a GNU extension.
1558
1559 @item @emph{Standard}:
1560 Fortran 2008 and later
1561
1562 @item @emph{Class}:
1563 Elemental function
1564
1565 @item @emph{Syntax}:
1566 @code{RESULT = BESSEL_J0(X)}
1567
1568 @item @emph{Arguments}:
1569 @multitable @columnfractions .15 .70
1570 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1571 @end multitable
1572
1573 @item @emph{Return value}:
1574 The return value is of type @code{REAL} and lies in the
1575 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
1576 kind as @var{X}.
1577
1578 @item @emph{Example}:
1579 @smallexample
1580 program test_besj0
1581   real(8) :: x = 0.0_8
1582   x = bessel_j0(x)
1583 end program test_besj0
1584 @end smallexample
1585
1586 @item @emph{Specific names}:
1587 @multitable @columnfractions .20 .20 .20 .25
1588 @item Name            @tab Argument          @tab Return type       @tab Standard
1589 @item @code{DBESJ0(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}   @tab GNU extension
1590 @end multitable
1591 @end table
1592
1593
1594
1595 @node BESSEL_J1
1596 @section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
1597 @fnindex BESSEL_J1
1598 @fnindex BESJ1
1599 @fnindex DBESJ1
1600 @cindex Bessel function, first kind
1601
1602 @table @asis
1603 @item @emph{Description}:
1604 @code{BESSEL_J1(X)} computes the Bessel function of the first kind of
1605 order 1 of @var{X}. This function is available under the name
1606 @code{BESJ1} as a GNU extension.
1607
1608 @item @emph{Standard}:
1609 Fortran 2008
1610
1611 @item @emph{Class}:
1612 Elemental function
1613
1614 @item @emph{Syntax}:
1615 @code{RESULT = BESSEL_J1(X)}
1616
1617 @item @emph{Arguments}:
1618 @multitable @columnfractions .15 .70
1619 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1620 @end multitable
1621
1622 @item @emph{Return value}:
1623 The return value is of type @code{REAL} and it lies in the
1624 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
1625 kind as @var{X}.
1626
1627 @item @emph{Example}:
1628 @smallexample
1629 program test_besj1
1630   real(8) :: x = 1.0_8
1631   x = bessel_j1(x)
1632 end program test_besj1
1633 @end smallexample
1634
1635 @item @emph{Specific names}:
1636 @multitable @columnfractions .20 .20 .20 .25
1637 @item Name             @tab Argument          @tab Return type       @tab Standard
1638 @item @code{DBESJ1(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1639 @end multitable
1640 @end table
1641
1642
1643
1644 @node BESSEL_JN
1645 @section @code{BESSEL_JN} --- Bessel function of the first kind
1646 @fnindex BESSEL_JN
1647 @fnindex BESJN
1648 @fnindex DBESJN
1649 @cindex Bessel function, first kind
1650
1651 @table @asis
1652 @item @emph{Description}:
1653 @code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
1654 order @var{N} of @var{X}. This function is available under the name
1655 @code{BESJN} as a GNU extension.  If @var{N} and @var{X} are arrays,
1656 their ranks and shapes shall conform.  
1657
1658 @code{BESSEL_JN(N1, N2, X)} returns an array with the Bessel functions
1659 of the first kind of the orders @var{N1} to @var{N2}.
1660
1661 @item @emph{Standard}:
1662 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
1663
1664 @item @emph{Class}:
1665 Elemental function, except for the transformational function
1666 @code{BESSEL_JN(N1, N2, X)}
1667
1668 @item @emph{Syntax}:
1669 @code{RESULT = BESSEL_JN(N, X)}
1670 @code{RESULT = BESSEL_JN(N1, N2, X)}
1671
1672 @item @emph{Arguments}:
1673 @multitable @columnfractions .15 .70
1674 @item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER}.
1675 @item @var{N1} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
1676 @item @var{N2} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
1677 @item @var{X} @tab Shall be a scalar or an array of type  @code{REAL};
1678 for @code{BESSEL_JN(N1, N2, X)} it shall be scalar.
1679 @end multitable
1680
1681 @item @emph{Return value}:
1682 The return value is a scalar of type @code{REAL}. It has the same
1683 kind as @var{X}.
1684
1685 @item @emph{Note}:
1686 The transformational function uses a recurrence algorithm which might,
1687 for some values of @var{X}, lead to different results than calls to
1688 the elemental function.
1689
1690 @item @emph{Example}:
1691 @smallexample
1692 program test_besjn
1693   real(8) :: x = 1.0_8
1694   x = bessel_jn(5,x)
1695 end program test_besjn
1696 @end smallexample
1697
1698 @item @emph{Specific names}:
1699 @multitable @columnfractions .20 .20 .20 .25
1700 @item Name                @tab Argument            @tab Return type       @tab Standard
1701 @item @code{DBESJN(N, X)} @tab @code{INTEGER N}    @tab @code{REAL(8)}    @tab GNU extension
1702 @item                     @tab @code{REAL(8) X}    @tab                   @tab
1703 @end multitable
1704 @end table
1705
1706
1707
1708 @node BESSEL_Y0
1709 @section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
1710 @fnindex BESSEL_Y0
1711 @fnindex BESY0
1712 @fnindex DBESY0
1713 @cindex Bessel function, second kind
1714
1715 @table @asis
1716 @item @emph{Description}:
1717 @code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
1718 order 0 of @var{X}. This function is available under the name
1719 @code{BESY0} as a GNU extension.
1720
1721 @item @emph{Standard}:
1722 Fortran 2008 and later
1723
1724 @item @emph{Class}:
1725 Elemental function
1726
1727 @item @emph{Syntax}:
1728 @code{RESULT = BESSEL_Y0(X)}
1729
1730 @item @emph{Arguments}:
1731 @multitable @columnfractions .15 .70
1732 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1733 @end multitable
1734
1735 @item @emph{Return value}:
1736 The return value is a scalar of type @code{REAL}. It has the same
1737 kind as @var{X}.
1738
1739 @item @emph{Example}:
1740 @smallexample
1741 program test_besy0
1742   real(8) :: x = 0.0_8
1743   x = bessel_y0(x)
1744 end program test_besy0
1745 @end smallexample
1746
1747 @item @emph{Specific names}:
1748 @multitable @columnfractions .20 .20 .20 .25
1749 @item Name            @tab Argument          @tab Return type       @tab Standard
1750 @item @code{DBESY0(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1751 @end multitable
1752 @end table
1753
1754
1755
1756 @node BESSEL_Y1
1757 @section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
1758 @fnindex BESSEL_Y1
1759 @fnindex BESY1
1760 @fnindex DBESY1
1761 @cindex Bessel function, second kind
1762
1763 @table @asis
1764 @item @emph{Description}:
1765 @code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
1766 order 1 of @var{X}. This function is available under the name
1767 @code{BESY1} as a GNU extension.
1768
1769 @item @emph{Standard}:
1770 Fortran 2008 and later
1771
1772 @item @emph{Class}:
1773 Elemental function
1774
1775 @item @emph{Syntax}:
1776 @code{RESULT = BESSEL_Y1(X)}
1777
1778 @item @emph{Arguments}:
1779 @multitable @columnfractions .15 .70
1780 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1781 @end multitable
1782
1783 @item @emph{Return value}:
1784 The return value is a scalar of type @code{REAL}. It has the same
1785 kind as @var{X}.
1786
1787 @item @emph{Example}:
1788 @smallexample
1789 program test_besy1
1790   real(8) :: x = 1.0_8
1791   x = bessel_y1(x)
1792 end program test_besy1
1793 @end smallexample
1794
1795 @item @emph{Specific names}:
1796 @multitable @columnfractions .20 .20 .20 .25
1797 @item Name            @tab Argument          @tab Return type       @tab Standard
1798 @item @code{DBESY1(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1799 @end multitable
1800 @end table
1801
1802
1803
1804 @node BESSEL_YN
1805 @section @code{BESSEL_YN} --- Bessel function of the second kind
1806 @fnindex BESSEL_YN
1807 @fnindex BESYN
1808 @fnindex DBESYN
1809 @cindex Bessel function, second kind
1810
1811 @table @asis
1812 @item @emph{Description}:
1813 @code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
1814 order @var{N} of @var{X}. This function is available under the name
1815 @code{BESYN} as a GNU extension.  If @var{N} and @var{X} are arrays,
1816 their ranks and shapes shall conform.  
1817
1818 @code{BESSEL_YN(N1, N2, X)} returns an array with the Bessel functions
1819 of the first kind of the orders @var{N1} to @var{N2}.
1820
1821 @item @emph{Standard}:
1822 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
1823
1824 @item @emph{Class}:
1825 Elemental function, except for the transformational function
1826 @code{BESSEL_YN(N1, N2, X)}
1827
1828 @item @emph{Syntax}:
1829 @code{RESULT = BESSEL_YN(N, X)}
1830 @code{RESULT = BESSEL_YN(N1, N2, X)}
1831
1832 @item @emph{Arguments}:
1833 @multitable @columnfractions .15 .70
1834 @item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER} .
1835 @item @var{N1} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
1836 @item @var{N2} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
1837 @item @var{X} @tab Shall be a scalar or an array of type  @code{REAL};
1838 for @code{BESSEL_YN(N1, N2, X)} it shall be scalar.
1839 @end multitable
1840
1841 @item @emph{Return value}:
1842 The return value is a scalar of type @code{REAL}. It has the same
1843 kind as @var{X}.
1844
1845 @item @emph{Note}:
1846 The transformational function uses a recurrence algorithm which might,
1847 for some values of @var{X}, lead to different results than calls to
1848 the elemental function.
1849
1850 @item @emph{Example}:
1851 @smallexample
1852 program test_besyn
1853   real(8) :: x = 1.0_8
1854   x = bessel_yn(5,x)
1855 end program test_besyn
1856 @end smallexample
1857
1858 @item @emph{Specific names}:
1859 @multitable @columnfractions .20 .20 .20 .25
1860 @item Name               @tab Argument            @tab Return type     @tab Standard
1861 @item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)}  @tab GNU extension
1862 @item                    @tab @code{REAL(8) X} @tab                 @tab 
1863 @end multitable
1864 @end table
1865
1866
1867
1868 @node BGE
1869 @section @code{BGE} --- Bitwise greater than or equal to
1870 @fnindex BGE
1871 @cindex bitwise comparison
1872
1873 @table @asis
1874 @item @emph{Description}:
1875 Determines whether an integral is a bitwise greater than or equal to
1876 another.
1877
1878 @item @emph{Standard}:
1879 Fortran 2008 and later
1880
1881 @item @emph{Class}:
1882 Elemental function
1883
1884 @item @emph{Syntax}:
1885 @code{RESULT = BGE(I, J)}
1886
1887 @item @emph{Arguments}:
1888 @multitable @columnfractions .15 .70
1889 @item @var{I} @tab Shall be of @code{INTEGER} type.
1890 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
1891 as @var{I}.
1892 @end multitable
1893
1894 @item @emph{Return value}:
1895 The return value is of type @code{LOGICAL} and of the default kind.
1896
1897 @item @emph{See also}:
1898 @ref{BGT}, @ref{BLE}, @ref{BLT}
1899 @end table
1900
1901
1902
1903 @node BGT
1904 @section @code{BGT} --- Bitwise greater than
1905 @fnindex BGT
1906 @cindex bitwise comparison
1907
1908 @table @asis
1909 @item @emph{Description}:
1910 Determines whether an integral is a bitwise greater than another.
1911
1912 @item @emph{Standard}:
1913 Fortran 2008 and later
1914
1915 @item @emph{Class}:
1916 Elemental function
1917
1918 @item @emph{Syntax}:
1919 @code{RESULT = BGT(I, J)}
1920
1921 @item @emph{Arguments}:
1922 @multitable @columnfractions .15 .70
1923 @item @var{I} @tab Shall be of @code{INTEGER} type.
1924 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
1925 as @var{I}.
1926 @end multitable
1927
1928 @item @emph{Return value}:
1929 The return value is of type @code{LOGICAL} and of the default kind.
1930
1931 @item @emph{See also}:
1932 @ref{BGE}, @ref{BLE}, @ref{BLT}
1933 @end table
1934
1935
1936
1937 @node BIT_SIZE
1938 @section @code{BIT_SIZE} --- Bit size inquiry function
1939 @fnindex BIT_SIZE
1940 @cindex bits, number of
1941 @cindex size of a variable, in bits
1942
1943 @table @asis
1944 @item @emph{Description}:
1945 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1946 represented by the type of @var{I}.  The result of @code{BIT_SIZE(I)} is
1947 independent of the actual value of @var{I}.
1948
1949 @item @emph{Standard}:
1950 Fortran 95 and later
1951
1952 @item @emph{Class}:
1953 Inquiry function
1954
1955 @item @emph{Syntax}:
1956 @code{RESULT = BIT_SIZE(I)}
1957
1958 @item @emph{Arguments}:
1959 @multitable @columnfractions .15 .70
1960 @item @var{I} @tab The type shall be @code{INTEGER}.
1961 @end multitable
1962
1963 @item @emph{Return value}:
1964 The return value is of type @code{INTEGER}
1965
1966 @item @emph{Example}:
1967 @smallexample
1968 program test_bit_size
1969     integer :: i = 123
1970     integer :: size
1971     size = bit_size(i)
1972     print *, size
1973 end program test_bit_size
1974 @end smallexample
1975 @end table
1976
1977
1978
1979 @node BLE
1980 @section @code{BLE} --- Bitwise less than or equal to
1981 @fnindex BLE
1982 @cindex bitwise comparison
1983
1984 @table @asis
1985 @item @emph{Description}:
1986 Determines whether an integral is a bitwise less than or equal to
1987 another.
1988
1989 @item @emph{Standard}:
1990 Fortran 2008 and later
1991
1992 @item @emph{Class}:
1993 Elemental function
1994
1995 @item @emph{Syntax}:
1996 @code{RESULT = BLE(I, J)}
1997
1998 @item @emph{Arguments}:
1999 @multitable @columnfractions .15 .70
2000 @item @var{I} @tab Shall be of @code{INTEGER} type.
2001 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2002 as @var{I}.
2003 @end multitable
2004
2005 @item @emph{Return value}:
2006 The return value is of type @code{LOGICAL} and of the default kind.
2007
2008 @item @emph{See also}:
2009 @ref{BGT}, @ref{BGE}, @ref{BLT}
2010 @end table
2011
2012
2013
2014 @node BLT
2015 @section @code{BLT} --- Bitwise less than
2016 @fnindex BLT
2017 @cindex bitwise comparison
2018
2019 @table @asis
2020 @item @emph{Description}:
2021 Determines whether an integral is a bitwise less than another.
2022
2023 @item @emph{Standard}:
2024 Fortran 2008 and later
2025
2026 @item @emph{Class}:
2027 Elemental function
2028
2029 @item @emph{Syntax}:
2030 @code{RESULT = BLT(I, J)}
2031
2032 @item @emph{Arguments}:
2033 @multitable @columnfractions .15 .70
2034 @item @var{I} @tab Shall be of @code{INTEGER} type.
2035 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2036 as @var{I}.
2037 @end multitable
2038
2039 @item @emph{Return value}:
2040 The return value is of type @code{LOGICAL} and of the default kind.
2041
2042 @item @emph{See also}:
2043 @ref{BGE}, @ref{BGT}, @ref{BLE}
2044 @end table
2045
2046
2047
2048 @node BTEST
2049 @section @code{BTEST} --- Bit test function
2050 @fnindex BTEST
2051 @cindex bits, testing
2052
2053 @table @asis
2054 @item @emph{Description}:
2055 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
2056 in @var{I} is set.  The counting of the bits starts at 0.
2057
2058 @item @emph{Standard}:
2059 Fortran 95 and later
2060
2061 @item @emph{Class}:
2062 Elemental function
2063
2064 @item @emph{Syntax}:
2065 @code{RESULT = BTEST(I, POS)}
2066
2067 @item @emph{Arguments}:
2068 @multitable @columnfractions .15 .70
2069 @item @var{I} @tab The type shall be @code{INTEGER}.
2070 @item @var{POS} @tab The type shall be @code{INTEGER}.
2071 @end multitable
2072
2073 @item @emph{Return value}:
2074 The return value is of type @code{LOGICAL}
2075
2076 @item @emph{Example}:
2077 @smallexample
2078 program test_btest
2079     integer :: i = 32768 + 1024 + 64
2080     integer :: pos
2081     logical :: bool
2082     do pos=0,16
2083         bool = btest(i, pos) 
2084         print *, pos, bool
2085     end do
2086 end program test_btest
2087 @end smallexample
2088 @end table
2089
2090
2091 @node C_ASSOCIATED
2092 @section @code{C_ASSOCIATED} --- Status of a C pointer
2093 @fnindex C_ASSOCIATED
2094 @cindex association status, C pointer
2095 @cindex pointer, C association status
2096
2097 @table @asis
2098 @item @emph{Description}:
2099 @code{C_ASSOCIATED(c_prt_1[, c_ptr_2])} determines the status of the C pointer
2100 @var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
2101
2102 @item @emph{Standard}:
2103 Fortran 2003 and later
2104
2105 @item @emph{Class}:
2106 Inquiry function
2107
2108 @item @emph{Syntax}:
2109 @code{RESULT = C_ASSOCIATED(c_prt_1[, c_ptr_2])}
2110
2111 @item @emph{Arguments}:
2112 @multitable @columnfractions .15 .70
2113 @item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
2114 @item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
2115 @end multitable
2116
2117 @item @emph{Return value}:
2118 The return value is of type @code{LOGICAL}; it is @code{.false.} if either
2119 @var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
2120 point to different addresses.
2121
2122 @item @emph{Example}:
2123 @smallexample
2124 subroutine association_test(a,b)
2125   use iso_c_binding, only: c_associated, c_loc, c_ptr
2126   implicit none
2127   real, pointer :: a
2128   type(c_ptr) :: b
2129   if(c_associated(b, c_loc(a))) &
2130      stop 'b and a do not point to same target'
2131 end subroutine association_test
2132 @end smallexample
2133
2134 @item @emph{See also}:
2135 @ref{C_LOC}, @ref{C_FUNLOC}
2136 @end table
2137
2138
2139 @node C_FUNLOC
2140 @section @code{C_FUNLOC} --- Obtain the C address of a procedure
2141 @fnindex C_FUNLOC
2142 @cindex pointer, C address of procedures
2143
2144 @table @asis
2145 @item @emph{Description}:
2146 @code{C_FUNLOC(x)} determines the C address of the argument.
2147
2148 @item @emph{Standard}:
2149 Fortran 2003 and later
2150
2151 @item @emph{Class}:
2152 Inquiry function
2153
2154 @item @emph{Syntax}:
2155 @code{RESULT = C_FUNLOC(x)}
2156
2157 @item @emph{Arguments}:
2158 @multitable @columnfractions .15 .70
2159 @item @var{x} @tab Interoperable function or pointer to such function.
2160 @end multitable
2161
2162 @item @emph{Return value}:
2163 The return value is of type @code{C_FUNPTR} and contains the C address
2164 of the argument.
2165
2166 @item @emph{Example}:
2167 @smallexample
2168 module x
2169   use iso_c_binding
2170   implicit none
2171 contains
2172   subroutine sub(a) bind(c)
2173     real(c_float) :: a
2174     a = sqrt(a)+5.0
2175   end subroutine sub
2176 end module x
2177 program main
2178   use iso_c_binding
2179   use x
2180   implicit none
2181   interface
2182     subroutine my_routine(p) bind(c,name='myC_func')
2183       import :: c_funptr
2184       type(c_funptr), intent(in) :: p
2185     end subroutine
2186   end interface
2187   call my_routine(c_funloc(sub))
2188 end program main
2189 @end smallexample
2190
2191 @item @emph{See also}:
2192 @ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2193 @end table
2194
2195
2196 @node C_F_PROCPOINTER
2197 @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
2198 @fnindex C_F_PROCPOINTER
2199 @cindex pointer, C address of pointers
2200
2201 @table @asis
2202 @item @emph{Description}:
2203 @code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
2204 @var{CPTR} to the Fortran procedure pointer @var{FPTR}.
2205
2206 @item @emph{Standard}:
2207 Fortran 2003 and later
2208
2209 @item @emph{Class}:
2210 Subroutine
2211
2212 @item @emph{Syntax}:
2213 @code{CALL C_F_PROCPOINTER(cptr, fptr)}
2214
2215 @item @emph{Arguments}:
2216 @multitable @columnfractions .15 .70
2217 @item @var{CPTR}  @tab scalar of the type @code{C_FUNPTR}. It is
2218 @code{INTENT(IN)}.
2219 @item @var{FPTR}  @tab procedure pointer interoperable with @var{cptr}. It is
2220 @code{INTENT(OUT)}.
2221 @end multitable
2222
2223 @item @emph{Example}:
2224 @smallexample
2225 program main
2226   use iso_c_binding
2227   implicit none
2228   abstract interface
2229     function func(a)
2230       import :: c_float
2231       real(c_float), intent(in) :: a
2232       real(c_float) :: func
2233     end function
2234   end interface
2235   interface
2236      function getIterFunc() bind(c,name="getIterFunc")
2237        import :: c_funptr
2238        type(c_funptr) :: getIterFunc
2239      end function
2240   end interface
2241   type(c_funptr) :: cfunptr
2242   procedure(func), pointer :: myFunc
2243   cfunptr = getIterFunc()
2244   call c_f_procpointer(cfunptr, myFunc)
2245 end program main
2246 @end smallexample
2247
2248 @item @emph{See also}:
2249 @ref{C_LOC}, @ref{C_F_POINTER}
2250 @end table
2251
2252
2253 @node C_F_POINTER
2254 @section @code{C_F_POINTER} --- Convert C into Fortran pointer
2255 @fnindex C_F_POINTER
2256 @cindex pointer, convert C to Fortran
2257
2258 @table @asis
2259 @item @emph{Description}:
2260 @code{C_F_POINTER(CPTR, FPTR[, SHAPE])} Assign the target the C pointer
2261 @var{CPTR} to the Fortran pointer @var{FPTR} and specify its
2262 shape.
2263
2264 @item @emph{Standard}:
2265 Fortran 2003 and later
2266
2267 @item @emph{Class}:
2268 Subroutine
2269
2270 @item @emph{Syntax}:
2271 @code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
2272
2273 @item @emph{Arguments}:
2274 @multitable @columnfractions .15 .70
2275 @item @var{CPTR}  @tab scalar of the type @code{C_PTR}. It is
2276 @code{INTENT(IN)}.
2277 @item @var{FPTR}  @tab pointer interoperable with @var{cptr}. It is
2278 @code{INTENT(OUT)}.
2279 @item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
2280 with @code{INTENT(IN)}. It shall be present
2281 if and only if @var{fptr} is an array. The size
2282 must be equal to the rank of @var{fptr}.
2283 @end multitable
2284
2285 @item @emph{Example}:
2286 @smallexample
2287 program main
2288   use iso_c_binding
2289   implicit none
2290   interface
2291     subroutine my_routine(p) bind(c,name='myC_func')
2292       import :: c_ptr
2293       type(c_ptr), intent(out) :: p
2294     end subroutine
2295   end interface
2296   type(c_ptr) :: cptr
2297   real,pointer :: a(:)
2298   call my_routine(cptr)
2299   call c_f_pointer(cptr, a, [12])
2300 end program main
2301 @end smallexample
2302
2303 @item @emph{See also}:
2304 @ref{C_LOC}, @ref{C_F_PROCPOINTER}
2305 @end table
2306
2307
2308 @node C_LOC
2309 @section @code{C_LOC} --- Obtain the C address of an object
2310 @fnindex C_LOC
2311 @cindex procedure pointer, convert C to Fortran
2312
2313 @table @asis
2314 @item @emph{Description}:
2315 @code{C_LOC(X)} determines the C address of the argument.
2316
2317 @item @emph{Standard}:
2318 Fortran 2003 and later
2319
2320 @item @emph{Class}:
2321 Inquiry function
2322
2323 @item @emph{Syntax}:
2324 @code{RESULT = C_LOC(X)}
2325
2326 @item @emph{Arguments}:
2327 @multitable @columnfractions .10 .75
2328 @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.
2329
2330 @end multitable
2331
2332 @item @emph{Return value}:
2333 The return value is of type @code{C_PTR} and contains the C address
2334 of the argument.
2335
2336 @item @emph{Example}:
2337 @smallexample
2338 subroutine association_test(a,b)
2339   use iso_c_binding, only: c_associated, c_loc, c_ptr
2340   implicit none
2341   real, pointer :: a
2342   type(c_ptr) :: b
2343   if(c_associated(b, c_loc(a))) &
2344      stop 'b and a do not point to same target'
2345 end subroutine association_test
2346 @end smallexample
2347
2348 @item @emph{See also}:
2349 @ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2350 @end table
2351
2352
2353 @node C_SIZEOF
2354 @section @code{C_SIZEOF} --- Size in bytes of an expression
2355 @fnindex C_SIZEOF
2356 @cindex expression size
2357 @cindex size of an expression
2358
2359 @table @asis
2360 @item @emph{Description}:
2361 @code{C_SIZEOF(X)} calculates the number of bytes of storage the
2362 expression @code{X} occupies.
2363
2364 @item @emph{Standard}:
2365 Fortran 2008
2366
2367 @item @emph{Class}:
2368 Inquiry function of the module @code{ISO_C_BINDING}
2369
2370 @item @emph{Syntax}:
2371 @code{N = C_SIZEOF(X)}
2372
2373 @item @emph{Arguments}:
2374 @multitable @columnfractions .15 .70
2375 @item @var{X} @tab The argument shall be an interoperable data entity.
2376 @end multitable
2377
2378 @item @emph{Return value}:
2379 The return value is of type integer and of the system-dependent kind
2380 @code{C_SIZE_T} (from the @code{ISO_C_BINDING} module). Its value is the
2381 number of bytes occupied by the argument.  If the argument has the
2382 @code{POINTER} attribute, the number of bytes of the storage area pointed
2383 to is returned.  If the argument is of a derived type with @code{POINTER}
2384 or @code{ALLOCATABLE} components, the return value doesn't account for
2385 the sizes of the data pointed to by these components.
2386
2387 @item @emph{Example}:
2388 @smallexample
2389    use iso_c_binding
2390    integer(c_int) :: i
2391    real(c_float) :: r, s(5)
2392    print *, (c_sizeof(s)/c_sizeof(r) == 5)
2393    end
2394 @end smallexample
2395 The example will print @code{.TRUE.} unless you are using a platform
2396 where default @code{REAL} variables are unusually padded.
2397
2398 @item @emph{See also}:
2399 @ref{SIZEOF}, @ref{STORAGE_SIZE}
2400 @end table
2401
2402
2403 @node CEILING
2404 @section @code{CEILING} --- Integer ceiling function
2405 @fnindex CEILING
2406 @cindex ceiling
2407 @cindex rounding, ceiling
2408
2409 @table @asis
2410 @item @emph{Description}:
2411 @code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
2412
2413 @item @emph{Standard}:
2414 Fortran 95 and later
2415
2416 @item @emph{Class}:
2417 Elemental function
2418
2419 @item @emph{Syntax}:
2420 @code{RESULT = CEILING(A [, KIND])}
2421
2422 @item @emph{Arguments}:
2423 @multitable @columnfractions .15 .70
2424 @item @var{A} @tab The type shall be @code{REAL}.
2425 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2426 expression indicating the kind parameter of the result.
2427 @end multitable
2428
2429 @item @emph{Return value}:
2430 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
2431 and a default-kind @code{INTEGER} otherwise.
2432
2433 @item @emph{Example}:
2434 @smallexample
2435 program test_ceiling
2436     real :: x = 63.29
2437     real :: y = -63.59
2438     print *, ceiling(x) ! returns 64
2439     print *, ceiling(y) ! returns -63
2440 end program test_ceiling
2441 @end smallexample
2442
2443 @item @emph{See also}:
2444 @ref{FLOOR}, @ref{NINT}
2445
2446 @end table
2447
2448
2449
2450 @node CHAR
2451 @section @code{CHAR} --- Character conversion function
2452 @fnindex CHAR
2453 @cindex conversion, to character
2454
2455 @table @asis
2456 @item @emph{Description}:
2457 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
2458
2459 @item @emph{Standard}:
2460 Fortran 77 and later
2461
2462 @item @emph{Class}:
2463 Elemental function
2464
2465 @item @emph{Syntax}:
2466 @code{RESULT = CHAR(I [, KIND])}
2467
2468 @item @emph{Arguments}:
2469 @multitable @columnfractions .15 .70
2470 @item @var{I} @tab The type shall be @code{INTEGER}.
2471 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2472 expression indicating the kind parameter of the result.
2473 @end multitable
2474
2475 @item @emph{Return value}:
2476 The return value is of type @code{CHARACTER(1)}
2477
2478 @item @emph{Example}:
2479 @smallexample
2480 program test_char
2481     integer :: i = 74
2482     character(1) :: c
2483     c = char(i)
2484     print *, i, c ! returns 'J'
2485 end program test_char
2486 @end smallexample
2487
2488 @item @emph{Specific names}:
2489 @multitable @columnfractions .20 .20 .20 .25
2490 @item Name           @tab Argument         @tab Return type             @tab Standard
2491 @item @code{CHAR(I)} @tab @code{INTEGER I} @tab @code{CHARACTER(LEN=1)} @tab F77 and later
2492 @end multitable
2493
2494 @item @emph{Note}:
2495 See @ref{ICHAR} for a discussion of converting between numerical values
2496 and formatted string representations.
2497
2498 @item @emph{See also}:
2499 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
2500
2501 @end table
2502
2503
2504
2505 @node CHDIR
2506 @section @code{CHDIR} --- Change working directory
2507 @fnindex CHDIR
2508 @cindex system, working directory
2509
2510 @table @asis
2511 @item @emph{Description}:
2512 Change current working directory to a specified path.
2513
2514 This intrinsic is provided in both subroutine and function forms; however,
2515 only one form can be used in any given program unit.
2516
2517 @item @emph{Standard}:
2518 GNU extension
2519
2520 @item @emph{Class}:
2521 Subroutine, function
2522
2523 @item @emph{Syntax}:
2524 @multitable @columnfractions .80
2525 @item @code{CALL CHDIR(NAME [, STATUS])}
2526 @item @code{STATUS = CHDIR(NAME)}
2527 @end multitable
2528
2529 @item @emph{Arguments}:
2530 @multitable @columnfractions .15 .70
2531 @item @var{NAME}   @tab The type shall be @code{CHARACTER} of default
2532 kind and shall specify a valid path within the file system.
2533 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
2534 kind.  Returns 0 on success, and a system specific and nonzero error code
2535 otherwise.
2536 @end multitable
2537
2538 @item @emph{Example}:
2539 @smallexample
2540 PROGRAM test_chdir
2541   CHARACTER(len=255) :: path
2542   CALL getcwd(path)
2543   WRITE(*,*) TRIM(path)
2544   CALL chdir("/tmp")
2545   CALL getcwd(path)
2546   WRITE(*,*) TRIM(path)
2547 END PROGRAM
2548 @end smallexample
2549
2550 @item @emph{See also}:
2551 @ref{GETCWD}
2552 @end table
2553
2554
2555
2556 @node CHMOD
2557 @section @code{CHMOD} --- Change access permissions of files
2558 @fnindex CHMOD
2559 @cindex file system, change access mode
2560
2561 @table @asis
2562 @item @emph{Description}:
2563 @code{CHMOD} changes the permissions of a file. This function invokes
2564 @code{/bin/chmod} and might therefore not work on all platforms.
2565
2566 This intrinsic is provided in both subroutine and function forms; however,
2567 only one form can be used in any given program unit.
2568
2569 @item @emph{Standard}:
2570 GNU extension
2571
2572 @item @emph{Class}:
2573 Subroutine, function
2574
2575 @item @emph{Syntax}:
2576 @multitable @columnfractions .80
2577 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
2578 @item @code{STATUS = CHMOD(NAME, MODE)}
2579 @end multitable
2580
2581 @item @emph{Arguments}:
2582 @multitable @columnfractions .15 .70
2583
2584 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
2585 file name. Trailing blanks are ignored unless the character
2586 @code{achar(0)} is present, then all characters up to and excluding
2587 @code{achar(0)} are used as the file name.
2588
2589 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
2590 file permission. @var{MODE} uses the same syntax as the @var{MODE}
2591 argument of @code{/bin/chmod}.
2592
2593 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
2594 @code{0} on success and nonzero otherwise.
2595 @end multitable
2596
2597 @item @emph{Return value}:
2598 In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
2599 otherwise.
2600
2601 @item @emph{Example}:
2602 @code{CHMOD} as subroutine
2603 @smallexample
2604 program chmod_test
2605   implicit none
2606   integer :: status
2607   call chmod('test.dat','u+x',status)
2608   print *, 'Status: ', status
2609 end program chmod_test
2610 @end smallexample
2611 @code{CHMOD} as function:
2612 @smallexample
2613 program chmod_test
2614   implicit none
2615   integer :: status
2616   status = chmod('test.dat','u+x')
2617   print *, 'Status: ', status
2618 end program chmod_test
2619 @end smallexample
2620
2621 @end table
2622
2623
2624
2625 @node CMPLX
2626 @section @code{CMPLX} --- Complex conversion function
2627 @fnindex CMPLX
2628 @cindex complex numbers, conversion to
2629 @cindex conversion, to complex
2630
2631 @table @asis
2632 @item @emph{Description}:
2633 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
2634 the real component.  If @var{Y} is present it is converted to the imaginary
2635 component.  If @var{Y} is not present then the imaginary component is set to
2636 0.0.  If @var{X} is complex then @var{Y} must not be present.
2637
2638 @item @emph{Standard}:
2639 Fortran 77 and later
2640
2641 @item @emph{Class}:
2642 Elemental function
2643
2644 @item @emph{Syntax}:
2645 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2646
2647 @item @emph{Arguments}:
2648 @multitable @columnfractions .15 .70
2649 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
2650 or @code{COMPLEX}.
2651 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2652 @code{COMPLEX}.)  May be @code{INTEGER} or @code{REAL}.
2653 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2654 expression indicating the kind parameter of the result.
2655 @end multitable
2656
2657 @item @emph{Return value}:
2658 The return value is of @code{COMPLEX} type, with a kind equal to
2659 @var{KIND} if it is specified.  If @var{KIND} is not specified, the
2660 result is of the default @code{COMPLEX} kind, regardless of the kinds of
2661 @var{X} and @var{Y}. 
2662
2663 @item @emph{Example}:
2664 @smallexample
2665 program test_cmplx
2666     integer :: i = 42
2667     real :: x = 3.14
2668     complex :: z
2669     z = cmplx(i, x)
2670     print *, z, cmplx(x)
2671 end program test_cmplx
2672 @end smallexample
2673
2674 @item @emph{See also}:
2675 @ref{COMPLEX}
2676 @end table
2677
2678
2679
2680 @node COMMAND_ARGUMENT_COUNT
2681 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2682 @fnindex COMMAND_ARGUMENT_COUNT
2683 @cindex command-line arguments
2684 @cindex command-line arguments, number of
2685 @cindex arguments, to program
2686
2687 @table @asis
2688 @item @emph{Description}:
2689 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2690 command line when the containing program was invoked.
2691
2692 @item @emph{Standard}:
2693 Fortran 2003 and later
2694
2695 @item @emph{Class}:
2696 Inquiry function
2697
2698 @item @emph{Syntax}:
2699 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2700
2701 @item @emph{Arguments}:
2702 @multitable @columnfractions .15 .70
2703 @item None
2704 @end multitable
2705
2706 @item @emph{Return value}:
2707 The return value is an @code{INTEGER} of default kind.
2708
2709 @item @emph{Example}:
2710 @smallexample
2711 program test_command_argument_count
2712     integer :: count
2713     count = command_argument_count()
2714     print *, count
2715 end program test_command_argument_count
2716 @end smallexample
2717
2718 @item @emph{See also}:
2719 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2720 @end table
2721
2722
2723
2724 @node COMPILER_OPTIONS
2725 @section @code{COMPILER_OPTIONS} --- Options passed to the compiler
2726 @fnindex COMPILER_OPTIONS
2727 @cindex flags inquiry function
2728 @cindex options inquiry function
2729 @cindex compiler flags inquiry function
2730
2731 @table @asis
2732 @item @emph{Description}:
2733 @code{COMPILER_OPTIONS()} returns a string with the options used for
2734 compiling.
2735
2736 @item @emph{Standard}:
2737 Fortran 2008
2738
2739 @item @emph{Class}:
2740 Inquiry function of the module @code{ISO_FORTRAN_ENV}
2741
2742 @item @emph{Syntax}:
2743 @code{STR = COMPILER_OPTIONS()}
2744
2745 @item @emph{Arguments}:
2746 None.
2747
2748 @item @emph{Return value}:
2749 The return value is a default-kind string with system-dependent length.
2750 It contains the compiler flags used to compile the file, which called
2751 the @code{COMPILER_OPTIONS} intrinsic.
2752
2753 @item @emph{Example}:
2754 @smallexample
2755    use iso_fortran_env
2756    print '(4a)', 'This file was compiled by ', &
2757                  compiler_version(), ' using the the options ', &
2758                  compiler_options()
2759    end
2760 @end smallexample
2761
2762 @item @emph{See also}:
2763 @ref{COMPILER_VERSION}, @ref{ISO_FORTRAN_ENV}
2764 @end table
2765
2766
2767
2768 @node COMPILER_VERSION
2769 @section @code{COMPILER_VERSION} --- Compiler version string
2770 @fnindex COMPILER_VERSION
2771 @cindex compiler, name and version
2772 @cindex version of the compiler
2773
2774 @table @asis
2775 @item @emph{Description}:
2776 @code{COMPILER_VERSION()} returns a string with the name and the
2777 version of the compiler.
2778
2779 @item @emph{Standard}:
2780 Fortran 2008
2781
2782 @item @emph{Class}:
2783 Inquiry function of the module @code{ISO_FORTRAN_ENV}
2784
2785 @item @emph{Syntax}:
2786 @code{STR = COMPILER_VERSION()}
2787
2788 @item @emph{Arguments}:
2789 None.
2790
2791 @item @emph{Return value}:
2792 The return value is a default-kind string with system-dependent length.
2793 It contains the name of the compiler and its version number.
2794
2795 @item @emph{Example}:
2796 @smallexample
2797    use iso_fortran_env
2798    print '(4a)', 'This file was compiled by ', &
2799                  compiler_version(), ' using the the options ', &
2800                  compiler_options()
2801    end
2802 @end smallexample
2803
2804 @item @emph{See also}:
2805 @ref{COMPILER_OPTIONS}, @ref{ISO_FORTRAN_ENV}
2806 @end table
2807
2808
2809
2810 @node COMPLEX
2811 @section @code{COMPLEX} --- Complex conversion function
2812 @fnindex COMPLEX
2813 @cindex complex numbers, conversion to
2814 @cindex conversion, to complex
2815
2816 @table @asis
2817 @item @emph{Description}:
2818 @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
2819 to the real component and @var{Y} is converted to the imaginary
2820 component.
2821
2822 @item @emph{Standard}:
2823 GNU extension
2824
2825 @item @emph{Class}:
2826 Elemental function
2827
2828 @item @emph{Syntax}:
2829 @code{RESULT = COMPLEX(X, Y)}
2830
2831 @item @emph{Arguments}:
2832 @multitable @columnfractions .15 .70
2833 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
2834 @item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
2835 @end multitable
2836
2837 @item @emph{Return value}:
2838 If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
2839 value is of default @code{COMPLEX} type.
2840
2841 If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
2842 type and one is of @code{INTEGER} type, then the return value is of
2843 @code{COMPLEX} type with a kind equal to that of the @code{REAL}
2844 argument with the highest precision.  
2845
2846 @item @emph{Example}:
2847 @smallexample
2848 program test_complex
2849     integer :: i = 42
2850     real :: x = 3.14
2851     print *, complex(i, x)
2852 end program test_complex
2853 @end smallexample
2854
2855 @item @emph{See also}:
2856 @ref{CMPLX}
2857 @end table
2858
2859
2860
2861 @node CONJG
2862 @section @code{CONJG} --- Complex conjugate function 
2863 @fnindex CONJG
2864 @fnindex DCONJG
2865 @cindex complex conjugate
2866
2867 @table @asis
2868 @item @emph{Description}:
2869 @code{CONJG(Z)} returns the conjugate of @var{Z}.  If @var{Z} is @code{(x, y)}
2870 then the result is @code{(x, -y)}
2871
2872 @item @emph{Standard}:
2873 Fortran 77 and later, has overloads that are GNU extensions
2874
2875 @item @emph{Class}:
2876 Elemental function
2877
2878 @item @emph{Syntax}:
2879 @code{Z = CONJG(Z)}
2880
2881 @item @emph{Arguments}:
2882 @multitable @columnfractions .15 .70
2883 @item @var{Z} @tab The type shall be @code{COMPLEX}.
2884 @end multitable
2885
2886 @item @emph{Return value}:
2887 The return value is of type @code{COMPLEX}.
2888
2889 @item @emph{Example}:
2890 @smallexample
2891 program test_conjg
2892     complex :: z = (2.0, 3.0)
2893     complex(8) :: dz = (2.71_8, -3.14_8)
2894     z= conjg(z)
2895     print *, z
2896     dz = dconjg(dz)
2897     print *, dz
2898 end program test_conjg
2899 @end smallexample
2900
2901 @item @emph{Specific names}:
2902 @multitable @columnfractions .20 .20 .20 .25
2903 @item Name             @tab Argument             @tab Return type       @tab Standard
2904 @item @code{CONJG(Z)}  @tab @code{COMPLEX Z}     @tab @code{COMPLEX}    @tab GNU extension
2905 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z}  @tab @code{COMPLEX(8)} @tab GNU extension
2906 @end multitable
2907 @end table
2908
2909
2910
2911 @node COS
2912 @section @code{COS} --- Cosine function 
2913 @fnindex COS
2914 @fnindex DCOS
2915 @fnindex CCOS
2916 @fnindex ZCOS
2917 @fnindex CDCOS
2918 @cindex trigonometric function, cosine
2919 @cindex cosine
2920
2921 @table @asis
2922 @item @emph{Description}:
2923 @code{COS(X)} computes the cosine of @var{X}.
2924
2925 @item @emph{Standard}:
2926 Fortran 77 and later, has overloads that are GNU extensions
2927
2928 @item @emph{Class}:
2929 Elemental function
2930
2931 @item @emph{Syntax}:
2932 @code{RESULT = COS(X)}
2933
2934 @item @emph{Arguments}:
2935 @multitable @columnfractions .15 .70
2936 @item @var{X} @tab The type shall be @code{REAL} or
2937 @code{COMPLEX}.
2938 @end multitable
2939
2940 @item @emph{Return value}:
2941 The return value is of the same type and kind as @var{X}. The real part
2942 of the result is in radians. If @var{X} is of the type @code{REAL},
2943 the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}.
2944
2945 @item @emph{Example}:
2946 @smallexample
2947 program test_cos
2948   real :: x = 0.0
2949   x = cos(x)
2950 end program test_cos
2951 @end smallexample
2952
2953 @item @emph{Specific names}:
2954 @multitable @columnfractions .20 .20 .20 .25
2955 @item Name            @tab Argument            @tab Return type       @tab Standard
2956 @item @code{COS(X)}   @tab @code{REAL(4) X}    @tab @code{REAL(4)}    @tab Fortran 77 and later
2957 @item @code{DCOS(X)}  @tab @code{REAL(8) X}    @tab @code{REAL(8)}    @tab Fortran 77 and later
2958 @item @code{CCOS(X)}  @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
2959 @item @code{ZCOS(X)}  @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2960 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2961 @end multitable
2962
2963 @item @emph{See also}:
2964 Inverse function: @ref{ACOS}
2965
2966 @end table
2967
2968
2969
2970 @node COSH
2971 @section @code{COSH} --- Hyperbolic cosine function 
2972 @fnindex COSH
2973 @fnindex DCOSH
2974 @cindex hyperbolic cosine
2975 @cindex hyperbolic function, cosine
2976 @cindex cosine, hyperbolic
2977
2978 @table @asis
2979 @item @emph{Description}:
2980 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2981
2982 @item @emph{Standard}:
2983 Fortran 77 and later, for a complex argument Fortran 2008 or later
2984
2985 @item @emph{Class}:
2986 Elemental function
2987
2988 @item @emph{Syntax}:
2989 @code{X = COSH(X)}
2990
2991 @item @emph{Arguments}:
2992 @multitable @columnfractions .15 .70
2993 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
2994 @end multitable
2995
2996 @item @emph{Return value}:
2997 The return value has same type and kind as @var{X}. If @var{X} is
2998 complex, the imaginary part of the result is in radians. If @var{X}
2999 is @code{REAL}, the return value has a lower bound of one,
3000 @math{\cosh (x) \geq 1}.
3001
3002 @item @emph{Example}:
3003 @smallexample
3004 program test_cosh
3005   real(8) :: x = 1.0_8
3006   x = cosh(x)
3007 end program test_cosh
3008 @end smallexample
3009
3010 @item @emph{Specific names}:
3011 @multitable @columnfractions .20 .20 .20 .25
3012 @item Name            @tab Argument          @tab Return type       @tab Standard
3013 @item @code{COSH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
3014 @item @code{DCOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
3015 @end multitable
3016
3017 @item @emph{See also}:
3018 Inverse function: @ref{ACOSH}
3019
3020 @end table
3021
3022
3023
3024 @node COUNT
3025 @section @code{COUNT} --- Count function
3026 @fnindex COUNT
3027 @cindex array, conditionally count elements
3028 @cindex array, element counting
3029 @cindex array, number of elements
3030
3031 @table @asis
3032 @item @emph{Description}:
3033
3034 Counts the number of @code{.TRUE.} elements in a logical @var{MASK},
3035 or, if the @var{DIM} argument is supplied, counts the number of
3036 elements along each row of the array in the @var{DIM} direction.
3037 If the array has zero size, or all of the elements of @var{MASK} are
3038 @code{.FALSE.}, then the result is @code{0}.
3039
3040 @item @emph{Standard}:
3041 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
3042
3043 @item @emph{Class}:
3044 Transformational function
3045
3046 @item @emph{Syntax}:
3047 @code{RESULT = COUNT(MASK [, DIM, KIND])}
3048
3049 @item @emph{Arguments}:
3050 @multitable @columnfractions .15 .70
3051 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
3052 @item @var{DIM}  @tab (Optional) The type shall be @code{INTEGER}.
3053 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3054 expression indicating the kind parameter of the result.
3055 @end multitable
3056
3057 @item @emph{Return value}:
3058 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
3059 @var{KIND} is absent, the return value is of default integer kind.
3060 If @var{DIM} is present, the result is an array with a rank one less
3061 than the rank of @var{ARRAY}, and a size corresponding to the shape
3062 of @var{ARRAY} with the @var{DIM} dimension removed.
3063
3064 @item @emph{Example}:
3065 @smallexample
3066 program test_count
3067     integer, dimension(2,3) :: a, b
3068     logical, dimension(2,3) :: mask
3069     a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
3070     b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
3071     print '(3i3)', a(1,:)
3072     print '(3i3)', a(2,:)
3073     print *
3074     print '(3i3)', b(1,:)
3075     print '(3i3)', b(2,:)
3076     print *
3077     mask = a.ne.b
3078     print '(3l3)', mask(1,:)
3079     print '(3l3)', mask(2,:)
3080     print *
3081     print '(3i3)', count(mask)
3082     print *
3083     print '(3i3)', count(mask, 1)
3084     print *
3085     print '(3i3)', count(mask, 2)
3086 end program test_count
3087 @end smallexample
3088 @end table
3089
3090
3091
3092 @node CPU_TIME
3093 @section @code{CPU_TIME} --- CPU elapsed time in seconds
3094 @fnindex CPU_TIME
3095 @cindex time, elapsed
3096
3097 @table @asis
3098 @item @emph{Description}:
3099 Returns a @code{REAL} value representing the elapsed CPU time in
3100 seconds.  This is useful for testing segments of code to determine
3101 execution time.
3102
3103 If a time source is available, time will be reported with microsecond
3104 resolution. If no time source is available, @var{TIME} is set to
3105 @code{-1.0}.
3106
3107 Note that @var{TIME} may contain a, system dependent, arbitrary offset
3108 and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
3109 value is meaningless, only differences between subsequent calls to
3110 this subroutine, as shown in the example below, should be used.
3111
3112
3113 @item @emph{Standard}:
3114 Fortran 95 and later
3115
3116 @item @emph{Class}:
3117 Subroutine
3118
3119 @item @emph{Syntax}:
3120 @code{CALL CPU_TIME(TIME)}
3121
3122 @item @emph{Arguments}:
3123 @multitable @columnfractions .15 .70
3124 @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
3125 @end multitable
3126
3127 @item @emph{Return value}:
3128 None
3129
3130 @item @emph{Example}:
3131 @smallexample
3132 program test_cpu_time
3133     real :: start, finish
3134     call cpu_time(start)
3135         ! put code to test here
3136     call cpu_time(finish)
3137     print '("Time = ",f6.3," seconds.")',finish-start
3138 end program test_cpu_time
3139 @end smallexample
3140
3141 @item @emph{See also}:
3142 @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
3143 @end table
3144
3145
3146
3147 @node CSHIFT
3148 @section @code{CSHIFT} --- Circular shift elements of an array
3149 @fnindex CSHIFT
3150 @cindex array, shift circularly
3151 @cindex array, permutation
3152 @cindex array, rotate
3153
3154 @table @asis
3155 @item @emph{Description}:
3156 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
3157 @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is omitted it is
3158 taken to be @code{1}.  @var{DIM} is a scalar of type @code{INTEGER} in the
3159 range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}.
3160 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
3161 by @var{SHIFT} places.  If rank is greater than one, then all complete rank one
3162 sections of @var{ARRAY} along the given dimension are shifted.  Elements
3163 shifted out one end of each rank one section are shifted back in the other end.
3164
3165 @item @emph{Standard}:
3166 Fortran 95 and later
3167
3168 @item @emph{Class}:
3169 Transformational function
3170
3171 @item @emph{Syntax}:
3172 @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
3173
3174 @item @emph{Arguments}:
3175 @multitable @columnfractions .15 .70
3176 @item @var{ARRAY}  @tab Shall be an array of any type.
3177 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
3178 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
3179 @end multitable
3180
3181 @item @emph{Return value}:
3182 Returns an array of same type and rank as the @var{ARRAY} argument.
3183
3184 @item @emph{Example}:
3185 @smallexample
3186 program test_cshift
3187     integer, dimension(3,3) :: a
3188     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3189     print '(3i3)', a(1,:)
3190     print '(3i3)', a(2,:)
3191     print '(3i3)', a(3,:)    
3192     a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
3193     print *
3194     print '(3i3)', a(1,:)
3195     print '(3i3)', a(2,:)
3196     print '(3i3)', a(3,:)
3197 end program test_cshift
3198 @end smallexample
3199 @end table
3200
3201
3202
3203 @node CTIME
3204 @section @code{CTIME} --- Convert a time into a string
3205 @fnindex CTIME
3206 @cindex time, conversion to string
3207 @cindex conversion, to string
3208
3209 @table @asis
3210 @item @emph{Description}:
3211 @code{CTIME} converts a system time value, such as returned by
3212 @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14 1995}.
3213
3214 This intrinsic is provided in both subroutine and function forms; however,
3215 only one form can be used in any given program unit.
3216
3217 @item @emph{Standard}:
3218 GNU extension
3219
3220 @item @emph{Class}:
3221 Subroutine, function
3222
3223 @item @emph{Syntax}:
3224 @multitable @columnfractions .80
3225 @item @code{CALL CTIME(TIME, RESULT)}.
3226 @item @code{RESULT = CTIME(TIME)}, (not recommended).
3227 @end multitable
3228
3229 @item @emph{Arguments}:
3230 @multitable @columnfractions .15 .70
3231 @item @var{TIME}    @tab The type shall be of type @code{INTEGER(KIND=8)}.
3232 @item @var{RESULT}  @tab The type shall be of type @code{CHARACTER} and
3233 of default kind.
3234 @end multitable
3235
3236 @item @emph{Return value}:
3237 The converted date and time as a string.
3238
3239 @item @emph{Example}:
3240 @smallexample
3241 program test_ctime
3242     integer(8) :: i
3243     character(len=30) :: date
3244     i = time8()
3245
3246     ! Do something, main part of the program
3247     
3248     call ctime(i,date)
3249     print *, 'Program was started on ', date
3250 end program test_ctime
3251 @end smallexample
3252
3253 @item @emph{See Also}:
3254 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
3255 @end table
3256
3257
3258
3259 @node DATE_AND_TIME
3260 @section @code{DATE_AND_TIME} --- Date and time subroutine
3261 @fnindex DATE_AND_TIME
3262 @cindex date, current
3263 @cindex current date
3264 @cindex time, current
3265 @cindex current time
3266
3267 @table @asis
3268 @item @emph{Description}:
3269 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
3270 time information from the real-time system clock.  @var{DATE} is
3271 @code{INTENT(OUT)} and has form ccyymmdd.  @var{TIME} is @code{INTENT(OUT)} and
3272 has form hhmmss.sss.  @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
3273 representing the difference with respect to Coordinated Universal Time (UTC).
3274 Unavailable time and date parameters return blanks.
3275
3276 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
3277
3278 @multitable @columnfractions .15 .30 .40
3279 @item @tab @code{VALUE(1)}: @tab The year
3280 @item @tab @code{VALUE(2)}: @tab The month
3281 @item @tab @code{VALUE(3)}: @tab The day of the month
3282 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
3283 @item @tab @code{VALUE(5)}: @tab The hour of the day
3284 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
3285 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
3286 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
3287 @end multitable
3288
3289 @item @emph{Standard}:
3290 Fortran 95 and later
3291
3292 @item @emph{Class}:
3293 Subroutine
3294
3295 @item @emph{Syntax}:
3296 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
3297
3298 @item @emph{Arguments}:
3299 @multitable @columnfractions .15 .70
3300 @item @var{DATE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
3301 or larger, and of default kind.
3302 @item @var{TIME}  @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
3303 or larger, and of default kind.
3304 @item @var{ZONE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
3305 or larger, and of default kind.
3306 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
3307 @end multitable
3308
3309 @item @emph{Return value}:
3310 None
3311
3312 @item @emph{Example}:
3313 @smallexample
3314 program test_time_and_date
3315     character(8)  :: date
3316     character(10) :: time
3317     character(5)  :: zone
3318     integer,dimension(8) :: values
3319     ! using keyword arguments
3320     call date_and_time(date,time,zone,values)
3321     call date_and_time(DATE=date,ZONE=zone)
3322     call date_and_time(TIME=time)
3323     call date_and_time(VALUES=values)
3324     print '(a,2x,a,2x,a)', date, time, zone
3325     print '(8i5))', values
3326 end program test_time_and_date
3327 @end smallexample
3328
3329 @item @emph{See also}:
3330 @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
3331 @end table
3332
3333
3334
3335 @node DBLE
3336 @section @code{DBLE} --- Double conversion function 
3337 @fnindex DBLE
3338 @cindex conversion, to real
3339
3340 @table @asis
3341 @item @emph{Description}:
3342 @code{DBLE(A)} Converts @var{A} to double precision real type.
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 = DBLE(A)}
3352
3353 @item @emph{Arguments}:
3354 @multitable @columnfractions .15 .70
3355 @item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
3356 or @code{COMPLEX}.
3357 @end multitable
3358
3359 @item @emph{Return value}:
3360 The return value is of type double precision real.
3361
3362 @item @emph{Example}:
3363 @smallexample
3364 program test_dble
3365     real    :: x = 2.18
3366     integer :: i = 5
3367     complex :: z = (2.3,1.14)
3368     print *, dble(x), dble(i), dble(z)
3369 end program test_dble
3370 @end smallexample
3371
3372 @item @emph{See also}:
3373 @ref{REAL}
3374 @end table
3375
3376
3377
3378 @node DCMPLX
3379 @section @code{DCMPLX} --- Double complex conversion function
3380 @fnindex DCMPLX
3381 @cindex complex numbers, conversion to
3382 @cindex conversion, to complex
3383
3384 @table @asis
3385 @item @emph{Description}:
3386 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
3387 converted to the real component.  If @var{Y} is present it is converted to the
3388 imaginary component.  If @var{Y} is not present then the imaginary component is
3389 set to 0.0.  If @var{X} is complex then @var{Y} must not be present.
3390
3391 @item @emph{Standard}:
3392 GNU extension
3393
3394 @item @emph{Class}:
3395 Elemental function
3396
3397 @item @emph{Syntax}:
3398 @code{RESULT = DCMPLX(X [, Y])}
3399
3400 @item @emph{Arguments}:
3401 @multitable @columnfractions .15 .70
3402 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
3403 or @code{COMPLEX}.
3404 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
3405 @code{INTEGER} or @code{REAL}. 
3406 @end multitable
3407
3408 @item @emph{Return value}:
3409 The return value is of type @code{COMPLEX(8)}
3410
3411 @item @emph{Example}:
3412 @smallexample
3413 program test_dcmplx
3414     integer :: i = 42
3415     real :: x = 3.14
3416     complex :: z
3417     z = cmplx(i, x)
3418     print *, dcmplx(i)
3419     print *, dcmplx(x)
3420     print *, dcmplx(z)
3421     print *, dcmplx(x,i)
3422 end program test_dcmplx
3423 @end smallexample
3424 @end table
3425
3426
3427 @node DIGITS
3428 @section @code{DIGITS} --- Significant binary digits function
3429 @fnindex DIGITS
3430 @cindex model representation, significant digits
3431
3432 @table @asis
3433 @item @emph{Description}:
3434 @code{DIGITS(X)} returns the number of significant binary digits of the internal
3435 model representation of @var{X}.  For example, on a system using a 32-bit
3436 floating point representation, a default real number would likely return 24.
3437
3438 @item @emph{Standard}:
3439 Fortran 95 and later
3440
3441 @item @emph{Class}:
3442 Inquiry function
3443
3444 @item @emph{Syntax}:
3445 @code{RESULT = DIGITS(X)}
3446
3447 @item @emph{Arguments}:
3448 @multitable @columnfractions .15 .70
3449 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
3450 @end multitable
3451
3452 @item @emph{Return value}:
3453 The return value is of type @code{INTEGER}.
3454
3455 @item @emph{Example}:
3456 @smallexample
3457 program test_digits
3458     integer :: i = 12345
3459     real :: x = 3.143
3460     real(8) :: y = 2.33
3461     print *, digits(i)
3462     print *, digits(x)
3463     print *, digits(y)
3464 end program test_digits
3465 @end smallexample
3466 @end table
3467
3468
3469
3470 @node DIM
3471 @section @code{DIM} --- Positive difference
3472 @fnindex DIM
3473 @fnindex IDIM
3474 @fnindex DDIM
3475 @cindex positive difference
3476
3477 @table @asis
3478 @item @emph{Description}:
3479 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
3480 otherwise returns zero.
3481
3482 @item @emph{Standard}:
3483 Fortran 77 and later
3484
3485 @item @emph{Class}:
3486 Elemental function
3487
3488 @item @emph{Syntax}:
3489 @code{RESULT = DIM(X, Y)}
3490
3491 @item @emph{Arguments}:
3492 @multitable @columnfractions .15 .70
3493 @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
3494 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
3495 @end multitable
3496
3497 @item @emph{Return value}:
3498 The return value is of type @code{INTEGER} or @code{REAL}.
3499
3500 @item @emph{Example}:
3501 @smallexample
3502 program test_dim
3503     integer :: i
3504     real(8) :: x
3505     i = dim(4, 15)
3506     x = dim(4.345_8, 2.111_8)
3507     print *, i
3508     print *, x
3509 end program test_dim
3510 @end smallexample
3511
3512 @item @emph{Specific names}:
3513 @multitable @columnfractions .20 .20 .20 .25
3514 @item Name             @tab Argument               @tab Return type       @tab Standard
3515 @item @code{DIM(X,Y)}  @tab @code{REAL(4) X, Y}    @tab @code{REAL(4)}    @tab Fortran 77 and later
3516 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X, Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
3517 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X, Y}    @tab @code{REAL(8)}    @tab Fortran 77 and later
3518 @end multitable
3519 @end table
3520
3521
3522
3523 @node DOT_PRODUCT
3524 @section @code{DOT_PRODUCT} --- Dot product function
3525 @fnindex DOT_PRODUCT
3526 @cindex dot product
3527 @cindex vector product
3528 @cindex product, vector
3529
3530 @table @asis
3531 @item @emph{Description}:
3532 @code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
3533 of two vectors @var{VECTOR_A} and @var{VECTOR_B}.  The two vectors may be
3534 either numeric or logical and must be arrays of rank one and of equal size. If
3535 the vectors are @code{INTEGER} or @code{REAL}, the result is
3536 @code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
3537 is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
3538 the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.  
3539
3540 @item @emph{Standard}:
3541 Fortran 95 and later
3542
3543 @item @emph{Class}:
3544 Transformational function
3545
3546 @item @emph{Syntax}:
3547 @code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
3548
3549 @item @emph{Arguments}:
3550 @multitable @columnfractions .15 .70
3551 @item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
3552 @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.
3553 @end multitable
3554
3555 @item @emph{Return value}:
3556 If the arguments are numeric, the return value is a scalar of numeric type,
3557 @code{INTEGER}, @code{REAL}, or @code{COMPLEX}.  If the arguments are
3558 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
3559
3560 @item @emph{Example}:
3561 @smallexample
3562 program test_dot_prod
3563     integer, dimension(3) :: a, b
3564     a = (/ 1, 2, 3 /)
3565     b = (/ 4, 5, 6 /)
3566     print '(3i3)', a
3567     print *
3568     print '(3i3)', b
3569     print *
3570     print *, dot_product(a,b)
3571 end program test_dot_prod
3572 @end smallexample
3573 @end table
3574
3575
3576
3577 @node DPROD
3578 @section @code{DPROD} --- Double product function
3579 @fnindex DPROD
3580 @cindex product, double-precision
3581
3582 @table @asis
3583 @item @emph{Description}:
3584 @code{DPROD(X,Y)} returns the product @code{X*Y}.
3585
3586 @item @emph{Standard}:
3587 Fortran 77 and later
3588
3589 @item @emph{Class}:
3590 Elemental function
3591
3592 @item @emph{Syntax}:
3593 @code{RESULT = DPROD(X, Y)}
3594
3595 @item @emph{Arguments}:
3596 @multitable @columnfractions .15 .70
3597 @item @var{X} @tab The type shall be @code{REAL}.
3598 @item @var{Y} @tab The type shall be @code{REAL}.
3599 @end multitable
3600
3601 @item @emph{Return value}:
3602 The return value is of type @code{REAL(8)}.
3603
3604 @item @emph{Example}:
3605 @smallexample
3606 program test_dprod
3607     real :: x = 5.2
3608     real :: y = 2.3
3609     real(8) :: d
3610     d = dprod(x,y)
3611     print *, d
3612 end program test_dprod
3613 @end smallexample
3614
3615 @item @emph{Specific names}:
3616 @multitable @columnfractions .20 .20 .20 .25
3617 @item Name              @tab Argument               @tab Return type       @tab Standard
3618 @item @code{DPROD(X,Y)} @tab @code{REAL(4) X, Y}    @tab @code{REAL(4)}    @tab Fortran 77 and later
3619 @end multitable
3620
3621 @end table
3622
3623
3624 @node DREAL
3625 @section @code{DREAL} --- Double real part function
3626 @fnindex DREAL
3627 @cindex complex numbers, real part
3628
3629 @table @asis
3630 @item @emph{Description}:
3631 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
3632
3633 @item @emph{Standard}:
3634 GNU extension
3635
3636 @item @emph{Class}:
3637 Elemental function
3638
3639 @item @emph{Syntax}:
3640 @code{RESULT = DREAL(A)}
3641
3642 @item @emph{Arguments}:
3643 @multitable @columnfractions .15 .70
3644 @item @var{A} @tab The type shall be @code{COMPLEX(8)}.
3645 @end multitable
3646
3647 @item @emph{Return value}:
3648 The return value is of type @code{REAL(8)}.
3649
3650 @item @emph{Example}:
3651 @smallexample
3652 program test_dreal
3653     complex(8) :: z = (1.3_8,7.2_8)
3654     print *, dreal(z)
3655 end program test_dreal
3656 @end smallexample
3657
3658 @item @emph{See also}:
3659 @ref{AIMAG}
3660
3661 @end table
3662
3663
3664
3665 @node DSHIFTL
3666 @section @code{DSHIFTL} --- Combined left shift
3667 @fnindex DSHIFTL
3668 @cindex left shift, combined
3669 @cindex shift, left
3670
3671 @table @asis
3672 @item @emph{Description}:
3673 @code{DSHIFTL(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
3674 rightmost @var{SHIFT} bits of the result are the leftmost @var{SHIFT}
3675 bits of @var{J}, and the remaining bits are the rightmost bits of
3676 @var{I}.
3677
3678 @item @emph{Standard}:
3679 Fortran 2008 and later
3680
3681 @item @emph{Class}:
3682 Elemental function
3683
3684 @item @emph{Syntax}:
3685 @code{RESULT = DSHIFTL(I, J, SHIFT)}
3686
3687 @item @emph{Arguments}:
3688 @multitable @columnfractions .15 .70
3689 @item @var{I} @tab Shall be of type @code{INTEGER}.
3690 @item @var{J} @tab Shall be of type @code{INTEGER}, and of the same kind
3691 as @var{I}.
3692 @item @var{SHIFT} @tab Shall be of type @code{INTEGER}.
3693 @end multitable
3694
3695 @item @emph{Return value}:
3696 The return value has same type and kind as @var{I}.
3697
3698 @item @emph{See also}:
3699 @ref{DSHIFTR}
3700
3701 @end table
3702
3703
3704
3705 @node DSHIFTR
3706 @section @code{DSHIFTR} --- Combined right shift
3707 @fnindex DSHIFTR
3708 @cindex right shift, combined
3709 @cindex shift, right
3710
3711 @table @asis
3712 @item @emph{Description}:
3713 @code{DSHIFTR(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
3714 leftmost @var{SHIFT} bits of the result are the rightmost @var{SHIFT}
3715 bits of @var{I}, and the remaining bits are the leftmost bits of
3716 @var{J}.
3717
3718 @item @emph{Standard}:
3719 Fortran 2008 and later
3720
3721 @item @emph{Class}:
3722 Elemental function
3723
3724 @item @emph{Syntax}:
3725 @code{RESULT = DSHIFTR(I, J, SHIFT)}
3726
3727 @item @emph{Arguments}:
3728 @multitable @columnfractions .15 .70
3729 @item @var{I} @tab Shall be of type @code{INTEGER}.
3730 @item @var{J} @tab Shall be of type @code{INTEGER}, and of the same kind
3731 as @var{I}.
3732 @item @var{SHIFT} @tab Shall be of type @code{INTEGER}.
3733 @end multitable
3734
3735 @item @emph{Return value}:
3736 The return value has same type and kind as @var{I}.
3737
3738 @item @emph{See also}:
3739 @ref{DSHIFTL}
3740
3741 @end table
3742
3743
3744
3745 @node DTIME
3746 @section @code{DTIME} --- Execution time subroutine (or function)
3747 @fnindex DTIME
3748 @cindex time, elapsed
3749 @cindex elapsed time
3750
3751 @table @asis
3752 @item @emph{Description}:
3753 @code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime
3754 since the start of the process's execution in @var{TIME}.  @var{VALUES}
3755 returns the user and system components of this time in @code{VALUES(1)} and
3756 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) +
3757 VALUES(2)}.
3758
3759 Subsequent invocations of @code{DTIME} return values accumulated since the
3760 previous invocation.
3761
3762 On some systems, the underlying timings are represented using types with
3763 sufficiently small limits that overflows (wrap around) are possible, such as
3764 32-bit types. Therefore, the values returned by this intrinsic might be, or
3765 become, negative, or numerically less than previous values, during a single
3766 run of the compiled program.
3767
3768 Please note, that this implementation is thread safe if used within OpenMP
3769 directives, i.e., its state will be consistent while called from multiple
3770 threads. However, if @code{DTIME} is called from multiple threads, the result
3771 is still the time since the last invocation. This may not give the intended
3772 results. If possible, use @code{CPU_TIME} instead.
3773
3774 This intrinsic is provided in both subroutine and function forms; however,
3775 only one form can be used in any given program unit.
3776
3777 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
3778
3779 @multitable @columnfractions .15 .30 .40
3780 @item @tab @code{VALUES(1)}: @tab User time in seconds.
3781 @item @tab @code{VALUES(2)}: @tab System time in seconds.
3782 @item @tab @code{TIME}: @tab Run time since start in seconds.
3783 @end multitable
3784
3785 @item @emph{Standard}:
3786 GNU extension
3787
3788 @item @emph{Class}:
3789 Subroutine, function
3790
3791 @item @emph{Syntax}:
3792 @multitable @columnfractions .80
3793 @item @code{CALL DTIME(VALUES, TIME)}.
3794 @item @code{TIME = DTIME(VALUES)}, (not recommended).
3795 @end multitable
3796
3797 @item @emph{Arguments}:
3798 @multitable @columnfractions .15 .70
3799 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
3800 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
3801 @end multitable
3802
3803 @item @emph{Return value}:
3804 Elapsed time in seconds since the last invocation or since the start of program
3805 execution if not called before.
3806
3807 @item @emph{Example}:
3808 @smallexample
3809 program test_dtime
3810     integer(8) :: i, j
3811     real, dimension(2) :: tarray
3812     real :: result
3813     call dtime(tarray, result)
3814     print *, result
3815     print *, tarray(1)
3816     print *, tarray(2)   
3817     do i=1,100000000    ! Just a delay
3818         j = i * i - i
3819     end do
3820     call dtime(tarray, result)
3821     print *, result
3822     print *, tarray(1)
3823     print *, tarray(2)
3824 end program test_dtime
3825 @end smallexample
3826
3827 @item @emph{See also}:
3828 @ref{CPU_TIME}
3829
3830 @end table
3831
3832
3833
3834 @node EOSHIFT
3835 @section @code{EOSHIFT} --- End-off shift elements of an array
3836 @fnindex EOSHIFT
3837 @cindex array, shift
3838
3839 @table @asis
3840 @item @emph{Description}:
3841 @code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
3842 elements of @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is
3843 omitted it is taken to be @code{1}.  @var{DIM} is a scalar of type
3844 @code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the
3845 rank of @var{ARRAY}.  If the rank of @var{ARRAY} is one, then all elements of
3846 @var{ARRAY} are shifted by @var{SHIFT} places.  If rank is greater than one,
3847 then all complete rank one sections of @var{ARRAY} along the given dimension are
3848 shifted.  Elements shifted out one end of each rank one section are dropped.  If
3849 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
3850 is copied back in the other end.  If @var{BOUNDARY} is not present then the
3851 following are copied in depending on the type of @var{ARRAY}.
3852
3853 @multitable @columnfractions .15 .80
3854 @item @emph{Array Type} @tab @emph{Boundary Value}
3855 @item Numeric  @tab 0 of the type and kind of @var{ARRAY}.
3856 @item Logical  @tab @code{.FALSE.}.
3857 @item Character(@var{len}) @tab @var{len} blanks.
3858 @end multitable
3859
3860 @item @emph{Standard}:
3861 Fortran 95 and later
3862
3863 @item @emph{Class}:
3864 Transformational function
3865
3866 @item @emph{Syntax}:
3867 @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
3868
3869 @item @emph{Arguments}:
3870 @multitable @columnfractions .15 .70
3871 @item @var{ARRAY}  @tab May be any type, not scalar.
3872 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
3873 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}. 
3874 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
3875 @end multitable
3876
3877 @item @emph{Return value}:
3878 Returns an array of same type and rank as the @var{ARRAY} argument.
3879
3880 @item @emph{Example}:
3881 @smallexample
3882 program test_eoshift
3883     integer, dimension(3,3) :: a
3884     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3885     print '(3i3)', a(1,:)
3886     print '(3i3)', a(2,:)
3887     print '(3i3)', a(3,:)    
3888     a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3889     print *
3890     print '(3i3)', a(1,:)
3891     print '(3i3)', a(2,:)
3892     print '(3i3)', a(3,:)
3893 end program test_eoshift
3894 @end smallexample
3895 @end table
3896
3897
3898
3899 @node EPSILON
3900 @section @code{EPSILON} --- Epsilon function
3901 @fnindex EPSILON
3902 @cindex model representation, epsilon
3903
3904 @table @asis
3905 @item @emph{Description}:
3906 @code{EPSILON(X)} returns the smallest number @var{E} of the same kind
3907 as @var{X} such that @math{1 + E > 1}.
3908
3909 @item @emph{Standard}:
3910 Fortran 95 and later
3911
3912 @item @emph{Class}:
3913 Inquiry function
3914
3915 @item @emph{Syntax}:
3916 @code{RESULT = EPSILON(X)}
3917
3918 @item @emph{Arguments}:
3919 @multitable @columnfractions .15 .70
3920 @item @var{X} @tab The type shall be @code{REAL}.
3921 @end multitable
3922
3923 @item @emph{Return value}:
3924 The return value is of same type as the argument.
3925
3926 @item @emph{Example}:
3927 @smallexample
3928 program test_epsilon
3929     real :: x = 3.143
3930     real(8) :: y = 2.33
3931     print *, EPSILON(x)
3932     print *, EPSILON(y)
3933 end program test_epsilon
3934 @end smallexample
3935 @end table
3936
3937
3938
3939 @node ERF
3940 @section @code{ERF} --- Error function 
3941 @fnindex ERF
3942 @cindex error function
3943
3944 @table @asis
3945 @item @emph{Description}:
3946 @code{ERF(X)} computes the error function of @var{X}.
3947
3948 @item @emph{Standard}:
3949 Fortran 2008 and later
3950
3951 @item @emph{Class}:
3952 Elemental function
3953
3954 @item @emph{Syntax}:
3955 @code{RESULT = ERF(X)}
3956
3957 @item @emph{Arguments}:
3958 @multitable @columnfractions .15 .70
3959 @item @var{X} @tab The type shall be @code{REAL}.
3960 @end multitable
3961
3962 @item @emph{Return value}:
3963 The return value is of type @code{REAL}, of the same kind as
3964 @var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
3965
3966 @item @emph{Example}:
3967 @smallexample
3968 program test_erf
3969   real(8) :: x = 0.17_8
3970   x = erf(x)
3971 end program test_erf
3972 @end smallexample
3973
3974 @item @emph{Specific names}:
3975 @multitable @columnfractions .20 .20 .20 .25
3976 @item Name            @tab Argument          @tab Return type       @tab Standard
3977 @item @code{DERF(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
3978 @end multitable
3979 @end table
3980
3981
3982
3983 @node ERFC
3984 @section @code{ERFC} --- Error function 
3985 @fnindex ERFC
3986 @cindex error function, complementary
3987
3988 @table @asis
3989 @item @emph{Description}:
3990 @code{ERFC(X)} computes the complementary error function of @var{X}.
3991
3992 @item @emph{Standard}:
3993 Fortran 2008 and later
3994
3995 @item @emph{Class}:
3996 Elemental function
3997
3998 @item @emph{Syntax}:
3999 @code{RESULT = ERFC(X)}
4000
4001 @item @emph{Arguments}:
4002 @multitable @columnfractions .15 .70
4003 @item @var{X} @tab The type shall be @code{REAL}.
4004 @end multitable
4005
4006 @item @emph{Return value}:
4007 The return value is of type @code{REAL} and of the same kind as @var{X}.
4008 It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
4009
4010 @item @emph{Example}:
4011 @smallexample
4012 program test_erfc
4013   real(8) :: x = 0.17_8
4014   x = erfc(x)
4015 end program test_erfc
4016 @end smallexample
4017
4018 @item @emph{Specific names}:
4019 @multitable @columnfractions .20 .20 .20 .25
4020 @item Name            @tab Argument          @tab Return type       @tab Standard
4021 @item @code{DERFC(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
4022 @end multitable
4023 @end table
4024
4025
4026
4027 @node ERFC_SCALED
4028 @section @code{ERFC_SCALED} --- Error function 
4029 @fnindex ERFC_SCALED
4030 @cindex error function, complementary, exponentially-scaled
4031
4032 @table @asis
4033 @item @emph{Description}:
4034 @code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
4035 error function of @var{X}.
4036
4037 @item @emph{Standard}:
4038 Fortran 2008 and later
4039
4040 @item @emph{Class}:
4041 Elemental function
4042
4043 @item @emph{Syntax}:
4044 @code{RESULT = ERFC_SCALED(X)}
4045
4046 @item @emph{Arguments}:
4047 @multitable @columnfractions .15 .70
4048 @item @var{X} @tab The type shall be @code{REAL}.
4049 @end multitable
4050
4051 @item @emph{Return value}:
4052 The return value is of type @code{REAL} and of the same kind as @var{X}.
4053
4054 @item @emph{Example}:
4055 @smallexample
4056 program test_erfc_scaled
4057   real(8) :: x = 0.17_8
4058   x = erfc_scaled(x)
4059 end program test_erfc_scaled
4060 @end smallexample
4061 @end table
4062
4063
4064
4065 @node ETIME
4066 @section @code{ETIME} --- Execution time subroutine (or function)
4067 @fnindex ETIME
4068 @cindex time, elapsed
4069
4070 @table @asis
4071 @item @emph{Description}:
4072 @code{ETIME(VALUES, TIME)} returns the number of seconds of runtime
4073 since the start of the process's execution in @var{TIME}.  @var{VALUES}
4074 returns the user and system components of this time in @code{VALUES(1)} and
4075 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}.
4076
4077 On some systems, the underlying timings are represented using types with
4078 sufficiently small limits that overflows (wrap around) are possible, such as
4079 32-bit types. Therefore, the values returned by this intrinsic might be, or
4080 become, negative, or numerically less than previous values, during a single
4081 run of the compiled program.
4082
4083 This intrinsic is provided in both subroutine and function forms; however,
4084 only one form can be used in any given program unit.
4085
4086 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
4087
4088 @multitable @columnfractions .15 .30 .60
4089 @item @tab @code{VALUES(1)}: @tab User time in seconds.
4090 @item @tab @code{VALUES(2)}: @tab System time in seconds.
4091 @item @tab @code{TIME}: @tab Run time since start in seconds.
4092 @end multitable
4093
4094 @item @emph{Standard}:
4095 GNU extension
4096
4097 @item @emph{Class}:
4098 Subroutine, function
4099
4100 @item @emph{Syntax}:
4101 @multitable @columnfractions .80
4102 @item @code{CALL ETIME(VALUES, TIME)}.
4103 @item @code{TIME = ETIME(VALUES)}, (not recommended).
4104 @end multitable
4105
4106 @item @emph{Arguments}:
4107 @multitable @columnfractions .15 .70
4108 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
4109 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
4110 @end multitable
4111
4112 @item @emph{Return value}:
4113 Elapsed time in seconds since the start of program execution.
4114
4115 @item @emph{Example}:
4116 @smallexample
4117 program test_etime
4118     integer(8) :: i, j
4119     real, dimension(2) :: tarray
4120     real :: result
4121     call ETIME(tarray, result)
4122     print *, result
4123     print *, tarray(1)
4124     print *, tarray(2)   
4125     do i=1,100000000    ! Just a delay
4126         j = i * i - i
4127     end do
4128     call ETIME(tarray, result)
4129     print *, result
4130     print *, tarray(1)
4131     print *, tarray(2)
4132 end program test_etime
4133 @end smallexample
4134
4135 @item @emph{See also}:
4136 @ref{CPU_TIME}
4137
4138 @end table
4139
4140
4141
4142 @node EXECUTE_COMMAND_LINE
4143 @section @code{EXECUTE_COMMAND_LINE} --- Execute a shell command
4144 @fnindex EXECUTE_COMMAND_LINE
4145 @cindex system, system call
4146 @cindex command line
4147
4148 @table @asis
4149 @item @emph{Description}:
4150 @code{EXECUTE_COMMAND_LINE} runs a shell command, synchronously or
4151 asynchronously.
4152
4153 The @code{COMMAND} argument is passed to the shell and executed, using
4154 the C library's @code{system()} call.  (The shell is @code{sh} on Unix
4155 systems, and @code{cmd.exe} on Windows.)  If @code{WAIT} is present and
4156 has the value false, the execution of the command is asynchronous if the
4157 system supports it; otherwise, the command is executed synchronously.
4158
4159 The three last arguments allow the user to get status information.  After
4160 synchronous execution, @code{EXITSTAT} contains the integer exit code of
4161 the command, as returned by @code{system}.  @code{CMDSTAT} is set to zero
4162 if the command line was executed (whatever its exit status was).
4163 @code{CMDMSG} is assigned an error message if an error has occurred.
4164
4165
4166 @item @emph{Standard}:
4167 Fortran 2008 and later
4168
4169 @item @emph{Class}:
4170 Subroutine
4171
4172 @item @emph{Syntax}:
4173 @code{CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])}
4174
4175 @item @emph{Arguments}:
4176 @multitable @columnfractions .15 .70
4177 @item @var{COMMAND} @tab Shall be a default @code{CHARACTER} scalar.
4178 @item @var{WAIT} @tab (Optional) Shall be a default @code{LOGICAL} scalar.
4179 @item @var{EXITSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
4180 default kind.
4181 @item @var{CMDSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
4182 default kind.
4183 @item @var{CMDMSG} @tab (Optional) Shall be an @code{CHARACTER} scalar of the
4184 default kind.
4185 @end multitable
4186
4187 @item @emph{Example}:
4188 @smallexample
4189 program test_exec
4190   integer :: i
4191
4192   call execute_command_line ("external_prog.exe", exitstat=i)
4193   print *, "Exit status of external_prog.exe was ", i
4194
4195   call execute_command_line ("reindex_files.exe", wait=.false.)
4196   print *, "Now reindexing files in the background"
4197
4198 end program test_exec
4199 @end smallexample
4200
4201
4202 @item @emph{Note}:
4203
4204 Because this intrinsic is implemented in terms of the @code{system()}
4205 function call, its behavior with respect to signaling is processor
4206 dependent. In particular, on POSIX-compliant systems, the SIGINT and
4207 SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As
4208 such, if the parent process is terminated, the child process might not be
4209 terminated alongside.
4210
4211
4212 @item @emph{See also}:
4213 @ref{SYSTEM}
4214 @end table
4215
4216
4217
4218 @node EXIT
4219 @section @code{EXIT} --- Exit the program with status. 
4220 @fnindex EXIT
4221 @cindex program termination
4222 @cindex terminate program
4223
4224 @table @asis
4225 @item @emph{Description}:
4226 @code{EXIT} causes immediate termination of the program with status.  If status
4227 is omitted it returns the canonical @emph{success} for the system.  All Fortran
4228 I/O units are closed. 
4229
4230 @item @emph{Standard}:
4231 GNU extension
4232
4233 @item @emph{Class}:
4234 Subroutine
4235
4236 @item @emph{Syntax}:
4237 @code{CALL EXIT([STATUS])}
4238
4239 @item @emph{Arguments}:
4240 @multitable @columnfractions .15 .70
4241 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
4242 @end multitable
4243
4244 @item @emph{Return value}:
4245 @code{STATUS} is passed to the parent process on exit.
4246
4247 @item @emph{Example}:
4248 @smallexample
4249 program test_exit
4250   integer :: STATUS = 0
4251   print *, 'This program is going to exit.'
4252   call EXIT(STATUS)
4253 end program test_exit
4254 @end smallexample
4255
4256 @item @emph{See also}:
4257 @ref{ABORT}, @ref{KILL}
4258 @end table
4259
4260
4261
4262 @node EXP
4263 @section @code{EXP} --- Exponential function 
4264 @fnindex EXP
4265 @fnindex DEXP
4266 @fnindex CEXP
4267 @fnindex ZEXP
4268 @fnindex CDEXP
4269 @cindex exponential function
4270 @cindex logarithmic function, inverse
4271
4272 @table @asis
4273 @item @emph{Description}:
4274 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
4275
4276 @item @emph{Standard}:
4277 Fortran 77 and later, has overloads that are GNU extensions
4278
4279 @item @emph{Class}:
4280 Elemental function
4281
4282 @item @emph{Syntax}:
4283 @code{RESULT = EXP(X)}
4284
4285 @item @emph{Arguments}:
4286 @multitable @columnfractions .15 .70
4287 @item @var{X} @tab The type shall be @code{REAL} or
4288 @code{COMPLEX}.
4289 @end multitable
4290
4291 @item @emph{Return value}:
4292 The return value has same type and kind as @var{X}.
4293
4294 @item @emph{Example}:
4295 @smallexample
4296 program test_exp
4297   real :: x = 1.0
4298   x = exp(x)
4299 end program test_exp
4300 @end smallexample
4301
4302 @item @emph{Specific names}:
4303 @multitable @columnfractions .20 .20 .20 .25
4304 @item Name            @tab Argument             @tab Return type         @tab Standard
4305 @item @code{EXP(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}      @tab Fortran 77 and later
4306 @item @code{DEXP(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}      @tab Fortran 77 and later
4307 @item @code{CEXP(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}   @tab Fortran 77 and later
4308 @item @code{ZEXP(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
4309 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
4310 @end multitable
4311 @end table
4312
4313
4314
4315 @node EXPONENT
4316 @section @code{EXPONENT} --- Exponent function 
4317 @fnindex EXPONENT
4318 @cindex real number, exponent
4319 @cindex floating point, exponent
4320
4321 @table @asis
4322 @item @emph{Description}:
4323 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
4324 is zero the value returned is zero. 
4325
4326 @item @emph{Standard}:
4327 Fortran 95 and later
4328
4329 @item @emph{Class}:
4330 Elemental function
4331
4332 @item @emph{Syntax}:
4333 @code{RESULT = EXPONENT(X)}
4334
4335 @item @emph{Arguments}:
4336 @multitable @columnfractions .15 .70
4337 @item @var{X} @tab The type shall be @code{REAL}.
4338 @end multitable
4339
4340 @item @emph{Return value}:
4341 The return value is of type default @code{INTEGER}.
4342
4343 @item @emph{Example}:
4344 @smallexample
4345 program test_exponent
4346   real :: x = 1.0
4347   integer :: i
4348   i = exponent(x)
4349   print *, i
4350   print *, exponent(0.0)
4351 end program test_exponent
4352 @end smallexample
4353 @end table
4354
4355
4356
4357 @node EXTENDS_TYPE_OF
4358 @section @code{EXTENDS_TYPE_OF} ---  Query dynamic type for extension
4359 @fnindex EXTENDS_TYPE_OF
4360
4361 @table @asis
4362 @item @emph{Description}:
4363 Query dynamic type for extension.
4364
4365 @item @emph{Standard}:
4366 Fortran 2003 and later
4367
4368 @item @emph{Class}:
4369 Inquiry function
4370
4371 @item @emph{Syntax}:
4372 @code{RESULT = EXTENDS_TYPE_OF(A, MOLD)}
4373
4374 @item @emph{Arguments}:
4375 @multitable @columnfractions .15 .70
4376 @item @var{A} @tab Shall be an object of extensible declared type or
4377 unlimited polymorphic. 
4378 @item @var{MOLD} @tab Shall be an object of extensible declared type or
4379 unlimited polymorphic. 
4380 @end multitable
4381
4382 @item @emph{Return value}:
4383 The return value is a scalar of type default logical. It is true if and only if
4384 the dynamic type of A is an extension type of the dynamic type of MOLD.
4385
4386
4387 @item @emph{See also}:
4388 @ref{SAME_TYPE_AS}
4389 @end table
4390
4391
4392
4393 @node FDATE
4394 @section @code{FDATE} --- Get the current time as a string
4395 @fnindex FDATE
4396 @cindex time, current
4397 @cindex current time
4398 @cindex date, current
4399 @cindex current date
4400
4401 @table @asis
4402 @item @emph{Description}:
4403 @code{FDATE(DATE)} returns the current date (using the same format as
4404 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
4405 TIME())}.
4406
4407 This intrinsic is provided in both subroutine and function forms; however,
4408 only one form can be used in any given program unit.
4409
4410 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable of the
4411 default kind.
4412
4413 @item @emph{Standard}:
4414 GNU extension
4415
4416 @item @emph{Class}:
4417 Subroutine, function
4418
4419 @item @emph{Syntax}:
4420 @multitable @columnfractions .80
4421 @item @code{CALL FDATE(DATE)}.
4422 @item @code{DATE = FDATE()}, (not recommended).
4423 @end multitable
4424
4425 @item @emph{Arguments}:
4426 @multitable @columnfractions .15 .70
4427 @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
4428 default kind
4429 @end multitable
4430
4431 @item @emph{Return value}:
4432 The current date as a string.
4433
4434 @item @emph{Example}:
4435 @smallexample
4436 program test_fdate
4437     integer(8) :: i, j
4438     character(len=30) :: date
4439     call fdate(date)
4440     print *, 'Program started on ', date
4441     do i = 1, 100000000 ! Just a delay
4442         j = i * i - i
4443     end do
4444     call fdate(date)
4445     print *, 'Program ended on ', date
4446 end program test_fdate
4447 @end smallexample
4448 @end table
4449
4450
4451
4452 @node FGET
4453 @section @code{FGET} --- Read a single character in stream mode from stdin 
4454 @fnindex FGET
4455 @cindex read character, stream mode
4456 @cindex stream mode, read character
4457 @cindex file operation, read character
4458
4459 @table @asis
4460 @item @emph{Description}:
4461 Read a single character in stream mode from stdin by bypassing normal 
4462 formatted output. Stream I/O should not be mixed with normal record-oriented 
4463 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4464
4465 This intrinsic is provided in both subroutine and function forms; however,
4466 only one form can be used in any given program unit.
4467
4468 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4469 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4470 Programmers should consider the use of new stream IO feature in new code 
4471 for future portability. See also @ref{Fortran 2003 status}.
4472
4473 @item @emph{Standard}:
4474 GNU extension
4475
4476 @item @emph{Class}:
4477 Subroutine, function
4478
4479 @item @emph{Syntax}:
4480 @multitable @columnfractions .80
4481 @item @code{CALL FGET(C [, STATUS])}
4482 @item @code{STATUS = FGET(C)}
4483 @end multitable
4484
4485 @item @emph{Arguments}:
4486 @multitable @columnfractions .15 .70
4487 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4488 kind.
4489 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4490 Returns 0 on success, -1 on end-of-file, and a system specific positive
4491 error code otherwise.
4492 @end multitable
4493
4494 @item @emph{Example}:
4495 @smallexample
4496 PROGRAM test_fget
4497   INTEGER, PARAMETER :: strlen = 100
4498   INTEGER :: status, i = 1
4499   CHARACTER(len=strlen) :: str = ""
4500
4501   WRITE (*,*) 'Enter text:'
4502   DO
4503     CALL fget(str(i:i), status)
4504     if (status /= 0 .OR. i > strlen) exit
4505     i = i + 1
4506   END DO
4507   WRITE (*,*) TRIM(str)
4508 END PROGRAM
4509 @end smallexample
4510
4511 @item @emph{See also}:
4512 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
4513 @end table
4514
4515
4516
4517 @node FGETC
4518 @section @code{FGETC} --- Read a single character in stream mode
4519 @fnindex FGETC
4520 @cindex read character, stream mode
4521 @cindex stream mode, read character
4522 @cindex file operation, read character
4523
4524 @table @asis
4525 @item @emph{Description}:
4526 Read a single character in stream mode by bypassing normal formatted output. 
4527 Stream I/O should not be mixed with normal record-oriented (formatted or 
4528 unformatted) I/O on the same unit; the results are unpredictable.
4529
4530 This intrinsic is provided in both subroutine and function forms; however,
4531 only one form can be used in any given program unit.
4532
4533 Note that the @code{FGET} intrinsic is provided for backwards compatibility
4534 with @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4535 Programmers should consider the use of new stream IO feature in new code 
4536 for future portability. See also @ref{Fortran 2003 status}.
4537
4538 @item @emph{Standard}:
4539 GNU extension
4540
4541 @item @emph{Class}:
4542 Subroutine, function
4543
4544 @item @emph{Syntax}:
4545 @multitable @columnfractions .80
4546 @item @code{CALL FGETC(UNIT, C [, STATUS])}
4547 @item @code{STATUS = FGETC(UNIT, C)}
4548 @end multitable
4549
4550 @item @emph{Arguments}:
4551 @multitable @columnfractions .15 .70
4552 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4553 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4554 kind.
4555 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4556 Returns 0 on success, -1 on end-of-file and a system specific positive
4557 error code otherwise.
4558 @end multitable
4559
4560 @item @emph{Example}:
4561 @smallexample
4562 PROGRAM test_fgetc
4563   INTEGER :: fd = 42, status
4564   CHARACTER :: c
4565
4566   OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
4567   DO
4568     CALL fgetc(fd, c, status)
4569     IF (status /= 0) EXIT
4570     call fput(c)
4571   END DO
4572   CLOSE(UNIT=fd)
4573 END PROGRAM
4574 @end smallexample
4575
4576 @item @emph{See also}:
4577 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
4578 @end table
4579
4580
4581
4582 @node FLOOR
4583 @section @code{FLOOR} --- Integer floor function
4584 @fnindex FLOOR
4585 @cindex floor
4586 @cindex rounding, floor
4587
4588 @table @asis
4589 @item @emph{Description}:
4590 @code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
4591
4592 @item @emph{Standard}:
4593 Fortran 95 and later
4594
4595 @item @emph{Class}:
4596 Elemental function
4597
4598 @item @emph{Syntax}:
4599 @code{RESULT = FLOOR(A [, KIND])}
4600
4601 @item @emph{Arguments}:
4602 @multitable @columnfractions .15 .70
4603 @item @var{A} @tab The type shall be @code{REAL}.
4604 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
4605 expression indicating the kind parameter of the result.
4606 @end multitable
4607
4608 @item @emph{Return value}:
4609 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
4610 and of default-kind @code{INTEGER} otherwise.
4611
4612 @item @emph{Example}:
4613 @smallexample
4614 program test_floor
4615     real :: x = 63.29
4616     real :: y = -63.59
4617     print *, floor(x) ! returns 63
4618     print *, floor(y) ! returns -64
4619 end program test_floor
4620 @end smallexample
4621
4622 @item @emph{See also}:
4623 @ref{CEILING}, @ref{NINT}
4624
4625 @end table
4626
4627
4628
4629 @node FLUSH
4630 @section @code{FLUSH} --- Flush I/O unit(s)
4631 @fnindex FLUSH
4632 @cindex file operation, flush
4633
4634 @table @asis
4635 @item @emph{Description}:
4636 Flushes Fortran unit(s) currently open for output. Without the optional
4637 argument, all units are flushed, otherwise just the unit specified.
4638
4639 @item @emph{Standard}:
4640 GNU extension
4641
4642 @item @emph{Class}:
4643 Subroutine
4644
4645 @item @emph{Syntax}:
4646 @code{CALL FLUSH(UNIT)}
4647
4648 @item @emph{Arguments}:
4649 @multitable @columnfractions .15 .70
4650 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
4651 @end multitable
4652
4653 @item @emph{Note}:
4654 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
4655 statement that should be preferred over the @code{FLUSH} intrinsic.
4656
4657 The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement
4658 have identical effect: they flush the runtime library's I/O buffer so
4659 that the data becomes visible to other processes. This does not guarantee
4660 that the data is committed to disk.
4661
4662 On POSIX systems, you can request that all data is transferred  to  the
4663 storage device by calling the @code{fsync} function, with the POSIX file
4664 descriptor of the I/O unit as argument (retrieved with GNU intrinsic
4665 @code{FNUM}). The following example shows how:
4666
4667 @smallexample
4668   ! Declare the interface for POSIX fsync function
4669   interface
4670     function fsync (fd) bind(c,name="fsync")
4671     use iso_c_binding, only: c_int
4672       integer(c_int), value :: fd
4673       integer(c_int) :: fsync
4674     end function fsync
4675   end interface
4676
4677   ! Variable declaration
4678   integer :: ret
4679
4680   ! Opening unit 10
4681   open (10,file="foo")
4682
4683   ! ...
4684   ! Perform I/O on unit 10
4685   ! ...
4686
4687   ! Flush and sync
4688   flush(10)
4689   ret = fsync(fnum(10))
4690
4691   ! Handle possible error
4692   if (ret /= 0) stop "Error calling FSYNC"
4693 @end smallexample
4694
4695 @end table
4696
4697
4698
4699 @node FNUM
4700 @section @code{FNUM} --- File number function
4701 @fnindex FNUM
4702 @cindex file operation, file number
4703
4704 @table @asis
4705 @item @emph{Description}:
4706 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
4707 open Fortran I/O unit @code{UNIT}.
4708
4709 @item @emph{Standard}:
4710 GNU extension
4711
4712 @item @emph{Class}:
4713 Function
4714
4715 @item @emph{Syntax}:
4716 @code{RESULT = FNUM(UNIT)}
4717
4718 @item @emph{Arguments}:
4719 @multitable @columnfractions .15 .70
4720 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
4721 @end multitable
4722
4723 @item @emph{Return value}:
4724 The return value is of type @code{INTEGER}
4725
4726 @item @emph{Example}:
4727 @smallexample
4728 program test_fnum
4729   integer :: i
4730   open (unit=10, status = "scratch")
4731   i = fnum(10)
4732   print *, i
4733   close (10)
4734 end program test_fnum
4735 @end smallexample
4736 @end table
4737
4738
4739
4740 @node FPUT
4741 @section @code{FPUT} --- Write a single character in stream mode to stdout 
4742 @fnindex FPUT
4743 @cindex write character, stream mode
4744 @cindex stream mode, write character
4745 @cindex file operation, write character
4746
4747 @table @asis
4748 @item @emph{Description}:
4749 Write a single character in stream mode to stdout by bypassing normal 
4750 formatted output. Stream I/O should not be mixed with normal record-oriented 
4751 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4752
4753 This intrinsic is provided in both subroutine and function forms; however,
4754 only one form can be used in any given program unit.
4755
4756 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4757 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4758 Programmers should consider the use of new stream IO feature in new code 
4759 for future portability. See also @ref{Fortran 2003 status}.
4760
4761 @item @emph{Standard}:
4762 GNU extension
4763
4764 @item @emph{Class}:
4765 Subroutine, function
4766
4767 @item @emph{Syntax}:
4768 @multitable @columnfractions .80
4769 @item @code{CALL FPUT(C [, STATUS])}
4770 @item @code{STATUS = FPUT(C)}
4771 @end multitable
4772
4773 @item @emph{Arguments}:
4774 @multitable @columnfractions .15 .70
4775 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4776 kind.
4777 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4778 Returns 0 on success, -1 on end-of-file and a system specific positive
4779 error code otherwise.
4780 @end multitable
4781
4782 @item @emph{Example}:
4783 @smallexample
4784 PROGRAM test_fput
4785   CHARACTER(len=10) :: str = "gfortran"
4786   INTEGER :: i
4787   DO i = 1, len_trim(str)
4788     CALL fput(str(i:i))
4789   END DO
4790 END PROGRAM
4791 @end smallexample
4792
4793 @item @emph{See also}:
4794 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
4795 @end table
4796
4797
4798
4799 @node FPUTC
4800 @section @code{FPUTC} --- Write a single character in stream mode
4801 @fnindex FPUTC
4802 @cindex write character, stream mode
4803 @cindex stream mode, write character
4804 @cindex file operation, write character
4805
4806 @table @asis
4807 @item @emph{Description}:
4808 Write a single character in stream mode by bypassing normal formatted 
4809 output. Stream I/O should not be mixed with normal record-oriented 
4810 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4811
4812 This intrinsic is provided in both subroutine and function forms; however,
4813 only one form can be used in any given program unit.
4814
4815 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4816 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4817 Programmers should consider the use of new stream IO feature in new code 
4818 for future portability. See also @ref{Fortran 2003 status}.
4819
4820 @item @emph{Standard}:
4821 GNU extension
4822
4823 @item @emph{Class}:
4824 Subroutine, function
4825
4826 @item @emph{Syntax}:
4827 @multitable @columnfractions .80
4828 @item @code{CALL FPUTC(UNIT, C [, STATUS])}
4829 @item @code{STATUS = FPUTC(UNIT, C)}
4830 @end multitable
4831
4832 @item @emph{Arguments}:
4833 @multitable @columnfractions .15 .70
4834 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4835 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4836 kind.
4837 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4838 Returns 0 on success, -1 on end-of-file and a system specific positive
4839 error code otherwise.
4840 @end multitable
4841
4842 @item @emph{Example}:
4843 @smallexample
4844 PROGRAM test_fputc
4845   CHARACTER(len=10) :: str = "gfortran"
4846   INTEGER :: fd = 42, i
4847
4848   OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
4849   DO i = 1, len_trim(str)
4850     CALL fputc(fd, str(i:i))
4851   END DO
4852   CLOSE(fd)
4853 END PROGRAM
4854 @end smallexample
4855
4856 @item @emph{See also}:
4857 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
4858 @end table
4859
4860
4861
4862 @node FRACTION
4863 @section @code{FRACTION} --- Fractional part of the model representation
4864 @fnindex FRACTION
4865 @cindex real number, fraction
4866 @cindex floating point, fraction
4867
4868 @table @asis
4869 @item @emph{Description}:
4870 @code{FRACTION(X)} returns the fractional part of the model
4871 representation of @code{X}.
4872
4873 @item @emph{Standard}:
4874 Fortran 95 and later
4875
4876 @item @emph{Class}:
4877 Elemental function
4878
4879 @item @emph{Syntax}:
4880 @code{Y = FRACTION(X)}
4881
4882 @item @emph{Arguments}:
4883 @multitable @columnfractions .15 .70
4884 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
4885 @end multitable
4886
4887 @item @emph{Return value}:
4888 The return value is of the same type and kind as the argument.
4889 The fractional part of the model representation of @code{X} is returned;
4890 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
4891
4892 @item @emph{Example}:
4893 @smallexample
4894 program test_fraction
4895   real :: x
4896   x = 178.1387e-4
4897   print *, fraction(x), x * radix(x)**(-exponent(x))
4898 end program test_fraction
4899 @end smallexample
4900
4901 @end table
4902
4903
4904
4905 @node FREE
4906 @section @code{FREE} --- Frees memory
4907 @fnindex FREE
4908 @cindex pointer, cray
4909
4910 @table @asis
4911 @item @emph{Description}:
4912 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
4913 intrinsic is an extension intended to be used with Cray pointers, and is
4914 provided in GNU Fortran to allow user to compile legacy code. For
4915 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
4916 @code{DEALLOCATE}.
4917
4918 @item @emph{Standard}:
4919 GNU extension
4920
4921 @item @emph{Class}:
4922 Subroutine
4923
4924 @item @emph{Syntax}:
4925 @code{CALL FREE(PTR)}
4926
4927 @item @emph{Arguments}:
4928 @multitable @columnfractions .15 .70
4929 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
4930 location of the memory that should be de-allocated.
4931 @end multitable
4932
4933 @item @emph{Return value}:
4934 None
4935
4936 @item @emph{Example}:
4937 See @code{MALLOC} for an example.
4938
4939 @item @emph{See also}:
4940 @ref{MALLOC}
4941 @end table
4942
4943
4944
4945 @node FSEEK
4946 @section @code{FSEEK} --- Low level file positioning subroutine
4947 @fnindex FSEEK
4948 @cindex file operation, seek
4949 @cindex file operation, position
4950
4951 @table @asis
4952 @item @emph{Description}:
4953 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE} 
4954 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
4955 if set to 1, @var{OFFSET} is taken to be relative to the current position 
4956 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
4957 On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek 
4958 fails silently.
4959
4960 This intrinsic routine is not fully backwards compatible with @command{g77}. 
4961 In @command{g77}, the @code{FSEEK} takes a statement label instead of a 
4962 @var{STATUS} variable. If FSEEK is used in old code, change
4963 @smallexample
4964   CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
4965 @end smallexample 
4966 to
4967 @smallexample
4968   INTEGER :: status
4969   CALL FSEEK(UNIT, OFFSET, WHENCE, status)
4970   IF (status /= 0) GOTO label
4971 @end smallexample 
4972
4973 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
4974 Programmers should consider the use of new stream IO feature in new code 
4975 for future portability. See also @ref{Fortran 2003 status}.
4976
4977 @item @emph{Standard}:
4978 GNU extension
4979
4980 @item @emph{Class}:
4981 Subroutine
4982
4983 @item @emph{Syntax}:
4984 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
4985
4986 @item @emph{Arguments}:
4987 @multitable @columnfractions .15 .70
4988 @item @var{UNIT}   @tab Shall be a scalar of type @code{INTEGER}.
4989 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
4990 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
4991 Its value shall be either 0, 1 or 2.
4992 @item @var{STATUS} @tab (Optional) shall be a scalar of type 
4993 @code{INTEGER(4)}.
4994 @end multitable
4995
4996 @item @emph{Example}:
4997 @smallexample
4998 PROGRAM test_fseek
4999   INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
5000   INTEGER :: fd, offset, ierr
5001
5002   ierr   = 0
5003   offset = 5
5004   fd     = 10
5005
5006   OPEN(UNIT=fd, FILE="fseek.test")
5007   CALL FSEEK(fd, offset, SEEK_SET, ierr)  ! move to OFFSET
5008   print *, FTELL(fd), ierr
5009
5010   CALL FSEEK(fd, 0, SEEK_END, ierr)       ! move to end
5011   print *, FTELL(fd), ierr
5012
5013   CALL FSEEK(fd, 0, SEEK_SET, ierr)       ! move to beginning
5014   print *, FTELL(fd), ierr
5015
5016   CLOSE(UNIT=fd)
5017 END PROGRAM
5018 @end smallexample
5019
5020 @item @emph{See also}:
5021 @ref{FTELL}
5022 @end table
5023
5024
5025
5026 @node FSTAT
5027 @section @code{FSTAT} --- Get file status
5028 @fnindex FSTAT
5029 @cindex file system, file status
5030
5031 @table @asis
5032 @item @emph{Description}:
5033 @code{FSTAT} is identical to @ref{STAT}, except that information about an 
5034 already opened file is obtained.
5035
5036 The elements in @code{VALUES} are the same as described by @ref{STAT}.
5037
5038 This intrinsic is provided in both subroutine and function forms; however,
5039 only one form can be used in any given program unit.
5040
5041 @item @emph{Standard}:
5042 GNU extension
5043
5044 @item @emph{Class}:
5045 Subroutine, function
5046
5047 @item @emph{Syntax}:
5048 @multitable @columnfractions .80
5049 @item @code{CALL FSTAT(UNIT, VALUES [, STATUS])}
5050 @item @code{STATUS = FSTAT(UNIT, VALUES)}
5051 @end multitable
5052
5053 @item @emph{Arguments}:
5054 @multitable @columnfractions .15 .70
5055 @item @var{UNIT}   @tab An open I/O unit number of type @code{INTEGER}.
5056 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
5057 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
5058 on success and a system specific error code otherwise.
5059 @end multitable
5060
5061 @item @emph{Example}:
5062 See @ref{STAT} for an example.
5063
5064 @item @emph{See also}:
5065 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
5066 @end table
5067
5068
5069
5070 @node FTELL
5071 @section @code{FTELL} --- Current stream position
5072 @fnindex FTELL
5073 @cindex file operation, position
5074
5075 @table @asis
5076 @item @emph{Description}:
5077 Retrieves the current position within an open file.
5078
5079 This intrinsic is provided in both subroutine and function forms; however,
5080 only one form can be used in any given program unit.
5081
5082 @item @emph{Standard}:
5083 GNU extension
5084
5085 @item @emph{Class}:
5086 Subroutine, function
5087
5088 @item @emph{Syntax}:
5089 @multitable @columnfractions .80
5090 @item @code{CALL FTELL(UNIT, OFFSET)}
5091 @item @code{OFFSET = FTELL(UNIT)}
5092 @end multitable
5093
5094 @item @emph{Arguments}:
5095 @multitable @columnfractions .15 .70
5096 @item @var{OFFSET}  @tab Shall of type @code{INTEGER}.
5097 @item @var{UNIT}    @tab Shall of type @code{INTEGER}.
5098 @end multitable
5099
5100 @item @emph{Return value}:
5101 In either syntax, @var{OFFSET} is set to the current offset of unit
5102 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
5103
5104 @item @emph{Example}:
5105 @smallexample
5106 PROGRAM test_ftell
5107   INTEGER :: i
5108   OPEN(10, FILE="temp.dat")
5109   CALL ftell(10,i)
5110   WRITE(*,*) i
5111 END PROGRAM
5112 @end smallexample
5113
5114 @item @emph{See also}:
5115 @ref{FSEEK}
5116 @end table
5117
5118
5119
5120 @node GAMMA
5121 @section @code{GAMMA} --- Gamma function
5122 @fnindex GAMMA
5123 @fnindex DGAMMA
5124 @cindex Gamma function
5125 @cindex Factorial function
5126
5127 @table @asis
5128 @item @emph{Description}:
5129 @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
5130 integer values of @var{X} the Gamma function simplifies to the factorial
5131 function @math{\Gamma(x)=(x-1)!}.
5132
5133 @tex
5134 $$
5135 \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
5136 $$
5137 @end tex
5138
5139 @item @emph{Standard}:
5140 Fortran 2008 and later
5141
5142 @item @emph{Class}:
5143 Elemental function
5144
5145 @item @emph{Syntax}:
5146 @code{X = GAMMA(X)}
5147
5148 @item @emph{Arguments}:
5149 @multitable @columnfractions .15 .70
5150 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
5151 nor a negative integer.
5152 @end multitable
5153
5154 @item @emph{Return value}:
5155 The return value is of type @code{REAL} of the same kind as @var{X}.
5156
5157 @item @emph{Example}:
5158 @smallexample
5159 program test_gamma
5160   real :: x = 1.0
5161   x = gamma(x) ! returns 1.0
5162 end program test_gamma
5163 @end smallexample
5164
5165 @item @emph{Specific names}:
5166 @multitable @columnfractions .20 .20 .20 .25
5167 @item Name             @tab Argument         @tab Return type       @tab Standard
5168 @item @code{GAMMA(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
5169 @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
5170 @end multitable
5171
5172 @item @emph{See also}:
5173 Logarithm of the Gamma function: @ref{LOG_GAMMA}
5174
5175 @end table
5176
5177
5178
5179 @node GERROR
5180 @section @code{GERROR} --- Get last system error message
5181 @fnindex GERROR
5182 @cindex system, error handling
5183
5184 @table @asis
5185 @item @emph{Description}:
5186 Returns the system error message corresponding to the last system error.
5187 This resembles the functionality of @code{strerror(3)} in C.
5188
5189 @item @emph{Standard}:
5190 GNU extension
5191
5192 @item @emph{Class}:
5193 Subroutine
5194
5195 @item @emph{Syntax}:
5196 @code{CALL GERROR(RESULT)}
5197
5198 @item @emph{Arguments}:
5199 @multitable @columnfractions .15 .70
5200 @item @var{RESULT}  @tab Shall of type @code{CHARACTER} and of default
5201 @end multitable
5202
5203 @item @emph{Example}:
5204 @smallexample
5205 PROGRAM test_gerror
5206   CHARACTER(len=100) :: msg
5207   CALL gerror(msg)
5208   WRITE(*,*) msg
5209 END PROGRAM
5210 @end smallexample
5211
5212 @item @emph{See also}:
5213 @ref{IERRNO}, @ref{PERROR}
5214 @end table
5215
5216
5217
5218 @node GETARG
5219 @section @code{GETARG} --- Get command line arguments
5220 @fnindex GETARG
5221 @cindex command-line arguments
5222 @cindex arguments, to program
5223
5224 @table @asis
5225 @item @emph{Description}:
5226 Retrieve the @var{POS}-th argument that was passed on the
5227 command line when the containing program was invoked.
5228
5229 This intrinsic routine is provided for backwards compatibility with 
5230 GNU Fortran 77.  In new code, programmers should consider the use of 
5231 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003 
5232 standard.
5233
5234 @item @emph{Standard}:
5235 GNU extension
5236
5237 @item @emph{Class}:
5238 Subroutine
5239
5240 @item @emph{Syntax}:
5241 @code{CALL GETARG(POS, VALUE)}
5242
5243 @item @emph{Arguments}:
5244 @multitable @columnfractions .15 .70
5245 @item @var{POS}   @tab Shall be of type @code{INTEGER} and not wider than
5246 the default integer kind; @math{@var{POS} \geq 0}
5247 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
5248 kind.
5249 @item @var{VALUE} @tab Shall be of type @code{CHARACTER}. 
5250 @end multitable
5251
5252 @item @emph{Return value}:
5253 After @code{GETARG} returns, the @var{VALUE} argument holds the
5254 @var{POS}th command line argument. If @var{VALUE} can not hold the
5255 argument, it is truncated to fit the length of @var{VALUE}. If there are
5256 less than @var{POS} arguments specified at the command line, @var{VALUE}
5257 will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
5258 to the name of the program (on systems that support this feature).
5259
5260 @item @emph{Example}:
5261 @smallexample
5262 PROGRAM test_getarg
5263   INTEGER :: i
5264   CHARACTER(len=32) :: arg
5265
5266   DO i = 1, iargc()
5267     CALL getarg(i, arg)
5268     WRITE (*,*) arg
5269   END DO
5270 END PROGRAM
5271 @end smallexample
5272
5273 @item @emph{See also}:
5274 GNU Fortran 77 compatibility function: @ref{IARGC}
5275
5276 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
5277 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
5278 @end table
5279
5280
5281
5282 @node GET_COMMAND
5283 @section @code{GET_COMMAND} --- Get the entire command line
5284 @fnindex GET_COMMAND
5285 @cindex command-line arguments
5286 @cindex arguments, to program
5287
5288 @table @asis
5289 @item @emph{Description}:
5290 Retrieve the entire command line that was used to invoke the program.
5291
5292 @item @emph{Standard}:
5293 Fortran 2003 and later
5294
5295 @item @emph{Class}:
5296 Subroutine
5297
5298 @item @emph{Syntax}:
5299 @code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])}
5300
5301 @item @emph{Arguments}:
5302 @multitable @columnfractions .15 .70
5303 @item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and
5304 of default kind.
5305 @item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of
5306 default kind.
5307 @item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of
5308 default kind.
5309 @end multitable
5310
5311 @item @emph{Return value}:
5312 If @var{COMMAND} is present, stores the entire command line that was used
5313 to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is
5314 assigned the length of the command line. If @var{STATUS} is present, it
5315 is assigned 0 upon success of the command, -1 if @var{COMMAND} is too
5316 short to store the command line, or a positive value in case of an error.
5317
5318 @item @emph{Example}:
5319 @smallexample
5320 PROGRAM test_get_command
5321   CHARACTER(len=255) :: cmd
5322   CALL get_command(cmd)
5323   WRITE (*,*) TRIM(cmd)
5324 END PROGRAM
5325 @end smallexample
5326
5327 @item @emph{See also}:
5328 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
5329 @end table
5330
5331
5332
5333 @node GET_COMMAND_ARGUMENT
5334 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
5335 @fnindex GET_COMMAND_ARGUMENT
5336 @cindex command-line arguments
5337 @cindex arguments, to program
5338
5339 @table @asis
5340 @item @emph{Description}:
5341 Retrieve the @var{NUMBER}-th argument that was passed on the
5342 command line when the containing program was invoked.
5343
5344 @item @emph{Standard}:
5345 Fortran 2003 and later
5346
5347 @item @emph{Class}:
5348 Subroutine
5349
5350 @item @emph{Syntax}:
5351 @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
5352
5353 @item @emph{Arguments}:
5354 @multitable @columnfractions .15 .70
5355 @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of
5356 default kind, @math{@var{NUMBER} \geq 0}
5357 @item @var{VALUE}  @tab Shall be a scalar of type @code{CHARACTER}
5358 and of default kind.
5359 @item @var{LENGTH} @tab (Option) Shall be a scalar of type @code{INTEGER}
5360 and of default kind.
5361 @item @var{STATUS} @tab (Option) Shall be a scalar of type @code{INTEGER}
5362 and of default kind.
5363 @end multitable
5364
5365 @item @emph{Return value}:
5366 After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the 
5367 @var{NUMBER}-th command line argument. If @var{VALUE} can not hold the argument, it is 
5368 truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
5369 arguments specified at the command line, @var{VALUE} will be filled with blanks. 
5370 If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on
5371 systems that support this feature). The @var{LENGTH} argument contains the
5372 length of the @var{NUMBER}-th command line argument. If the argument retrieval
5373 fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated
5374 command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is
5375 zero.
5376
5377 @item @emph{Example}:
5378 @smallexample
5379 PROGRAM test_get_command_argument
5380   INTEGER :: i
5381   CHARACTER(len=32) :: arg
5382
5383   i = 0
5384   DO
5385     CALL get_command_argument(i, arg)
5386     IF (LEN_TRIM(arg) == 0) EXIT
5387
5388     WRITE (*,*) TRIM(arg)
5389     i = i+1
5390   END DO
5391 END PROGRAM
5392 @end smallexample
5393
5394 @item @emph{See also}:
5395 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
5396 @end table
5397
5398
5399
5400 @node GETCWD
5401 @section @code{GETCWD} --- Get current working directory
5402 @fnindex GETCWD
5403 @cindex system, working directory
5404
5405 @table @asis
5406 @item @emph{Description}:
5407 Get current working directory.
5408
5409 This intrinsic is provided in both subroutine and function forms; however,
5410 only one form can be used in any given program unit.
5411
5412 @item @emph{Standard}:
5413 GNU extension
5414
5415 @item @emph{Class}:
5416 Subroutine, function
5417
5418 @item @emph{Syntax}:
5419 @multitable @columnfractions .80
5420 @item @code{CALL GETCWD(C [, STATUS])}
5421 @item @code{STATUS = GETCWD(C)}
5422 @end multitable
5423
5424 @item @emph{Arguments}:
5425 @multitable @columnfractions .15 .70
5426 @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
5427 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success, 
5428 a system specific and nonzero error code otherwise.
5429 @end multitable
5430
5431 @item @emph{Example}:
5432 @smallexample
5433 PROGRAM test_getcwd
5434   CHARACTER(len=255) :: cwd
5435   CALL getcwd(cwd)
5436   WRITE(*,*) TRIM(cwd)
5437 END PROGRAM
5438 @end smallexample
5439
5440 @item @emph{See also}:
5441 @ref{CHDIR}
5442 @end table
5443
5444
5445
5446 @node GETENV
5447 @section @code{GETENV} --- Get an environmental variable
5448 @fnindex GETENV
5449 @cindex environment variable
5450
5451 @table @asis
5452 @item @emph{Description}:
5453 Get the @var{VALUE} of the environmental variable @var{NAME}.
5454
5455 This intrinsic routine is provided for backwards compatibility with 
5456 GNU Fortran 77.  In new code, programmers should consider the use of 
5457 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
5458 2003 standard.
5459
5460 @item @emph{Standard}:
5461 GNU extension
5462
5463 @item @emph{Class}:
5464 Subroutine
5465
5466 @item @emph{Syntax}:
5467 @code{CALL GETENV(NAME, VALUE)}
5468
5469 @item @emph{Arguments}:
5470 @multitable @columnfractions .15 .70
5471 @item @var{NAME}  @tab Shall be of type @code{CHARACTER} and of default kind.
5472 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
5473 @end multitable
5474
5475 @item @emph{Return value}:
5476 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
5477 not large enough to hold the data, it is truncated. If @var{NAME}
5478 is not set, @var{VALUE} will be filled with blanks.
5479
5480 @item @emph{Example}:
5481 @smallexample
5482 PROGRAM test_getenv
5483   CHARACTER(len=255) :: homedir
5484   CALL getenv("HOME", homedir)
5485   WRITE (*,*) TRIM(homedir)
5486 END PROGRAM
5487 @end smallexample
5488
5489 @item @emph{See also}:
5490 @ref{GET_ENVIRONMENT_VARIABLE}
5491 @end table
5492
5493
5494
5495 @node GET_ENVIRONMENT_VARIABLE
5496 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
5497 @fnindex GET_ENVIRONMENT_VARIABLE
5498 @cindex environment variable
5499
5500 @table @asis
5501 @item @emph{Description}:
5502 Get the @var{VALUE} of the environmental variable @var{NAME}.
5503
5504 @item @emph{Standard}:
5505 Fortran 2003 and later
5506
5507 @item @emph{Class}:
5508 Subroutine
5509
5510 @item @emph{Syntax}:
5511 @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
5512
5513 @item @emph{Arguments}:
5514 @multitable @columnfractions .15 .70
5515 @item @var{NAME}      @tab Shall be a scalar of type @code{CHARACTER}
5516 and of default kind.
5517 @item @var{VALUE}     @tab Shall be a scalar of type @code{CHARACTER}
5518 and of default kind.
5519 @item @var{LENGTH}    @tab Shall be a scalar of type @code{INTEGER}
5520 and of default kind.
5521 @item @var{STATUS}    @tab Shall be a scalar of type @code{INTEGER}
5522 and of default kind.
5523 @item @var{TRIM_NAME} @tab Shall be a scalar of type @code{LOGICAL}
5524 and of default kind.
5525 @end multitable
5526
5527 @item @emph{Return value}:
5528 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
5529 not large enough to hold the data, it is truncated. If @var{NAME}
5530 is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
5531 contains the length needed for storing the environment variable @var{NAME}
5532 or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
5533 but too short for the environment variable; it is 1 if the environment
5534 variable does not exist and 2 if the processor does not support environment
5535 variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
5536 present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
5537 are significant; otherwise they are not part of the environment variable
5538 name.
5539
5540 @item @emph{Example}:
5541 @smallexample
5542 PROGRAM test_getenv
5543   CHARACTER(len=255) :: homedir
5544   CALL get_environment_variable("HOME", homedir)
5545   WRITE (*,*) TRIM(homedir)
5546 END PROGRAM
5547 @end smallexample
5548 @end table
5549
5550
5551
5552 @node GETGID
5553 @section @code{GETGID} --- Group ID function
5554 @fnindex GETGID
5555 @cindex system, group ID
5556
5557 @table @asis
5558 @item @emph{Description}:
5559 Returns the numerical group ID of the current process.
5560
5561 @item @emph{Standard}:
5562 GNU extension
5563
5564 @item @emph{Class}:
5565 Function
5566
5567 @item @emph{Syntax}:
5568 @code{RESULT = GETGID()}
5569
5570 @item @emph{Return value}:
5571 The return value of @code{GETGID} is an @code{INTEGER} of the default
5572 kind.
5573
5574
5575 @item @emph{Example}:
5576 See @code{GETPID} for an example.
5577
5578 @item @emph{See also}:
5579 @ref{GETPID}, @ref{GETUID}
5580 @end table
5581
5582
5583
5584 @node GETLOG
5585 @section @code{GETLOG} --- Get login name
5586 @fnindex GETLOG
5587 @cindex system, login name
5588 @cindex login name
5589
5590 @table @asis
5591 @item @emph{Description}:
5592 Gets the username under which the program is running.
5593
5594 @item @emph{Standard}:
5595 GNU extension
5596
5597 @item @emph{Class}:
5598 Subroutine
5599
5600 @item @emph{Syntax}:
5601 @code{CALL GETLOG(C)}
5602
5603 @item @emph{Arguments}:
5604 @multitable @columnfractions .15 .70
5605 @item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
5606 @end multitable
5607
5608 @item @emph{Return value}:
5609 Stores the current user name in @var{LOGIN}.  (On systems where POSIX
5610 functions @code{geteuid} and @code{getpwuid} are not available, and 
5611 the @code{getlogin} function is not implemented either, this will
5612 return a blank string.)
5613
5614 @item @emph{Example}:
5615 @smallexample
5616 PROGRAM TEST_GETLOG
5617   CHARACTER(32) :: login
5618   CALL GETLOG(login)
5619   WRITE(*,*) login
5620 END PROGRAM
5621 @end smallexample
5622
5623 @item @emph{See also}:
5624 @ref{GETUID}
5625 @end table
5626
5627
5628
5629 @node GETPID
5630 @section @code{GETPID} --- Process ID function
5631 @fnindex GETPID
5632 @cindex system, process ID
5633 @cindex process ID
5634
5635 @table @asis
5636 @item @emph{Description}:
5637 Returns the numerical process identifier of the current process.
5638
5639 @item @emph{Standard}:
5640 GNU extension
5641
5642 @item @emph{Class}:
5643 Function
5644
5645 @item @emph{Syntax}:
5646 @code{RESULT = GETPID()}
5647
5648 @item @emph{Return value}:
5649 The return value of @code{GETPID} is an @code{INTEGER} of the default
5650 kind.
5651
5652
5653 @item @emph{Example}:
5654 @smallexample
5655 program info
5656   print *, "The current process ID is ", getpid()
5657   print *, "Your numerical user ID is ", getuid()
5658   print *, "Your numerical group ID is ", getgid()
5659 end program info
5660 @end smallexample
5661
5662 @item @emph{See also}:
5663 @ref{GETGID}, @ref{GETUID}
5664 @end table
5665
5666
5667
5668 @node GETUID
5669 @section @code{GETUID} --- User ID function
5670 @fnindex GETUID
5671 @cindex system, user ID
5672 @cindex user id
5673
5674 @table @asis
5675 @item @emph{Description}:
5676 Returns the numerical user ID of the current process.
5677
5678 @item @emph{Standard}:
5679 GNU extension
5680
5681 @item @emph{Class}:
5682 Function
5683
5684 @item @emph{Syntax}:
5685 @code{RESULT = GETUID()}
5686
5687 @item @emph{Return value}:
5688 The return value of @code{GETUID} is an @code{INTEGER} of the default
5689 kind.
5690
5691
5692 @item @emph{Example}:
5693 See @code{GETPID} for an example.
5694
5695 @item @emph{See also}:
5696 @ref{GETPID}, @ref{GETLOG}
5697 @end table
5698
5699
5700
5701 @node GMTIME
5702 @section @code{GMTIME} --- Convert time to GMT info
5703 @fnindex GMTIME
5704 @cindex time, conversion to GMT info
5705
5706 @table @asis
5707 @item @emph{Description}:
5708 Given a system time value @var{TIME} (as provided by the @code{TIME8()}
5709 intrinsic), fills @var{VALUES} with values extracted from it appropriate
5710 to the UTC time zone (Universal Coordinated Time, also known in some
5711 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
5712
5713 @item @emph{Standard}:
5714 GNU extension
5715
5716 @item @emph{Class}:
5717 Subroutine
5718
5719 @item @emph{Syntax}:
5720 @code{CALL GMTIME(TIME, VALUES)}
5721
5722 @item @emph{Arguments}:
5723 @multitable @columnfractions .15 .70
5724 @item @var{TIME}   @tab An @code{INTEGER} scalar expression
5725 corresponding to a system time, with @code{INTENT(IN)}.
5726 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
5727 with @code{INTENT(OUT)}.
5728 @end multitable
5729
5730 @item @emph{Return value}:
5731 The elements of @var{VALUES} are assigned as follows:
5732 @enumerate
5733 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
5734 seconds
5735 @item Minutes after the hour, range 0--59
5736 @item Hours past midnight, range 0--23
5737 @item Day of month, range 0--31
5738 @item Number of months since January, range 0--12
5739 @item Years since 1900
5740 @item Number of days since Sunday, range 0--6
5741 @item Days since January 1
5742 @item Daylight savings indicator: positive if daylight savings is in
5743 effect, zero if not, and negative if the information is not available.
5744 @end enumerate
5745
5746 @item @emph{See also}:
5747 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
5748
5749 @end table
5750
5751
5752
5753 @node HOSTNM
5754 @section @code{HOSTNM} --- Get system host name
5755 @fnindex HOSTNM
5756 @cindex system, host name
5757
5758 @table @asis
5759 @item @emph{Description}:
5760 Retrieves the host name of the system on which the program is running.
5761
5762 This intrinsic is provided in both subroutine and function forms; however,
5763 only one form can be used in any given program unit.
5764
5765 @item @emph{Standard}:
5766 GNU extension
5767
5768 @item @emph{Class}:
5769 Subroutine, function
5770
5771 @item @emph{Syntax}:
5772 @multitable @columnfractions .80
5773 @item @code{CALL HOSTNM(C [, STATUS])}
5774 @item @code{STATUS = HOSTNM(NAME)}
5775 @end multitable
5776
5777 @item @emph{Arguments}:
5778 @multitable @columnfractions .15 .70
5779 @item @var{C}    @tab Shall of type @code{CHARACTER} and of default kind.
5780 @item @var{STATUS}  @tab (Optional) status flag of type @code{INTEGER}.
5781 Returns 0 on success, or a system specific error code otherwise.
5782 @end multitable
5783
5784 @item @emph{Return value}:
5785 In either syntax, @var{NAME} is set to the current hostname if it can
5786 be obtained, or to a blank string otherwise.
5787
5788 @end table
5789
5790
5791
5792 @node HUGE
5793 @section @code{HUGE} --- Largest number of a kind
5794 @fnindex HUGE
5795 @cindex limits, largest number
5796 @cindex model representation, largest number
5797
5798 @table @asis
5799 @item @emph{Description}:
5800 @code{HUGE(X)} returns the largest number that is not an infinity in
5801 the model of the type of @code{X}.
5802
5803 @item @emph{Standard}:
5804 Fortran 95 and later
5805
5806 @item @emph{Class}:
5807 Inquiry function
5808
5809 @item @emph{Syntax}:
5810 @code{RESULT = HUGE(X)}
5811
5812 @item @emph{Arguments}:
5813 @multitable @columnfractions .15 .70
5814 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
5815 @end multitable
5816
5817 @item @emph{Return value}:
5818 The return value is of the same type and kind as @var{X}
5819
5820 @item @emph{Example}:
5821 @smallexample
5822 program test_huge_tiny
5823   print *, huge(0), huge(0.0), huge(0.0d0)
5824   print *, tiny(0.0), tiny(0.0d0)
5825 end program test_huge_tiny
5826 @end smallexample
5827 @end table
5828
5829
5830
5831 @node HYPOT
5832 @section @code{HYPOT} --- Euclidean distance function
5833 @fnindex HYPOT
5834 @cindex Euclidean distance
5835
5836 @table @asis
5837 @item @emph{Description}:
5838 @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
5839 @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
5840
5841 @item @emph{Standard}:
5842 Fortran 2008 and later
5843
5844 @item @emph{Class}:
5845 Elemental function
5846
5847 @item @emph{Syntax}:
5848 @code{RESULT = HYPOT(X, Y)}
5849
5850 @item @emph{Arguments}:
5851 @multitable @columnfractions .15 .70
5852 @item @var{X} @tab The type shall be @code{REAL}.
5853 @item @var{Y} @tab The type and kind type parameter shall be the same as
5854 @var{X}.
5855 @end multitable
5856
5857 @item @emph{Return value}:
5858 The return value has the same type and kind type parameter as @var{X}.
5859
5860 @item @emph{Example}:
5861 @smallexample
5862 program test_hypot
5863   real(4) :: x = 1.e0_4, y = 0.5e0_4
5864   x = hypot(x,y)
5865 end program test_hypot
5866 @end smallexample
5867 @end table
5868
5869
5870
5871 @node IACHAR
5872 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence 
5873 @fnindex IACHAR
5874 @cindex @acronym{ASCII} collating sequence
5875 @cindex collating sequence, @acronym{ASCII}
5876 @cindex conversion, to integer
5877
5878 @table @asis
5879 @item @emph{Description}:
5880 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
5881 in the first character position of @code{C}.
5882
5883 @item @emph{Standard}:
5884 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
5885
5886 @item @emph{Class}:
5887 Elemental function
5888
5889 @item @emph{Syntax}:
5890 @code{RESULT = IACHAR(C [, KIND])}
5891
5892 @item @emph{Arguments}:
5893 @multitable @columnfractions .15 .70
5894 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5895 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5896 expression indicating the kind parameter of the result.
5897 @end multitable
5898
5899 @item @emph{Return value}:
5900 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5901 @var{KIND} is absent, the return value is of default integer kind.
5902
5903 @item @emph{Example}:
5904 @smallexample
5905 program test_iachar
5906   integer i
5907   i = iachar(' ')
5908 end program test_iachar
5909 @end smallexample
5910
5911 @item @emph{Note}:
5912 See @ref{ICHAR} for a discussion of converting between numerical values
5913 and formatted string representations.
5914
5915 @item @emph{See also}:
5916 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
5917
5918 @end table
5919
5920
5921
5922 @node IALL
5923 @section @code{IALL} --- Bitwise AND of array elements
5924 @fnindex IALL
5925 @cindex array, AND
5926 @cindex bits, AND of array elements
5927
5928 @table @asis
5929 @item @emph{Description}:
5930 Reduces with bitwise AND the elements of @var{ARRAY} along dimension @var{DIM}
5931 if the corresponding element in @var{MASK} is @code{TRUE}.
5932
5933 @item @emph{Standard}:
5934 Fortran 2008 and later
5935
5936 @item @emph{Class}:
5937 Transformational function
5938
5939 @item @emph{Syntax}:
5940 @multitable @columnfractions .80
5941 @item @code{RESULT = IALL(ARRAY[, MASK])}
5942 @item @code{RESULT = IALL(ARRAY, DIM[, MASK])}
5943 @end multitable
5944
5945 @item @emph{Arguments}:
5946 @multitable @columnfractions .15 .70
5947 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
5948 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
5949 @code{INTEGER} with a value in the range from 1 to n, where n 
5950 equals the rank of @var{ARRAY}.
5951 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
5952 and either be a scalar or an array of the same shape as @var{ARRAY}.
5953 @end multitable
5954
5955 @item @emph{Return value}:
5956 The result is of the same type as @var{ARRAY}.
5957
5958 If @var{DIM} is absent, a scalar with the bitwise ALL of all elements in
5959 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
5960 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
5961 dimension @var{DIM} dropped is returned.
5962
5963 @item @emph{Example}:
5964 @smallexample
5965 PROGRAM test_iall
5966   INTEGER(1) :: a(2)
5967
5968   a(1) = b'00100100'
5969   a(1) = b'01101010'
5970
5971   ! prints 00100000
5972   PRINT '(b8.8)', IALL(a)
5973 END PROGRAM
5974 @end smallexample
5975
5976 @item @emph{See also}:
5977 @ref{IANY}, @ref{IPARITY}, @ref{IAND}
5978 @end table
5979
5980
5981
5982 @node IAND
5983 @section @code{IAND} --- Bitwise logical and
5984 @fnindex IAND
5985 @cindex bitwise logical and
5986 @cindex logical and, bitwise
5987
5988 @table @asis
5989 @item @emph{Description}:
5990 Bitwise logical @code{AND}.
5991
5992 @item @emph{Standard}:
5993 Fortran 95 and later
5994
5995 @item @emph{Class}:
5996 Elemental function
5997
5998 @item @emph{Syntax}:
5999 @code{RESULT = IAND(I, J)}
6000
6001 @item @emph{Arguments}:
6002 @multitable @columnfractions .15 .70
6003 @item @var{I} @tab The type shall be @code{INTEGER}.
6004 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6005 kind as @var{I}.  (As a GNU extension, different kinds are also 
6006 permitted.)
6007 @end multitable
6008
6009 @item @emph{Return value}:
6010 The return type is @code{INTEGER}, of the same kind as the
6011 arguments.  (If the argument kinds differ, it is of the same kind as
6012 the larger argument.)
6013
6014 @item @emph{Example}:
6015 @smallexample
6016 PROGRAM test_iand
6017   INTEGER :: a, b
6018   DATA a / Z'F' /, b / Z'3' /
6019   WRITE (*,*) IAND(a, b)
6020 END PROGRAM
6021 @end smallexample
6022
6023 @item @emph{See also}:
6024 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6025
6026 @end table
6027
6028
6029
6030 @node IANY
6031 @section @code{IANY} --- Bitwise XOR of array elements
6032 @fnindex IANY
6033 @cindex array, OR
6034 @cindex bits, OR of array elements
6035
6036 @table @asis
6037 @item @emph{Description}:
6038 Reduces with bitwise OR (inclusive or) the elements of @var{ARRAY} along
6039 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
6040
6041 @item @emph{Standard}:
6042 Fortran 2008 and later
6043
6044 @item @emph{Class}:
6045 Transformational function
6046
6047 @item @emph{Syntax}:
6048 @multitable @columnfractions .80
6049 @item @code{RESULT = IANY(ARRAY[, MASK])}
6050 @item @code{RESULT = IANY(ARRAY, DIM[, MASK])}
6051 @end multitable
6052
6053 @item @emph{Arguments}:
6054 @multitable @columnfractions .15 .70
6055 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
6056 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
6057 @code{INTEGER} with a value in the range from 1 to n, where n 
6058 equals the rank of @var{ARRAY}.
6059 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
6060 and either be a scalar or an array of the same shape as @var{ARRAY}.
6061 @end multitable
6062
6063 @item @emph{Return value}:
6064 The result is of the same type as @var{ARRAY}.
6065
6066 If @var{DIM} is absent, a scalar with the bitwise OR of all elements in
6067 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
6068 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
6069 dimension @var{DIM} dropped is returned.
6070
6071 @item @emph{Example}:
6072 @smallexample
6073 PROGRAM test_iany
6074   INTEGER(1) :: a(2)
6075
6076   a(1) = b'00100100'
6077   a(1) = b'01101010'
6078
6079   ! prints 01111011
6080   PRINT '(b8.8)', IANY(a)
6081 END PROGRAM
6082 @end smallexample
6083
6084 @item @emph{See also}:
6085 @ref{IPARITY}, @ref{IALL}, @ref{IOR}
6086 @end table
6087
6088
6089
6090 @node IARGC
6091 @section @code{IARGC} --- Get the number of command line arguments
6092 @fnindex IARGC
6093 @cindex command-line arguments
6094 @cindex command-line arguments, number of
6095 @cindex arguments, to program
6096
6097 @table @asis
6098 @item @emph{Description}:
6099 @code{IARGC()} returns the number of arguments passed on the
6100 command line when the containing program was invoked.
6101
6102 This intrinsic routine is provided for backwards compatibility with 
6103 GNU Fortran 77.  In new code, programmers should consider the use of 
6104 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003 
6105 standard.
6106
6107 @item @emph{Standard}:
6108 GNU extension
6109
6110 @item @emph{Class}:
6111 Function
6112
6113 @item @emph{Syntax}:
6114 @code{RESULT = IARGC()}
6115
6116 @item @emph{Arguments}:
6117 None.
6118
6119 @item @emph{Return value}:
6120 The number of command line arguments, type @code{INTEGER(4)}.
6121
6122 @item @emph{Example}:
6123 See @ref{GETARG}
6124
6125 @item @emph{See also}:
6126 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
6127
6128 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
6129 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
6130 @end table
6131
6132
6133
6134 @node IBCLR
6135 @section @code{IBCLR} --- Clear bit
6136 @fnindex IBCLR
6137 @cindex bits, unset
6138 @cindex bits, clear
6139
6140 @table @asis
6141 @item @emph{Description}:
6142 @code{IBCLR} returns the value of @var{I} with the bit at position
6143 @var{POS} set to zero.
6144
6145 @item @emph{Standard}:
6146 Fortran 95 and later
6147
6148 @item @emph{Class}:
6149 Elemental function
6150
6151 @item @emph{Syntax}:
6152 @code{RESULT = IBCLR(I, POS)}
6153
6154 @item @emph{Arguments}:
6155 @multitable @columnfractions .15 .70
6156 @item @var{I} @tab The type shall be @code{INTEGER}.
6157 @item @var{POS} @tab The type shall be @code{INTEGER}.
6158 @end multitable
6159
6160 @item @emph{Return value}:
6161 The return value is of type @code{INTEGER} and of the same kind as
6162 @var{I}.
6163
6164 @item @emph{See also}:
6165 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
6166
6167 @end table
6168
6169
6170
6171 @node IBITS
6172 @section @code{IBITS} --- Bit extraction
6173 @fnindex IBITS
6174 @cindex bits, get
6175 @cindex bits, extract
6176
6177 @table @asis
6178 @item @emph{Description}:
6179 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
6180 starting from bit position @var{POS} and extending left for @var{LEN}
6181 bits.  The result is right-justified and the remaining bits are
6182 zeroed.  The value of @code{POS+LEN} must be less than or equal to the
6183 value @code{BIT_SIZE(I)}.
6184
6185 @item @emph{Standard}:
6186 Fortran 95 and later
6187
6188 @item @emph{Class}:
6189 Elemental function
6190
6191 @item @emph{Syntax}:
6192 @code{RESULT = IBITS(I, POS, LEN)}
6193
6194 @item @emph{Arguments}:
6195 @multitable @columnfractions .15 .70
6196 @item @var{I}   @tab The type shall be @code{INTEGER}.
6197 @item @var{POS} @tab The type shall be @code{INTEGER}.
6198 @item @var{LEN} @tab The type shall be @code{INTEGER}.
6199 @end multitable
6200
6201 @item @emph{Return value}:
6202 The return value is of type @code{INTEGER} and of the same kind as
6203 @var{I}.
6204
6205 @item @emph{See also}:
6206 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
6207 @end table
6208
6209
6210
6211 @node IBSET
6212 @section @code{IBSET} --- Set bit
6213 @fnindex IBSET
6214 @cindex bits, set
6215
6216 @table @asis
6217 @item @emph{Description}:
6218 @code{IBSET} returns the value of @var{I} with the bit at position
6219 @var{POS} set to one.
6220
6221 @item @emph{Standard}:
6222 Fortran 95 and later
6223
6224 @item @emph{Class}:
6225 Elemental function
6226
6227 @item @emph{Syntax}:
6228 @code{RESULT = IBSET(I, POS)}
6229
6230 @item @emph{Arguments}:
6231 @multitable @columnfractions .15 .70
6232 @item @var{I} @tab The type shall be @code{INTEGER}.
6233 @item @var{POS} @tab The type shall be @code{INTEGER}.
6234 @end multitable
6235
6236 @item @emph{Return value}:
6237 The return value is of type @code{INTEGER} and of the same kind as
6238 @var{I}.
6239
6240 @item @emph{See also}:
6241 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
6242
6243 @end table
6244
6245
6246
6247 @node ICHAR
6248 @section @code{ICHAR} --- Character-to-integer conversion function
6249 @fnindex ICHAR
6250 @cindex conversion, to integer
6251
6252 @table @asis
6253 @item @emph{Description}:
6254 @code{ICHAR(C)} returns the code for the character in the first character
6255 position of @code{C} in the system's native character set.
6256 The correspondence between characters and their codes is not necessarily
6257 the same across different GNU Fortran implementations.
6258
6259 @item @emph{Standard}:
6260 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6261
6262 @item @emph{Class}:
6263 Elemental function
6264
6265 @item @emph{Syntax}:
6266 @code{RESULT = ICHAR(C [, KIND])}
6267
6268 @item @emph{Arguments}:
6269 @multitable @columnfractions .15 .70
6270 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
6271 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6272 expression indicating the kind parameter of the result.
6273 @end multitable
6274
6275 @item @emph{Return value}:
6276 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6277 @var{KIND} is absent, the return value is of default integer kind.
6278
6279 @item @emph{Example}:
6280 @smallexample
6281 program test_ichar
6282   integer i
6283   i = ichar(' ')
6284 end program test_ichar
6285 @end smallexample
6286
6287 @item @emph{Specific names}:
6288 @multitable @columnfractions .20 .20 .20 .25
6289 @item Name             @tab Argument             @tab Return type       @tab Standard
6290 @item @code{ICHAR(C)}  @tab @code{CHARACTER C}   @tab @code{INTEGER(4)}    @tab Fortran 77 and later
6291 @end multitable
6292
6293 @item @emph{Note}:
6294 No intrinsic exists to convert between a numeric value and a formatted
6295 character string representation -- for instance, given the
6296 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
6297 @code{REAL} value with the value 154, or vice versa. Instead, this
6298 functionality is provided by internal-file I/O, as in the following
6299 example:
6300 @smallexample
6301 program read_val
6302   integer value
6303   character(len=10) string, string2
6304   string = '154'
6305   
6306   ! Convert a string to a numeric value
6307   read (string,'(I10)') value
6308   print *, value
6309   
6310   ! Convert a value to a formatted string
6311   write (string2,'(I10)') value
6312   print *, string2
6313 end program read_val
6314 @end smallexample
6315
6316 @item @emph{See also}:
6317 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
6318
6319 @end table
6320
6321
6322
6323 @node IDATE
6324 @section @code{IDATE} --- Get current local time subroutine (day/month/year) 
6325 @fnindex IDATE
6326 @cindex date, current
6327 @cindex current date
6328
6329 @table @asis
6330 @item @emph{Description}:
6331 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the  
6332 current local time. The day (in the range 1-31), month (in the range 1-12), 
6333 and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively. 
6334 The year has four significant digits.
6335
6336 @item @emph{Standard}:
6337 GNU extension
6338
6339 @item @emph{Class}:
6340 Subroutine
6341
6342 @item @emph{Syntax}:
6343 @code{CALL IDATE(VALUES)}
6344
6345 @item @emph{Arguments}:
6346 @multitable @columnfractions .15 .70
6347 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
6348 the kind shall be the default integer kind.
6349 @end multitable
6350
6351 @item @emph{Return value}:
6352 Does not return anything.
6353
6354 @item @emph{Example}:
6355 @smallexample
6356 program test_idate
6357   integer, dimension(3) :: tarray
6358   call idate(tarray)
6359   print *, tarray(1)
6360   print *, tarray(2)
6361   print *, tarray(3)
6362 end program test_idate
6363 @end smallexample
6364 @end table
6365
6366
6367
6368 @node IEOR
6369 @section @code{IEOR} --- Bitwise logical exclusive or
6370 @fnindex IEOR
6371 @cindex bitwise logical exclusive or
6372 @cindex logical exclusive or, bitwise
6373
6374 @table @asis
6375 @item @emph{Description}:
6376 @code{IEOR} returns the bitwise Boolean exclusive-OR of @var{I} and
6377 @var{J}.
6378
6379 @item @emph{Standard}:
6380 Fortran 95 and later
6381
6382 @item @emph{Class}:
6383 Elemental function
6384
6385 @item @emph{Syntax}:
6386 @code{RESULT = IEOR(I, J)}
6387
6388 @item @emph{Arguments}:
6389 @multitable @columnfractions .15 .70
6390 @item @var{I} @tab The type shall be @code{INTEGER}.
6391 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6392 kind as @var{I}.  (As a GNU extension, different kinds are also 
6393 permitted.)
6394 @end multitable
6395
6396 @item @emph{Return value}:
6397 The return type is @code{INTEGER}, of the same kind as the
6398 arguments.  (If the argument kinds differ, it is of the same kind as
6399 the larger argument.)
6400
6401 @item @emph{See also}:
6402 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6403 @end table
6404
6405
6406
6407 @node IERRNO
6408 @section @code{IERRNO} --- Get the last system error number
6409 @fnindex IERRNO
6410 @cindex system, error handling
6411
6412 @table @asis
6413 @item @emph{Description}:
6414 Returns the last system error number, as given by the C @code{errno()}
6415 function.
6416
6417 @item @emph{Standard}:
6418 GNU extension
6419
6420 @item @emph{Class}:
6421 Function
6422
6423 @item @emph{Syntax}:
6424 @code{RESULT = IERRNO()}
6425
6426 @item @emph{Arguments}:
6427 None.
6428
6429 @item @emph{Return value}:
6430 The return value is of type @code{INTEGER} and of the default integer
6431 kind.
6432
6433 @item @emph{See also}:
6434 @ref{PERROR}
6435 @end table
6436
6437
6438
6439 @node IMAGE_INDEX
6440 @section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index
6441 @fnindex IMAGE_INDEX
6442 @cindex coarray, @code{IMAGE_INDEX}
6443 @cindex images, cosubscript to image index conversion
6444
6445 @table @asis
6446 @item @emph{Description}:
6447 Returns the image index belonging to a cosubscript.
6448
6449 @item @emph{Standard}:
6450 Fortran 2008 and later
6451
6452 @item @emph{Class}:
6453 Inquiry function.
6454
6455 @item @emph{Syntax}:
6456 @code{RESULT = IMAGE_INDEX(COARRAY, SUB)}
6457
6458 @item @emph{Arguments}: None.
6459 @multitable @columnfractions .15 .70
6460 @item @var{COARRAY} @tab Coarray of any type.
6461 @item @var{SUB}     @tab default integer rank-1 array of a size equal to
6462 the corank of @var{COARRAY}.
6463 @end multitable
6464
6465
6466 @item @emph{Return value}:
6467 Scalar default integer with the value of the image index which corresponds
6468 to the cosubscripts. For invalid cosubscripts the result is zero.
6469
6470 @item @emph{Example}:
6471 @smallexample
6472 INTEGER :: array[2,-1:4,8,*]
6473 ! Writes  28 (or 0 if there are fewer than 28 images)
6474 WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1])
6475 @end smallexample
6476
6477 @item @emph{See also}:
6478 @ref{THIS_IMAGE}, @ref{NUM_IMAGES}
6479 @end table
6480
6481
6482
6483 @node INDEX intrinsic
6484 @section @code{INDEX} --- Position of a substring within a string
6485 @fnindex INDEX
6486 @cindex substring position
6487 @cindex string, find substring
6488
6489 @table @asis
6490 @item @emph{Description}:
6491 Returns the position of the start of the first occurrence of string
6492 @var{SUBSTRING} as a substring in @var{STRING}, counting from one.  If
6493 @var{SUBSTRING} is not present in @var{STRING}, zero is returned.  If 
6494 the @var{BACK} argument is present and true, the return value is the
6495 start of the last occurrence rather than the first.
6496
6497 @item @emph{Standard}:
6498 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
6499
6500 @item @emph{Class}:
6501 Elemental function
6502
6503 @item @emph{Syntax}:
6504 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
6505
6506 @item @emph{Arguments}:
6507 @multitable @columnfractions .15 .70
6508 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
6509 @code{INTENT(IN)}
6510 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
6511 @code{INTENT(IN)}
6512 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
6513 @code{INTENT(IN)}
6514 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6515 expression indicating the kind parameter of the result.
6516 @end multitable
6517
6518 @item @emph{Return value}:
6519 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6520 @var{KIND} is absent, the return value is of default integer kind.
6521
6522 @item @emph{Specific names}:
6523 @multitable @columnfractions .20 .20 .20 .25
6524 @item Name                            @tab Argument           @tab Return type       @tab Standard
6525 @item @code{INDEX(STRING, SUBSTRING)} @tab @code{CHARACTER}   @tab @code{INTEGER(4)} @tab Fortran 77 and later
6526 @end multitable
6527
6528 @item @emph{See also}:
6529 @ref{SCAN}, @ref{VERIFY}
6530 @end table
6531
6532
6533
6534 @node INT
6535 @section @code{INT} --- Convert to integer type
6536 @fnindex INT
6537 @fnindex IFIX
6538 @fnindex IDINT
6539 @cindex conversion, to integer
6540
6541 @table @asis
6542 @item @emph{Description}:
6543 Convert to integer type
6544
6545 @item @emph{Standard}:
6546 Fortran 77 and later
6547
6548 @item @emph{Class}:
6549 Elemental function
6550
6551 @item @emph{Syntax}:
6552 @code{RESULT = INT(A [, KIND))}
6553
6554 @item @emph{Arguments}:
6555 @multitable @columnfractions .15 .70
6556 @item @var{A}    @tab Shall be of type @code{INTEGER},
6557 @code{REAL}, or @code{COMPLEX}.
6558 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6559 expression indicating the kind parameter of the result.
6560 @end multitable
6561
6562 @item @emph{Return value}:
6563 These functions return a @code{INTEGER} variable or array under 
6564 the following rules: 
6565
6566 @table @asis
6567 @item (A)
6568 If @var{A} is of type @code{INTEGER}, @code{INT(A) = A} 
6569 @item (B)
6570 If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} equals @code{0}. 
6571 If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed 
6572 the range of @var{A} and whose sign is the same as the sign of @var{A}.
6573 @item (C)
6574 If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
6575 @end table
6576
6577 @item @emph{Example}:
6578 @smallexample
6579 program test_int
6580   integer :: i = 42
6581   complex :: z = (-3.7, 1.0)
6582   print *, int(i)
6583   print *, int(z), int(z,8)
6584 end program
6585 @end smallexample
6586
6587 @item @emph{Specific names}:
6588 @multitable @columnfractions .20 .20 .20 .25
6589 @item Name            @tab Argument          @tab Return type       @tab Standard
6590 @item @code{INT(A)}   @tab @code{REAL(4) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
6591 @item @code{IFIX(A)}  @tab @code{REAL(4) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
6592 @item @code{IDINT(A)} @tab @code{REAL(8) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
6593 @end multitable
6594
6595 @end table
6596
6597
6598 @node INT2
6599 @section @code{INT2} --- Convert to 16-bit integer type
6600 @fnindex INT2
6601 @fnindex SHORT
6602 @cindex conversion, to integer
6603
6604 @table @asis
6605 @item @emph{Description}:
6606 Convert to a @code{KIND=2} integer type. This is equivalent to the
6607 standard @code{INT} intrinsic with an optional argument of
6608 @code{KIND=2}, and is only included for backwards compatibility.
6609
6610 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
6611
6612 @item @emph{Standard}:
6613 GNU extension
6614
6615 @item @emph{Class}:
6616 Elemental function
6617
6618 @item @emph{Syntax}:
6619 @code{RESULT = INT2(A)}
6620
6621 @item @emph{Arguments}:
6622 @multitable @columnfractions .15 .70
6623 @item @var{A}    @tab Shall be of type @code{INTEGER},
6624 @code{REAL}, or @code{COMPLEX}.
6625 @end multitable
6626
6627 @item @emph{Return value}:
6628 The return value is a @code{INTEGER(2)} variable.
6629
6630 @item @emph{See also}:
6631 @ref{INT}, @ref{INT8}, @ref{LONG}
6632 @end table
6633
6634
6635
6636 @node INT8
6637 @section @code{INT8} --- Convert to 64-bit integer type
6638 @fnindex INT8
6639 @cindex conversion, to integer
6640
6641 @table @asis
6642 @item @emph{Description}:
6643 Convert to a @code{KIND=8} integer type. This is equivalent to the
6644 standard @code{INT} intrinsic with an optional argument of
6645 @code{KIND=8}, and is only included for backwards compatibility.
6646
6647 @item @emph{Standard}:
6648 GNU extension
6649
6650 @item @emph{Class}:
6651 Elemental function
6652
6653 @item @emph{Syntax}:
6654 @code{RESULT = INT8(A)}
6655
6656 @item @emph{Arguments}:
6657 @multitable @columnfractions .15 .70
6658 @item @var{A}    @tab Shall be of type @code{INTEGER},
6659 @code{REAL}, or @code{COMPLEX}.
6660 @end multitable
6661
6662 @item @emph{Return value}:
6663 The return value is a @code{INTEGER(8)} variable.
6664
6665 @item @emph{See also}:
6666 @ref{INT}, @ref{INT2}, @ref{LONG}
6667 @end table
6668
6669
6670
6671 @node IOR
6672 @section @code{IOR} --- Bitwise logical or
6673 @fnindex IOR
6674 @cindex bitwise logical or
6675 @cindex logical or, bitwise
6676
6677 @table @asis
6678 @item @emph{Description}:
6679 @code{IOR} returns the bitwise Boolean inclusive-OR of @var{I} and
6680 @var{J}.
6681
6682 @item @emph{Standard}:
6683 Fortran 95 and later
6684
6685 @item @emph{Class}:
6686 Elemental function
6687
6688 @item @emph{Syntax}:
6689 @code{RESULT = IOR(I, J)}
6690
6691 @item @emph{Arguments}:
6692 @multitable @columnfractions .15 .70
6693 @item @var{I} @tab The type shall be @code{INTEGER}.
6694 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6695 kind as @var{I}.  (As a GNU extension, different kinds are also 
6696 permitted.)
6697 @end multitable
6698
6699 @item @emph{Return value}:
6700 The return type is @code{INTEGER}, of the same kind as the
6701 arguments.  (If the argument kinds differ, it is of the same kind as
6702 the larger argument.)
6703
6704 @item @emph{See also}:
6705 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6706 @end table
6707
6708
6709
6710 @node IPARITY
6711 @section @code{IPARITY} --- Bitwise XOR of array elements
6712 @fnindex IPARITY
6713 @cindex array, parity
6714 @cindex array, XOR
6715 @cindex bits, XOR of array elements
6716
6717 @table @asis
6718 @item @emph{Description}:
6719 Reduces with bitwise XOR (exclusive or) the elements of @var{ARRAY} along
6720 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
6721
6722 @item @emph{Standard}:
6723 Fortran 2008 and later
6724
6725 @item @emph{Class}:
6726 Transformational function
6727
6728 @item @emph{Syntax}:
6729 @multitable @columnfractions .80
6730 @item @code{RESULT = IPARITY(ARRAY[, MASK])}
6731 @item @code{RESULT = IPARITY(ARRAY, DIM[, MASK])}
6732 @end multitable
6733
6734 @item @emph{Arguments}:
6735 @multitable @columnfractions .15 .70
6736 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
6737 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
6738 @code{INTEGER} with a value in the range from 1 to n, where n 
6739 equals the rank of @var{ARRAY}.
6740 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
6741 and either be a scalar or an array of the same shape as @var{ARRAY}.
6742 @end multitable
6743
6744 @item @emph{Return value}:
6745 The result is of the same type as @var{ARRAY}.
6746
6747 If @var{DIM} is absent, a scalar with the bitwise XOR of all elements in
6748 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
6749 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
6750 dimension @var{DIM} dropped is returned.
6751
6752 @item @emph{Example}:
6753 @smallexample
6754 PROGRAM test_iparity
6755   INTEGER(1) :: a(2)
6756
6757   a(1) = b'00100100'
6758   a(1) = b'01101010'
6759
6760   ! prints 10111011
6761   PRINT '(b8.8)', IPARITY(a)
6762 END PROGRAM
6763 @end smallexample
6764
6765 @item @emph{See also}:
6766 @ref{IANY}, @ref{IALL}, @ref{IEOR}, @ref{PARITY}
6767 @end table
6768
6769
6770
6771 @node IRAND
6772 @section @code{IRAND} --- Integer pseudo-random number
6773 @fnindex IRAND
6774 @cindex random number generation
6775
6776 @table @asis
6777 @item @emph{Description}:
6778 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
6779 distribution between 0 and a system-dependent limit (which is in most
6780 cases 2147483647). If @var{FLAG} is 0, the next number
6781 in the current sequence is returned; if @var{FLAG} is 1, the generator
6782 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
6783 it is used as a new seed with @code{SRAND}.
6784
6785 This intrinsic routine is provided for backwards compatibility with
6786 GNU Fortran 77. It implements a simple modulo generator as provided 
6787 by @command{g77}. For new code, one should consider the use of 
6788 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
6789
6790 @item @emph{Standard}:
6791 GNU extension
6792
6793 @item @emph{Class}:
6794 Function
6795
6796 @item @emph{Syntax}:
6797 @code{RESULT = IRAND(I)}
6798
6799 @item @emph{Arguments}:
6800 @multitable @columnfractions .15 .70
6801 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
6802 @end multitable
6803
6804 @item @emph{Return value}:
6805 The return value is of @code{INTEGER(kind=4)} type.
6806
6807 @item @emph{Example}:
6808 @smallexample
6809 program test_irand
6810   integer,parameter :: seed = 86456
6811   
6812   call srand(seed)
6813   print *, irand(), irand(), irand(), irand()
6814   print *, irand(seed), irand(), irand(), irand()
6815 end program test_irand
6816 @end smallexample
6817
6818 @end table
6819
6820
6821
6822 @node IS_IOSTAT_END
6823 @section @code{IS_IOSTAT_END} --- Test for end-of-file value
6824 @fnindex IS_IOSTAT_END
6825 @cindex @code{IOSTAT}, end of file
6826
6827 @table @asis
6828 @item @emph{Description}:
6829 @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
6830 status ``end of file''. The function is equivalent to comparing the variable
6831 with the @code{IOSTAT_END} parameter of the intrinsic module
6832 @code{ISO_FORTRAN_ENV}.
6833
6834 @item @emph{Standard}:
6835 Fortran 2003 and later
6836
6837 @item @emph{Class}:
6838 Elemental function
6839
6840 @item @emph{Syntax}:
6841 @code{RESULT = IS_IOSTAT_END(I)}
6842
6843 @item @emph{Arguments}:
6844 @multitable @columnfractions .15 .70
6845 @item @var{I} @tab Shall be of the type @code{INTEGER}.
6846 @end multitable
6847
6848 @item @emph{Return value}:
6849 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6850 @var{I} has the value which indicates an end of file condition for
6851 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
6852
6853 @item @emph{Example}:
6854 @smallexample
6855 PROGRAM iostat
6856   IMPLICIT NONE
6857   INTEGER :: stat, i
6858   OPEN(88, FILE='test.dat')
6859   READ(88, *, IOSTAT=stat) i
6860   IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
6861 END PROGRAM
6862 @end smallexample
6863 @end table
6864
6865
6866
6867 @node IS_IOSTAT_EOR
6868 @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
6869 @fnindex IS_IOSTAT_EOR
6870 @cindex @code{IOSTAT}, end of record
6871
6872 @table @asis
6873 @item @emph{Description}:
6874 @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
6875 status ``end of record''. The function is equivalent to comparing the
6876 variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
6877 @code{ISO_FORTRAN_ENV}.
6878
6879 @item @emph{Standard}:
6880 Fortran 2003 and later
6881
6882 @item @emph{Class}:
6883 Elemental function
6884
6885 @item @emph{Syntax}:
6886 @code{RESULT = IS_IOSTAT_EOR(I)}
6887
6888 @item @emph{Arguments}:
6889 @multitable @columnfractions .15 .70
6890 @item @var{I} @tab Shall be of the type @code{INTEGER}.
6891 @end multitable
6892
6893 @item @emph{Return value}:
6894 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6895 @var{I} has the value which indicates an end of file condition for
6896 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
6897
6898 @item @emph{Example}:
6899 @smallexample
6900 PROGRAM iostat
6901   IMPLICIT NONE
6902   INTEGER :: stat, i(50)
6903   OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
6904   READ(88, IOSTAT=stat) i
6905   IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
6906 END PROGRAM
6907 @end smallexample
6908 @end table
6909
6910
6911
6912 @node ISATTY
6913 @section @code{ISATTY} --- Whether a unit is a terminal device.
6914 @fnindex ISATTY
6915 @cindex system, terminal
6916
6917 @table @asis
6918 @item @emph{Description}:
6919 Determine whether a unit is connected to a terminal device.
6920
6921 @item @emph{Standard}:
6922 GNU extension
6923
6924 @item @emph{Class}:
6925 Function
6926
6927 @item @emph{Syntax}:
6928 @code{RESULT = ISATTY(UNIT)}
6929
6930 @item @emph{Arguments}:
6931 @multitable @columnfractions .15 .70
6932 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
6933 @end multitable
6934
6935 @item @emph{Return value}:
6936 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal 
6937 device, @code{.FALSE.} otherwise.
6938
6939 @item @emph{Example}:
6940 @smallexample
6941 PROGRAM test_isatty
6942   INTEGER(kind=1) :: unit
6943   DO unit = 1, 10
6944     write(*,*) isatty(unit=unit)
6945   END DO
6946 END PROGRAM
6947 @end smallexample
6948 @item @emph{See also}:
6949 @ref{TTYNAM}
6950 @end table
6951
6952
6953
6954 @node ISHFT
6955 @section @code{ISHFT} --- Shift bits
6956 @fnindex ISHFT
6957 @cindex bits, shift
6958
6959 @table @asis
6960 @item @emph{Description}:
6961 @code{ISHFT} returns a value corresponding to @var{I} with all of the
6962 bits shifted @var{SHIFT} places.  A value of @var{SHIFT} greater than
6963 zero corresponds to a left shift, a value of zero corresponds to no
6964 shift, and a value less than zero corresponds to a right shift.  If the
6965 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
6966 value is undefined.  Bits shifted out from the left end or right end are
6967 lost; zeros are shifted in from the opposite end.
6968
6969 @item @emph{Standard}:
6970 Fortran 95 and later
6971
6972 @item @emph{Class}:
6973 Elemental function
6974
6975 @item @emph{Syntax}:
6976 @code{RESULT = ISHFT(I, SHIFT)}
6977
6978 @item @emph{Arguments}:
6979 @multitable @columnfractions .15 .70
6980 @item @var{I} @tab The type shall be @code{INTEGER}.
6981 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
6982 @end multitable
6983
6984 @item @emph{Return value}:
6985 The return value is of type @code{INTEGER} and of the same kind as
6986 @var{I}.
6987
6988 @item @emph{See also}:
6989 @ref{ISHFTC}
6990 @end table
6991
6992
6993
6994 @node ISHFTC
6995 @section @code{ISHFTC} --- Shift bits circularly
6996 @fnindex ISHFTC
6997 @cindex bits, shift circular
6998
6999 @table @asis
7000 @item @emph{Description}:
7001 @code{ISHFTC} returns a value corresponding to @var{I} with the
7002 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
7003 is, bits shifted out one end are shifted into the opposite end.  A value
7004 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
7005 zero corresponds to no shift, and a value less than zero corresponds to
7006 a right shift.  The absolute value of @var{SHIFT} must be less than
7007 @var{SIZE}.  If the @var{SIZE} argument is omitted, it is taken to be
7008 equivalent to @code{BIT_SIZE(I)}.
7009
7010 @item @emph{Standard}:
7011 Fortran 95 and later
7012
7013 @item @emph{Class}:
7014 Elemental function
7015
7016 @item @emph{Syntax}:
7017 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
7018
7019 @item @emph{Arguments}:
7020 @multitable @columnfractions .15 .70
7021 @item @var{I} @tab The type shall be @code{INTEGER}.
7022 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
7023 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
7024 the value must be greater than zero and less than or equal to
7025 @code{BIT_SIZE(I)}.
7026 @end multitable
7027
7028 @item @emph{Return value}:
7029 The return value is of type @code{INTEGER} and of the same kind as
7030 @var{I}.
7031
7032 @item @emph{See also}:
7033 @ref{ISHFT}
7034 @end table
7035
7036
7037
7038 @node ISNAN
7039 @section @code{ISNAN} --- Test for a NaN
7040 @fnindex ISNAN
7041 @cindex IEEE, ISNAN
7042
7043 @table @asis
7044 @item @emph{Description}:
7045 @code{ISNAN} tests whether a floating-point value is an IEEE
7046 Not-a-Number (NaN).
7047 @item @emph{Standard}:
7048 GNU extension
7049
7050 @item @emph{Class}:
7051 Elemental function
7052
7053 @item @emph{Syntax}:
7054 @code{ISNAN(X)}
7055
7056 @item @emph{Arguments}:
7057 @multitable @columnfractions .15 .70
7058 @item @var{X} @tab Variable of the type @code{REAL}.
7059
7060 @end multitable
7061
7062 @item @emph{Return value}:
7063 Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
7064 if @var{X} is a NaN and @code{FALSE} otherwise.
7065
7066 @item @emph{Example}:
7067 @smallexample
7068 program test_nan
7069   implicit none
7070   real :: x
7071   x = -1.0
7072   x = sqrt(x)
7073   if (isnan(x)) stop '"x" is a NaN'
7074 end program test_nan
7075 @end smallexample
7076 @end table
7077
7078
7079
7080 @node ITIME
7081 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds) 
7082 @fnindex ITIME
7083 @cindex time, current
7084 @cindex current time
7085
7086 @table @asis
7087 @item @emph{Description}:
7088 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the  
7089 current local time. The hour (in the range 1-24), minute (in the range 1-60), 
7090 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES}, 
7091 respectively.
7092
7093 @item @emph{Standard}:
7094 GNU extension
7095
7096 @item @emph{Class}:
7097 Subroutine
7098
7099 @item @emph{Syntax}:
7100 @code{CALL ITIME(VALUES)}
7101
7102 @item @emph{Arguments}:
7103 @multitable @columnfractions .15 .70
7104 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
7105 and the kind shall be the default integer kind.
7106 @end multitable
7107
7108 @item @emph{Return value}:
7109 Does not return anything.
7110
7111
7112 @item @emph{Example}:
7113 @smallexample
7114 program test_itime
7115   integer, dimension(3) :: tarray
7116   call itime(tarray)
7117   print *, tarray(1)
7118   print *, tarray(2)
7119   print *, tarray(3)
7120 end program test_itime
7121 @end smallexample
7122 @end table
7123
7124
7125
7126 @node KILL
7127 @section @code{KILL} --- Send a signal to a process
7128 @fnindex KILL
7129
7130 @table @asis
7131 @item @emph{Description}:
7132 @item @emph{Standard}:
7133 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
7134 See @code{kill(2)}.
7135
7136 This intrinsic is provided in both subroutine and function forms; however,
7137 only one form can be used in any given program unit.
7138
7139 @item @emph{Class}:
7140 Subroutine, function
7141
7142 @item @emph{Syntax}:
7143 @multitable @columnfractions .80
7144 @item @code{CALL KILL(C, VALUE [, STATUS])}
7145 @item @code{STATUS = KILL(C, VALUE)}
7146 @end multitable
7147
7148 @item @emph{Arguments}:
7149 @multitable @columnfractions .15 .70
7150 @item @var{C} @tab Shall be a scalar @code{INTEGER}, with
7151 @code{INTENT(IN)}
7152 @item @var{VALUE} @tab Shall be a scalar @code{INTEGER}, with
7153 @code{INTENT(IN)}
7154 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
7155 @code{INTEGER(8)}. Returns 0 on success, or a system-specific error code
7156 otherwise.
7157 @end multitable
7158
7159 @item @emph{See also}:
7160 @ref{ABORT}, @ref{EXIT}
7161 @end table
7162
7163
7164
7165 @node KIND
7166 @section @code{KIND} --- Kind of an entity
7167 @fnindex KIND
7168 @cindex kind
7169
7170 @table @asis
7171 @item @emph{Description}:
7172 @code{KIND(X)} returns the kind value of the entity @var{X}.
7173
7174 @item @emph{Standard}:
7175 Fortran 95 and later
7176
7177 @item @emph{Class}:
7178 Inquiry function
7179
7180 @item @emph{Syntax}:
7181 @code{K = KIND(X)}
7182
7183 @item @emph{Arguments}:
7184 @multitable @columnfractions .15 .70
7185 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
7186 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
7187 @end multitable
7188
7189 @item @emph{Return value}:
7190 The return value is a scalar of type @code{INTEGER} and of the default
7191 integer kind.
7192
7193 @item @emph{Example}:
7194 @smallexample
7195 program test_kind
7196   integer,parameter :: kc = kind(' ')
7197   integer,parameter :: kl = kind(.true.)
7198
7199   print *, "The default character kind is ", kc
7200   print *, "The default logical kind is ", kl
7201 end program test_kind
7202 @end smallexample
7203
7204 @end table
7205
7206
7207
7208 @node LBOUND
7209 @section @code{LBOUND} --- Lower dimension bounds of an array
7210 @fnindex LBOUND
7211 @cindex array, lower bound
7212
7213 @table @asis
7214 @item @emph{Description}:
7215 Returns the lower bounds of an array, or a single lower bound
7216 along the @var{DIM} dimension.
7217 @item @emph{Standard}:
7218 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7219
7220 @item @emph{Class}:
7221 Inquiry function
7222
7223 @item @emph{Syntax}:
7224 @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
7225
7226 @item @emph{Arguments}:
7227 @multitable @columnfractions .15 .70
7228 @item @var{ARRAY} @tab Shall be an array, of any type.
7229 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
7230 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7231 expression indicating the kind parameter of the result.
7232 @end multitable
7233
7234 @item @emph{Return value}:
7235 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7236 @var{KIND} is absent, the return value is of default integer kind.
7237 If @var{DIM} is absent, the result is an array of the lower bounds of
7238 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
7239 corresponding to the lower bound of the array along that dimension.  If
7240 @var{ARRAY} is an expression rather than a whole array or array
7241 structure component, or if it has a zero extent along the relevant
7242 dimension, the lower bound is taken to be 1.
7243
7244 @item @emph{See also}:
7245 @ref{UBOUND}, @ref{LCOBOUND}
7246 @end table
7247
7248
7249
7250 @node LCOBOUND
7251 @section @code{LCOBOUND} --- Lower codimension bounds of an array
7252 @fnindex LCOBOUND
7253 @cindex coarray, lower bound
7254
7255 @table @asis
7256 @item @emph{Description}:
7257 Returns the lower bounds of a coarray, or a single lower cobound
7258 along the @var{DIM} codimension.
7259 @item @emph{Standard}:
7260 Fortran 2008 and later
7261
7262 @item @emph{Class}:
7263 Inquiry function
7264
7265 @item @emph{Syntax}:
7266 @code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])}
7267
7268 @item @emph{Arguments}:
7269 @multitable @columnfractions .15 .70
7270 @item @var{ARRAY} @tab Shall be an coarray, of any type.
7271 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
7272 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7273 expression indicating the kind parameter of the result.
7274 @end multitable
7275
7276 @item @emph{Return value}:
7277 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7278 @var{KIND} is absent, the return value is of default integer kind.
7279 If @var{DIM} is absent, the result is an array of the lower cobounds of
7280 @var{COARRAY}.  If @var{DIM} is present, the result is a scalar
7281 corresponding to the lower cobound of the array along that codimension.
7282
7283 @item @emph{See also}:
7284 @ref{UCOBOUND}, @ref{LBOUND}
7285 @end table
7286
7287
7288
7289 @node LEADZ
7290 @section @code{LEADZ} --- Number of leading zero bits of an integer
7291 @fnindex LEADZ
7292 @cindex zero bits
7293
7294 @table @asis
7295 @item @emph{Description}:
7296 @code{LEADZ} returns the number of leading zero bits of an integer.
7297
7298 @item @emph{Standard}:
7299 Fortran 2008 and later
7300
7301 @item @emph{Class}:
7302 Elemental function
7303
7304 @item @emph{Syntax}:
7305 @code{RESULT = LEADZ(I)}
7306
7307 @item @emph{Arguments}:
7308 @multitable @columnfractions .15 .70
7309 @item @var{I} @tab Shall be of type @code{INTEGER}.
7310 @end multitable
7311
7312 @item @emph{Return value}:
7313 The type of the return value is the default @code{INTEGER}.
7314 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
7315
7316 @item @emph{Example}:
7317 @smallexample
7318 PROGRAM test_leadz
7319   WRITE (*,*) LEADZ(1)  ! prints 8 if BITSIZE(I) has the value 32
7320 END PROGRAM
7321 @end smallexample
7322
7323 @item @emph{See also}:
7324 @ref{BIT_SIZE}, @ref{TRAILZ}, @ref{POPCNT}, @ref{POPPAR}
7325 @end table
7326
7327
7328
7329 @node LEN
7330 @section @code{LEN} --- Length of a character entity
7331 @fnindex LEN
7332 @cindex string, length
7333
7334 @table @asis
7335 @item @emph{Description}:
7336 Returns the length of a character string.  If @var{STRING} is an array,
7337 the length of an element of @var{STRING} is returned.  Note that
7338 @var{STRING} need not be defined when this intrinsic is invoked, since
7339 only the length, not the content, of @var{STRING} is needed.
7340
7341 @item @emph{Standard}:
7342 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
7343
7344 @item @emph{Class}:
7345 Inquiry function
7346
7347 @item @emph{Syntax}:
7348 @code{L = LEN(STRING [, KIND])}
7349
7350 @item @emph{Arguments}:
7351 @multitable @columnfractions .15 .70
7352 @item @var{STRING} @tab Shall be a scalar or array of type
7353 @code{CHARACTER}, with @code{INTENT(IN)}
7354 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7355 expression indicating the kind parameter of the result.
7356 @end multitable
7357
7358 @item @emph{Return value}:
7359 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7360 @var{KIND} is absent, the return value is of default integer kind.
7361
7362
7363 @item @emph{Specific names}:
7364 @multitable @columnfractions .20 .20 .20 .25
7365 @item Name               @tab Argument          @tab Return type       @tab Standard
7366 @item @code{LEN(STRING)} @tab @code{CHARACTER}  @tab @code{INTEGER}    @tab Fortran 77 and later
7367 @end multitable
7368
7369
7370 @item @emph{See also}:
7371 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
7372 @end table
7373
7374
7375
7376 @node LEN_TRIM
7377 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
7378 @fnindex LEN_TRIM
7379 @cindex string, length, without trailing whitespace
7380
7381 @table @asis
7382 @item @emph{Description}:
7383 Returns the length of a character string, ignoring any trailing blanks.
7384
7385 @item @emph{Standard}:
7386 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7387
7388 @item @emph{Class}:
7389 Elemental function
7390
7391 @item @emph{Syntax}:
7392 @code{RESULT = LEN_TRIM(STRING [, KIND])}
7393
7394 @item @emph{Arguments}:
7395 @multitable @columnfractions .15 .70
7396 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
7397 with @code{INTENT(IN)}
7398 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7399 expression indicating the kind parameter of the result.
7400 @end multitable
7401
7402 @item @emph{Return value}:
7403 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7404 @var{KIND} is absent, the return value is of default integer kind.
7405
7406 @item @emph{See also}:
7407 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
7408 @end table
7409
7410
7411
7412 @node LGE
7413 @section @code{LGE} --- Lexical greater than or equal
7414 @fnindex LGE
7415 @cindex lexical comparison of strings
7416 @cindex string, comparison
7417
7418 @table @asis
7419 @item @emph{Description}:
7420 Determines whether one string is lexically greater than or equal to
7421 another string, where the two strings are interpreted as containing
7422 ASCII character codes.  If the String A and String B are not the same
7423 length, the shorter is compared as if spaces were appended to it to form
7424 a value that has the same length as the longer.
7425
7426 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7427 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7428 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7429 that the latter use the processor's character ordering (which is not
7430 ASCII on some targets), whereas the former always use the ASCII
7431 ordering.
7432
7433 @item @emph{Standard}:
7434 Fortran 77 and later
7435
7436 @item @emph{Class}:
7437 Elemental function
7438
7439 @item @emph{Syntax}:
7440 @code{RESULT = LGE(STRING_A, STRING_B)}
7441
7442 @item @emph{Arguments}:
7443 @multitable @columnfractions .15 .70
7444 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7445 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7446 @end multitable
7447
7448 @item @emph{Return value}:
7449 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
7450 otherwise, based on the ASCII ordering.
7451
7452 @item @emph{Specific names}:
7453 @multitable @columnfractions .20 .20 .20 .25
7454 @item Name                           @tab Argument          @tab Return type       @tab Standard
7455 @item @code{LGE(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
7456 @end multitable
7457
7458 @item @emph{See also}:
7459 @ref{LGT}, @ref{LLE}, @ref{LLT}
7460 @end table
7461
7462
7463
7464 @node LGT
7465 @section @code{LGT} --- Lexical greater than
7466 @fnindex LGT
7467 @cindex lexical comparison of strings
7468 @cindex string, comparison
7469
7470 @table @asis
7471 @item @emph{Description}:
7472 Determines whether one string is lexically greater than another string,
7473 where the two strings are interpreted as containing ASCII character
7474 codes.  If the String A and String B are not the same length, the
7475 shorter is compared as if spaces were appended to it to form a value
7476 that has the same length as the longer.
7477
7478 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7479 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7480 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7481 that the latter use the processor's character ordering (which is not
7482 ASCII on some targets), whereas the former always use the ASCII
7483 ordering.
7484
7485 @item @emph{Standard}:
7486 Fortran 77 and later
7487
7488 @item @emph{Class}:
7489 Elemental function
7490
7491 @item @emph{Syntax}:
7492 @code{RESULT = LGT(STRING_A, STRING_B)}
7493
7494 @item @emph{Arguments}:
7495 @multitable @columnfractions .15 .70
7496 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7497 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7498 @end multitable
7499
7500 @item @emph{Return value}:
7501 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
7502 otherwise, based on the ASCII ordering.
7503
7504 @item @emph{Specific names}:
7505 @multitable @columnfractions .20 .20 .20 .25
7506 @item Name                           @tab Argument          @tab Return type       @tab Standard
7507 @item @code{LGT(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
7508 @end multitable
7509
7510 @item @emph{See also}:
7511 @ref{LGE}, @ref{LLE}, @ref{LLT}
7512 @end table
7513
7514
7515
7516 @node LINK
7517 @section @code{LINK} --- Create a hard link
7518 @fnindex LINK
7519 @cindex file system, create link
7520 @cindex file system, hard link
7521
7522 @table @asis
7523 @item @emph{Description}:
7524 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
7525 character (@code{CHAR(0)}) can be used to mark the end of the names in
7526 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
7527 names are ignored.  If the @var{STATUS} argument is supplied, it
7528 contains 0 on success or a nonzero error code upon return; see
7529 @code{link(2)}.
7530
7531 This intrinsic is provided in both subroutine and function forms;
7532 however, only one form can be used in any given program unit.
7533
7534 @item @emph{Standard}:
7535 GNU extension
7536
7537 @item @emph{Class}:
7538 Subroutine, function
7539
7540 @item @emph{Syntax}:
7541 @multitable @columnfractions .80
7542 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
7543 @item @code{STATUS = LINK(PATH1, PATH2)}
7544 @end multitable
7545
7546 @item @emph{Arguments}:
7547 @multitable @columnfractions .15 .70
7548 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
7549 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
7550 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
7551 @end multitable
7552
7553 @item @emph{See also}:
7554 @ref{SYMLNK}, @ref{UNLINK}
7555 @end table
7556
7557
7558
7559 @node LLE
7560 @section @code{LLE} --- Lexical less than or equal
7561 @fnindex LLE
7562 @cindex lexical comparison of strings
7563 @cindex string, comparison
7564
7565 @table @asis
7566 @item @emph{Description}:
7567 Determines whether one string is lexically less than or equal to another
7568 string, where the two strings are interpreted as containing ASCII
7569 character codes.  If the String A and String B are not the same length,
7570 the shorter is compared as if spaces were appended to it to form a value
7571 that has the same length as the longer.
7572
7573 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7574 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7575 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7576 that the latter use the processor's character ordering (which is not
7577 ASCII on some targets), whereas the former always use the ASCII
7578 ordering.
7579
7580 @item @emph{Standard}:
7581 Fortran 77 and later
7582
7583 @item @emph{Class}:
7584 Elemental function
7585
7586 @item @emph{Syntax}:
7587 @code{RESULT = LLE(STRING_A, STRING_B)}
7588
7589 @item @emph{Arguments}:
7590 @multitable @columnfractions .15 .70
7591 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7592 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7593 @end multitable
7594
7595 @item @emph{Return value}:
7596 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
7597 otherwise, based on the ASCII ordering.
7598
7599 @item @emph{Specific names}:
7600 @multitable @columnfractions .20 .20 .20 .25
7601 @item Name                           @tab Argument          @tab Return type       @tab Standard
7602 @item @code{LLE(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
7603 @end multitable
7604
7605 @item @emph{See also}:
7606 @ref{LGE}, @ref{LGT}, @ref{LLT}
7607 @end table
7608
7609
7610
7611 @node LLT
7612 @section @code{LLT} --- Lexical less than
7613 @fnindex LLT
7614 @cindex lexical comparison of strings
7615 @cindex string, comparison
7616
7617 @table @asis
7618 @item @emph{Description}:
7619 Determines whether one string is lexically less than another string,
7620 where the two strings are interpreted as containing ASCII character
7621 codes.  If the String A and String B are not the same length, the
7622 shorter is compared as if spaces were appended to it to form a value
7623 that has the same length as the longer.
7624
7625 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7626 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7627 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7628 that the latter use the processor's character ordering (which is not
7629 ASCII on some targets), whereas the former always use the ASCII
7630 ordering.
7631
7632 @item @emph{Standard}:
7633 Fortran 77 and later
7634
7635 @item @emph{Class}:
7636 Elemental function
7637
7638 @item @emph{Syntax}:
7639 @code{RESULT = LLT(STRING_A, STRING_B)}
7640
7641 @item @emph{Arguments}:
7642 @multitable @columnfractions .15 .70
7643 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7644 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7645 @end multitable
7646
7647 @item @emph{Return value}:
7648 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
7649 otherwise, based on the ASCII ordering.
7650
7651 @item @emph{Specific names}:
7652 @multitable @columnfractions .20 .20 .20 .25
7653 @item Name                           @tab Argument          @tab Return type       @tab Standard
7654 @item @code{LLT(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
7655 @end multitable
7656
7657 @item @emph{See also}:
7658 @ref{LGE}, @ref{LGT}, @ref{LLE}
7659 @end table
7660
7661
7662
7663 @node LNBLNK
7664 @section @code{LNBLNK} --- Index of the last non-blank character in a string
7665 @fnindex LNBLNK
7666 @cindex string, find non-blank character
7667
7668 @table @asis
7669 @item @emph{Description}:
7670 Returns the length of a character string, ignoring any trailing blanks.
7671 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
7672 included for backwards compatibility.
7673
7674 @item @emph{Standard}:
7675 GNU extension
7676
7677 @item @emph{Class}:
7678 Elemental function
7679
7680 @item @emph{Syntax}:
7681 @code{RESULT = LNBLNK(STRING)}
7682
7683 @item @emph{Arguments}:
7684 @multitable @columnfractions .15 .70
7685 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
7686 with @code{INTENT(IN)}
7687 @end multitable
7688
7689 @item @emph{Return value}:
7690 The return value is of @code{INTEGER(kind=4)} type.
7691
7692 @item @emph{See also}:
7693 @ref{INDEX intrinsic}, @ref{LEN_TRIM}
7694 @end table
7695
7696
7697
7698 @node LOC
7699 @section @code{LOC} --- Returns the address of a variable
7700 @fnindex LOC
7701 @cindex location of a variable in memory
7702
7703 @table @asis
7704 @item @emph{Description}:
7705 @code{LOC(X)} returns the address of @var{X} as an integer.
7706
7707 @item @emph{Standard}:
7708 GNU extension
7709
7710 @item @emph{Class}:
7711 Inquiry function
7712
7713 @item @emph{Syntax}:
7714 @code{RESULT = LOC(X)}
7715
7716 @item @emph{Arguments}:
7717 @multitable @columnfractions .15 .70
7718 @item @var{X} @tab Variable of any type.
7719 @end multitable
7720
7721 @item @emph{Return value}:
7722 The return value is of type @code{INTEGER}, with a @code{KIND}
7723 corresponding to the size (in bytes) of a memory address on the target
7724 machine.
7725
7726 @item @emph{Example}:
7727 @smallexample
7728 program test_loc
7729   integer :: i
7730   real :: r
7731   i = loc(r)
7732   print *, i
7733 end program test_loc
7734 @end smallexample
7735 @end table
7736
7737
7738
7739 @node LOG
7740 @section @code{LOG} --- Logarithm function
7741 @fnindex LOG
7742 @fnindex ALOG
7743 @fnindex DLOG
7744 @fnindex CLOG
7745 @fnindex ZLOG
7746 @fnindex CDLOG
7747 @cindex exponential function, inverse
7748 @cindex logarithmic function
7749
7750 @table @asis
7751 @item @emph{Description}:
7752 @code{LOG(X)} computes the logarithm of @var{X}.
7753
7754 @item @emph{Standard}:
7755 Fortran 77 and later
7756
7757 @item @emph{Class}:
7758 Elemental function
7759
7760 @item @emph{Syntax}:
7761 @code{RESULT = LOG(X)}
7762
7763 @item @emph{Arguments}:
7764 @multitable @columnfractions .15 .70
7765 @item @var{X} @tab The type shall be @code{REAL} or
7766 @code{COMPLEX}.
7767 @end multitable
7768
7769 @item @emph{Return value}:
7770 The return value is of type @code{REAL} or @code{COMPLEX}.
7771 The kind type parameter is the same as @var{X}.
7772 If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range
7773 @math{-\pi \leq \omega \leq \pi}.
7774
7775 @item @emph{Example}:
7776 @smallexample
7777 program test_log
7778   real(8) :: x = 1.0_8
7779   complex :: z = (1.0, 2.0)
7780   x = log(x)
7781   z = log(z)
7782 end program test_log
7783 @end smallexample
7784
7785 @item @emph{Specific names}:
7786 @multitable @columnfractions .20 .20 .20 .25
7787 @item Name            @tab Argument          @tab Return type       @tab Standard
7788 @item @code{ALOG(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab f95, gnu
7789 @item @code{DLOG(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
7790 @item @code{CLOG(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
7791 @item @code{ZLOG(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
7792 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
7793 @end multitable
7794 @end table
7795
7796
7797
7798 @node LOG10
7799 @section @code{LOG10} --- Base 10 logarithm function
7800 @fnindex LOG10
7801 @fnindex ALOG10
7802 @fnindex DLOG10
7803 @cindex exponential function, inverse
7804 @cindex logarithmic function
7805
7806 @table @asis
7807 @item @emph{Description}:
7808 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
7809
7810 @item @emph{Standard}:
7811 Fortran 77 and later
7812
7813 @item @emph{Class}:
7814 Elemental function
7815
7816 @item @emph{Syntax}:
7817 @code{RESULT = LOG10(X)}
7818
7819 @item @emph{Arguments}:
7820 @multitable @columnfractions .15 .70
7821 @item @var{X} @tab The type shall be @code{REAL}.
7822 @end multitable
7823
7824 @item @emph{Return value}:
7825 The return value is of type @code{REAL} or @code{COMPLEX}.
7826 The kind type parameter is the same as @var{X}.
7827
7828 @item @emph{Example}:
7829 @smallexample
7830 program test_log10
7831   real(8) :: x = 10.0_8
7832   x = log10(x)
7833 end program test_log10
7834 @end smallexample
7835
7836 @item @emph{Specific names}:
7837 @multitable @columnfractions .20 .20 .20 .25
7838 @item Name            @tab Argument          @tab Return type       @tab Standard
7839 @item @code{ALOG10(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
7840 @item @code{DLOG10(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
7841 @end multitable
7842 @end table
7843
7844
7845
7846 @node LOG_GAMMA
7847 @section @code{LOG_GAMMA} --- Logarithm of the Gamma function
7848 @fnindex LOG_GAMMA
7849 @fnindex LGAMMA
7850 @fnindex ALGAMA
7851 @fnindex DLGAMA
7852 @cindex Gamma function, logarithm of
7853
7854 @table @asis
7855 @item @emph{Description}:
7856 @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
7857 of the Gamma (@math{\Gamma}) function.
7858
7859 @item @emph{Standard}:
7860 Fortran 2008 and later
7861
7862 @item @emph{Class}:
7863 Elemental function
7864
7865 @item @emph{Syntax}:
7866 @code{X = LOG_GAMMA(X)}
7867
7868 @item @emph{Arguments}:
7869 @multitable @columnfractions .15 .70
7870 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
7871 nor a negative integer.
7872 @end multitable
7873
7874 @item @emph{Return value}:
7875 The return value is of type @code{REAL} of the same kind as @var{X}.
7876
7877 @item @emph{Example}:
7878 @smallexample
7879 program test_log_gamma
7880   real :: x = 1.0
7881   x = lgamma(x) ! returns 0.0
7882 end program test_log_gamma
7883 @end smallexample
7884
7885 @item @emph{Specific names}:
7886 @multitable @columnfractions .20 .20 .20 .25
7887 @item Name             @tab Argument         @tab Return type       @tab Standard
7888 @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
7889 @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
7890 @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
7891 @end multitable
7892
7893 @item @emph{See also}:
7894 Gamma function: @ref{GAMMA}
7895
7896 @end table
7897
7898
7899
7900 @node LOGICAL
7901 @section @code{LOGICAL} --- Convert to logical type
7902 @fnindex LOGICAL
7903 @cindex conversion, to logical
7904
7905 @table @asis
7906 @item @emph{Description}:
7907 Converts one kind of @code{LOGICAL} variable to another.
7908
7909 @item @emph{Standard}:
7910 Fortran 95 and later
7911
7912 @item @emph{Class}:
7913 Elemental function
7914
7915 @item @emph{Syntax}:
7916 @code{RESULT = LOGICAL(L [, KIND])}
7917
7918 @item @emph{Arguments}:
7919 @multitable @columnfractions .15 .70
7920 @item @var{L}    @tab The type shall be @code{LOGICAL}.
7921 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7922 expression indicating the kind parameter of the result.
7923 @end multitable
7924
7925 @item @emph{Return value}:
7926 The return value is a @code{LOGICAL} value equal to @var{L}, with a
7927 kind corresponding to @var{KIND}, or of the default logical kind if
7928 @var{KIND} is not given.
7929
7930 @item @emph{See also}:
7931 @ref{INT}, @ref{REAL}, @ref{CMPLX}
7932 @end table
7933
7934
7935
7936 @node LONG
7937 @section @code{LONG} --- Convert to integer type
7938 @fnindex LONG
7939 @cindex conversion, to integer
7940
7941 @table @asis
7942 @item @emph{Description}:
7943 Convert to a @code{KIND=4} integer type, which is the same size as a C
7944 @code{long} integer.  This is equivalent to the standard @code{INT}
7945 intrinsic with an optional argument of @code{KIND=4}, and is only
7946 included for backwards compatibility.
7947
7948 @item @emph{Standard}:
7949 GNU extension
7950
7951 @item @emph{Class}:
7952 Elemental function
7953
7954 @item @emph{Syntax}:
7955 @code{RESULT = LONG(A)}
7956
7957 @item @emph{Arguments}:
7958 @multitable @columnfractions .15 .70
7959 @item @var{A}    @tab Shall be of type @code{INTEGER},
7960 @code{REAL}, or @code{COMPLEX}.
7961 @end multitable
7962
7963 @item @emph{Return value}:
7964 The return value is a @code{INTEGER(4)} variable.
7965
7966 @item @emph{See also}:
7967 @ref{INT}, @ref{INT2}, @ref{INT8}
7968 @end table
7969
7970
7971
7972 @node LSHIFT
7973 @section @code{LSHIFT} --- Left shift bits
7974 @fnindex LSHIFT
7975 @cindex bits, shift left
7976
7977 @table @asis
7978 @item @emph{Description}:
7979 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
7980 bits shifted left by @var{SHIFT} places.  If the absolute value of
7981 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined. 
7982 Bits shifted out from the left end are lost; zeros are shifted in from
7983 the opposite end.
7984
7985 This function has been superseded by the @code{ISHFT} intrinsic, which
7986 is standard in Fortran 95 and later, and the @code{SHIFTL} intrinsic,
7987 which is standard in Fortran 2008 and later.
7988
7989 @item @emph{Standard}:
7990 GNU extension
7991
7992 @item @emph{Class}:
7993 Elemental function
7994
7995 @item @emph{Syntax}:
7996 @code{RESULT = LSHIFT(I, SHIFT)}
7997
7998 @item @emph{Arguments}:
7999 @multitable @columnfractions .15 .70
8000 @item @var{I} @tab The type shall be @code{INTEGER}.
8001 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8002 @end multitable
8003
8004 @item @emph{Return value}:
8005 The return value is of type @code{INTEGER} and of the same kind as
8006 @var{I}.
8007
8008 @item @emph{See also}:
8009 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}, @ref{SHIFTA}, @ref{SHIFTL},
8010 @ref{SHIFTR}
8011
8012 @end table
8013
8014
8015
8016 @node LSTAT
8017 @section @code{LSTAT} --- Get file status
8018 @fnindex LSTAT
8019 @cindex file system, file status
8020
8021 @table @asis
8022 @item @emph{Description}:
8023 @code{LSTAT} is identical to @ref{STAT}, except that if path is a
8024 symbolic link, then the link itself is statted, not the file that it
8025 refers to.
8026
8027 The elements in @code{VALUES} are the same as described by @ref{STAT}.
8028
8029 This intrinsic is provided in both subroutine and function forms;
8030 however, only one form can be used in any given program unit.
8031
8032 @item @emph{Standard}:
8033 GNU extension
8034
8035 @item @emph{Class}:
8036 Subroutine, function
8037
8038 @item @emph{Syntax}:
8039 @multitable @columnfractions .80
8040 @item @code{CALL LSTAT(NAME, VALUES [, STATUS])}
8041 @item @code{STATUS = LSTAT(NAME, VALUES)}
8042 @end multitable
8043
8044 @item @emph{Arguments}:
8045 @multitable @columnfractions .15 .70
8046 @item @var{NAME}   @tab The type shall be @code{CHARACTER} of the default
8047 kind, a valid path within the file system.
8048 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
8049 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
8050 Returns 0 on success and a system specific error code otherwise.
8051 @end multitable
8052
8053 @item @emph{Example}:
8054 See @ref{STAT} for an example.
8055
8056 @item @emph{See also}:
8057 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
8058 @end table
8059
8060
8061
8062 @node LTIME
8063 @section @code{LTIME} --- Convert time to local time info
8064 @fnindex LTIME
8065 @cindex time, conversion to local time info
8066
8067 @table @asis
8068 @item @emph{Description}:
8069 Given a system time value @var{TIME} (as provided by the @code{TIME8()}
8070 intrinsic), fills @var{VALUES} with values extracted from it appropriate
8071 to the local time zone using @code{localtime(3)}.
8072
8073 @item @emph{Standard}:
8074 GNU extension
8075
8076 @item @emph{Class}:
8077 Subroutine
8078
8079 @item @emph{Syntax}:
8080 @code{CALL LTIME(TIME, VALUES)}
8081
8082 @item @emph{Arguments}:
8083 @multitable @columnfractions .15 .70
8084 @item @var{TIME}  @tab An @code{INTEGER} scalar expression
8085 corresponding to a system time, with @code{INTENT(IN)}.
8086 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
8087 with @code{INTENT(OUT)}.
8088 @end multitable
8089
8090 @item @emph{Return value}:
8091 The elements of @var{VALUES} are assigned as follows:
8092 @enumerate
8093 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
8094 seconds
8095 @item Minutes after the hour, range 0--59
8096 @item Hours past midnight, range 0--23
8097 @item Day of month, range 0--31
8098 @item Number of months since January, range 0--12
8099 @item Years since 1900
8100 @item Number of days since Sunday, range 0--6
8101 @item Days since January 1
8102 @item Daylight savings indicator: positive if daylight savings is in
8103 effect, zero if not, and negative if the information is not available.
8104 @end enumerate
8105
8106 @item @emph{See also}:
8107 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
8108
8109 @end table
8110
8111
8112
8113 @node MALLOC
8114 @section @code{MALLOC} --- Allocate dynamic memory
8115 @fnindex MALLOC
8116 @cindex pointer, cray
8117
8118 @table @asis
8119 @item @emph{Description}:
8120 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
8121 returns the address of the allocated memory. The @code{MALLOC} intrinsic
8122 is an extension intended to be used with Cray pointers, and is provided
8123 in GNU Fortran to allow the user to compile legacy code. For new code
8124 using Fortran 95 pointers, the memory allocation intrinsic is
8125 @code{ALLOCATE}.
8126
8127 @item @emph{Standard}:
8128 GNU extension
8129
8130 @item @emph{Class}:
8131 Function
8132
8133 @item @emph{Syntax}:
8134 @code{PTR = MALLOC(SIZE)}
8135
8136 @item @emph{Arguments}:
8137 @multitable @columnfractions .15 .70
8138 @item @var{SIZE} @tab The type shall be @code{INTEGER}.
8139 @end multitable
8140
8141 @item @emph{Return value}:
8142 The return value is of type @code{INTEGER(K)}, with @var{K} such that
8143 variables of type @code{INTEGER(K)} have the same size as
8144 C pointers (@code{sizeof(void *)}).
8145
8146 @item @emph{Example}:
8147 The following example demonstrates the use of @code{MALLOC} and
8148 @code{FREE} with Cray pointers.
8149
8150 @smallexample
8151 program test_malloc
8152   implicit none
8153   integer i
8154   real*8 x(*), z
8155   pointer(ptr_x,x)
8156
8157   ptr_x = malloc(20*8)
8158   do i = 1, 20
8159     x(i) = sqrt(1.0d0 / i)
8160   end do
8161   z = 0
8162   do i = 1, 20
8163     z = z + x(i)
8164     print *, z
8165   end do
8166   call free(ptr_x)
8167 end program test_malloc
8168 @end smallexample
8169
8170 @item @emph{See also}:
8171 @ref{FREE}
8172 @end table
8173
8174
8175
8176 @node MASKL
8177 @section @code{MASKL} --- Left justified mask
8178 @fnindex MASKL
8179 @cindex mask, left justified
8180
8181 @table @asis
8182 @item @emph{Description}:
8183 @code{MASKL(I[, KIND])} has its leftmost @var{I} bits set to 1, and the
8184 remaining bits set to 0.
8185
8186 @item @emph{Standard}:
8187 Fortran 2008 and later
8188
8189 @item @emph{Class}:
8190 Elemental function
8191
8192 @item @emph{Syntax}:
8193 @code{RESULT = MASKL(I[, KIND])}
8194
8195 @item @emph{Arguments}:
8196 @multitable @columnfractions .15 .70
8197 @item @var{I} @tab Shall be of type @code{INTEGER}.
8198 @item @var{KIND} @tab Shall be a scalar constant expression of type
8199 @code{INTEGER}.
8200 @end multitable
8201
8202 @item @emph{Return value}:
8203 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
8204 specifies the kind value of the return type; otherwise, it is of the
8205 default integer kind.
8206
8207 @item @emph{See also}:
8208 @ref{MASKR}
8209 @end table
8210
8211
8212
8213 @node MASKR
8214 @section @code{MASKR} --- Right justified mask
8215 @fnindex MASKR
8216 @cindex mask, right justified
8217
8218 @table @asis
8219 @item @emph{Description}:
8220 @code{MASKL(I[, KIND])} has its rightmost @var{I} bits set to 1, and the
8221 remaining bits set to 0.
8222
8223 @item @emph{Standard}:
8224 Fortran 2008 and later
8225
8226 @item @emph{Class}:
8227 Elemental function
8228
8229 @item @emph{Syntax}:
8230 @code{RESULT = MASKR(I[, KIND])}
8231
8232 @item @emph{Arguments}:
8233 @multitable @columnfractions .15 .70
8234 @item @var{I} @tab Shall be of type @code{INTEGER}.
8235 @item @var{KIND} @tab Shall be a scalar constant expression of type
8236 @code{INTEGER}.
8237 @end multitable
8238
8239 @item @emph{Return value}:
8240 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
8241 specifies the kind value of the return type; otherwise, it is of the
8242 default integer kind.
8243
8244 @item @emph{See also}:
8245 @ref{MASKL}
8246 @end table
8247
8248
8249
8250 @node MATMUL
8251 @section @code{MATMUL} --- matrix multiplication
8252 @fnindex MATMUL
8253 @cindex matrix multiplication
8254 @cindex product, matrix
8255
8256 @table @asis
8257 @item @emph{Description}:
8258 Performs a matrix multiplication on numeric or logical arguments.
8259
8260 @item @emph{Standard}:
8261 Fortran 95 and later
8262
8263 @item @emph{Class}:
8264 Transformational function
8265
8266 @item @emph{Syntax}:
8267 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
8268
8269 @item @emph{Arguments}:
8270 @multitable @columnfractions .15 .70
8271 @item @var{MATRIX_A} @tab An array of @code{INTEGER},
8272 @code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of
8273 one or two.
8274 @item @var{MATRIX_B} @tab An array of @code{INTEGER},
8275 @code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric
8276 type; otherwise, an array of @code{LOGICAL} type. The rank shall be one
8277 or two, and the first (or only) dimension of @var{MATRIX_B} shall be
8278 equal to the last (or only) dimension of @var{MATRIX_A}.
8279 @end multitable
8280
8281 @item @emph{Return value}:
8282 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}.  The type and
8283 kind of the result follow the usual type and kind promotion rules, as
8284 for the @code{*} or @code{.AND.} operators.
8285
8286 @item @emph{See also}:
8287 @end table
8288
8289
8290
8291 @node MAX
8292 @section @code{MAX} --- Maximum value of an argument list
8293 @fnindex MAX
8294 @fnindex MAX0
8295 @fnindex AMAX0
8296 @fnindex MAX1
8297 @fnindex AMAX1
8298 @fnindex DMAX1
8299 @cindex maximum value
8300
8301 @table @asis
8302 @item @emph{Description}:
8303 Returns the argument with the largest (most positive) value.
8304
8305 @item @emph{Standard}:
8306 Fortran 77 and later
8307
8308 @item @emph{Class}:
8309 Elemental function
8310
8311 @item @emph{Syntax}:
8312 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
8313
8314 @item @emph{Arguments}:
8315 @multitable @columnfractions .15 .70
8316 @item @var{A1}          @tab The type shall be @code{INTEGER} or
8317 @code{REAL}.
8318 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
8319 as @var{A1}.  (As a GNU extension, arguments of different kinds are
8320 permitted.)
8321 @end multitable
8322
8323 @item @emph{Return value}:
8324 The return value corresponds to the maximum value among the arguments,
8325 and has the same type and kind as the first argument.
8326
8327 @item @emph{Specific names}:
8328 @multitable @columnfractions .20 .20 .20 .25
8329 @item Name             @tab Argument             @tab Return type         @tab Standard
8330 @item @code{MAX0(A1)}  @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)}   @tab Fortran 77 and later
8331 @item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
8332 @item @code{MAX1(A1)}  @tab @code{REAL A1}       @tab @code{INT(MAX(X))}  @tab Fortran 77 and later
8333 @item @code{AMAX1(A1)} @tab @code{REAL(4) A1}    @tab @code{REAL(4)}      @tab Fortran 77 and later
8334 @item @code{DMAX1(A1)} @tab @code{REAL(8) A1}    @tab @code{REAL(8)}      @tab Fortran 77 and later
8335 @end multitable
8336
8337 @item @emph{See also}:
8338 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
8339
8340 @end table
8341
8342
8343
8344 @node MAXEXPONENT
8345 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
8346 @fnindex MAXEXPONENT
8347 @cindex model representation, maximum exponent
8348
8349 @table @asis
8350 @item @emph{Description}:
8351 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
8352 type of @code{X}.
8353
8354 @item @emph{Standard}:
8355 Fortran 95 and later
8356
8357 @item @emph{Class}:
8358 Inquiry function
8359
8360 @item @emph{Syntax}:
8361 @code{RESULT = MAXEXPONENT(X)}
8362
8363 @item @emph{Arguments}:
8364 @multitable @columnfractions .15 .70
8365 @item @var{X} @tab Shall be of type @code{REAL}.
8366 @end multitable
8367
8368 @item @emph{Return value}:
8369 The return value is of type @code{INTEGER} and of the default integer
8370 kind.
8371
8372 @item @emph{Example}:
8373 @smallexample
8374 program exponents
8375   real(kind=4) :: x
8376   real(kind=8) :: y
8377
8378   print *, minexponent(x), maxexponent(x)
8379   print *, minexponent(y), maxexponent(y)
8380 end program exponents
8381 @end smallexample
8382 @end table
8383
8384
8385
8386 @node MAXLOC
8387 @section @code{MAXLOC} --- Location of the maximum value within an array
8388 @fnindex MAXLOC
8389 @cindex array, location of maximum element
8390
8391 @table @asis
8392 @item @emph{Description}:
8393 Determines the location of the element in the array with the maximum
8394 value, or, if the @var{DIM} argument is supplied, determines the
8395 locations of the maximum element along each row of the array in the
8396 @var{DIM} direction.  If @var{MASK} is present, only the elements for
8397 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
8398 element in the array has the maximum value, the location returned is
8399 that of the first such element in array element order.  If the array has
8400 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
8401 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
8402 and all of the elements of @var{MASK} along a given row are zero, the
8403 result value for that row is zero.
8404
8405 @item @emph{Standard}:
8406 Fortran 95 and later
8407
8408 @item @emph{Class}:
8409 Transformational function
8410
8411 @item @emph{Syntax}:
8412 @multitable @columnfractions .80
8413 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
8414 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
8415 @end multitable
8416
8417 @item @emph{Arguments}:
8418 @multitable @columnfractions .15 .70
8419 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8420 @code{REAL}.
8421 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8422 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8423 inclusive.  It may not be an optional dummy argument.
8424 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8425 and conformable with @var{ARRAY}.
8426 @end multitable
8427
8428 @item @emph{Return value}:
8429 If @var{DIM} is absent, the result is a rank-one array with a length
8430 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
8431 is an array with a rank one less than the rank of @var{ARRAY}, and a
8432 size corresponding to the size of @var{ARRAY} with the @var{DIM}
8433 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
8434 of one, the result is a scalar.  In all cases, the result is of default
8435 @code{INTEGER} type.
8436
8437 @item @emph{See also}:
8438 @ref{MAX}, @ref{MAXVAL}
8439
8440 @end table
8441
8442
8443
8444 @node MAXVAL
8445 @section @code{MAXVAL} --- Maximum value of an array
8446 @fnindex MAXVAL
8447 @cindex array, maximum value
8448 @cindex maximum value
8449
8450 @table @asis
8451 @item @emph{Description}:
8452 Determines the maximum value of the elements in an array value, or, if
8453 the @var{DIM} argument is supplied, determines the maximum value along
8454 each row of the array in the @var{DIM} direction.  If @var{MASK} is
8455 present, only the elements for which @var{MASK} is @code{.TRUE.} are
8456 considered.  If the array has zero size, or all of the elements of
8457 @var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)}
8458 if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character
8459 type.
8460
8461 @item @emph{Standard}:
8462 Fortran 95 and later
8463
8464 @item @emph{Class}:
8465 Transformational function
8466
8467 @item @emph{Syntax}:
8468 @multitable @columnfractions .80
8469 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
8470 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
8471 @end multitable
8472
8473 @item @emph{Arguments}:
8474 @multitable @columnfractions .15 .70
8475 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8476 @code{REAL}.
8477 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8478 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8479 inclusive.  It may not be an optional dummy argument.
8480 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8481 and conformable with @var{ARRAY}.
8482 @end multitable
8483
8484 @item @emph{Return value}:
8485 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
8486 is a scalar.  If @var{DIM} is present, the result is an array with a
8487 rank one less than the rank of @var{ARRAY}, and a size corresponding to
8488 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
8489 cases, the result is of the same type and kind as @var{ARRAY}.
8490
8491 @item @emph{See also}:
8492 @ref{MAX}, @ref{MAXLOC}
8493 @end table
8494
8495
8496
8497 @node MCLOCK
8498 @section @code{MCLOCK} --- Time function
8499 @fnindex MCLOCK
8500 @cindex time, clock ticks
8501 @cindex clock ticks
8502
8503 @table @asis
8504 @item @emph{Description}:
8505 Returns the number of clock ticks since the start of the process, based
8506 on the UNIX function @code{clock(3)}.
8507
8508 This intrinsic is not fully portable, such as to systems with 32-bit
8509 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
8510 the values returned by this intrinsic might be, or become, negative, or
8511 numerically less than previous values, during a single run of the
8512 compiled program.
8513
8514 @item @emph{Standard}:
8515 GNU extension
8516
8517 @item @emph{Class}:
8518 Function
8519
8520 @item @emph{Syntax}:
8521 @code{RESULT = MCLOCK()}
8522
8523 @item @emph{Return value}:
8524 The return value is a scalar of type @code{INTEGER(4)}, equal to the
8525 number of clock ticks since the start of the process, or @code{-1} if
8526 the system does not support @code{clock(3)}.
8527
8528 @item @emph{See also}:
8529 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
8530
8531 @end table
8532
8533
8534
8535 @node MCLOCK8
8536 @section @code{MCLOCK8} --- Time function (64-bit)
8537 @fnindex MCLOCK8
8538 @cindex time, clock ticks
8539 @cindex clock ticks
8540
8541 @table @asis
8542 @item @emph{Description}:
8543 Returns the number of clock ticks since the start of the process, based
8544 on the UNIX function @code{clock(3)}.
8545
8546 @emph{Warning:} this intrinsic does not increase the range of the timing
8547 values over that returned by @code{clock(3)}. On a system with a 32-bit
8548 @code{clock(3)}, @code{MCLOCK8()} will return a 32-bit value, even though
8549 it is converted to a 64-bit @code{INTEGER(8)} value. That means
8550 overflows of the 32-bit value can still occur. Therefore, the values
8551 returned by this intrinsic might be or become negative or numerically
8552 less than previous values during a single run of the compiled program.
8553
8554 @item @emph{Standard}:
8555 GNU extension
8556
8557 @item @emph{Class}:
8558 Function
8559
8560 @item @emph{Syntax}:
8561 @code{RESULT = MCLOCK8()}
8562
8563 @item @emph{Return value}:
8564 The return value is a scalar of type @code{INTEGER(8)}, equal to the
8565 number of clock ticks since the start of the process, or @code{-1} if
8566 the system does not support @code{clock(3)}.
8567
8568 @item @emph{See also}:
8569 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
8570
8571 @end table
8572
8573
8574
8575 @node MERGE
8576 @section @code{MERGE} --- Merge variables
8577 @fnindex MERGE
8578 @cindex array, merge arrays
8579 @cindex array, combine arrays
8580
8581 @table @asis
8582 @item @emph{Description}:
8583 Select values from two arrays according to a logical mask.  The result
8584 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
8585 @var{FSOURCE} if it is @code{.FALSE.}.
8586
8587 @item @emph{Standard}:
8588 Fortran 95 and later
8589
8590 @item @emph{Class}:
8591 Elemental function
8592
8593 @item @emph{Syntax}:
8594 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
8595
8596 @item @emph{Arguments}:
8597 @multitable @columnfractions .15 .70
8598 @item @var{TSOURCE} @tab May be of any type.
8599 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
8600 as @var{TSOURCE}.
8601 @item @var{MASK}    @tab Shall be of type @code{LOGICAL}.
8602 @end multitable
8603
8604 @item @emph{Return value}:
8605 The result is of the same type and type parameters as @var{TSOURCE}.
8606
8607 @end table
8608
8609
8610
8611 @node MERGE_BITS
8612 @section @code{MERGE_BITS} --- Merge of bits under mask
8613 @fnindex MERGE_BITS
8614 @cindex bits, merge
8615
8616 @table @asis
8617 @item @emph{Description}:
8618 @code{MERGE_BITS(I, J, MASK)} merges the bits of @var{I} and @var{J}
8619 as determined by the mask.  The i-th bit of the result is equal to the 
8620 i-th bit of @var{I} if the i-th bit of @var{MASK} is 1; it is equal to
8621 the i-th bit of @var{J} otherwise.
8622
8623 @item @emph{Standard}:
8624 Fortran 2008 and later
8625
8626 @item @emph{Class}:
8627 Elemental function
8628
8629 @item @emph{Syntax}:
8630 @code{RESULT = MERGE_BITS(I, J, MASK)}
8631
8632 @item @emph{Arguments}:
8633 @multitable @columnfractions .15 .70
8634 @item @var{I}    @tab Shall be of type @code{INTEGER}.
8635 @item @var{J}    @tab Shall be of type @code{INTEGER} and of the same
8636 kind as @var{I}.
8637 @item @var{MASK} @tab Shall be of type @code{INTEGER} and of the same
8638 kind as @var{I}.
8639 @end multitable
8640
8641 @item @emph{Return value}:
8642 The result is of the same type and kind as @var{I}.
8643
8644 @end table
8645
8646
8647
8648 @node MIN
8649 @section @code{MIN} --- Minimum value of an argument list
8650 @fnindex MIN
8651 @fnindex MIN0
8652 @fnindex AMIN0
8653 @fnindex MIN1
8654 @fnindex AMIN1
8655 @fnindex DMIN1
8656 @cindex minimum value
8657
8658 @table @asis
8659 @item @emph{Description}:
8660 Returns the argument with the smallest (most negative) value.
8661
8662 @item @emph{Standard}:
8663 Fortran 77 and later
8664
8665 @item @emph{Class}:
8666 Elemental function
8667
8668 @item @emph{Syntax}:
8669 @code{RESULT = MIN(A1, A2 [, A3, ...])}
8670
8671 @item @emph{Arguments}:
8672 @multitable @columnfractions .15 .70
8673 @item @var{A1}          @tab The type shall be @code{INTEGER} or
8674 @code{REAL}.
8675 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
8676 as @var{A1}.  (As a GNU extension, arguments of different kinds are
8677 permitted.)
8678 @end multitable
8679
8680 @item @emph{Return value}:
8681 The return value corresponds to the maximum value among the arguments,
8682 and has the same type and kind as the first argument.
8683
8684 @item @emph{Specific names}:
8685 @multitable @columnfractions .20 .20 .20 .25
8686 @item Name              @tab Argument             @tab Return type        @tab Standard
8687 @item @code{MIN0(A1)}   @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)}  @tab Fortran 77 and later
8688 @item @code{AMIN0(A1)}  @tab @code{INTEGER(4) A1} @tab @code{REAL(4)}     @tab Fortran 77 and later
8689 @item @code{MIN1(A1)}   @tab @code{REAL A1}       @tab @code{INTEGER(4)}  @tab Fortran 77 and later
8690 @item @code{AMIN1(A1)}  @tab @code{REAL(4) A1}    @tab @code{REAL(4)}     @tab Fortran 77 and later
8691 @item @code{DMIN1(A1)}  @tab @code{REAL(8) A1}    @tab @code{REAL(8)}     @tab Fortran 77 and later
8692 @end multitable
8693
8694 @item @emph{See also}:
8695 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
8696 @end table
8697
8698
8699
8700 @node MINEXPONENT
8701 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
8702 @fnindex MINEXPONENT
8703 @cindex model representation, minimum exponent
8704
8705 @table @asis
8706 @item @emph{Description}:
8707 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
8708 type of @code{X}.
8709
8710 @item @emph{Standard}:
8711 Fortran 95 and later
8712
8713 @item @emph{Class}:
8714 Inquiry function
8715
8716 @item @emph{Syntax}:
8717 @code{RESULT = MINEXPONENT(X)}
8718
8719 @item @emph{Arguments}:
8720 @multitable @columnfractions .15 .70
8721 @item @var{X} @tab Shall be of type @code{REAL}.
8722 @end multitable
8723
8724 @item @emph{Return value}:
8725 The return value is of type @code{INTEGER} and of the default integer
8726 kind.
8727
8728 @item @emph{Example}:
8729 See @code{MAXEXPONENT} for an example.
8730 @end table
8731
8732
8733
8734 @node MINLOC
8735 @section @code{MINLOC} --- Location of the minimum value within an array
8736 @fnindex MINLOC
8737 @cindex array, location of minimum element
8738
8739 @table @asis
8740 @item @emph{Description}:
8741 Determines the location of the element in the array with the minimum
8742 value, or, if the @var{DIM} argument is supplied, determines the
8743 locations of the minimum element along each row of the array in the
8744 @var{DIM} direction.  If @var{MASK} is present, only the elements for
8745 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
8746 element in the array has the minimum value, the location returned is
8747 that of the first such element in array element order.  If the array has
8748 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
8749 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
8750 and all of the elements of @var{MASK} along a given row are zero, the
8751 result value for that row is zero.
8752
8753 @item @emph{Standard}:
8754 Fortran 95 and later
8755
8756 @item @emph{Class}:
8757 Transformational function
8758
8759 @item @emph{Syntax}:
8760 @multitable @columnfractions .80
8761 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
8762 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
8763 @end multitable
8764
8765 @item @emph{Arguments}:
8766 @multitable @columnfractions .15 .70
8767 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8768 @code{REAL}.
8769 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8770 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8771 inclusive.  It may not be an optional dummy argument.
8772 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8773 and conformable with @var{ARRAY}.
8774 @end multitable
8775
8776 @item @emph{Return value}:
8777 If @var{DIM} is absent, the result is a rank-one array with a length
8778 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
8779 is an array with a rank one less than the rank of @var{ARRAY}, and a
8780 size corresponding to the size of @var{ARRAY} with the @var{DIM}
8781 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
8782 of one, the result is a scalar.  In all cases, the result is of default
8783 @code{INTEGER} type.
8784
8785 @item @emph{See also}:
8786 @ref{MIN}, @ref{MINVAL}
8787
8788 @end table
8789
8790
8791
8792 @node MINVAL
8793 @section @code{MINVAL} --- Minimum value of an array
8794 @fnindex MINVAL
8795 @cindex array, minimum value
8796 @cindex minimum value
8797
8798 @table @asis
8799 @item @emph{Description}:
8800 Determines the minimum value of the elements in an array value, or, if
8801 the @var{DIM} argument is supplied, determines the minimum value along
8802 each row of the array in the @var{DIM} direction.  If @var{MASK} is
8803 present, only the elements for which @var{MASK} is @code{.TRUE.} are
8804 considered.  If the array has zero size, or all of the elements of
8805 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
8806 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
8807 @var{ARRAY} is of character type.
8808
8809 @item @emph{Standard}:
8810 Fortran 95 and later
8811
8812 @item @emph{Class}:
8813 Transformational function
8814
8815 @item @emph{Syntax}:
8816 @multitable @columnfractions .80
8817 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
8818 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
8819 @end multitable
8820
8821 @item @emph{Arguments}:
8822 @multitable @columnfractions .15 .70
8823 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8824 @code{REAL}.
8825 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8826 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8827 inclusive.  It may not be an optional dummy argument.
8828 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8829 and conformable with @var{ARRAY}.
8830 @end multitable
8831
8832 @item @emph{Return value}:
8833 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
8834 is a scalar.  If @var{DIM} is present, the result is an array with a
8835 rank one less than the rank of @var{ARRAY}, and a size corresponding to
8836 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
8837 cases, the result is of the same type and kind as @var{ARRAY}.
8838
8839 @item @emph{See also}:
8840 @ref{MIN}, @ref{MINLOC}
8841
8842 @end table
8843
8844
8845
8846 @node MOD
8847 @section @code{MOD} --- Remainder function
8848 @fnindex MOD
8849 @fnindex AMOD
8850 @fnindex DMOD
8851 @cindex remainder
8852 @cindex division, remainder
8853
8854 @table @asis
8855 @item @emph{Description}:
8856 @code{MOD(A,P)} computes the remainder of the division of A by P@. It is
8857 calculated as @code{A - (INT(A/P) * P)}.
8858
8859 @item @emph{Standard}:
8860 Fortran 77 and later
8861
8862 @item @emph{Class}:
8863 Elemental function
8864
8865 @item @emph{Syntax}:
8866 @code{RESULT = MOD(A, P)}
8867
8868 @item @emph{Arguments}:
8869 @multitable @columnfractions .15 .70
8870 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
8871 @item @var{P} @tab Shall be a scalar of the same type as @var{A} and not
8872 equal to zero
8873 @end multitable
8874
8875 @item @emph{Return value}:
8876 The kind of the return value is the result of cross-promoting
8877 the kinds of the arguments.
8878
8879 @item @emph{Example}:
8880 @smallexample
8881 program test_mod
8882   print *, mod(17,3)
8883   print *, mod(17.5,5.5)
8884   print *, mod(17.5d0,5.5)
8885   print *, mod(17.5,5.5d0)
8886
8887   print *, mod(-17,3)
8888   print *, mod(-17.5,5.5)
8889   print *, mod(-17.5d0,5.5)
8890   print *, mod(-17.5,5.5d0)
8891
8892   print *, mod(17,-3)
8893   print *, mod(17.5,-5.5)
8894   print *, mod(17.5d0,-5.5)
8895   print *, mod(17.5,-5.5d0)
8896 end program test_mod
8897 @end smallexample
8898
8899 @item @emph{Specific names}:
8900 @multitable @columnfractions .20 .20 .20 .25
8901 @item Name             @tab Arguments          @tab Return type    @tab Standard
8902 @item @code{MOD(A,P)}  @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 95 and later
8903 @item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 95 and later
8904 @item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 95 and later
8905 @end multitable
8906 @end table
8907
8908
8909
8910 @node MODULO
8911 @section @code{MODULO} --- Modulo function
8912 @fnindex MODULO
8913 @cindex modulo
8914 @cindex division, modulo
8915
8916 @table @asis
8917 @item @emph{Description}:
8918 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
8919
8920 @item @emph{Standard}:
8921 Fortran 95 and later
8922
8923 @item @emph{Class}:
8924 Elemental function
8925
8926 @item @emph{Syntax}:
8927 @code{RESULT = MODULO(A, P)}
8928
8929 @item @emph{Arguments}:
8930 @multitable @columnfractions .15 .70
8931 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
8932 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
8933 @end multitable
8934
8935 @item @emph{Return value}:
8936 The type and kind of the result are those of the arguments.
8937 @table @asis
8938 @item If @var{A} and @var{P} are of type @code{INTEGER}:
8939 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
8940 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
8941 (exclusive).
8942 @item If @var{A} and @var{P} are of type @code{REAL}:
8943 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
8944 @end table
8945 In all cases, if @var{P} is zero the result is processor-dependent.
8946
8947 @item @emph{Example}:
8948 @smallexample
8949 program test_modulo
8950   print *, modulo(17,3)
8951   print *, modulo(17.5,5.5)
8952
8953   print *, modulo(-17,3)
8954   print *, modulo(-17.5,5.5)
8955
8956   print *, modulo(17,-3)
8957   print *, modulo(17.5,-5.5)
8958 end program
8959 @end smallexample
8960
8961 @end table
8962
8963
8964
8965 @node MOVE_ALLOC
8966 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
8967 @fnindex MOVE_ALLOC
8968 @cindex moving allocation
8969 @cindex allocation, moving
8970
8971 @table @asis
8972 @item @emph{Description}:
8973 @code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
8974 @var{TO}.  @var{FROM} will become deallocated in the process.
8975
8976 @item @emph{Standard}:
8977 Fortran 2003 and later
8978
8979 @item @emph{Class}:
8980 Subroutine
8981
8982 @item @emph{Syntax}:
8983 @code{CALL MOVE_ALLOC(FROM, TO)}
8984
8985 @item @emph{Arguments}:
8986 @multitable @columnfractions .15 .70
8987 @item @var{FROM}  @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
8988 of any type and kind.
8989 @item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
8990 of the same type, kind and rank as @var{FROM}.
8991 @end multitable
8992
8993 @item @emph{Return value}:
8994 None
8995
8996 @item @emph{Example}:
8997 @smallexample
8998 program test_move_alloc
8999     integer, allocatable :: a(:), b(:)
9000
9001     allocate(a(3))
9002     a = [ 1, 2, 3 ]
9003     call move_alloc(a, b)
9004     print *, allocated(a), allocated(b)
9005     print *, b
9006 end program test_move_alloc
9007 @end smallexample
9008 @end table
9009
9010
9011
9012 @node MVBITS
9013 @section @code{MVBITS} --- Move bits from one integer to another
9014 @fnindex MVBITS
9015 @cindex bits, move
9016
9017 @table @asis
9018 @item @emph{Description}:
9019 Moves @var{LEN} bits from positions @var{FROMPOS} through
9020 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
9021 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
9022 affected by the movement of bits is unchanged. The values of
9023 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
9024 @code{BIT_SIZE(FROM)}.
9025
9026 @item @emph{Standard}:
9027 Fortran 95 and later
9028
9029 @item @emph{Class}:
9030 Elemental subroutine
9031
9032 @item @emph{Syntax}:
9033 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
9034
9035 @item @emph{Arguments}:
9036 @multitable @columnfractions .15 .70
9037 @item @var{FROM}    @tab The type shall be @code{INTEGER}.
9038 @item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
9039 @item @var{LEN}     @tab The type shall be @code{INTEGER}.
9040 @item @var{TO}      @tab The type shall be @code{INTEGER}, of the
9041 same kind as @var{FROM}.
9042 @item @var{TOPOS}   @tab The type shall be @code{INTEGER}.
9043 @end multitable
9044
9045 @item @emph{See also}:
9046 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
9047 @end table
9048
9049
9050
9051 @node NEAREST
9052 @section @code{NEAREST} --- Nearest representable number
9053 @fnindex NEAREST
9054 @cindex real number, nearest different
9055 @cindex floating point, nearest different
9056
9057 @table @asis
9058 @item @emph{Description}:
9059 @code{NEAREST(X, S)} returns the processor-representable number nearest
9060 to @code{X} in the direction indicated by the sign of @code{S}.
9061
9062 @item @emph{Standard}:
9063 Fortran 95 and later
9064
9065 @item @emph{Class}:
9066 Elemental function
9067
9068 @item @emph{Syntax}:
9069 @code{RESULT = NEAREST(X, S)}
9070
9071 @item @emph{Arguments}:
9072 @multitable @columnfractions .15 .70
9073 @item @var{X} @tab Shall be of type @code{REAL}.
9074 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
9075 not equal to zero.
9076 @end multitable
9077
9078 @item @emph{Return value}:
9079 The return value is of the same type as @code{X}. If @code{S} is
9080 positive, @code{NEAREST} returns the processor-representable number
9081 greater than @code{X} and nearest to it. If @code{S} is negative,
9082 @code{NEAREST} returns the processor-representable number smaller than
9083 @code{X} and nearest to it.
9084
9085 @item @emph{Example}:
9086 @smallexample
9087 program test_nearest
9088   real :: x, y
9089   x = nearest(42.0, 1.0)
9090   y = nearest(42.0, -1.0)
9091   write (*,"(3(G20.15))") x, y, x - y
9092 end program test_nearest
9093 @end smallexample
9094 @end table
9095
9096
9097
9098 @node NEW_LINE
9099 @section @code{NEW_LINE} --- New line character
9100 @fnindex NEW_LINE
9101 @cindex newline
9102 @cindex output, newline
9103
9104 @table @asis
9105 @item @emph{Description}:
9106 @code{NEW_LINE(C)} returns the new-line character.
9107
9108 @item @emph{Standard}:
9109 Fortran 2003 and later
9110
9111 @item @emph{Class}:
9112 Inquiry function
9113
9114 @item @emph{Syntax}:
9115 @code{RESULT = NEW_LINE(C)}
9116
9117 @item @emph{Arguments}:
9118 @multitable @columnfractions .15 .70
9119 @item @var{C}    @tab The argument shall be a scalar or array of the
9120 type @code{CHARACTER}.
9121 @end multitable
9122
9123 @item @emph{Return value}:
9124 Returns a @var{CHARACTER} scalar of length one with the new-line character of
9125 the same kind as parameter @var{C}.
9126
9127 @item @emph{Example}:
9128 @smallexample
9129 program newline
9130   implicit none
9131   write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
9132 end program newline
9133 @end smallexample
9134 @end table
9135
9136
9137
9138 @node NINT
9139 @section @code{NINT} --- Nearest whole number
9140 @fnindex NINT
9141 @fnindex IDNINT
9142 @cindex rounding, nearest whole number
9143
9144 @table @asis
9145 @item @emph{Description}:
9146 @code{NINT(A)} rounds its argument to the nearest whole number.
9147
9148 @item @emph{Standard}:
9149 Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
9150
9151 @item @emph{Class}:
9152 Elemental function
9153
9154 @item @emph{Syntax}:
9155 @code{RESULT = NINT(A [, KIND])}
9156
9157 @item @emph{Arguments}:
9158 @multitable @columnfractions .15 .70
9159 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
9160 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9161 expression indicating the kind parameter of the result.
9162 @end multitable
9163
9164 @item @emph{Return value}:
9165 Returns @var{A} with the fractional portion of its magnitude eliminated by
9166 rounding to the nearest whole number and with its sign preserved,
9167 converted to an @code{INTEGER} of the default kind.
9168
9169 @item @emph{Example}:
9170 @smallexample
9171 program test_nint
9172   real(4) x4
9173   real(8) x8
9174   x4 = 1.234E0_4
9175   x8 = 4.321_8
9176   print *, nint(x4), idnint(x8)
9177 end program test_nint
9178 @end smallexample
9179
9180 @item @emph{Specific names}:
9181 @multitable @columnfractions .20 .20 .20 .25
9182 @item Name             @tab Argument           @tab Return Type     @tab Standard
9183 @item @code{NINT(A)}   @tab @code{REAL(4) A}   @tab  @code{INTEGER} @tab Fortran 95 and later
9184 @item @code{IDNINT(A)} @tab @code{REAL(8) A}   @tab  @code{INTEGER} @tab Fortran 95 and later
9185 @end multitable
9186
9187 @item @emph{See also}:
9188 @ref{CEILING}, @ref{FLOOR}
9189
9190 @end table
9191
9192
9193
9194 @node NORM2
9195 @section @code{NORM2} --- Euclidean vector norms
9196 @fnindex NORM2
9197 @cindex Euclidean vector norm
9198 @cindex L2 vector norm
9199 @cindex norm, Euclidean
9200
9201 @table @asis
9202 @item @emph{Description}:
9203 Calculates the Euclidean vector norm (@math{L_2} norm) of
9204 of @var{ARRAY} along dimension @var{DIM}.
9205
9206 @item @emph{Standard}:
9207 Fortran 2008 and later
9208
9209 @item @emph{Class}:
9210 Transformational function
9211
9212 @item @emph{Syntax}:
9213 @multitable @columnfractions .80
9214 @item @code{RESULT = NORM2(ARRAY[, DIM])}
9215 @end multitable
9216
9217 @item @emph{Arguments}:
9218 @multitable @columnfractions .15 .70
9219 @item @var{ARRAY} @tab Shall be an array of type @code{REAL}
9220 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
9221 @code{INTEGER} with a value in the range from 1 to n, where n 
9222 equals the rank of @var{ARRAY}.
9223 @end multitable
9224
9225 @item @emph{Return value}:
9226 The result is of the same type as @var{ARRAY}.
9227
9228 If @var{DIM} is absent, a scalar with the square root of the sum of all
9229 elements in @var{ARRAY} squared  is returned. Otherwise, an array of
9230 rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, and a
9231 shape similar to that of @var{ARRAY} with dimension @var{DIM} dropped
9232 is returned.
9233
9234 @item @emph{Example}:
9235 @smallexample
9236 PROGRAM test_sum
9237   REAL :: x(5) = [ real :: 1, 2, 3, 4, 5 ]
9238   print *, NORM2(x)  ! = sqrt(55.) ~ 7.416
9239 END PROGRAM
9240 @end smallexample
9241 @end table
9242
9243
9244
9245 @node NOT
9246 @section @code{NOT} --- Logical negation
9247 @fnindex NOT
9248 @cindex bits, negate
9249 @cindex bitwise logical not
9250 @cindex logical not, bitwise
9251
9252 @table @asis
9253 @item @emph{Description}:
9254 @code{NOT} returns the bitwise Boolean inverse of @var{I}.
9255
9256 @item @emph{Standard}:
9257 Fortran 95 and later
9258
9259 @item @emph{Class}:
9260 Elemental function
9261
9262 @item @emph{Syntax}:
9263 @code{RESULT = NOT(I)}
9264
9265 @item @emph{Arguments}:
9266 @multitable @columnfractions .15 .70
9267 @item @var{I} @tab The type shall be @code{INTEGER}.
9268 @end multitable
9269
9270 @item @emph{Return value}:
9271 The return type is @code{INTEGER}, of the same kind as the
9272 argument.
9273
9274 @item @emph{See also}:
9275 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
9276
9277 @end table
9278
9279
9280
9281 @node NULL
9282 @section @code{NULL} --- Function that returns an disassociated pointer
9283 @fnindex NULL
9284 @cindex pointer, status
9285 @cindex pointer, disassociated
9286
9287 @table @asis
9288 @item @emph{Description}:
9289 Returns a disassociated pointer.
9290
9291 If @var{MOLD} is present, a disassociated pointer of the same type is
9292 returned, otherwise the type is determined by context.
9293
9294 In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
9295 includes cases where it is required.
9296
9297 @item @emph{Standard}:
9298 Fortran 95 and later
9299
9300 @item @emph{Class}:
9301 Transformational function
9302
9303 @item @emph{Syntax}:
9304 @code{PTR => NULL([MOLD])}
9305
9306 @item @emph{Arguments}:
9307 @multitable @columnfractions .15 .70
9308 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
9309 status and of any type.
9310 @end multitable
9311
9312 @item @emph{Return value}:
9313 A disassociated pointer.
9314
9315 @item @emph{Example}:
9316 @smallexample
9317 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
9318 @end smallexample
9319
9320 @item @emph{See also}:
9321 @ref{ASSOCIATED}
9322 @end table
9323
9324
9325
9326 @node NUM_IMAGES
9327 @section @code{NUM_IMAGES} --- Function that returns the number of images
9328 @fnindex NUM_IMAGES
9329 @cindex coarray, @code{NUM_IMAGES}
9330 @cindex images, number of
9331
9332 @table @asis
9333 @item @emph{Description}:
9334 Returns the number of images.
9335
9336 @item @emph{Standard}:
9337 Fortran 2008 and later
9338
9339 @item @emph{Class}:
9340 Transformational function
9341
9342 @item @emph{Syntax}:
9343 @code{RESULT = NUM_IMAGES()}
9344
9345 @item @emph{Arguments}: None.
9346
9347 @item @emph{Return value}:
9348 Scalar default-kind integer.
9349
9350 @item @emph{Example}:
9351 @smallexample
9352 INTEGER :: value[*]
9353 INTEGER :: i
9354 value = THIS_IMAGE()
9355 SYNC ALL
9356 IF (THIS_IMAGE() == 1) THEN
9357   DO i = 1, NUM_IMAGES()
9358     WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
9359   END DO
9360 END IF
9361 @end smallexample
9362
9363 @item @emph{See also}:
9364 @ref{THIS_IMAGE}, @ref{IMAGE_INDEX}
9365 @end table
9366
9367
9368
9369 @node OR
9370 @section @code{OR} --- Bitwise logical OR
9371 @fnindex OR
9372 @cindex bitwise logical or
9373 @cindex logical or, bitwise
9374
9375 @table @asis
9376 @item @emph{Description}:
9377 Bitwise logical @code{OR}.
9378
9379 This intrinsic routine is provided for backwards compatibility with 
9380 GNU Fortran 77.  For integer arguments, programmers should consider
9381 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
9382
9383 @item @emph{Standard}:
9384 GNU extension
9385
9386 @item @emph{Class}:
9387 Function
9388
9389 @item @emph{Syntax}:
9390 @code{RESULT = OR(I, J)}
9391
9392 @item @emph{Arguments}:
9393 @multitable @columnfractions .15 .70
9394 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
9395 type or a scalar @code{LOGICAL} type.
9396 @item @var{J} @tab The type shall be the same as the type of @var{J}.
9397 @end multitable
9398
9399 @item @emph{Return value}:
9400 The return type is either a scalar @code{INTEGER} or a scalar
9401 @code{LOGICAL}.  If the kind type parameters differ, then the
9402 smaller kind type is implicitly converted to larger kind, and the 
9403 return has the larger kind.
9404
9405 @item @emph{Example}:
9406 @smallexample
9407 PROGRAM test_or
9408   LOGICAL :: T = .TRUE., F = .FALSE.
9409   INTEGER :: a, b
9410   DATA a / Z'F' /, b / Z'3' /
9411
9412   WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
9413   WRITE (*,*) OR(a, b)
9414 END PROGRAM
9415 @end smallexample
9416
9417 @item @emph{See also}:
9418 Fortran 95 elemental function: @ref{IOR}
9419 @end table
9420
9421
9422
9423 @node PACK
9424 @section @code{PACK} --- Pack an array into an array of rank one
9425 @fnindex PACK
9426 @cindex array, packing
9427 @cindex array, reduce dimension
9428 @cindex array, gather elements
9429
9430 @table @asis
9431 @item @emph{Description}:
9432 Stores the elements of @var{ARRAY} in an array of rank one.
9433
9434 The beginning of the resulting array is made up of elements whose @var{MASK} 
9435 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
9436 @var{VECTOR}.
9437
9438 @item @emph{Standard}:
9439 Fortran 95 and later
9440
9441 @item @emph{Class}:
9442 Transformational function
9443
9444 @item @emph{Syntax}:
9445 @code{RESULT = PACK(ARRAY, MASK[,VECTOR]}
9446
9447 @item @emph{Arguments}:
9448 @multitable @columnfractions .15 .70
9449 @item @var{ARRAY}  @tab Shall be an array of any type.
9450 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL} and 
9451 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL} 
9452 scalar.
9453 @item @var{VECTOR} @tab (Optional) shall be an array of the same type 
9454 as @var{ARRAY} and of rank one. If present, the number of elements in 
9455 @var{VECTOR} shall be equal to or greater than the number of true elements 
9456 in @var{MASK}. If @var{MASK} is scalar, the number of elements in 
9457 @var{VECTOR} shall be equal to or greater than the number of elements in
9458 @var{ARRAY}.
9459 @end multitable
9460
9461 @item @emph{Return value}:
9462 The result is an array of rank one and the same type as that of @var{ARRAY}.
9463 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
9464 number of @code{TRUE} values in @var{MASK} otherwise.
9465
9466 @item @emph{Example}:
9467 Gathering nonzero elements from an array:
9468 @smallexample
9469 PROGRAM test_pack_1
9470   INTEGER :: m(6)
9471   m = (/ 1, 0, 0, 0, 5, 0 /)
9472   WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0)  ! "1 5"
9473 END PROGRAM
9474 @end smallexample
9475
9476 Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
9477 @smallexample
9478 PROGRAM test_pack_2
9479   INTEGER :: m(4)
9480   m = (/ 1, 0, 0, 2 /)
9481   WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /))  ! "1 2 3 4"
9482 END PROGRAM
9483 @end smallexample
9484
9485 @item @emph{See also}:
9486 @ref{UNPACK}
9487 @end table
9488
9489
9490
9491 @node PARITY
9492 @section @code{PARITY} --- Reduction with exclusive OR
9493 @fnindex PARITY
9494 @cindex Parity
9495 @cindex Reduction, XOR
9496 @cindex XOR reduction
9497
9498 @table @asis
9499 @item @emph{Description}:
9500 Calculates the parity, i.e. the reduction using @code{.XOR.},
9501 of @var{MASK} along dimension @var{DIM}.
9502
9503 @item @emph{Standard}:
9504 Fortran 2008 and later
9505
9506 @item @emph{Class}:
9507 Transformational function
9508
9509 @item @emph{Syntax}:
9510 @multitable @columnfractions .80
9511 @item @code{RESULT = PARITY(MASK[, DIM])}
9512 @end multitable
9513
9514 @item @emph{Arguments}:
9515 @multitable @columnfractions .15 .70
9516 @item @var{LOGICAL} @tab Shall be an array of type @code{LOGICAL}
9517 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
9518 @code{INTEGER} with a value in the range from 1 to n, where n 
9519 equals the rank of @var{MASK}.
9520 @end multitable
9521
9522 @item @emph{Return value}:
9523 The result is of the same type as @var{MASK}.
9524
9525 If @var{DIM} is absent, a scalar with the parity of all elements in
9526 @var{MASK} is returned, i.e. true if an odd number of elements is
9527 @code{.true.} and false otherwise.  If @var{DIM} is present, an array
9528 of rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY},
9529 and a shape similar to that of @var{MASK} with dimension @var{DIM}
9530 dropped is returned.
9531
9532 @item @emph{Example}:
9533 @smallexample
9534 PROGRAM test_sum
9535   LOGICAL :: x(2) = [ .true., .false. ]
9536   print *, PARITY(x) ! prints "T" (true).
9537 END PROGRAM
9538 @end smallexample
9539 @end table
9540
9541
9542
9543 @node PERROR
9544 @section @code{PERROR} --- Print system error message
9545 @fnindex PERROR
9546 @cindex system, error handling
9547
9548 @table @asis
9549 @item @emph{Description}:
9550 Prints (on the C @code{stderr} stream) a newline-terminated error
9551 message corresponding to the last system error. This is prefixed by
9552 @var{STRING}, a colon and a space. See @code{perror(3)}.
9553
9554 @item @emph{Standard}:
9555 GNU extension
9556
9557 @item @emph{Class}:
9558 Subroutine
9559
9560 @item @emph{Syntax}:
9561 @code{CALL PERROR(STRING)}
9562
9563 @item @emph{Arguments}:
9564 @multitable @columnfractions .15 .70
9565 @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
9566 default kind.
9567 @end multitable
9568
9569 @item @emph{See also}:
9570 @ref{IERRNO}
9571 @end table
9572
9573
9574
9575 @node PRECISION
9576 @section @code{PRECISION} --- Decimal precision of a real kind
9577 @fnindex PRECISION
9578 @cindex model representation, precision
9579
9580 @table @asis
9581 @item @emph{Description}:
9582 @code{PRECISION(X)} returns the decimal precision in the model of the
9583 type of @code{X}.
9584
9585 @item @emph{Standard}:
9586 Fortran 95 and later
9587
9588 @item @emph{Class}:
9589 Inquiry function
9590
9591 @item @emph{Syntax}:
9592 @code{RESULT = PRECISION(X)}
9593
9594 @item @emph{Arguments}:
9595 @multitable @columnfractions .15 .70
9596 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
9597 @end multitable
9598
9599 @item @emph{Return value}:
9600 The return value is of type @code{INTEGER} and of the default integer
9601 kind.
9602
9603 @item @emph{See also}:
9604 @ref{SELECTED_REAL_KIND}, @ref{RANGE}
9605
9606 @item @emph{Example}:
9607 @smallexample
9608 program prec_and_range
9609   real(kind=4) :: x(2)
9610   complex(kind=8) :: y
9611
9612   print *, precision(x), range(x)
9613   print *, precision(y), range(y)
9614 end program prec_and_range
9615 @end smallexample
9616 @end table
9617
9618
9619
9620 @node POPCNT
9621 @section @code{POPCNT} --- Number of bits set
9622 @fnindex POPCNT
9623 @cindex binary representation
9624 @cindex bits set
9625
9626 @table @asis
9627 @item @emph{Description}:
9628 @code{POPCNT(I)} returns the number of bits set ('1' bits) in the binary
9629 representation of @code{I}.
9630
9631 @item @emph{Standard}:
9632 Fortran 2008 and later
9633
9634 @item @emph{Class}:
9635 Elemental function
9636
9637 @item @emph{Syntax}:
9638 @code{RESULT = POPCNT(I)}
9639
9640 @item @emph{Arguments}:
9641 @multitable @columnfractions .15 .70
9642 @item @var{I} @tab Shall be of type @code{INTEGER}.
9643 @end multitable
9644
9645 @item @emph{Return value}:
9646 The return value is of type @code{INTEGER} and of the default integer
9647 kind.
9648
9649 @item @emph{See also}:
9650 @ref{POPPAR}, @ref{LEADZ}, @ref{TRAILZ}
9651
9652 @item @emph{Example}:
9653 @smallexample
9654 program test_population
9655   print *, popcnt(127),       poppar(127)
9656   print *, popcnt(huge(0_4)), poppar(huge(0_4))
9657   print *, popcnt(huge(0_8)), poppar(huge(0_8))
9658 end program test_population
9659 @end smallexample
9660 @end table
9661
9662
9663 @node POPPAR
9664 @section @code{POPPAR} --- Parity of the number of bits set
9665 @fnindex POPPAR
9666 @cindex binary representation
9667 @cindex parity
9668
9669 @table @asis
9670 @item @emph{Description}:
9671 @code{POPPAR(I)} returns parity of the integer @code{I}, i.e. the parity
9672 of the number of bits set ('1' bits) in the binary representation of
9673 @code{I}. It is equal to 0 if @code{I} has an even number of bits set,
9674 and 1 for an odd number of '1' bits.
9675
9676 @item @emph{Standard}:
9677 Fortran 2008 and later
9678
9679 @item @emph{Class}:
9680 Elemental function
9681
9682 @item @emph{Syntax}:
9683 @code{RESULT = POPPAR(I)}
9684
9685 @item @emph{Arguments}:
9686 @multitable @columnfractions .15 .70
9687 @item @var{I} @tab Shall be of type @code{INTEGER}.
9688 @end multitable
9689
9690 @item @emph{Return value}:
9691 The return value is of type @code{INTEGER} and of the default integer
9692 kind.
9693
9694 @item @emph{See also}:
9695 @ref{POPCNT}, @ref{LEADZ}, @ref{TRAILZ}
9696
9697 @item @emph{Example}:
9698 @smallexample
9699 program test_population
9700   print *, popcnt(127),       poppar(127)
9701   print *, popcnt(huge(0_4)), poppar(huge(0_4))
9702   print *, popcnt(huge(0_8)), poppar(huge(0_8))
9703 end program test_population
9704 @end smallexample
9705 @end table
9706
9707
9708
9709 @node PRESENT
9710 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
9711 @fnindex PRESENT
9712
9713 @table @asis
9714 @item @emph{Description}:
9715 Determines whether an optional dummy argument is present.
9716
9717 @item @emph{Standard}:
9718 Fortran 95 and later
9719
9720 @item @emph{Class}:
9721 Inquiry function
9722
9723 @item @emph{Syntax}:
9724 @code{RESULT = PRESENT(A)}
9725
9726 @item @emph{Arguments}:
9727 @multitable @columnfractions .15 .70
9728 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
9729 value, or a dummy procedure. It shall be the name of an optional dummy argument
9730 accessible within the current subroutine or function.
9731 @end multitable
9732
9733 @item @emph{Return value}:
9734 Returns either @code{TRUE} if the optional argument @var{A} is present, or
9735 @code{FALSE} otherwise.
9736
9737 @item @emph{Example}:
9738 @smallexample
9739 PROGRAM test_present
9740   WRITE(*,*) f(), f(42)      ! "F T"
9741 CONTAINS
9742   LOGICAL FUNCTION f(x)
9743     INTEGER, INTENT(IN), OPTIONAL :: x
9744     f = PRESENT(x)
9745   END FUNCTION
9746 END PROGRAM
9747 @end smallexample
9748 @end table
9749
9750
9751
9752 @node PRODUCT
9753 @section @code{PRODUCT} --- Product of array elements
9754 @fnindex PRODUCT
9755 @cindex array, product
9756 @cindex array, multiply elements
9757 @cindex array, conditionally multiply elements
9758 @cindex multiply array elements
9759
9760 @table @asis
9761 @item @emph{Description}:
9762 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
9763 the corresponding element in @var{MASK} is @code{TRUE}.
9764
9765 @item @emph{Standard}:
9766 Fortran 95 and later
9767
9768 @item @emph{Class}:
9769 Transformational function
9770
9771 @item @emph{Syntax}:
9772 @multitable @columnfractions .80
9773 @item @code{RESULT = PRODUCT(ARRAY[, MASK])}
9774 @item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
9775 @end multitable
9776
9777 @item @emph{Arguments}:
9778 @multitable @columnfractions .15 .70
9779 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
9780 @code{REAL} or @code{COMPLEX}.
9781 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
9782 @code{INTEGER} with a value in the range from 1 to n, where n 
9783 equals the rank of @var{ARRAY}.
9784 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
9785 and either be a scalar or an array of the same shape as @var{ARRAY}.
9786 @end multitable
9787
9788 @item @emph{Return value}:
9789 The result is of the same type as @var{ARRAY}.
9790
9791 If @var{DIM} is absent, a scalar with the product of all elements in 
9792 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals 
9793 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with 
9794 dimension @var{DIM} dropped is returned.
9795
9796
9797 @item @emph{Example}:
9798 @smallexample
9799 PROGRAM test_product
9800   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
9801   print *, PRODUCT(x)                    ! all elements, product = 120
9802   print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
9803 END PROGRAM
9804 @end smallexample
9805
9806 @item @emph{See also}:
9807 @ref{SUM}
9808 @end table
9809
9810
9811
9812 @node RADIX
9813 @section @code{RADIX} --- Base of a model number
9814 @fnindex RADIX
9815 @cindex model representation, base
9816 @cindex model representation, radix
9817
9818 @table @asis
9819 @item @emph{Description}:
9820 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
9821
9822 @item @emph{Standard}:
9823 Fortran 95 and later
9824
9825 @item @emph{Class}:
9826 Inquiry function
9827
9828 @item @emph{Syntax}:
9829 @code{RESULT = RADIX(X)}
9830
9831 @item @emph{Arguments}:
9832 @multitable @columnfractions .15 .70
9833 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
9834 @end multitable
9835
9836 @item @emph{Return value}:
9837 The return value is a scalar of type @code{INTEGER} and of the default
9838 integer kind.
9839
9840 @item @emph{See also}:
9841 @ref{SELECTED_REAL_KIND}
9842
9843 @item @emph{Example}:
9844 @smallexample
9845 program test_radix
9846   print *, "The radix for the default integer kind is", radix(0)
9847   print *, "The radix for the default real kind is", radix(0.0)
9848 end program test_radix
9849 @end smallexample
9850
9851 @end table
9852
9853
9854
9855 @node RAN
9856 @section @code{RAN} --- Real pseudo-random number
9857 @fnindex RAN
9858 @cindex random number generation
9859
9860 @table @asis
9861 @item @emph{Description}:
9862 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
9863 provided as an alias for @code{RAND}.  See @ref{RAND} for complete
9864 documentation.
9865
9866 @item @emph{Standard}:
9867 GNU extension
9868
9869 @item @emph{Class}:
9870 Function
9871
9872 @item @emph{See also}:
9873 @ref{RAND}, @ref{RANDOM_NUMBER}
9874 @end table
9875
9876
9877
9878 @node RAND
9879 @section @code{RAND} --- Real pseudo-random number
9880 @fnindex RAND
9881 @cindex random number generation
9882
9883 @table @asis
9884 @item @emph{Description}:
9885 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
9886 distribution between 0 and 1. If @var{FLAG} is 0, the next number
9887 in the current sequence is returned; if @var{FLAG} is 1, the generator
9888 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
9889 it is used as a new seed with @code{SRAND}.
9890
9891 This intrinsic routine is provided for backwards compatibility with
9892 GNU Fortran 77. It implements a simple modulo generator as provided 
9893 by @command{g77}. For new code, one should consider the use of 
9894 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
9895
9896 @item @emph{Standard}:
9897 GNU extension
9898
9899 @item @emph{Class}:
9900 Function
9901
9902 @item @emph{Syntax}:
9903 @code{RESULT = RAND(I)}
9904
9905 @item @emph{Arguments}:
9906 @multitable @columnfractions .15 .70
9907 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
9908 @end multitable
9909
9910 @item @emph{Return value}:
9911 The return value is of @code{REAL} type and the default kind.
9912
9913 @item @emph{Example}:
9914 @smallexample
9915 program test_rand
9916   integer,parameter :: seed = 86456
9917   
9918   call srand(seed)
9919   print *, rand(), rand(), rand(), rand()
9920   print *, rand(seed), rand(), rand(), rand()
9921 end program test_rand
9922 @end smallexample
9923
9924 @item @emph{See also}:
9925 @ref{SRAND}, @ref{RANDOM_NUMBER}
9926
9927 @end table
9928
9929
9930
9931 @node RANDOM_NUMBER
9932 @section @code{RANDOM_NUMBER} --- Pseudo-random number
9933 @fnindex RANDOM_NUMBER
9934 @cindex random number generation
9935
9936 @table @asis
9937 @item @emph{Description}:
9938 Returns a single pseudorandom number or an array of pseudorandom numbers
9939 from the uniform distribution over the range @math{ 0 \leq x < 1}.
9940
9941 The runtime-library implements George Marsaglia's KISS (Keep It Simple 
9942 Stupid) random number generator (RNG). This RNG combines:
9943 @enumerate
9944 @item The congruential generator @math{x(n) = 69069 \cdot x(n-1) + 1327217885}
9945 with a period of @math{2^{32}},
9946 @item A 3-shift shift-register generator with a period of @math{2^{32} - 1},
9947 @item  Two 16-bit multiply-with-carry generators with a period of
9948 @math{597273182964842497 > 2^{59}}.
9949 @end enumerate
9950 The overall period exceeds @math{2^{123}}.
9951
9952 Please note, this RNG is thread safe if used within OpenMP directives,
9953 i.e., its state will be consistent while called from multiple threads.
9954 However, the KISS generator does not create random numbers in parallel 
9955 from multiple sources, but in sequence from a single source. If an
9956 OpenMP-enabled application heavily relies on random numbers, one should 
9957 consider employing a dedicated parallel random number generator instead.
9958
9959 @item @emph{Standard}:
9960 Fortran 95 and later
9961
9962 @item @emph{Class}:
9963 Subroutine
9964
9965 @item @emph{Syntax}:
9966 @code{RANDOM_NUMBER(HARVEST)}
9967
9968 @item @emph{Arguments}:
9969 @multitable @columnfractions .15 .70
9970 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
9971 @end multitable
9972
9973 @item @emph{Example}:
9974 @smallexample
9975 program test_random_number
9976   REAL :: r(5,5)
9977   CALL init_random_seed()         ! see example of RANDOM_SEED
9978   CALL RANDOM_NUMBER(r)
9979 end program
9980 @end smallexample
9981
9982 @item @emph{See also}:
9983 @ref{RANDOM_SEED}
9984 @end table
9985
9986
9987
9988 @node RANDOM_SEED
9989 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
9990 @fnindex RANDOM_SEED
9991 @cindex random number generation, seeding
9992 @cindex seeding a random number generator
9993
9994 @table @asis
9995 @item @emph{Description}:
9996 Restarts or queries the state of the pseudorandom number generator used by 
9997 @code{RANDOM_NUMBER}.
9998
9999 If @code{RANDOM_SEED} is called without arguments, it is initialized to
10000 a default state. The example below shows how to initialize the random 
10001 seed based on the system's time.
10002
10003 @item @emph{Standard}:
10004 Fortran 95 and later
10005
10006 @item @emph{Class}:
10007 Subroutine
10008
10009 @item @emph{Syntax}:
10010 @code{CALL RANDOM_SEED([SIZE, PUT, GET])}
10011
10012 @item @emph{Arguments}:
10013 @multitable @columnfractions .15 .70
10014 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default 
10015 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size 
10016 of the arrays used with the @var{PUT} and @var{GET} arguments.
10017 @item @var{PUT}  @tab (Optional) Shall be an array of type default 
10018 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of 
10019 the array must be larger than or equal to the number returned by the 
10020 @var{SIZE} argument.
10021 @item @var{GET}  @tab (Optional) Shall be an array of type default 
10022 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size 
10023 of the array must be larger than or equal to the number returned by 
10024 the @var{SIZE} argument.
10025 @end multitable
10026
10027 @item @emph{Example}:
10028 @smallexample
10029 SUBROUTINE init_random_seed()
10030   INTEGER :: i, n, clock
10031   INTEGER, DIMENSION(:), ALLOCATABLE :: seed
10032
10033   CALL RANDOM_SEED(size = n)
10034   ALLOCATE(seed(n))
10035
10036   CALL SYSTEM_CLOCK(COUNT=clock)
10037
10038   seed = clock + 37 * (/ (i - 1, i = 1, n) /)
10039   CALL RANDOM_SEED(PUT = seed)
10040
10041   DEALLOCATE(seed)
10042 END SUBROUTINE
10043 @end smallexample
10044
10045 @item @emph{See also}:
10046 @ref{RANDOM_NUMBER}
10047 @end table
10048
10049
10050
10051 @node RANGE
10052 @section @code{RANGE} --- Decimal exponent range
10053 @fnindex RANGE
10054 @cindex model representation, range
10055
10056 @table @asis
10057 @item @emph{Description}:
10058 @code{RANGE(X)} returns the decimal exponent range in the model of the
10059 type of @code{X}.
10060
10061 @item @emph{Standard}:
10062 Fortran 95 and later
10063
10064 @item @emph{Class}:
10065 Inquiry function
10066
10067 @item @emph{Syntax}:
10068 @code{RESULT = RANGE(X)}
10069
10070 @item @emph{Arguments}:
10071 @multitable @columnfractions .15 .70
10072 @item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL}
10073 or @code{COMPLEX}.
10074 @end multitable
10075
10076 @item @emph{Return value}:
10077 The return value is of type @code{INTEGER} and of the default integer
10078 kind.
10079
10080 @item @emph{See also}:
10081 @ref{SELECTED_REAL_KIND}, @ref{PRECISION}
10082
10083 @item @emph{Example}:
10084 See @code{PRECISION} for an example.
10085 @end table
10086
10087
10088
10089 @node REAL
10090 @section @code{REAL} --- Convert to real type 
10091 @fnindex REAL
10092 @fnindex REALPART
10093 @fnindex FLOAT
10094 @fnindex DFLOAT
10095 @fnindex SNGL
10096 @cindex conversion, to real
10097 @cindex complex numbers, real part
10098
10099 @table @asis
10100 @item @emph{Description}:
10101 @code{REAL(A [, KIND])} converts its argument @var{A} to a real type.  The
10102 @code{REALPART} function is provided for compatibility with @command{g77},
10103 and its use is strongly discouraged.
10104
10105 @item @emph{Standard}:
10106 Fortran 77 and later
10107
10108 @item @emph{Class}:
10109 Elemental function
10110
10111 @item @emph{Syntax}:
10112 @multitable @columnfractions .80
10113 @item @code{RESULT = REAL(A [, KIND])}
10114 @item @code{RESULT = REALPART(Z)}
10115 @end multitable
10116
10117 @item @emph{Arguments}:
10118 @multitable @columnfractions .15 .70
10119 @item @var{A}    @tab Shall be @code{INTEGER}, @code{REAL}, or
10120 @code{COMPLEX}.
10121 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10122 expression indicating the kind parameter of the result.
10123 @end multitable
10124
10125 @item @emph{Return value}:
10126 These functions return a @code{REAL} variable or array under
10127 the following rules: 
10128
10129 @table @asis
10130 @item (A)
10131 @code{REAL(A)} is converted to a default real type if @var{A} is an 
10132 integer or real variable.
10133 @item (B)
10134 @code{REAL(A)} is converted to a real type with the kind type parameter
10135 of @var{A} if @var{A} is a complex variable.
10136 @item (C)
10137 @code{REAL(A, KIND)} is converted to a real type with kind type
10138 parameter @var{KIND} if @var{A} is a complex, integer, or real
10139 variable.
10140 @end table
10141
10142 @item @emph{Example}:
10143 @smallexample
10144 program test_real
10145   complex :: x = (1.0, 2.0)
10146   print *, real(x), real(x,8), realpart(x)
10147 end program test_real
10148 @end smallexample
10149
10150 @item @emph{Specific names}:
10151 @multitable @columnfractions .20 .20 .20 .25
10152 @item Name             @tab Argument           @tab Return type     @tab Standard
10153 @item @code{FLOAT(A)}  @tab @code{INTEGER(4)}  @tab @code{REAL(4)}  @tab Fortran 77 and later
10154 @item @code{DFLOAT(A)} @tab @code{INTEGER(4)}  @tab @code{REAL(8)}  @tab GNU extension
10155 @item @code{SNGL(A)}   @tab @code{INTEGER(8)}  @tab @code{REAL(4)}  @tab Fortran 77 and later
10156 @end multitable
10157
10158
10159 @item @emph{See also}:
10160 @ref{DBLE}
10161
10162 @end table
10163
10164
10165
10166 @node RENAME
10167 @section @code{RENAME} --- Rename a file
10168 @fnindex RENAME
10169 @cindex file system, rename file
10170
10171 @table @asis
10172 @item @emph{Description}:
10173 Renames a file from file @var{PATH1} to @var{PATH2}. A null
10174 character (@code{CHAR(0)}) can be used to mark the end of the names in
10175 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
10176 names are ignored.  If the @var{STATUS} argument is supplied, it
10177 contains 0 on success or a nonzero error code upon return; see
10178 @code{rename(2)}.
10179
10180 This intrinsic is provided in both subroutine and function forms;
10181 however, only one form can be used in any given program unit.
10182
10183 @item @emph{Standard}:
10184 GNU extension
10185
10186 @item @emph{Class}:
10187 Subroutine, function
10188
10189 @item @emph{Syntax}:
10190 @multitable @columnfractions .80
10191 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
10192 @item @code{STATUS = RENAME(PATH1, PATH2)}
10193 @end multitable
10194
10195 @item @emph{Arguments}:
10196 @multitable @columnfractions .15 .70
10197 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
10198 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
10199 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10200 @end multitable
10201
10202 @item @emph{See also}:
10203 @ref{LINK}
10204
10205 @end table
10206
10207
10208
10209 @node REPEAT
10210 @section @code{REPEAT} --- Repeated string concatenation 
10211 @fnindex REPEAT
10212 @cindex string, repeat
10213 @cindex string, concatenate
10214
10215 @table @asis
10216 @item @emph{Description}:
10217 Concatenates @var{NCOPIES} copies of a string.
10218
10219 @item @emph{Standard}:
10220 Fortran 95 and later
10221
10222 @item @emph{Class}:
10223 Transformational function
10224
10225 @item @emph{Syntax}:
10226 @code{RESULT = REPEAT(STRING, NCOPIES)}
10227
10228 @item @emph{Arguments}:
10229 @multitable @columnfractions .15 .70
10230 @item @var{STRING}  @tab Shall be scalar and of type @code{CHARACTER}.
10231 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
10232 @end multitable
10233
10234 @item @emph{Return value}:
10235 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies 
10236 of @var{STRING}.
10237
10238 @item @emph{Example}:
10239 @smallexample
10240 program test_repeat
10241   write(*,*) repeat("x", 5)   ! "xxxxx"
10242 end program
10243 @end smallexample
10244 @end table
10245
10246
10247
10248 @node RESHAPE
10249 @section @code{RESHAPE} --- Function to reshape an array
10250 @fnindex RESHAPE
10251 @cindex array, change dimensions
10252 @cindex array, transmogrify
10253
10254 @table @asis
10255 @item @emph{Description}:
10256 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
10257 the new array may be padded with elements from @var{PAD} or permuted
10258 as defined by @var{ORDER}.
10259
10260 @item @emph{Standard}:
10261 Fortran 95 and later
10262
10263 @item @emph{Class}:
10264 Transformational function
10265
10266 @item @emph{Syntax}:
10267 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
10268
10269 @item @emph{Arguments}:
10270 @multitable @columnfractions .15 .70
10271 @item @var{SOURCE} @tab Shall be an array of any type.
10272 @item @var{SHAPE}  @tab Shall be of type @code{INTEGER} and an 
10273 array of rank one. Its values must be positive or zero.
10274 @item @var{PAD}    @tab (Optional) shall be an array of the same 
10275 type as @var{SOURCE}.
10276 @item @var{ORDER}  @tab (Optional) shall be of type @code{INTEGER}
10277 and an array of the same shape as @var{SHAPE}. Its values shall
10278 be a permutation of the numbers from 1 to n, where n is the size of 
10279 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
10280 be assumed.
10281 @end multitable
10282
10283 @item @emph{Return value}:
10284 The result is an array of shape @var{SHAPE} with the same type as 
10285 @var{SOURCE}. 
10286
10287 @item @emph{Example}:
10288 @smallexample
10289 PROGRAM test_reshape
10290   INTEGER, DIMENSION(4) :: x
10291   WRITE(*,*) SHAPE(x)                       ! prints "4"
10292   WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/)))    ! prints "2 2"
10293 END PROGRAM
10294 @end smallexample
10295
10296 @item @emph{See also}:
10297 @ref{SHAPE}
10298 @end table
10299
10300
10301
10302 @node RRSPACING
10303 @section @code{RRSPACING} --- Reciprocal of the relative spacing
10304 @fnindex RRSPACING
10305 @cindex real number, relative spacing
10306 @cindex floating point, relative spacing
10307
10308
10309 @table @asis
10310 @item @emph{Description}:
10311 @code{RRSPACING(X)} returns the  reciprocal of the relative spacing of
10312 model numbers near @var{X}.
10313
10314 @item @emph{Standard}:
10315 Fortran 95 and later
10316
10317 @item @emph{Class}:
10318 Elemental function
10319
10320 @item @emph{Syntax}:
10321 @code{RESULT = RRSPACING(X)}
10322
10323 @item @emph{Arguments}:
10324 @multitable @columnfractions .15 .70
10325 @item @var{X} @tab Shall be of type @code{REAL}.
10326 @end multitable
10327
10328 @item @emph{Return value}:
10329 The return value is of the same type and kind as @var{X}.
10330 The value returned is equal to
10331 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
10332
10333 @item @emph{See also}:
10334 @ref{SPACING}
10335 @end table
10336
10337
10338
10339 @node RSHIFT
10340 @section @code{RSHIFT} --- Right shift bits
10341 @fnindex RSHIFT
10342 @cindex bits, shift right
10343
10344 @table @asis
10345 @item @emph{Description}:
10346 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
10347 bits shifted right by @var{SHIFT} places.  If the absolute value of
10348 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
10349 Bits shifted out from the right end are lost. The fill is arithmetic: the
10350 bits shifted in from the left end are equal to the leftmost bit, which in
10351 two's complement representation is the sign bit.
10352
10353 This function has been superseded by the @code{SHIFTA} intrinsic, which
10354 is standard in Fortran 2008 and later.
10355
10356 @item @emph{Standard}:
10357 GNU extension
10358
10359 @item @emph{Class}:
10360 Elemental function
10361
10362 @item @emph{Syntax}:
10363 @code{RESULT = RSHIFT(I, SHIFT)}
10364
10365 @item @emph{Arguments}:
10366 @multitable @columnfractions .15 .70
10367 @item @var{I} @tab The type shall be @code{INTEGER}.
10368 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
10369 @end multitable
10370
10371 @item @emph{Return value}:
10372 The return value is of type @code{INTEGER} and of the same kind as
10373 @var{I}.
10374
10375 @item @emph{See also}:
10376 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}, @ref{SHIFTA}, @ref{SHIFTR},
10377 @ref{SHIFTL}
10378
10379 @end table
10380
10381
10382
10383 @node SAME_TYPE_AS
10384 @section @code{SAME_TYPE_AS} ---  Query dynamic types for equality
10385 @fnindex SAME_TYPE_AS
10386
10387 @table @asis
10388 @item @emph{Description}:
10389 Query dynamic types for equality.
10390
10391 @item @emph{Standard}:
10392 Fortran 2003 and later
10393
10394 @item @emph{Class}:
10395 Inquiry function
10396
10397 @item @emph{Syntax}:
10398 @code{RESULT = SAME_TYPE_AS(A, B)}
10399
10400 @item @emph{Arguments}:
10401 @multitable @columnfractions .15 .70
10402 @item @var{A} @tab Shall be an object of extensible declared type or
10403 unlimited polymorphic.
10404 @item @var{B} @tab Shall be an object of extensible declared type or
10405 unlimited polymorphic.
10406 @end multitable
10407
10408 @item @emph{Return value}:
10409 The return value is a scalar of type default logical. It is true if and
10410 only if the dynamic type of A is the same as the dynamic type of B.
10411
10412 @item @emph{See also}:
10413 @ref{EXTENDS_TYPE_OF}
10414
10415 @end table
10416
10417
10418
10419 @node SCALE
10420 @section @code{SCALE} --- Scale a real value
10421 @fnindex SCALE
10422 @cindex real number, scale
10423 @cindex floating point, scale
10424
10425 @table @asis
10426 @item @emph{Description}:
10427 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
10428
10429 @item @emph{Standard}:
10430 Fortran 95 and later
10431
10432 @item @emph{Class}:
10433 Elemental function
10434
10435 @item @emph{Syntax}:
10436 @code{RESULT = SCALE(X, I)}
10437
10438 @item @emph{Arguments}:
10439 @multitable @columnfractions .15 .70
10440 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
10441 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
10442 @end multitable
10443
10444 @item @emph{Return value}:
10445 The return value is of the same type and kind as @var{X}.
10446 Its value is @code{X * RADIX(X)**I}.
10447
10448 @item @emph{Example}:
10449 @smallexample
10450 program test_scale
10451   real :: x = 178.1387e-4
10452   integer :: i = 5
10453   print *, scale(x,i), x*radix(x)**i
10454 end program test_scale
10455 @end smallexample
10456
10457 @end table
10458
10459
10460
10461 @node SCAN
10462 @section @code{SCAN} --- Scan a string for the presence of a set of characters
10463 @fnindex SCAN
10464 @cindex string, find subset
10465
10466 @table @asis
10467 @item @emph{Description}:
10468 Scans a @var{STRING} for any of the characters in a @var{SET} 
10469 of characters.
10470
10471 If @var{BACK} is either absent or equals @code{FALSE}, this function
10472 returns the position of the leftmost character of @var{STRING} that is
10473 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
10474 is returned. If no character of @var{SET} is found in @var{STRING}, the 
10475 result is zero.
10476
10477 @item @emph{Standard}:
10478 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
10479
10480 @item @emph{Class}:
10481 Elemental function
10482
10483 @item @emph{Syntax}:
10484 @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
10485
10486 @item @emph{Arguments}:
10487 @multitable @columnfractions .15 .70
10488 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
10489 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
10490 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
10491 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
10492 expression indicating the kind parameter of the result.
10493 @end multitable
10494
10495 @item @emph{Return value}:
10496 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
10497 @var{KIND} is absent, the return value is of default integer kind.
10498
10499 @item @emph{Example}:
10500 @smallexample
10501 PROGRAM test_scan
10502   WRITE(*,*) SCAN("FORTRAN", "AO")          ! 2, found 'O'
10503   WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.)  ! 6, found 'A'
10504   WRITE(*,*) SCAN("FORTRAN", "C++")         ! 0, found none
10505 END PROGRAM
10506 @end smallexample
10507
10508 @item @emph{See also}:
10509 @ref{INDEX intrinsic}, @ref{VERIFY}
10510 @end table
10511
10512
10513
10514 @node SECNDS
10515 @section @code{SECNDS} --- Time function
10516 @fnindex SECNDS
10517 @cindex time, elapsed
10518 @cindex elapsed time
10519
10520 @table @asis
10521 @item @emph{Description}:
10522 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
10523 @var{X} is a reference time, also in seconds. If this is zero, the time in
10524 seconds from midnight is returned. This function is non-standard and its
10525 use is discouraged.
10526
10527 @item @emph{Standard}:
10528 GNU extension
10529
10530 @item @emph{Class}:
10531 Function
10532
10533 @item @emph{Syntax}:
10534 @code{RESULT = SECNDS (X)}
10535
10536 @item @emph{Arguments}:
10537 @multitable @columnfractions .15 .70
10538 @item @var{T}     @tab Shall be of type @code{REAL(4)}.
10539 @item @var{X}     @tab Shall be of type @code{REAL(4)}.
10540 @end multitable
10541
10542 @item @emph{Return value}:
10543 None
10544
10545 @item @emph{Example}:
10546 @smallexample
10547 program test_secnds
10548     integer :: i
10549     real(4) :: t1, t2
10550     print *, secnds (0.0)   ! seconds since midnight
10551     t1 = secnds (0.0)       ! reference time
10552     do i = 1, 10000000      ! do something
10553     end do
10554     t2 = secnds (t1)        ! elapsed time
10555     print *, "Something took ", t2, " seconds."
10556 end program test_secnds
10557 @end smallexample
10558 @end table
10559
10560
10561
10562 @node SECOND
10563 @section @code{SECOND} --- CPU time function
10564 @fnindex SECOND
10565 @cindex time, elapsed
10566 @cindex elapsed time
10567
10568 @table @asis
10569 @item @emph{Description}:
10570 Returns a @code{REAL(4)} value representing the elapsed CPU time in
10571 seconds.  This provides the same functionality as the standard
10572 @code{CPU_TIME} intrinsic, and is only included for backwards
10573 compatibility.
10574
10575 This intrinsic is provided in both subroutine and function forms;
10576 however, only one form can be used in any given program unit.
10577
10578 @item @emph{Standard}:
10579 GNU extension
10580
10581 @item @emph{Class}:
10582 Subroutine, function
10583
10584 @item @emph{Syntax}:
10585 @multitable @columnfractions .80
10586 @item @code{CALL SECOND(TIME)}
10587 @item @code{TIME = SECOND()}
10588 @end multitable
10589
10590 @item @emph{Arguments}:
10591 @multitable @columnfractions .15 .70
10592 @item @var{TIME}  @tab Shall be of type @code{REAL(4)}.
10593 @end multitable
10594
10595 @item @emph{Return value}:
10596 In either syntax, @var{TIME} is set to the process's current runtime in
10597 seconds.
10598
10599 @item @emph{See also}:
10600 @ref{CPU_TIME}
10601
10602 @end table
10603
10604
10605
10606 @node SELECTED_CHAR_KIND
10607 @section @code{SELECTED_CHAR_KIND} --- Choose character kind
10608 @fnindex SELECTED_CHAR_KIND
10609 @cindex character kind
10610 @cindex kind, character
10611
10612 @table @asis
10613 @item @emph{Description}:
10614
10615 @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
10616 set named @var{NAME}, if a character set with such a name is supported,
10617 or @math{-1} otherwise. Currently, supported character sets include
10618 ``ASCII'' and ``DEFAULT'', which are equivalent, and ``ISO_10646''
10619 (Universal Character Set, UCS-4) which is commonly known as Unicode.
10620
10621 @item @emph{Standard}:
10622 Fortran 2003 and later
10623
10624 @item @emph{Class}:
10625 Transformational function
10626
10627 @item @emph{Syntax}:
10628 @code{RESULT = SELECTED_CHAR_KIND(NAME)}
10629
10630 @item @emph{Arguments}:
10631 @multitable @columnfractions .15 .70
10632 @item @var{NAME} @tab Shall be a scalar and of the default character type.
10633 @end multitable
10634
10635 @item @emph{Example}:
10636 @smallexample
10637 program character_kind
10638   use iso_fortran_env
10639   implicit none
10640   integer, parameter :: ascii = selected_char_kind ("ascii")
10641   integer, parameter :: ucs4  = selected_char_kind ('ISO_10646')
10642
10643   character(kind=ascii, len=26) :: alphabet
10644   character(kind=ucs4,  len=30) :: hello_world
10645
10646   alphabet = ascii_"abcdefghijklmnopqrstuvwxyz"
10647   hello_world = ucs4_'Hello World and Ni Hao -- ' &
10648                 // char (int (z'4F60'), ucs4)     &
10649                 // char (int (z'597D'), ucs4)
10650
10651   write (*,*) alphabet
10652
10653   open (output_unit, encoding='UTF-8')
10654   write (*,*) trim (hello_world)
10655 end program character_kind
10656 @end smallexample
10657 @end table
10658
10659
10660
10661 @node SELECTED_INT_KIND
10662 @section @code{SELECTED_INT_KIND} --- Choose integer kind
10663 @fnindex SELECTED_INT_KIND
10664 @cindex integer kind
10665 @cindex kind, integer
10666
10667 @table @asis
10668 @item @emph{Description}:
10669 @code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer
10670 type that can represent all values ranging from @math{-10^R} (exclusive)
10671 to @math{10^R} (exclusive). If there is no integer kind that accommodates
10672 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
10673
10674 @item @emph{Standard}:
10675 Fortran 95 and later
10676
10677 @item @emph{Class}:
10678 Transformational function
10679
10680 @item @emph{Syntax}:
10681 @code{RESULT = SELECTED_INT_KIND(R)}
10682
10683 @item @emph{Arguments}:
10684 @multitable @columnfractions .15 .70
10685 @item @var{R} @tab Shall be a scalar and of type @code{INTEGER}.
10686 @end multitable
10687
10688 @item @emph{Example}:
10689 @smallexample
10690 program large_integers
10691   integer,parameter :: k5 = selected_int_kind(5)
10692   integer,parameter :: k15 = selected_int_kind(15)
10693   integer(kind=k5) :: i5
10694   integer(kind=k15) :: i15
10695
10696   print *, huge(i5), huge(i15)
10697
10698   ! The following inequalities are always true
10699   print *, huge(i5) >= 10_k5**5-1
10700   print *, huge(i15) >= 10_k15**15-1
10701 end program large_integers
10702 @end smallexample
10703 @end table
10704
10705
10706
10707 @node SELECTED_REAL_KIND
10708 @section @code{SELECTED_REAL_KIND} --- Choose real kind
10709 @fnindex SELECTED_REAL_KIND
10710 @cindex real kind
10711 @cindex kind, real
10712 @cindex radix, real
10713
10714 @table @asis
10715 @item @emph{Description}:
10716 @code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type
10717 with decimal precision of at least @code{P} digits, exponent range of
10718 at least @code{R}, and with a radix of @code{RADIX}.
10719
10720 @item @emph{Standard}:
10721 Fortran 95 and later, with @code{RADIX} Fortran 2008 or later
10722
10723 @item @emph{Class}:
10724 Transformational function
10725
10726 @item @emph{Syntax}:
10727 @code{RESULT = SELECTED_REAL_KIND([P, R, RADIX])}
10728
10729 @item @emph{Arguments}:
10730 @multitable @columnfractions .15 .70
10731 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
10732 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
10733 @item @var{RADIX} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
10734 @end multitable
10735 Before Fortran 2008, at least one of the arguments @var{R} or @var{P} shall
10736 be present; since Fortran 2008, they are assumed to be zero if absent.
10737
10738 @item @emph{Return value}:
10739
10740 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
10741 a real data type with decimal precision of at least @code{P} digits, a
10742 decimal exponent range of at least @code{R}, and with the requested
10743 @code{RADIX}. If the @code{RADIX} parameter is absent, real kinds with
10744 any radix can be returned. If more than one real data type meet the
10745 criteria, the kind of the data type with the smallest decimal precision
10746 is returned. If no real data type matches the criteria, the result is
10747 @table @asis
10748 @item -1 if the processor does not support a real data type with a
10749 precision greater than or equal to @code{P}, but the @code{R} and
10750 @code{RADIX} requirements can be fulfilled
10751 @item -2 if the processor does not support a real type with an exponent
10752 range greater than or equal to @code{R}, but @code{P} and @code{RADIX}
10753 are fulfillable
10754 @item -3 if @code{RADIX} but not @code{P} and @code{R} requirements
10755 are fulfillable
10756 @item -4 if @code{RADIX} and either @code{P} or @code{R} requirements
10757 are fulfillable
10758 @item -5 if there is no real type with the given @code{RADIX}
10759 @end table
10760
10761 @item @emph{See also}:
10762 @ref{PRECISION}, @ref{RANGE}, @ref{RADIX}
10763
10764 @item @emph{Example}:
10765 @smallexample
10766 program real_kinds
10767   integer,parameter :: p6 = selected_real_kind(6)
10768   integer,parameter :: p10r100 = selected_real_kind(10,100)
10769   integer,parameter :: r400 = selected_real_kind(r=400)
10770   real(kind=p6) :: x
10771   real(kind=p10r100) :: y
10772   real(kind=r400) :: z
10773
10774   print *, precision(x), range(x)
10775   print *, precision(y), range(y)
10776   print *, precision(z), range(z)
10777 end program real_kinds
10778 @end smallexample
10779 @end table
10780
10781
10782
10783 @node SET_EXPONENT
10784 @section @code{SET_EXPONENT} --- Set the exponent of the model
10785 @fnindex SET_EXPONENT
10786 @cindex real number, set exponent
10787 @cindex floating point, set exponent
10788
10789 @table @asis
10790 @item @emph{Description}:
10791 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
10792 is that that of @var{X} and whose exponent part is @var{I}.
10793
10794 @item @emph{Standard}:
10795 Fortran 95 and later
10796
10797 @item @emph{Class}:
10798 Elemental function
10799
10800 @item @emph{Syntax}:
10801 @code{RESULT = SET_EXPONENT(X, I)}
10802
10803 @item @emph{Arguments}:
10804 @multitable @columnfractions .15 .70
10805 @item @var{X} @tab Shall be of type @code{REAL}.
10806 @item @var{I} @tab Shall be of type @code{INTEGER}.
10807 @end multitable
10808
10809 @item @emph{Return value}:
10810 The return value is of the same type and kind as @var{X}.
10811 The real number whose fractional part
10812 is that that of @var{X} and whose exponent part if @var{I} is returned;
10813 it is @code{FRACTION(X) * RADIX(X)**I}.
10814
10815 @item @emph{Example}:
10816 @smallexample
10817 PROGRAM test_setexp
10818   REAL :: x = 178.1387e-4
10819   INTEGER :: i = 17
10820   PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
10821 END PROGRAM
10822 @end smallexample
10823
10824 @end table
10825
10826
10827
10828 @node SHAPE
10829 @section @code{SHAPE} --- Determine the shape of an array
10830 @fnindex SHAPE
10831 @cindex array, shape
10832
10833 @table @asis
10834 @item @emph{Description}:
10835 Determines the shape of an array.
10836
10837 @item @emph{Standard}:
10838 Fortran 95 and later
10839
10840 @item @emph{Class}:
10841 Inquiry function
10842
10843 @item @emph{Syntax}:
10844 @code{RESULT = SHAPE(SOURCE)}
10845
10846 @item @emph{Arguments}:
10847 @multitable @columnfractions .15 .70
10848 @item @var{SOURCE} @tab Shall be an array or scalar of any type. 
10849 If @var{SOURCE} is a pointer it must be associated and allocatable 
10850 arrays must be allocated.
10851 @end multitable
10852
10853 @item @emph{Return value}:
10854 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE} 
10855 has dimensions. The elements of the resulting array correspond to the extend
10856 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
10857 the result is the rank one array of size zero.
10858
10859 @item @emph{Example}:
10860 @smallexample
10861 PROGRAM test_shape
10862   INTEGER, DIMENSION(-1:1, -1:2) :: A
10863   WRITE(*,*) SHAPE(A)             ! (/ 3, 4 /)
10864   WRITE(*,*) SIZE(SHAPE(42))      ! (/ /)
10865 END PROGRAM
10866 @end smallexample
10867
10868 @item @emph{See also}:
10869 @ref{RESHAPE}, @ref{SIZE}
10870 @end table
10871
10872
10873
10874 @node SHIFTA
10875 @section @code{SHIFTA} --- Right shift with fill
10876 @fnindex SHIFTA
10877 @cindex bits, shift right
10878 @cindex shift, right with fill
10879
10880 @table @asis
10881 @item @emph{Description}:
10882 @code{SHIFTA} returns a value corresponding to @var{I} with all of the
10883 bits shifted right by @var{SHIFT} places.  If the absolute value of
10884 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
10885 Bits shifted out from the right end are lost. The fill is arithmetic: the
10886 bits shifted in from the left end are equal to the leftmost bit, which in
10887 two's complement representation is the sign bit.
10888
10889 @item @emph{Standard}:
10890 Fortran 2008 and later
10891
10892 @item @emph{Class}:
10893 Elemental function
10894
10895 @item @emph{Syntax}:
10896 @code{RESULT = SHIFTA(I, SHIFT)}
10897
10898 @item @emph{Arguments}:
10899 @multitable @columnfractions .15 .70
10900 @item @var{I} @tab The type shall be @code{INTEGER}.
10901 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
10902 @end multitable
10903
10904 @item @emph{Return value}:
10905 The return value is of type @code{INTEGER} and of the same kind as
10906 @var{I}.
10907
10908 @item @emph{See also}:
10909 @ref{SHIFTL}, @ref{SHIFTR}
10910 @end table
10911
10912
10913
10914 @node SHIFTL
10915 @section @code{SHIFTL} --- Left shift
10916 @fnindex SHIFTL
10917 @cindex bits, shift left
10918 @cindex shift, left
10919
10920 @table @asis
10921 @item @emph{Description}:
10922 @code{SHIFTL} returns a value corresponding to @var{I} with all of the
10923 bits shifted left by @var{SHIFT} places.  If the absolute value of
10924 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
10925 Bits shifted out from the left end are lost, and bits shifted in from
10926 the right end are set to 0.
10927
10928 @item @emph{Standard}:
10929 Fortran 2008 and later
10930
10931 @item @emph{Class}:
10932 Elemental function
10933
10934 @item @emph{Syntax}:
10935 @code{RESULT = SHIFTL(I, SHIFT)}
10936
10937 @item @emph{Arguments}:
10938 @multitable @columnfractions .15 .70
10939 @item @var{I} @tab The type shall be @code{INTEGER}.
10940 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
10941 @end multitable
10942
10943 @item @emph{Return value}:
10944 The return value is of type @code{INTEGER} and of the same kind as
10945 @var{I}.
10946
10947 @item @emph{See also}:
10948 @ref{SHIFTA}, @ref{SHIFTR}
10949 @end table
10950
10951
10952
10953 @node SHIFTR
10954 @section @code{SHIFTR} --- Right shift
10955 @fnindex SHIFTR
10956 @cindex bits, shift right
10957 @cindex shift, right
10958
10959 @table @asis
10960 @item @emph{Description}:
10961 @code{SHIFTR} returns a value corresponding to @var{I} with all of the
10962 bits shifted right by @var{SHIFT} places.  If the absolute value of
10963 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
10964 Bits shifted out from the right end are lost, and bits shifted in from
10965 the left end are set to 0.
10966
10967 @item @emph{Standard}:
10968 Fortran 2008 and later
10969
10970 @item @emph{Class}:
10971 Elemental function
10972
10973 @item @emph{Syntax}:
10974 @code{RESULT = SHIFTR(I, SHIFT)}
10975
10976 @item @emph{Arguments}:
10977 @multitable @columnfractions .15 .70
10978 @item @var{I} @tab The type shall be @code{INTEGER}.
10979 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
10980 @end multitable
10981
10982 @item @emph{Return value}:
10983 The return value is of type @code{INTEGER} and of the same kind as
10984 @var{I}.
10985
10986 @item @emph{See also}:
10987 @ref{SHIFTA}, @ref{SHIFTL}
10988 @end table
10989
10990
10991
10992 @node SIGN
10993 @section @code{SIGN} --- Sign copying function
10994 @fnindex SIGN
10995 @fnindex ISIGN
10996 @fnindex DSIGN
10997 @cindex sign copying
10998
10999 @table @asis
11000 @item @emph{Description}:
11001 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
11002
11003 @item @emph{Standard}:
11004 Fortran 77 and later
11005
11006 @item @emph{Class}:
11007 Elemental function
11008
11009 @item @emph{Syntax}:
11010 @code{RESULT = SIGN(A, B)}
11011
11012 @item @emph{Arguments}:
11013 @multitable @columnfractions .15 .70
11014 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
11015 @item @var{B} @tab Shall be of the same type and kind as @var{A}
11016 @end multitable
11017
11018 @item @emph{Return value}:
11019 The kind of the return value is that of @var{A} and @var{B}.
11020 If @math{B\ge 0} then the result is @code{ABS(A)}, else
11021 it is @code{-ABS(A)}.
11022
11023 @item @emph{Example}:
11024 @smallexample
11025 program test_sign
11026   print *, sign(-12,1)
11027   print *, sign(-12,0)
11028   print *, sign(-12,-1)
11029
11030   print *, sign(-12.,1.)
11031   print *, sign(-12.,0.)
11032   print *, sign(-12.,-1.)
11033 end program test_sign
11034 @end smallexample
11035
11036 @item @emph{Specific names}:
11037 @multitable @columnfractions .20 .20 .20 .25
11038 @item Name              @tab Arguments              @tab Return type       @tab Standard
11039 @item @code{SIGN(A,B)}  @tab @code{REAL(4) A, B}    @tab @code{REAL(4)}    @tab f77, gnu
11040 @item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab f77, gnu
11041 @item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B}    @tab @code{REAL(8)}    @tab f77, gnu
11042 @end multitable
11043 @end table
11044
11045
11046
11047 @node SIGNAL
11048 @section @code{SIGNAL} --- Signal handling subroutine (or function)
11049 @fnindex SIGNAL
11050 @cindex system, signal handling
11051
11052 @table @asis
11053 @item @emph{Description}:
11054 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
11055 @var{HANDLER} to be executed with a single integer argument when signal
11056 @var{NUMBER} occurs.  If @var{HANDLER} is an integer, it can be used to
11057 turn off handling of signal @var{NUMBER} or revert to its default
11058 action.  See @code{signal(2)}.
11059
11060 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
11061 is supplied, it is set to the value returned by @code{signal(2)}.
11062
11063 @item @emph{Standard}:
11064 GNU extension
11065
11066 @item @emph{Class}:
11067 Subroutine, function
11068
11069 @item @emph{Syntax}:
11070 @multitable @columnfractions .80
11071 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
11072 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
11073 @end multitable
11074
11075 @item @emph{Arguments}:
11076 @multitable @columnfractions .15 .70
11077 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
11078 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
11079 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
11080 @code{INTEGER}. It is @code{INTENT(IN)}.
11081 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
11082 integer. It has @code{INTENT(OUT)}.
11083 @end multitable
11084 @c TODO: What should the interface of the handler be?  Does it take arguments?
11085
11086 @item @emph{Return value}:
11087 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
11088
11089 @item @emph{Example}:
11090 @smallexample
11091 program test_signal
11092   intrinsic signal
11093   external handler_print
11094
11095   call signal (12, handler_print)
11096   call signal (10, 1)
11097
11098   call sleep (30)
11099 end program test_signal
11100 @end smallexample
11101 @end table
11102
11103
11104
11105 @node SIN
11106 @section @code{SIN} --- Sine function 
11107 @fnindex SIN
11108 @fnindex DSIN
11109 @fnindex CSIN
11110 @fnindex ZSIN
11111 @fnindex CDSIN
11112 @cindex trigonometric function, sine
11113 @cindex sine
11114
11115 @table @asis
11116 @item @emph{Description}:
11117 @code{SIN(X)} computes the sine of @var{X}.
11118
11119 @item @emph{Standard}:
11120 Fortran 77 and later
11121
11122 @item @emph{Class}:
11123 Elemental function
11124
11125 @item @emph{Syntax}:
11126 @code{RESULT = SIN(X)}
11127
11128 @item @emph{Arguments}:
11129 @multitable @columnfractions .15 .70
11130 @item @var{X} @tab The type shall be @code{REAL} or
11131 @code{COMPLEX}.
11132 @end multitable
11133
11134 @item @emph{Return value}:
11135 The return value has same type and kind as @var{X}.
11136
11137 @item @emph{Example}:
11138 @smallexample
11139 program test_sin
11140   real :: x = 0.0
11141   x = sin(x)
11142 end program test_sin
11143 @end smallexample
11144
11145 @item @emph{Specific names}:
11146 @multitable @columnfractions .20 .20 .20 .25
11147 @item Name            @tab Argument             @tab Return type       @tab Standard
11148 @item @code{SIN(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}    @tab f77, gnu
11149 @item @code{DSIN(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}    @tab f95, gnu
11150 @item @code{CSIN(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)} @tab f95, gnu
11151 @item @code{ZSIN(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)} @tab f95, gnu
11152 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)} @tab f95, gnu
11153 @end multitable
11154
11155 @item @emph{See also}:
11156 @ref{ASIN}
11157 @end table
11158
11159
11160
11161 @node SINH
11162 @section @code{SINH} --- Hyperbolic sine function 
11163 @fnindex SINH
11164 @fnindex DSINH
11165 @cindex hyperbolic sine
11166 @cindex hyperbolic function, sine
11167 @cindex sine, hyperbolic
11168
11169 @table @asis
11170 @item @emph{Description}:
11171 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
11172
11173 @item @emph{Standard}:
11174 Fortran 95 and later, for a complex argument Fortran 2008 or later
11175
11176 @item @emph{Class}:
11177 Elemental function
11178
11179 @item @emph{Syntax}:
11180 @code{RESULT = SINH(X)}
11181
11182 @item @emph{Arguments}:
11183 @multitable @columnfractions .15 .70
11184 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
11185 @end multitable
11186
11187 @item @emph{Return value}:
11188 The return value has same type and kind as @var{X}.
11189
11190 @item @emph{Example}:
11191 @smallexample
11192 program test_sinh
11193   real(8) :: x = - 1.0_8
11194   x = sinh(x)
11195 end program test_sinh
11196 @end smallexample
11197
11198 @item @emph{Specific names}:
11199 @multitable @columnfractions .20 .20 .20 .25
11200 @item Name            @tab Argument          @tab Return type       @tab Standard
11201 @item @code{SINH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
11202 @item @code{DSINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
11203 @end multitable
11204
11205 @item @emph{See also}:
11206 @ref{ASINH}
11207 @end table
11208
11209
11210
11211 @node SIZE
11212 @section @code{SIZE} --- Determine the size of an array
11213 @fnindex SIZE
11214 @cindex array, size
11215 @cindex array, number of elements
11216 @cindex array, count elements
11217
11218 @table @asis
11219 @item @emph{Description}:
11220 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
11221 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
11222
11223 @item @emph{Standard}:
11224 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
11225
11226 @item @emph{Class}:
11227 Inquiry function
11228
11229 @item @emph{Syntax}:
11230 @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
11231
11232 @item @emph{Arguments}:
11233 @multitable @columnfractions .15 .70
11234 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
11235 a pointer it must be associated and allocatable arrays must be allocated.
11236 @item @var{DIM}   @tab (Optional) shall be a scalar of type @code{INTEGER} 
11237 and its value shall be in the range from 1 to n, where n equals the rank 
11238 of @var{ARRAY}.
11239 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
11240 expression indicating the kind parameter of the result.
11241 @end multitable
11242
11243 @item @emph{Return value}:
11244 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11245 @var{KIND} is absent, the return value is of default integer kind.
11246
11247 @item @emph{Example}:
11248 @smallexample
11249 PROGRAM test_size
11250   WRITE(*,*) SIZE((/ 1, 2 /))    ! 2
11251 END PROGRAM
11252 @end smallexample
11253
11254 @item @emph{See also}:
11255 @ref{SHAPE}, @ref{RESHAPE}
11256 @end table
11257
11258
11259 @node SIZEOF
11260 @section @code{SIZEOF} --- Size in bytes of an expression
11261 @fnindex SIZEOF
11262 @cindex expression size
11263 @cindex size of an expression
11264
11265 @table @asis
11266 @item @emph{Description}:
11267 @code{SIZEOF(X)} calculates the number of bytes of storage the
11268 expression @code{X} occupies.
11269
11270 @item @emph{Standard}:
11271 GNU extension
11272
11273 @item @emph{Class}:
11274 Intrinsic function
11275
11276 @item @emph{Syntax}:
11277 @code{N = SIZEOF(X)}
11278
11279 @item @emph{Arguments}:
11280 @multitable @columnfractions .15 .70
11281 @item @var{X} @tab The argument shall be of any type, rank or shape.
11282 @end multitable
11283
11284 @item @emph{Return value}:
11285 The return value is of type integer and of the system-dependent kind
11286 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
11287 number of bytes occupied by the argument.  If the argument has the
11288 @code{POINTER} attribute, the number of bytes of the storage area pointed
11289 to is returned.  If the argument is of a derived type with @code{POINTER}
11290 or @code{ALLOCATABLE} components, the return value doesn't account for
11291 the sizes of the data pointed to by these components. If the argument is
11292 polymorphic, the size according to the declared type is returned.
11293
11294 @item @emph{Example}:
11295 @smallexample
11296    integer :: i
11297    real :: r, s(5)
11298    print *, (sizeof(s)/sizeof(r) == 5)
11299    end
11300 @end smallexample
11301 The example will print @code{.TRUE.} unless you are using a platform
11302 where default @code{REAL} variables are unusually padded.
11303
11304 @item @emph{See also}:
11305 @ref{C_SIZEOF}, @ref{STORAGE_SIZE}
11306 @end table
11307
11308
11309 @node SLEEP
11310 @section @code{SLEEP} --- Sleep for the specified number of seconds
11311 @fnindex SLEEP
11312 @cindex delayed execution
11313
11314 @table @asis
11315 @item @emph{Description}:
11316 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
11317
11318 @item @emph{Standard}:
11319 GNU extension
11320
11321 @item @emph{Class}:
11322 Subroutine
11323
11324 @item @emph{Syntax}:
11325 @code{CALL SLEEP(SECONDS)}
11326
11327 @item @emph{Arguments}:
11328 @multitable @columnfractions .15 .70
11329 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
11330 @end multitable
11331
11332 @item @emph{Example}:
11333 @smallexample
11334 program test_sleep
11335   call sleep(5)
11336 end
11337 @end smallexample
11338 @end table
11339
11340
11341
11342 @node SPACING
11343 @section @code{SPACING} --- Smallest distance between two numbers of a given type
11344 @fnindex SPACING
11345 @cindex real number, relative spacing
11346 @cindex floating point, relative spacing
11347
11348 @table @asis
11349 @item @emph{Description}:
11350 Determines the distance between the argument @var{X} and the nearest 
11351 adjacent number of the same type.
11352
11353 @item @emph{Standard}:
11354 Fortran 95 and later
11355
11356 @item @emph{Class}:
11357 Elemental function
11358
11359 @item @emph{Syntax}:
11360 @code{RESULT = SPACING(X)}
11361
11362 @item @emph{Arguments}:
11363 @multitable @columnfractions .15 .70
11364 @item @var{X} @tab Shall be of type @code{REAL}.
11365 @end multitable
11366
11367 @item @emph{Return value}:
11368 The result is of the same type as the input argument @var{X}.
11369
11370 @item @emph{Example}:
11371 @smallexample
11372 PROGRAM test_spacing
11373   INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
11374   INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
11375
11376   WRITE(*,*) spacing(1.0_SGL)      ! "1.1920929E-07"          on i686
11377   WRITE(*,*) spacing(1.0_DBL)      ! "2.220446049250313E-016" on i686
11378 END PROGRAM
11379 @end smallexample
11380
11381 @item @emph{See also}:
11382 @ref{RRSPACING}
11383 @end table
11384
11385
11386
11387 @node SPREAD
11388 @section @code{SPREAD} --- Add a dimension to an array
11389 @fnindex SPREAD
11390 @cindex array, increase dimension
11391 @cindex array, duplicate elements
11392 @cindex array, duplicate dimensions
11393
11394 @table @asis
11395 @item @emph{Description}:
11396 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified 
11397 dimension @var{DIM}.
11398
11399 @item @emph{Standard}:
11400 Fortran 95 and later
11401
11402 @item @emph{Class}:
11403 Transformational function
11404
11405 @item @emph{Syntax}:
11406 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
11407
11408 @item @emph{Arguments}:
11409 @multitable @columnfractions .15 .70
11410 @item @var{SOURCE}  @tab Shall be a scalar or an array of any type and 
11411 a rank less than seven.
11412 @item @var{DIM}     @tab Shall be a scalar of type @code{INTEGER} with a 
11413 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
11414 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
11415 @end multitable
11416
11417 @item @emph{Return value}:
11418 The result is an array of the same type as @var{SOURCE} and has rank n+1
11419 where n equals the rank of @var{SOURCE}.
11420
11421 @item @emph{Example}:
11422 @smallexample
11423 PROGRAM test_spread
11424   INTEGER :: a = 1, b(2) = (/ 1, 2 /)
11425   WRITE(*,*) SPREAD(A, 1, 2)            ! "1 1"
11426   WRITE(*,*) SPREAD(B, 1, 2)            ! "1 1 2 2"
11427 END PROGRAM
11428 @end smallexample
11429
11430 @item @emph{See also}:
11431 @ref{UNPACK}
11432 @end table
11433
11434
11435
11436 @node SQRT
11437 @section @code{SQRT} --- Square-root function
11438 @fnindex SQRT
11439 @fnindex DSQRT
11440 @fnindex CSQRT
11441 @fnindex ZSQRT
11442 @fnindex CDSQRT
11443 @cindex root
11444 @cindex square-root
11445
11446 @table @asis
11447 @item @emph{Description}:
11448 @code{SQRT(X)} computes the square root of @var{X}.
11449
11450 @item @emph{Standard}:
11451 Fortran 77 and later
11452
11453 @item @emph{Class}:
11454 Elemental function
11455
11456 @item @emph{Syntax}:
11457 @code{RESULT = SQRT(X)}
11458
11459 @item @emph{Arguments}:
11460 @multitable @columnfractions .15 .70
11461 @item @var{X} @tab The type shall be @code{REAL} or
11462 @code{COMPLEX}.
11463 @end multitable
11464
11465 @item @emph{Return value}:
11466 The return value is of type @code{REAL} or @code{COMPLEX}.
11467 The kind type parameter is the same as @var{X}.
11468
11469 @item @emph{Example}:
11470 @smallexample
11471 program test_sqrt
11472   real(8) :: x = 2.0_8
11473   complex :: z = (1.0, 2.0)
11474   x = sqrt(x)
11475   z = sqrt(z)
11476 end program test_sqrt
11477 @end smallexample
11478
11479 @item @emph{Specific names}:
11480 @multitable @columnfractions .20 .20 .20 .25
11481 @item Name             @tab Argument             @tab Return type          @tab Standard
11482 @item @code{SQRT(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}       @tab Fortran 95 and later
11483 @item @code{DSQRT(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}       @tab Fortran 95 and later
11484 @item @code{CSQRT(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab Fortran 95 and later
11485 @item @code{ZSQRT(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
11486 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
11487 @end multitable
11488 @end table
11489
11490
11491
11492 @node SRAND
11493 @section @code{SRAND} --- Reinitialize the random number generator
11494 @fnindex SRAND
11495 @cindex random number generation, seeding
11496 @cindex seeding a random number generator
11497
11498 @table @asis
11499 @item @emph{Description}:
11500 @code{SRAND} reinitializes the pseudo-random number generator
11501 called by @code{RAND} and @code{IRAND}. The new seed used by the
11502 generator is specified by the required argument @var{SEED}.
11503
11504 @item @emph{Standard}:
11505 GNU extension
11506
11507 @item @emph{Class}:
11508 Subroutine
11509
11510 @item @emph{Syntax}:
11511 @code{CALL SRAND(SEED)}
11512
11513 @item @emph{Arguments}:
11514 @multitable @columnfractions .15 .70
11515 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
11516 @end multitable
11517
11518 @item @emph{Return value}:
11519 Does not return anything.
11520
11521 @item @emph{Example}:
11522 See @code{RAND} and @code{IRAND} for examples.
11523
11524 @item @emph{Notes}:
11525 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
11526 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
11527 to generate pseudo-random numbers. Please note that in
11528 GNU Fortran, these two sets of intrinsics (@code{RAND},
11529 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
11530 @code{RANDOM_SEED} on the other hand) access two independent
11531 pseudo-random number generators.
11532
11533 @item @emph{See also}:
11534 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
11535
11536 @end table
11537
11538
11539
11540 @node STAT
11541 @section @code{STAT} --- Get file status
11542 @fnindex STAT
11543 @cindex file system, file status
11544
11545 @table @asis
11546 @item @emph{Description}:
11547 This function returns information about a file. No permissions are required on 
11548 the file itself, but execute (search) permission is required on all of the 
11549 directories in path that lead to the file.
11550
11551 The elements that are obtained and stored in the array @code{VALUES}:
11552 @multitable @columnfractions .15 .70
11553 @item @code{VALUES(1)}   @tab  Device ID 
11554 @item @code{VALUES(2)}   @tab  Inode number 
11555 @item @code{VALUES(3)}   @tab  File mode 
11556 @item @code{VALUES(4)}   @tab  Number of links 
11557 @item @code{VALUES(5)}   @tab  Owner's uid 
11558 @item @code{VALUES(6)}   @tab  Owner's gid 
11559 @item @code{VALUES(7)}   @tab  ID of device containing directory entry for file (0 if not available) 
11560 @item @code{VALUES(8)}   @tab  File size (bytes) 
11561 @item @code{VALUES(9)}   @tab  Last access time 
11562 @item @code{VALUES(10)}  @tab  Last modification time 
11563 @item @code{VALUES(11)}  @tab  Last file status change time 
11564 @item @code{VALUES(12)}  @tab  Preferred I/O block size (-1 if not available) 
11565 @item @code{VALUES(13)}  @tab  Number of blocks allocated (-1 if not available)
11566 @end multitable
11567
11568 Not all these elements are relevant on all systems. 
11569 If an element is not relevant, it is returned as 0.
11570
11571 This intrinsic is provided in both subroutine and function forms; however,
11572 only one form can be used in any given program unit.
11573
11574 @item @emph{Standard}:
11575 GNU extension
11576
11577 @item @emph{Class}:
11578 Subroutine, function
11579
11580 @item @emph{Syntax}:
11581 @multitable @columnfractions .80
11582 @item @code{CALL STAT(NAME, VALUES [, STATUS])}
11583 @item @code{STATUS = STAT(NAME, VALUES)}
11584 @end multitable
11585
11586 @item @emph{Arguments}:
11587 @multitable @columnfractions .15 .70
11588 @item @var{NAME}   @tab The type shall be @code{CHARACTER}, of the
11589 default kind and a valid path within the file system.
11590 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
11591 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
11592 on success and a system specific error code otherwise.
11593 @end multitable
11594
11595 @item @emph{Example}:
11596 @smallexample
11597 PROGRAM test_stat
11598   INTEGER, DIMENSION(13) :: buff
11599   INTEGER :: status
11600
11601   CALL STAT("/etc/passwd", buff, status)
11602
11603   IF (status == 0) THEN
11604     WRITE (*, FMT="('Device ID:',               T30, I19)") buff(1)
11605     WRITE (*, FMT="('Inode number:',            T30, I19)") buff(2)
11606     WRITE (*, FMT="('File mode (octal):',       T30, O19)") buff(3)
11607     WRITE (*, FMT="('Number of links:',         T30, I19)") buff(4)
11608     WRITE (*, FMT="('Owner''s uid:',            T30, I19)") buff(5)
11609     WRITE (*, FMT="('Owner''s gid:',            T30, I19)") buff(6)
11610     WRITE (*, FMT="('Device where located:',    T30, I19)") buff(7)
11611     WRITE (*, FMT="('File size:',               T30, I19)") buff(8)
11612     WRITE (*, FMT="('Last access time:',        T30, A19)") CTIME(buff(9))
11613     WRITE (*, FMT="('Last modification time',   T30, A19)") CTIME(buff(10))
11614     WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
11615     WRITE (*, FMT="('Preferred block size:',    T30, I19)") buff(12)
11616     WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
11617   END IF
11618 END PROGRAM
11619 @end smallexample
11620
11621 @item @emph{See also}:
11622 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
11623 @end table
11624
11625
11626
11627 @node STORAGE_SIZE
11628 @section @code{STORAGE_SIZE} --- Storage size in bits
11629 @fnindex STORAGE_SIZE
11630 @cindex storage size
11631
11632 @table @asis
11633 @item @emph{Description}:
11634 Returns the storage size of argument @var{A} in bits.
11635 @item @emph{Standard}:
11636 Fortran 2008 and later
11637 @item @emph{Class}:
11638 Inquiry function
11639 @item @emph{Syntax}:
11640 @code{RESULT = STORAGE_SIZE(A [, KIND])}
11641
11642 @item @emph{Arguments}:
11643 @multitable @columnfractions .15 .70
11644 @item @var{A} @tab Shall be a scalar or array of any type.
11645 @item @var{KIND} @tab (Optional) shall be a scalar integer constant expression.
11646 @end multitable
11647
11648 @item @emph{Return Value}:
11649 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
11650 has the dynamic type and type parameters of A.
11651
11652 @item @emph{See also}:
11653 @ref{C_SIZEOF}, @ref{SIZEOF}
11654 @end table
11655
11656
11657
11658 @node SUM
11659 @section @code{SUM} --- Sum of array elements
11660 @fnindex SUM
11661 @cindex array, sum
11662 @cindex array, add elements
11663 @cindex array, conditionally add elements
11664 @cindex sum array elements
11665
11666 @table @asis
11667 @item @emph{Description}:
11668 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
11669 the corresponding element in @var{MASK} is @code{TRUE}.
11670
11671 @item @emph{Standard}:
11672 Fortran 95 and later
11673
11674 @item @emph{Class}:
11675 Transformational function
11676
11677 @item @emph{Syntax}:
11678 @multitable @columnfractions .80
11679 @item @code{RESULT = SUM(ARRAY[, MASK])}
11680 @item @code{RESULT = SUM(ARRAY, DIM[, MASK])}
11681 @end multitable
11682
11683 @item @emph{Arguments}:
11684 @multitable @columnfractions .15 .70
11685 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
11686 @code{REAL} or @code{COMPLEX}.
11687 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
11688 @code{INTEGER} with a value in the range from 1 to n, where n 
11689 equals the rank of @var{ARRAY}.
11690 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
11691 and either be a scalar or an array of the same shape as @var{ARRAY}.
11692 @end multitable
11693
11694 @item @emph{Return value}:
11695 The result is of the same type as @var{ARRAY}.
11696
11697 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
11698 is returned. Otherwise, an array of rank n-1, where n equals the rank of 
11699 @var{ARRAY}, and a shape similar to that of @var{ARRAY} with dimension @var{DIM} 
11700 dropped is returned.
11701
11702 @item @emph{Example}:
11703 @smallexample
11704 PROGRAM test_sum
11705   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
11706   print *, SUM(x)                        ! all elements, sum = 15
11707   print *, SUM(x, MASK=MOD(x, 2)==1)     ! odd elements, sum = 9
11708 END PROGRAM
11709 @end smallexample
11710
11711 @item @emph{See also}:
11712 @ref{PRODUCT}
11713 @end table
11714
11715
11716
11717 @node SYMLNK
11718 @section @code{SYMLNK} --- Create a symbolic link
11719 @fnindex SYMLNK
11720 @cindex file system, create link
11721 @cindex file system, soft link
11722
11723 @table @asis
11724 @item @emph{Description}:
11725 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
11726 character (@code{CHAR(0)}) can be used to mark the end of the names in
11727 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
11728 names are ignored.  If the @var{STATUS} argument is supplied, it
11729 contains 0 on success or a nonzero error code upon return; see
11730 @code{symlink(2)}.  If the system does not supply @code{symlink(2)}, 
11731 @code{ENOSYS} is returned.
11732
11733 This intrinsic is provided in both subroutine and function forms;
11734 however, only one form can be used in any given program unit.
11735
11736 @item @emph{Standard}:
11737 GNU extension
11738
11739 @item @emph{Class}:
11740 Subroutine, function
11741
11742 @item @emph{Syntax}:
11743 @multitable @columnfractions .80
11744 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
11745 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
11746 @end multitable
11747
11748 @item @emph{Arguments}:
11749 @multitable @columnfractions .15 .70
11750 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
11751 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
11752 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
11753 @end multitable
11754
11755 @item @emph{See also}:
11756 @ref{LINK}, @ref{UNLINK}
11757
11758 @end table
11759
11760
11761
11762 @node SYSTEM
11763 @section @code{SYSTEM} --- Execute a shell command
11764 @fnindex SYSTEM
11765 @cindex system, system call
11766
11767 @table @asis
11768 @item @emph{Description}:
11769 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
11770 argument @var{STATUS} is present, it contains the value returned by
11771 @code{system(3)}, which is presumably 0 if the shell command succeeded.
11772 Note that which shell is used to invoke the command is system-dependent
11773 and environment-dependent.
11774
11775 This intrinsic is provided in both subroutine and function forms;
11776 however, only one form can be used in any given program unit.
11777
11778 @item @emph{Standard}:
11779 GNU extension
11780
11781 @item @emph{Class}:
11782 Subroutine, function
11783
11784 @item @emph{Syntax}:
11785 @multitable @columnfractions .80
11786 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
11787 @item @code{STATUS = SYSTEM(COMMAND)}
11788 @end multitable
11789
11790 @item @emph{Arguments}:
11791 @multitable @columnfractions .15 .70
11792 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
11793 @item @var{STATUS}  @tab (Optional) Shall be of default @code{INTEGER} type.
11794 @end multitable
11795
11796 @item @emph{See also}:
11797 @ref{EXECUTE_COMMAND_LINE}, which is part of the Fortran 2008 standard
11798 and should considered in new code for future portability.
11799 @end table
11800
11801
11802
11803 @node SYSTEM_CLOCK
11804 @section @code{SYSTEM_CLOCK} --- Time function
11805 @fnindex SYSTEM_CLOCK
11806 @cindex time, clock ticks
11807 @cindex clock ticks
11808
11809 @table @asis
11810 @item @emph{Description}:
11811 Determines the @var{COUNT} of milliseconds of wall clock time since 
11812 the Epoch (00:00:00 UTC, January 1, 1970) modulo @var{COUNT_MAX}, 
11813 @var{COUNT_RATE} determines the number of clock ticks per second.
11814 @var{COUNT_RATE} and @var{COUNT_MAX} are constant and specific to 
11815 @command{gfortran}.
11816
11817 If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and
11818 @var{COUNT_RATE} and @var{COUNT_MAX} are set to zero 
11819
11820 @item @emph{Standard}:
11821 Fortran 95 and later
11822
11823 @item @emph{Class}:
11824 Subroutine
11825
11826 @item @emph{Syntax}:
11827 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
11828
11829 @item @emph{Arguments}:
11830 @multitable @columnfractions .15 .70
11831 @item @var{COUNT}      @tab (Optional) shall be a scalar of type default 
11832 @code{INTEGER} with @code{INTENT(OUT)}.
11833 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type default 
11834 @code{INTEGER} with @code{INTENT(OUT)}.
11835 @item @var{COUNT_MAX}  @tab (Optional) shall be a scalar of type default 
11836 @code{INTEGER} with @code{INTENT(OUT)}.
11837 @end multitable
11838
11839 @item @emph{Example}:
11840 @smallexample
11841 PROGRAM test_system_clock
11842   INTEGER :: count, count_rate, count_max
11843   CALL SYSTEM_CLOCK(count, count_rate, count_max)
11844   WRITE(*,*) count, count_rate, count_max
11845 END PROGRAM
11846 @end smallexample
11847
11848 @item @emph{See also}:
11849 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
11850 @end table
11851
11852
11853
11854 @node TAN
11855 @section @code{TAN} --- Tangent function
11856 @fnindex TAN
11857 @fnindex DTAN
11858 @cindex trigonometric function, tangent
11859 @cindex tangent
11860
11861 @table @asis
11862 @item @emph{Description}:
11863 @code{TAN(X)} computes the tangent of @var{X}.
11864
11865 @item @emph{Standard}:
11866 Fortran 77 and later, for a complex argument Fortran 2008 or later
11867
11868 @item @emph{Class}:
11869 Elemental function
11870
11871 @item @emph{Syntax}:
11872 @code{RESULT = TAN(X)}
11873
11874 @item @emph{Arguments}:
11875 @multitable @columnfractions .15 .70
11876 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
11877 @end multitable
11878
11879 @item @emph{Return value}:
11880 The return value has same type and kind as @var{X}.
11881
11882 @item @emph{Example}:
11883 @smallexample
11884 program test_tan
11885   real(8) :: x = 0.165_8
11886   x = tan(x)
11887 end program test_tan
11888 @end smallexample
11889
11890 @item @emph{Specific names}:
11891 @multitable @columnfractions .20 .20 .20 .25
11892 @item Name            @tab Argument          @tab Return type     @tab Standard
11893 @item @code{TAN(X)}   @tab @code{REAL(4) X}  @tab @code{REAL(4)}  @tab Fortran 95 and later
11894 @item @code{DTAN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}  @tab Fortran 95 and later
11895 @end multitable
11896
11897 @item @emph{See also}:
11898 @ref{ATAN}
11899 @end table
11900
11901
11902
11903 @node TANH
11904 @section @code{TANH} --- Hyperbolic tangent function 
11905 @fnindex TANH
11906 @fnindex DTANH
11907 @cindex hyperbolic tangent
11908 @cindex hyperbolic function, tangent
11909 @cindex tangent, hyperbolic
11910
11911 @table @asis
11912 @item @emph{Description}:
11913 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
11914
11915 @item @emph{Standard}:
11916 Fortran 77 and later, for a complex argument Fortran 2008 or later
11917
11918 @item @emph{Class}:
11919 Elemental function
11920
11921 @item @emph{Syntax}:
11922 @code{X = TANH(X)}
11923
11924 @item @emph{Arguments}:
11925 @multitable @columnfractions .15 .70
11926 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
11927 @end multitable
11928
11929 @item @emph{Return value}:
11930 The return value has same type and kind as @var{X}. If @var{X} is
11931 complex, the imaginary part of the result is in radians. If @var{X}
11932 is @code{REAL}, the return value lies in the range
11933 @math{ - 1 \leq tanh(x) \leq 1 }.
11934
11935 @item @emph{Example}:
11936 @smallexample
11937 program test_tanh
11938   real(8) :: x = 2.1_8
11939   x = tanh(x)
11940 end program test_tanh
11941 @end smallexample
11942
11943 @item @emph{Specific names}:
11944 @multitable @columnfractions .20 .20 .20 .25
11945 @item Name            @tab Argument          @tab Return type       @tab Standard
11946 @item @code{TANH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
11947 @item @code{DTANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
11948 @end multitable
11949
11950 @item @emph{See also}:
11951 @ref{ATANH}
11952 @end table
11953
11954
11955
11956 @node THIS_IMAGE
11957 @section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image
11958 @fnindex THIS_IMAGE
11959 @cindex coarray, @code{THIS_IMAGE}
11960 @cindex images, index of this image
11961
11962 @table @asis
11963 @item @emph{Description}:
11964 Returns the cosubscript for this image.
11965
11966 @item @emph{Standard}:
11967 Fortran 2008 and later
11968
11969 @item @emph{Class}:
11970 Transformational function
11971
11972 @item @emph{Syntax}:
11973 @multitable @columnfractions .80
11974 @item @code{RESULT = THIS_IMAGE()}
11975 @item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])}
11976 @end multitable
11977
11978 @item @emph{Arguments}:
11979 @multitable @columnfractions .15 .70
11980 @item @var{COARRAY} @tab Coarray of any type  (optional; if @var{DIM}
11981 present, required).
11982 @item @var{DIM}     @tab default integer scalar (optional). If present,
11983 @var{DIM} shall be between one and the corank of @var{COARRAY}.
11984 @end multitable
11985
11986
11987 @item @emph{Return value}:
11988 Default integer. If @var{COARRAY} is not present, it is scalar and its value
11989 is the index of the invoking image. Otherwise, if @var{DIM} is not present,
11990 a rank-1 array with corank elements is returned, containing the cosubscripts
11991 for @var{COARRAY} specifying the invoking image. If @var{DIM} is present,
11992 a scalar is returned, with the value of the @var{DIM} element of
11993 @code{THIS_IMAGE(COARRAY)}.
11994
11995 @item @emph{Example}:
11996 @smallexample
11997 INTEGER :: value[*]
11998 INTEGER :: i
11999 value = THIS_IMAGE()
12000 SYNC ALL
12001 IF (THIS_IMAGE() == 1) THEN
12002   DO i = 1, NUM_IMAGES()
12003     WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
12004   END DO
12005 END IF
12006 @end smallexample
12007
12008 @item @emph{See also}:
12009 @ref{NUM_IMAGES}, @ref{IMAGE_INDEX}
12010 @end table
12011
12012
12013
12014 @node TIME
12015 @section @code{TIME} --- Time function
12016 @fnindex TIME
12017 @cindex time, current
12018 @cindex current time
12019
12020 @table @asis
12021 @item @emph{Description}:
12022 Returns the current time encoded as an integer (in the manner of the
12023 UNIX function @code{time(3)}). This value is suitable for passing to
12024 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
12025
12026 This intrinsic is not fully portable, such as to systems with 32-bit
12027 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
12028 the values returned by this intrinsic might be, or become, negative, or
12029 numerically less than previous values, during a single run of the
12030 compiled program.
12031
12032 See @ref{TIME8}, for information on a similar intrinsic that might be
12033 portable to more GNU Fortran implementations, though to fewer Fortran
12034 compilers.
12035
12036 @item @emph{Standard}:
12037 GNU extension
12038
12039 @item @emph{Class}:
12040 Function
12041
12042 @item @emph{Syntax}:
12043 @code{RESULT = TIME()}
12044
12045 @item @emph{Return value}:
12046 The return value is a scalar of type @code{INTEGER(4)}.
12047
12048 @item @emph{See also}:
12049 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
12050
12051 @end table
12052
12053
12054
12055 @node TIME8
12056 @section @code{TIME8} --- Time function (64-bit)
12057 @fnindex TIME8
12058 @cindex time, current
12059 @cindex current time
12060
12061 @table @asis
12062 @item @emph{Description}:
12063 Returns the current time encoded as an integer (in the manner of the
12064 UNIX function @code{time(3)}). This value is suitable for passing to
12065 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
12066
12067 @emph{Warning:} this intrinsic does not increase the range of the timing
12068 values over that returned by @code{time(3)}. On a system with a 32-bit
12069 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
12070 it is converted to a 64-bit @code{INTEGER(8)} value. That means
12071 overflows of the 32-bit value can still occur. Therefore, the values
12072 returned by this intrinsic might be or become negative or numerically
12073 less than previous values during a single run of the compiled program.
12074
12075 @item @emph{Standard}:
12076 GNU extension
12077
12078 @item @emph{Class}:
12079 Function
12080
12081 @item @emph{Syntax}:
12082 @code{RESULT = TIME8()}
12083
12084 @item @emph{Return value}:
12085 The return value is a scalar of type @code{INTEGER(8)}.
12086
12087 @item @emph{See also}:
12088 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
12089
12090 @end table
12091
12092
12093
12094 @node TINY
12095 @section @code{TINY} --- Smallest positive number of a real kind
12096 @fnindex TINY
12097 @cindex limits, smallest number
12098 @cindex model representation, smallest number
12099
12100 @table @asis
12101 @item @emph{Description}:
12102 @code{TINY(X)} returns the smallest positive (non zero) number
12103 in the model of the type of @code{X}.
12104
12105 @item @emph{Standard}:
12106 Fortran 95 and later
12107
12108 @item @emph{Class}:
12109 Inquiry function
12110
12111 @item @emph{Syntax}:
12112 @code{RESULT = TINY(X)}
12113
12114 @item @emph{Arguments}:
12115 @multitable @columnfractions .15 .70
12116 @item @var{X} @tab Shall be of type @code{REAL}.
12117 @end multitable
12118
12119 @item @emph{Return value}:
12120 The return value is of the same type and kind as @var{X}
12121
12122 @item @emph{Example}:
12123 See @code{HUGE} for an example.
12124 @end table
12125
12126
12127
12128 @node TRAILZ
12129 @section @code{TRAILZ} --- Number of trailing zero bits of an integer
12130 @fnindex TRAILZ
12131 @cindex zero bits
12132
12133 @table @asis
12134 @item @emph{Description}:
12135 @code{TRAILZ} returns the number of trailing zero bits of an integer.
12136
12137 @item @emph{Standard}:
12138 Fortran 2008 and later
12139
12140 @item @emph{Class}:
12141 Elemental function
12142
12143 @item @emph{Syntax}:
12144 @code{RESULT = TRAILZ(I)}
12145
12146 @item @emph{Arguments}:
12147 @multitable @columnfractions .15 .70
12148 @item @var{I} @tab Shall be of type @code{INTEGER}.
12149 @end multitable
12150
12151 @item @emph{Return value}:
12152 The type of the return value is the default @code{INTEGER}.
12153 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
12154
12155 @item @emph{Example}:
12156 @smallexample
12157 PROGRAM test_trailz
12158   WRITE (*,*) TRAILZ(8)  ! prints 3
12159 END PROGRAM
12160 @end smallexample
12161
12162 @item @emph{See also}:
12163 @ref{BIT_SIZE}, @ref{LEADZ}, @ref{POPPAR}, @ref{POPCNT}
12164 @end table
12165
12166
12167
12168 @node TRANSFER
12169 @section @code{TRANSFER} --- Transfer bit patterns
12170 @fnindex TRANSFER
12171 @cindex bits, move
12172 @cindex type cast
12173
12174 @table @asis
12175 @item @emph{Description}:
12176 Interprets the bitwise representation of @var{SOURCE} in memory as if it
12177 is the representation of a variable or array of the same type and type
12178 parameters as @var{MOLD}.
12179
12180 This is approximately equivalent to the C concept of @emph{casting} one
12181 type to another.
12182
12183 @item @emph{Standard}:
12184 Fortran 95 and later
12185
12186 @item @emph{Class}:
12187 Transformational function
12188
12189 @item @emph{Syntax}:
12190 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
12191
12192 @item @emph{Arguments}:
12193 @multitable @columnfractions .15 .70
12194 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
12195 @item @var{MOLD}   @tab Shall be a scalar or an array of any type.
12196 @item @var{SIZE}   @tab (Optional) shall be a scalar of type 
12197 @code{INTEGER}.
12198 @end multitable
12199
12200 @item @emph{Return value}:
12201 The result has the same type as @var{MOLD}, with the bit level
12202 representation of @var{SOURCE}.  If @var{SIZE} is present, the result is
12203 a one-dimensional array of length @var{SIZE}.  If @var{SIZE} is absent
12204 but @var{MOLD} is an array (of any size or shape), the result is a one-
12205 dimensional array of the minimum length needed to contain the entirety
12206 of the bitwise representation of @var{SOURCE}.   If @var{SIZE} is absent
12207 and @var{MOLD} is a scalar, the result is a scalar.
12208
12209 If the bitwise representation of the result is longer than that of
12210 @var{SOURCE}, then the leading bits of the result correspond to those of
12211 @var{SOURCE} and any trailing bits are filled arbitrarily.
12212
12213 When the resulting bit representation does not correspond to a valid
12214 representation of a variable of the same type as @var{MOLD}, the results
12215 are undefined, and subsequent operations on the result cannot be
12216 guaranteed to produce sensible behavior.  For example, it is possible to
12217 create @code{LOGICAL} variables for which @code{@var{VAR}} and
12218 @code{.NOT.@var{VAR}} both appear to be true.
12219
12220 @item @emph{Example}:
12221 @smallexample
12222 PROGRAM test_transfer
12223   integer :: x = 2143289344
12224   print *, transfer(x, 1.0)    ! prints "NaN" on i686
12225 END PROGRAM
12226 @end smallexample
12227 @end table
12228
12229
12230
12231 @node TRANSPOSE
12232 @section @code{TRANSPOSE} --- Transpose an array of rank two
12233 @fnindex TRANSPOSE
12234 @cindex array, transpose
12235 @cindex matrix, transpose
12236 @cindex transpose
12237
12238 @table @asis
12239 @item @emph{Description}:
12240 Transpose an array of rank two. Element (i, j) of the result has the value 
12241 @code{MATRIX(j, i)}, for all i, j.
12242
12243 @item @emph{Standard}:
12244 Fortran 95 and later
12245
12246 @item @emph{Class}:
12247 Transformational function
12248
12249 @item @emph{Syntax}:
12250 @code{RESULT = TRANSPOSE(MATRIX)}
12251
12252 @item @emph{Arguments}:
12253 @multitable @columnfractions .15 .70
12254 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
12255 @end multitable
12256
12257 @item @emph{Return value}:
12258 The result has the same type as @var{MATRIX}, and has shape 
12259 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
12260 @end table
12261
12262
12263
12264 @node TRIM
12265 @section @code{TRIM} --- Remove trailing blank characters of a string
12266 @fnindex TRIM
12267 @cindex string, remove trailing whitespace
12268
12269 @table @asis
12270 @item @emph{Description}:
12271 Removes trailing blank characters of a string.
12272
12273 @item @emph{Standard}:
12274 Fortran 95 and later
12275
12276 @item @emph{Class}:
12277 Transformational function
12278
12279 @item @emph{Syntax}:
12280 @code{RESULT = TRIM(STRING)}
12281
12282 @item @emph{Arguments}:
12283 @multitable @columnfractions .15 .70
12284 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
12285 @end multitable
12286
12287 @item @emph{Return value}:
12288 A scalar of type @code{CHARACTER} which length is that of @var{STRING}
12289 less the number of trailing blanks.
12290
12291 @item @emph{Example}:
12292 @smallexample
12293 PROGRAM test_trim
12294   CHARACTER(len=10), PARAMETER :: s = "GFORTRAN  "
12295   WRITE(*,*) LEN(s), LEN(TRIM(s))  ! "10 8", with/without trailing blanks
12296 END PROGRAM
12297 @end smallexample
12298
12299 @item @emph{See also}:
12300 @ref{ADJUSTL}, @ref{ADJUSTR}
12301 @end table
12302
12303
12304
12305 @node TTYNAM
12306 @section @code{TTYNAM} --- Get the name of a terminal device.
12307 @fnindex TTYNAM
12308 @cindex system, terminal
12309
12310 @table @asis
12311 @item @emph{Description}:
12312 Get the name of a terminal device. For more information, 
12313 see @code{ttyname(3)}.
12314
12315 This intrinsic is provided in both subroutine and function forms; 
12316 however, only one form can be used in any given program unit. 
12317
12318 @item @emph{Standard}:
12319 GNU extension
12320
12321 @item @emph{Class}:
12322 Subroutine, function
12323
12324 @item @emph{Syntax}:
12325 @multitable @columnfractions .80
12326 @item @code{CALL TTYNAM(UNIT, NAME)}
12327 @item @code{NAME = TTYNAM(UNIT)}
12328 @end multitable
12329
12330 @item @emph{Arguments}:
12331 @multitable @columnfractions .15 .70
12332 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
12333 @item @var{NAME} @tab Shall be of type @code{CHARACTER}.
12334 @end multitable
12335
12336 @item @emph{Example}:
12337 @smallexample
12338 PROGRAM test_ttynam
12339   INTEGER :: unit
12340   DO unit = 1, 10
12341     IF (isatty(unit=unit)) write(*,*) ttynam(unit)
12342   END DO
12343 END PROGRAM
12344 @end smallexample
12345
12346 @item @emph{See also}:
12347 @ref{ISATTY}
12348 @end table
12349
12350
12351
12352 @node UBOUND
12353 @section @code{UBOUND} --- Upper dimension bounds of an array
12354 @fnindex UBOUND
12355 @cindex array, upper bound
12356
12357 @table @asis
12358 @item @emph{Description}:
12359 Returns the upper bounds of an array, or a single upper bound
12360 along the @var{DIM} dimension.
12361 @item @emph{Standard}:
12362 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
12363
12364 @item @emph{Class}:
12365 Inquiry function
12366
12367 @item @emph{Syntax}:
12368 @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
12369
12370 @item @emph{Arguments}:
12371 @multitable @columnfractions .15 .70
12372 @item @var{ARRAY} @tab Shall be an array, of any type.
12373 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
12374 @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
12375 expression indicating the kind parameter of the result.
12376 @end multitable
12377
12378 @item @emph{Return value}:
12379 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12380 @var{KIND} is absent, the return value is of default integer kind.
12381 If @var{DIM} is absent, the result is an array of the upper bounds of
12382 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
12383 corresponding to the upper bound of the array along that dimension.  If
12384 @var{ARRAY} is an expression rather than a whole array or array
12385 structure component, or if it has a zero extent along the relevant
12386 dimension, the upper bound is taken to be the number of elements along
12387 the relevant dimension.
12388
12389 @item @emph{See also}:
12390 @ref{LBOUND}, @ref{LCOBOUND}
12391 @end table
12392
12393
12394
12395 @node UCOBOUND
12396 @section @code{UCOBOUND} --- Upper codimension bounds of an array
12397 @fnindex UCOBOUND
12398 @cindex coarray, upper bound
12399
12400 @table @asis
12401 @item @emph{Description}:
12402 Returns the upper cobounds of a coarray, or a single upper cobound
12403 along the @var{DIM} codimension.
12404 @item @emph{Standard}:
12405 Fortran 2008 and later
12406
12407 @item @emph{Class}:
12408 Inquiry function
12409
12410 @item @emph{Syntax}:
12411 @code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])}
12412
12413 @item @emph{Arguments}:
12414 @multitable @columnfractions .15 .70
12415 @item @var{ARRAY} @tab Shall be an coarray, of any type.
12416 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
12417 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12418 expression indicating the kind parameter of the result.
12419 @end multitable
12420
12421 @item @emph{Return value}:
12422 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12423 @var{KIND} is absent, the return value is of default integer kind.
12424 If @var{DIM} is absent, the result is an array of the lower cobounds of
12425 @var{COARRAY}.  If @var{DIM} is present, the result is a scalar
12426 corresponding to the lower cobound of the array along that codimension.
12427
12428 @item @emph{See also}:
12429 @ref{LCOBOUND}, @ref{LBOUND}
12430 @end table
12431
12432
12433
12434 @node UMASK
12435 @section @code{UMASK} --- Set the file creation mask
12436 @fnindex UMASK
12437 @cindex file system, file creation mask
12438
12439 @table @asis
12440 @item @emph{Description}:
12441 Sets the file creation mask to @var{MASK}. If called as a function, it
12442 returns the old value. If called as a subroutine and argument @var{OLD}
12443 if it is supplied, it is set to the old value. See @code{umask(2)}.
12444
12445 @item @emph{Standard}:
12446 GNU extension
12447
12448 @item @emph{Class}:
12449 Subroutine, function
12450
12451 @item @emph{Syntax}:
12452 @multitable @columnfractions .80
12453 @item @code{CALL UMASK(MASK [, OLD])}
12454 @item @code{OLD = UMASK(MASK)}
12455 @end multitable
12456
12457 @item @emph{Arguments}:
12458 @multitable @columnfractions .15 .70
12459 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
12460 @item @var{OLD} @tab (Optional) Shall be a scalar of type
12461 @code{INTEGER}.
12462 @end multitable
12463
12464 @end table
12465
12466
12467
12468 @node UNLINK
12469 @section @code{UNLINK} --- Remove a file from the file system
12470 @fnindex UNLINK
12471 @cindex file system, remove file
12472
12473 @table @asis
12474 @item @emph{Description}:
12475 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
12476 used to mark the end of the name in @var{PATH}; otherwise, trailing
12477 blanks in the file name are ignored.  If the @var{STATUS} argument is
12478 supplied, it contains 0 on success or a nonzero error code upon return;
12479 see @code{unlink(2)}.
12480
12481 This intrinsic is provided in both subroutine and function forms;
12482 however, only one form can be used in any given program unit.
12483
12484 @item @emph{Standard}:
12485 GNU extension
12486
12487 @item @emph{Class}:
12488 Subroutine, function
12489
12490 @item @emph{Syntax}:
12491 @multitable @columnfractions .80
12492 @item @code{CALL UNLINK(PATH [, STATUS])}
12493 @item @code{STATUS = UNLINK(PATH)}
12494 @end multitable
12495
12496 @item @emph{Arguments}:
12497 @multitable @columnfractions .15 .70
12498 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
12499 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
12500 @end multitable
12501
12502 @item @emph{See also}:
12503 @ref{LINK}, @ref{SYMLNK}
12504 @end table
12505
12506
12507
12508 @node UNPACK
12509 @section @code{UNPACK} --- Unpack an array of rank one into an array
12510 @fnindex UNPACK
12511 @cindex array, unpacking
12512 @cindex array, increase dimension
12513 @cindex array, scatter elements
12514
12515 @table @asis
12516 @item @emph{Description}:
12517 Store the elements of @var{VECTOR} in an array of higher rank.
12518
12519 @item @emph{Standard}:
12520 Fortran 95 and later
12521
12522 @item @emph{Class}:
12523 Transformational function
12524
12525 @item @emph{Syntax}:
12526 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
12527
12528 @item @emph{Arguments}:
12529 @multitable @columnfractions .15 .70
12530 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It 
12531 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
12532 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL}.
12533 @item @var{FIELD}  @tab Shall be of the same type as @var{VECTOR} and have
12534 the same shape as @var{MASK}.
12535 @end multitable
12536
12537 @item @emph{Return value}:
12538 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
12539 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
12540
12541 @item @emph{Example}:
12542 @smallexample
12543 PROGRAM test_unpack
12544   integer :: vector(2)  = (/1,1/)
12545   logical :: mask(4)  = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
12546   integer :: field(2,2) = 0, unity(2,2)
12547
12548   ! result: unity matrix
12549   unity = unpack(vector, reshape(mask, (/2,2/)), field)
12550 END PROGRAM
12551 @end smallexample
12552
12553 @item @emph{See also}:
12554 @ref{PACK}, @ref{SPREAD}
12555 @end table
12556
12557
12558
12559 @node VERIFY
12560 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
12561 @fnindex VERIFY
12562 @cindex string, find missing set
12563
12564 @table @asis
12565 @item @emph{Description}:
12566 Verifies that all the characters in a @var{SET} are present in a @var{STRING}.
12567
12568 If @var{BACK} is either absent or equals @code{FALSE}, this function
12569 returns the position of the leftmost character of @var{STRING} that is
12570 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
12571 is returned. If all characters of @var{SET} are found in @var{STRING}, the 
12572 result is zero.
12573
12574 @item @emph{Standard}:
12575 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
12576
12577 @item @emph{Class}:
12578 Elemental function
12579
12580 @item @emph{Syntax}:
12581 @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
12582
12583 @item @emph{Arguments}:
12584 @multitable @columnfractions .15 .70
12585 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
12586 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
12587 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
12588 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
12589 expression indicating the kind parameter of the result.
12590 @end multitable
12591
12592 @item @emph{Return value}:
12593 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12594 @var{KIND} is absent, the return value is of default integer kind.
12595
12596 @item @emph{Example}:
12597 @smallexample
12598 PROGRAM test_verify
12599   WRITE(*,*) VERIFY("FORTRAN", "AO")           ! 1, found 'F'
12600   WRITE(*,*) VERIFY("FORTRAN", "FOO")          ! 3, found 'R'
12601   WRITE(*,*) VERIFY("FORTRAN", "C++")          ! 1, found 'F'
12602   WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.)  ! 7, found 'N'
12603   WRITE(*,*) VERIFY("FORTRAN", "FORTRAN")      ! 0' found none
12604 END PROGRAM
12605 @end smallexample
12606
12607 @item @emph{See also}:
12608 @ref{SCAN}, @ref{INDEX intrinsic}
12609 @end table
12610
12611
12612
12613 @node XOR
12614 @section @code{XOR} --- Bitwise logical exclusive OR
12615 @fnindex XOR
12616 @cindex bitwise logical exclusive or
12617 @cindex logical exclusive or, bitwise
12618
12619 @table @asis
12620 @item @emph{Description}:
12621 Bitwise logical exclusive or. 
12622
12623 This intrinsic routine is provided for backwards compatibility with 
12624 GNU Fortran 77.  For integer arguments, programmers should consider
12625 the use of the @ref{IEOR} intrinsic and for logical arguments the
12626 @code{.NEQV.} operator, which are both defined by the Fortran standard.
12627
12628 @item @emph{Standard}:
12629 GNU extension
12630
12631 @item @emph{Class}:
12632 Function
12633
12634 @item @emph{Syntax}:
12635 @code{RESULT = XOR(I, J)}
12636
12637 @item @emph{Arguments}:
12638 @multitable @columnfractions .15 .70
12639 @item @var{I} @tab The type shall be either  a scalar @code{INTEGER}
12640 type or a scalar @code{LOGICAL} type.
12641 @item @var{J} @tab The type shall be the same as the type of @var{I}.
12642 @end multitable
12643
12644 @item @emph{Return value}:
12645 The return type is either a scalar @code{INTEGER} or a scalar
12646 @code{LOGICAL}.  If the kind type parameters differ, then the
12647 smaller kind type is implicitly converted to larger kind, and the 
12648 return has the larger kind.
12649
12650 @item @emph{Example}:
12651 @smallexample
12652 PROGRAM test_xor
12653   LOGICAL :: T = .TRUE., F = .FALSE.
12654   INTEGER :: a, b
12655   DATA a / Z'F' /, b / Z'3' /
12656
12657   WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
12658   WRITE (*,*) XOR(a, b)
12659 END PROGRAM
12660 @end smallexample
12661
12662 @item @emph{See also}:
12663 Fortran 95 elemental function: @ref{IEOR}
12664 @end table
12665
12666
12667
12668 @node Intrinsic Modules
12669 @chapter Intrinsic Modules
12670 @cindex intrinsic Modules
12671
12672 @menu
12673 * ISO_FORTRAN_ENV::
12674 * ISO_C_BINDING::
12675 * OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
12676 @end menu
12677
12678 @node ISO_FORTRAN_ENV
12679 @section @code{ISO_FORTRAN_ENV}
12680 @table @asis
12681 @item @emph{Standard}:
12682 Fortran 2003 and later, except when otherwise noted
12683 @end table
12684
12685 The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
12686 named constants:
12687
12688 @table @asis
12689 @item @code{ATOMIC_INT_KIND}:
12690 Default-kind integer constant to be used as kind parameter when defining
12691 integer variables used in atomic operations. (Fortran 2008 or later.)
12692
12693 @item @code{ATOMIC_LOGICAL_KIND}:
12694 Default-kind integer constant to be used as kind parameter when defining
12695 logical variables used in atomic operations. (Fortran 2008 or later.)
12696
12697 @item @code{CHARACTER_KINDS}:
12698 Default-kind integer constant array of rank one containing the supported kind
12699 parameters of the @code{CHARACTER} type. (Fortran 2008 or later.)
12700
12701 @item @code{CHARACTER_STORAGE_SIZE}:
12702 Size in bits of the character storage unit.
12703
12704 @item @code{ERROR_UNIT}:
12705 Identifies the preconnected unit used for error reporting.
12706
12707 @item @code{FILE_STORAGE_SIZE}:
12708 Size in bits of the file-storage unit.
12709
12710 @item @code{INPUT_UNIT}:
12711 Identifies the preconnected unit identified by the asterisk
12712 (@code{*}) in @code{READ} statement.
12713
12714 @item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}:
12715 Kind type parameters to specify an INTEGER type with a storage
12716 size of 16, 32, and 64 bits. It is negative if a target platform
12717 does not support the particular kind. (Fortran 2008 or later.)
12718
12719 @item @code{INTEGER_KINDS}:
12720 Default-kind integer constant array of rank one containing the supported kind
12721 parameters of the @code{INTEGER} type. (Fortran 2008 or later.)
12722
12723 @item @code{IOSTAT_END}:
12724 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
12725 an input/output statement if an end-of-file condition occurred.
12726
12727 @item @code{IOSTAT_EOR}:
12728 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
12729 an input/output statement if an end-of-record condition occurred.
12730
12731 @item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}:
12732 Scalar default-integer constant, used by @code{INQUIRE} for the
12733 @code{IOSTAT=} specifier to denote an that a unit number identifies an
12734 internal unit. (Fortran 2008 or later.)
12735
12736 @item @code{NUMERIC_STORAGE_SIZE}:
12737 The size in bits of the numeric storage unit.
12738
12739 @item @code{LOGICAL_KINDS}:
12740 Default-kind integer constant array of rank one containing the supported kind
12741 parameters of the @code{LOGICAL} type. (Fortran 2008 or later.)
12742
12743 @item @code{OUTPUT_UNIT}:
12744 Identifies the preconnected unit identified by the asterisk
12745 (@code{*}) in @code{WRITE} statement.
12746
12747 @item @code{REAL32}, @code{REAL64}, @code{REAL128}:
12748 Kind type parameters to specify a REAL type with a storage
12749 size of 32, 64, and 128 bits. It is negative if a target platform
12750 does not support the particular kind. (Fortran 2008 or later.)
12751
12752 @item @code{REAL_KINDS}:
12753 Default-kind integer constant array of rank one containing the supported kind
12754 parameters of the @code{REAL} type. (Fortran 2008 or later.)
12755
12756 @item @code{STAT_LOCKED}:
12757 Scalar default-integer constant used as STAT= return value by @code{LOCK} to
12758 denote that the lock variable is locked by the executing image. (Fortran 2008
12759 or later.)
12760
12761 @item @code{STAT_LOCKED_OTHER_IMAGE}:
12762 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
12763 denote that the lock variable is locked by another image. (Fortran 2008 or
12764 later.)
12765
12766 @item @code{STAT_STOPPED_IMAGE}:
12767 Positive, scalar default-integer constant used as STAT= return value if the
12768 argument in the statement requires synchronisation with an image, which has
12769 initiated the termination of the execution. (Fortran 2008 or later.)
12770
12771 @item @code{STAT_UNLOCKED}:
12772 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
12773 denote that the lock variable is unlocked. (Fortran 2008 or later.)
12774 @end table
12775
12776 The module also provides the following intrinsic procedures:
12777 @ref{COMPILER_OPTIONS} and @ref{COMPILER_VERSION}.
12778
12779
12780
12781 @node ISO_C_BINDING
12782 @section @code{ISO_C_BINDING}
12783 @table @asis
12784 @item @emph{Standard}:
12785 Fortran 2003 and later, GNU extensions
12786 @end table
12787
12788 The following intrinsic procedures are provided by the module; their
12789 definition can be found in the section Intrinsic Procedures of this
12790 manual.
12791
12792 @table @asis
12793 @item @code{C_ASSOCIATED}
12794 @item @code{C_F_POINTER}
12795 @item @code{C_F_PROCPOINTER}
12796 @item @code{C_FUNLOC}
12797 @item @code{C_LOC}
12798 @item @code{C_SIZEOF}
12799 @end table
12800 @c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
12801 @c don't really know why.
12802
12803 The @code{ISO_C_BINDING} module provides the following named constants of
12804 type default integer, which can be used as KIND type parameters.
12805
12806 In addition to the integer named constants required by the Fortran 2003 
12807 standard, GNU Fortran provides as an extension named constants for the 
12808 128-bit integer types supported by the C compiler: @code{C_INT128_T, 
12809 C_INT_LEAST128_T, C_INT_FAST128_T}.
12810
12811 @multitable @columnfractions .15 .35 .35 .35
12812 @item Fortran Type  @tab Named constant         @tab C type                                @tab Extension
12813 @item @code{INTEGER}@tab @code{C_INT}           @tab @code{int}
12814 @item @code{INTEGER}@tab @code{C_SHORT}         @tab @code{short int}
12815 @item @code{INTEGER}@tab @code{C_LONG}          @tab @code{long int}
12816 @item @code{INTEGER}@tab @code{C_LONG_LONG}     @tab @code{long long int}
12817 @item @code{INTEGER}@tab @code{C_SIGNED_CHAR}   @tab @code{signed char}/@code{unsigned char}
12818 @item @code{INTEGER}@tab @code{C_SIZE_T}        @tab @code{size_t}
12819 @item @code{INTEGER}@tab @code{C_INT8_T}        @tab @code{int8_t}
12820 @item @code{INTEGER}@tab @code{C_INT16_T}       @tab @code{int16_t}
12821 @item @code{INTEGER}@tab @code{C_INT32_T}       @tab @code{int32_t}
12822 @item @code{INTEGER}@tab @code{C_INT64_T}       @tab @code{int64_t}
12823 @item @code{INTEGER}@tab @code{C_INT128_T}      @tab @code{int128_t}                      @tab Ext.
12824 @item @code{INTEGER}@tab @code{C_INT_LEAST8_T}  @tab @code{int_least8_t}
12825 @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
12826 @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
12827 @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
12828 @item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t}                @tab Ext.
12829 @item @code{INTEGER}@tab @code{C_INT_FAST8_T}   @tab @code{int_fast8_t}
12830 @item @code{INTEGER}@tab @code{C_INT_FAST16_T}  @tab @code{int_fast16_t}
12831 @item @code{INTEGER}@tab @code{C_INT_FAST32_T}  @tab @code{int_fast32_t}
12832 @item @code{INTEGER}@tab @code{C_INT_FAST64_T}  @tab @code{int_fast64_t}
12833 @item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t}                 @tab Ext.
12834 @item @code{INTEGER}@tab @code{C_INTMAX_T}      @tab @code{intmax_t}
12835 @item @code{INTEGER}@tab @code{C_INTPTR_T}      @tab @code{intptr_t}
12836 @item @code{REAL}   @tab @code{C_FLOAT}         @tab @code{float}
12837 @item @code{REAL}   @tab @code{C_DOUBLE}        @tab @code{double}
12838 @item @code{REAL}   @tab @code{C_LONG_DOUBLE}   @tab @code{long double}
12839 @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
12840 @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
12841 @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
12842 @item @code{LOGICAL}@tab @code{C_BOOL}          @tab @code{_Bool}
12843 @item @code{CHARACTER}@tab @code{C_CHAR}        @tab @code{char}
12844 @end multitable
12845
12846 Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)}
12847 are defined.
12848
12849 @multitable @columnfractions .20 .45 .15
12850 @item Name                     @tab C definition    @tab Value
12851 @item @code{C_NULL_CHAR}       @tab null character  @tab @code{'\0'}
12852 @item @code{C_ALERT}           @tab alert           @tab @code{'\a'}
12853 @item @code{C_BACKSPACE}       @tab backspace       @tab @code{'\b'}
12854 @item @code{C_FORM_FEED}       @tab form feed       @tab @code{'\f'}
12855 @item @code{C_NEW_LINE}        @tab new line        @tab @code{'\n'}
12856 @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
12857 @item @code{C_HORIZONTAL_TAB}  @tab horizontal tab  @tab @code{'\t'}
12858 @item @code{C_VERTICAL_TAB}    @tab vertical tab    @tab @code{'\v'}
12859 @end multitable
12860
12861 Moreover, the following two named constants are defined:
12862
12863 @multitable @columnfractions .20 .80
12864 @item Name                 @tab Type
12865 @item @code{C_NULL_PTR}    @tab @code{C_PTR}
12866 @item @code{C_NULL_FUNPTR} @tab @code{C_FUNPTR}
12867 @end multitable
12868
12869 Both are equivalent to the value @code{NULL} in C.
12870
12871 @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
12872 @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
12873 @table @asis
12874 @item @emph{Standard}:
12875 OpenMP Application Program Interface v3.0
12876 @end table
12877
12878
12879 The OpenMP Fortran runtime library routines are provided both in
12880 a form of two Fortran 90 modules, named @code{OMP_LIB} and 
12881 @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
12882 @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
12883 in the @ref{Top,,Introduction,libgomp,GNU OpenMP runtime library} manual,
12884 the named constants defined in the modules are listed
12885 below.
12886
12887 For details refer to the actual
12888 @uref{http://www.openmp.org/mp-documents/spec30.pdf,
12889 OpenMP Application Program Interface v3.0}.
12890
12891 @code{OMP_LIB_KINDS} provides the following scalar default-integer
12892 named constants:
12893
12894 @table @asis
12895 @item @code{omp_integer_kind}
12896 @item @code{omp_logical_kind}
12897 @item @code{omp_lock_kind}
12898 @item @code{omp_nest_lock_kind}
12899 @item @code{omp_sched_kind}
12900 @end table
12901
12902 @code{OMP_LIB} provides the scalar default-integer
12903 named constant @code{openmp_version} with a value of the form
12904 @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
12905 of the OpenMP version; for OpenMP v3.0 the value is @code{200805}.
12906
12907 And the following scalar integer named constants of the
12908 kind @code{omp_sched_kind}:
12909
12910 @table @asis
12911 @item @code{omp_sched_static}
12912 @item @code{omp_sched_dynamic}
12913 @item @code{omp_sched_guided}
12914 @item @code{omp_sched_auto}
12915 @end table