OSDN Git Service

d91ecfdbb1ece25b874b06780b49d0ed9d72d2f1
[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
4156 and has the value false, the execution of the command is asynchronous
4157 if the system supports it; otherwise, the command is executed
4158 synchronously.
4159
4160 The three last arguments allow the user to get status information.  After
4161 synchronous execution, @code{EXITSTAT} contains the integer exit code of
4162 the command, as returned by @code{system}.  @code{CMDSTAT} is set to zero
4163 if the command line was executed (whatever its exit status was).
4164 @code{CMDMSG} is assigned an error message if an error has occurred.
4165
4166 Note that the @code{system} function need not be thread-safe. It is
4167 the responsibility of the user to ensure that @code{system} is not
4168 called concurrently.
4169
4170 @item @emph{Standard}:
4171 Fortran 2008 and later
4172
4173 @item @emph{Class}:
4174 Subroutine
4175
4176 @item @emph{Syntax}:
4177 @code{CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])}
4178
4179 @item @emph{Arguments}:
4180 @multitable @columnfractions .15 .70
4181 @item @var{COMMAND} @tab Shall be a default @code{CHARACTER} scalar.
4182 @item @var{WAIT} @tab (Optional) Shall be a default @code{LOGICAL} scalar.
4183 @item @var{EXITSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
4184 default kind.
4185 @item @var{CMDSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
4186 default kind.
4187 @item @var{CMDMSG} @tab (Optional) Shall be an @code{CHARACTER} scalar of the
4188 default kind.
4189 @end multitable
4190
4191 @item @emph{Example}:
4192 @smallexample
4193 program test_exec
4194   integer :: i
4195
4196   call execute_command_line ("external_prog.exe", exitstat=i)
4197   print *, "Exit status of external_prog.exe was ", i
4198
4199   call execute_command_line ("reindex_files.exe", wait=.false.)
4200   print *, "Now reindexing files in the background"
4201
4202 end program test_exec
4203 @end smallexample
4204
4205
4206 @item @emph{Note}:
4207
4208 Because this intrinsic is implemented in terms of the @code{system}
4209 function call, its behavior with respect to signaling is processor
4210 dependent. In particular, on POSIX-compliant systems, the SIGINT and
4211 SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As
4212 such, if the parent process is terminated, the child process might not be
4213 terminated alongside.
4214
4215
4216 @item @emph{See also}:
4217 @ref{SYSTEM}
4218 @end table
4219
4220
4221
4222 @node EXIT
4223 @section @code{EXIT} --- Exit the program with status. 
4224 @fnindex EXIT
4225 @cindex program termination
4226 @cindex terminate program
4227
4228 @table @asis
4229 @item @emph{Description}:
4230 @code{EXIT} causes immediate termination of the program with status.  If status
4231 is omitted it returns the canonical @emph{success} for the system.  All Fortran
4232 I/O units are closed. 
4233
4234 @item @emph{Standard}:
4235 GNU extension
4236
4237 @item @emph{Class}:
4238 Subroutine
4239
4240 @item @emph{Syntax}:
4241 @code{CALL EXIT([STATUS])}
4242
4243 @item @emph{Arguments}:
4244 @multitable @columnfractions .15 .70
4245 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
4246 @end multitable
4247
4248 @item @emph{Return value}:
4249 @code{STATUS} is passed to the parent process on exit.
4250
4251 @item @emph{Example}:
4252 @smallexample
4253 program test_exit
4254   integer :: STATUS = 0
4255   print *, 'This program is going to exit.'
4256   call EXIT(STATUS)
4257 end program test_exit
4258 @end smallexample
4259
4260 @item @emph{See also}:
4261 @ref{ABORT}, @ref{KILL}
4262 @end table
4263
4264
4265
4266 @node EXP
4267 @section @code{EXP} --- Exponential function 
4268 @fnindex EXP
4269 @fnindex DEXP
4270 @fnindex CEXP
4271 @fnindex ZEXP
4272 @fnindex CDEXP
4273 @cindex exponential function
4274 @cindex logarithmic function, inverse
4275
4276 @table @asis
4277 @item @emph{Description}:
4278 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
4279
4280 @item @emph{Standard}:
4281 Fortran 77 and later, has overloads that are GNU extensions
4282
4283 @item @emph{Class}:
4284 Elemental function
4285
4286 @item @emph{Syntax}:
4287 @code{RESULT = EXP(X)}
4288
4289 @item @emph{Arguments}:
4290 @multitable @columnfractions .15 .70
4291 @item @var{X} @tab The type shall be @code{REAL} or
4292 @code{COMPLEX}.
4293 @end multitable
4294
4295 @item @emph{Return value}:
4296 The return value has same type and kind as @var{X}.
4297
4298 @item @emph{Example}:
4299 @smallexample
4300 program test_exp
4301   real :: x = 1.0
4302   x = exp(x)
4303 end program test_exp
4304 @end smallexample
4305
4306 @item @emph{Specific names}:
4307 @multitable @columnfractions .20 .20 .20 .25
4308 @item Name            @tab Argument             @tab Return type         @tab Standard
4309 @item @code{EXP(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}      @tab Fortran 77 and later
4310 @item @code{DEXP(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}      @tab Fortran 77 and later
4311 @item @code{CEXP(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}   @tab Fortran 77 and later
4312 @item @code{ZEXP(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
4313 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
4314 @end multitable
4315 @end table
4316
4317
4318
4319 @node EXPONENT
4320 @section @code{EXPONENT} --- Exponent function 
4321 @fnindex EXPONENT
4322 @cindex real number, exponent
4323 @cindex floating point, exponent
4324
4325 @table @asis
4326 @item @emph{Description}:
4327 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
4328 is zero the value returned is zero. 
4329
4330 @item @emph{Standard}:
4331 Fortran 95 and later
4332
4333 @item @emph{Class}:
4334 Elemental function
4335
4336 @item @emph{Syntax}:
4337 @code{RESULT = EXPONENT(X)}
4338
4339 @item @emph{Arguments}:
4340 @multitable @columnfractions .15 .70
4341 @item @var{X} @tab The type shall be @code{REAL}.
4342 @end multitable
4343
4344 @item @emph{Return value}:
4345 The return value is of type default @code{INTEGER}.
4346
4347 @item @emph{Example}:
4348 @smallexample
4349 program test_exponent
4350   real :: x = 1.0
4351   integer :: i
4352   i = exponent(x)
4353   print *, i
4354   print *, exponent(0.0)
4355 end program test_exponent
4356 @end smallexample
4357 @end table
4358
4359
4360
4361 @node EXTENDS_TYPE_OF
4362 @section @code{EXTENDS_TYPE_OF} ---  Query dynamic type for extension
4363 @fnindex EXTENDS_TYPE_OF
4364
4365 @table @asis
4366 @item @emph{Description}:
4367 Query dynamic type for extension.
4368
4369 @item @emph{Standard}:
4370 Fortran 2003 and later
4371
4372 @item @emph{Class}:
4373 Inquiry function
4374
4375 @item @emph{Syntax}:
4376 @code{RESULT = EXTENDS_TYPE_OF(A, MOLD)}
4377
4378 @item @emph{Arguments}:
4379 @multitable @columnfractions .15 .70
4380 @item @var{A} @tab Shall be an object of extensible declared type or
4381 unlimited polymorphic. 
4382 @item @var{MOLD} @tab Shall be an object of extensible declared type or
4383 unlimited polymorphic. 
4384 @end multitable
4385
4386 @item @emph{Return value}:
4387 The return value is a scalar of type default logical. It is true if and only if
4388 the dynamic type of A is an extension type of the dynamic type of MOLD.
4389
4390
4391 @item @emph{See also}:
4392 @ref{SAME_TYPE_AS}
4393 @end table
4394
4395
4396
4397 @node FDATE
4398 @section @code{FDATE} --- Get the current time as a string
4399 @fnindex FDATE
4400 @cindex time, current
4401 @cindex current time
4402 @cindex date, current
4403 @cindex current date
4404
4405 @table @asis
4406 @item @emph{Description}:
4407 @code{FDATE(DATE)} returns the current date (using the same format as
4408 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
4409 TIME())}.
4410
4411 This intrinsic is provided in both subroutine and function forms; however,
4412 only one form can be used in any given program unit.
4413
4414 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable of the
4415 default kind.
4416
4417 @item @emph{Standard}:
4418 GNU extension
4419
4420 @item @emph{Class}:
4421 Subroutine, function
4422
4423 @item @emph{Syntax}:
4424 @multitable @columnfractions .80
4425 @item @code{CALL FDATE(DATE)}.
4426 @item @code{DATE = FDATE()}, (not recommended).
4427 @end multitable
4428
4429 @item @emph{Arguments}:
4430 @multitable @columnfractions .15 .70
4431 @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
4432 default kind
4433 @end multitable
4434
4435 @item @emph{Return value}:
4436 The current date as a string.
4437
4438 @item @emph{Example}:
4439 @smallexample
4440 program test_fdate
4441     integer(8) :: i, j
4442     character(len=30) :: date
4443     call fdate(date)
4444     print *, 'Program started on ', date
4445     do i = 1, 100000000 ! Just a delay
4446         j = i * i - i
4447     end do
4448     call fdate(date)
4449     print *, 'Program ended on ', date
4450 end program test_fdate
4451 @end smallexample
4452 @end table
4453
4454
4455
4456 @node FGET
4457 @section @code{FGET} --- Read a single character in stream mode from stdin 
4458 @fnindex FGET
4459 @cindex read character, stream mode
4460 @cindex stream mode, read character
4461 @cindex file operation, read character
4462
4463 @table @asis
4464 @item @emph{Description}:
4465 Read a single character in stream mode from stdin by bypassing normal 
4466 formatted output. Stream I/O should not be mixed with normal record-oriented 
4467 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4468
4469 This intrinsic is provided in both subroutine and function forms; however,
4470 only one form can be used in any given program unit.
4471
4472 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4473 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4474 Programmers should consider the use of new stream IO feature in new code 
4475 for future portability. See also @ref{Fortran 2003 status}.
4476
4477 @item @emph{Standard}:
4478 GNU extension
4479
4480 @item @emph{Class}:
4481 Subroutine, function
4482
4483 @item @emph{Syntax}:
4484 @multitable @columnfractions .80
4485 @item @code{CALL FGET(C [, STATUS])}
4486 @item @code{STATUS = FGET(C)}
4487 @end multitable
4488
4489 @item @emph{Arguments}:
4490 @multitable @columnfractions .15 .70
4491 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4492 kind.
4493 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4494 Returns 0 on success, -1 on end-of-file, and a system specific positive
4495 error code otherwise.
4496 @end multitable
4497
4498 @item @emph{Example}:
4499 @smallexample
4500 PROGRAM test_fget
4501   INTEGER, PARAMETER :: strlen = 100
4502   INTEGER :: status, i = 1
4503   CHARACTER(len=strlen) :: str = ""
4504
4505   WRITE (*,*) 'Enter text:'
4506   DO
4507     CALL fget(str(i:i), status)
4508     if (status /= 0 .OR. i > strlen) exit
4509     i = i + 1
4510   END DO
4511   WRITE (*,*) TRIM(str)
4512 END PROGRAM
4513 @end smallexample
4514
4515 @item @emph{See also}:
4516 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
4517 @end table
4518
4519
4520
4521 @node FGETC
4522 @section @code{FGETC} --- Read a single character in stream mode
4523 @fnindex FGETC
4524 @cindex read character, stream mode
4525 @cindex stream mode, read character
4526 @cindex file operation, read character
4527
4528 @table @asis
4529 @item @emph{Description}:
4530 Read a single character in stream mode by bypassing normal formatted output. 
4531 Stream I/O should not be mixed with normal record-oriented (formatted or 
4532 unformatted) I/O on the same unit; the results are unpredictable.
4533
4534 This intrinsic is provided in both subroutine and function forms; however,
4535 only one form can be used in any given program unit.
4536
4537 Note that the @code{FGET} intrinsic is provided for backwards compatibility
4538 with @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4539 Programmers should consider the use of new stream IO feature in new code 
4540 for future portability. See also @ref{Fortran 2003 status}.
4541
4542 @item @emph{Standard}:
4543 GNU extension
4544
4545 @item @emph{Class}:
4546 Subroutine, function
4547
4548 @item @emph{Syntax}:
4549 @multitable @columnfractions .80
4550 @item @code{CALL FGETC(UNIT, C [, STATUS])}
4551 @item @code{STATUS = FGETC(UNIT, C)}
4552 @end multitable
4553
4554 @item @emph{Arguments}:
4555 @multitable @columnfractions .15 .70
4556 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4557 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4558 kind.
4559 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4560 Returns 0 on success, -1 on end-of-file and a system specific positive
4561 error code otherwise.
4562 @end multitable
4563
4564 @item @emph{Example}:
4565 @smallexample
4566 PROGRAM test_fgetc
4567   INTEGER :: fd = 42, status
4568   CHARACTER :: c
4569
4570   OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
4571   DO
4572     CALL fgetc(fd, c, status)
4573     IF (status /= 0) EXIT
4574     call fput(c)
4575   END DO
4576   CLOSE(UNIT=fd)
4577 END PROGRAM
4578 @end smallexample
4579
4580 @item @emph{See also}:
4581 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
4582 @end table
4583
4584
4585
4586 @node FLOOR
4587 @section @code{FLOOR} --- Integer floor function
4588 @fnindex FLOOR
4589 @cindex floor
4590 @cindex rounding, floor
4591
4592 @table @asis
4593 @item @emph{Description}:
4594 @code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
4595
4596 @item @emph{Standard}:
4597 Fortran 95 and later
4598
4599 @item @emph{Class}:
4600 Elemental function
4601
4602 @item @emph{Syntax}:
4603 @code{RESULT = FLOOR(A [, KIND])}
4604
4605 @item @emph{Arguments}:
4606 @multitable @columnfractions .15 .70
4607 @item @var{A} @tab The type shall be @code{REAL}.
4608 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
4609 expression indicating the kind parameter of the result.
4610 @end multitable
4611
4612 @item @emph{Return value}:
4613 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
4614 and of default-kind @code{INTEGER} otherwise.
4615
4616 @item @emph{Example}:
4617 @smallexample
4618 program test_floor
4619     real :: x = 63.29
4620     real :: y = -63.59
4621     print *, floor(x) ! returns 63
4622     print *, floor(y) ! returns -64
4623 end program test_floor
4624 @end smallexample
4625
4626 @item @emph{See also}:
4627 @ref{CEILING}, @ref{NINT}
4628
4629 @end table
4630
4631
4632
4633 @node FLUSH
4634 @section @code{FLUSH} --- Flush I/O unit(s)
4635 @fnindex FLUSH
4636 @cindex file operation, flush
4637
4638 @table @asis
4639 @item @emph{Description}:
4640 Flushes Fortran unit(s) currently open for output. Without the optional
4641 argument, all units are flushed, otherwise just the unit specified.
4642
4643 @item @emph{Standard}:
4644 GNU extension
4645
4646 @item @emph{Class}:
4647 Subroutine
4648
4649 @item @emph{Syntax}:
4650 @code{CALL FLUSH(UNIT)}
4651
4652 @item @emph{Arguments}:
4653 @multitable @columnfractions .15 .70
4654 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
4655 @end multitable
4656
4657 @item @emph{Note}:
4658 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
4659 statement that should be preferred over the @code{FLUSH} intrinsic.
4660
4661 The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement
4662 have identical effect: they flush the runtime library's I/O buffer so
4663 that the data becomes visible to other processes. This does not guarantee
4664 that the data is committed to disk.
4665
4666 On POSIX systems, you can request that all data is transferred  to  the
4667 storage device by calling the @code{fsync} function, with the POSIX file
4668 descriptor of the I/O unit as argument (retrieved with GNU intrinsic
4669 @code{FNUM}). The following example shows how:
4670
4671 @smallexample
4672   ! Declare the interface for POSIX fsync function
4673   interface
4674     function fsync (fd) bind(c,name="fsync")
4675     use iso_c_binding, only: c_int
4676       integer(c_int), value :: fd
4677       integer(c_int) :: fsync
4678     end function fsync
4679   end interface
4680
4681   ! Variable declaration
4682   integer :: ret
4683
4684   ! Opening unit 10
4685   open (10,file="foo")
4686
4687   ! ...
4688   ! Perform I/O on unit 10
4689   ! ...
4690
4691   ! Flush and sync
4692   flush(10)
4693   ret = fsync(fnum(10))
4694
4695   ! Handle possible error
4696   if (ret /= 0) stop "Error calling FSYNC"
4697 @end smallexample
4698
4699 @end table
4700
4701
4702
4703 @node FNUM
4704 @section @code{FNUM} --- File number function
4705 @fnindex FNUM
4706 @cindex file operation, file number
4707
4708 @table @asis
4709 @item @emph{Description}:
4710 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
4711 open Fortran I/O unit @code{UNIT}.
4712
4713 @item @emph{Standard}:
4714 GNU extension
4715
4716 @item @emph{Class}:
4717 Function
4718
4719 @item @emph{Syntax}:
4720 @code{RESULT = FNUM(UNIT)}
4721
4722 @item @emph{Arguments}:
4723 @multitable @columnfractions .15 .70
4724 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
4725 @end multitable
4726
4727 @item @emph{Return value}:
4728 The return value is of type @code{INTEGER}
4729
4730 @item @emph{Example}:
4731 @smallexample
4732 program test_fnum
4733   integer :: i
4734   open (unit=10, status = "scratch")
4735   i = fnum(10)
4736   print *, i
4737   close (10)
4738 end program test_fnum
4739 @end smallexample
4740 @end table
4741
4742
4743
4744 @node FPUT
4745 @section @code{FPUT} --- Write a single character in stream mode to stdout 
4746 @fnindex FPUT
4747 @cindex write character, stream mode
4748 @cindex stream mode, write character
4749 @cindex file operation, write character
4750
4751 @table @asis
4752 @item @emph{Description}:
4753 Write a single character in stream mode to stdout by bypassing normal 
4754 formatted output. Stream I/O should not be mixed with normal record-oriented 
4755 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4756
4757 This intrinsic is provided in both subroutine and function forms; however,
4758 only one form can be used in any given program unit.
4759
4760 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4761 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4762 Programmers should consider the use of new stream IO feature in new code 
4763 for future portability. See also @ref{Fortran 2003 status}.
4764
4765 @item @emph{Standard}:
4766 GNU extension
4767
4768 @item @emph{Class}:
4769 Subroutine, function
4770
4771 @item @emph{Syntax}:
4772 @multitable @columnfractions .80
4773 @item @code{CALL FPUT(C [, STATUS])}
4774 @item @code{STATUS = FPUT(C)}
4775 @end multitable
4776
4777 @item @emph{Arguments}:
4778 @multitable @columnfractions .15 .70
4779 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4780 kind.
4781 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4782 Returns 0 on success, -1 on end-of-file and a system specific positive
4783 error code otherwise.
4784 @end multitable
4785
4786 @item @emph{Example}:
4787 @smallexample
4788 PROGRAM test_fput
4789   CHARACTER(len=10) :: str = "gfortran"
4790   INTEGER :: i
4791   DO i = 1, len_trim(str)
4792     CALL fput(str(i:i))
4793   END DO
4794 END PROGRAM
4795 @end smallexample
4796
4797 @item @emph{See also}:
4798 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
4799 @end table
4800
4801
4802
4803 @node FPUTC
4804 @section @code{FPUTC} --- Write a single character in stream mode
4805 @fnindex FPUTC
4806 @cindex write character, stream mode
4807 @cindex stream mode, write character
4808 @cindex file operation, write character
4809
4810 @table @asis
4811 @item @emph{Description}:
4812 Write a single character in stream mode by bypassing normal formatted 
4813 output. Stream I/O should not be mixed with normal record-oriented 
4814 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4815
4816 This intrinsic is provided in both subroutine and function forms; however,
4817 only one form can be used in any given program unit.
4818
4819 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4820 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4821 Programmers should consider the use of new stream IO feature in new code 
4822 for future portability. See also @ref{Fortran 2003 status}.
4823
4824 @item @emph{Standard}:
4825 GNU extension
4826
4827 @item @emph{Class}:
4828 Subroutine, function
4829
4830 @item @emph{Syntax}:
4831 @multitable @columnfractions .80
4832 @item @code{CALL FPUTC(UNIT, C [, STATUS])}
4833 @item @code{STATUS = FPUTC(UNIT, C)}
4834 @end multitable
4835
4836 @item @emph{Arguments}:
4837 @multitable @columnfractions .15 .70
4838 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4839 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4840 kind.
4841 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4842 Returns 0 on success, -1 on end-of-file and a system specific positive
4843 error code otherwise.
4844 @end multitable
4845
4846 @item @emph{Example}:
4847 @smallexample
4848 PROGRAM test_fputc
4849   CHARACTER(len=10) :: str = "gfortran"
4850   INTEGER :: fd = 42, i
4851
4852   OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
4853   DO i = 1, len_trim(str)
4854     CALL fputc(fd, str(i:i))
4855   END DO
4856   CLOSE(fd)
4857 END PROGRAM
4858 @end smallexample
4859
4860 @item @emph{See also}:
4861 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
4862 @end table
4863
4864
4865
4866 @node FRACTION
4867 @section @code{FRACTION} --- Fractional part of the model representation
4868 @fnindex FRACTION
4869 @cindex real number, fraction
4870 @cindex floating point, fraction
4871
4872 @table @asis
4873 @item @emph{Description}:
4874 @code{FRACTION(X)} returns the fractional part of the model
4875 representation of @code{X}.
4876
4877 @item @emph{Standard}:
4878 Fortran 95 and later
4879
4880 @item @emph{Class}:
4881 Elemental function
4882
4883 @item @emph{Syntax}:
4884 @code{Y = FRACTION(X)}
4885
4886 @item @emph{Arguments}:
4887 @multitable @columnfractions .15 .70
4888 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
4889 @end multitable
4890
4891 @item @emph{Return value}:
4892 The return value is of the same type and kind as the argument.
4893 The fractional part of the model representation of @code{X} is returned;
4894 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
4895
4896 @item @emph{Example}:
4897 @smallexample
4898 program test_fraction
4899   real :: x
4900   x = 178.1387e-4
4901   print *, fraction(x), x * radix(x)**(-exponent(x))
4902 end program test_fraction
4903 @end smallexample
4904
4905 @end table
4906
4907
4908
4909 @node FREE
4910 @section @code{FREE} --- Frees memory
4911 @fnindex FREE
4912 @cindex pointer, cray
4913
4914 @table @asis
4915 @item @emph{Description}:
4916 Frees memory previously allocated by @code{MALLOC}. The @code{FREE}
4917 intrinsic is an extension intended to be used with Cray pointers, and is
4918 provided in GNU Fortran to allow user to compile legacy code. For
4919 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
4920 @code{DEALLOCATE}.
4921
4922 @item @emph{Standard}:
4923 GNU extension
4924
4925 @item @emph{Class}:
4926 Subroutine
4927
4928 @item @emph{Syntax}:
4929 @code{CALL FREE(PTR)}
4930
4931 @item @emph{Arguments}:
4932 @multitable @columnfractions .15 .70
4933 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
4934 location of the memory that should be de-allocated.
4935 @end multitable
4936
4937 @item @emph{Return value}:
4938 None
4939
4940 @item @emph{Example}:
4941 See @code{MALLOC} for an example.
4942
4943 @item @emph{See also}:
4944 @ref{MALLOC}
4945 @end table
4946
4947
4948
4949 @node FSEEK
4950 @section @code{FSEEK} --- Low level file positioning subroutine
4951 @fnindex FSEEK
4952 @cindex file operation, seek
4953 @cindex file operation, position
4954
4955 @table @asis
4956 @item @emph{Description}:
4957 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE} 
4958 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
4959 if set to 1, @var{OFFSET} is taken to be relative to the current position 
4960 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
4961 On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek 
4962 fails silently.
4963
4964 This intrinsic routine is not fully backwards compatible with @command{g77}. 
4965 In @command{g77}, the @code{FSEEK} takes a statement label instead of a 
4966 @var{STATUS} variable. If FSEEK is used in old code, change
4967 @smallexample
4968   CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
4969 @end smallexample 
4970 to
4971 @smallexample
4972   INTEGER :: status
4973   CALL FSEEK(UNIT, OFFSET, WHENCE, status)
4974   IF (status /= 0) GOTO label
4975 @end smallexample 
4976
4977 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
4978 Programmers should consider the use of new stream IO feature in new code 
4979 for future portability. See also @ref{Fortran 2003 status}.
4980
4981 @item @emph{Standard}:
4982 GNU extension
4983
4984 @item @emph{Class}:
4985 Subroutine
4986
4987 @item @emph{Syntax}:
4988 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
4989
4990 @item @emph{Arguments}:
4991 @multitable @columnfractions .15 .70
4992 @item @var{UNIT}   @tab Shall be a scalar of type @code{INTEGER}.
4993 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
4994 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
4995 Its value shall be either 0, 1 or 2.
4996 @item @var{STATUS} @tab (Optional) shall be a scalar of type 
4997 @code{INTEGER(4)}.
4998 @end multitable
4999
5000 @item @emph{Example}:
5001 @smallexample
5002 PROGRAM test_fseek
5003   INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
5004   INTEGER :: fd, offset, ierr
5005
5006   ierr   = 0
5007   offset = 5
5008   fd     = 10
5009
5010   OPEN(UNIT=fd, FILE="fseek.test")
5011   CALL FSEEK(fd, offset, SEEK_SET, ierr)  ! move to OFFSET
5012   print *, FTELL(fd), ierr
5013
5014   CALL FSEEK(fd, 0, SEEK_END, ierr)       ! move to end
5015   print *, FTELL(fd), ierr
5016
5017   CALL FSEEK(fd, 0, SEEK_SET, ierr)       ! move to beginning
5018   print *, FTELL(fd), ierr
5019
5020   CLOSE(UNIT=fd)
5021 END PROGRAM
5022 @end smallexample
5023
5024 @item @emph{See also}:
5025 @ref{FTELL}
5026 @end table
5027
5028
5029
5030 @node FSTAT
5031 @section @code{FSTAT} --- Get file status
5032 @fnindex FSTAT
5033 @cindex file system, file status
5034
5035 @table @asis
5036 @item @emph{Description}:
5037 @code{FSTAT} is identical to @ref{STAT}, except that information about an 
5038 already opened file is obtained.
5039
5040 The elements in @code{VALUES} are the same as described by @ref{STAT}.
5041
5042 This intrinsic is provided in both subroutine and function forms; however,
5043 only one form can be used in any given program unit.
5044
5045 @item @emph{Standard}:
5046 GNU extension
5047
5048 @item @emph{Class}:
5049 Subroutine, function
5050
5051 @item @emph{Syntax}:
5052 @multitable @columnfractions .80
5053 @item @code{CALL FSTAT(UNIT, VALUES [, STATUS])}
5054 @item @code{STATUS = FSTAT(UNIT, VALUES)}
5055 @end multitable
5056
5057 @item @emph{Arguments}:
5058 @multitable @columnfractions .15 .70
5059 @item @var{UNIT}   @tab An open I/O unit number of type @code{INTEGER}.
5060 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
5061 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
5062 on success and a system specific error code otherwise.
5063 @end multitable
5064
5065 @item @emph{Example}:
5066 See @ref{STAT} for an example.
5067
5068 @item @emph{See also}:
5069 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
5070 @end table
5071
5072
5073
5074 @node FTELL
5075 @section @code{FTELL} --- Current stream position
5076 @fnindex FTELL
5077 @cindex file operation, position
5078
5079 @table @asis
5080 @item @emph{Description}:
5081 Retrieves the current position within an open file.
5082
5083 This intrinsic is provided in both subroutine and function forms; however,
5084 only one form can be used in any given program unit.
5085
5086 @item @emph{Standard}:
5087 GNU extension
5088
5089 @item @emph{Class}:
5090 Subroutine, function
5091
5092 @item @emph{Syntax}:
5093 @multitable @columnfractions .80
5094 @item @code{CALL FTELL(UNIT, OFFSET)}
5095 @item @code{OFFSET = FTELL(UNIT)}
5096 @end multitable
5097
5098 @item @emph{Arguments}:
5099 @multitable @columnfractions .15 .70
5100 @item @var{OFFSET}  @tab Shall of type @code{INTEGER}.
5101 @item @var{UNIT}    @tab Shall of type @code{INTEGER}.
5102 @end multitable
5103
5104 @item @emph{Return value}:
5105 In either syntax, @var{OFFSET} is set to the current offset of unit
5106 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
5107
5108 @item @emph{Example}:
5109 @smallexample
5110 PROGRAM test_ftell
5111   INTEGER :: i
5112   OPEN(10, FILE="temp.dat")
5113   CALL ftell(10,i)
5114   WRITE(*,*) i
5115 END PROGRAM
5116 @end smallexample
5117
5118 @item @emph{See also}:
5119 @ref{FSEEK}
5120 @end table
5121
5122
5123
5124 @node GAMMA
5125 @section @code{GAMMA} --- Gamma function
5126 @fnindex GAMMA
5127 @fnindex DGAMMA
5128 @cindex Gamma function
5129 @cindex Factorial function
5130
5131 @table @asis
5132 @item @emph{Description}:
5133 @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
5134 integer values of @var{X} the Gamma function simplifies to the factorial
5135 function @math{\Gamma(x)=(x-1)!}.
5136
5137 @tex
5138 $$
5139 \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
5140 $$
5141 @end tex
5142
5143 @item @emph{Standard}:
5144 Fortran 2008 and later
5145
5146 @item @emph{Class}:
5147 Elemental function
5148
5149 @item @emph{Syntax}:
5150 @code{X = GAMMA(X)}
5151
5152 @item @emph{Arguments}:
5153 @multitable @columnfractions .15 .70
5154 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
5155 nor a negative integer.
5156 @end multitable
5157
5158 @item @emph{Return value}:
5159 The return value is of type @code{REAL} of the same kind as @var{X}.
5160
5161 @item @emph{Example}:
5162 @smallexample
5163 program test_gamma
5164   real :: x = 1.0
5165   x = gamma(x) ! returns 1.0
5166 end program test_gamma
5167 @end smallexample
5168
5169 @item @emph{Specific names}:
5170 @multitable @columnfractions .20 .20 .20 .25
5171 @item Name             @tab Argument         @tab Return type       @tab Standard
5172 @item @code{GAMMA(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
5173 @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
5174 @end multitable
5175
5176 @item @emph{See also}:
5177 Logarithm of the Gamma function: @ref{LOG_GAMMA}
5178
5179 @end table
5180
5181
5182
5183 @node GERROR
5184 @section @code{GERROR} --- Get last system error message
5185 @fnindex GERROR
5186 @cindex system, error handling
5187
5188 @table @asis
5189 @item @emph{Description}:
5190 Returns the system error message corresponding to the last system error.
5191 This resembles the functionality of @code{strerror(3)} in C.
5192
5193 @item @emph{Standard}:
5194 GNU extension
5195
5196 @item @emph{Class}:
5197 Subroutine
5198
5199 @item @emph{Syntax}:
5200 @code{CALL GERROR(RESULT)}
5201
5202 @item @emph{Arguments}:
5203 @multitable @columnfractions .15 .70
5204 @item @var{RESULT}  @tab Shall of type @code{CHARACTER} and of default
5205 @end multitable
5206
5207 @item @emph{Example}:
5208 @smallexample
5209 PROGRAM test_gerror
5210   CHARACTER(len=100) :: msg
5211   CALL gerror(msg)
5212   WRITE(*,*) msg
5213 END PROGRAM
5214 @end smallexample
5215
5216 @item @emph{See also}:
5217 @ref{IERRNO}, @ref{PERROR}
5218 @end table
5219
5220
5221
5222 @node GETARG
5223 @section @code{GETARG} --- Get command line arguments
5224 @fnindex GETARG
5225 @cindex command-line arguments
5226 @cindex arguments, to program
5227
5228 @table @asis
5229 @item @emph{Description}:
5230 Retrieve the @var{POS}-th argument that was passed on the
5231 command line when the containing program was invoked.
5232
5233 This intrinsic routine is provided for backwards compatibility with 
5234 GNU Fortran 77.  In new code, programmers should consider the use of 
5235 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003 
5236 standard.
5237
5238 @item @emph{Standard}:
5239 GNU extension
5240
5241 @item @emph{Class}:
5242 Subroutine
5243
5244 @item @emph{Syntax}:
5245 @code{CALL GETARG(POS, VALUE)}
5246
5247 @item @emph{Arguments}:
5248 @multitable @columnfractions .15 .70
5249 @item @var{POS}   @tab Shall be of type @code{INTEGER} and not wider than
5250 the default integer kind; @math{@var{POS} \geq 0}
5251 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
5252 kind.
5253 @item @var{VALUE} @tab Shall be of type @code{CHARACTER}. 
5254 @end multitable
5255
5256 @item @emph{Return value}:
5257 After @code{GETARG} returns, the @var{VALUE} argument holds the
5258 @var{POS}th command line argument. If @var{VALUE} can not hold the
5259 argument, it is truncated to fit the length of @var{VALUE}. If there are
5260 less than @var{POS} arguments specified at the command line, @var{VALUE}
5261 will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
5262 to the name of the program (on systems that support this feature).
5263
5264 @item @emph{Example}:
5265 @smallexample
5266 PROGRAM test_getarg
5267   INTEGER :: i
5268   CHARACTER(len=32) :: arg
5269
5270   DO i = 1, iargc()
5271     CALL getarg(i, arg)
5272     WRITE (*,*) arg
5273   END DO
5274 END PROGRAM
5275 @end smallexample
5276
5277 @item @emph{See also}:
5278 GNU Fortran 77 compatibility function: @ref{IARGC}
5279
5280 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
5281 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
5282 @end table
5283
5284
5285
5286 @node GET_COMMAND
5287 @section @code{GET_COMMAND} --- Get the entire command line
5288 @fnindex GET_COMMAND
5289 @cindex command-line arguments
5290 @cindex arguments, to program
5291
5292 @table @asis
5293 @item @emph{Description}:
5294 Retrieve the entire command line that was used to invoke the program.
5295
5296 @item @emph{Standard}:
5297 Fortran 2003 and later
5298
5299 @item @emph{Class}:
5300 Subroutine
5301
5302 @item @emph{Syntax}:
5303 @code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])}
5304
5305 @item @emph{Arguments}:
5306 @multitable @columnfractions .15 .70
5307 @item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and
5308 of default kind.
5309 @item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of
5310 default kind.
5311 @item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of
5312 default kind.
5313 @end multitable
5314
5315 @item @emph{Return value}:
5316 If @var{COMMAND} is present, stores the entire command line that was used
5317 to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is
5318 assigned the length of the command line. If @var{STATUS} is present, it
5319 is assigned 0 upon success of the command, -1 if @var{COMMAND} is too
5320 short to store the command line, or a positive value in case of an error.
5321
5322 @item @emph{Example}:
5323 @smallexample
5324 PROGRAM test_get_command
5325   CHARACTER(len=255) :: cmd
5326   CALL get_command(cmd)
5327   WRITE (*,*) TRIM(cmd)
5328 END PROGRAM
5329 @end smallexample
5330
5331 @item @emph{See also}:
5332 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
5333 @end table
5334
5335
5336
5337 @node GET_COMMAND_ARGUMENT
5338 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
5339 @fnindex GET_COMMAND_ARGUMENT
5340 @cindex command-line arguments
5341 @cindex arguments, to program
5342
5343 @table @asis
5344 @item @emph{Description}:
5345 Retrieve the @var{NUMBER}-th argument that was passed on the
5346 command line when the containing program was invoked.
5347
5348 @item @emph{Standard}:
5349 Fortran 2003 and later
5350
5351 @item @emph{Class}:
5352 Subroutine
5353
5354 @item @emph{Syntax}:
5355 @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
5356
5357 @item @emph{Arguments}:
5358 @multitable @columnfractions .15 .70
5359 @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of
5360 default kind, @math{@var{NUMBER} \geq 0}
5361 @item @var{VALUE}  @tab (Optional) Shall be a scalar of type @code{CHARACTER}
5362 and of default kind.
5363 @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
5364 and of default kind.
5365 @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
5366 and of default kind.
5367 @end multitable
5368
5369 @item @emph{Return value}:
5370 After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the 
5371 @var{NUMBER}-th command line argument. If @var{VALUE} can not hold the argument, it is 
5372 truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
5373 arguments specified at the command line, @var{VALUE} will be filled with blanks. 
5374 If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on
5375 systems that support this feature). The @var{LENGTH} argument contains the
5376 length of the @var{NUMBER}-th command line argument. If the argument retrieval
5377 fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated
5378 command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is
5379 zero.
5380
5381 @item @emph{Example}:
5382 @smallexample
5383 PROGRAM test_get_command_argument
5384   INTEGER :: i
5385   CHARACTER(len=32) :: arg
5386
5387   i = 0
5388   DO
5389     CALL get_command_argument(i, arg)
5390     IF (LEN_TRIM(arg) == 0) EXIT
5391
5392     WRITE (*,*) TRIM(arg)
5393     i = i+1
5394   END DO
5395 END PROGRAM
5396 @end smallexample
5397
5398 @item @emph{See also}:
5399 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
5400 @end table
5401
5402
5403
5404 @node GETCWD
5405 @section @code{GETCWD} --- Get current working directory
5406 @fnindex GETCWD
5407 @cindex system, working directory
5408
5409 @table @asis
5410 @item @emph{Description}:
5411 Get current working directory.
5412
5413 This intrinsic is provided in both subroutine and function forms; however,
5414 only one form can be used in any given program unit.
5415
5416 @item @emph{Standard}:
5417 GNU extension
5418
5419 @item @emph{Class}:
5420 Subroutine, function
5421
5422 @item @emph{Syntax}:
5423 @multitable @columnfractions .80
5424 @item @code{CALL GETCWD(C [, STATUS])}
5425 @item @code{STATUS = GETCWD(C)}
5426 @end multitable
5427
5428 @item @emph{Arguments}:
5429 @multitable @columnfractions .15 .70
5430 @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
5431 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success, 
5432 a system specific and nonzero error code otherwise.
5433 @end multitable
5434
5435 @item @emph{Example}:
5436 @smallexample
5437 PROGRAM test_getcwd
5438   CHARACTER(len=255) :: cwd
5439   CALL getcwd(cwd)
5440   WRITE(*,*) TRIM(cwd)
5441 END PROGRAM
5442 @end smallexample
5443
5444 @item @emph{See also}:
5445 @ref{CHDIR}
5446 @end table
5447
5448
5449
5450 @node GETENV
5451 @section @code{GETENV} --- Get an environmental variable
5452 @fnindex GETENV
5453 @cindex environment variable
5454
5455 @table @asis
5456 @item @emph{Description}:
5457 Get the @var{VALUE} of the environmental variable @var{NAME}.
5458
5459 This intrinsic routine is provided for backwards compatibility with
5460 GNU Fortran 77.  In new code, programmers should consider the use of
5461 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
5462 2003 standard.
5463
5464 Note that @code{GETENV} need not be thread-safe. It is the
5465 responsibility of the user to ensure that the environment is not being
5466 updated concurrently with a call to the @code{GETENV} intrinsic.
5467
5468 @item @emph{Standard}:
5469 GNU extension
5470
5471 @item @emph{Class}:
5472 Subroutine
5473
5474 @item @emph{Syntax}:
5475 @code{CALL GETENV(NAME, VALUE)}
5476
5477 @item @emph{Arguments}:
5478 @multitable @columnfractions .15 .70
5479 @item @var{NAME}  @tab Shall be of type @code{CHARACTER} and of default kind.
5480 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
5481 @end multitable
5482
5483 @item @emph{Return value}:
5484 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
5485 not large enough to hold the data, it is truncated. If @var{NAME}
5486 is not set, @var{VALUE} will be filled with blanks.
5487
5488 @item @emph{Example}:
5489 @smallexample
5490 PROGRAM test_getenv
5491   CHARACTER(len=255) :: homedir
5492   CALL getenv("HOME", homedir)
5493   WRITE (*,*) TRIM(homedir)
5494 END PROGRAM
5495 @end smallexample
5496
5497 @item @emph{See also}:
5498 @ref{GET_ENVIRONMENT_VARIABLE}
5499 @end table
5500
5501
5502
5503 @node GET_ENVIRONMENT_VARIABLE
5504 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
5505 @fnindex GET_ENVIRONMENT_VARIABLE
5506 @cindex environment variable
5507
5508 @table @asis
5509 @item @emph{Description}:
5510 Get the @var{VALUE} of the environmental variable @var{NAME}.
5511
5512 Note that @code{GET_ENVIRONMENT_VARIABLE} need not be thread-safe. It
5513 is the responsibility of the user to ensure that the environment is
5514 not being updated concurrently with a call to the
5515 @code{GET_ENVIRONMENT_VARIABLE} intrinsic.
5516
5517 @item @emph{Standard}:
5518 Fortran 2003 and later
5519
5520 @item @emph{Class}:
5521 Subroutine
5522
5523 @item @emph{Syntax}:
5524 @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
5525
5526 @item @emph{Arguments}:
5527 @multitable @columnfractions .15 .70
5528 @item @var{NAME}      @tab Shall be a scalar of type @code{CHARACTER}
5529 and of default kind.
5530 @item @var{VALUE}     @tab (Optional) Shall be a scalar of type @code{CHARACTER}
5531 and of default kind.
5532 @item @var{LENGTH}    @tab (Optional) Shall be a scalar of type @code{INTEGER}
5533 and of default kind.
5534 @item @var{STATUS}    @tab (Optional) Shall be a scalar of type @code{INTEGER}
5535 and of default kind.
5536 @item @var{TRIM_NAME} @tab (Optional) Shall be a scalar of type @code{LOGICAL}
5537 and of default kind.
5538 @end multitable
5539
5540 @item @emph{Return value}:
5541 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
5542 not large enough to hold the data, it is truncated. If @var{NAME}
5543 is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
5544 contains the length needed for storing the environment variable @var{NAME}
5545 or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
5546 but too short for the environment variable; it is 1 if the environment
5547 variable does not exist and 2 if the processor does not support environment
5548 variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
5549 present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
5550 are significant; otherwise they are not part of the environment variable
5551 name.
5552
5553 @item @emph{Example}:
5554 @smallexample
5555 PROGRAM test_getenv
5556   CHARACTER(len=255) :: homedir
5557   CALL get_environment_variable("HOME", homedir)
5558   WRITE (*,*) TRIM(homedir)
5559 END PROGRAM
5560 @end smallexample
5561 @end table
5562
5563
5564
5565 @node GETGID
5566 @section @code{GETGID} --- Group ID function
5567 @fnindex GETGID
5568 @cindex system, group ID
5569
5570 @table @asis
5571 @item @emph{Description}:
5572 Returns the numerical group ID of the current process.
5573
5574 @item @emph{Standard}:
5575 GNU extension
5576
5577 @item @emph{Class}:
5578 Function
5579
5580 @item @emph{Syntax}:
5581 @code{RESULT = GETGID()}
5582
5583 @item @emph{Return value}:
5584 The return value of @code{GETGID} is an @code{INTEGER} of the default
5585 kind.
5586
5587
5588 @item @emph{Example}:
5589 See @code{GETPID} for an example.
5590
5591 @item @emph{See also}:
5592 @ref{GETPID}, @ref{GETUID}
5593 @end table
5594
5595
5596
5597 @node GETLOG
5598 @section @code{GETLOG} --- Get login name
5599 @fnindex GETLOG
5600 @cindex system, login name
5601 @cindex login name
5602
5603 @table @asis
5604 @item @emph{Description}:
5605 Gets the username under which the program is running.
5606
5607 @item @emph{Standard}:
5608 GNU extension
5609
5610 @item @emph{Class}:
5611 Subroutine
5612
5613 @item @emph{Syntax}:
5614 @code{CALL GETLOG(C)}
5615
5616 @item @emph{Arguments}:
5617 @multitable @columnfractions .15 .70
5618 @item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
5619 @end multitable
5620
5621 @item @emph{Return value}:
5622 Stores the current user name in @var{LOGIN}.  (On systems where POSIX
5623 functions @code{geteuid} and @code{getpwuid} are not available, and 
5624 the @code{getlogin} function is not implemented either, this will
5625 return a blank string.)
5626
5627 @item @emph{Example}:
5628 @smallexample
5629 PROGRAM TEST_GETLOG
5630   CHARACTER(32) :: login
5631   CALL GETLOG(login)
5632   WRITE(*,*) login
5633 END PROGRAM
5634 @end smallexample
5635
5636 @item @emph{See also}:
5637 @ref{GETUID}
5638 @end table
5639
5640
5641
5642 @node GETPID
5643 @section @code{GETPID} --- Process ID function
5644 @fnindex GETPID
5645 @cindex system, process ID
5646 @cindex process ID
5647
5648 @table @asis
5649 @item @emph{Description}:
5650 Returns the numerical process identifier of the current process.
5651
5652 @item @emph{Standard}:
5653 GNU extension
5654
5655 @item @emph{Class}:
5656 Function
5657
5658 @item @emph{Syntax}:
5659 @code{RESULT = GETPID()}
5660
5661 @item @emph{Return value}:
5662 The return value of @code{GETPID} is an @code{INTEGER} of the default
5663 kind.
5664
5665
5666 @item @emph{Example}:
5667 @smallexample
5668 program info
5669   print *, "The current process ID is ", getpid()
5670   print *, "Your numerical user ID is ", getuid()
5671   print *, "Your numerical group ID is ", getgid()
5672 end program info
5673 @end smallexample
5674
5675 @item @emph{See also}:
5676 @ref{GETGID}, @ref{GETUID}
5677 @end table
5678
5679
5680
5681 @node GETUID
5682 @section @code{GETUID} --- User ID function
5683 @fnindex GETUID
5684 @cindex system, user ID
5685 @cindex user id
5686
5687 @table @asis
5688 @item @emph{Description}:
5689 Returns the numerical user ID of the current process.
5690
5691 @item @emph{Standard}:
5692 GNU extension
5693
5694 @item @emph{Class}:
5695 Function
5696
5697 @item @emph{Syntax}:
5698 @code{RESULT = GETUID()}
5699
5700 @item @emph{Return value}:
5701 The return value of @code{GETUID} is an @code{INTEGER} of the default
5702 kind.
5703
5704
5705 @item @emph{Example}:
5706 See @code{GETPID} for an example.
5707
5708 @item @emph{See also}:
5709 @ref{GETPID}, @ref{GETLOG}
5710 @end table
5711
5712
5713
5714 @node GMTIME
5715 @section @code{GMTIME} --- Convert time to GMT info
5716 @fnindex GMTIME
5717 @cindex time, conversion to GMT info
5718
5719 @table @asis
5720 @item @emph{Description}:
5721 Given a system time value @var{TIME} (as provided by the @code{TIME8}
5722 intrinsic), fills @var{VALUES} with values extracted from it appropriate
5723 to the UTC time zone (Universal Coordinated Time, also known in some
5724 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
5725
5726 @item @emph{Standard}:
5727 GNU extension
5728
5729 @item @emph{Class}:
5730 Subroutine
5731
5732 @item @emph{Syntax}:
5733 @code{CALL GMTIME(TIME, VALUES)}
5734
5735 @item @emph{Arguments}:
5736 @multitable @columnfractions .15 .70
5737 @item @var{TIME}   @tab An @code{INTEGER} scalar expression
5738 corresponding to a system time, with @code{INTENT(IN)}.
5739 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
5740 with @code{INTENT(OUT)}.
5741 @end multitable
5742
5743 @item @emph{Return value}:
5744 The elements of @var{VALUES} are assigned as follows:
5745 @enumerate
5746 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
5747 seconds
5748 @item Minutes after the hour, range 0--59
5749 @item Hours past midnight, range 0--23
5750 @item Day of month, range 0--31
5751 @item Number of months since January, range 0--12
5752 @item Years since 1900
5753 @item Number of days since Sunday, range 0--6
5754 @item Days since January 1
5755 @item Daylight savings indicator: positive if daylight savings is in
5756 effect, zero if not, and negative if the information is not available.
5757 @end enumerate
5758
5759 @item @emph{See also}:
5760 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
5761
5762 @end table
5763
5764
5765
5766 @node HOSTNM
5767 @section @code{HOSTNM} --- Get system host name
5768 @fnindex HOSTNM
5769 @cindex system, host name
5770
5771 @table @asis
5772 @item @emph{Description}:
5773 Retrieves the host name of the system on which the program is running.
5774
5775 This intrinsic is provided in both subroutine and function forms; however,
5776 only one form can be used in any given program unit.
5777
5778 @item @emph{Standard}:
5779 GNU extension
5780
5781 @item @emph{Class}:
5782 Subroutine, function
5783
5784 @item @emph{Syntax}:
5785 @multitable @columnfractions .80
5786 @item @code{CALL HOSTNM(C [, STATUS])}
5787 @item @code{STATUS = HOSTNM(NAME)}
5788 @end multitable
5789
5790 @item @emph{Arguments}:
5791 @multitable @columnfractions .15 .70
5792 @item @var{C}    @tab Shall of type @code{CHARACTER} and of default kind.
5793 @item @var{STATUS}  @tab (Optional) status flag of type @code{INTEGER}.
5794 Returns 0 on success, or a system specific error code otherwise.
5795 @end multitable
5796
5797 @item @emph{Return value}:
5798 In either syntax, @var{NAME} is set to the current hostname if it can
5799 be obtained, or to a blank string otherwise.
5800
5801 @end table
5802
5803
5804
5805 @node HUGE
5806 @section @code{HUGE} --- Largest number of a kind
5807 @fnindex HUGE
5808 @cindex limits, largest number
5809 @cindex model representation, largest number
5810
5811 @table @asis
5812 @item @emph{Description}:
5813 @code{HUGE(X)} returns the largest number that is not an infinity in
5814 the model of the type of @code{X}.
5815
5816 @item @emph{Standard}:
5817 Fortran 95 and later
5818
5819 @item @emph{Class}:
5820 Inquiry function
5821
5822 @item @emph{Syntax}:
5823 @code{RESULT = HUGE(X)}
5824
5825 @item @emph{Arguments}:
5826 @multitable @columnfractions .15 .70
5827 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
5828 @end multitable
5829
5830 @item @emph{Return value}:
5831 The return value is of the same type and kind as @var{X}
5832
5833 @item @emph{Example}:
5834 @smallexample
5835 program test_huge_tiny
5836   print *, huge(0), huge(0.0), huge(0.0d0)
5837   print *, tiny(0.0), tiny(0.0d0)
5838 end program test_huge_tiny
5839 @end smallexample
5840 @end table
5841
5842
5843
5844 @node HYPOT
5845 @section @code{HYPOT} --- Euclidean distance function
5846 @fnindex HYPOT
5847 @cindex Euclidean distance
5848
5849 @table @asis
5850 @item @emph{Description}:
5851 @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
5852 @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
5853
5854 @item @emph{Standard}:
5855 Fortran 2008 and later
5856
5857 @item @emph{Class}:
5858 Elemental function
5859
5860 @item @emph{Syntax}:
5861 @code{RESULT = HYPOT(X, Y)}
5862
5863 @item @emph{Arguments}:
5864 @multitable @columnfractions .15 .70
5865 @item @var{X} @tab The type shall be @code{REAL}.
5866 @item @var{Y} @tab The type and kind type parameter shall be the same as
5867 @var{X}.
5868 @end multitable
5869
5870 @item @emph{Return value}:
5871 The return value has the same type and kind type parameter as @var{X}.
5872
5873 @item @emph{Example}:
5874 @smallexample
5875 program test_hypot
5876   real(4) :: x = 1.e0_4, y = 0.5e0_4
5877   x = hypot(x,y)
5878 end program test_hypot
5879 @end smallexample
5880 @end table
5881
5882
5883
5884 @node IACHAR
5885 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence 
5886 @fnindex IACHAR
5887 @cindex @acronym{ASCII} collating sequence
5888 @cindex collating sequence, @acronym{ASCII}
5889 @cindex conversion, to integer
5890
5891 @table @asis
5892 @item @emph{Description}:
5893 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
5894 in the first character position of @code{C}.
5895
5896 @item @emph{Standard}:
5897 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
5898
5899 @item @emph{Class}:
5900 Elemental function
5901
5902 @item @emph{Syntax}:
5903 @code{RESULT = IACHAR(C [, KIND])}
5904
5905 @item @emph{Arguments}:
5906 @multitable @columnfractions .15 .70
5907 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5908 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5909 expression indicating the kind parameter of the result.
5910 @end multitable
5911
5912 @item @emph{Return value}:
5913 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5914 @var{KIND} is absent, the return value is of default integer kind.
5915
5916 @item @emph{Example}:
5917 @smallexample
5918 program test_iachar
5919   integer i
5920   i = iachar(' ')
5921 end program test_iachar
5922 @end smallexample
5923
5924 @item @emph{Note}:
5925 See @ref{ICHAR} for a discussion of converting between numerical values
5926 and formatted string representations.
5927
5928 @item @emph{See also}:
5929 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
5930
5931 @end table
5932
5933
5934
5935 @node IALL
5936 @section @code{IALL} --- Bitwise AND of array elements
5937 @fnindex IALL
5938 @cindex array, AND
5939 @cindex bits, AND of array elements
5940
5941 @table @asis
5942 @item @emph{Description}:
5943 Reduces with bitwise AND the elements of @var{ARRAY} along dimension @var{DIM}
5944 if the corresponding element in @var{MASK} is @code{TRUE}.
5945
5946 @item @emph{Standard}:
5947 Fortran 2008 and later
5948
5949 @item @emph{Class}:
5950 Transformational function
5951
5952 @item @emph{Syntax}:
5953 @multitable @columnfractions .80
5954 @item @code{RESULT = IALL(ARRAY[, MASK])}
5955 @item @code{RESULT = IALL(ARRAY, DIM[, MASK])}
5956 @end multitable
5957
5958 @item @emph{Arguments}:
5959 @multitable @columnfractions .15 .70
5960 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
5961 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
5962 @code{INTEGER} with a value in the range from 1 to n, where n 
5963 equals the rank of @var{ARRAY}.
5964 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
5965 and either be a scalar or an array of the same shape as @var{ARRAY}.
5966 @end multitable
5967
5968 @item @emph{Return value}:
5969 The result is of the same type as @var{ARRAY}.
5970
5971 If @var{DIM} is absent, a scalar with the bitwise ALL of all elements in
5972 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
5973 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
5974 dimension @var{DIM} dropped is returned.
5975
5976 @item @emph{Example}:
5977 @smallexample
5978 PROGRAM test_iall
5979   INTEGER(1) :: a(2)
5980
5981   a(1) = b'00100100'
5982   a(2) = b'01101010'
5983
5984   ! prints 00100000
5985   PRINT '(b8.8)', IALL(a)
5986 END PROGRAM
5987 @end smallexample
5988
5989 @item @emph{See also}:
5990 @ref{IANY}, @ref{IPARITY}, @ref{IAND}
5991 @end table
5992
5993
5994
5995 @node IAND
5996 @section @code{IAND} --- Bitwise logical and
5997 @fnindex IAND
5998 @cindex bitwise logical and
5999 @cindex logical and, bitwise
6000
6001 @table @asis
6002 @item @emph{Description}:
6003 Bitwise logical @code{AND}.
6004
6005 @item @emph{Standard}:
6006 Fortran 95 and later
6007
6008 @item @emph{Class}:
6009 Elemental function
6010
6011 @item @emph{Syntax}:
6012 @code{RESULT = IAND(I, J)}
6013
6014 @item @emph{Arguments}:
6015 @multitable @columnfractions .15 .70
6016 @item @var{I} @tab The type shall be @code{INTEGER}.
6017 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6018 kind as @var{I}.  (As a GNU extension, different kinds are also 
6019 permitted.)
6020 @end multitable
6021
6022 @item @emph{Return value}:
6023 The return type is @code{INTEGER}, of the same kind as the
6024 arguments.  (If the argument kinds differ, it is of the same kind as
6025 the larger argument.)
6026
6027 @item @emph{Example}:
6028 @smallexample
6029 PROGRAM test_iand
6030   INTEGER :: a, b
6031   DATA a / Z'F' /, b / Z'3' /
6032   WRITE (*,*) IAND(a, b)
6033 END PROGRAM
6034 @end smallexample
6035
6036 @item @emph{See also}:
6037 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6038
6039 @end table
6040
6041
6042
6043 @node IANY
6044 @section @code{IANY} --- Bitwise OR of array elements
6045 @fnindex IANY
6046 @cindex array, OR
6047 @cindex bits, OR of array elements
6048
6049 @table @asis
6050 @item @emph{Description}:
6051 Reduces with bitwise OR (inclusive or) the elements of @var{ARRAY} along
6052 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
6053
6054 @item @emph{Standard}:
6055 Fortran 2008 and later
6056
6057 @item @emph{Class}:
6058 Transformational function
6059
6060 @item @emph{Syntax}:
6061 @multitable @columnfractions .80
6062 @item @code{RESULT = IANY(ARRAY[, MASK])}
6063 @item @code{RESULT = IANY(ARRAY, DIM[, MASK])}
6064 @end multitable
6065
6066 @item @emph{Arguments}:
6067 @multitable @columnfractions .15 .70
6068 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
6069 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
6070 @code{INTEGER} with a value in the range from 1 to n, where n 
6071 equals the rank of @var{ARRAY}.
6072 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
6073 and either be a scalar or an array of the same shape as @var{ARRAY}.
6074 @end multitable
6075
6076 @item @emph{Return value}:
6077 The result is of the same type as @var{ARRAY}.
6078
6079 If @var{DIM} is absent, a scalar with the bitwise OR of all elements in
6080 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
6081 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
6082 dimension @var{DIM} dropped is returned.
6083
6084 @item @emph{Example}:
6085 @smallexample
6086 PROGRAM test_iany
6087   INTEGER(1) :: a(2)
6088
6089   a(1) = b'00100100'
6090   a(2) = b'01101010'
6091
6092   ! prints 01101110
6093   PRINT '(b8.8)', IANY(a)
6094 END PROGRAM
6095 @end smallexample
6096
6097 @item @emph{See also}:
6098 @ref{IPARITY}, @ref{IALL}, @ref{IOR}
6099 @end table
6100
6101
6102
6103 @node IARGC
6104 @section @code{IARGC} --- Get the number of command line arguments
6105 @fnindex IARGC
6106 @cindex command-line arguments
6107 @cindex command-line arguments, number of
6108 @cindex arguments, to program
6109
6110 @table @asis
6111 @item @emph{Description}:
6112 @code{IARGC} returns the number of arguments passed on the
6113 command line when the containing program was invoked.
6114
6115 This intrinsic routine is provided for backwards compatibility with 
6116 GNU Fortran 77.  In new code, programmers should consider the use of 
6117 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003 
6118 standard.
6119
6120 @item @emph{Standard}:
6121 GNU extension
6122
6123 @item @emph{Class}:
6124 Function
6125
6126 @item @emph{Syntax}:
6127 @code{RESULT = IARGC()}
6128
6129 @item @emph{Arguments}:
6130 None.
6131
6132 @item @emph{Return value}:
6133 The number of command line arguments, type @code{INTEGER(4)}.
6134
6135 @item @emph{Example}:
6136 See @ref{GETARG}
6137
6138 @item @emph{See also}:
6139 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
6140
6141 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
6142 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
6143 @end table
6144
6145
6146
6147 @node IBCLR
6148 @section @code{IBCLR} --- Clear bit
6149 @fnindex IBCLR
6150 @cindex bits, unset
6151 @cindex bits, clear
6152
6153 @table @asis
6154 @item @emph{Description}:
6155 @code{IBCLR} returns the value of @var{I} with the bit at position
6156 @var{POS} set to zero.
6157
6158 @item @emph{Standard}:
6159 Fortran 95 and later
6160
6161 @item @emph{Class}:
6162 Elemental function
6163
6164 @item @emph{Syntax}:
6165 @code{RESULT = IBCLR(I, POS)}
6166
6167 @item @emph{Arguments}:
6168 @multitable @columnfractions .15 .70
6169 @item @var{I} @tab The type shall be @code{INTEGER}.
6170 @item @var{POS} @tab The type shall be @code{INTEGER}.
6171 @end multitable
6172
6173 @item @emph{Return value}:
6174 The return value is of type @code{INTEGER} and of the same kind as
6175 @var{I}.
6176
6177 @item @emph{See also}:
6178 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
6179
6180 @end table
6181
6182
6183
6184 @node IBITS
6185 @section @code{IBITS} --- Bit extraction
6186 @fnindex IBITS
6187 @cindex bits, get
6188 @cindex bits, extract
6189
6190 @table @asis
6191 @item @emph{Description}:
6192 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
6193 starting from bit position @var{POS} and extending left for @var{LEN}
6194 bits.  The result is right-justified and the remaining bits are
6195 zeroed.  The value of @code{POS+LEN} must be less than or equal to the
6196 value @code{BIT_SIZE(I)}.
6197
6198 @item @emph{Standard}:
6199 Fortran 95 and later
6200
6201 @item @emph{Class}:
6202 Elemental function
6203
6204 @item @emph{Syntax}:
6205 @code{RESULT = IBITS(I, POS, LEN)}
6206
6207 @item @emph{Arguments}:
6208 @multitable @columnfractions .15 .70
6209 @item @var{I}   @tab The type shall be @code{INTEGER}.
6210 @item @var{POS} @tab The type shall be @code{INTEGER}.
6211 @item @var{LEN} @tab The type shall be @code{INTEGER}.
6212 @end multitable
6213
6214 @item @emph{Return value}:
6215 The return value is of type @code{INTEGER} and of the same kind as
6216 @var{I}.
6217
6218 @item @emph{See also}:
6219 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
6220 @end table
6221
6222
6223
6224 @node IBSET
6225 @section @code{IBSET} --- Set bit
6226 @fnindex IBSET
6227 @cindex bits, set
6228
6229 @table @asis
6230 @item @emph{Description}:
6231 @code{IBSET} returns the value of @var{I} with the bit at position
6232 @var{POS} set to one.
6233
6234 @item @emph{Standard}:
6235 Fortran 95 and later
6236
6237 @item @emph{Class}:
6238 Elemental function
6239
6240 @item @emph{Syntax}:
6241 @code{RESULT = IBSET(I, POS)}
6242
6243 @item @emph{Arguments}:
6244 @multitable @columnfractions .15 .70
6245 @item @var{I} @tab The type shall be @code{INTEGER}.
6246 @item @var{POS} @tab The type shall be @code{INTEGER}.
6247 @end multitable
6248
6249 @item @emph{Return value}:
6250 The return value is of type @code{INTEGER} and of the same kind as
6251 @var{I}.
6252
6253 @item @emph{See also}:
6254 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
6255
6256 @end table
6257
6258
6259
6260 @node ICHAR
6261 @section @code{ICHAR} --- Character-to-integer conversion function
6262 @fnindex ICHAR
6263 @cindex conversion, to integer
6264
6265 @table @asis
6266 @item @emph{Description}:
6267 @code{ICHAR(C)} returns the code for the character in the first character
6268 position of @code{C} in the system's native character set.
6269 The correspondence between characters and their codes is not necessarily
6270 the same across different GNU Fortran implementations.
6271
6272 @item @emph{Standard}:
6273 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6274
6275 @item @emph{Class}:
6276 Elemental function
6277
6278 @item @emph{Syntax}:
6279 @code{RESULT = ICHAR(C [, KIND])}
6280
6281 @item @emph{Arguments}:
6282 @multitable @columnfractions .15 .70
6283 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
6284 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6285 expression indicating the kind parameter of the result.
6286 @end multitable
6287
6288 @item @emph{Return value}:
6289 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6290 @var{KIND} is absent, the return value is of default integer kind.
6291
6292 @item @emph{Example}:
6293 @smallexample
6294 program test_ichar
6295   integer i
6296   i = ichar(' ')
6297 end program test_ichar
6298 @end smallexample
6299
6300 @item @emph{Specific names}:
6301 @multitable @columnfractions .20 .20 .20 .25
6302 @item Name             @tab Argument             @tab Return type       @tab Standard
6303 @item @code{ICHAR(C)}  @tab @code{CHARACTER C}   @tab @code{INTEGER(4)}    @tab Fortran 77 and later
6304 @end multitable
6305
6306 @item @emph{Note}:
6307 No intrinsic exists to convert between a numeric value and a formatted
6308 character string representation -- for instance, given the
6309 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
6310 @code{REAL} value with the value 154, or vice versa. Instead, this
6311 functionality is provided by internal-file I/O, as in the following
6312 example:
6313 @smallexample
6314 program read_val
6315   integer value
6316   character(len=10) string, string2
6317   string = '154'
6318   
6319   ! Convert a string to a numeric value
6320   read (string,'(I10)') value
6321   print *, value
6322   
6323   ! Convert a value to a formatted string
6324   write (string2,'(I10)') value
6325   print *, string2
6326 end program read_val
6327 @end smallexample
6328
6329 @item @emph{See also}:
6330 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
6331
6332 @end table
6333
6334
6335
6336 @node IDATE
6337 @section @code{IDATE} --- Get current local time subroutine (day/month/year) 
6338 @fnindex IDATE
6339 @cindex date, current
6340 @cindex current date
6341
6342 @table @asis
6343 @item @emph{Description}:
6344 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the  
6345 current local time. The day (in the range 1-31), month (in the range 1-12), 
6346 and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively. 
6347 The year has four significant digits.
6348
6349 @item @emph{Standard}:
6350 GNU extension
6351
6352 @item @emph{Class}:
6353 Subroutine
6354
6355 @item @emph{Syntax}:
6356 @code{CALL IDATE(VALUES)}
6357
6358 @item @emph{Arguments}:
6359 @multitable @columnfractions .15 .70
6360 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
6361 the kind shall be the default integer kind.
6362 @end multitable
6363
6364 @item @emph{Return value}:
6365 Does not return anything.
6366
6367 @item @emph{Example}:
6368 @smallexample
6369 program test_idate
6370   integer, dimension(3) :: tarray
6371   call idate(tarray)
6372   print *, tarray(1)
6373   print *, tarray(2)
6374   print *, tarray(3)
6375 end program test_idate
6376 @end smallexample
6377 @end table
6378
6379
6380
6381 @node IEOR
6382 @section @code{IEOR} --- Bitwise logical exclusive or
6383 @fnindex IEOR
6384 @cindex bitwise logical exclusive or
6385 @cindex logical exclusive or, bitwise
6386
6387 @table @asis
6388 @item @emph{Description}:
6389 @code{IEOR} returns the bitwise Boolean exclusive-OR of @var{I} and
6390 @var{J}.
6391
6392 @item @emph{Standard}:
6393 Fortran 95 and later
6394
6395 @item @emph{Class}:
6396 Elemental function
6397
6398 @item @emph{Syntax}:
6399 @code{RESULT = IEOR(I, J)}
6400
6401 @item @emph{Arguments}:
6402 @multitable @columnfractions .15 .70
6403 @item @var{I} @tab The type shall be @code{INTEGER}.
6404 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6405 kind as @var{I}.  (As a GNU extension, different kinds are also 
6406 permitted.)
6407 @end multitable
6408
6409 @item @emph{Return value}:
6410 The return type is @code{INTEGER}, of the same kind as the
6411 arguments.  (If the argument kinds differ, it is of the same kind as
6412 the larger argument.)
6413
6414 @item @emph{See also}:
6415 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6416 @end table
6417
6418
6419
6420 @node IERRNO
6421 @section @code{IERRNO} --- Get the last system error number
6422 @fnindex IERRNO
6423 @cindex system, error handling
6424
6425 @table @asis
6426 @item @emph{Description}:
6427 Returns the last system error number, as given by the C @code{errno}
6428 variable.
6429
6430 @item @emph{Standard}:
6431 GNU extension
6432
6433 @item @emph{Class}:
6434 Function
6435
6436 @item @emph{Syntax}:
6437 @code{RESULT = IERRNO()}
6438
6439 @item @emph{Arguments}:
6440 None.
6441
6442 @item @emph{Return value}:
6443 The return value is of type @code{INTEGER} and of the default integer
6444 kind.
6445
6446 @item @emph{See also}:
6447 @ref{PERROR}
6448 @end table
6449
6450
6451
6452 @node IMAGE_INDEX
6453 @section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index
6454 @fnindex IMAGE_INDEX
6455 @cindex coarray, @code{IMAGE_INDEX}
6456 @cindex images, cosubscript to image index conversion
6457
6458 @table @asis
6459 @item @emph{Description}:
6460 Returns the image index belonging to a cosubscript.
6461
6462 @item @emph{Standard}:
6463 Fortran 2008 and later
6464
6465 @item @emph{Class}:
6466 Inquiry function.
6467
6468 @item @emph{Syntax}:
6469 @code{RESULT = IMAGE_INDEX(COARRAY, SUB)}
6470
6471 @item @emph{Arguments}: None.
6472 @multitable @columnfractions .15 .70
6473 @item @var{COARRAY} @tab Coarray of any type.
6474 @item @var{SUB}     @tab default integer rank-1 array of a size equal to
6475 the corank of @var{COARRAY}.
6476 @end multitable
6477
6478
6479 @item @emph{Return value}:
6480 Scalar default integer with the value of the image index which corresponds
6481 to the cosubscripts. For invalid cosubscripts the result is zero.
6482
6483 @item @emph{Example}:
6484 @smallexample
6485 INTEGER :: array[2,-1:4,8,*]
6486 ! Writes  28 (or 0 if there are fewer than 28 images)
6487 WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1])
6488 @end smallexample
6489
6490 @item @emph{See also}:
6491 @ref{THIS_IMAGE}, @ref{NUM_IMAGES}
6492 @end table
6493
6494
6495
6496 @node INDEX intrinsic
6497 @section @code{INDEX} --- Position of a substring within a string
6498 @fnindex INDEX
6499 @cindex substring position
6500 @cindex string, find substring
6501
6502 @table @asis
6503 @item @emph{Description}:
6504 Returns the position of the start of the first occurrence of string
6505 @var{SUBSTRING} as a substring in @var{STRING}, counting from one.  If
6506 @var{SUBSTRING} is not present in @var{STRING}, zero is returned.  If 
6507 the @var{BACK} argument is present and true, the return value is the
6508 start of the last occurrence rather than the first.
6509
6510 @item @emph{Standard}:
6511 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
6512
6513 @item @emph{Class}:
6514 Elemental function
6515
6516 @item @emph{Syntax}:
6517 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
6518
6519 @item @emph{Arguments}:
6520 @multitable @columnfractions .15 .70
6521 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
6522 @code{INTENT(IN)}
6523 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
6524 @code{INTENT(IN)}
6525 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
6526 @code{INTENT(IN)}
6527 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6528 expression indicating the kind parameter of the result.
6529 @end multitable
6530
6531 @item @emph{Return value}:
6532 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6533 @var{KIND} is absent, the return value is of default integer kind.
6534
6535 @item @emph{Specific names}:
6536 @multitable @columnfractions .20 .20 .20 .25
6537 @item Name                            @tab Argument           @tab Return type       @tab Standard
6538 @item @code{INDEX(STRING, SUBSTRING)} @tab @code{CHARACTER}   @tab @code{INTEGER(4)} @tab Fortran 77 and later
6539 @end multitable
6540
6541 @item @emph{See also}:
6542 @ref{SCAN}, @ref{VERIFY}
6543 @end table
6544
6545
6546
6547 @node INT
6548 @section @code{INT} --- Convert to integer type
6549 @fnindex INT
6550 @fnindex IFIX
6551 @fnindex IDINT
6552 @cindex conversion, to integer
6553
6554 @table @asis
6555 @item @emph{Description}:
6556 Convert to integer type
6557
6558 @item @emph{Standard}:
6559 Fortran 77 and later
6560
6561 @item @emph{Class}:
6562 Elemental function
6563
6564 @item @emph{Syntax}:
6565 @code{RESULT = INT(A [, KIND))}
6566
6567 @item @emph{Arguments}:
6568 @multitable @columnfractions .15 .70
6569 @item @var{A}    @tab Shall be of type @code{INTEGER},
6570 @code{REAL}, or @code{COMPLEX}.
6571 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6572 expression indicating the kind parameter of the result.
6573 @end multitable
6574
6575 @item @emph{Return value}:
6576 These functions return a @code{INTEGER} variable or array under 
6577 the following rules: 
6578
6579 @table @asis
6580 @item (A)
6581 If @var{A} is of type @code{INTEGER}, @code{INT(A) = A} 
6582 @item (B)
6583 If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} equals @code{0}. 
6584 If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed 
6585 the range of @var{A} and whose sign is the same as the sign of @var{A}.
6586 @item (C)
6587 If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
6588 @end table
6589
6590 @item @emph{Example}:
6591 @smallexample
6592 program test_int
6593   integer :: i = 42
6594   complex :: z = (-3.7, 1.0)
6595   print *, int(i)
6596   print *, int(z), int(z,8)
6597 end program
6598 @end smallexample
6599
6600 @item @emph{Specific names}:
6601 @multitable @columnfractions .20 .20 .20 .25
6602 @item Name            @tab Argument          @tab Return type       @tab Standard
6603 @item @code{INT(A)}   @tab @code{REAL(4) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
6604 @item @code{IFIX(A)}  @tab @code{REAL(4) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
6605 @item @code{IDINT(A)} @tab @code{REAL(8) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
6606 @end multitable
6607
6608 @end table
6609
6610
6611 @node INT2
6612 @section @code{INT2} --- Convert to 16-bit integer type
6613 @fnindex INT2
6614 @fnindex SHORT
6615 @cindex conversion, to integer
6616
6617 @table @asis
6618 @item @emph{Description}:
6619 Convert to a @code{KIND=2} integer type. This is equivalent to the
6620 standard @code{INT} intrinsic with an optional argument of
6621 @code{KIND=2}, and is only included for backwards compatibility.
6622
6623 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
6624
6625 @item @emph{Standard}:
6626 GNU extension
6627
6628 @item @emph{Class}:
6629 Elemental function
6630
6631 @item @emph{Syntax}:
6632 @code{RESULT = INT2(A)}
6633
6634 @item @emph{Arguments}:
6635 @multitable @columnfractions .15 .70
6636 @item @var{A}    @tab Shall be of type @code{INTEGER},
6637 @code{REAL}, or @code{COMPLEX}.
6638 @end multitable
6639
6640 @item @emph{Return value}:
6641 The return value is a @code{INTEGER(2)} variable.
6642
6643 @item @emph{See also}:
6644 @ref{INT}, @ref{INT8}, @ref{LONG}
6645 @end table
6646
6647
6648
6649 @node INT8
6650 @section @code{INT8} --- Convert to 64-bit integer type
6651 @fnindex INT8
6652 @cindex conversion, to integer
6653
6654 @table @asis
6655 @item @emph{Description}:
6656 Convert to a @code{KIND=8} integer type. This is equivalent to the
6657 standard @code{INT} intrinsic with an optional argument of
6658 @code{KIND=8}, and is only included for backwards compatibility.
6659
6660 @item @emph{Standard}:
6661 GNU extension
6662
6663 @item @emph{Class}:
6664 Elemental function
6665
6666 @item @emph{Syntax}:
6667 @code{RESULT = INT8(A)}
6668
6669 @item @emph{Arguments}:
6670 @multitable @columnfractions .15 .70
6671 @item @var{A}    @tab Shall be of type @code{INTEGER},
6672 @code{REAL}, or @code{COMPLEX}.
6673 @end multitable
6674
6675 @item @emph{Return value}:
6676 The return value is a @code{INTEGER(8)} variable.
6677
6678 @item @emph{See also}:
6679 @ref{INT}, @ref{INT2}, @ref{LONG}
6680 @end table
6681
6682
6683
6684 @node IOR
6685 @section @code{IOR} --- Bitwise logical or
6686 @fnindex IOR
6687 @cindex bitwise logical or
6688 @cindex logical or, bitwise
6689
6690 @table @asis
6691 @item @emph{Description}:
6692 @code{IOR} returns the bitwise Boolean inclusive-OR of @var{I} and
6693 @var{J}.
6694
6695 @item @emph{Standard}:
6696 Fortran 95 and later
6697
6698 @item @emph{Class}:
6699 Elemental function
6700
6701 @item @emph{Syntax}:
6702 @code{RESULT = IOR(I, J)}
6703
6704 @item @emph{Arguments}:
6705 @multitable @columnfractions .15 .70
6706 @item @var{I} @tab The type shall be @code{INTEGER}.
6707 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6708 kind as @var{I}.  (As a GNU extension, different kinds are also 
6709 permitted.)
6710 @end multitable
6711
6712 @item @emph{Return value}:
6713 The return type is @code{INTEGER}, of the same kind as the
6714 arguments.  (If the argument kinds differ, it is of the same kind as
6715 the larger argument.)
6716
6717 @item @emph{See also}:
6718 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6719 @end table
6720
6721
6722
6723 @node IPARITY
6724 @section @code{IPARITY} --- Bitwise XOR of array elements
6725 @fnindex IPARITY
6726 @cindex array, parity
6727 @cindex array, XOR
6728 @cindex bits, XOR of array elements
6729
6730 @table @asis
6731 @item @emph{Description}:
6732 Reduces with bitwise XOR (exclusive or) the elements of @var{ARRAY} along
6733 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
6734
6735 @item @emph{Standard}:
6736 Fortran 2008 and later
6737
6738 @item @emph{Class}:
6739 Transformational function
6740
6741 @item @emph{Syntax}:
6742 @multitable @columnfractions .80
6743 @item @code{RESULT = IPARITY(ARRAY[, MASK])}
6744 @item @code{RESULT = IPARITY(ARRAY, DIM[, MASK])}
6745 @end multitable
6746
6747 @item @emph{Arguments}:
6748 @multitable @columnfractions .15 .70
6749 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
6750 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
6751 @code{INTEGER} with a value in the range from 1 to n, where n 
6752 equals the rank of @var{ARRAY}.
6753 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
6754 and either be a scalar or an array of the same shape as @var{ARRAY}.
6755 @end multitable
6756
6757 @item @emph{Return value}:
6758 The result is of the same type as @var{ARRAY}.
6759
6760 If @var{DIM} is absent, a scalar with the bitwise XOR of all elements in
6761 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
6762 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
6763 dimension @var{DIM} dropped is returned.
6764
6765 @item @emph{Example}:
6766 @smallexample
6767 PROGRAM test_iparity
6768   INTEGER(1) :: a(2)
6769
6770   a(1) = b'00100100'
6771   a(2) = b'01101010'
6772
6773   ! prints 01001110
6774   PRINT '(b8.8)', IPARITY(a)
6775 END PROGRAM
6776 @end smallexample
6777
6778 @item @emph{See also}:
6779 @ref{IANY}, @ref{IALL}, @ref{IEOR}, @ref{PARITY}
6780 @end table
6781
6782
6783
6784 @node IRAND
6785 @section @code{IRAND} --- Integer pseudo-random number
6786 @fnindex IRAND
6787 @cindex random number generation
6788
6789 @table @asis
6790 @item @emph{Description}:
6791 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
6792 distribution between 0 and a system-dependent limit (which is in most
6793 cases 2147483647). If @var{FLAG} is 0, the next number
6794 in the current sequence is returned; if @var{FLAG} is 1, the generator
6795 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
6796 it is used as a new seed with @code{SRAND}.
6797
6798 This intrinsic routine is provided for backwards compatibility with
6799 GNU Fortran 77. It implements a simple modulo generator as provided 
6800 by @command{g77}. For new code, one should consider the use of 
6801 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
6802
6803 @item @emph{Standard}:
6804 GNU extension
6805
6806 @item @emph{Class}:
6807 Function
6808
6809 @item @emph{Syntax}:
6810 @code{RESULT = IRAND(I)}
6811
6812 @item @emph{Arguments}:
6813 @multitable @columnfractions .15 .70
6814 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
6815 @end multitable
6816
6817 @item @emph{Return value}:
6818 The return value is of @code{INTEGER(kind=4)} type.
6819
6820 @item @emph{Example}:
6821 @smallexample
6822 program test_irand
6823   integer,parameter :: seed = 86456
6824   
6825   call srand(seed)
6826   print *, irand(), irand(), irand(), irand()
6827   print *, irand(seed), irand(), irand(), irand()
6828 end program test_irand
6829 @end smallexample
6830
6831 @end table
6832
6833
6834
6835 @node IS_IOSTAT_END
6836 @section @code{IS_IOSTAT_END} --- Test for end-of-file value
6837 @fnindex IS_IOSTAT_END
6838 @cindex @code{IOSTAT}, end of file
6839
6840 @table @asis
6841 @item @emph{Description}:
6842 @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
6843 status ``end of file''. The function is equivalent to comparing the variable
6844 with the @code{IOSTAT_END} parameter of the intrinsic module
6845 @code{ISO_FORTRAN_ENV}.
6846
6847 @item @emph{Standard}:
6848 Fortran 2003 and later
6849
6850 @item @emph{Class}:
6851 Elemental function
6852
6853 @item @emph{Syntax}:
6854 @code{RESULT = IS_IOSTAT_END(I)}
6855
6856 @item @emph{Arguments}:
6857 @multitable @columnfractions .15 .70
6858 @item @var{I} @tab Shall be of the type @code{INTEGER}.
6859 @end multitable
6860
6861 @item @emph{Return value}:
6862 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6863 @var{I} has the value which indicates an end of file condition for
6864 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
6865
6866 @item @emph{Example}:
6867 @smallexample
6868 PROGRAM iostat
6869   IMPLICIT NONE
6870   INTEGER :: stat, i
6871   OPEN(88, FILE='test.dat')
6872   READ(88, *, IOSTAT=stat) i
6873   IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
6874 END PROGRAM
6875 @end smallexample
6876 @end table
6877
6878
6879
6880 @node IS_IOSTAT_EOR
6881 @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
6882 @fnindex IS_IOSTAT_EOR
6883 @cindex @code{IOSTAT}, end of record
6884
6885 @table @asis
6886 @item @emph{Description}:
6887 @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
6888 status ``end of record''. The function is equivalent to comparing the
6889 variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
6890 @code{ISO_FORTRAN_ENV}.
6891
6892 @item @emph{Standard}:
6893 Fortran 2003 and later
6894
6895 @item @emph{Class}:
6896 Elemental function
6897
6898 @item @emph{Syntax}:
6899 @code{RESULT = IS_IOSTAT_EOR(I)}
6900
6901 @item @emph{Arguments}:
6902 @multitable @columnfractions .15 .70
6903 @item @var{I} @tab Shall be of the type @code{INTEGER}.
6904 @end multitable
6905
6906 @item @emph{Return value}:
6907 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6908 @var{I} has the value which indicates an end of file condition for
6909 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
6910
6911 @item @emph{Example}:
6912 @smallexample
6913 PROGRAM iostat
6914   IMPLICIT NONE
6915   INTEGER :: stat, i(50)
6916   OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
6917   READ(88, IOSTAT=stat) i
6918   IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
6919 END PROGRAM
6920 @end smallexample
6921 @end table
6922
6923
6924
6925 @node ISATTY
6926 @section @code{ISATTY} --- Whether a unit is a terminal device.
6927 @fnindex ISATTY
6928 @cindex system, terminal
6929
6930 @table @asis
6931 @item @emph{Description}:
6932 Determine whether a unit is connected to a terminal device.
6933
6934 @item @emph{Standard}:
6935 GNU extension
6936
6937 @item @emph{Class}:
6938 Function
6939
6940 @item @emph{Syntax}:
6941 @code{RESULT = ISATTY(UNIT)}
6942
6943 @item @emph{Arguments}:
6944 @multitable @columnfractions .15 .70
6945 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
6946 @end multitable
6947
6948 @item @emph{Return value}:
6949 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal 
6950 device, @code{.FALSE.} otherwise.
6951
6952 @item @emph{Example}:
6953 @smallexample
6954 PROGRAM test_isatty
6955   INTEGER(kind=1) :: unit
6956   DO unit = 1, 10
6957     write(*,*) isatty(unit=unit)
6958   END DO
6959 END PROGRAM
6960 @end smallexample
6961 @item @emph{See also}:
6962 @ref{TTYNAM}
6963 @end table
6964
6965
6966
6967 @node ISHFT
6968 @section @code{ISHFT} --- Shift bits
6969 @fnindex ISHFT
6970 @cindex bits, shift
6971
6972 @table @asis
6973 @item @emph{Description}:
6974 @code{ISHFT} returns a value corresponding to @var{I} with all of the
6975 bits shifted @var{SHIFT} places.  A value of @var{SHIFT} greater than
6976 zero corresponds to a left shift, a value of zero corresponds to no
6977 shift, and a value less than zero corresponds to a right shift.  If the
6978 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
6979 value is undefined.  Bits shifted out from the left end or right end are
6980 lost; zeros are shifted in from the opposite end.
6981
6982 @item @emph{Standard}:
6983 Fortran 95 and later
6984
6985 @item @emph{Class}:
6986 Elemental function
6987
6988 @item @emph{Syntax}:
6989 @code{RESULT = ISHFT(I, SHIFT)}
6990
6991 @item @emph{Arguments}:
6992 @multitable @columnfractions .15 .70
6993 @item @var{I} @tab The type shall be @code{INTEGER}.
6994 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
6995 @end multitable
6996
6997 @item @emph{Return value}:
6998 The return value is of type @code{INTEGER} and of the same kind as
6999 @var{I}.
7000
7001 @item @emph{See also}:
7002 @ref{ISHFTC}
7003 @end table
7004
7005
7006
7007 @node ISHFTC
7008 @section @code{ISHFTC} --- Shift bits circularly
7009 @fnindex ISHFTC
7010 @cindex bits, shift circular
7011
7012 @table @asis
7013 @item @emph{Description}:
7014 @code{ISHFTC} returns a value corresponding to @var{I} with the
7015 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
7016 is, bits shifted out one end are shifted into the opposite end.  A value
7017 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
7018 zero corresponds to no shift, and a value less than zero corresponds to
7019 a right shift.  The absolute value of @var{SHIFT} must be less than
7020 @var{SIZE}.  If the @var{SIZE} argument is omitted, it is taken to be
7021 equivalent to @code{BIT_SIZE(I)}.
7022
7023 @item @emph{Standard}:
7024 Fortran 95 and later
7025
7026 @item @emph{Class}:
7027 Elemental function
7028
7029 @item @emph{Syntax}:
7030 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
7031
7032 @item @emph{Arguments}:
7033 @multitable @columnfractions .15 .70
7034 @item @var{I} @tab The type shall be @code{INTEGER}.
7035 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
7036 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
7037 the value must be greater than zero and less than or equal to
7038 @code{BIT_SIZE(I)}.
7039 @end multitable
7040
7041 @item @emph{Return value}:
7042 The return value is of type @code{INTEGER} and of the same kind as
7043 @var{I}.
7044
7045 @item @emph{See also}:
7046 @ref{ISHFT}
7047 @end table
7048
7049
7050
7051 @node ISNAN
7052 @section @code{ISNAN} --- Test for a NaN
7053 @fnindex ISNAN
7054 @cindex IEEE, ISNAN
7055
7056 @table @asis
7057 @item @emph{Description}:
7058 @code{ISNAN} tests whether a floating-point value is an IEEE
7059 Not-a-Number (NaN).
7060 @item @emph{Standard}:
7061 GNU extension
7062
7063 @item @emph{Class}:
7064 Elemental function
7065
7066 @item @emph{Syntax}:
7067 @code{ISNAN(X)}
7068
7069 @item @emph{Arguments}:
7070 @multitable @columnfractions .15 .70
7071 @item @var{X} @tab Variable of the type @code{REAL}.
7072
7073 @end multitable
7074
7075 @item @emph{Return value}:
7076 Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
7077 if @var{X} is a NaN and @code{FALSE} otherwise.
7078
7079 @item @emph{Example}:
7080 @smallexample
7081 program test_nan
7082   implicit none
7083   real :: x
7084   x = -1.0
7085   x = sqrt(x)
7086   if (isnan(x)) stop '"x" is a NaN'
7087 end program test_nan
7088 @end smallexample
7089 @end table
7090
7091
7092
7093 @node ITIME
7094 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds) 
7095 @fnindex ITIME
7096 @cindex time, current
7097 @cindex current time
7098
7099 @table @asis
7100 @item @emph{Description}:
7101 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the  
7102 current local time. The hour (in the range 1-24), minute (in the range 1-60), 
7103 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES}, 
7104 respectively.
7105
7106 @item @emph{Standard}:
7107 GNU extension
7108
7109 @item @emph{Class}:
7110 Subroutine
7111
7112 @item @emph{Syntax}:
7113 @code{CALL ITIME(VALUES)}
7114
7115 @item @emph{Arguments}:
7116 @multitable @columnfractions .15 .70
7117 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
7118 and the kind shall be the default integer kind.
7119 @end multitable
7120
7121 @item @emph{Return value}:
7122 Does not return anything.
7123
7124
7125 @item @emph{Example}:
7126 @smallexample
7127 program test_itime
7128   integer, dimension(3) :: tarray
7129   call itime(tarray)
7130   print *, tarray(1)
7131   print *, tarray(2)
7132   print *, tarray(3)
7133 end program test_itime
7134 @end smallexample
7135 @end table
7136
7137
7138
7139 @node KILL
7140 @section @code{KILL} --- Send a signal to a process
7141 @fnindex KILL
7142
7143 @table @asis
7144 @item @emph{Description}:
7145 @item @emph{Standard}:
7146 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
7147 See @code{kill(2)}.
7148
7149 This intrinsic is provided in both subroutine and function forms; however,
7150 only one form can be used in any given program unit.
7151
7152 @item @emph{Class}:
7153 Subroutine, function
7154
7155 @item @emph{Syntax}:
7156 @multitable @columnfractions .80
7157 @item @code{CALL KILL(C, VALUE [, STATUS])}
7158 @item @code{STATUS = KILL(C, VALUE)}
7159 @end multitable
7160
7161 @item @emph{Arguments}:
7162 @multitable @columnfractions .15 .70
7163 @item @var{C} @tab Shall be a scalar @code{INTEGER}, with
7164 @code{INTENT(IN)}
7165 @item @var{VALUE} @tab Shall be a scalar @code{INTEGER}, with
7166 @code{INTENT(IN)}
7167 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
7168 @code{INTEGER(8)}. Returns 0 on success, or a system-specific error code
7169 otherwise.
7170 @end multitable
7171
7172 @item @emph{See also}:
7173 @ref{ABORT}, @ref{EXIT}
7174 @end table
7175
7176
7177
7178 @node KIND
7179 @section @code{KIND} --- Kind of an entity
7180 @fnindex KIND
7181 @cindex kind
7182
7183 @table @asis
7184 @item @emph{Description}:
7185 @code{KIND(X)} returns the kind value of the entity @var{X}.
7186
7187 @item @emph{Standard}:
7188 Fortran 95 and later
7189
7190 @item @emph{Class}:
7191 Inquiry function
7192
7193 @item @emph{Syntax}:
7194 @code{K = KIND(X)}
7195
7196 @item @emph{Arguments}:
7197 @multitable @columnfractions .15 .70
7198 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
7199 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
7200 @end multitable
7201
7202 @item @emph{Return value}:
7203 The return value is a scalar of type @code{INTEGER} and of the default
7204 integer kind.
7205
7206 @item @emph{Example}:
7207 @smallexample
7208 program test_kind
7209   integer,parameter :: kc = kind(' ')
7210   integer,parameter :: kl = kind(.true.)
7211
7212   print *, "The default character kind is ", kc
7213   print *, "The default logical kind is ", kl
7214 end program test_kind
7215 @end smallexample
7216
7217 @end table
7218
7219
7220
7221 @node LBOUND
7222 @section @code{LBOUND} --- Lower dimension bounds of an array
7223 @fnindex LBOUND
7224 @cindex array, lower bound
7225
7226 @table @asis
7227 @item @emph{Description}:
7228 Returns the lower bounds of an array, or a single lower bound
7229 along the @var{DIM} dimension.
7230 @item @emph{Standard}:
7231 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7232
7233 @item @emph{Class}:
7234 Inquiry function
7235
7236 @item @emph{Syntax}:
7237 @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
7238
7239 @item @emph{Arguments}:
7240 @multitable @columnfractions .15 .70
7241 @item @var{ARRAY} @tab Shall be an array, of any type.
7242 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
7243 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7244 expression indicating the kind parameter of the result.
7245 @end multitable
7246
7247 @item @emph{Return value}:
7248 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7249 @var{KIND} is absent, the return value is of default integer kind.
7250 If @var{DIM} is absent, the result is an array of the lower bounds of
7251 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
7252 corresponding to the lower bound of the array along that dimension.  If
7253 @var{ARRAY} is an expression rather than a whole array or array
7254 structure component, or if it has a zero extent along the relevant
7255 dimension, the lower bound is taken to be 1.
7256
7257 @item @emph{See also}:
7258 @ref{UBOUND}, @ref{LCOBOUND}
7259 @end table
7260
7261
7262
7263 @node LCOBOUND
7264 @section @code{LCOBOUND} --- Lower codimension bounds of an array
7265 @fnindex LCOBOUND
7266 @cindex coarray, lower bound
7267
7268 @table @asis
7269 @item @emph{Description}:
7270 Returns the lower bounds of a coarray, or a single lower cobound
7271 along the @var{DIM} codimension.
7272 @item @emph{Standard}:
7273 Fortran 2008 and later
7274
7275 @item @emph{Class}:
7276 Inquiry function
7277
7278 @item @emph{Syntax}:
7279 @code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])}
7280
7281 @item @emph{Arguments}:
7282 @multitable @columnfractions .15 .70
7283 @item @var{ARRAY} @tab Shall be an coarray, of any type.
7284 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
7285 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7286 expression indicating the kind parameter of the result.
7287 @end multitable
7288
7289 @item @emph{Return value}:
7290 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7291 @var{KIND} is absent, the return value is of default integer kind.
7292 If @var{DIM} is absent, the result is an array of the lower cobounds of
7293 @var{COARRAY}.  If @var{DIM} is present, the result is a scalar
7294 corresponding to the lower cobound of the array along that codimension.
7295
7296 @item @emph{See also}:
7297 @ref{UCOBOUND}, @ref{LBOUND}
7298 @end table
7299
7300
7301
7302 @node LEADZ
7303 @section @code{LEADZ} --- Number of leading zero bits of an integer
7304 @fnindex LEADZ
7305 @cindex zero bits
7306
7307 @table @asis
7308 @item @emph{Description}:
7309 @code{LEADZ} returns the number of leading zero bits of an integer.
7310
7311 @item @emph{Standard}:
7312 Fortran 2008 and later
7313
7314 @item @emph{Class}:
7315 Elemental function
7316
7317 @item @emph{Syntax}:
7318 @code{RESULT = LEADZ(I)}
7319
7320 @item @emph{Arguments}:
7321 @multitable @columnfractions .15 .70
7322 @item @var{I} @tab Shall be of type @code{INTEGER}.
7323 @end multitable
7324
7325 @item @emph{Return value}:
7326 The type of the return value is the default @code{INTEGER}.
7327 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
7328
7329 @item @emph{Example}:
7330 @smallexample
7331 PROGRAM test_leadz
7332   WRITE (*,*) BIT_SIZE(1)  ! prints 32
7333   WRITE (*,*) LEADZ(1)     ! prints 31
7334 END PROGRAM
7335 @end smallexample
7336
7337 @item @emph{See also}:
7338 @ref{BIT_SIZE}, @ref{TRAILZ}, @ref{POPCNT}, @ref{POPPAR}
7339 @end table
7340
7341
7342
7343 @node LEN
7344 @section @code{LEN} --- Length of a character entity
7345 @fnindex LEN
7346 @cindex string, length
7347
7348 @table @asis
7349 @item @emph{Description}:
7350 Returns the length of a character string.  If @var{STRING} is an array,
7351 the length of an element of @var{STRING} is returned.  Note that
7352 @var{STRING} need not be defined when this intrinsic is invoked, since
7353 only the length, not the content, of @var{STRING} is needed.
7354
7355 @item @emph{Standard}:
7356 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
7357
7358 @item @emph{Class}:
7359 Inquiry function
7360
7361 @item @emph{Syntax}:
7362 @code{L = LEN(STRING [, KIND])}
7363
7364 @item @emph{Arguments}:
7365 @multitable @columnfractions .15 .70
7366 @item @var{STRING} @tab Shall be a scalar or array of type
7367 @code{CHARACTER}, with @code{INTENT(IN)}
7368 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7369 expression indicating the kind parameter of the result.
7370 @end multitable
7371
7372 @item @emph{Return value}:
7373 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7374 @var{KIND} is absent, the return value is of default integer kind.
7375
7376
7377 @item @emph{Specific names}:
7378 @multitable @columnfractions .20 .20 .20 .25
7379 @item Name               @tab Argument          @tab Return type       @tab Standard
7380 @item @code{LEN(STRING)} @tab @code{CHARACTER}  @tab @code{INTEGER}    @tab Fortran 77 and later
7381 @end multitable
7382
7383
7384 @item @emph{See also}:
7385 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
7386 @end table
7387
7388
7389
7390 @node LEN_TRIM
7391 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
7392 @fnindex LEN_TRIM
7393 @cindex string, length, without trailing whitespace
7394
7395 @table @asis
7396 @item @emph{Description}:
7397 Returns the length of a character string, ignoring any trailing blanks.
7398
7399 @item @emph{Standard}:
7400 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7401
7402 @item @emph{Class}:
7403 Elemental function
7404
7405 @item @emph{Syntax}:
7406 @code{RESULT = LEN_TRIM(STRING [, KIND])}
7407
7408 @item @emph{Arguments}:
7409 @multitable @columnfractions .15 .70
7410 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
7411 with @code{INTENT(IN)}
7412 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7413 expression indicating the kind parameter of the result.
7414 @end multitable
7415
7416 @item @emph{Return value}:
7417 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7418 @var{KIND} is absent, the return value is of default integer kind.
7419
7420 @item @emph{See also}:
7421 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
7422 @end table
7423
7424
7425
7426 @node LGE
7427 @section @code{LGE} --- Lexical greater than or equal
7428 @fnindex LGE
7429 @cindex lexical comparison of strings
7430 @cindex string, comparison
7431
7432 @table @asis
7433 @item @emph{Description}:
7434 Determines whether one string is lexically greater than or equal to
7435 another string, where the two strings are interpreted as containing
7436 ASCII character codes.  If the String A and String B are not the same
7437 length, the shorter is compared as if spaces were appended to it to form
7438 a value that has the same length as the longer.
7439
7440 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7441 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7442 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7443 that the latter use the processor's character ordering (which is not
7444 ASCII on some targets), whereas the former always use the ASCII
7445 ordering.
7446
7447 @item @emph{Standard}:
7448 Fortran 77 and later
7449
7450 @item @emph{Class}:
7451 Elemental function
7452
7453 @item @emph{Syntax}:
7454 @code{RESULT = LGE(STRING_A, STRING_B)}
7455
7456 @item @emph{Arguments}:
7457 @multitable @columnfractions .15 .70
7458 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7459 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7460 @end multitable
7461
7462 @item @emph{Return value}:
7463 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
7464 otherwise, based on the ASCII ordering.
7465
7466 @item @emph{Specific names}:
7467 @multitable @columnfractions .20 .20 .20 .25
7468 @item Name                           @tab Argument          @tab Return type       @tab Standard
7469 @item @code{LGE(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
7470 @end multitable
7471
7472 @item @emph{See also}:
7473 @ref{LGT}, @ref{LLE}, @ref{LLT}
7474 @end table
7475
7476
7477
7478 @node LGT
7479 @section @code{LGT} --- Lexical greater than
7480 @fnindex LGT
7481 @cindex lexical comparison of strings
7482 @cindex string, comparison
7483
7484 @table @asis
7485 @item @emph{Description}:
7486 Determines whether one string is lexically greater than another string,
7487 where the two strings are interpreted as containing ASCII character
7488 codes.  If the String A and String B are not the same length, the
7489 shorter is compared as if spaces were appended to it to form a value
7490 that has the same length as the longer.
7491
7492 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7493 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7494 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7495 that the latter use the processor's character ordering (which is not
7496 ASCII on some targets), whereas the former always use the ASCII
7497 ordering.
7498
7499 @item @emph{Standard}:
7500 Fortran 77 and later
7501
7502 @item @emph{Class}:
7503 Elemental function
7504
7505 @item @emph{Syntax}:
7506 @code{RESULT = LGT(STRING_A, STRING_B)}
7507
7508 @item @emph{Arguments}:
7509 @multitable @columnfractions .15 .70
7510 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7511 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7512 @end multitable
7513
7514 @item @emph{Return value}:
7515 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
7516 otherwise, based on the ASCII ordering.
7517
7518 @item @emph{Specific names}:
7519 @multitable @columnfractions .20 .20 .20 .25
7520 @item Name                           @tab Argument          @tab Return type       @tab Standard
7521 @item @code{LGT(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
7522 @end multitable
7523
7524 @item @emph{See also}:
7525 @ref{LGE}, @ref{LLE}, @ref{LLT}
7526 @end table
7527
7528
7529
7530 @node LINK
7531 @section @code{LINK} --- Create a hard link
7532 @fnindex LINK
7533 @cindex file system, create link
7534 @cindex file system, hard link
7535
7536 @table @asis
7537 @item @emph{Description}:
7538 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
7539 character (@code{CHAR(0)}) can be used to mark the end of the names in
7540 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
7541 names are ignored.  If the @var{STATUS} argument is supplied, it
7542 contains 0 on success or a nonzero error code upon return; see
7543 @code{link(2)}.
7544
7545 This intrinsic is provided in both subroutine and function forms;
7546 however, only one form can be used in any given program unit.
7547
7548 @item @emph{Standard}:
7549 GNU extension
7550
7551 @item @emph{Class}:
7552 Subroutine, function
7553
7554 @item @emph{Syntax}:
7555 @multitable @columnfractions .80
7556 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
7557 @item @code{STATUS = LINK(PATH1, PATH2)}
7558 @end multitable
7559
7560 @item @emph{Arguments}:
7561 @multitable @columnfractions .15 .70
7562 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
7563 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
7564 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
7565 @end multitable
7566
7567 @item @emph{See also}:
7568 @ref{SYMLNK}, @ref{UNLINK}
7569 @end table
7570
7571
7572
7573 @node LLE
7574 @section @code{LLE} --- Lexical less than or equal
7575 @fnindex LLE
7576 @cindex lexical comparison of strings
7577 @cindex string, comparison
7578
7579 @table @asis
7580 @item @emph{Description}:
7581 Determines whether one string is lexically less than or equal to another
7582 string, where the two strings are interpreted as containing ASCII
7583 character codes.  If the String A and String B are not the same length,
7584 the shorter is compared as if spaces were appended to it to form a value
7585 that has the same length as the longer.
7586
7587 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7588 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7589 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7590 that the latter use the processor's character ordering (which is not
7591 ASCII on some targets), whereas the former always use the ASCII
7592 ordering.
7593
7594 @item @emph{Standard}:
7595 Fortran 77 and later
7596
7597 @item @emph{Class}:
7598 Elemental function
7599
7600 @item @emph{Syntax}:
7601 @code{RESULT = LLE(STRING_A, STRING_B)}
7602
7603 @item @emph{Arguments}:
7604 @multitable @columnfractions .15 .70
7605 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7606 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7607 @end multitable
7608
7609 @item @emph{Return value}:
7610 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
7611 otherwise, based on the ASCII ordering.
7612
7613 @item @emph{Specific names}:
7614 @multitable @columnfractions .20 .20 .20 .25
7615 @item Name                           @tab Argument          @tab Return type       @tab Standard
7616 @item @code{LLE(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
7617 @end multitable
7618
7619 @item @emph{See also}:
7620 @ref{LGE}, @ref{LGT}, @ref{LLT}
7621 @end table
7622
7623
7624
7625 @node LLT
7626 @section @code{LLT} --- Lexical less than
7627 @fnindex LLT
7628 @cindex lexical comparison of strings
7629 @cindex string, comparison
7630
7631 @table @asis
7632 @item @emph{Description}:
7633 Determines whether one string is lexically less than another string,
7634 where the two strings are interpreted as containing ASCII character
7635 codes.  If the String A and String B are not the same length, the
7636 shorter is compared as if spaces were appended to it to form a value
7637 that has the same length as the longer.
7638
7639 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7640 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7641 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7642 that the latter use the processor's character ordering (which is not
7643 ASCII on some targets), whereas the former always use the ASCII
7644 ordering.
7645
7646 @item @emph{Standard}:
7647 Fortran 77 and later
7648
7649 @item @emph{Class}:
7650 Elemental function
7651
7652 @item @emph{Syntax}:
7653 @code{RESULT = LLT(STRING_A, STRING_B)}
7654
7655 @item @emph{Arguments}:
7656 @multitable @columnfractions .15 .70
7657 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7658 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7659 @end multitable
7660
7661 @item @emph{Return value}:
7662 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
7663 otherwise, based on the ASCII ordering.
7664
7665 @item @emph{Specific names}:
7666 @multitable @columnfractions .20 .20 .20 .25
7667 @item Name                           @tab Argument          @tab Return type       @tab Standard
7668 @item @code{LLT(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
7669 @end multitable
7670
7671 @item @emph{See also}:
7672 @ref{LGE}, @ref{LGT}, @ref{LLE}
7673 @end table
7674
7675
7676
7677 @node LNBLNK
7678 @section @code{LNBLNK} --- Index of the last non-blank character in a string
7679 @fnindex LNBLNK
7680 @cindex string, find non-blank character
7681
7682 @table @asis
7683 @item @emph{Description}:
7684 Returns the length of a character string, ignoring any trailing blanks.
7685 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
7686 included for backwards compatibility.
7687
7688 @item @emph{Standard}:
7689 GNU extension
7690
7691 @item @emph{Class}:
7692 Elemental function
7693
7694 @item @emph{Syntax}:
7695 @code{RESULT = LNBLNK(STRING)}
7696
7697 @item @emph{Arguments}:
7698 @multitable @columnfractions .15 .70
7699 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
7700 with @code{INTENT(IN)}
7701 @end multitable
7702
7703 @item @emph{Return value}:
7704 The return value is of @code{INTEGER(kind=4)} type.
7705
7706 @item @emph{See also}:
7707 @ref{INDEX intrinsic}, @ref{LEN_TRIM}
7708 @end table
7709
7710
7711
7712 @node LOC
7713 @section @code{LOC} --- Returns the address of a variable
7714 @fnindex LOC
7715 @cindex location of a variable in memory
7716
7717 @table @asis
7718 @item @emph{Description}:
7719 @code{LOC(X)} returns the address of @var{X} as an integer.
7720
7721 @item @emph{Standard}:
7722 GNU extension
7723
7724 @item @emph{Class}:
7725 Inquiry function
7726
7727 @item @emph{Syntax}:
7728 @code{RESULT = LOC(X)}
7729
7730 @item @emph{Arguments}:
7731 @multitable @columnfractions .15 .70
7732 @item @var{X} @tab Variable of any type.
7733 @end multitable
7734
7735 @item @emph{Return value}:
7736 The return value is of type @code{INTEGER}, with a @code{KIND}
7737 corresponding to the size (in bytes) of a memory address on the target
7738 machine.
7739
7740 @item @emph{Example}:
7741 @smallexample
7742 program test_loc
7743   integer :: i
7744   real :: r
7745   i = loc(r)
7746   print *, i
7747 end program test_loc
7748 @end smallexample
7749 @end table
7750
7751
7752
7753 @node LOG
7754 @section @code{LOG} --- Logarithm function
7755 @fnindex LOG
7756 @fnindex ALOG
7757 @fnindex DLOG
7758 @fnindex CLOG
7759 @fnindex ZLOG
7760 @fnindex CDLOG
7761 @cindex exponential function, inverse
7762 @cindex logarithmic function
7763
7764 @table @asis
7765 @item @emph{Description}:
7766 @code{LOG(X)} computes the logarithm of @var{X}.
7767
7768 @item @emph{Standard}:
7769 Fortran 77 and later
7770
7771 @item @emph{Class}:
7772 Elemental function
7773
7774 @item @emph{Syntax}:
7775 @code{RESULT = LOG(X)}
7776
7777 @item @emph{Arguments}:
7778 @multitable @columnfractions .15 .70
7779 @item @var{X} @tab The type shall be @code{REAL} or
7780 @code{COMPLEX}.
7781 @end multitable
7782
7783 @item @emph{Return value}:
7784 The return value is of type @code{REAL} or @code{COMPLEX}.
7785 The kind type parameter is the same as @var{X}.
7786 If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range
7787 @math{-\pi \leq \omega \leq \pi}.
7788
7789 @item @emph{Example}:
7790 @smallexample
7791 program test_log
7792   real(8) :: x = 1.0_8
7793   complex :: z = (1.0, 2.0)
7794   x = log(x)
7795   z = log(z)
7796 end program test_log
7797 @end smallexample
7798
7799 @item @emph{Specific names}:
7800 @multitable @columnfractions .20 .20 .20 .25
7801 @item Name            @tab Argument          @tab Return type       @tab Standard
7802 @item @code{ALOG(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab f95, gnu
7803 @item @code{DLOG(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
7804 @item @code{CLOG(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
7805 @item @code{ZLOG(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
7806 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
7807 @end multitable
7808 @end table
7809
7810
7811
7812 @node LOG10
7813 @section @code{LOG10} --- Base 10 logarithm function
7814 @fnindex LOG10
7815 @fnindex ALOG10
7816 @fnindex DLOG10
7817 @cindex exponential function, inverse
7818 @cindex logarithmic function
7819
7820 @table @asis
7821 @item @emph{Description}:
7822 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
7823
7824 @item @emph{Standard}:
7825 Fortran 77 and later
7826
7827 @item @emph{Class}:
7828 Elemental function
7829
7830 @item @emph{Syntax}:
7831 @code{RESULT = LOG10(X)}
7832
7833 @item @emph{Arguments}:
7834 @multitable @columnfractions .15 .70
7835 @item @var{X} @tab The type shall be @code{REAL}.
7836 @end multitable
7837
7838 @item @emph{Return value}:
7839 The return value is of type @code{REAL} or @code{COMPLEX}.
7840 The kind type parameter is the same as @var{X}.
7841
7842 @item @emph{Example}:
7843 @smallexample
7844 program test_log10
7845   real(8) :: x = 10.0_8
7846   x = log10(x)
7847 end program test_log10
7848 @end smallexample
7849
7850 @item @emph{Specific names}:
7851 @multitable @columnfractions .20 .20 .20 .25
7852 @item Name            @tab Argument          @tab Return type       @tab Standard
7853 @item @code{ALOG10(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
7854 @item @code{DLOG10(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
7855 @end multitable
7856 @end table
7857
7858
7859
7860 @node LOG_GAMMA
7861 @section @code{LOG_GAMMA} --- Logarithm of the Gamma function
7862 @fnindex LOG_GAMMA
7863 @fnindex LGAMMA
7864 @fnindex ALGAMA
7865 @fnindex DLGAMA
7866 @cindex Gamma function, logarithm of
7867
7868 @table @asis
7869 @item @emph{Description}:
7870 @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
7871 of the Gamma (@math{\Gamma}) function.
7872
7873 @item @emph{Standard}:
7874 Fortran 2008 and later
7875
7876 @item @emph{Class}:
7877 Elemental function
7878
7879 @item @emph{Syntax}:
7880 @code{X = LOG_GAMMA(X)}
7881
7882 @item @emph{Arguments}:
7883 @multitable @columnfractions .15 .70
7884 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
7885 nor a negative integer.
7886 @end multitable
7887
7888 @item @emph{Return value}:
7889 The return value is of type @code{REAL} of the same kind as @var{X}.
7890
7891 @item @emph{Example}:
7892 @smallexample
7893 program test_log_gamma
7894   real :: x = 1.0
7895   x = lgamma(x) ! returns 0.0
7896 end program test_log_gamma
7897 @end smallexample
7898
7899 @item @emph{Specific names}:
7900 @multitable @columnfractions .20 .20 .20 .25
7901 @item Name             @tab Argument         @tab Return type       @tab Standard
7902 @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
7903 @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
7904 @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
7905 @end multitable
7906
7907 @item @emph{See also}:
7908 Gamma function: @ref{GAMMA}
7909
7910 @end table
7911
7912
7913
7914 @node LOGICAL
7915 @section @code{LOGICAL} --- Convert to logical type
7916 @fnindex LOGICAL
7917 @cindex conversion, to logical
7918
7919 @table @asis
7920 @item @emph{Description}:
7921 Converts one kind of @code{LOGICAL} variable to another.
7922
7923 @item @emph{Standard}:
7924 Fortran 95 and later
7925
7926 @item @emph{Class}:
7927 Elemental function
7928
7929 @item @emph{Syntax}:
7930 @code{RESULT = LOGICAL(L [, KIND])}
7931
7932 @item @emph{Arguments}:
7933 @multitable @columnfractions .15 .70
7934 @item @var{L}    @tab The type shall be @code{LOGICAL}.
7935 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7936 expression indicating the kind parameter of the result.
7937 @end multitable
7938
7939 @item @emph{Return value}:
7940 The return value is a @code{LOGICAL} value equal to @var{L}, with a
7941 kind corresponding to @var{KIND}, or of the default logical kind if
7942 @var{KIND} is not given.
7943
7944 @item @emph{See also}:
7945 @ref{INT}, @ref{REAL}, @ref{CMPLX}
7946 @end table
7947
7948
7949
7950 @node LONG
7951 @section @code{LONG} --- Convert to integer type
7952 @fnindex LONG
7953 @cindex conversion, to integer
7954
7955 @table @asis
7956 @item @emph{Description}:
7957 Convert to a @code{KIND=4} integer type, which is the same size as a C
7958 @code{long} integer.  This is equivalent to the standard @code{INT}
7959 intrinsic with an optional argument of @code{KIND=4}, and is only
7960 included for backwards compatibility.
7961
7962 @item @emph{Standard}:
7963 GNU extension
7964
7965 @item @emph{Class}:
7966 Elemental function
7967
7968 @item @emph{Syntax}:
7969 @code{RESULT = LONG(A)}
7970
7971 @item @emph{Arguments}:
7972 @multitable @columnfractions .15 .70
7973 @item @var{A}    @tab Shall be of type @code{INTEGER},
7974 @code{REAL}, or @code{COMPLEX}.
7975 @end multitable
7976
7977 @item @emph{Return value}:
7978 The return value is a @code{INTEGER(4)} variable.
7979
7980 @item @emph{See also}:
7981 @ref{INT}, @ref{INT2}, @ref{INT8}
7982 @end table
7983
7984
7985
7986 @node LSHIFT
7987 @section @code{LSHIFT} --- Left shift bits
7988 @fnindex LSHIFT
7989 @cindex bits, shift left
7990
7991 @table @asis
7992 @item @emph{Description}:
7993 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
7994 bits shifted left by @var{SHIFT} places.  If the absolute value of
7995 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined. 
7996 Bits shifted out from the left end are lost; zeros are shifted in from
7997 the opposite end.
7998
7999 This function has been superseded by the @code{ISHFT} intrinsic, which
8000 is standard in Fortran 95 and later, and the @code{SHIFTL} intrinsic,
8001 which is standard in Fortran 2008 and later.
8002
8003 @item @emph{Standard}:
8004 GNU extension
8005
8006 @item @emph{Class}:
8007 Elemental function
8008
8009 @item @emph{Syntax}:
8010 @code{RESULT = LSHIFT(I, SHIFT)}
8011
8012 @item @emph{Arguments}:
8013 @multitable @columnfractions .15 .70
8014 @item @var{I} @tab The type shall be @code{INTEGER}.
8015 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8016 @end multitable
8017
8018 @item @emph{Return value}:
8019 The return value is of type @code{INTEGER} and of the same kind as
8020 @var{I}.
8021
8022 @item @emph{See also}:
8023 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}, @ref{SHIFTA}, @ref{SHIFTL},
8024 @ref{SHIFTR}
8025
8026 @end table
8027
8028
8029
8030 @node LSTAT
8031 @section @code{LSTAT} --- Get file status
8032 @fnindex LSTAT
8033 @cindex file system, file status
8034
8035 @table @asis
8036 @item @emph{Description}:
8037 @code{LSTAT} is identical to @ref{STAT}, except that if path is a
8038 symbolic link, then the link itself is statted, not the file that it
8039 refers to.
8040
8041 The elements in @code{VALUES} are the same as described by @ref{STAT}.
8042
8043 This intrinsic is provided in both subroutine and function forms;
8044 however, only one form can be used in any given program unit.
8045
8046 @item @emph{Standard}:
8047 GNU extension
8048
8049 @item @emph{Class}:
8050 Subroutine, function
8051
8052 @item @emph{Syntax}:
8053 @multitable @columnfractions .80
8054 @item @code{CALL LSTAT(NAME, VALUES [, STATUS])}
8055 @item @code{STATUS = LSTAT(NAME, VALUES)}
8056 @end multitable
8057
8058 @item @emph{Arguments}:
8059 @multitable @columnfractions .15 .70
8060 @item @var{NAME}   @tab The type shall be @code{CHARACTER} of the default
8061 kind, a valid path within the file system.
8062 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
8063 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
8064 Returns 0 on success and a system specific error code otherwise.
8065 @end multitable
8066
8067 @item @emph{Example}:
8068 See @ref{STAT} for an example.
8069
8070 @item @emph{See also}:
8071 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
8072 @end table
8073
8074
8075
8076 @node LTIME
8077 @section @code{LTIME} --- Convert time to local time info
8078 @fnindex LTIME
8079 @cindex time, conversion to local time info
8080
8081 @table @asis
8082 @item @emph{Description}:
8083 Given a system time value @var{TIME} (as provided by the @code{TIME8}
8084 intrinsic), fills @var{VALUES} with values extracted from it appropriate
8085 to the local time zone using @code{localtime(3)}.
8086
8087 @item @emph{Standard}:
8088 GNU extension
8089
8090 @item @emph{Class}:
8091 Subroutine
8092
8093 @item @emph{Syntax}:
8094 @code{CALL LTIME(TIME, VALUES)}
8095
8096 @item @emph{Arguments}:
8097 @multitable @columnfractions .15 .70
8098 @item @var{TIME}  @tab An @code{INTEGER} scalar expression
8099 corresponding to a system time, with @code{INTENT(IN)}.
8100 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
8101 with @code{INTENT(OUT)}.
8102 @end multitable
8103
8104 @item @emph{Return value}:
8105 The elements of @var{VALUES} are assigned as follows:
8106 @enumerate
8107 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
8108 seconds
8109 @item Minutes after the hour, range 0--59
8110 @item Hours past midnight, range 0--23
8111 @item Day of month, range 0--31
8112 @item Number of months since January, range 0--12
8113 @item Years since 1900
8114 @item Number of days since Sunday, range 0--6
8115 @item Days since January 1
8116 @item Daylight savings indicator: positive if daylight savings is in
8117 effect, zero if not, and negative if the information is not available.
8118 @end enumerate
8119
8120 @item @emph{See also}:
8121 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
8122
8123 @end table
8124
8125
8126
8127 @node MALLOC
8128 @section @code{MALLOC} --- Allocate dynamic memory
8129 @fnindex MALLOC
8130 @cindex pointer, cray
8131
8132 @table @asis
8133 @item @emph{Description}:
8134 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
8135 returns the address of the allocated memory. The @code{MALLOC} intrinsic
8136 is an extension intended to be used with Cray pointers, and is provided
8137 in GNU Fortran to allow the user to compile legacy code. For new code
8138 using Fortran 95 pointers, the memory allocation intrinsic is
8139 @code{ALLOCATE}.
8140
8141 @item @emph{Standard}:
8142 GNU extension
8143
8144 @item @emph{Class}:
8145 Function
8146
8147 @item @emph{Syntax}:
8148 @code{PTR = MALLOC(SIZE)}
8149
8150 @item @emph{Arguments}:
8151 @multitable @columnfractions .15 .70
8152 @item @var{SIZE} @tab The type shall be @code{INTEGER}.
8153 @end multitable
8154
8155 @item @emph{Return value}:
8156 The return value is of type @code{INTEGER(K)}, with @var{K} such that
8157 variables of type @code{INTEGER(K)} have the same size as
8158 C pointers (@code{sizeof(void *)}).
8159
8160 @item @emph{Example}:
8161 The following example demonstrates the use of @code{MALLOC} and
8162 @code{FREE} with Cray pointers.
8163
8164 @smallexample
8165 program test_malloc
8166   implicit none
8167   integer i
8168   real*8 x(*), z
8169   pointer(ptr_x,x)
8170
8171   ptr_x = malloc(20*8)
8172   do i = 1, 20
8173     x(i) = sqrt(1.0d0 / i)
8174   end do
8175   z = 0
8176   do i = 1, 20
8177     z = z + x(i)
8178     print *, z
8179   end do
8180   call free(ptr_x)
8181 end program test_malloc
8182 @end smallexample
8183
8184 @item @emph{See also}:
8185 @ref{FREE}
8186 @end table
8187
8188
8189
8190 @node MASKL
8191 @section @code{MASKL} --- Left justified mask
8192 @fnindex MASKL
8193 @cindex mask, left justified
8194
8195 @table @asis
8196 @item @emph{Description}:
8197 @code{MASKL(I[, KIND])} has its leftmost @var{I} bits set to 1, and the
8198 remaining bits set to 0.
8199
8200 @item @emph{Standard}:
8201 Fortran 2008 and later
8202
8203 @item @emph{Class}:
8204 Elemental function
8205
8206 @item @emph{Syntax}:
8207 @code{RESULT = MASKL(I[, KIND])}
8208
8209 @item @emph{Arguments}:
8210 @multitable @columnfractions .15 .70
8211 @item @var{I} @tab Shall be of type @code{INTEGER}.
8212 @item @var{KIND} @tab Shall be a scalar constant expression of type
8213 @code{INTEGER}.
8214 @end multitable
8215
8216 @item @emph{Return value}:
8217 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
8218 specifies the kind value of the return type; otherwise, it is of the
8219 default integer kind.
8220
8221 @item @emph{See also}:
8222 @ref{MASKR}
8223 @end table
8224
8225
8226
8227 @node MASKR
8228 @section @code{MASKR} --- Right justified mask
8229 @fnindex MASKR
8230 @cindex mask, right justified
8231
8232 @table @asis
8233 @item @emph{Description}:
8234 @code{MASKL(I[, KIND])} has its rightmost @var{I} bits set to 1, and the
8235 remaining bits set to 0.
8236
8237 @item @emph{Standard}:
8238 Fortran 2008 and later
8239
8240 @item @emph{Class}:
8241 Elemental function
8242
8243 @item @emph{Syntax}:
8244 @code{RESULT = MASKR(I[, KIND])}
8245
8246 @item @emph{Arguments}:
8247 @multitable @columnfractions .15 .70
8248 @item @var{I} @tab Shall be of type @code{INTEGER}.
8249 @item @var{KIND} @tab Shall be a scalar constant expression of type
8250 @code{INTEGER}.
8251 @end multitable
8252
8253 @item @emph{Return value}:
8254 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
8255 specifies the kind value of the return type; otherwise, it is of the
8256 default integer kind.
8257
8258 @item @emph{See also}:
8259 @ref{MASKL}
8260 @end table
8261
8262
8263
8264 @node MATMUL
8265 @section @code{MATMUL} --- matrix multiplication
8266 @fnindex MATMUL
8267 @cindex matrix multiplication
8268 @cindex product, matrix
8269
8270 @table @asis
8271 @item @emph{Description}:
8272 Performs a matrix multiplication on numeric or logical arguments.
8273
8274 @item @emph{Standard}:
8275 Fortran 95 and later
8276
8277 @item @emph{Class}:
8278 Transformational function
8279
8280 @item @emph{Syntax}:
8281 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
8282
8283 @item @emph{Arguments}:
8284 @multitable @columnfractions .15 .70
8285 @item @var{MATRIX_A} @tab An array of @code{INTEGER},
8286 @code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of
8287 one or two.
8288 @item @var{MATRIX_B} @tab An array of @code{INTEGER},
8289 @code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric
8290 type; otherwise, an array of @code{LOGICAL} type. The rank shall be one
8291 or two, and the first (or only) dimension of @var{MATRIX_B} shall be
8292 equal to the last (or only) dimension of @var{MATRIX_A}.
8293 @end multitable
8294
8295 @item @emph{Return value}:
8296 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}.  The type and
8297 kind of the result follow the usual type and kind promotion rules, as
8298 for the @code{*} or @code{.AND.} operators.
8299
8300 @item @emph{See also}:
8301 @end table
8302
8303
8304
8305 @node MAX
8306 @section @code{MAX} --- Maximum value of an argument list
8307 @fnindex MAX
8308 @fnindex MAX0
8309 @fnindex AMAX0
8310 @fnindex MAX1
8311 @fnindex AMAX1
8312 @fnindex DMAX1
8313 @cindex maximum value
8314
8315 @table @asis
8316 @item @emph{Description}:
8317 Returns the argument with the largest (most positive) value.
8318
8319 @item @emph{Standard}:
8320 Fortran 77 and later
8321
8322 @item @emph{Class}:
8323 Elemental function
8324
8325 @item @emph{Syntax}:
8326 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
8327
8328 @item @emph{Arguments}:
8329 @multitable @columnfractions .15 .70
8330 @item @var{A1}          @tab The type shall be @code{INTEGER} or
8331 @code{REAL}.
8332 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
8333 as @var{A1}.  (As a GNU extension, arguments of different kinds are
8334 permitted.)
8335 @end multitable
8336
8337 @item @emph{Return value}:
8338 The return value corresponds to the maximum value among the arguments,
8339 and has the same type and kind as the first argument.
8340
8341 @item @emph{Specific names}:
8342 @multitable @columnfractions .20 .20 .20 .25
8343 @item Name             @tab Argument             @tab Return type         @tab Standard
8344 @item @code{MAX0(A1)}  @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)}   @tab Fortran 77 and later
8345 @item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
8346 @item @code{MAX1(A1)}  @tab @code{REAL A1}       @tab @code{INT(MAX(X))}  @tab Fortran 77 and later
8347 @item @code{AMAX1(A1)} @tab @code{REAL(4) A1}    @tab @code{REAL(4)}      @tab Fortran 77 and later
8348 @item @code{DMAX1(A1)} @tab @code{REAL(8) A1}    @tab @code{REAL(8)}      @tab Fortran 77 and later
8349 @end multitable
8350
8351 @item @emph{See also}:
8352 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
8353
8354 @end table
8355
8356
8357
8358 @node MAXEXPONENT
8359 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
8360 @fnindex MAXEXPONENT
8361 @cindex model representation, maximum exponent
8362
8363 @table @asis
8364 @item @emph{Description}:
8365 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
8366 type of @code{X}.
8367
8368 @item @emph{Standard}:
8369 Fortran 95 and later
8370
8371 @item @emph{Class}:
8372 Inquiry function
8373
8374 @item @emph{Syntax}:
8375 @code{RESULT = MAXEXPONENT(X)}
8376
8377 @item @emph{Arguments}:
8378 @multitable @columnfractions .15 .70
8379 @item @var{X} @tab Shall be of type @code{REAL}.
8380 @end multitable
8381
8382 @item @emph{Return value}:
8383 The return value is of type @code{INTEGER} and of the default integer
8384 kind.
8385
8386 @item @emph{Example}:
8387 @smallexample
8388 program exponents
8389   real(kind=4) :: x
8390   real(kind=8) :: y
8391
8392   print *, minexponent(x), maxexponent(x)
8393   print *, minexponent(y), maxexponent(y)
8394 end program exponents
8395 @end smallexample
8396 @end table
8397
8398
8399
8400 @node MAXLOC
8401 @section @code{MAXLOC} --- Location of the maximum value within an array
8402 @fnindex MAXLOC
8403 @cindex array, location of maximum element
8404
8405 @table @asis
8406 @item @emph{Description}:
8407 Determines the location of the element in the array with the maximum
8408 value, or, if the @var{DIM} argument is supplied, determines the
8409 locations of the maximum element along each row of the array in the
8410 @var{DIM} direction.  If @var{MASK} is present, only the elements for
8411 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
8412 element in the array has the maximum value, the location returned is
8413 that of the first such element in array element order.  If the array has
8414 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
8415 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
8416 and all of the elements of @var{MASK} along a given row are zero, the
8417 result value for that row is zero.
8418
8419 @item @emph{Standard}:
8420 Fortran 95 and later
8421
8422 @item @emph{Class}:
8423 Transformational function
8424
8425 @item @emph{Syntax}:
8426 @multitable @columnfractions .80
8427 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
8428 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
8429 @end multitable
8430
8431 @item @emph{Arguments}:
8432 @multitable @columnfractions .15 .70
8433 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8434 @code{REAL}.
8435 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8436 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8437 inclusive.  It may not be an optional dummy argument.
8438 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8439 and conformable with @var{ARRAY}.
8440 @end multitable
8441
8442 @item @emph{Return value}:
8443 If @var{DIM} is absent, the result is a rank-one array with a length
8444 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
8445 is an array with a rank one less than the rank of @var{ARRAY}, and a
8446 size corresponding to the size of @var{ARRAY} with the @var{DIM}
8447 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
8448 of one, the result is a scalar.  In all cases, the result is of default
8449 @code{INTEGER} type.
8450
8451 @item @emph{See also}:
8452 @ref{MAX}, @ref{MAXVAL}
8453
8454 @end table
8455
8456
8457
8458 @node MAXVAL
8459 @section @code{MAXVAL} --- Maximum value of an array
8460 @fnindex MAXVAL
8461 @cindex array, maximum value
8462 @cindex maximum value
8463
8464 @table @asis
8465 @item @emph{Description}:
8466 Determines the maximum value of the elements in an array value, or, if
8467 the @var{DIM} argument is supplied, determines the maximum value along
8468 each row of the array in the @var{DIM} direction.  If @var{MASK} is
8469 present, only the elements for which @var{MASK} is @code{.TRUE.} are
8470 considered.  If the array has zero size, or all of the elements of
8471 @var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)}
8472 if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character
8473 type.
8474
8475 @item @emph{Standard}:
8476 Fortran 95 and later
8477
8478 @item @emph{Class}:
8479 Transformational function
8480
8481 @item @emph{Syntax}:
8482 @multitable @columnfractions .80
8483 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
8484 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
8485 @end multitable
8486
8487 @item @emph{Arguments}:
8488 @multitable @columnfractions .15 .70
8489 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8490 @code{REAL}.
8491 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8492 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8493 inclusive.  It may not be an optional dummy argument.
8494 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8495 and conformable with @var{ARRAY}.
8496 @end multitable
8497
8498 @item @emph{Return value}:
8499 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
8500 is a scalar.  If @var{DIM} is present, the result is an array with a
8501 rank one less than the rank of @var{ARRAY}, and a size corresponding to
8502 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
8503 cases, the result is of the same type and kind as @var{ARRAY}.
8504
8505 @item @emph{See also}:
8506 @ref{MAX}, @ref{MAXLOC}
8507 @end table
8508
8509
8510
8511 @node MCLOCK
8512 @section @code{MCLOCK} --- Time function
8513 @fnindex MCLOCK
8514 @cindex time, clock ticks
8515 @cindex clock ticks
8516
8517 @table @asis
8518 @item @emph{Description}:
8519 Returns the number of clock ticks since the start of the process, based
8520 on the UNIX function @code{clock(3)}.
8521
8522 This intrinsic is not fully portable, such as to systems with 32-bit
8523 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
8524 the values returned by this intrinsic might be, or become, negative, or
8525 numerically less than previous values, during a single run of the
8526 compiled program.
8527
8528 @item @emph{Standard}:
8529 GNU extension
8530
8531 @item @emph{Class}:
8532 Function
8533
8534 @item @emph{Syntax}:
8535 @code{RESULT = MCLOCK()}
8536
8537 @item @emph{Return value}:
8538 The return value is a scalar of type @code{INTEGER(4)}, equal to the
8539 number of clock ticks since the start of the process, or @code{-1} if
8540 the system does not support @code{clock(3)}.
8541
8542 @item @emph{See also}:
8543 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
8544
8545 @end table
8546
8547
8548
8549 @node MCLOCK8
8550 @section @code{MCLOCK8} --- Time function (64-bit)
8551 @fnindex MCLOCK8
8552 @cindex time, clock ticks
8553 @cindex clock ticks
8554
8555 @table @asis
8556 @item @emph{Description}:
8557 Returns the number of clock ticks since the start of the process, based
8558 on the UNIX function @code{clock(3)}.
8559
8560 @emph{Warning:} this intrinsic does not increase the range of the timing
8561 values over that returned by @code{clock(3)}. On a system with a 32-bit
8562 @code{clock(3)}, @code{MCLOCK8} will return a 32-bit value, even though
8563 it is converted to a 64-bit @code{INTEGER(8)} value. That means
8564 overflows of the 32-bit value can still occur. Therefore, the values
8565 returned by this intrinsic might be or become negative or numerically
8566 less than previous values during a single run of the compiled program.
8567
8568 @item @emph{Standard}:
8569 GNU extension
8570
8571 @item @emph{Class}:
8572 Function
8573
8574 @item @emph{Syntax}:
8575 @code{RESULT = MCLOCK8()}
8576
8577 @item @emph{Return value}:
8578 The return value is a scalar of type @code{INTEGER(8)}, equal to the
8579 number of clock ticks since the start of the process, or @code{-1} if
8580 the system does not support @code{clock(3)}.
8581
8582 @item @emph{See also}:
8583 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
8584
8585 @end table
8586
8587
8588
8589 @node MERGE
8590 @section @code{MERGE} --- Merge variables
8591 @fnindex MERGE
8592 @cindex array, merge arrays
8593 @cindex array, combine arrays
8594
8595 @table @asis
8596 @item @emph{Description}:
8597 Select values from two arrays according to a logical mask.  The result
8598 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
8599 @var{FSOURCE} if it is @code{.FALSE.}.
8600
8601 @item @emph{Standard}:
8602 Fortran 95 and later
8603
8604 @item @emph{Class}:
8605 Elemental function
8606
8607 @item @emph{Syntax}:
8608 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
8609
8610 @item @emph{Arguments}:
8611 @multitable @columnfractions .15 .70
8612 @item @var{TSOURCE} @tab May be of any type.
8613 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
8614 as @var{TSOURCE}.
8615 @item @var{MASK}    @tab Shall be of type @code{LOGICAL}.
8616 @end multitable
8617
8618 @item @emph{Return value}:
8619 The result is of the same type and type parameters as @var{TSOURCE}.
8620
8621 @end table
8622
8623
8624
8625 @node MERGE_BITS
8626 @section @code{MERGE_BITS} --- Merge of bits under mask
8627 @fnindex MERGE_BITS
8628 @cindex bits, merge
8629
8630 @table @asis
8631 @item @emph{Description}:
8632 @code{MERGE_BITS(I, J, MASK)} merges the bits of @var{I} and @var{J}
8633 as determined by the mask.  The i-th bit of the result is equal to the 
8634 i-th bit of @var{I} if the i-th bit of @var{MASK} is 1; it is equal to
8635 the i-th bit of @var{J} otherwise.
8636
8637 @item @emph{Standard}:
8638 Fortran 2008 and later
8639
8640 @item @emph{Class}:
8641 Elemental function
8642
8643 @item @emph{Syntax}:
8644 @code{RESULT = MERGE_BITS(I, J, MASK)}
8645
8646 @item @emph{Arguments}:
8647 @multitable @columnfractions .15 .70
8648 @item @var{I}    @tab Shall be of type @code{INTEGER}.
8649 @item @var{J}    @tab Shall be of type @code{INTEGER} and of the same
8650 kind as @var{I}.
8651 @item @var{MASK} @tab Shall be of type @code{INTEGER} and of the same
8652 kind as @var{I}.
8653 @end multitable
8654
8655 @item @emph{Return value}:
8656 The result is of the same type and kind as @var{I}.
8657
8658 @end table
8659
8660
8661
8662 @node MIN
8663 @section @code{MIN} --- Minimum value of an argument list
8664 @fnindex MIN
8665 @fnindex MIN0
8666 @fnindex AMIN0
8667 @fnindex MIN1
8668 @fnindex AMIN1
8669 @fnindex DMIN1
8670 @cindex minimum value
8671
8672 @table @asis
8673 @item @emph{Description}:
8674 Returns the argument with the smallest (most negative) value.
8675
8676 @item @emph{Standard}:
8677 Fortran 77 and later
8678
8679 @item @emph{Class}:
8680 Elemental function
8681
8682 @item @emph{Syntax}:
8683 @code{RESULT = MIN(A1, A2 [, A3, ...])}
8684
8685 @item @emph{Arguments}:
8686 @multitable @columnfractions .15 .70
8687 @item @var{A1}          @tab The type shall be @code{INTEGER} or
8688 @code{REAL}.
8689 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
8690 as @var{A1}.  (As a GNU extension, arguments of different kinds are
8691 permitted.)
8692 @end multitable
8693
8694 @item @emph{Return value}:
8695 The return value corresponds to the maximum value among the arguments,
8696 and has the same type and kind as the first argument.
8697
8698 @item @emph{Specific names}:
8699 @multitable @columnfractions .20 .20 .20 .25
8700 @item Name              @tab Argument             @tab Return type        @tab Standard
8701 @item @code{MIN0(A1)}   @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)}  @tab Fortran 77 and later
8702 @item @code{AMIN0(A1)}  @tab @code{INTEGER(4) A1} @tab @code{REAL(4)}     @tab Fortran 77 and later
8703 @item @code{MIN1(A1)}   @tab @code{REAL A1}       @tab @code{INTEGER(4)}  @tab Fortran 77 and later
8704 @item @code{AMIN1(A1)}  @tab @code{REAL(4) A1}    @tab @code{REAL(4)}     @tab Fortran 77 and later
8705 @item @code{DMIN1(A1)}  @tab @code{REAL(8) A1}    @tab @code{REAL(8)}     @tab Fortran 77 and later
8706 @end multitable
8707
8708 @item @emph{See also}:
8709 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
8710 @end table
8711
8712
8713
8714 @node MINEXPONENT
8715 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
8716 @fnindex MINEXPONENT
8717 @cindex model representation, minimum exponent
8718
8719 @table @asis
8720 @item @emph{Description}:
8721 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
8722 type of @code{X}.
8723
8724 @item @emph{Standard}:
8725 Fortran 95 and later
8726
8727 @item @emph{Class}:
8728 Inquiry function
8729
8730 @item @emph{Syntax}:
8731 @code{RESULT = MINEXPONENT(X)}
8732
8733 @item @emph{Arguments}:
8734 @multitable @columnfractions .15 .70
8735 @item @var{X} @tab Shall be of type @code{REAL}.
8736 @end multitable
8737
8738 @item @emph{Return value}:
8739 The return value is of type @code{INTEGER} and of the default integer
8740 kind.
8741
8742 @item @emph{Example}:
8743 See @code{MAXEXPONENT} for an example.
8744 @end table
8745
8746
8747
8748 @node MINLOC
8749 @section @code{MINLOC} --- Location of the minimum value within an array
8750 @fnindex MINLOC
8751 @cindex array, location of minimum element
8752
8753 @table @asis
8754 @item @emph{Description}:
8755 Determines the location of the element in the array with the minimum
8756 value, or, if the @var{DIM} argument is supplied, determines the
8757 locations of the minimum element along each row of the array in the
8758 @var{DIM} direction.  If @var{MASK} is present, only the elements for
8759 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
8760 element in the array has the minimum value, the location returned is
8761 that of the first such element in array element order.  If the array has
8762 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
8763 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
8764 and all of the elements of @var{MASK} along a given row are zero, the
8765 result value for that row is zero.
8766
8767 @item @emph{Standard}:
8768 Fortran 95 and later
8769
8770 @item @emph{Class}:
8771 Transformational function
8772
8773 @item @emph{Syntax}:
8774 @multitable @columnfractions .80
8775 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
8776 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
8777 @end multitable
8778
8779 @item @emph{Arguments}:
8780 @multitable @columnfractions .15 .70
8781 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8782 @code{REAL}.
8783 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8784 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8785 inclusive.  It may not be an optional dummy argument.
8786 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8787 and conformable with @var{ARRAY}.
8788 @end multitable
8789
8790 @item @emph{Return value}:
8791 If @var{DIM} is absent, the result is a rank-one array with a length
8792 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
8793 is an array with a rank one less than the rank of @var{ARRAY}, and a
8794 size corresponding to the size of @var{ARRAY} with the @var{DIM}
8795 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
8796 of one, the result is a scalar.  In all cases, the result is of default
8797 @code{INTEGER} type.
8798
8799 @item @emph{See also}:
8800 @ref{MIN}, @ref{MINVAL}
8801
8802 @end table
8803
8804
8805
8806 @node MINVAL
8807 @section @code{MINVAL} --- Minimum value of an array
8808 @fnindex MINVAL
8809 @cindex array, minimum value
8810 @cindex minimum value
8811
8812 @table @asis
8813 @item @emph{Description}:
8814 Determines the minimum value of the elements in an array value, or, if
8815 the @var{DIM} argument is supplied, determines the minimum value along
8816 each row of the array in the @var{DIM} direction.  If @var{MASK} is
8817 present, only the elements for which @var{MASK} is @code{.TRUE.} are
8818 considered.  If the array has zero size, or all of the elements of
8819 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
8820 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
8821 @var{ARRAY} is of character type.
8822
8823 @item @emph{Standard}:
8824 Fortran 95 and later
8825
8826 @item @emph{Class}:
8827 Transformational function
8828
8829 @item @emph{Syntax}:
8830 @multitable @columnfractions .80
8831 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
8832 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
8833 @end multitable
8834
8835 @item @emph{Arguments}:
8836 @multitable @columnfractions .15 .70
8837 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8838 @code{REAL}.
8839 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8840 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8841 inclusive.  It may not be an optional dummy argument.
8842 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8843 and conformable with @var{ARRAY}.
8844 @end multitable
8845
8846 @item @emph{Return value}:
8847 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
8848 is a scalar.  If @var{DIM} is present, the result is an array with a
8849 rank one less than the rank of @var{ARRAY}, and a size corresponding to
8850 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
8851 cases, the result is of the same type and kind as @var{ARRAY}.
8852
8853 @item @emph{See also}:
8854 @ref{MIN}, @ref{MINLOC}
8855
8856 @end table
8857
8858
8859
8860 @node MOD
8861 @section @code{MOD} --- Remainder function
8862 @fnindex MOD
8863 @fnindex AMOD
8864 @fnindex DMOD
8865 @cindex remainder
8866 @cindex division, remainder
8867
8868 @table @asis
8869 @item @emph{Description}:
8870 @code{MOD(A,P)} computes the remainder of the division of A by P@. It is
8871 calculated as @code{A - (INT(A/P) * P)}.
8872
8873 @item @emph{Standard}:
8874 Fortran 77 and later
8875
8876 @item @emph{Class}:
8877 Elemental function
8878
8879 @item @emph{Syntax}:
8880 @code{RESULT = MOD(A, P)}
8881
8882 @item @emph{Arguments}:
8883 @multitable @columnfractions .15 .70
8884 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
8885 @item @var{P} @tab Shall be a scalar of the same type as @var{A} and not
8886 equal to zero
8887 @end multitable
8888
8889 @item @emph{Return value}:
8890 The kind of the return value is the result of cross-promoting
8891 the kinds of the arguments.
8892
8893 @item @emph{Example}:
8894 @smallexample
8895 program test_mod
8896   print *, mod(17,3)
8897   print *, mod(17.5,5.5)
8898   print *, mod(17.5d0,5.5)
8899   print *, mod(17.5,5.5d0)
8900
8901   print *, mod(-17,3)
8902   print *, mod(-17.5,5.5)
8903   print *, mod(-17.5d0,5.5)
8904   print *, mod(-17.5,5.5d0)
8905
8906   print *, mod(17,-3)
8907   print *, mod(17.5,-5.5)
8908   print *, mod(17.5d0,-5.5)
8909   print *, mod(17.5,-5.5d0)
8910 end program test_mod
8911 @end smallexample
8912
8913 @item @emph{Specific names}:
8914 @multitable @columnfractions .20 .20 .20 .25
8915 @item Name             @tab Arguments          @tab Return type    @tab Standard
8916 @item @code{MOD(A,P)}  @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 95 and later
8917 @item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 95 and later
8918 @item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 95 and later
8919 @end multitable
8920 @end table
8921
8922
8923
8924 @node MODULO
8925 @section @code{MODULO} --- Modulo function
8926 @fnindex MODULO
8927 @cindex modulo
8928 @cindex division, modulo
8929
8930 @table @asis
8931 @item @emph{Description}:
8932 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
8933
8934 @item @emph{Standard}:
8935 Fortran 95 and later
8936
8937 @item @emph{Class}:
8938 Elemental function
8939
8940 @item @emph{Syntax}:
8941 @code{RESULT = MODULO(A, P)}
8942
8943 @item @emph{Arguments}:
8944 @multitable @columnfractions .15 .70
8945 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
8946 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
8947 @end multitable
8948
8949 @item @emph{Return value}:
8950 The type and kind of the result are those of the arguments.
8951 @table @asis
8952 @item If @var{A} and @var{P} are of type @code{INTEGER}:
8953 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
8954 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
8955 (exclusive).
8956 @item If @var{A} and @var{P} are of type @code{REAL}:
8957 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
8958 @end table
8959 In all cases, if @var{P} is zero the result is processor-dependent.
8960
8961 @item @emph{Example}:
8962 @smallexample
8963 program test_modulo
8964   print *, modulo(17,3)
8965   print *, modulo(17.5,5.5)
8966
8967   print *, modulo(-17,3)
8968   print *, modulo(-17.5,5.5)
8969
8970   print *, modulo(17,-3)
8971   print *, modulo(17.5,-5.5)
8972 end program
8973 @end smallexample
8974
8975 @end table
8976
8977
8978
8979 @node MOVE_ALLOC
8980 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
8981 @fnindex MOVE_ALLOC
8982 @cindex moving allocation
8983 @cindex allocation, moving
8984
8985 @table @asis
8986 @item @emph{Description}:
8987 @code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
8988 @var{TO}.  @var{FROM} will become deallocated in the process.
8989
8990 @item @emph{Standard}:
8991 Fortran 2003 and later
8992
8993 @item @emph{Class}:
8994 Pure subroutine
8995
8996 @item @emph{Syntax}:
8997 @code{CALL MOVE_ALLOC(FROM, TO)}
8998
8999 @item @emph{Arguments}:
9000 @multitable @columnfractions .15 .70
9001 @item @var{FROM}  @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
9002 of any type and kind.
9003 @item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
9004 of the same type, kind and rank as @var{FROM}.
9005 @end multitable
9006
9007 @item @emph{Return value}:
9008 None
9009
9010 @item @emph{Example}:
9011 @smallexample
9012 program test_move_alloc
9013     integer, allocatable :: a(:), b(:)
9014
9015     allocate(a(3))
9016     a = [ 1, 2, 3 ]
9017     call move_alloc(a, b)
9018     print *, allocated(a), allocated(b)
9019     print *, b
9020 end program test_move_alloc
9021 @end smallexample
9022 @end table
9023
9024
9025
9026 @node MVBITS
9027 @section @code{MVBITS} --- Move bits from one integer to another
9028 @fnindex MVBITS
9029 @cindex bits, move
9030
9031 @table @asis
9032 @item @emph{Description}:
9033 Moves @var{LEN} bits from positions @var{FROMPOS} through
9034 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
9035 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
9036 affected by the movement of bits is unchanged. The values of
9037 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
9038 @code{BIT_SIZE(FROM)}.
9039
9040 @item @emph{Standard}:
9041 Fortran 95 and later
9042
9043 @item @emph{Class}:
9044 Elemental subroutine
9045
9046 @item @emph{Syntax}:
9047 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
9048
9049 @item @emph{Arguments}:
9050 @multitable @columnfractions .15 .70
9051 @item @var{FROM}    @tab The type shall be @code{INTEGER}.
9052 @item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
9053 @item @var{LEN}     @tab The type shall be @code{INTEGER}.
9054 @item @var{TO}      @tab The type shall be @code{INTEGER}, of the
9055 same kind as @var{FROM}.
9056 @item @var{TOPOS}   @tab The type shall be @code{INTEGER}.
9057 @end multitable
9058
9059 @item @emph{See also}:
9060 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
9061 @end table
9062
9063
9064
9065 @node NEAREST
9066 @section @code{NEAREST} --- Nearest representable number
9067 @fnindex NEAREST
9068 @cindex real number, nearest different
9069 @cindex floating point, nearest different
9070
9071 @table @asis
9072 @item @emph{Description}:
9073 @code{NEAREST(X, S)} returns the processor-representable number nearest
9074 to @code{X} in the direction indicated by the sign of @code{S}.
9075
9076 @item @emph{Standard}:
9077 Fortran 95 and later
9078
9079 @item @emph{Class}:
9080 Elemental function
9081
9082 @item @emph{Syntax}:
9083 @code{RESULT = NEAREST(X, S)}
9084
9085 @item @emph{Arguments}:
9086 @multitable @columnfractions .15 .70
9087 @item @var{X} @tab Shall be of type @code{REAL}.
9088 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
9089 not equal to zero.
9090 @end multitable
9091
9092 @item @emph{Return value}:
9093 The return value is of the same type as @code{X}. If @code{S} is
9094 positive, @code{NEAREST} returns the processor-representable number
9095 greater than @code{X} and nearest to it. If @code{S} is negative,
9096 @code{NEAREST} returns the processor-representable number smaller than
9097 @code{X} and nearest to it.
9098
9099 @item @emph{Example}:
9100 @smallexample
9101 program test_nearest
9102   real :: x, y
9103   x = nearest(42.0, 1.0)
9104   y = nearest(42.0, -1.0)
9105   write (*,"(3(G20.15))") x, y, x - y
9106 end program test_nearest
9107 @end smallexample
9108 @end table
9109
9110
9111
9112 @node NEW_LINE
9113 @section @code{NEW_LINE} --- New line character
9114 @fnindex NEW_LINE
9115 @cindex newline
9116 @cindex output, newline
9117
9118 @table @asis
9119 @item @emph{Description}:
9120 @code{NEW_LINE(C)} returns the new-line character.
9121
9122 @item @emph{Standard}:
9123 Fortran 2003 and later
9124
9125 @item @emph{Class}:
9126 Inquiry function
9127
9128 @item @emph{Syntax}:
9129 @code{RESULT = NEW_LINE(C)}
9130
9131 @item @emph{Arguments}:
9132 @multitable @columnfractions .15 .70
9133 @item @var{C}    @tab The argument shall be a scalar or array of the
9134 type @code{CHARACTER}.
9135 @end multitable
9136
9137 @item @emph{Return value}:
9138 Returns a @var{CHARACTER} scalar of length one with the new-line character of
9139 the same kind as parameter @var{C}.
9140
9141 @item @emph{Example}:
9142 @smallexample
9143 program newline
9144   implicit none
9145   write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
9146 end program newline
9147 @end smallexample
9148 @end table
9149
9150
9151
9152 @node NINT
9153 @section @code{NINT} --- Nearest whole number
9154 @fnindex NINT
9155 @fnindex IDNINT
9156 @cindex rounding, nearest whole number
9157
9158 @table @asis
9159 @item @emph{Description}:
9160 @code{NINT(A)} rounds its argument to the nearest whole number.
9161
9162 @item @emph{Standard}:
9163 Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
9164
9165 @item @emph{Class}:
9166 Elemental function
9167
9168 @item @emph{Syntax}:
9169 @code{RESULT = NINT(A [, KIND])}
9170
9171 @item @emph{Arguments}:
9172 @multitable @columnfractions .15 .70
9173 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
9174 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9175 expression indicating the kind parameter of the result.
9176 @end multitable
9177
9178 @item @emph{Return value}:
9179 Returns @var{A} with the fractional portion of its magnitude eliminated by
9180 rounding to the nearest whole number and with its sign preserved,
9181 converted to an @code{INTEGER} of the default kind.
9182
9183 @item @emph{Example}:
9184 @smallexample
9185 program test_nint
9186   real(4) x4
9187   real(8) x8
9188   x4 = 1.234E0_4
9189   x8 = 4.321_8
9190   print *, nint(x4), idnint(x8)
9191 end program test_nint
9192 @end smallexample
9193
9194 @item @emph{Specific names}:
9195 @multitable @columnfractions .20 .20 .20 .25
9196 @item Name             @tab Argument           @tab Return Type     @tab Standard
9197 @item @code{NINT(A)}   @tab @code{REAL(4) A}   @tab  @code{INTEGER} @tab Fortran 95 and later
9198 @item @code{IDNINT(A)} @tab @code{REAL(8) A}   @tab  @code{INTEGER} @tab Fortran 95 and later
9199 @end multitable
9200
9201 @item @emph{See also}:
9202 @ref{CEILING}, @ref{FLOOR}
9203
9204 @end table
9205
9206
9207
9208 @node NORM2
9209 @section @code{NORM2} --- Euclidean vector norms
9210 @fnindex NORM2
9211 @cindex Euclidean vector norm
9212 @cindex L2 vector norm
9213 @cindex norm, Euclidean
9214
9215 @table @asis
9216 @item @emph{Description}:
9217 Calculates the Euclidean vector norm (@math{L_2} norm) of
9218 of @var{ARRAY} along dimension @var{DIM}.
9219
9220 @item @emph{Standard}:
9221 Fortran 2008 and later
9222
9223 @item @emph{Class}:
9224 Transformational function
9225
9226 @item @emph{Syntax}:
9227 @multitable @columnfractions .80
9228 @item @code{RESULT = NORM2(ARRAY[, DIM])}
9229 @end multitable
9230
9231 @item @emph{Arguments}:
9232 @multitable @columnfractions .15 .70
9233 @item @var{ARRAY} @tab Shall be an array of type @code{REAL}
9234 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
9235 @code{INTEGER} with a value in the range from 1 to n, where n 
9236 equals the rank of @var{ARRAY}.
9237 @end multitable
9238
9239 @item @emph{Return value}:
9240 The result is of the same type as @var{ARRAY}.
9241
9242 If @var{DIM} is absent, a scalar with the square root of the sum of all
9243 elements in @var{ARRAY} squared  is returned. Otherwise, an array of
9244 rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, and a
9245 shape similar to that of @var{ARRAY} with dimension @var{DIM} dropped
9246 is returned.
9247
9248 @item @emph{Example}:
9249 @smallexample
9250 PROGRAM test_sum
9251   REAL :: x(5) = [ real :: 1, 2, 3, 4, 5 ]
9252   print *, NORM2(x)  ! = sqrt(55.) ~ 7.416
9253 END PROGRAM
9254 @end smallexample
9255 @end table
9256
9257
9258
9259 @node NOT
9260 @section @code{NOT} --- Logical negation
9261 @fnindex NOT
9262 @cindex bits, negate
9263 @cindex bitwise logical not
9264 @cindex logical not, bitwise
9265
9266 @table @asis
9267 @item @emph{Description}:
9268 @code{NOT} returns the bitwise Boolean inverse of @var{I}.
9269
9270 @item @emph{Standard}:
9271 Fortran 95 and later
9272
9273 @item @emph{Class}:
9274 Elemental function
9275
9276 @item @emph{Syntax}:
9277 @code{RESULT = NOT(I)}
9278
9279 @item @emph{Arguments}:
9280 @multitable @columnfractions .15 .70
9281 @item @var{I} @tab The type shall be @code{INTEGER}.
9282 @end multitable
9283
9284 @item @emph{Return value}:
9285 The return type is @code{INTEGER}, of the same kind as the
9286 argument.
9287
9288 @item @emph{See also}:
9289 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
9290
9291 @end table
9292
9293
9294
9295 @node NULL
9296 @section @code{NULL} --- Function that returns an disassociated pointer
9297 @fnindex NULL
9298 @cindex pointer, status
9299 @cindex pointer, disassociated
9300
9301 @table @asis
9302 @item @emph{Description}:
9303 Returns a disassociated pointer.
9304
9305 If @var{MOLD} is present, a disassociated pointer of the same type is
9306 returned, otherwise the type is determined by context.
9307
9308 In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
9309 includes cases where it is required.
9310
9311 @item @emph{Standard}:
9312 Fortran 95 and later
9313
9314 @item @emph{Class}:
9315 Transformational function
9316
9317 @item @emph{Syntax}:
9318 @code{PTR => NULL([MOLD])}
9319
9320 @item @emph{Arguments}:
9321 @multitable @columnfractions .15 .70
9322 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
9323 status and of any type.
9324 @end multitable
9325
9326 @item @emph{Return value}:
9327 A disassociated pointer.
9328
9329 @item @emph{Example}:
9330 @smallexample
9331 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
9332 @end smallexample
9333
9334 @item @emph{See also}:
9335 @ref{ASSOCIATED}
9336 @end table
9337
9338
9339
9340 @node NUM_IMAGES
9341 @section @code{NUM_IMAGES} --- Function that returns the number of images
9342 @fnindex NUM_IMAGES
9343 @cindex coarray, @code{NUM_IMAGES}
9344 @cindex images, number of
9345
9346 @table @asis
9347 @item @emph{Description}:
9348 Returns the number of images.
9349
9350 @item @emph{Standard}:
9351 Fortran 2008 and later
9352
9353 @item @emph{Class}:
9354 Transformational function
9355
9356 @item @emph{Syntax}:
9357 @code{RESULT = NUM_IMAGES()}
9358
9359 @item @emph{Arguments}: None.
9360
9361 @item @emph{Return value}:
9362 Scalar default-kind integer.
9363
9364 @item @emph{Example}:
9365 @smallexample
9366 INTEGER :: value[*]
9367 INTEGER :: i
9368 value = THIS_IMAGE()
9369 SYNC ALL
9370 IF (THIS_IMAGE() == 1) THEN
9371   DO i = 1, NUM_IMAGES()
9372     WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
9373   END DO
9374 END IF
9375 @end smallexample
9376
9377 @item @emph{See also}:
9378 @ref{THIS_IMAGE}, @ref{IMAGE_INDEX}
9379 @end table
9380
9381
9382
9383 @node OR
9384 @section @code{OR} --- Bitwise logical OR
9385 @fnindex OR
9386 @cindex bitwise logical or
9387 @cindex logical or, bitwise
9388
9389 @table @asis
9390 @item @emph{Description}:
9391 Bitwise logical @code{OR}.
9392
9393 This intrinsic routine is provided for backwards compatibility with 
9394 GNU Fortran 77.  For integer arguments, programmers should consider
9395 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
9396
9397 @item @emph{Standard}:
9398 GNU extension
9399
9400 @item @emph{Class}:
9401 Function
9402
9403 @item @emph{Syntax}:
9404 @code{RESULT = OR(I, J)}
9405
9406 @item @emph{Arguments}:
9407 @multitable @columnfractions .15 .70
9408 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
9409 type or a scalar @code{LOGICAL} type.
9410 @item @var{J} @tab The type shall be the same as the type of @var{J}.
9411 @end multitable
9412
9413 @item @emph{Return value}:
9414 The return type is either a scalar @code{INTEGER} or a scalar
9415 @code{LOGICAL}.  If the kind type parameters differ, then the
9416 smaller kind type is implicitly converted to larger kind, and the 
9417 return has the larger kind.
9418
9419 @item @emph{Example}:
9420 @smallexample
9421 PROGRAM test_or
9422   LOGICAL :: T = .TRUE., F = .FALSE.
9423   INTEGER :: a, b
9424   DATA a / Z'F' /, b / Z'3' /
9425
9426   WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
9427   WRITE (*,*) OR(a, b)
9428 END PROGRAM
9429 @end smallexample
9430
9431 @item @emph{See also}:
9432 Fortran 95 elemental function: @ref{IOR}
9433 @end table
9434
9435
9436
9437 @node PACK
9438 @section @code{PACK} --- Pack an array into an array of rank one
9439 @fnindex PACK
9440 @cindex array, packing
9441 @cindex array, reduce dimension
9442 @cindex array, gather elements
9443
9444 @table @asis
9445 @item @emph{Description}:
9446 Stores the elements of @var{ARRAY} in an array of rank one.
9447
9448 The beginning of the resulting array is made up of elements whose @var{MASK} 
9449 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
9450 @var{VECTOR}.
9451
9452 @item @emph{Standard}:
9453 Fortran 95 and later
9454
9455 @item @emph{Class}:
9456 Transformational function
9457
9458 @item @emph{Syntax}:
9459 @code{RESULT = PACK(ARRAY, MASK[,VECTOR]}
9460
9461 @item @emph{Arguments}:
9462 @multitable @columnfractions .15 .70
9463 @item @var{ARRAY}  @tab Shall be an array of any type.
9464 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL} and 
9465 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL} 
9466 scalar.
9467 @item @var{VECTOR} @tab (Optional) shall be an array of the same type 
9468 as @var{ARRAY} and of rank one. If present, the number of elements in 
9469 @var{VECTOR} shall be equal to or greater than the number of true elements 
9470 in @var{MASK}. If @var{MASK} is scalar, the number of elements in 
9471 @var{VECTOR} shall be equal to or greater than the number of elements in
9472 @var{ARRAY}.
9473 @end multitable
9474
9475 @item @emph{Return value}:
9476 The result is an array of rank one and the same type as that of @var{ARRAY}.
9477 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
9478 number of @code{TRUE} values in @var{MASK} otherwise.
9479
9480 @item @emph{Example}:
9481 Gathering nonzero elements from an array:
9482 @smallexample
9483 PROGRAM test_pack_1
9484   INTEGER :: m(6)
9485   m = (/ 1, 0, 0, 0, 5, 0 /)
9486   WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0)  ! "1 5"
9487 END PROGRAM
9488 @end smallexample
9489
9490 Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
9491 @smallexample
9492 PROGRAM test_pack_2
9493   INTEGER :: m(4)
9494   m = (/ 1, 0, 0, 2 /)
9495   WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /))  ! "1 2 3 4"
9496 END PROGRAM
9497 @end smallexample
9498
9499 @item @emph{See also}:
9500 @ref{UNPACK}
9501 @end table
9502
9503
9504
9505 @node PARITY
9506 @section @code{PARITY} --- Reduction with exclusive OR
9507 @fnindex PARITY
9508 @cindex Parity
9509 @cindex Reduction, XOR
9510 @cindex XOR reduction
9511
9512 @table @asis
9513 @item @emph{Description}:
9514 Calculates the parity, i.e. the reduction using @code{.XOR.},
9515 of @var{MASK} along dimension @var{DIM}.
9516
9517 @item @emph{Standard}:
9518 Fortran 2008 and later
9519
9520 @item @emph{Class}:
9521 Transformational function
9522
9523 @item @emph{Syntax}:
9524 @multitable @columnfractions .80
9525 @item @code{RESULT = PARITY(MASK[, DIM])}
9526 @end multitable
9527
9528 @item @emph{Arguments}:
9529 @multitable @columnfractions .15 .70
9530 @item @var{LOGICAL} @tab Shall be an array of type @code{LOGICAL}
9531 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
9532 @code{INTEGER} with a value in the range from 1 to n, where n 
9533 equals the rank of @var{MASK}.
9534 @end multitable
9535
9536 @item @emph{Return value}:
9537 The result is of the same type as @var{MASK}.
9538
9539 If @var{DIM} is absent, a scalar with the parity of all elements in
9540 @var{MASK} is returned, i.e. true if an odd number of elements is
9541 @code{.true.} and false otherwise.  If @var{DIM} is present, an array
9542 of rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY},
9543 and a shape similar to that of @var{MASK} with dimension @var{DIM}
9544 dropped is returned.
9545
9546 @item @emph{Example}:
9547 @smallexample
9548 PROGRAM test_sum
9549   LOGICAL :: x(2) = [ .true., .false. ]
9550   print *, PARITY(x) ! prints "T" (true).
9551 END PROGRAM
9552 @end smallexample
9553 @end table
9554
9555
9556
9557 @node PERROR
9558 @section @code{PERROR} --- Print system error message
9559 @fnindex PERROR
9560 @cindex system, error handling
9561
9562 @table @asis
9563 @item @emph{Description}:
9564 Prints (on the C @code{stderr} stream) a newline-terminated error
9565 message corresponding to the last system error. This is prefixed by
9566 @var{STRING}, a colon and a space. See @code{perror(3)}.
9567
9568 @item @emph{Standard}:
9569 GNU extension
9570
9571 @item @emph{Class}:
9572 Subroutine
9573
9574 @item @emph{Syntax}:
9575 @code{CALL PERROR(STRING)}
9576
9577 @item @emph{Arguments}:
9578 @multitable @columnfractions .15 .70
9579 @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
9580 default kind.
9581 @end multitable
9582
9583 @item @emph{See also}:
9584 @ref{IERRNO}
9585 @end table
9586
9587
9588
9589 @node PRECISION
9590 @section @code{PRECISION} --- Decimal precision of a real kind
9591 @fnindex PRECISION
9592 @cindex model representation, precision
9593
9594 @table @asis
9595 @item @emph{Description}:
9596 @code{PRECISION(X)} returns the decimal precision in the model of the
9597 type of @code{X}.
9598
9599 @item @emph{Standard}:
9600 Fortran 95 and later
9601
9602 @item @emph{Class}:
9603 Inquiry function
9604
9605 @item @emph{Syntax}:
9606 @code{RESULT = PRECISION(X)}
9607
9608 @item @emph{Arguments}:
9609 @multitable @columnfractions .15 .70
9610 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
9611 @end multitable
9612
9613 @item @emph{Return value}:
9614 The return value is of type @code{INTEGER} and of the default integer
9615 kind.
9616
9617 @item @emph{See also}:
9618 @ref{SELECTED_REAL_KIND}, @ref{RANGE}
9619
9620 @item @emph{Example}:
9621 @smallexample
9622 program prec_and_range
9623   real(kind=4) :: x(2)
9624   complex(kind=8) :: y
9625
9626   print *, precision(x), range(x)
9627   print *, precision(y), range(y)
9628 end program prec_and_range
9629 @end smallexample
9630 @end table
9631
9632
9633
9634 @node POPCNT
9635 @section @code{POPCNT} --- Number of bits set
9636 @fnindex POPCNT
9637 @cindex binary representation
9638 @cindex bits set
9639
9640 @table @asis
9641 @item @emph{Description}:
9642 @code{POPCNT(I)} returns the number of bits set ('1' bits) in the binary
9643 representation of @code{I}.
9644
9645 @item @emph{Standard}:
9646 Fortran 2008 and later
9647
9648 @item @emph{Class}:
9649 Elemental function
9650
9651 @item @emph{Syntax}:
9652 @code{RESULT = POPCNT(I)}
9653
9654 @item @emph{Arguments}:
9655 @multitable @columnfractions .15 .70
9656 @item @var{I} @tab Shall be of type @code{INTEGER}.
9657 @end multitable
9658
9659 @item @emph{Return value}:
9660 The return value is of type @code{INTEGER} and of the default integer
9661 kind.
9662
9663 @item @emph{See also}:
9664 @ref{POPPAR}, @ref{LEADZ}, @ref{TRAILZ}
9665
9666 @item @emph{Example}:
9667 @smallexample
9668 program test_population
9669   print *, popcnt(127),       poppar(127)
9670   print *, popcnt(huge(0_4)), poppar(huge(0_4))
9671   print *, popcnt(huge(0_8)), poppar(huge(0_8))
9672 end program test_population
9673 @end smallexample
9674 @end table
9675
9676
9677 @node POPPAR
9678 @section @code{POPPAR} --- Parity of the number of bits set
9679 @fnindex POPPAR
9680 @cindex binary representation
9681 @cindex parity
9682
9683 @table @asis
9684 @item @emph{Description}:
9685 @code{POPPAR(I)} returns parity of the integer @code{I}, i.e. the parity
9686 of the number of bits set ('1' bits) in the binary representation of
9687 @code{I}. It is equal to 0 if @code{I} has an even number of bits set,
9688 and 1 for an odd number of '1' bits.
9689
9690 @item @emph{Standard}:
9691 Fortran 2008 and later
9692
9693 @item @emph{Class}:
9694 Elemental function
9695
9696 @item @emph{Syntax}:
9697 @code{RESULT = POPPAR(I)}
9698
9699 @item @emph{Arguments}:
9700 @multitable @columnfractions .15 .70
9701 @item @var{I} @tab Shall be of type @code{INTEGER}.
9702 @end multitable
9703
9704 @item @emph{Return value}:
9705 The return value is of type @code{INTEGER} and of the default integer
9706 kind.
9707
9708 @item @emph{See also}:
9709 @ref{POPCNT}, @ref{LEADZ}, @ref{TRAILZ}
9710
9711 @item @emph{Example}:
9712 @smallexample
9713 program test_population
9714   print *, popcnt(127),       poppar(127)
9715   print *, popcnt(huge(0_4)), poppar(huge(0_4))
9716   print *, popcnt(huge(0_8)), poppar(huge(0_8))
9717 end program test_population
9718 @end smallexample
9719 @end table
9720
9721
9722
9723 @node PRESENT
9724 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
9725 @fnindex PRESENT
9726
9727 @table @asis
9728 @item @emph{Description}:
9729 Determines whether an optional dummy argument is present.
9730
9731 @item @emph{Standard}:
9732 Fortran 95 and later
9733
9734 @item @emph{Class}:
9735 Inquiry function
9736
9737 @item @emph{Syntax}:
9738 @code{RESULT = PRESENT(A)}
9739
9740 @item @emph{Arguments}:
9741 @multitable @columnfractions .15 .70
9742 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
9743 value, or a dummy procedure. It shall be the name of an optional dummy argument
9744 accessible within the current subroutine or function.
9745 @end multitable
9746
9747 @item @emph{Return value}:
9748 Returns either @code{TRUE} if the optional argument @var{A} is present, or
9749 @code{FALSE} otherwise.
9750
9751 @item @emph{Example}:
9752 @smallexample
9753 PROGRAM test_present
9754   WRITE(*,*) f(), f(42)      ! "F T"
9755 CONTAINS
9756   LOGICAL FUNCTION f(x)
9757     INTEGER, INTENT(IN), OPTIONAL :: x
9758     f = PRESENT(x)
9759   END FUNCTION
9760 END PROGRAM
9761 @end smallexample
9762 @end table
9763
9764
9765
9766 @node PRODUCT
9767 @section @code{PRODUCT} --- Product of array elements
9768 @fnindex PRODUCT
9769 @cindex array, product
9770 @cindex array, multiply elements
9771 @cindex array, conditionally multiply elements
9772 @cindex multiply array elements
9773
9774 @table @asis
9775 @item @emph{Description}:
9776 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
9777 the corresponding element in @var{MASK} is @code{TRUE}.
9778
9779 @item @emph{Standard}:
9780 Fortran 95 and later
9781
9782 @item @emph{Class}:
9783 Transformational function
9784
9785 @item @emph{Syntax}:
9786 @multitable @columnfractions .80
9787 @item @code{RESULT = PRODUCT(ARRAY[, MASK])}
9788 @item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
9789 @end multitable
9790
9791 @item @emph{Arguments}:
9792 @multitable @columnfractions .15 .70
9793 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
9794 @code{REAL} or @code{COMPLEX}.
9795 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
9796 @code{INTEGER} with a value in the range from 1 to n, where n 
9797 equals the rank of @var{ARRAY}.
9798 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
9799 and either be a scalar or an array of the same shape as @var{ARRAY}.
9800 @end multitable
9801
9802 @item @emph{Return value}:
9803 The result is of the same type as @var{ARRAY}.
9804
9805 If @var{DIM} is absent, a scalar with the product of all elements in 
9806 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals 
9807 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with 
9808 dimension @var{DIM} dropped is returned.
9809
9810
9811 @item @emph{Example}:
9812 @smallexample
9813 PROGRAM test_product
9814   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
9815   print *, PRODUCT(x)                    ! all elements, product = 120
9816   print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
9817 END PROGRAM
9818 @end smallexample
9819
9820 @item @emph{See also}:
9821 @ref{SUM}
9822 @end table
9823
9824
9825
9826 @node RADIX
9827 @section @code{RADIX} --- Base of a model number
9828 @fnindex RADIX
9829 @cindex model representation, base
9830 @cindex model representation, radix
9831
9832 @table @asis
9833 @item @emph{Description}:
9834 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
9835
9836 @item @emph{Standard}:
9837 Fortran 95 and later
9838
9839 @item @emph{Class}:
9840 Inquiry function
9841
9842 @item @emph{Syntax}:
9843 @code{RESULT = RADIX(X)}
9844
9845 @item @emph{Arguments}:
9846 @multitable @columnfractions .15 .70
9847 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
9848 @end multitable
9849
9850 @item @emph{Return value}:
9851 The return value is a scalar of type @code{INTEGER} and of the default
9852 integer kind.
9853
9854 @item @emph{See also}:
9855 @ref{SELECTED_REAL_KIND}
9856
9857 @item @emph{Example}:
9858 @smallexample
9859 program test_radix
9860   print *, "The radix for the default integer kind is", radix(0)
9861   print *, "The radix for the default real kind is", radix(0.0)
9862 end program test_radix
9863 @end smallexample
9864
9865 @end table
9866
9867
9868
9869 @node RAN
9870 @section @code{RAN} --- Real pseudo-random number
9871 @fnindex RAN
9872 @cindex random number generation
9873
9874 @table @asis
9875 @item @emph{Description}:
9876 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
9877 provided as an alias for @code{RAND}.  See @ref{RAND} for complete
9878 documentation.
9879
9880 @item @emph{Standard}:
9881 GNU extension
9882
9883 @item @emph{Class}:
9884 Function
9885
9886 @item @emph{See also}:
9887 @ref{RAND}, @ref{RANDOM_NUMBER}
9888 @end table
9889
9890
9891
9892 @node RAND
9893 @section @code{RAND} --- Real pseudo-random number
9894 @fnindex RAND
9895 @cindex random number generation
9896
9897 @table @asis
9898 @item @emph{Description}:
9899 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
9900 distribution between 0 and 1. If @var{FLAG} is 0, the next number
9901 in the current sequence is returned; if @var{FLAG} is 1, the generator
9902 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
9903 it is used as a new seed with @code{SRAND}.
9904
9905 This intrinsic routine is provided for backwards compatibility with
9906 GNU Fortran 77. It implements a simple modulo generator as provided 
9907 by @command{g77}. For new code, one should consider the use of 
9908 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
9909
9910 @item @emph{Standard}:
9911 GNU extension
9912
9913 @item @emph{Class}:
9914 Function
9915
9916 @item @emph{Syntax}:
9917 @code{RESULT = RAND(I)}
9918
9919 @item @emph{Arguments}:
9920 @multitable @columnfractions .15 .70
9921 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
9922 @end multitable
9923
9924 @item @emph{Return value}:
9925 The return value is of @code{REAL} type and the default kind.
9926
9927 @item @emph{Example}:
9928 @smallexample
9929 program test_rand
9930   integer,parameter :: seed = 86456
9931   
9932   call srand(seed)
9933   print *, rand(), rand(), rand(), rand()
9934   print *, rand(seed), rand(), rand(), rand()
9935 end program test_rand
9936 @end smallexample
9937
9938 @item @emph{See also}:
9939 @ref{SRAND}, @ref{RANDOM_NUMBER}
9940
9941 @end table
9942
9943
9944
9945 @node RANDOM_NUMBER
9946 @section @code{RANDOM_NUMBER} --- Pseudo-random number
9947 @fnindex RANDOM_NUMBER
9948 @cindex random number generation
9949
9950 @table @asis
9951 @item @emph{Description}:
9952 Returns a single pseudorandom number or an array of pseudorandom numbers
9953 from the uniform distribution over the range @math{ 0 \leq x < 1}.
9954
9955 The runtime-library implements George Marsaglia's KISS (Keep It Simple 
9956 Stupid) random number generator (RNG). This RNG combines:
9957 @enumerate
9958 @item The congruential generator @math{x(n) = 69069 \cdot x(n-1) + 1327217885}
9959 with a period of @math{2^{32}},
9960 @item A 3-shift shift-register generator with a period of @math{2^{32} - 1},
9961 @item  Two 16-bit multiply-with-carry generators with a period of
9962 @math{597273182964842497 > 2^{59}}.
9963 @end enumerate
9964 The overall period exceeds @math{2^{123}}.
9965
9966 Please note, this RNG is thread safe if used within OpenMP directives,
9967 i.e., its state will be consistent while called from multiple threads.
9968 However, the KISS generator does not create random numbers in parallel 
9969 from multiple sources, but in sequence from a single source. If an
9970 OpenMP-enabled application heavily relies on random numbers, one should 
9971 consider employing a dedicated parallel random number generator instead.
9972
9973 @item @emph{Standard}:
9974 Fortran 95 and later
9975
9976 @item @emph{Class}:
9977 Subroutine
9978
9979 @item @emph{Syntax}:
9980 @code{RANDOM_NUMBER(HARVEST)}
9981
9982 @item @emph{Arguments}:
9983 @multitable @columnfractions .15 .70
9984 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
9985 @end multitable
9986
9987 @item @emph{Example}:
9988 @smallexample
9989 program test_random_number
9990   REAL :: r(5,5)
9991   CALL init_random_seed()         ! see example of RANDOM_SEED
9992   CALL RANDOM_NUMBER(r)
9993 end program
9994 @end smallexample
9995
9996 @item @emph{See also}:
9997 @ref{RANDOM_SEED}
9998 @end table
9999
10000
10001
10002 @node RANDOM_SEED
10003 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
10004 @fnindex RANDOM_SEED
10005 @cindex random number generation, seeding
10006 @cindex seeding a random number generator
10007
10008 @table @asis
10009 @item @emph{Description}:
10010 Restarts or queries the state of the pseudorandom number generator used by 
10011 @code{RANDOM_NUMBER}.
10012
10013 If @code{RANDOM_SEED} is called without arguments, it is initialized to
10014 a default state. The example below shows how to initialize the random 
10015 seed based on the system's time.
10016
10017 @item @emph{Standard}:
10018 Fortran 95 and later
10019
10020 @item @emph{Class}:
10021 Subroutine
10022
10023 @item @emph{Syntax}:
10024 @code{CALL RANDOM_SEED([SIZE, PUT, GET])}
10025
10026 @item @emph{Arguments}:
10027 @multitable @columnfractions .15 .70
10028 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default 
10029 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size 
10030 of the arrays used with the @var{PUT} and @var{GET} arguments.
10031 @item @var{PUT}  @tab (Optional) Shall be an array of type default 
10032 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of 
10033 the array must be larger than or equal to the number returned by the 
10034 @var{SIZE} argument.
10035 @item @var{GET}  @tab (Optional) Shall be an array of type default 
10036 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size 
10037 of the array must be larger than or equal to the number returned by 
10038 the @var{SIZE} argument.
10039 @end multitable
10040
10041 @item @emph{Example}:
10042 @smallexample
10043 SUBROUTINE init_random_seed()
10044   INTEGER :: i, n, clock
10045   INTEGER, DIMENSION(:), ALLOCATABLE :: seed
10046
10047   CALL RANDOM_SEED(size = n)
10048   ALLOCATE(seed(n))
10049
10050   CALL SYSTEM_CLOCK(COUNT=clock)
10051
10052   seed = clock + 37 * (/ (i - 1, i = 1, n) /)
10053   CALL RANDOM_SEED(PUT = seed)
10054
10055   DEALLOCATE(seed)
10056 END SUBROUTINE
10057 @end smallexample
10058
10059 @item @emph{See also}:
10060 @ref{RANDOM_NUMBER}
10061 @end table
10062
10063
10064
10065 @node RANGE
10066 @section @code{RANGE} --- Decimal exponent range
10067 @fnindex RANGE
10068 @cindex model representation, range
10069
10070 @table @asis
10071 @item @emph{Description}:
10072 @code{RANGE(X)} returns the decimal exponent range in the model of the
10073 type of @code{X}.
10074
10075 @item @emph{Standard}:
10076 Fortran 95 and later
10077
10078 @item @emph{Class}:
10079 Inquiry function
10080
10081 @item @emph{Syntax}:
10082 @code{RESULT = RANGE(X)}
10083
10084 @item @emph{Arguments}:
10085 @multitable @columnfractions .15 .70
10086 @item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL}
10087 or @code{COMPLEX}.
10088 @end multitable
10089
10090 @item @emph{Return value}:
10091 The return value is of type @code{INTEGER} and of the default integer
10092 kind.
10093
10094 @item @emph{See also}:
10095 @ref{SELECTED_REAL_KIND}, @ref{PRECISION}
10096
10097 @item @emph{Example}:
10098 See @code{PRECISION} for an example.
10099 @end table
10100
10101
10102
10103 @node REAL
10104 @section @code{REAL} --- Convert to real type 
10105 @fnindex REAL
10106 @fnindex REALPART
10107 @fnindex FLOAT
10108 @fnindex DFLOAT
10109 @fnindex SNGL
10110 @cindex conversion, to real
10111 @cindex complex numbers, real part
10112
10113 @table @asis
10114 @item @emph{Description}:
10115 @code{REAL(A [, KIND])} converts its argument @var{A} to a real type.  The
10116 @code{REALPART} function is provided for compatibility with @command{g77},
10117 and its use is strongly discouraged.
10118
10119 @item @emph{Standard}:
10120 Fortran 77 and later
10121
10122 @item @emph{Class}:
10123 Elemental function
10124
10125 @item @emph{Syntax}:
10126 @multitable @columnfractions .80
10127 @item @code{RESULT = REAL(A [, KIND])}
10128 @item @code{RESULT = REALPART(Z)}
10129 @end multitable
10130
10131 @item @emph{Arguments}:
10132 @multitable @columnfractions .15 .70
10133 @item @var{A}    @tab Shall be @code{INTEGER}, @code{REAL}, or
10134 @code{COMPLEX}.
10135 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10136 expression indicating the kind parameter of the result.
10137 @end multitable
10138
10139 @item @emph{Return value}:
10140 These functions return a @code{REAL} variable or array under
10141 the following rules: 
10142
10143 @table @asis
10144 @item (A)
10145 @code{REAL(A)} is converted to a default real type if @var{A} is an 
10146 integer or real variable.
10147 @item (B)
10148 @code{REAL(A)} is converted to a real type with the kind type parameter
10149 of @var{A} if @var{A} is a complex variable.
10150 @item (C)
10151 @code{REAL(A, KIND)} is converted to a real type with kind type
10152 parameter @var{KIND} if @var{A} is a complex, integer, or real
10153 variable.
10154 @end table
10155
10156 @item @emph{Example}:
10157 @smallexample
10158 program test_real
10159   complex :: x = (1.0, 2.0)
10160   print *, real(x), real(x,8), realpart(x)
10161 end program test_real
10162 @end smallexample
10163
10164 @item @emph{Specific names}:
10165 @multitable @columnfractions .20 .20 .20 .25
10166 @item Name             @tab Argument           @tab Return type     @tab Standard
10167 @item @code{FLOAT(A)}  @tab @code{INTEGER(4)}  @tab @code{REAL(4)}  @tab Fortran 77 and later
10168 @item @code{DFLOAT(A)} @tab @code{INTEGER(4)}  @tab @code{REAL(8)}  @tab GNU extension
10169 @item @code{SNGL(A)}   @tab @code{INTEGER(8)}  @tab @code{REAL(4)}  @tab Fortran 77 and later
10170 @end multitable
10171
10172
10173 @item @emph{See also}:
10174 @ref{DBLE}
10175
10176 @end table
10177
10178
10179
10180 @node RENAME
10181 @section @code{RENAME} --- Rename a file
10182 @fnindex RENAME
10183 @cindex file system, rename file
10184
10185 @table @asis
10186 @item @emph{Description}:
10187 Renames a file from file @var{PATH1} to @var{PATH2}. A null
10188 character (@code{CHAR(0)}) can be used to mark the end of the names in
10189 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
10190 names are ignored.  If the @var{STATUS} argument is supplied, it
10191 contains 0 on success or a nonzero error code upon return; see
10192 @code{rename(2)}.
10193
10194 This intrinsic is provided in both subroutine and function forms;
10195 however, only one form can be used in any given program unit.
10196
10197 @item @emph{Standard}:
10198 GNU extension
10199
10200 @item @emph{Class}:
10201 Subroutine, function
10202
10203 @item @emph{Syntax}:
10204 @multitable @columnfractions .80
10205 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
10206 @item @code{STATUS = RENAME(PATH1, PATH2)}
10207 @end multitable
10208
10209 @item @emph{Arguments}:
10210 @multitable @columnfractions .15 .70
10211 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
10212 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
10213 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10214 @end multitable
10215
10216 @item @emph{See also}:
10217 @ref{LINK}
10218
10219 @end table
10220
10221
10222
10223 @node REPEAT
10224 @section @code{REPEAT} --- Repeated string concatenation 
10225 @fnindex REPEAT
10226 @cindex string, repeat
10227 @cindex string, concatenate
10228
10229 @table @asis
10230 @item @emph{Description}:
10231 Concatenates @var{NCOPIES} copies of a string.
10232
10233 @item @emph{Standard}:
10234 Fortran 95 and later
10235
10236 @item @emph{Class}:
10237 Transformational function
10238
10239 @item @emph{Syntax}:
10240 @code{RESULT = REPEAT(STRING, NCOPIES)}
10241
10242 @item @emph{Arguments}:
10243 @multitable @columnfractions .15 .70
10244 @item @var{STRING}  @tab Shall be scalar and of type @code{CHARACTER}.
10245 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
10246 @end multitable
10247
10248 @item @emph{Return value}:
10249 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies 
10250 of @var{STRING}.
10251
10252 @item @emph{Example}:
10253 @smallexample
10254 program test_repeat
10255   write(*,*) repeat("x", 5)   ! "xxxxx"
10256 end program
10257 @end smallexample
10258 @end table
10259
10260
10261
10262 @node RESHAPE
10263 @section @code{RESHAPE} --- Function to reshape an array
10264 @fnindex RESHAPE
10265 @cindex array, change dimensions
10266 @cindex array, transmogrify
10267
10268 @table @asis
10269 @item @emph{Description}:
10270 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
10271 the new array may be padded with elements from @var{PAD} or permuted
10272 as defined by @var{ORDER}.
10273
10274 @item @emph{Standard}:
10275 Fortran 95 and later
10276
10277 @item @emph{Class}:
10278 Transformational function
10279
10280 @item @emph{Syntax}:
10281 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
10282
10283 @item @emph{Arguments}:
10284 @multitable @columnfractions .15 .70
10285 @item @var{SOURCE} @tab Shall be an array of any type.
10286 @item @var{SHAPE}  @tab Shall be of type @code{INTEGER} and an 
10287 array of rank one. Its values must be positive or zero.
10288 @item @var{PAD}    @tab (Optional) shall be an array of the same 
10289 type as @var{SOURCE}.
10290 @item @var{ORDER}  @tab (Optional) shall be of type @code{INTEGER}
10291 and an array of the same shape as @var{SHAPE}. Its values shall
10292 be a permutation of the numbers from 1 to n, where n is the size of 
10293 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
10294 be assumed.
10295 @end multitable
10296
10297 @item @emph{Return value}:
10298 The result is an array of shape @var{SHAPE} with the same type as 
10299 @var{SOURCE}. 
10300
10301 @item @emph{Example}:
10302 @smallexample
10303 PROGRAM test_reshape
10304   INTEGER, DIMENSION(4) :: x
10305   WRITE(*,*) SHAPE(x)                       ! prints "4"
10306   WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/)))    ! prints "2 2"
10307 END PROGRAM
10308 @end smallexample
10309
10310 @item @emph{See also}:
10311 @ref{SHAPE}
10312 @end table
10313
10314
10315
10316 @node RRSPACING
10317 @section @code{RRSPACING} --- Reciprocal of the relative spacing
10318 @fnindex RRSPACING
10319 @cindex real number, relative spacing
10320 @cindex floating point, relative spacing
10321
10322
10323 @table @asis
10324 @item @emph{Description}:
10325 @code{RRSPACING(X)} returns the  reciprocal of the relative spacing of
10326 model numbers near @var{X}.
10327
10328 @item @emph{Standard}:
10329 Fortran 95 and later
10330
10331 @item @emph{Class}:
10332 Elemental function
10333
10334 @item @emph{Syntax}:
10335 @code{RESULT = RRSPACING(X)}
10336
10337 @item @emph{Arguments}:
10338 @multitable @columnfractions .15 .70
10339 @item @var{X} @tab Shall be of type @code{REAL}.
10340 @end multitable
10341
10342 @item @emph{Return value}:
10343 The return value is of the same type and kind as @var{X}.
10344 The value returned is equal to
10345 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
10346
10347 @item @emph{See also}:
10348 @ref{SPACING}
10349 @end table
10350
10351
10352
10353 @node RSHIFT
10354 @section @code{RSHIFT} --- Right shift bits
10355 @fnindex RSHIFT
10356 @cindex bits, shift right
10357
10358 @table @asis
10359 @item @emph{Description}:
10360 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
10361 bits shifted right by @var{SHIFT} places.  If the absolute value of
10362 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
10363 Bits shifted out from the right end are lost. The fill is arithmetic: the
10364 bits shifted in from the left end are equal to the leftmost bit, which in
10365 two's complement representation is the sign bit.
10366
10367 This function has been superseded by the @code{SHIFTA} intrinsic, which
10368 is standard in Fortran 2008 and later.
10369
10370 @item @emph{Standard}:
10371 GNU extension
10372
10373 @item @emph{Class}:
10374 Elemental function
10375
10376 @item @emph{Syntax}:
10377 @code{RESULT = RSHIFT(I, SHIFT)}
10378
10379 @item @emph{Arguments}:
10380 @multitable @columnfractions .15 .70
10381 @item @var{I} @tab The type shall be @code{INTEGER}.
10382 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
10383 @end multitable
10384
10385 @item @emph{Return value}:
10386 The return value is of type @code{INTEGER} and of the same kind as
10387 @var{I}.
10388
10389 @item @emph{See also}:
10390 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}, @ref{SHIFTA}, @ref{SHIFTR},
10391 @ref{SHIFTL}
10392
10393 @end table
10394
10395
10396
10397 @node SAME_TYPE_AS
10398 @section @code{SAME_TYPE_AS} ---  Query dynamic types for equality
10399 @fnindex SAME_TYPE_AS
10400
10401 @table @asis
10402 @item @emph{Description}:
10403 Query dynamic types for equality.
10404
10405 @item @emph{Standard}:
10406 Fortran 2003 and later
10407
10408 @item @emph{Class}:
10409 Inquiry function
10410
10411 @item @emph{Syntax}:
10412 @code{RESULT = SAME_TYPE_AS(A, B)}
10413
10414 @item @emph{Arguments}:
10415 @multitable @columnfractions .15 .70
10416 @item @var{A} @tab Shall be an object of extensible declared type or
10417 unlimited polymorphic.
10418 @item @var{B} @tab Shall be an object of extensible declared type or
10419 unlimited polymorphic.
10420 @end multitable
10421
10422 @item @emph{Return value}:
10423 The return value is a scalar of type default logical. It is true if and
10424 only if the dynamic type of A is the same as the dynamic type of B.
10425
10426 @item @emph{See also}:
10427 @ref{EXTENDS_TYPE_OF}
10428
10429 @end table
10430
10431
10432
10433 @node SCALE
10434 @section @code{SCALE} --- Scale a real value
10435 @fnindex SCALE
10436 @cindex real number, scale
10437 @cindex floating point, scale
10438
10439 @table @asis
10440 @item @emph{Description}:
10441 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
10442
10443 @item @emph{Standard}:
10444 Fortran 95 and later
10445
10446 @item @emph{Class}:
10447 Elemental function
10448
10449 @item @emph{Syntax}:
10450 @code{RESULT = SCALE(X, I)}
10451
10452 @item @emph{Arguments}:
10453 @multitable @columnfractions .15 .70
10454 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
10455 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
10456 @end multitable
10457
10458 @item @emph{Return value}:
10459 The return value is of the same type and kind as @var{X}.
10460 Its value is @code{X * RADIX(X)**I}.
10461
10462 @item @emph{Example}:
10463 @smallexample
10464 program test_scale
10465   real :: x = 178.1387e-4
10466   integer :: i = 5
10467   print *, scale(x,i), x*radix(x)**i
10468 end program test_scale
10469 @end smallexample
10470
10471 @end table
10472
10473
10474
10475 @node SCAN
10476 @section @code{SCAN} --- Scan a string for the presence of a set of characters
10477 @fnindex SCAN
10478 @cindex string, find subset
10479
10480 @table @asis
10481 @item @emph{Description}:
10482 Scans a @var{STRING} for any of the characters in a @var{SET} 
10483 of characters.
10484
10485 If @var{BACK} is either absent or equals @code{FALSE}, this function
10486 returns the position of the leftmost character of @var{STRING} that is
10487 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
10488 is returned. If no character of @var{SET} is found in @var{STRING}, the 
10489 result is zero.
10490
10491 @item @emph{Standard}:
10492 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
10493
10494 @item @emph{Class}:
10495 Elemental function
10496
10497 @item @emph{Syntax}:
10498 @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
10499
10500 @item @emph{Arguments}:
10501 @multitable @columnfractions .15 .70
10502 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
10503 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
10504 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
10505 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
10506 expression indicating the kind parameter of the result.
10507 @end multitable
10508
10509 @item @emph{Return value}:
10510 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
10511 @var{KIND} is absent, the return value is of default integer kind.
10512
10513 @item @emph{Example}:
10514 @smallexample
10515 PROGRAM test_scan
10516   WRITE(*,*) SCAN("FORTRAN", "AO")          ! 2, found 'O'
10517   WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.)  ! 6, found 'A'
10518   WRITE(*,*) SCAN("FORTRAN", "C++")         ! 0, found none
10519 END PROGRAM
10520 @end smallexample
10521
10522 @item @emph{See also}:
10523 @ref{INDEX intrinsic}, @ref{VERIFY}
10524 @end table
10525
10526
10527
10528 @node SECNDS
10529 @section @code{SECNDS} --- Time function
10530 @fnindex SECNDS
10531 @cindex time, elapsed
10532 @cindex elapsed time
10533
10534 @table @asis
10535 @item @emph{Description}:
10536 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
10537 @var{X} is a reference time, also in seconds. If this is zero, the time in
10538 seconds from midnight is returned. This function is non-standard and its
10539 use is discouraged.
10540
10541 @item @emph{Standard}:
10542 GNU extension
10543
10544 @item @emph{Class}:
10545 Function
10546
10547 @item @emph{Syntax}:
10548 @code{RESULT = SECNDS (X)}
10549
10550 @item @emph{Arguments}:
10551 @multitable @columnfractions .15 .70
10552 @item @var{T}     @tab Shall be of type @code{REAL(4)}.
10553 @item @var{X}     @tab Shall be of type @code{REAL(4)}.
10554 @end multitable
10555
10556 @item @emph{Return value}:
10557 None
10558
10559 @item @emph{Example}:
10560 @smallexample
10561 program test_secnds
10562     integer :: i
10563     real(4) :: t1, t2
10564     print *, secnds (0.0)   ! seconds since midnight
10565     t1 = secnds (0.0)       ! reference time
10566     do i = 1, 10000000      ! do something
10567     end do
10568     t2 = secnds (t1)        ! elapsed time
10569     print *, "Something took ", t2, " seconds."
10570 end program test_secnds
10571 @end smallexample
10572 @end table
10573
10574
10575
10576 @node SECOND
10577 @section @code{SECOND} --- CPU time function
10578 @fnindex SECOND
10579 @cindex time, elapsed
10580 @cindex elapsed time
10581
10582 @table @asis
10583 @item @emph{Description}:
10584 Returns a @code{REAL(4)} value representing the elapsed CPU time in
10585 seconds.  This provides the same functionality as the standard
10586 @code{CPU_TIME} intrinsic, and is only included for backwards
10587 compatibility.
10588
10589 This intrinsic is provided in both subroutine and function forms;
10590 however, only one form can be used in any given program unit.
10591
10592 @item @emph{Standard}:
10593 GNU extension
10594
10595 @item @emph{Class}:
10596 Subroutine, function
10597
10598 @item @emph{Syntax}:
10599 @multitable @columnfractions .80
10600 @item @code{CALL SECOND(TIME)}
10601 @item @code{TIME = SECOND()}
10602 @end multitable
10603
10604 @item @emph{Arguments}:
10605 @multitable @columnfractions .15 .70
10606 @item @var{TIME}  @tab Shall be of type @code{REAL(4)}.
10607 @end multitable
10608
10609 @item @emph{Return value}:
10610 In either syntax, @var{TIME} is set to the process's current runtime in
10611 seconds.
10612
10613 @item @emph{See also}:
10614 @ref{CPU_TIME}
10615
10616 @end table
10617
10618
10619
10620 @node SELECTED_CHAR_KIND
10621 @section @code{SELECTED_CHAR_KIND} --- Choose character kind
10622 @fnindex SELECTED_CHAR_KIND
10623 @cindex character kind
10624 @cindex kind, character
10625
10626 @table @asis
10627 @item @emph{Description}:
10628
10629 @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
10630 set named @var{NAME}, if a character set with such a name is supported,
10631 or @math{-1} otherwise. Currently, supported character sets include
10632 ``ASCII'' and ``DEFAULT'', which are equivalent, and ``ISO_10646''
10633 (Universal Character Set, UCS-4) which is commonly known as Unicode.
10634
10635 @item @emph{Standard}:
10636 Fortran 2003 and later
10637
10638 @item @emph{Class}:
10639 Transformational function
10640
10641 @item @emph{Syntax}:
10642 @code{RESULT = SELECTED_CHAR_KIND(NAME)}
10643
10644 @item @emph{Arguments}:
10645 @multitable @columnfractions .15 .70
10646 @item @var{NAME} @tab Shall be a scalar and of the default character type.
10647 @end multitable
10648
10649 @item @emph{Example}:
10650 @smallexample
10651 program character_kind
10652   use iso_fortran_env
10653   implicit none
10654   integer, parameter :: ascii = selected_char_kind ("ascii")
10655   integer, parameter :: ucs4  = selected_char_kind ('ISO_10646')
10656
10657   character(kind=ascii, len=26) :: alphabet
10658   character(kind=ucs4,  len=30) :: hello_world
10659
10660   alphabet = ascii_"abcdefghijklmnopqrstuvwxyz"
10661   hello_world = ucs4_'Hello World and Ni Hao -- ' &
10662                 // char (int (z'4F60'), ucs4)     &
10663                 // char (int (z'597D'), ucs4)
10664
10665   write (*,*) alphabet
10666
10667   open (output_unit, encoding='UTF-8')
10668   write (*,*) trim (hello_world)
10669 end program character_kind
10670 @end smallexample
10671 @end table
10672
10673
10674
10675 @node SELECTED_INT_KIND
10676 @section @code{SELECTED_INT_KIND} --- Choose integer kind
10677 @fnindex SELECTED_INT_KIND
10678 @cindex integer kind
10679 @cindex kind, integer
10680
10681 @table @asis
10682 @item @emph{Description}:
10683 @code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer
10684 type that can represent all values ranging from @math{-10^R} (exclusive)
10685 to @math{10^R} (exclusive). If there is no integer kind that accommodates
10686 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
10687
10688 @item @emph{Standard}:
10689 Fortran 95 and later
10690
10691 @item @emph{Class}:
10692 Transformational function
10693
10694 @item @emph{Syntax}:
10695 @code{RESULT = SELECTED_INT_KIND(R)}
10696
10697 @item @emph{Arguments}:
10698 @multitable @columnfractions .15 .70
10699 @item @var{R} @tab Shall be a scalar and of type @code{INTEGER}.
10700 @end multitable
10701
10702 @item @emph{Example}:
10703 @smallexample
10704 program large_integers
10705   integer,parameter :: k5 = selected_int_kind(5)
10706   integer,parameter :: k15 = selected_int_kind(15)
10707   integer(kind=k5) :: i5
10708   integer(kind=k15) :: i15
10709
10710   print *, huge(i5), huge(i15)
10711
10712   ! The following inequalities are always true
10713   print *, huge(i5) >= 10_k5**5-1
10714   print *, huge(i15) >= 10_k15**15-1
10715 end program large_integers
10716 @end smallexample
10717 @end table
10718
10719
10720
10721 @node SELECTED_REAL_KIND
10722 @section @code{SELECTED_REAL_KIND} --- Choose real kind
10723 @fnindex SELECTED_REAL_KIND
10724 @cindex real kind
10725 @cindex kind, real
10726 @cindex radix, real
10727
10728 @table @asis
10729 @item @emph{Description}:
10730 @code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type
10731 with decimal precision of at least @code{P} digits, exponent range of
10732 at least @code{R}, and with a radix of @code{RADIX}.
10733
10734 @item @emph{Standard}:
10735 Fortran 95 and later, with @code{RADIX} Fortran 2008 or later
10736
10737 @item @emph{Class}:
10738 Transformational function
10739
10740 @item @emph{Syntax}:
10741 @code{RESULT = SELECTED_REAL_KIND([P, R, RADIX])}
10742
10743 @item @emph{Arguments}:
10744 @multitable @columnfractions .15 .70
10745 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
10746 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
10747 @item @var{RADIX} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
10748 @end multitable
10749 Before Fortran 2008, at least one of the arguments @var{R} or @var{P} shall
10750 be present; since Fortran 2008, they are assumed to be zero if absent.
10751
10752 @item @emph{Return value}:
10753
10754 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
10755 a real data type with decimal precision of at least @code{P} digits, a
10756 decimal exponent range of at least @code{R}, and with the requested
10757 @code{RADIX}. If the @code{RADIX} parameter is absent, real kinds with
10758 any radix can be returned. If more than one real data type meet the
10759 criteria, the kind of the data type with the smallest decimal precision
10760 is returned. If no real data type matches the criteria, the result is
10761 @table @asis
10762 @item -1 if the processor does not support a real data type with a
10763 precision greater than or equal to @code{P}, but the @code{R} and
10764 @code{RADIX} requirements can be fulfilled
10765 @item -2 if the processor does not support a real type with an exponent
10766 range greater than or equal to @code{R}, but @code{P} and @code{RADIX}
10767 are fulfillable
10768 @item -3 if @code{RADIX} but not @code{P} and @code{R} requirements
10769 are fulfillable
10770 @item -4 if @code{RADIX} and either @code{P} or @code{R} requirements
10771 are fulfillable
10772 @item -5 if there is no real type with the given @code{RADIX}
10773 @end table
10774
10775 @item @emph{See also}:
10776 @ref{PRECISION}, @ref{RANGE}, @ref{RADIX}
10777
10778 @item @emph{Example}:
10779 @smallexample
10780 program real_kinds
10781   integer,parameter :: p6 = selected_real_kind(6)
10782   integer,parameter :: p10r100 = selected_real_kind(10,100)
10783   integer,parameter :: r400 = selected_real_kind(r=400)
10784   real(kind=p6) :: x
10785   real(kind=p10r100) :: y
10786   real(kind=r400) :: z
10787
10788   print *, precision(x), range(x)
10789   print *, precision(y), range(y)
10790   print *, precision(z), range(z)
10791 end program real_kinds
10792 @end smallexample
10793 @end table
10794
10795
10796
10797 @node SET_EXPONENT
10798 @section @code{SET_EXPONENT} --- Set the exponent of the model
10799 @fnindex SET_EXPONENT
10800 @cindex real number, set exponent
10801 @cindex floating point, set exponent
10802
10803 @table @asis
10804 @item @emph{Description}:
10805 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
10806 is that that of @var{X} and whose exponent part is @var{I}.
10807
10808 @item @emph{Standard}:
10809 Fortran 95 and later
10810
10811 @item @emph{Class}:
10812 Elemental function
10813
10814 @item @emph{Syntax}:
10815 @code{RESULT = SET_EXPONENT(X, I)}
10816
10817 @item @emph{Arguments}:
10818 @multitable @columnfractions .15 .70
10819 @item @var{X} @tab Shall be of type @code{REAL}.
10820 @item @var{I} @tab Shall be of type @code{INTEGER}.
10821 @end multitable
10822
10823 @item @emph{Return value}:
10824 The return value is of the same type and kind as @var{X}.
10825 The real number whose fractional part
10826 is that that of @var{X} and whose exponent part if @var{I} is returned;
10827 it is @code{FRACTION(X) * RADIX(X)**I}.
10828
10829 @item @emph{Example}:
10830 @smallexample
10831 PROGRAM test_setexp
10832   REAL :: x = 178.1387e-4
10833   INTEGER :: i = 17
10834   PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
10835 END PROGRAM
10836 @end smallexample
10837
10838 @end table
10839
10840
10841
10842 @node SHAPE
10843 @section @code{SHAPE} --- Determine the shape of an array
10844 @fnindex SHAPE
10845 @cindex array, shape
10846
10847 @table @asis
10848 @item @emph{Description}:
10849 Determines the shape of an array.
10850
10851 @item @emph{Standard}:
10852 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
10853
10854 @item @emph{Class}:
10855 Inquiry function
10856
10857 @item @emph{Syntax}:
10858 @code{RESULT = SHAPE(SOURCE [, KIND])}
10859
10860 @item @emph{Arguments}:
10861 @multitable @columnfractions .15 .70
10862 @item @var{SOURCE} @tab Shall be an array or scalar of any type. 
10863 If @var{SOURCE} is a pointer it must be associated and allocatable 
10864 arrays must be allocated.
10865 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
10866 expression indicating the kind parameter of the result.
10867 @end multitable
10868
10869 @item @emph{Return value}:
10870 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE} 
10871 has dimensions. The elements of the resulting array correspond to the extend
10872 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
10873 the result is the rank one array of size zero. If @var{KIND} is absent, the
10874 return value has the default integer kind otherwise the specified kind.
10875
10876 @item @emph{Example}:
10877 @smallexample
10878 PROGRAM test_shape
10879   INTEGER, DIMENSION(-1:1, -1:2) :: A
10880   WRITE(*,*) SHAPE(A)             ! (/ 3, 4 /)
10881   WRITE(*,*) SIZE(SHAPE(42))      ! (/ /)
10882 END PROGRAM
10883 @end smallexample
10884
10885 @item @emph{See also}:
10886 @ref{RESHAPE}, @ref{SIZE}
10887 @end table
10888
10889
10890
10891 @node SHIFTA
10892 @section @code{SHIFTA} --- Right shift with fill
10893 @fnindex SHIFTA
10894 @cindex bits, shift right
10895 @cindex shift, right with fill
10896
10897 @table @asis
10898 @item @emph{Description}:
10899 @code{SHIFTA} returns a value corresponding to @var{I} with all of the
10900 bits shifted right by @var{SHIFT} places.  If the absolute value of
10901 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
10902 Bits shifted out from the right end are lost. The fill is arithmetic: the
10903 bits shifted in from the left end are equal to the leftmost bit, which in
10904 two's complement representation is the sign bit.
10905
10906 @item @emph{Standard}:
10907 Fortran 2008 and later
10908
10909 @item @emph{Class}:
10910 Elemental function
10911
10912 @item @emph{Syntax}:
10913 @code{RESULT = SHIFTA(I, SHIFT)}
10914
10915 @item @emph{Arguments}:
10916 @multitable @columnfractions .15 .70
10917 @item @var{I} @tab The type shall be @code{INTEGER}.
10918 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
10919 @end multitable
10920
10921 @item @emph{Return value}:
10922 The return value is of type @code{INTEGER} and of the same kind as
10923 @var{I}.
10924
10925 @item @emph{See also}:
10926 @ref{SHIFTL}, @ref{SHIFTR}
10927 @end table
10928
10929
10930
10931 @node SHIFTL
10932 @section @code{SHIFTL} --- Left shift
10933 @fnindex SHIFTL
10934 @cindex bits, shift left
10935 @cindex shift, left
10936
10937 @table @asis
10938 @item @emph{Description}:
10939 @code{SHIFTL} returns a value corresponding to @var{I} with all of the
10940 bits shifted left by @var{SHIFT} places.  If the absolute value of
10941 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
10942 Bits shifted out from the left end are lost, and bits shifted in from
10943 the right end are set to 0.
10944
10945 @item @emph{Standard}:
10946 Fortran 2008 and later
10947
10948 @item @emph{Class}:
10949 Elemental function
10950
10951 @item @emph{Syntax}:
10952 @code{RESULT = SHIFTL(I, SHIFT)}
10953
10954 @item @emph{Arguments}:
10955 @multitable @columnfractions .15 .70
10956 @item @var{I} @tab The type shall be @code{INTEGER}.
10957 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
10958 @end multitable
10959
10960 @item @emph{Return value}:
10961 The return value is of type @code{INTEGER} and of the same kind as
10962 @var{I}.
10963
10964 @item @emph{See also}:
10965 @ref{SHIFTA}, @ref{SHIFTR}
10966 @end table
10967
10968
10969
10970 @node SHIFTR
10971 @section @code{SHIFTR} --- Right shift
10972 @fnindex SHIFTR
10973 @cindex bits, shift right
10974 @cindex shift, right
10975
10976 @table @asis
10977 @item @emph{Description}:
10978 @code{SHIFTR} returns a value corresponding to @var{I} with all of the
10979 bits shifted right by @var{SHIFT} places.  If the absolute value of
10980 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
10981 Bits shifted out from the right end are lost, and bits shifted in from
10982 the left end are set to 0.
10983
10984 @item @emph{Standard}:
10985 Fortran 2008 and later
10986
10987 @item @emph{Class}:
10988 Elemental function
10989
10990 @item @emph{Syntax}:
10991 @code{RESULT = SHIFTR(I, SHIFT)}
10992
10993 @item @emph{Arguments}:
10994 @multitable @columnfractions .15 .70
10995 @item @var{I} @tab The type shall be @code{INTEGER}.
10996 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
10997 @end multitable
10998
10999 @item @emph{Return value}:
11000 The return value is of type @code{INTEGER} and of the same kind as
11001 @var{I}.
11002
11003 @item @emph{See also}:
11004 @ref{SHIFTA}, @ref{SHIFTL}
11005 @end table
11006
11007
11008
11009 @node SIGN
11010 @section @code{SIGN} --- Sign copying function
11011 @fnindex SIGN
11012 @fnindex ISIGN
11013 @fnindex DSIGN
11014 @cindex sign copying
11015
11016 @table @asis
11017 @item @emph{Description}:
11018 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
11019
11020 @item @emph{Standard}:
11021 Fortran 77 and later
11022
11023 @item @emph{Class}:
11024 Elemental function
11025
11026 @item @emph{Syntax}:
11027 @code{RESULT = SIGN(A, B)}
11028
11029 @item @emph{Arguments}:
11030 @multitable @columnfractions .15 .70
11031 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
11032 @item @var{B} @tab Shall be of the same type and kind as @var{A}
11033 @end multitable
11034
11035 @item @emph{Return value}:
11036 The kind of the return value is that of @var{A} and @var{B}.
11037 If @math{B\ge 0} then the result is @code{ABS(A)}, else
11038 it is @code{-ABS(A)}.
11039
11040 @item @emph{Example}:
11041 @smallexample
11042 program test_sign
11043   print *, sign(-12,1)
11044   print *, sign(-12,0)
11045   print *, sign(-12,-1)
11046
11047   print *, sign(-12.,1.)
11048   print *, sign(-12.,0.)
11049   print *, sign(-12.,-1.)
11050 end program test_sign
11051 @end smallexample
11052
11053 @item @emph{Specific names}:
11054 @multitable @columnfractions .20 .20 .20 .25
11055 @item Name              @tab Arguments              @tab Return type       @tab Standard
11056 @item @code{SIGN(A,B)}  @tab @code{REAL(4) A, B}    @tab @code{REAL(4)}    @tab f77, gnu
11057 @item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab f77, gnu
11058 @item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B}    @tab @code{REAL(8)}    @tab f77, gnu
11059 @end multitable
11060 @end table
11061
11062
11063
11064 @node SIGNAL
11065 @section @code{SIGNAL} --- Signal handling subroutine (or function)
11066 @fnindex SIGNAL
11067 @cindex system, signal handling
11068
11069 @table @asis
11070 @item @emph{Description}:
11071 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
11072 @var{HANDLER} to be executed with a single integer argument when signal
11073 @var{NUMBER} occurs.  If @var{HANDLER} is an integer, it can be used to
11074 turn off handling of signal @var{NUMBER} or revert to its default
11075 action.  See @code{signal(2)}.
11076
11077 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
11078 is supplied, it is set to the value returned by @code{signal(2)}.
11079
11080 @item @emph{Standard}:
11081 GNU extension
11082
11083 @item @emph{Class}:
11084 Subroutine, function
11085
11086 @item @emph{Syntax}:
11087 @multitable @columnfractions .80
11088 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
11089 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
11090 @end multitable
11091
11092 @item @emph{Arguments}:
11093 @multitable @columnfractions .15 .70
11094 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
11095 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
11096 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
11097 @code{INTEGER}. It is @code{INTENT(IN)}.
11098 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
11099 integer. It has @code{INTENT(OUT)}.
11100 @end multitable
11101 @c TODO: What should the interface of the handler be?  Does it take arguments?
11102
11103 @item @emph{Return value}:
11104 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
11105
11106 @item @emph{Example}:
11107 @smallexample
11108 program test_signal
11109   intrinsic signal
11110   external handler_print
11111
11112   call signal (12, handler_print)
11113   call signal (10, 1)
11114
11115   call sleep (30)
11116 end program test_signal
11117 @end smallexample
11118 @end table
11119
11120
11121
11122 @node SIN
11123 @section @code{SIN} --- Sine function 
11124 @fnindex SIN
11125 @fnindex DSIN
11126 @fnindex CSIN
11127 @fnindex ZSIN
11128 @fnindex CDSIN
11129 @cindex trigonometric function, sine
11130 @cindex sine
11131
11132 @table @asis
11133 @item @emph{Description}:
11134 @code{SIN(X)} computes the sine of @var{X}.
11135
11136 @item @emph{Standard}:
11137 Fortran 77 and later
11138
11139 @item @emph{Class}:
11140 Elemental function
11141
11142 @item @emph{Syntax}:
11143 @code{RESULT = SIN(X)}
11144
11145 @item @emph{Arguments}:
11146 @multitable @columnfractions .15 .70
11147 @item @var{X} @tab The type shall be @code{REAL} or
11148 @code{COMPLEX}.
11149 @end multitable
11150
11151 @item @emph{Return value}:
11152 The return value has same type and kind as @var{X}.
11153
11154 @item @emph{Example}:
11155 @smallexample
11156 program test_sin
11157   real :: x = 0.0
11158   x = sin(x)
11159 end program test_sin
11160 @end smallexample
11161
11162 @item @emph{Specific names}:
11163 @multitable @columnfractions .20 .20 .20 .25
11164 @item Name            @tab Argument             @tab Return type       @tab Standard
11165 @item @code{SIN(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}    @tab f77, gnu
11166 @item @code{DSIN(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}    @tab f95, gnu
11167 @item @code{CSIN(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)} @tab f95, gnu
11168 @item @code{ZSIN(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)} @tab f95, gnu
11169 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)} @tab f95, gnu
11170 @end multitable
11171
11172 @item @emph{See also}:
11173 @ref{ASIN}
11174 @end table
11175
11176
11177
11178 @node SINH
11179 @section @code{SINH} --- Hyperbolic sine function 
11180 @fnindex SINH
11181 @fnindex DSINH
11182 @cindex hyperbolic sine
11183 @cindex hyperbolic function, sine
11184 @cindex sine, hyperbolic
11185
11186 @table @asis
11187 @item @emph{Description}:
11188 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
11189
11190 @item @emph{Standard}:
11191 Fortran 95 and later, for a complex argument Fortran 2008 or later
11192
11193 @item @emph{Class}:
11194 Elemental function
11195
11196 @item @emph{Syntax}:
11197 @code{RESULT = SINH(X)}
11198
11199 @item @emph{Arguments}:
11200 @multitable @columnfractions .15 .70
11201 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
11202 @end multitable
11203
11204 @item @emph{Return value}:
11205 The return value has same type and kind as @var{X}.
11206
11207 @item @emph{Example}:
11208 @smallexample
11209 program test_sinh
11210   real(8) :: x = - 1.0_8
11211   x = sinh(x)
11212 end program test_sinh
11213 @end smallexample
11214
11215 @item @emph{Specific names}:
11216 @multitable @columnfractions .20 .20 .20 .25
11217 @item Name            @tab Argument          @tab Return type       @tab Standard
11218 @item @code{SINH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
11219 @item @code{DSINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
11220 @end multitable
11221
11222 @item @emph{See also}:
11223 @ref{ASINH}
11224 @end table
11225
11226
11227
11228 @node SIZE
11229 @section @code{SIZE} --- Determine the size of an array
11230 @fnindex SIZE
11231 @cindex array, size
11232 @cindex array, number of elements
11233 @cindex array, count elements
11234
11235 @table @asis
11236 @item @emph{Description}:
11237 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
11238 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
11239
11240 @item @emph{Standard}:
11241 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
11242
11243 @item @emph{Class}:
11244 Inquiry function
11245
11246 @item @emph{Syntax}:
11247 @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
11248
11249 @item @emph{Arguments}:
11250 @multitable @columnfractions .15 .70
11251 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
11252 a pointer it must be associated and allocatable arrays must be allocated.
11253 @item @var{DIM}   @tab (Optional) shall be a scalar of type @code{INTEGER} 
11254 and its value shall be in the range from 1 to n, where n equals the rank 
11255 of @var{ARRAY}.
11256 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
11257 expression indicating the kind parameter of the result.
11258 @end multitable
11259
11260 @item @emph{Return value}:
11261 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11262 @var{KIND} is absent, the return value is of default integer kind.
11263
11264 @item @emph{Example}:
11265 @smallexample
11266 PROGRAM test_size
11267   WRITE(*,*) SIZE((/ 1, 2 /))    ! 2
11268 END PROGRAM
11269 @end smallexample
11270
11271 @item @emph{See also}:
11272 @ref{SHAPE}, @ref{RESHAPE}
11273 @end table
11274
11275
11276 @node SIZEOF
11277 @section @code{SIZEOF} --- Size in bytes of an expression
11278 @fnindex SIZEOF
11279 @cindex expression size
11280 @cindex size of an expression
11281
11282 @table @asis
11283 @item @emph{Description}:
11284 @code{SIZEOF(X)} calculates the number of bytes of storage the
11285 expression @code{X} occupies.
11286
11287 @item @emph{Standard}:
11288 GNU extension
11289
11290 @item @emph{Class}:
11291 Intrinsic function
11292
11293 @item @emph{Syntax}:
11294 @code{N = SIZEOF(X)}
11295
11296 @item @emph{Arguments}:
11297 @multitable @columnfractions .15 .70
11298 @item @var{X} @tab The argument shall be of any type, rank or shape.
11299 @end multitable
11300
11301 @item @emph{Return value}:
11302 The return value is of type integer and of the system-dependent kind
11303 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
11304 number of bytes occupied by the argument.  If the argument has the
11305 @code{POINTER} attribute, the number of bytes of the storage area pointed
11306 to is returned.  If the argument is of a derived type with @code{POINTER}
11307 or @code{ALLOCATABLE} components, the return value doesn't account for
11308 the sizes of the data pointed to by these components. If the argument is
11309 polymorphic, the size according to the declared type is returned.
11310
11311 @item @emph{Example}:
11312 @smallexample
11313    integer :: i
11314    real :: r, s(5)
11315    print *, (sizeof(s)/sizeof(r) == 5)
11316    end
11317 @end smallexample
11318 The example will print @code{.TRUE.} unless you are using a platform
11319 where default @code{REAL} variables are unusually padded.
11320
11321 @item @emph{See also}:
11322 @ref{C_SIZEOF}, @ref{STORAGE_SIZE}
11323 @end table
11324
11325
11326 @node SLEEP
11327 @section @code{SLEEP} --- Sleep for the specified number of seconds
11328 @fnindex SLEEP
11329 @cindex delayed execution
11330
11331 @table @asis
11332 @item @emph{Description}:
11333 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
11334
11335 @item @emph{Standard}:
11336 GNU extension
11337
11338 @item @emph{Class}:
11339 Subroutine
11340
11341 @item @emph{Syntax}:
11342 @code{CALL SLEEP(SECONDS)}
11343
11344 @item @emph{Arguments}:
11345 @multitable @columnfractions .15 .70
11346 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
11347 @end multitable
11348
11349 @item @emph{Example}:
11350 @smallexample
11351 program test_sleep
11352   call sleep(5)
11353 end
11354 @end smallexample
11355 @end table
11356
11357
11358
11359 @node SPACING
11360 @section @code{SPACING} --- Smallest distance between two numbers of a given type
11361 @fnindex SPACING
11362 @cindex real number, relative spacing
11363 @cindex floating point, relative spacing
11364
11365 @table @asis
11366 @item @emph{Description}:
11367 Determines the distance between the argument @var{X} and the nearest 
11368 adjacent number of the same type.
11369
11370 @item @emph{Standard}:
11371 Fortran 95 and later
11372
11373 @item @emph{Class}:
11374 Elemental function
11375
11376 @item @emph{Syntax}:
11377 @code{RESULT = SPACING(X)}
11378
11379 @item @emph{Arguments}:
11380 @multitable @columnfractions .15 .70
11381 @item @var{X} @tab Shall be of type @code{REAL}.
11382 @end multitable
11383
11384 @item @emph{Return value}:
11385 The result is of the same type as the input argument @var{X}.
11386
11387 @item @emph{Example}:
11388 @smallexample
11389 PROGRAM test_spacing
11390   INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
11391   INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
11392
11393   WRITE(*,*) spacing(1.0_SGL)      ! "1.1920929E-07"          on i686
11394   WRITE(*,*) spacing(1.0_DBL)      ! "2.220446049250313E-016" on i686
11395 END PROGRAM
11396 @end smallexample
11397
11398 @item @emph{See also}:
11399 @ref{RRSPACING}
11400 @end table
11401
11402
11403
11404 @node SPREAD
11405 @section @code{SPREAD} --- Add a dimension to an array
11406 @fnindex SPREAD
11407 @cindex array, increase dimension
11408 @cindex array, duplicate elements
11409 @cindex array, duplicate dimensions
11410
11411 @table @asis
11412 @item @emph{Description}:
11413 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified 
11414 dimension @var{DIM}.
11415
11416 @item @emph{Standard}:
11417 Fortran 95 and later
11418
11419 @item @emph{Class}:
11420 Transformational function
11421
11422 @item @emph{Syntax}:
11423 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
11424
11425 @item @emph{Arguments}:
11426 @multitable @columnfractions .15 .70
11427 @item @var{SOURCE}  @tab Shall be a scalar or an array of any type and 
11428 a rank less than seven.
11429 @item @var{DIM}     @tab Shall be a scalar of type @code{INTEGER} with a 
11430 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
11431 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
11432 @end multitable
11433
11434 @item @emph{Return value}:
11435 The result is an array of the same type as @var{SOURCE} and has rank n+1
11436 where n equals the rank of @var{SOURCE}.
11437
11438 @item @emph{Example}:
11439 @smallexample
11440 PROGRAM test_spread
11441   INTEGER :: a = 1, b(2) = (/ 1, 2 /)
11442   WRITE(*,*) SPREAD(A, 1, 2)            ! "1 1"
11443   WRITE(*,*) SPREAD(B, 1, 2)            ! "1 1 2 2"
11444 END PROGRAM
11445 @end smallexample
11446
11447 @item @emph{See also}:
11448 @ref{UNPACK}
11449 @end table
11450
11451
11452
11453 @node SQRT
11454 @section @code{SQRT} --- Square-root function
11455 @fnindex SQRT
11456 @fnindex DSQRT
11457 @fnindex CSQRT
11458 @fnindex ZSQRT
11459 @fnindex CDSQRT
11460 @cindex root
11461 @cindex square-root
11462
11463 @table @asis
11464 @item @emph{Description}:
11465 @code{SQRT(X)} computes the square root of @var{X}.
11466
11467 @item @emph{Standard}:
11468 Fortran 77 and later
11469
11470 @item @emph{Class}:
11471 Elemental function
11472
11473 @item @emph{Syntax}:
11474 @code{RESULT = SQRT(X)}
11475
11476 @item @emph{Arguments}:
11477 @multitable @columnfractions .15 .70
11478 @item @var{X} @tab The type shall be @code{REAL} or
11479 @code{COMPLEX}.
11480 @end multitable
11481
11482 @item @emph{Return value}:
11483 The return value is of type @code{REAL} or @code{COMPLEX}.
11484 The kind type parameter is the same as @var{X}.
11485
11486 @item @emph{Example}:
11487 @smallexample
11488 program test_sqrt
11489   real(8) :: x = 2.0_8
11490   complex :: z = (1.0, 2.0)
11491   x = sqrt(x)
11492   z = sqrt(z)
11493 end program test_sqrt
11494 @end smallexample
11495
11496 @item @emph{Specific names}:
11497 @multitable @columnfractions .20 .20 .20 .25
11498 @item Name             @tab Argument             @tab Return type          @tab Standard
11499 @item @code{SQRT(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}       @tab Fortran 95 and later
11500 @item @code{DSQRT(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}       @tab Fortran 95 and later
11501 @item @code{CSQRT(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab Fortran 95 and later
11502 @item @code{ZSQRT(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
11503 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
11504 @end multitable
11505 @end table
11506
11507
11508
11509 @node SRAND
11510 @section @code{SRAND} --- Reinitialize the random number generator
11511 @fnindex SRAND
11512 @cindex random number generation, seeding
11513 @cindex seeding a random number generator
11514
11515 @table @asis
11516 @item @emph{Description}:
11517 @code{SRAND} reinitializes the pseudo-random number generator
11518 called by @code{RAND} and @code{IRAND}. The new seed used by the
11519 generator is specified by the required argument @var{SEED}.
11520
11521 @item @emph{Standard}:
11522 GNU extension
11523
11524 @item @emph{Class}:
11525 Subroutine
11526
11527 @item @emph{Syntax}:
11528 @code{CALL SRAND(SEED)}
11529
11530 @item @emph{Arguments}:
11531 @multitable @columnfractions .15 .70
11532 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
11533 @end multitable
11534
11535 @item @emph{Return value}:
11536 Does not return anything.
11537
11538 @item @emph{Example}:
11539 See @code{RAND} and @code{IRAND} for examples.
11540
11541 @item @emph{Notes}:
11542 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
11543 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
11544 to generate pseudo-random numbers. Please note that in
11545 GNU Fortran, these two sets of intrinsics (@code{RAND},
11546 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
11547 @code{RANDOM_SEED} on the other hand) access two independent
11548 pseudo-random number generators.
11549
11550 @item @emph{See also}:
11551 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
11552
11553 @end table
11554
11555
11556
11557 @node STAT
11558 @section @code{STAT} --- Get file status
11559 @fnindex STAT
11560 @cindex file system, file status
11561
11562 @table @asis
11563 @item @emph{Description}:
11564 This function returns information about a file. No permissions are required on 
11565 the file itself, but execute (search) permission is required on all of the 
11566 directories in path that lead to the file.
11567
11568 The elements that are obtained and stored in the array @code{VALUES}:
11569 @multitable @columnfractions .15 .70
11570 @item @code{VALUES(1)}   @tab  Device ID 
11571 @item @code{VALUES(2)}   @tab  Inode number 
11572 @item @code{VALUES(3)}   @tab  File mode 
11573 @item @code{VALUES(4)}   @tab  Number of links 
11574 @item @code{VALUES(5)}   @tab  Owner's uid 
11575 @item @code{VALUES(6)}   @tab  Owner's gid 
11576 @item @code{VALUES(7)}   @tab  ID of device containing directory entry for file (0 if not available) 
11577 @item @code{VALUES(8)}   @tab  File size (bytes) 
11578 @item @code{VALUES(9)}   @tab  Last access time 
11579 @item @code{VALUES(10)}  @tab  Last modification time 
11580 @item @code{VALUES(11)}  @tab  Last file status change time 
11581 @item @code{VALUES(12)}  @tab  Preferred I/O block size (-1 if not available) 
11582 @item @code{VALUES(13)}  @tab  Number of blocks allocated (-1 if not available)
11583 @end multitable
11584
11585 Not all these elements are relevant on all systems. 
11586 If an element is not relevant, it is returned as 0.
11587
11588 This intrinsic is provided in both subroutine and function forms; however,
11589 only one form can be used in any given program unit.
11590
11591 @item @emph{Standard}:
11592 GNU extension
11593
11594 @item @emph{Class}:
11595 Subroutine, function
11596
11597 @item @emph{Syntax}:
11598 @multitable @columnfractions .80
11599 @item @code{CALL STAT(NAME, VALUES [, STATUS])}
11600 @item @code{STATUS = STAT(NAME, VALUES)}
11601 @end multitable
11602
11603 @item @emph{Arguments}:
11604 @multitable @columnfractions .15 .70
11605 @item @var{NAME}   @tab The type shall be @code{CHARACTER}, of the
11606 default kind and a valid path within the file system.
11607 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
11608 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
11609 on success and a system specific error code otherwise.
11610 @end multitable
11611
11612 @item @emph{Example}:
11613 @smallexample
11614 PROGRAM test_stat
11615   INTEGER, DIMENSION(13) :: buff
11616   INTEGER :: status
11617
11618   CALL STAT("/etc/passwd", buff, status)
11619
11620   IF (status == 0) THEN
11621     WRITE (*, FMT="('Device ID:',               T30, I19)") buff(1)
11622     WRITE (*, FMT="('Inode number:',            T30, I19)") buff(2)
11623     WRITE (*, FMT="('File mode (octal):',       T30, O19)") buff(3)
11624     WRITE (*, FMT="('Number of links:',         T30, I19)") buff(4)
11625     WRITE (*, FMT="('Owner''s uid:',            T30, I19)") buff(5)
11626     WRITE (*, FMT="('Owner''s gid:',            T30, I19)") buff(6)
11627     WRITE (*, FMT="('Device where located:',    T30, I19)") buff(7)
11628     WRITE (*, FMT="('File size:',               T30, I19)") buff(8)
11629     WRITE (*, FMT="('Last access time:',        T30, A19)") CTIME(buff(9))
11630     WRITE (*, FMT="('Last modification time',   T30, A19)") CTIME(buff(10))
11631     WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
11632     WRITE (*, FMT="('Preferred block size:',    T30, I19)") buff(12)
11633     WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
11634   END IF
11635 END PROGRAM
11636 @end smallexample
11637
11638 @item @emph{See also}:
11639 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
11640 @end table
11641
11642
11643
11644 @node STORAGE_SIZE
11645 @section @code{STORAGE_SIZE} --- Storage size in bits
11646 @fnindex STORAGE_SIZE
11647 @cindex storage size
11648
11649 @table @asis
11650 @item @emph{Description}:
11651 Returns the storage size of argument @var{A} in bits.
11652 @item @emph{Standard}:
11653 Fortran 2008 and later
11654 @item @emph{Class}:
11655 Inquiry function
11656 @item @emph{Syntax}:
11657 @code{RESULT = STORAGE_SIZE(A [, KIND])}
11658
11659 @item @emph{Arguments}:
11660 @multitable @columnfractions .15 .70
11661 @item @var{A} @tab Shall be a scalar or array of any type.
11662 @item @var{KIND} @tab (Optional) shall be a scalar integer constant expression.
11663 @end multitable
11664
11665 @item @emph{Return Value}:
11666 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
11667 has the dynamic type and type parameters of A.
11668
11669 @item @emph{See also}:
11670 @ref{C_SIZEOF}, @ref{SIZEOF}
11671 @end table
11672
11673
11674
11675 @node SUM
11676 @section @code{SUM} --- Sum of array elements
11677 @fnindex SUM
11678 @cindex array, sum
11679 @cindex array, add elements
11680 @cindex array, conditionally add elements
11681 @cindex sum array elements
11682
11683 @table @asis
11684 @item @emph{Description}:
11685 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
11686 the corresponding element in @var{MASK} is @code{TRUE}.
11687
11688 @item @emph{Standard}:
11689 Fortran 95 and later
11690
11691 @item @emph{Class}:
11692 Transformational function
11693
11694 @item @emph{Syntax}:
11695 @multitable @columnfractions .80
11696 @item @code{RESULT = SUM(ARRAY[, MASK])}
11697 @item @code{RESULT = SUM(ARRAY, DIM[, MASK])}
11698 @end multitable
11699
11700 @item @emph{Arguments}:
11701 @multitable @columnfractions .15 .70
11702 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
11703 @code{REAL} or @code{COMPLEX}.
11704 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
11705 @code{INTEGER} with a value in the range from 1 to n, where n 
11706 equals the rank of @var{ARRAY}.
11707 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
11708 and either be a scalar or an array of the same shape as @var{ARRAY}.
11709 @end multitable
11710
11711 @item @emph{Return value}:
11712 The result is of the same type as @var{ARRAY}.
11713
11714 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
11715 is returned. Otherwise, an array of rank n-1, where n equals the rank of 
11716 @var{ARRAY}, and a shape similar to that of @var{ARRAY} with dimension @var{DIM} 
11717 dropped is returned.
11718
11719 @item @emph{Example}:
11720 @smallexample
11721 PROGRAM test_sum
11722   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
11723   print *, SUM(x)                        ! all elements, sum = 15
11724   print *, SUM(x, MASK=MOD(x, 2)==1)     ! odd elements, sum = 9
11725 END PROGRAM
11726 @end smallexample
11727
11728 @item @emph{See also}:
11729 @ref{PRODUCT}
11730 @end table
11731
11732
11733
11734 @node SYMLNK
11735 @section @code{SYMLNK} --- Create a symbolic link
11736 @fnindex SYMLNK
11737 @cindex file system, create link
11738 @cindex file system, soft link
11739
11740 @table @asis
11741 @item @emph{Description}:
11742 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
11743 character (@code{CHAR(0)}) can be used to mark the end of the names in
11744 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
11745 names are ignored.  If the @var{STATUS} argument is supplied, it
11746 contains 0 on success or a nonzero error code upon return; see
11747 @code{symlink(2)}.  If the system does not supply @code{symlink(2)}, 
11748 @code{ENOSYS} is returned.
11749
11750 This intrinsic is provided in both subroutine and function forms;
11751 however, only one form can be used in any given program unit.
11752
11753 @item @emph{Standard}:
11754 GNU extension
11755
11756 @item @emph{Class}:
11757 Subroutine, function
11758
11759 @item @emph{Syntax}:
11760 @multitable @columnfractions .80
11761 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
11762 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
11763 @end multitable
11764
11765 @item @emph{Arguments}:
11766 @multitable @columnfractions .15 .70
11767 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
11768 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
11769 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
11770 @end multitable
11771
11772 @item @emph{See also}:
11773 @ref{LINK}, @ref{UNLINK}
11774
11775 @end table
11776
11777
11778
11779 @node SYSTEM
11780 @section @code{SYSTEM} --- Execute a shell command
11781 @fnindex SYSTEM
11782 @cindex system, system call
11783
11784 @table @asis
11785 @item @emph{Description}:
11786 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
11787 argument @var{STATUS} is present, it contains the value returned by
11788 @code{system(3)}, which is presumably 0 if the shell command succeeded.
11789 Note that which shell is used to invoke the command is system-dependent
11790 and environment-dependent.
11791
11792 This intrinsic is provided in both subroutine and function forms;
11793 however, only one form can be used in any given program unit.
11794
11795 Note that the @code{system} function need not be thread-safe. It is
11796 the responsibility of the user to ensure that @code{system} is not
11797 called concurrently.
11798
11799 @item @emph{Standard}:
11800 GNU extension
11801
11802 @item @emph{Class}:
11803 Subroutine, function
11804
11805 @item @emph{Syntax}:
11806 @multitable @columnfractions .80
11807 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
11808 @item @code{STATUS = SYSTEM(COMMAND)}
11809 @end multitable
11810
11811 @item @emph{Arguments}:
11812 @multitable @columnfractions .15 .70
11813 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
11814 @item @var{STATUS}  @tab (Optional) Shall be of default @code{INTEGER} type.
11815 @end multitable
11816
11817 @item @emph{See also}:
11818 @ref{EXECUTE_COMMAND_LINE}, which is part of the Fortran 2008 standard
11819 and should considered in new code for future portability.
11820 @end table
11821
11822
11823
11824 @node SYSTEM_CLOCK
11825 @section @code{SYSTEM_CLOCK} --- Time function
11826 @fnindex SYSTEM_CLOCK
11827 @cindex time, clock ticks
11828 @cindex clock ticks
11829
11830 @table @asis
11831 @item @emph{Description}:
11832 Determines the @var{COUNT} of a processor clock since an unspecified
11833 time in the past modulo @var{COUNT_MAX}, @var{COUNT_RATE} determines
11834 the number of clock ticks per second.  If the platform supports a high
11835 resolution monotonic clock, that clock is used and can provide up to
11836 nanosecond resolution.  If a high resolution monotonic clock is not
11837 available, the implementation falls back to a potentially lower
11838 resolution realtime clock.
11839
11840 @var{COUNT_RATE} and @var{COUNT_MAX} vary depending on the kind of the
11841 arguments.  For @var{kind=8} arguments, @var{COUNT} represents
11842 nanoseconds, and for @var{kind=4} arguments, @var{COUNT} represents
11843 milliseconds. Other than the kind dependency, @var{COUNT_RATE} and
11844 @var{COUNT_MAX} are constant, however the particular values are
11845 specific to @command{gfortran}.
11846
11847 If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and
11848 @var{COUNT_RATE} and @var{COUNT_MAX} are set to zero.
11849
11850 When running on a platform using the GNU C library (glibc), or a
11851 derivative thereof, the high resolution monotonic clock is available
11852 only when linking with the @var{rt} library.  This can be done
11853 explicitly by adding the @code{-lrt} flag when linking the
11854 application, but is also done implicitly when using OpenMP.
11855
11856 @item @emph{Standard}:
11857 Fortran 95 and later
11858
11859 @item @emph{Class}:
11860 Subroutine
11861
11862 @item @emph{Syntax}:
11863 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
11864
11865 @item @emph{Arguments}:
11866 @multitable @columnfractions .15 .70
11867 @item @var{COUNT}      @tab (Optional) shall be a scalar of type 
11868 @code{INTEGER} with @code{INTENT(OUT)}.
11869 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type 
11870 @code{INTEGER} with @code{INTENT(OUT)}.
11871 @item @var{COUNT_MAX}  @tab (Optional) shall be a scalar of type 
11872 @code{INTEGER} with @code{INTENT(OUT)}.
11873 @end multitable
11874
11875 @item @emph{Example}:
11876 @smallexample
11877 PROGRAM test_system_clock
11878   INTEGER :: count, count_rate, count_max
11879   CALL SYSTEM_CLOCK(count, count_rate, count_max)
11880   WRITE(*,*) count, count_rate, count_max
11881 END PROGRAM
11882 @end smallexample
11883
11884 @item @emph{See also}:
11885 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
11886 @end table
11887
11888
11889
11890 @node TAN
11891 @section @code{TAN} --- Tangent function
11892 @fnindex TAN
11893 @fnindex DTAN
11894 @cindex trigonometric function, tangent
11895 @cindex tangent
11896
11897 @table @asis
11898 @item @emph{Description}:
11899 @code{TAN(X)} computes the tangent of @var{X}.
11900
11901 @item @emph{Standard}:
11902 Fortran 77 and later, for a complex argument Fortran 2008 or later
11903
11904 @item @emph{Class}:
11905 Elemental function
11906
11907 @item @emph{Syntax}:
11908 @code{RESULT = TAN(X)}
11909
11910 @item @emph{Arguments}:
11911 @multitable @columnfractions .15 .70
11912 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
11913 @end multitable
11914
11915 @item @emph{Return value}:
11916 The return value has same type and kind as @var{X}.
11917
11918 @item @emph{Example}:
11919 @smallexample
11920 program test_tan
11921   real(8) :: x = 0.165_8
11922   x = tan(x)
11923 end program test_tan
11924 @end smallexample
11925
11926 @item @emph{Specific names}:
11927 @multitable @columnfractions .20 .20 .20 .25
11928 @item Name            @tab Argument          @tab Return type     @tab Standard
11929 @item @code{TAN(X)}   @tab @code{REAL(4) X}  @tab @code{REAL(4)}  @tab Fortran 95 and later
11930 @item @code{DTAN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}  @tab Fortran 95 and later
11931 @end multitable
11932
11933 @item @emph{See also}:
11934 @ref{ATAN}
11935 @end table
11936
11937
11938
11939 @node TANH
11940 @section @code{TANH} --- Hyperbolic tangent function 
11941 @fnindex TANH
11942 @fnindex DTANH
11943 @cindex hyperbolic tangent
11944 @cindex hyperbolic function, tangent
11945 @cindex tangent, hyperbolic
11946
11947 @table @asis
11948 @item @emph{Description}:
11949 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
11950
11951 @item @emph{Standard}:
11952 Fortran 77 and later, for a complex argument Fortran 2008 or later
11953
11954 @item @emph{Class}:
11955 Elemental function
11956
11957 @item @emph{Syntax}:
11958 @code{X = TANH(X)}
11959
11960 @item @emph{Arguments}:
11961 @multitable @columnfractions .15 .70
11962 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
11963 @end multitable
11964
11965 @item @emph{Return value}:
11966 The return value has same type and kind as @var{X}. If @var{X} is
11967 complex, the imaginary part of the result is in radians. If @var{X}
11968 is @code{REAL}, the return value lies in the range
11969 @math{ - 1 \leq tanh(x) \leq 1 }.
11970
11971 @item @emph{Example}:
11972 @smallexample
11973 program test_tanh
11974   real(8) :: x = 2.1_8
11975   x = tanh(x)
11976 end program test_tanh
11977 @end smallexample
11978
11979 @item @emph{Specific names}:
11980 @multitable @columnfractions .20 .20 .20 .25
11981 @item Name            @tab Argument          @tab Return type       @tab Standard
11982 @item @code{TANH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
11983 @item @code{DTANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
11984 @end multitable
11985
11986 @item @emph{See also}:
11987 @ref{ATANH}
11988 @end table
11989
11990
11991
11992 @node THIS_IMAGE
11993 @section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image
11994 @fnindex THIS_IMAGE
11995 @cindex coarray, @code{THIS_IMAGE}
11996 @cindex images, index of this image
11997
11998 @table @asis
11999 @item @emph{Description}:
12000 Returns the cosubscript for this image.
12001
12002 @item @emph{Standard}:
12003 Fortran 2008 and later
12004
12005 @item @emph{Class}:
12006 Transformational function
12007
12008 @item @emph{Syntax}:
12009 @multitable @columnfractions .80
12010 @item @code{RESULT = THIS_IMAGE()}
12011 @item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])}
12012 @end multitable
12013
12014 @item @emph{Arguments}:
12015 @multitable @columnfractions .15 .70
12016 @item @var{COARRAY} @tab Coarray of any type  (optional; if @var{DIM}
12017 present, required).
12018 @item @var{DIM}     @tab default integer scalar (optional). If present,
12019 @var{DIM} shall be between one and the corank of @var{COARRAY}.
12020 @end multitable
12021
12022
12023 @item @emph{Return value}:
12024 Default integer. If @var{COARRAY} is not present, it is scalar and its value
12025 is the index of the invoking image. Otherwise, if @var{DIM} is not present,
12026 a rank-1 array with corank elements is returned, containing the cosubscripts
12027 for @var{COARRAY} specifying the invoking image. If @var{DIM} is present,
12028 a scalar is returned, with the value of the @var{DIM} element of
12029 @code{THIS_IMAGE(COARRAY)}.
12030
12031 @item @emph{Example}:
12032 @smallexample
12033 INTEGER :: value[*]
12034 INTEGER :: i
12035 value = THIS_IMAGE()
12036 SYNC ALL
12037 IF (THIS_IMAGE() == 1) THEN
12038   DO i = 1, NUM_IMAGES()
12039     WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
12040   END DO
12041 END IF
12042 @end smallexample
12043
12044 @item @emph{See also}:
12045 @ref{NUM_IMAGES}, @ref{IMAGE_INDEX}
12046 @end table
12047
12048
12049
12050 @node TIME
12051 @section @code{TIME} --- Time function
12052 @fnindex TIME
12053 @cindex time, current
12054 @cindex current time
12055
12056 @table @asis
12057 @item @emph{Description}:
12058 Returns the current time encoded as an integer (in the manner of the
12059 UNIX function @code{time(3)}). This value is suitable for passing to
12060 @code{CTIME}, @code{GMTIME}, and @code{LTIME}.
12061
12062 This intrinsic is not fully portable, such as to systems with 32-bit
12063 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
12064 the values returned by this intrinsic might be, or become, negative, or
12065 numerically less than previous values, during a single run of the
12066 compiled program.
12067
12068 See @ref{TIME8}, for information on a similar intrinsic that might be
12069 portable to more GNU Fortran implementations, though to fewer Fortran
12070 compilers.
12071
12072 @item @emph{Standard}:
12073 GNU extension
12074
12075 @item @emph{Class}:
12076 Function
12077
12078 @item @emph{Syntax}:
12079 @code{RESULT = TIME()}
12080
12081 @item @emph{Return value}:
12082 The return value is a scalar of type @code{INTEGER(4)}.
12083
12084 @item @emph{See also}:
12085 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
12086
12087 @end table
12088
12089
12090
12091 @node TIME8
12092 @section @code{TIME8} --- Time function (64-bit)
12093 @fnindex TIME8
12094 @cindex time, current
12095 @cindex current time
12096
12097 @table @asis
12098 @item @emph{Description}:
12099 Returns the current time encoded as an integer (in the manner of the
12100 UNIX function @code{time(3)}). This value is suitable for passing to
12101 @code{CTIME}, @code{GMTIME}, and @code{LTIME}.
12102
12103 @emph{Warning:} this intrinsic does not increase the range of the timing
12104 values over that returned by @code{time(3)}. On a system with a 32-bit
12105 @code{time(3)}, @code{TIME8} will return a 32-bit value, even though
12106 it is converted to a 64-bit @code{INTEGER(8)} value. That means
12107 overflows of the 32-bit value can still occur. Therefore, the values
12108 returned by this intrinsic might be or become negative or numerically
12109 less than previous values during a single run of the compiled program.
12110
12111 @item @emph{Standard}:
12112 GNU extension
12113
12114 @item @emph{Class}:
12115 Function
12116
12117 @item @emph{Syntax}:
12118 @code{RESULT = TIME8()}
12119
12120 @item @emph{Return value}:
12121 The return value is a scalar of type @code{INTEGER(8)}.
12122
12123 @item @emph{See also}:
12124 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
12125
12126 @end table
12127
12128
12129
12130 @node TINY
12131 @section @code{TINY} --- Smallest positive number of a real kind
12132 @fnindex TINY
12133 @cindex limits, smallest number
12134 @cindex model representation, smallest number
12135
12136 @table @asis
12137 @item @emph{Description}:
12138 @code{TINY(X)} returns the smallest positive (non zero) number
12139 in the model of the type of @code{X}.
12140
12141 @item @emph{Standard}:
12142 Fortran 95 and later
12143
12144 @item @emph{Class}:
12145 Inquiry function
12146
12147 @item @emph{Syntax}:
12148 @code{RESULT = TINY(X)}
12149
12150 @item @emph{Arguments}:
12151 @multitable @columnfractions .15 .70
12152 @item @var{X} @tab Shall be of type @code{REAL}.
12153 @end multitable
12154
12155 @item @emph{Return value}:
12156 The return value is of the same type and kind as @var{X}
12157
12158 @item @emph{Example}:
12159 See @code{HUGE} for an example.
12160 @end table
12161
12162
12163
12164 @node TRAILZ
12165 @section @code{TRAILZ} --- Number of trailing zero bits of an integer
12166 @fnindex TRAILZ
12167 @cindex zero bits
12168
12169 @table @asis
12170 @item @emph{Description}:
12171 @code{TRAILZ} returns the number of trailing zero bits of an integer.
12172
12173 @item @emph{Standard}:
12174 Fortran 2008 and later
12175
12176 @item @emph{Class}:
12177 Elemental function
12178
12179 @item @emph{Syntax}:
12180 @code{RESULT = TRAILZ(I)}
12181
12182 @item @emph{Arguments}:
12183 @multitable @columnfractions .15 .70
12184 @item @var{I} @tab Shall be of type @code{INTEGER}.
12185 @end multitable
12186
12187 @item @emph{Return value}:
12188 The type of the return value is the default @code{INTEGER}.
12189 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
12190
12191 @item @emph{Example}:
12192 @smallexample
12193 PROGRAM test_trailz
12194   WRITE (*,*) TRAILZ(8)  ! prints 3
12195 END PROGRAM
12196 @end smallexample
12197
12198 @item @emph{See also}:
12199 @ref{BIT_SIZE}, @ref{LEADZ}, @ref{POPPAR}, @ref{POPCNT}
12200 @end table
12201
12202
12203
12204 @node TRANSFER
12205 @section @code{TRANSFER} --- Transfer bit patterns
12206 @fnindex TRANSFER
12207 @cindex bits, move
12208 @cindex type cast
12209
12210 @table @asis
12211 @item @emph{Description}:
12212 Interprets the bitwise representation of @var{SOURCE} in memory as if it
12213 is the representation of a variable or array of the same type and type
12214 parameters as @var{MOLD}.
12215
12216 This is approximately equivalent to the C concept of @emph{casting} one
12217 type to another.
12218
12219 @item @emph{Standard}:
12220 Fortran 95 and later
12221
12222 @item @emph{Class}:
12223 Transformational function
12224
12225 @item @emph{Syntax}:
12226 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
12227
12228 @item @emph{Arguments}:
12229 @multitable @columnfractions .15 .70
12230 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
12231 @item @var{MOLD}   @tab Shall be a scalar or an array of any type.
12232 @item @var{SIZE}   @tab (Optional) shall be a scalar of type 
12233 @code{INTEGER}.
12234 @end multitable
12235
12236 @item @emph{Return value}:
12237 The result has the same type as @var{MOLD}, with the bit level
12238 representation of @var{SOURCE}.  If @var{SIZE} is present, the result is
12239 a one-dimensional array of length @var{SIZE}.  If @var{SIZE} is absent
12240 but @var{MOLD} is an array (of any size or shape), the result is a one-
12241 dimensional array of the minimum length needed to contain the entirety
12242 of the bitwise representation of @var{SOURCE}.   If @var{SIZE} is absent
12243 and @var{MOLD} is a scalar, the result is a scalar.
12244
12245 If the bitwise representation of the result is longer than that of
12246 @var{SOURCE}, then the leading bits of the result correspond to those of
12247 @var{SOURCE} and any trailing bits are filled arbitrarily.
12248
12249 When the resulting bit representation does not correspond to a valid
12250 representation of a variable of the same type as @var{MOLD}, the results
12251 are undefined, and subsequent operations on the result cannot be
12252 guaranteed to produce sensible behavior.  For example, it is possible to
12253 create @code{LOGICAL} variables for which @code{@var{VAR}} and
12254 @code{.NOT.@var{VAR}} both appear to be true.
12255
12256 @item @emph{Example}:
12257 @smallexample
12258 PROGRAM test_transfer
12259   integer :: x = 2143289344
12260   print *, transfer(x, 1.0)    ! prints "NaN" on i686
12261 END PROGRAM
12262 @end smallexample
12263 @end table
12264
12265
12266
12267 @node TRANSPOSE
12268 @section @code{TRANSPOSE} --- Transpose an array of rank two
12269 @fnindex TRANSPOSE
12270 @cindex array, transpose
12271 @cindex matrix, transpose
12272 @cindex transpose
12273
12274 @table @asis
12275 @item @emph{Description}:
12276 Transpose an array of rank two. Element (i, j) of the result has the value 
12277 @code{MATRIX(j, i)}, for all i, j.
12278
12279 @item @emph{Standard}:
12280 Fortran 95 and later
12281
12282 @item @emph{Class}:
12283 Transformational function
12284
12285 @item @emph{Syntax}:
12286 @code{RESULT = TRANSPOSE(MATRIX)}
12287
12288 @item @emph{Arguments}:
12289 @multitable @columnfractions .15 .70
12290 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
12291 @end multitable
12292
12293 @item @emph{Return value}:
12294 The result has the same type as @var{MATRIX}, and has shape 
12295 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
12296 @end table
12297
12298
12299
12300 @node TRIM
12301 @section @code{TRIM} --- Remove trailing blank characters of a string
12302 @fnindex TRIM
12303 @cindex string, remove trailing whitespace
12304
12305 @table @asis
12306 @item @emph{Description}:
12307 Removes trailing blank characters of a string.
12308
12309 @item @emph{Standard}:
12310 Fortran 95 and later
12311
12312 @item @emph{Class}:
12313 Transformational function
12314
12315 @item @emph{Syntax}:
12316 @code{RESULT = TRIM(STRING)}
12317
12318 @item @emph{Arguments}:
12319 @multitable @columnfractions .15 .70
12320 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
12321 @end multitable
12322
12323 @item @emph{Return value}:
12324 A scalar of type @code{CHARACTER} which length is that of @var{STRING}
12325 less the number of trailing blanks.
12326
12327 @item @emph{Example}:
12328 @smallexample
12329 PROGRAM test_trim
12330   CHARACTER(len=10), PARAMETER :: s = "GFORTRAN  "
12331   WRITE(*,*) LEN(s), LEN(TRIM(s))  ! "10 8", with/without trailing blanks
12332 END PROGRAM
12333 @end smallexample
12334
12335 @item @emph{See also}:
12336 @ref{ADJUSTL}, @ref{ADJUSTR}
12337 @end table
12338
12339
12340
12341 @node TTYNAM
12342 @section @code{TTYNAM} --- Get the name of a terminal device.
12343 @fnindex TTYNAM
12344 @cindex system, terminal
12345
12346 @table @asis
12347 @item @emph{Description}:
12348 Get the name of a terminal device. For more information, 
12349 see @code{ttyname(3)}.
12350
12351 This intrinsic is provided in both subroutine and function forms; 
12352 however, only one form can be used in any given program unit. 
12353
12354 @item @emph{Standard}:
12355 GNU extension
12356
12357 @item @emph{Class}:
12358 Subroutine, function
12359
12360 @item @emph{Syntax}:
12361 @multitable @columnfractions .80
12362 @item @code{CALL TTYNAM(UNIT, NAME)}
12363 @item @code{NAME = TTYNAM(UNIT)}
12364 @end multitable
12365
12366 @item @emph{Arguments}:
12367 @multitable @columnfractions .15 .70
12368 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
12369 @item @var{NAME} @tab Shall be of type @code{CHARACTER}.
12370 @end multitable
12371
12372 @item @emph{Example}:
12373 @smallexample
12374 PROGRAM test_ttynam
12375   INTEGER :: unit
12376   DO unit = 1, 10
12377     IF (isatty(unit=unit)) write(*,*) ttynam(unit)
12378   END DO
12379 END PROGRAM
12380 @end smallexample
12381
12382 @item @emph{See also}:
12383 @ref{ISATTY}
12384 @end table
12385
12386
12387
12388 @node UBOUND
12389 @section @code{UBOUND} --- Upper dimension bounds of an array
12390 @fnindex UBOUND
12391 @cindex array, upper bound
12392
12393 @table @asis
12394 @item @emph{Description}:
12395 Returns the upper bounds of an array, or a single upper bound
12396 along the @var{DIM} dimension.
12397 @item @emph{Standard}:
12398 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
12399
12400 @item @emph{Class}:
12401 Inquiry function
12402
12403 @item @emph{Syntax}:
12404 @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
12405
12406 @item @emph{Arguments}:
12407 @multitable @columnfractions .15 .70
12408 @item @var{ARRAY} @tab Shall be an array, of any type.
12409 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
12410 @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
12411 expression indicating the kind parameter of the result.
12412 @end multitable
12413
12414 @item @emph{Return value}:
12415 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12416 @var{KIND} is absent, the return value is of default integer kind.
12417 If @var{DIM} is absent, the result is an array of the upper bounds of
12418 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
12419 corresponding to the upper bound of the array along that dimension.  If
12420 @var{ARRAY} is an expression rather than a whole array or array
12421 structure component, or if it has a zero extent along the relevant
12422 dimension, the upper bound is taken to be the number of elements along
12423 the relevant dimension.
12424
12425 @item @emph{See also}:
12426 @ref{LBOUND}, @ref{LCOBOUND}
12427 @end table
12428
12429
12430
12431 @node UCOBOUND
12432 @section @code{UCOBOUND} --- Upper codimension bounds of an array
12433 @fnindex UCOBOUND
12434 @cindex coarray, upper bound
12435
12436 @table @asis
12437 @item @emph{Description}:
12438 Returns the upper cobounds of a coarray, or a single upper cobound
12439 along the @var{DIM} codimension.
12440 @item @emph{Standard}:
12441 Fortran 2008 and later
12442
12443 @item @emph{Class}:
12444 Inquiry function
12445
12446 @item @emph{Syntax}:
12447 @code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])}
12448
12449 @item @emph{Arguments}:
12450 @multitable @columnfractions .15 .70
12451 @item @var{ARRAY} @tab Shall be an coarray, of any type.
12452 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
12453 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12454 expression indicating the kind parameter of the result.
12455 @end multitable
12456
12457 @item @emph{Return value}:
12458 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12459 @var{KIND} is absent, the return value is of default integer kind.
12460 If @var{DIM} is absent, the result is an array of the lower cobounds of
12461 @var{COARRAY}.  If @var{DIM} is present, the result is a scalar
12462 corresponding to the lower cobound of the array along that codimension.
12463
12464 @item @emph{See also}:
12465 @ref{LCOBOUND}, @ref{LBOUND}
12466 @end table
12467
12468
12469
12470 @node UMASK
12471 @section @code{UMASK} --- Set the file creation mask
12472 @fnindex UMASK
12473 @cindex file system, file creation mask
12474
12475 @table @asis
12476 @item @emph{Description}:
12477 Sets the file creation mask to @var{MASK}. If called as a function, it
12478 returns the old value. If called as a subroutine and argument @var{OLD}
12479 if it is supplied, it is set to the old value. See @code{umask(2)}.
12480
12481 @item @emph{Standard}:
12482 GNU extension
12483
12484 @item @emph{Class}:
12485 Subroutine, function
12486
12487 @item @emph{Syntax}:
12488 @multitable @columnfractions .80
12489 @item @code{CALL UMASK(MASK [, OLD])}
12490 @item @code{OLD = UMASK(MASK)}
12491 @end multitable
12492
12493 @item @emph{Arguments}:
12494 @multitable @columnfractions .15 .70
12495 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
12496 @item @var{OLD} @tab (Optional) Shall be a scalar of type
12497 @code{INTEGER}.
12498 @end multitable
12499
12500 @end table
12501
12502
12503
12504 @node UNLINK
12505 @section @code{UNLINK} --- Remove a file from the file system
12506 @fnindex UNLINK
12507 @cindex file system, remove file
12508
12509 @table @asis
12510 @item @emph{Description}:
12511 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
12512 used to mark the end of the name in @var{PATH}; otherwise, trailing
12513 blanks in the file name are ignored.  If the @var{STATUS} argument is
12514 supplied, it contains 0 on success or a nonzero error code upon return;
12515 see @code{unlink(2)}.
12516
12517 This intrinsic is provided in both subroutine and function forms;
12518 however, only one form can be used in any given program unit.
12519
12520 @item @emph{Standard}:
12521 GNU extension
12522
12523 @item @emph{Class}:
12524 Subroutine, function
12525
12526 @item @emph{Syntax}:
12527 @multitable @columnfractions .80
12528 @item @code{CALL UNLINK(PATH [, STATUS])}
12529 @item @code{STATUS = UNLINK(PATH)}
12530 @end multitable
12531
12532 @item @emph{Arguments}:
12533 @multitable @columnfractions .15 .70
12534 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
12535 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
12536 @end multitable
12537
12538 @item @emph{See also}:
12539 @ref{LINK}, @ref{SYMLNK}
12540 @end table
12541
12542
12543
12544 @node UNPACK
12545 @section @code{UNPACK} --- Unpack an array of rank one into an array
12546 @fnindex UNPACK
12547 @cindex array, unpacking
12548 @cindex array, increase dimension
12549 @cindex array, scatter elements
12550
12551 @table @asis
12552 @item @emph{Description}:
12553 Store the elements of @var{VECTOR} in an array of higher rank.
12554
12555 @item @emph{Standard}:
12556 Fortran 95 and later
12557
12558 @item @emph{Class}:
12559 Transformational function
12560
12561 @item @emph{Syntax}:
12562 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
12563
12564 @item @emph{Arguments}:
12565 @multitable @columnfractions .15 .70
12566 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It 
12567 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
12568 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL}.
12569 @item @var{FIELD}  @tab Shall be of the same type as @var{VECTOR} and have
12570 the same shape as @var{MASK}.
12571 @end multitable
12572
12573 @item @emph{Return value}:
12574 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
12575 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
12576
12577 @item @emph{Example}:
12578 @smallexample
12579 PROGRAM test_unpack
12580   integer :: vector(2)  = (/1,1/)
12581   logical :: mask(4)  = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
12582   integer :: field(2,2) = 0, unity(2,2)
12583
12584   ! result: unity matrix
12585   unity = unpack(vector, reshape(mask, (/2,2/)), field)
12586 END PROGRAM
12587 @end smallexample
12588
12589 @item @emph{See also}:
12590 @ref{PACK}, @ref{SPREAD}
12591 @end table
12592
12593
12594
12595 @node VERIFY
12596 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
12597 @fnindex VERIFY
12598 @cindex string, find missing set
12599
12600 @table @asis
12601 @item @emph{Description}:
12602 Verifies that all the characters in a @var{SET} are present in a @var{STRING}.
12603
12604 If @var{BACK} is either absent or equals @code{FALSE}, this function
12605 returns the position of the leftmost character of @var{STRING} that is
12606 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
12607 is returned. If all characters of @var{SET} are found in @var{STRING}, the 
12608 result is zero.
12609
12610 @item @emph{Standard}:
12611 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
12612
12613 @item @emph{Class}:
12614 Elemental function
12615
12616 @item @emph{Syntax}:
12617 @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
12618
12619 @item @emph{Arguments}:
12620 @multitable @columnfractions .15 .70
12621 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
12622 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
12623 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
12624 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
12625 expression indicating the kind parameter of the result.
12626 @end multitable
12627
12628 @item @emph{Return value}:
12629 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12630 @var{KIND} is absent, the return value is of default integer kind.
12631
12632 @item @emph{Example}:
12633 @smallexample
12634 PROGRAM test_verify
12635   WRITE(*,*) VERIFY("FORTRAN", "AO")           ! 1, found 'F'
12636   WRITE(*,*) VERIFY("FORTRAN", "FOO")          ! 3, found 'R'
12637   WRITE(*,*) VERIFY("FORTRAN", "C++")          ! 1, found 'F'
12638   WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.)  ! 7, found 'N'
12639   WRITE(*,*) VERIFY("FORTRAN", "FORTRAN")      ! 0' found none
12640 END PROGRAM
12641 @end smallexample
12642
12643 @item @emph{See also}:
12644 @ref{SCAN}, @ref{INDEX intrinsic}
12645 @end table
12646
12647
12648
12649 @node XOR
12650 @section @code{XOR} --- Bitwise logical exclusive OR
12651 @fnindex XOR
12652 @cindex bitwise logical exclusive or
12653 @cindex logical exclusive or, bitwise
12654
12655 @table @asis
12656 @item @emph{Description}:
12657 Bitwise logical exclusive or. 
12658
12659 This intrinsic routine is provided for backwards compatibility with 
12660 GNU Fortran 77.  For integer arguments, programmers should consider
12661 the use of the @ref{IEOR} intrinsic and for logical arguments the
12662 @code{.NEQV.} operator, which are both defined by the Fortran standard.
12663
12664 @item @emph{Standard}:
12665 GNU extension
12666
12667 @item @emph{Class}:
12668 Function
12669
12670 @item @emph{Syntax}:
12671 @code{RESULT = XOR(I, J)}
12672
12673 @item @emph{Arguments}:
12674 @multitable @columnfractions .15 .70
12675 @item @var{I} @tab The type shall be either  a scalar @code{INTEGER}
12676 type or a scalar @code{LOGICAL} type.
12677 @item @var{J} @tab The type shall be the same as the type of @var{I}.
12678 @end multitable
12679
12680 @item @emph{Return value}:
12681 The return type is either a scalar @code{INTEGER} or a scalar
12682 @code{LOGICAL}.  If the kind type parameters differ, then the
12683 smaller kind type is implicitly converted to larger kind, and the 
12684 return has the larger kind.
12685
12686 @item @emph{Example}:
12687 @smallexample
12688 PROGRAM test_xor
12689   LOGICAL :: T = .TRUE., F = .FALSE.
12690   INTEGER :: a, b
12691   DATA a / Z'F' /, b / Z'3' /
12692
12693   WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
12694   WRITE (*,*) XOR(a, b)
12695 END PROGRAM
12696 @end smallexample
12697
12698 @item @emph{See also}:
12699 Fortran 95 elemental function: @ref{IEOR}
12700 @end table
12701
12702
12703
12704 @node Intrinsic Modules
12705 @chapter Intrinsic Modules
12706 @cindex intrinsic Modules
12707
12708 @menu
12709 * ISO_FORTRAN_ENV::
12710 * ISO_C_BINDING::
12711 * OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
12712 @end menu
12713
12714 @node ISO_FORTRAN_ENV
12715 @section @code{ISO_FORTRAN_ENV}
12716 @table @asis
12717 @item @emph{Standard}:
12718 Fortran 2003 and later, except when otherwise noted
12719 @end table
12720
12721 The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
12722 named constants:
12723
12724 @table @asis
12725 @item @code{ATOMIC_INT_KIND}:
12726 Default-kind integer constant to be used as kind parameter when defining
12727 integer variables used in atomic operations. (Fortran 2008 or later.)
12728
12729 @item @code{ATOMIC_LOGICAL_KIND}:
12730 Default-kind integer constant to be used as kind parameter when defining
12731 logical variables used in atomic operations. (Fortran 2008 or later.)
12732
12733 @item @code{CHARACTER_KINDS}:
12734 Default-kind integer constant array of rank one containing the supported kind
12735 parameters of the @code{CHARACTER} type. (Fortran 2008 or later.)
12736
12737 @item @code{CHARACTER_STORAGE_SIZE}:
12738 Size in bits of the character storage unit.
12739
12740 @item @code{ERROR_UNIT}:
12741 Identifies the preconnected unit used for error reporting.
12742
12743 @item @code{FILE_STORAGE_SIZE}:
12744 Size in bits of the file-storage unit.
12745
12746 @item @code{INPUT_UNIT}:
12747 Identifies the preconnected unit identified by the asterisk
12748 (@code{*}) in @code{READ} statement.
12749
12750 @item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}:
12751 Kind type parameters to specify an INTEGER type with a storage
12752 size of 16, 32, and 64 bits. It is negative if a target platform
12753 does not support the particular kind. (Fortran 2008 or later.)
12754
12755 @item @code{INTEGER_KINDS}:
12756 Default-kind integer constant array of rank one containing the supported kind
12757 parameters of the @code{INTEGER} type. (Fortran 2008 or later.)
12758
12759 @item @code{IOSTAT_END}:
12760 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
12761 an input/output statement if an end-of-file condition occurred.
12762
12763 @item @code{IOSTAT_EOR}:
12764 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
12765 an input/output statement if an end-of-record condition occurred.
12766
12767 @item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}:
12768 Scalar default-integer constant, used by @code{INQUIRE} for the
12769 @code{IOSTAT=} specifier to denote an that a unit number identifies an
12770 internal unit. (Fortran 2008 or later.)
12771
12772 @item @code{NUMERIC_STORAGE_SIZE}:
12773 The size in bits of the numeric storage unit.
12774
12775 @item @code{LOGICAL_KINDS}:
12776 Default-kind integer constant array of rank one containing the supported kind
12777 parameters of the @code{LOGICAL} type. (Fortran 2008 or later.)
12778
12779 @item @code{OUTPUT_UNIT}:
12780 Identifies the preconnected unit identified by the asterisk
12781 (@code{*}) in @code{WRITE} statement.
12782
12783 @item @code{REAL32}, @code{REAL64}, @code{REAL128}:
12784 Kind type parameters to specify a REAL type with a storage
12785 size of 32, 64, and 128 bits. It is negative if a target platform
12786 does not support the particular kind. (Fortran 2008 or later.)
12787
12788 @item @code{REAL_KINDS}:
12789 Default-kind integer constant array of rank one containing the supported kind
12790 parameters of the @code{REAL} type. (Fortran 2008 or later.)
12791
12792 @item @code{STAT_LOCKED}:
12793 Scalar default-integer constant used as STAT= return value by @code{LOCK} to
12794 denote that the lock variable is locked by the executing image. (Fortran 2008
12795 or later.)
12796
12797 @item @code{STAT_LOCKED_OTHER_IMAGE}:
12798 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
12799 denote that the lock variable is locked by another image. (Fortran 2008 or
12800 later.)
12801
12802 @item @code{STAT_STOPPED_IMAGE}:
12803 Positive, scalar default-integer constant used as STAT= return value if the
12804 argument in the statement requires synchronisation with an image, which has
12805 initiated the termination of the execution. (Fortran 2008 or later.)
12806
12807 @item @code{STAT_UNLOCKED}:
12808 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
12809 denote that the lock variable is unlocked. (Fortran 2008 or later.)
12810 @end table
12811
12812 The module also provides the following intrinsic procedures:
12813 @ref{COMPILER_OPTIONS} and @ref{COMPILER_VERSION}.
12814
12815
12816
12817 @node ISO_C_BINDING
12818 @section @code{ISO_C_BINDING}
12819 @table @asis
12820 @item @emph{Standard}:
12821 Fortran 2003 and later, GNU extensions
12822 @end table
12823
12824 The following intrinsic procedures are provided by the module; their
12825 definition can be found in the section Intrinsic Procedures of this
12826 manual.
12827
12828 @table @asis
12829 @item @code{C_ASSOCIATED}
12830 @item @code{C_F_POINTER}
12831 @item @code{C_F_PROCPOINTER}
12832 @item @code{C_FUNLOC}
12833 @item @code{C_LOC}
12834 @item @code{C_SIZEOF}
12835 @end table
12836 @c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
12837 @c don't really know why.
12838
12839 The @code{ISO_C_BINDING} module provides the following named constants of
12840 type default integer, which can be used as KIND type parameters.
12841
12842 In addition to the integer named constants required by the Fortran 2003 
12843 standard, GNU Fortran provides as an extension named constants for the 
12844 128-bit integer types supported by the C compiler: @code{C_INT128_T, 
12845 C_INT_LEAST128_T, C_INT_FAST128_T}.
12846
12847 @multitable @columnfractions .15 .35 .35 .35
12848 @item Fortran Type  @tab Named constant         @tab C type                                @tab Extension
12849 @item @code{INTEGER}@tab @code{C_INT}           @tab @code{int}
12850 @item @code{INTEGER}@tab @code{C_SHORT}         @tab @code{short int}
12851 @item @code{INTEGER}@tab @code{C_LONG}          @tab @code{long int}
12852 @item @code{INTEGER}@tab @code{C_LONG_LONG}     @tab @code{long long int}
12853 @item @code{INTEGER}@tab @code{C_SIGNED_CHAR}   @tab @code{signed char}/@code{unsigned char}
12854 @item @code{INTEGER}@tab @code{C_SIZE_T}        @tab @code{size_t}
12855 @item @code{INTEGER}@tab @code{C_INT8_T}        @tab @code{int8_t}
12856 @item @code{INTEGER}@tab @code{C_INT16_T}       @tab @code{int16_t}
12857 @item @code{INTEGER}@tab @code{C_INT32_T}       @tab @code{int32_t}
12858 @item @code{INTEGER}@tab @code{C_INT64_T}       @tab @code{int64_t}
12859 @item @code{INTEGER}@tab @code{C_INT128_T}      @tab @code{int128_t}                      @tab Ext.
12860 @item @code{INTEGER}@tab @code{C_INT_LEAST8_T}  @tab @code{int_least8_t}
12861 @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
12862 @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
12863 @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
12864 @item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t}                @tab Ext.
12865 @item @code{INTEGER}@tab @code{C_INT_FAST8_T}   @tab @code{int_fast8_t}
12866 @item @code{INTEGER}@tab @code{C_INT_FAST16_T}  @tab @code{int_fast16_t}
12867 @item @code{INTEGER}@tab @code{C_INT_FAST32_T}  @tab @code{int_fast32_t}
12868 @item @code{INTEGER}@tab @code{C_INT_FAST64_T}  @tab @code{int_fast64_t}
12869 @item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t}                 @tab Ext.
12870 @item @code{INTEGER}@tab @code{C_INTMAX_T}      @tab @code{intmax_t}
12871 @item @code{INTEGER}@tab @code{C_INTPTR_T}      @tab @code{intptr_t}
12872 @item @code{REAL}   @tab @code{C_FLOAT}         @tab @code{float}
12873 @item @code{REAL}   @tab @code{C_DOUBLE}        @tab @code{double}
12874 @item @code{REAL}   @tab @code{C_LONG_DOUBLE}   @tab @code{long double}
12875 @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
12876 @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
12877 @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
12878 @item @code{LOGICAL}@tab @code{C_BOOL}          @tab @code{_Bool}
12879 @item @code{CHARACTER}@tab @code{C_CHAR}        @tab @code{char}
12880 @end multitable
12881
12882 Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)}
12883 are defined.
12884
12885 @multitable @columnfractions .20 .45 .15
12886 @item Name                     @tab C definition    @tab Value
12887 @item @code{C_NULL_CHAR}       @tab null character  @tab @code{'\0'}
12888 @item @code{C_ALERT}           @tab alert           @tab @code{'\a'}
12889 @item @code{C_BACKSPACE}       @tab backspace       @tab @code{'\b'}
12890 @item @code{C_FORM_FEED}       @tab form feed       @tab @code{'\f'}
12891 @item @code{C_NEW_LINE}        @tab new line        @tab @code{'\n'}
12892 @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
12893 @item @code{C_HORIZONTAL_TAB}  @tab horizontal tab  @tab @code{'\t'}
12894 @item @code{C_VERTICAL_TAB}    @tab vertical tab    @tab @code{'\v'}
12895 @end multitable
12896
12897 Moreover, the following two named constants are defined:
12898
12899 @multitable @columnfractions .20 .80
12900 @item Name                 @tab Type
12901 @item @code{C_NULL_PTR}    @tab @code{C_PTR}
12902 @item @code{C_NULL_FUNPTR} @tab @code{C_FUNPTR}
12903 @end multitable
12904
12905 Both are equivalent to the value @code{NULL} in C.
12906
12907 @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
12908 @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
12909 @table @asis
12910 @item @emph{Standard}:
12911 OpenMP Application Program Interface v3.0
12912 @end table
12913
12914
12915 The OpenMP Fortran runtime library routines are provided both in
12916 a form of two Fortran 90 modules, named @code{OMP_LIB} and 
12917 @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
12918 @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
12919 in the @ref{Top,,Introduction,libgomp,GNU OpenMP runtime library} manual,
12920 the named constants defined in the modules are listed
12921 below.
12922
12923 For details refer to the actual
12924 @uref{http://www.openmp.org/mp-documents/spec30.pdf,
12925 OpenMP Application Program Interface v3.0}.
12926
12927 @code{OMP_LIB_KINDS} provides the following scalar default-integer
12928 named constants:
12929
12930 @table @asis
12931 @item @code{omp_integer_kind}
12932 @item @code{omp_logical_kind}
12933 @item @code{omp_lock_kind}
12934 @item @code{omp_nest_lock_kind}
12935 @item @code{omp_sched_kind}
12936 @end table
12937
12938 @code{OMP_LIB} provides the scalar default-integer
12939 named constant @code{openmp_version} with a value of the form
12940 @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
12941 of the OpenMP version; for OpenMP v3.0 the value is @code{200805}.
12942
12943 And the following scalar integer named constants of the
12944 kind @code{omp_sched_kind}:
12945
12946 @table @asis
12947 @item @code{omp_sched_static}
12948 @item @code{omp_sched_dynamic}
12949 @item @code{omp_sched_guided}
12950 @item @code{omp_sched_auto}
12951 @end table