3907501864aff541971089b50f224d4e868239de
[platform/upstream/gcc48.git] / gcc / fortran / intrinsic.texi
1 @ignore
2 Copyright (C) 2005-2013 Free Software Foundation, Inc.
3 This is part of the GNU Fortran manual.   
4 For copying conditions, see the file gfortran.texi.
5
6 Permission is granted to copy, distribute and/or modify this document
7 under the terms of the GNU Free Documentation License, Version 1.3 or
8 any later version published by the Free Software Foundation; with the
9 Invariant Sections being ``Funding Free Software'', the Front-Cover
10 Texts being (a) (see below), and with the Back-Cover Texts being (b)
11 (see below).  A copy of the license is included in the gfdl(7) man page.
12
13
14 Some basic guidelines for editing this document:
15
16   (1) The intrinsic procedures are to be listed in alphabetical order.
17   (2) The generic name is to be used.
18   (3) The specific names are included in the function index and in a
19       table at the end of the node (See ABS entry).
20   (4) Try to maintain the same style for each entry.
21
22
23 @end ignore
24
25 @tex
26 \gdef\acos{\mathop{\rm acos}\nolimits}
27 \gdef\asin{\mathop{\rm asin}\nolimits}
28 \gdef\atan{\mathop{\rm atan}\nolimits}
29 \gdef\acosh{\mathop{\rm acosh}\nolimits}
30 \gdef\asinh{\mathop{\rm asinh}\nolimits}
31 \gdef\atanh{\mathop{\rm atanh}\nolimits}
32 @end tex
33
34
35 @node Intrinsic Procedures
36 @chapter Intrinsic Procedures
37 @cindex intrinsic procedures
38
39 @menu
40 * Introduction:         Introduction to Intrinsics
41 * @code{ABORT}:         ABORT,     Abort the program     
42 * @code{ABS}:           ABS,       Absolute value     
43 * @code{ACCESS}:        ACCESS,    Checks file access modes
44 * @code{ACHAR}:         ACHAR,     Character in @acronym{ASCII} collating sequence
45 * @code{ACOS}:          ACOS,      Arccosine function
46 * @code{ACOSH}:         ACOSH,     Inverse hyperbolic cosine function
47 * @code{ADJUSTL}:       ADJUSTL,   Left adjust a string
48 * @code{ADJUSTR}:       ADJUSTR,   Right adjust a string
49 * @code{AIMAG}:         AIMAG,     Imaginary part of complex number
50 * @code{AINT}:          AINT,      Truncate to a whole number
51 * @code{ALARM}:         ALARM,     Set an alarm clock
52 * @code{ALL}:           ALL,       Determine if all values are true
53 * @code{ALLOCATED}:     ALLOCATED, Status of allocatable entity
54 * @code{AND}:           AND,       Bitwise logical AND
55 * @code{ANINT}:         ANINT,     Nearest whole number
56 * @code{ANY}:           ANY,       Determine if any values are true
57 * @code{ASIN}:          ASIN,      Arcsine function
58 * @code{ASINH}:         ASINH,     Inverse hyperbolic sine function
59 * @code{ASSOCIATED}:    ASSOCIATED, Status of a pointer or pointer/target pair
60 * @code{ATAN}:          ATAN,      Arctangent function
61 * @code{ATAN2}:         ATAN2,     Arctangent function
62 * @code{ATANH}:         ATANH,     Inverse hyperbolic tangent function
63 * @code{ATOMIC_DEFINE}: ATOMIC_DEFINE, Setting a variable atomically
64 * @code{ATOMIC_REF}:    ATOMIC_REF, Obtaining the value of a variable atomically
65 * @code{BACKTRACE}:     BACKTRACE, Show a backtrace
66 * @code{BESSEL_J0}:     BESSEL_J0, Bessel function of the first kind of order 0
67 * @code{BESSEL_J1}:     BESSEL_J1, Bessel function of the first kind of order 1
68 * @code{BESSEL_JN}:     BESSEL_JN, Bessel function of the first kind
69 * @code{BESSEL_Y0}:     BESSEL_Y0, Bessel function of the second kind of order 0
70 * @code{BESSEL_Y1}:     BESSEL_Y1, Bessel function of the second kind of order 1
71 * @code{BESSEL_YN}:     BESSEL_YN, Bessel function of the second kind
72 * @code{BGE}:           BGE,       Bitwise greater than or equal to
73 * @code{BGT}:           BGT,       Bitwise greater than
74 * @code{BIT_SIZE}:      BIT_SIZE,  Bit size inquiry function
75 * @code{BLE}:           BLE,       Bitwise less than or equal to
76 * @code{BLT}:           BLT,       Bitwise less than
77 * @code{BTEST}:         BTEST,     Bit test function
78 * @code{C_ASSOCIATED}:  C_ASSOCIATED, Status of a C pointer
79 * @code{C_F_POINTER}:   C_F_POINTER, Convert C into Fortran pointer
80 * @code{C_F_PROCPOINTER}: C_F_PROCPOINTER, Convert C into Fortran procedure pointer
81 * @code{C_FUNLOC}:      C_FUNLOC,  Obtain the C address of a procedure
82 * @code{C_LOC}:         C_LOC,     Obtain the C address of an object
83 * @code{C_SIZEOF}:      C_SIZEOF,  Size in bytes of an expression
84 * @code{CEILING}:       CEILING,   Integer ceiling function
85 * @code{CHAR}:          CHAR,      Integer-to-character conversion function
86 * @code{CHDIR}:         CHDIR,     Change working directory
87 * @code{CHMOD}:         CHMOD,     Change access permissions of files
88 * @code{CMPLX}:         CMPLX,     Complex conversion function
89 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
90 * @code{COMPILER_OPTIONS}: COMPILER_OPTIONS, Options passed to the compiler
91 * @code{COMPILER_VERSION}: COMPILER_VERSION, Compiler version string
92 * @code{COMPLEX}:       COMPLEX,   Complex conversion function
93 * @code{CONJG}:         CONJG,     Complex conjugate function
94 * @code{COS}:           COS,       Cosine function
95 * @code{COSH}:          COSH,      Hyperbolic cosine function
96 * @code{COUNT}:         COUNT,     Count occurrences of TRUE in an array
97 * @code{CPU_TIME}:      CPU_TIME,  CPU time subroutine
98 * @code{CSHIFT}:        CSHIFT,    Circular shift elements of an array
99 * @code{CTIME}:         CTIME,     Subroutine (or function) to convert a time into a string
100 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
101 * @code{DBLE}:          DBLE,      Double precision conversion function
102 * @code{DCMPLX}:        DCMPLX,    Double complex conversion function
103 * @code{DIGITS}:        DIGITS,    Significant digits function
104 * @code{DIM}:           DIM,       Positive difference
105 * @code{DOT_PRODUCT}:   DOT_PRODUCT, Dot product function
106 * @code{DPROD}:         DPROD,     Double product function
107 * @code{DREAL}:         DREAL,     Double real part function
108 * @code{DSHIFTL}:       DSHIFTL,   Combined left shift
109 * @code{DSHIFTR}:       DSHIFTR,   Combined right shift
110 * @code{DTIME}:         DTIME,     Execution time subroutine (or function)
111 * @code{EOSHIFT}:       EOSHIFT,   End-off shift elements of an array
112 * @code{EPSILON}:       EPSILON,   Epsilon function
113 * @code{ERF}:           ERF,       Error function
114 * @code{ERFC}:          ERFC,      Complementary error function
115 * @code{ERFC_SCALED}:   ERFC_SCALED, Exponentially-scaled complementary error function
116 * @code{ETIME}:         ETIME,     Execution time subroutine (or function)
117 * @code{EXECUTE_COMMAND_LINE}: EXECUTE_COMMAND_LINE, Execute a shell command
118 * @code{EXIT}:          EXIT,      Exit the program with status.
119 * @code{EXP}:           EXP,       Exponential function
120 * @code{EXPONENT}:      EXPONENT,  Exponent function
121 * @code{EXTENDS_TYPE_OF}: EXTENDS_TYPE_OF,  Query dynamic type for extension
122 * @code{FDATE}:         FDATE,     Subroutine (or function) to get the current time as a string
123 * @code{FGET}:          FGET,      Read a single character in stream mode from stdin
124 * @code{FGETC}:         FGETC,     Read a single character in stream mode
125 * @code{FLOOR}:         FLOOR,     Integer floor function
126 * @code{FLUSH}:         FLUSH,     Flush I/O unit(s)
127 * @code{FNUM}:          FNUM,      File number function
128 * @code{FPUT}:          FPUT,      Write a single character in stream mode to stdout
129 * @code{FPUTC}:         FPUTC,     Write a single character in stream mode
130 * @code{FRACTION}:      FRACTION,  Fractional part of the model representation
131 * @code{FREE}:          FREE,      Memory de-allocation subroutine
132 * @code{FSEEK}:         FSEEK,     Low level file positioning subroutine
133 * @code{FSTAT}:         FSTAT,     Get file status
134 * @code{FTELL}:         FTELL,     Current stream position
135 * @code{GAMMA}:         GAMMA,     Gamma function
136 * @code{GERROR}:        GERROR,    Get last system error message
137 * @code{GETARG}:        GETARG,    Get command line arguments
138 * @code{GET_COMMAND}:   GET_COMMAND, Get the entire command line
139 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
140 * @code{GETCWD}:        GETCWD,    Get current working directory
141 * @code{GETENV}:        GETENV,    Get an environmental variable
142 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
143 * @code{GETGID}:        GETGID,    Group ID function
144 * @code{GETLOG}:        GETLOG,    Get login name
145 * @code{GETPID}:        GETPID,    Process ID function
146 * @code{GETUID}:        GETUID,    User ID function
147 * @code{GMTIME}:        GMTIME,    Convert time to GMT info
148 * @code{HOSTNM}:        HOSTNM,    Get system host name
149 * @code{HUGE}:          HUGE,      Largest number of a kind
150 * @code{HYPOT}:         HYPOT,     Euclidean distance function
151 * @code{IACHAR}:        IACHAR,    Code in @acronym{ASCII} collating sequence
152 * @code{IALL}:          IALL,      Bitwise AND of array elements
153 * @code{IAND}:          IAND,      Bitwise logical and
154 * @code{IANY}:          IANY,      Bitwise OR of array elements
155 * @code{IARGC}:         IARGC,     Get the number of command line arguments
156 * @code{IBCLR}:         IBCLR,     Clear bit
157 * @code{IBITS}:         IBITS,     Bit extraction
158 * @code{IBSET}:         IBSET,     Set bit
159 * @code{ICHAR}:         ICHAR,     Character-to-integer conversion function
160 * @code{IDATE}:         IDATE,     Current local time (day/month/year)
161 * @code{IEOR}:          IEOR,      Bitwise logical exclusive or
162 * @code{IERRNO}:        IERRNO,    Function to get the last system error number
163 * @code{IMAGE_INDEX}:   IMAGE_INDEX, Cosubscript to image index conversion
164 * @code{INDEX}:         INDEX intrinsic, Position of a substring within a string
165 * @code{INT}:           INT,       Convert to integer type
166 * @code{INT2}:          INT2,      Convert to 16-bit integer type
167 * @code{INT8}:          INT8,      Convert to 64-bit integer type
168 * @code{IOR}:           IOR,       Bitwise logical or
169 * @code{IPARITY}:       IPARITY,   Bitwise XOR of array elements
170 * @code{IRAND}:         IRAND,     Integer pseudo-random number
171 * @code{IS_IOSTAT_END}:  IS_IOSTAT_END, Test for end-of-file value
172 * @code{IS_IOSTAT_EOR}:  IS_IOSTAT_EOR, Test for end-of-record value
173 * @code{ISATTY}:        ISATTY,    Whether a unit is a terminal device
174 * @code{ISHFT}:         ISHFT,     Shift bits
175 * @code{ISHFTC}:        ISHFTC,    Shift bits circularly
176 * @code{ISNAN}:         ISNAN,     Tests for a NaN
177 * @code{ITIME}:         ITIME,     Current local time (hour/minutes/seconds)
178 * @code{KILL}:          KILL,      Send a signal to a process
179 * @code{KIND}:          KIND,      Kind of an entity
180 * @code{LBOUND}:        LBOUND,    Lower dimension bounds of an array
181 * @code{LCOBOUND}:      LCOBOUND,  Lower codimension bounds of an array
182 * @code{LEADZ}:         LEADZ,     Number of leading zero bits of an integer
183 * @code{LEN}:           LEN,       Length of a character entity
184 * @code{LEN_TRIM}:      LEN_TRIM,  Length of a character entity without trailing blank characters
185 * @code{LGE}:           LGE,       Lexical greater than or equal
186 * @code{LGT}:           LGT,       Lexical greater than
187 * @code{LINK}:          LINK,      Create a hard link
188 * @code{LLE}:           LLE,       Lexical less than or equal
189 * @code{LLT}:           LLT,       Lexical less than
190 * @code{LNBLNK}:        LNBLNK,    Index of the last non-blank character in a string
191 * @code{LOC}:           LOC,       Returns the address of a variable
192 * @code{LOG}:           LOG,       Logarithm function
193 * @code{LOG10}:         LOG10,     Base 10 logarithm function 
194 * @code{LOG_GAMMA}:     LOG_GAMMA, Logarithm of the Gamma function
195 * @code{LOGICAL}:       LOGICAL,   Convert to logical type
196 * @code{LONG}:          LONG,      Convert to integer type
197 * @code{LSHIFT}:        LSHIFT,    Left shift bits
198 * @code{LSTAT}:         LSTAT,     Get file status
199 * @code{LTIME}:         LTIME,     Convert time to local time info
200 * @code{MALLOC}:        MALLOC,    Dynamic memory allocation function
201 * @code{MASKL}:         MASKL,     Left justified mask
202 * @code{MASKR}:         MASKR,     Right justified mask
203 * @code{MATMUL}:        MATMUL,    matrix multiplication
204 * @code{MAX}:           MAX,       Maximum value of an argument list
205 * @code{MAXEXPONENT}:   MAXEXPONENT, Maximum exponent of a real kind
206 * @code{MAXLOC}:        MAXLOC,    Location of the maximum value within an array
207 * @code{MAXVAL}:        MAXVAL,    Maximum value of an array
208 * @code{MCLOCK}:        MCLOCK,    Time function
209 * @code{MCLOCK8}:       MCLOCK8,   Time function (64-bit)
210 * @code{MERGE}:         MERGE,     Merge arrays
211 * @code{MERGE_BITS}:    MERGE_BITS, Merge of bits under mask
212 * @code{MIN}:           MIN,       Minimum value of an argument list
213 * @code{MINEXPONENT}:   MINEXPONENT, Minimum exponent of a real kind
214 * @code{MINLOC}:        MINLOC,    Location of the minimum value within an array
215 * @code{MINVAL}:        MINVAL,    Minimum value of an array
216 * @code{MOD}:           MOD,       Remainder function
217 * @code{MODULO}:        MODULO,    Modulo function
218 * @code{MOVE_ALLOC}:    MOVE_ALLOC, Move allocation from one object to another
219 * @code{MVBITS}:        MVBITS,    Move bits from one integer to another
220 * @code{NEAREST}:       NEAREST,   Nearest representable number
221 * @code{NEW_LINE}:      NEW_LINE,  New line character
222 * @code{NINT}:          NINT,      Nearest whole number
223 * @code{NORM2}:         NORM2,     Euclidean vector norm
224 * @code{NOT}:           NOT,       Logical negation
225 * @code{NULL}:          NULL,      Function that returns an disassociated pointer
226 * @code{NUM_IMAGES}:    NUM_IMAGES, Number of images
227 * @code{OR}:            OR,        Bitwise logical OR
228 * @code{PACK}:          PACK,      Pack an array into an array of rank one
229 * @code{PARITY}:        PARITY,    Reduction with exclusive OR
230 * @code{PERROR}:        PERROR,    Print system error message
231 * @code{POPCNT}:        POPCNT,    Number of bits set
232 * @code{POPPAR}:        POPPAR,    Parity of the number of bits set
233 * @code{PRECISION}:     PRECISION, Decimal precision of a real kind
234 * @code{PRESENT}:       PRESENT,   Determine whether an optional dummy argument is specified
235 * @code{PRODUCT}:       PRODUCT,   Product of array elements
236 * @code{RADIX}:         RADIX,     Base of a data model
237 * @code{RAN}:           RAN,       Real pseudo-random number
238 * @code{RAND}:          RAND,      Real pseudo-random number
239 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
240 * @code{RANDOM_SEED}:   RANDOM_SEED, Initialize a pseudo-random number sequence
241 * @code{RANGE}:         RANGE,     Decimal exponent range
242 * @code{RANK} :         RANK,      Rank of a data object
243 * @code{REAL}:          REAL,      Convert to real type 
244 * @code{RENAME}:        RENAME,    Rename a file
245 * @code{REPEAT}:        REPEAT,    Repeated string concatenation
246 * @code{RESHAPE}:       RESHAPE,   Function to reshape an array
247 * @code{RRSPACING}:     RRSPACING, Reciprocal of the relative spacing
248 * @code{RSHIFT}:        RSHIFT,    Right shift bits
249 * @code{SAME_TYPE_AS}:  SAME_TYPE_AS,  Query dynamic types for equality
250 * @code{SCALE}:         SCALE,     Scale a real value
251 * @code{SCAN}:          SCAN,      Scan a string for the presence of a set of characters
252 * @code{SECNDS}:        SECNDS,    Time function
253 * @code{SECOND}:        SECOND,    CPU time function
254 * @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND,  Choose character kind
255 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND,  Choose integer kind
256 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND,  Choose real kind
257 * @code{SET_EXPONENT}:  SET_EXPONENT, Set the exponent of the model
258 * @code{SHAPE}:         SHAPE,     Determine the shape of an array
259 * @code{SHIFTA}:        SHIFTA,    Right shift with fill
260 * @code{SHIFTL}:        SHIFTL,    Left shift
261 * @code{SHIFTR}:        SHIFTR,    Right shift
262 * @code{SIGN}:          SIGN,      Sign copying function
263 * @code{SIGNAL}:        SIGNAL,    Signal handling subroutine (or function)
264 * @code{SIN}:           SIN,       Sine function
265 * @code{SINH}:          SINH,      Hyperbolic sine function
266 * @code{SIZE}:          SIZE,      Function to determine the size of an array
267 * @code{SIZEOF}:        SIZEOF,    Determine the size in bytes of an expression
268 * @code{SLEEP}:         SLEEP,     Sleep for the specified number of seconds
269 * @code{SPACING}:       SPACING,   Smallest distance between two numbers of a given type
270 * @code{SPREAD}:        SPREAD,    Add a dimension to an array 
271 * @code{SQRT}:          SQRT,      Square-root function
272 * @code{SRAND}:         SRAND,     Reinitialize the random number generator
273 * @code{STAT}:          STAT,      Get file status
274 * @code{STORAGE_SIZE}:  STORAGE_SIZE, Storage size in bits
275 * @code{SUM}:           SUM,       Sum of array elements
276 * @code{SYMLNK}:        SYMLNK,    Create a symbolic link
277 * @code{SYSTEM}:        SYSTEM,    Execute a shell command
278 * @code{SYSTEM_CLOCK}:  SYSTEM_CLOCK, Time function
279 * @code{TAN}:           TAN,       Tangent function
280 * @code{TANH}:          TANH,      Hyperbolic tangent function
281 * @code{THIS_IMAGE}:    THIS_IMAGE, Cosubscript index of this image
282 * @code{TIME}:          TIME,      Time function
283 * @code{TIME8}:         TIME8,     Time function (64-bit)
284 * @code{TINY}:          TINY,      Smallest positive number of a real kind
285 * @code{TRAILZ}:        TRAILZ,    Number of trailing zero bits of an integer
286 * @code{TRANSFER}:      TRANSFER,  Transfer bit patterns
287 * @code{TRANSPOSE}:     TRANSPOSE, Transpose an array of rank two
288 * @code{TRIM}:          TRIM,      Remove trailing blank characters of a string
289 * @code{TTYNAM}:        TTYNAM,    Get the name of a terminal device.
290 * @code{UBOUND}:        UBOUND,    Upper dimension bounds of an array
291 * @code{UCOBOUND}:      UCOBOUND,  Upper codimension bounds of an array
292 * @code{UMASK}:         UMASK,     Set the file creation mask
293 * @code{UNLINK}:        UNLINK,    Remove a file from the file system
294 * @code{UNPACK}:        UNPACK,    Unpack an array of rank one into an array
295 * @code{VERIFY}:        VERIFY,    Scan a string for the absence of a set of characters
296 * @code{XOR}:           XOR,       Bitwise logical exclusive or
297 @end menu
298
299 @node Introduction to Intrinsics
300 @section Introduction to intrinsic procedures
301
302 The intrinsic procedures provided by GNU Fortran include all of the
303 intrinsic procedures required by the Fortran 95 standard, a set of
304 intrinsic procedures for backwards compatibility with G77, and a
305 selection of intrinsic procedures from the Fortran 2003 and Fortran 2008
306 standards.  Any conflict between a description here and a description in
307 either the Fortran 95 standard, the Fortran 2003 standard or the Fortran
308 2008 standard is unintentional, and the standard(s) should be considered
309 authoritative.
310
311 The enumeration of the @code{KIND} type parameter is processor defined in
312 the Fortran 95 standard.  GNU Fortran defines the default integer type and
313 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
314 respectively.  The standard mandates that both data types shall have
315 another kind, which have more precision.  On typical target architectures
316 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
317 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
318 In the description of generic intrinsic procedures, the kind type parameter
319 will be specified by @code{KIND=*}, and in the description of specific
320 names for an intrinsic procedure the kind type parameter will be explicitly
321 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}).  Finally, for
322 brevity the optional @code{KIND=} syntax will be omitted.
323
324 Many of the intrinsic procedures take one or more optional arguments.
325 This document follows the convention used in the Fortran 95 standard,
326 and denotes such arguments by square brackets.
327
328 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
329 which can be used to restrict the set of intrinsic procedures to a 
330 given standard.  By default, @command{gfortran} sets the @option{-std=gnu}
331 option, and so all intrinsic procedures described here are accepted.  There
332 is one caveat.  For a select group of intrinsic procedures, @command{g77}
333 implemented both a function and a subroutine.  Both classes 
334 have been implemented in @command{gfortran} for backwards compatibility
335 with @command{g77}.  It is noted here that these functions and subroutines
336 cannot be intermixed in a given subprogram.  In the descriptions that follow,
337 the applicable standard for each intrinsic procedure is noted.
338
339
340
341 @node ABORT
342 @section @code{ABORT} --- Abort the program
343 @fnindex ABORT
344 @cindex program termination, with core dump
345 @cindex terminate program, with core dump
346 @cindex core, dump
347
348 @table @asis
349 @item @emph{Description}:
350 @code{ABORT} causes immediate termination of the program.  On operating
351 systems that support a core dump, @code{ABORT} will produce a core dump.
352 It will also print a backtrace, unless @code{-fno-backtrace} is given.
353
354 @item @emph{Standard}:
355 GNU extension
356
357 @item @emph{Class}:
358 Subroutine
359
360 @item @emph{Syntax}:
361 @code{CALL ABORT}
362
363 @item @emph{Return value}:
364 Does not return.
365
366 @item @emph{Example}:
367 @smallexample
368 program test_abort
369   integer :: i = 1, j = 2
370   if (i /= j) call abort
371 end program test_abort
372 @end smallexample
373
374 @item @emph{See also}:
375 @ref{EXIT}, @ref{KILL}, @ref{BACKTRACE}
376
377 @end table
378
379
380
381 @node ABS
382 @section @code{ABS} --- Absolute value
383 @fnindex ABS
384 @fnindex CABS
385 @fnindex DABS
386 @fnindex IABS
387 @fnindex ZABS
388 @fnindex CDABS
389 @cindex absolute value
390
391 @table @asis
392 @item @emph{Description}:
393 @code{ABS(A)} computes the absolute value of @code{A}.
394
395 @item @emph{Standard}:
396 Fortran 77 and later, has overloads that are GNU extensions
397
398 @item @emph{Class}:
399 Elemental function
400
401 @item @emph{Syntax}:
402 @code{RESULT = ABS(A)}
403
404 @item @emph{Arguments}:
405 @multitable @columnfractions .15 .70
406 @item @var{A} @tab The type of the argument shall be an @code{INTEGER},
407 @code{REAL}, or @code{COMPLEX}.
408 @end multitable
409
410 @item @emph{Return value}:
411 The return value is of the same type and
412 kind as the argument except the return value is @code{REAL} for a
413 @code{COMPLEX} argument.
414
415 @item @emph{Example}:
416 @smallexample
417 program test_abs
418   integer :: i = -1
419   real :: x = -1.e0
420   complex :: z = (-1.e0,0.e0)
421   i = abs(i)
422   x = abs(x)
423   x = abs(z)
424 end program test_abs
425 @end smallexample
426
427 @item @emph{Specific names}:
428 @multitable @columnfractions .20 .20 .20 .25
429 @item Name            @tab Argument            @tab Return type       @tab Standard
430 @item @code{ABS(A)}   @tab @code{REAL(4) A}    @tab @code{REAL(4)}    @tab Fortran 77 and later
431 @item @code{CABS(A)}  @tab @code{COMPLEX(4) A} @tab @code{REAL(4)}    @tab Fortran 77 and later
432 @item @code{DABS(A)}  @tab @code{REAL(8) A}    @tab @code{REAL(8)}    @tab Fortran 77 and later
433 @item @code{IABS(A)}  @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab Fortran 77 and later
434 @item @code{ZABS(A)}  @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
435 @item @code{CDABS(A)} @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
436 @end multitable
437 @end table
438
439
440
441 @node ACCESS
442 @section @code{ACCESS} --- Checks file access modes
443 @fnindex ACCESS
444 @cindex file system, access mode
445
446 @table @asis
447 @item @emph{Description}:
448 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME} 
449 exists, is readable, writable or executable. Except for the
450 executable check, @code{ACCESS} can be replaced by
451 Fortran 95's @code{INQUIRE}.
452
453 @item @emph{Standard}:
454 GNU extension
455
456 @item @emph{Class}:
457 Inquiry function
458
459 @item @emph{Syntax}:
460 @code{RESULT = ACCESS(NAME, MODE)}
461
462 @item @emph{Arguments}:
463 @multitable @columnfractions .15 .70
464 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
465 file name. Tailing blank are ignored unless the character @code{achar(0)}
466 is present, then all characters up to and excluding @code{achar(0)} are
467 used as file name.
468 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the
469 file access mode, may be any concatenation of @code{"r"} (readable),
470 @code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check
471 for existence.
472 @end multitable
473
474 @item @emph{Return value}:
475 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
476 accessible in the given mode; otherwise or if an invalid argument
477 has been given for @code{MODE} the value @code{1} is returned.
478
479 @item @emph{Example}:
480 @smallexample
481 program access_test
482   implicit none
483   character(len=*), parameter :: file  = 'test.dat'
484   character(len=*), parameter :: file2 = 'test.dat  '//achar(0)
485   if(access(file,' ') == 0) print *, trim(file),' is exists'
486   if(access(file,'r') == 0) print *, trim(file),' is readable'
487   if(access(file,'w') == 0) print *, trim(file),' is writable'
488   if(access(file,'x') == 0) print *, trim(file),' is executable'
489   if(access(file2,'rwx') == 0) &
490     print *, trim(file2),' is readable, writable and executable'
491 end program access_test
492 @end smallexample
493 @item @emph{Specific names}:
494 @item @emph{See also}:
495
496 @end table
497
498
499
500 @node ACHAR
501 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence 
502 @fnindex ACHAR
503 @cindex @acronym{ASCII} collating sequence
504 @cindex collating sequence, @acronym{ASCII}
505
506 @table @asis
507 @item @emph{Description}:
508 @code{ACHAR(I)} returns the character located at position @code{I}
509 in the @acronym{ASCII} collating sequence.
510
511 @item @emph{Standard}:
512 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
513
514 @item @emph{Class}:
515 Elemental function
516
517 @item @emph{Syntax}:
518 @code{RESULT = ACHAR(I [, KIND])}
519
520 @item @emph{Arguments}:
521 @multitable @columnfractions .15 .70
522 @item @var{I}    @tab The type shall be @code{INTEGER}.
523 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
524 expression indicating the kind parameter of the result.
525 @end multitable
526
527 @item @emph{Return value}:
528 The return value is of type @code{CHARACTER} with a length of one.
529 If the @var{KIND} argument is present, the return value is of the
530 specified kind and of the default kind otherwise.
531
532 @item @emph{Example}:
533 @smallexample
534 program test_achar
535   character c
536   c = achar(32)
537 end program test_achar
538 @end smallexample
539
540 @item @emph{Note}:
541 See @ref{ICHAR} for a discussion of converting between numerical values
542 and formatted string representations.
543
544 @item @emph{See also}:
545 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
546
547 @end table
548
549
550
551 @node ACOS
552 @section @code{ACOS} --- Arccosine function 
553 @fnindex ACOS
554 @fnindex DACOS
555 @cindex trigonometric function, cosine, inverse
556 @cindex cosine, inverse
557
558 @table @asis
559 @item @emph{Description}:
560 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
561
562 @item @emph{Standard}:
563 Fortran 77 and later, for a complex argument Fortran 2008 or later
564
565 @item @emph{Class}:
566 Elemental function
567
568 @item @emph{Syntax}:
569 @code{RESULT = ACOS(X)}
570
571 @item @emph{Arguments}:
572 @multitable @columnfractions .15 .70
573 @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
574 less than or equal to one - or the type shall be @code{COMPLEX}.
575 @end multitable
576
577 @item @emph{Return value}:
578 The return value is of the same type and kind as @var{X}.
579 The real part of the result is in radians and lies in the range
580 @math{0 \leq \Re \acos(x) \leq \pi}.
581
582 @item @emph{Example}:
583 @smallexample
584 program test_acos
585   real(8) :: x = 0.866_8
586   x = acos(x)
587 end program test_acos
588 @end smallexample
589
590 @item @emph{Specific names}:
591 @multitable @columnfractions .20 .20 .20 .25
592 @item Name            @tab Argument         @tab Return type     @tab Standard
593 @item @code{ACOS(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}  @tab Fortran 77 and later
594 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}  @tab Fortran 77 and later
595 @end multitable
596
597 @item @emph{See also}:
598 Inverse function: @ref{COS}
599
600 @end table
601
602
603
604 @node ACOSH
605 @section @code{ACOSH} --- Inverse hyperbolic cosine function
606 @fnindex ACOSH
607 @fnindex DACOSH
608 @cindex area hyperbolic cosine
609 @cindex inverse hyperbolic cosine
610 @cindex hyperbolic function, cosine, inverse
611 @cindex cosine, hyperbolic, inverse
612
613 @table @asis
614 @item @emph{Description}:
615 @code{ACOSH(X)} computes the inverse hyperbolic cosine of @var{X}.
616
617 @item @emph{Standard}:
618 Fortran 2008 and later
619
620 @item @emph{Class}:
621 Elemental function
622
623 @item @emph{Syntax}:
624 @code{RESULT = ACOSH(X)}
625
626 @item @emph{Arguments}:
627 @multitable @columnfractions .15 .70
628 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
629 @end multitable
630
631 @item @emph{Return value}:
632 The return value has the same type and kind as @var{X}. If @var{X} is
633 complex, the imaginary part of the result is in radians and lies between
634 @math{ 0 \leq \Im \acosh(x) \leq \pi}.
635
636 @item @emph{Example}:
637 @smallexample
638 PROGRAM test_acosh
639   REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
640   WRITE (*,*) ACOSH(x)
641 END PROGRAM
642 @end smallexample
643
644 @item @emph{Specific names}:
645 @multitable @columnfractions .20 .20 .20 .25
646 @item Name             @tab Argument          @tab Return type       @tab Standard
647 @item @code{DACOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
648 @end multitable
649
650 @item @emph{See also}:
651 Inverse function: @ref{COSH}
652 @end table
653
654
655
656 @node ADJUSTL
657 @section @code{ADJUSTL} --- Left adjust a string 
658 @fnindex ADJUSTL
659 @cindex string, adjust left
660 @cindex adjust string
661
662 @table @asis
663 @item @emph{Description}:
664 @code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
665 Spaces are inserted at the end of the string as needed.
666
667 @item @emph{Standard}:
668 Fortran 90 and later
669
670 @item @emph{Class}:
671 Elemental function
672
673 @item @emph{Syntax}:
674 @code{RESULT = ADJUSTL(STRING)}
675
676 @item @emph{Arguments}:
677 @multitable @columnfractions .15 .70
678 @item @var{STRING} @tab The type shall be @code{CHARACTER}.
679 @end multitable
680
681 @item @emph{Return value}:
682 The return value is of type @code{CHARACTER} and of the same kind as
683 @var{STRING} where leading spaces are removed and the same number of
684 spaces are inserted on the end of @var{STRING}.
685
686 @item @emph{Example}:
687 @smallexample
688 program test_adjustl
689   character(len=20) :: str = '   gfortran'
690   str = adjustl(str)
691   print *, str
692 end program test_adjustl
693 @end smallexample
694
695 @item @emph{See also}:
696 @ref{ADJUSTR}, @ref{TRIM}
697 @end table
698
699
700
701 @node ADJUSTR
702 @section @code{ADJUSTR} --- Right adjust a string 
703 @fnindex ADJUSTR
704 @cindex string, adjust right
705 @cindex adjust string
706
707 @table @asis
708 @item @emph{Description}:
709 @code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
710 Spaces are inserted at the start of the string as needed.
711
712 @item @emph{Standard}:
713 Fortran 95 and later
714
715 @item @emph{Class}:
716 Elemental function
717
718 @item @emph{Syntax}:
719 @code{RESULT = ADJUSTR(STRING)}
720
721 @item @emph{Arguments}:
722 @multitable @columnfractions .15 .70
723 @item @var{STR} @tab The type shall be @code{CHARACTER}.
724 @end multitable
725
726 @item @emph{Return value}:
727 The return value is of type @code{CHARACTER} and of the same kind as
728 @var{STRING} where trailing spaces are removed and the same number of
729 spaces are inserted at the start of @var{STRING}.
730
731 @item @emph{Example}:
732 @smallexample
733 program test_adjustr
734   character(len=20) :: str = 'gfortran'
735   str = adjustr(str)
736   print *, str
737 end program test_adjustr
738 @end smallexample
739
740 @item @emph{See also}:
741 @ref{ADJUSTL}, @ref{TRIM}
742 @end table
743
744
745
746 @node AIMAG
747 @section @code{AIMAG} --- Imaginary part of complex number  
748 @fnindex AIMAG
749 @fnindex DIMAG
750 @fnindex IMAG
751 @fnindex IMAGPART
752 @cindex complex numbers, imaginary part
753
754 @table @asis
755 @item @emph{Description}:
756 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
757 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
758 for compatibility with @command{g77}, and their use in new code is 
759 strongly discouraged.
760
761 @item @emph{Standard}:
762 Fortran 77 and later, has overloads that are GNU extensions
763
764 @item @emph{Class}:
765 Elemental function
766
767 @item @emph{Syntax}:
768 @code{RESULT = AIMAG(Z)}
769
770 @item @emph{Arguments}:
771 @multitable @columnfractions .15 .70
772 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
773 @end multitable
774
775 @item @emph{Return value}:
776 The return value is of type @code{REAL} with the
777 kind type parameter of the argument.
778
779 @item @emph{Example}:
780 @smallexample
781 program test_aimag
782   complex(4) z4
783   complex(8) z8
784   z4 = cmplx(1.e0_4, 0.e0_4)
785   z8 = cmplx(0.e0_8, 1.e0_8)
786   print *, aimag(z4), dimag(z8)
787 end program test_aimag
788 @end smallexample
789
790 @item @emph{Specific names}:
791 @multitable @columnfractions .20 .20 .20 .25
792 @item Name               @tab Argument            @tab Return type     @tab Standard
793 @item @code{AIMAG(Z)}    @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
794 @item @code{DIMAG(Z)}    @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)}  @tab GNU extension
795 @item @code{IMAG(Z)}     @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
796 @item @code{IMAGPART(Z)} @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
797 @end multitable
798 @end table
799
800
801
802 @node AINT
803 @section @code{AINT} --- Truncate to a whole number
804 @fnindex AINT
805 @fnindex DINT
806 @cindex floor
807 @cindex rounding, floor
808
809 @table @asis
810 @item @emph{Description}:
811 @code{AINT(A [, KIND])} truncates its argument to a whole number.
812
813 @item @emph{Standard}:
814 Fortran 77 and later
815
816 @item @emph{Class}:
817 Elemental function
818
819 @item @emph{Syntax}:
820 @code{RESULT = AINT(A [, KIND])} 
821
822 @item @emph{Arguments}:
823 @multitable @columnfractions .15 .70
824 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
825 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
826 expression indicating the kind parameter of the result.
827 @end multitable
828
829 @item @emph{Return value}:
830 The return value is of type @code{REAL} with the kind type parameter of the
831 argument if the optional @var{KIND} is absent; otherwise, the kind
832 type parameter will be given by @var{KIND}.  If the magnitude of 
833 @var{X} is less than one, @code{AINT(X)} returns zero.  If the
834 magnitude is equal to or greater than one then it returns the largest
835 whole number that does not exceed its magnitude.  The sign is the same
836 as the sign of @var{X}. 
837
838 @item @emph{Example}:
839 @smallexample
840 program test_aint
841   real(4) x4
842   real(8) x8
843   x4 = 1.234E0_4
844   x8 = 4.321_8
845   print *, aint(x4), dint(x8)
846   x8 = aint(x4,8)
847 end program test_aint
848 @end smallexample
849
850 @item @emph{Specific names}:
851 @multitable @columnfractions .20 .20 .20 .25
852 @item Name           @tab Argument         @tab Return type      @tab Standard
853 @item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)}   @tab Fortran 77 and later
854 @item @code{DINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)}   @tab Fortran 77 and later
855 @end multitable
856 @end table
857
858
859
860 @node ALARM
861 @section @code{ALARM} --- Execute a routine after a given delay
862 @fnindex ALARM
863 @cindex delayed execution
864
865 @table @asis
866 @item @emph{Description}:
867 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
868 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
869 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
870 supplied, it will be returned with the number of seconds remaining until
871 any previously scheduled alarm was due to be delivered, or zero if there
872 was no previously scheduled alarm.
873
874 @item @emph{Standard}:
875 GNU extension
876
877 @item @emph{Class}:
878 Subroutine
879
880 @item @emph{Syntax}:
881 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
882
883 @item @emph{Arguments}:
884 @multitable @columnfractions .15 .70
885 @item @var{SECONDS} @tab The type of the argument shall be a scalar
886 @code{INTEGER}. It is @code{INTENT(IN)}.
887 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
888 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar 
889 values may be either @code{SIG_IGN=1} to ignore the alarm generated 
890 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
891 @item @var{STATUS}  @tab (Optional) @var{STATUS} shall be a scalar
892 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
893 @end multitable
894
895 @item @emph{Example}:
896 @smallexample
897 program test_alarm
898   external handler_print
899   integer i
900   call alarm (3, handler_print, i)
901   print *, i
902   call sleep(10)
903 end program test_alarm
904 @end smallexample
905 This will cause the external routine @var{handler_print} to be called
906 after 3 seconds.
907 @end table
908
909
910
911 @node ALL
912 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true 
913 @fnindex ALL
914 @cindex array, apply condition
915 @cindex array, condition testing
916
917 @table @asis
918 @item @emph{Description}:
919 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
920 in the array along dimension @var{DIM}.
921
922 @item @emph{Standard}:
923 Fortran 95 and later
924
925 @item @emph{Class}:
926 Transformational function
927
928 @item @emph{Syntax}:
929 @code{RESULT = ALL(MASK [, DIM])}
930
931 @item @emph{Arguments}:
932 @multitable @columnfractions .15 .70
933 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
934 it shall not be scalar.
935 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
936 with a value that lies between one and the rank of @var{MASK}.
937 @end multitable
938
939 @item @emph{Return value}:
940 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where
941 the kind type parameter is the same as the kind type parameter of
942 @var{MASK}.  If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
943 an array with the rank of @var{MASK} minus 1.  The shape is determined from
944 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
945
946 @table @asis
947 @item (A)
948 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
949 It also is true if @var{MASK} has zero size; otherwise, it is false.
950 @item (B)
951 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
952 to @code{ALL(MASK)}.  If the rank is greater than one, then @code{ALL(MASK,DIM)}
953 is determined by applying @code{ALL} to the array sections.
954 @end table
955
956 @item @emph{Example}:
957 @smallexample
958 program test_all
959   logical l
960   l = all((/.true., .true., .true./))
961   print *, l
962   call section
963   contains
964     subroutine section
965       integer a(2,3), b(2,3)
966       a = 1
967       b = 1
968       b(2,2) = 2
969       print *, all(a .eq. b, 1)
970       print *, all(a .eq. b, 2)
971     end subroutine section
972 end program test_all
973 @end smallexample
974 @end table
975
976
977
978 @node ALLOCATED
979 @section @code{ALLOCATED} --- Status of an allocatable entity
980 @fnindex ALLOCATED
981 @cindex allocation, status
982
983 @table @asis
984 @item @emph{Description}:
985 @code{ALLOCATED(ARRAY)} and @code{ALLOCATED(SCALAR)} check the allocation
986 status of @var{ARRAY} and @var{SCALAR}, respectively.
987
988 @item @emph{Standard}:
989 Fortran 95 and later.  Note, the @code{SCALAR=} keyword and allocatable
990 scalar entities are available in Fortran 2003 and later.
991
992 @item @emph{Class}:
993 Inquiry function
994
995 @item @emph{Syntax}:
996 @multitable @columnfractions .80
997 @item @code{RESULT = ALLOCATED(ARRAY)}
998 @item @code{RESULT = ALLOCATED(SCALAR)} 
999 @end multitable
1000
1001 @item @emph{Arguments}:
1002 @multitable @columnfractions .15 .70
1003 @item @var{ARRAY}    @tab The argument shall be an @code{ALLOCATABLE} array.
1004 @item @var{SCALAR}   @tab The argument shall be an @code{ALLOCATABLE} scalar.
1005 @end multitable
1006
1007 @item @emph{Return value}:
1008 The return value is a scalar @code{LOGICAL} with the default logical
1009 kind type parameter.  If the argument is allocated, then the result is
1010 @code{.TRUE.}; otherwise, it returns @code{.FALSE.} 
1011
1012 @item @emph{Example}:
1013 @smallexample
1014 program test_allocated
1015   integer :: i = 4
1016   real(4), allocatable :: x(:)
1017   if (.not. allocated(x)) allocate(x(i))
1018 end program test_allocated
1019 @end smallexample
1020 @end table
1021
1022
1023
1024 @node AND
1025 @section @code{AND} --- Bitwise logical AND
1026 @fnindex AND
1027 @cindex bitwise logical and
1028 @cindex logical and, bitwise
1029
1030 @table @asis
1031 @item @emph{Description}:
1032 Bitwise logical @code{AND}.
1033
1034 This intrinsic routine is provided for backwards compatibility with 
1035 GNU Fortran 77.  For integer arguments, programmers should consider
1036 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
1037
1038 @item @emph{Standard}:
1039 GNU extension
1040
1041 @item @emph{Class}:
1042 Function
1043
1044 @item @emph{Syntax}:
1045 @code{RESULT = AND(I, J)}
1046
1047 @item @emph{Arguments}:
1048 @multitable @columnfractions .15 .70
1049 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
1050 type or a scalar @code{LOGICAL} type.
1051 @item @var{J} @tab The type shall be the same as the type of @var{I}.
1052 @end multitable
1053
1054 @item @emph{Return value}:
1055 The return type is either a scalar @code{INTEGER} or a scalar
1056 @code{LOGICAL}.  If the kind type parameters differ, then the
1057 smaller kind type is implicitly converted to larger kind, and the 
1058 return has the larger kind.
1059
1060 @item @emph{Example}:
1061 @smallexample
1062 PROGRAM test_and
1063   LOGICAL :: T = .TRUE., F = .FALSE.
1064   INTEGER :: a, b
1065   DATA a / Z'F' /, b / Z'3' /
1066
1067   WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1068   WRITE (*,*) AND(a, b)
1069 END PROGRAM
1070 @end smallexample
1071
1072 @item @emph{See also}:
1073 Fortran 95 elemental function: @ref{IAND}
1074 @end table
1075
1076
1077
1078 @node ANINT
1079 @section @code{ANINT} --- Nearest whole number
1080 @fnindex ANINT
1081 @fnindex DNINT
1082 @cindex ceiling
1083 @cindex rounding, ceiling
1084
1085 @table @asis
1086 @item @emph{Description}:
1087 @code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1088
1089 @item @emph{Standard}:
1090 Fortran 77 and later
1091
1092 @item @emph{Class}:
1093 Elemental function
1094
1095 @item @emph{Syntax}:
1096 @code{RESULT = ANINT(A [, KIND])}
1097
1098 @item @emph{Arguments}:
1099 @multitable @columnfractions .15 .70
1100 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
1101 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
1102 expression indicating the kind parameter of the result.
1103 @end multitable
1104
1105 @item @emph{Return value}:
1106 The return value is of type real with the kind type parameter of the
1107 argument if the optional @var{KIND} is absent; otherwise, the kind
1108 type parameter will be given by @var{KIND}.  If @var{A} is greater than
1109 zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}.  If @var{A} is
1110 less than or equal to zero then it returns @code{AINT(X-0.5)}.
1111
1112 @item @emph{Example}:
1113 @smallexample
1114 program test_anint
1115   real(4) x4
1116   real(8) x8
1117   x4 = 1.234E0_4
1118   x8 = 4.321_8
1119   print *, anint(x4), dnint(x8)
1120   x8 = anint(x4,8)
1121 end program test_anint
1122 @end smallexample
1123
1124 @item @emph{Specific names}:
1125 @multitable @columnfractions .20 .20 .20 .25
1126 @item Name            @tab Argument         @tab Return type      @tab Standard
1127 @item @code{AINT(A)}  @tab @code{REAL(4) A} @tab @code{REAL(4)}   @tab Fortran 77 and later
1128 @item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)}   @tab Fortran 77 and later
1129 @end multitable
1130 @end table
1131
1132
1133
1134 @node ANY
1135 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true 
1136 @fnindex ANY
1137 @cindex array, apply condition
1138 @cindex array, condition testing
1139
1140 @table @asis
1141 @item @emph{Description}:
1142 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1143 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1144
1145 @item @emph{Standard}:
1146 Fortran 95 and later
1147
1148 @item @emph{Class}:
1149 Transformational function
1150
1151 @item @emph{Syntax}:
1152 @code{RESULT = ANY(MASK [, DIM])}
1153
1154 @item @emph{Arguments}:
1155 @multitable @columnfractions .15 .70
1156 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1157 it shall not be scalar.
1158 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
1159 with a value that lies between one and the rank of @var{MASK}.
1160 @end multitable
1161
1162 @item @emph{Return value}:
1163 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1164 the kind type parameter is the same as the kind type parameter of
1165 @var{MASK}.  If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1166 an array with the rank of @var{MASK} minus 1.  The shape is determined from
1167 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
1168
1169 @table @asis
1170 @item (A)
1171 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1172 otherwise, it is false.  It also is false if @var{MASK} has zero size.
1173 @item (B)
1174 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1175 to @code{ANY(MASK)}.  If the rank is greater than one, then @code{ANY(MASK,DIM)}
1176 is determined by applying @code{ANY} to the array sections.
1177 @end table
1178
1179 @item @emph{Example}:
1180 @smallexample
1181 program test_any
1182   logical l
1183   l = any((/.true., .true., .true./))
1184   print *, l
1185   call section
1186   contains
1187     subroutine section
1188       integer a(2,3), b(2,3)
1189       a = 1
1190       b = 1
1191       b(2,2) = 2
1192       print *, any(a .eq. b, 1)
1193       print *, any(a .eq. b, 2)
1194     end subroutine section
1195 end program test_any
1196 @end smallexample
1197 @end table
1198
1199
1200
1201 @node ASIN
1202 @section @code{ASIN} --- Arcsine function 
1203 @fnindex ASIN
1204 @fnindex DASIN
1205 @cindex trigonometric function, sine, inverse
1206 @cindex sine, inverse
1207
1208 @table @asis
1209 @item @emph{Description}:
1210 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1211
1212 @item @emph{Standard}:
1213 Fortran 77 and later, for a complex argument Fortran 2008 or later
1214
1215 @item @emph{Class}:
1216 Elemental function
1217
1218 @item @emph{Syntax}:
1219 @code{RESULT = ASIN(X)}
1220
1221 @item @emph{Arguments}:
1222 @multitable @columnfractions .15 .70
1223 @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1224 less than or equal to one - or be @code{COMPLEX}.
1225 @end multitable
1226
1227 @item @emph{Return value}:
1228 The return value is of the same type and kind as @var{X}.
1229 The real part of the result is in radians and lies in the range
1230 @math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}.
1231
1232 @item @emph{Example}:
1233 @smallexample
1234 program test_asin
1235   real(8) :: x = 0.866_8
1236   x = asin(x)
1237 end program test_asin
1238 @end smallexample
1239
1240 @item @emph{Specific names}:
1241 @multitable @columnfractions .20 .20 .20 .25
1242 @item Name            @tab Argument          @tab Return type       @tab Standard
1243 @item @code{ASIN(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
1244 @item @code{DASIN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1245 @end multitable
1246
1247 @item @emph{See also}:
1248 Inverse function: @ref{SIN}
1249
1250 @end table
1251
1252
1253
1254 @node ASINH
1255 @section @code{ASINH} --- Inverse hyperbolic sine function
1256 @fnindex ASINH
1257 @fnindex DASINH
1258 @cindex area hyperbolic sine
1259 @cindex inverse hyperbolic sine
1260 @cindex hyperbolic function, sine, inverse
1261 @cindex sine, hyperbolic, inverse
1262
1263 @table @asis
1264 @item @emph{Description}:
1265 @code{ASINH(X)} computes the inverse hyperbolic sine of @var{X}.
1266
1267 @item @emph{Standard}:
1268 Fortran 2008 and later
1269
1270 @item @emph{Class}:
1271 Elemental function
1272
1273 @item @emph{Syntax}:
1274 @code{RESULT = ASINH(X)}
1275
1276 @item @emph{Arguments}:
1277 @multitable @columnfractions .15 .70
1278 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1279 @end multitable
1280
1281 @item @emph{Return value}:
1282 The return value is of the same type and kind as  @var{X}. If @var{X} is
1283 complex, the imaginary part of the result is in radians and lies between
1284 @math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}.
1285
1286 @item @emph{Example}:
1287 @smallexample
1288 PROGRAM test_asinh
1289   REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1290   WRITE (*,*) ASINH(x)
1291 END PROGRAM
1292 @end smallexample
1293
1294 @item @emph{Specific names}:
1295 @multitable @columnfractions .20 .20 .20 .25
1296 @item Name             @tab Argument          @tab Return type       @tab Standard
1297 @item @code{DASINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension.
1298 @end multitable
1299
1300 @item @emph{See also}:
1301 Inverse function: @ref{SINH}
1302 @end table
1303
1304
1305
1306 @node ASSOCIATED
1307 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair 
1308 @fnindex ASSOCIATED
1309 @cindex pointer, status
1310 @cindex association status
1311
1312 @table @asis
1313 @item @emph{Description}:
1314 @code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1315 @var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
1316
1317 @item @emph{Standard}:
1318 Fortran 95 and later
1319
1320 @item @emph{Class}:
1321 Inquiry function
1322
1323 @item @emph{Syntax}:
1324 @code{RESULT = ASSOCIATED(POINTER [, TARGET])}
1325
1326 @item @emph{Arguments}:
1327 @multitable @columnfractions .15 .70
1328 @item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1329 and it can be of any type.
1330 @item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1331 a target.  It must have the same type, kind type parameter, and
1332 array rank as @var{POINTER}.
1333 @end multitable
1334 The association status of neither @var{POINTER} nor @var{TARGET} shall be
1335 undefined.
1336
1337 @item @emph{Return value}:
1338 @code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
1339 There are several cases:
1340 @table @asis
1341 @item (A) When the optional @var{TARGET} is not present then
1342 @code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1343 @item (B) If @var{TARGET} is present and a scalar target, the result is true if
1344 @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
1345 disassociated, the result is false.
1346 @item (C) If @var{TARGET} is present and an array target, the result is true if
1347 @var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1348 are arrays whose elements are not zero-sized storage sequences, and
1349 @var{TARGET} and @var{POINTER} occupy the same storage units in array element
1350 order.
1351 As in case(B), the result is false, if @var{POINTER} is disassociated.
1352 @item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1353 if @var{TARGET} is associated with @var{POINTER}, the target associated with
1354 @var{TARGET} are not zero-sized storage sequences and occupy the same storage
1355 units.
1356 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1357 @item (E) If @var{TARGET} is present and an array pointer, the result is true if
1358 target associated with @var{POINTER} and the target associated with @var{TARGET}
1359 have the same shape, are not zero-sized arrays, are arrays whose elements are
1360 not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1361 the same storage units in array element order.
1362 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1363 @end table
1364
1365 @item @emph{Example}:
1366 @smallexample
1367 program test_associated
1368    implicit none
1369    real, target  :: tgt(2) = (/1., 2./)
1370    real, pointer :: ptr(:)
1371    ptr => tgt
1372    if (associated(ptr)     .eqv. .false.) call abort
1373    if (associated(ptr,tgt) .eqv. .false.) call abort
1374 end program test_associated
1375 @end smallexample
1376
1377 @item @emph{See also}:
1378 @ref{NULL}
1379 @end table
1380
1381
1382
1383 @node ATAN
1384 @section @code{ATAN} --- Arctangent function 
1385 @fnindex ATAN
1386 @fnindex DATAN
1387 @cindex trigonometric function, tangent, inverse
1388 @cindex tangent, inverse
1389
1390 @table @asis
1391 @item @emph{Description}:
1392 @code{ATAN(X)} computes the arctangent of @var{X}.
1393
1394 @item @emph{Standard}:
1395 Fortran 77 and later, for a complex argument and for two arguments
1396 Fortran 2008 or later
1397
1398 @item @emph{Class}:
1399 Elemental function
1400
1401 @item @emph{Syntax}:
1402 @multitable @columnfractions .80
1403 @item @code{RESULT = ATAN(X)}
1404 @item @code{RESULT = ATAN(Y, X)}
1405 @end multitable
1406
1407 @item @emph{Arguments}:
1408 @multitable @columnfractions .15 .70
1409 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1410 if @var{Y} is present, @var{X} shall be REAL.
1411 @item @var{Y} shall be of the same type and kind as @var{X}.
1412 @end multitable
1413
1414 @item @emph{Return value}:
1415 The return value is of the same type and kind as @var{X}.
1416 If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}.
1417 Otherwise, it the arcus tangent of @var{X}, where the real part of
1418 the result is in radians and lies in the range
1419 @math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}.
1420
1421 @item @emph{Example}:
1422 @smallexample
1423 program test_atan
1424   real(8) :: x = 2.866_8
1425   x = atan(x)
1426 end program test_atan
1427 @end smallexample
1428
1429 @item @emph{Specific names}:
1430 @multitable @columnfractions .20 .20 .20 .25
1431 @item Name            @tab Argument          @tab Return type       @tab Standard
1432 @item @code{ATAN(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
1433 @item @code{DATAN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1434 @end multitable
1435
1436 @item @emph{See also}:
1437 Inverse function: @ref{TAN}
1438
1439 @end table
1440
1441
1442
1443 @node ATAN2
1444 @section @code{ATAN2} --- Arctangent function 
1445 @fnindex ATAN2
1446 @fnindex DATAN2
1447 @cindex trigonometric function, tangent, inverse
1448 @cindex tangent, inverse
1449
1450 @table @asis
1451 @item @emph{Description}:
1452 @code{ATAN2(Y, X)} computes the principal value of the argument
1453 function of the complex number @math{X + i Y}. This function can
1454 be used to transform from Cartesian into polar coordinates and
1455 allows to determine the angle in the correct quadrant.
1456
1457 @item @emph{Standard}:
1458 Fortran 77 and later
1459
1460 @item @emph{Class}:
1461 Elemental function
1462
1463 @item @emph{Syntax}:
1464 @code{RESULT = ATAN2(Y, X)}
1465
1466 @item @emph{Arguments}:
1467 @multitable @columnfractions .15 .70
1468 @item @var{Y} @tab The type shall be @code{REAL}.
1469 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1470 If @var{Y} is zero, then @var{X} must be nonzero.
1471 @end multitable
1472
1473 @item @emph{Return value}:
1474 The return value has the same type and kind type parameter as @var{Y}. It
1475 is the principal value of the complex number @math{X + i Y}.  If @var{X}
1476 is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1477 The sign is positive if @var{Y} is positive.  If @var{Y} is zero, then
1478 the return value is zero if @var{X} is strictly positive, @math{\pi} if
1479 @var{X} is negative and @var{Y} is positive zero (or the processor does
1480 not handle signed zeros), and @math{-\pi} if @var{X} is negative and
1481 @var{Y} is negative zero.  Finally, if @var{X} is zero, then the
1482 magnitude of the result is @math{\pi/2}.
1483
1484 @item @emph{Example}:
1485 @smallexample
1486 program test_atan2
1487   real(4) :: x = 1.e0_4, y = 0.5e0_4
1488   x = atan2(y,x)
1489 end program test_atan2
1490 @end smallexample
1491
1492 @item @emph{Specific names}:
1493 @multitable @columnfractions .20 .20 .20 .25
1494 @item Name                @tab Argument            @tab Return type    @tab Standard
1495 @item @code{ATAN2(X, Y)}  @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
1496 @item @code{DATAN2(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
1497 @end multitable
1498 @end table
1499
1500
1501
1502 @node ATANH
1503 @section @code{ATANH} --- Inverse hyperbolic tangent function
1504 @fnindex ATANH
1505 @fnindex DATANH
1506 @cindex area hyperbolic tangent
1507 @cindex inverse hyperbolic tangent
1508 @cindex hyperbolic function, tangent, inverse
1509 @cindex tangent, hyperbolic, inverse
1510
1511 @table @asis
1512 @item @emph{Description}:
1513 @code{ATANH(X)} computes the inverse hyperbolic tangent of @var{X}.
1514
1515 @item @emph{Standard}:
1516 Fortran 2008 and later
1517
1518 @item @emph{Class}:
1519 Elemental function
1520
1521 @item @emph{Syntax}:
1522 @code{RESULT = ATANH(X)}
1523
1524 @item @emph{Arguments}:
1525 @multitable @columnfractions .15 .70
1526 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1527 @end multitable
1528
1529 @item @emph{Return value}:
1530 The return value has same type and kind as @var{X}. If @var{X} is
1531 complex, the imaginary part of the result is in radians and lies between
1532 @math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}.
1533
1534 @item @emph{Example}:
1535 @smallexample
1536 PROGRAM test_atanh
1537   REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1538   WRITE (*,*) ATANH(x)
1539 END PROGRAM
1540 @end smallexample
1541
1542 @item @emph{Specific names}:
1543 @multitable @columnfractions .20 .20 .20 .25
1544 @item Name             @tab Argument          @tab Return type       @tab Standard
1545 @item @code{DATANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1546 @end multitable
1547
1548 @item @emph{See also}:
1549 Inverse function: @ref{TANH}
1550 @end table
1551
1552
1553
1554 @node ATOMIC_DEFINE
1555 @section @code{ATOMIC_DEFINE} --- Setting a variable atomically
1556 @fnindex ATOMIC_DEFINE
1557 @cindex Atomic subroutine, define
1558
1559 @table @asis
1560 @item @emph{Description}:
1561 @code{ATOMIC_DEFINE(ATOM, VALUE)} defines the variable @var{ATOM} with the value
1562 @var{VALUE} atomically.
1563
1564 @item @emph{Standard}:
1565 Fortran 2008 and later
1566
1567 @item @emph{Class}:
1568 Atomic subroutine
1569
1570 @item @emph{Syntax}:
1571 @code{CALL ATOMIC_DEFINE(ATOM, VALUE)}
1572
1573 @item @emph{Arguments}:
1574 @multitable @columnfractions .15 .70
1575 @item @var{ATOM}   @tab Scalar coarray or coindexed variable of either integer
1576                         type with @code{ATOMIC_INT_KIND} kind or logical type
1577                         with @code{ATOMIC_LOGICAL_KIND} kind.
1578 @item @var{VALURE} @tab Scalar and of the same type as @var{ATOM}. If the kind
1579                         is different, the value is converted to the kind of
1580                         @var{ATOM}.
1581 @end multitable
1582
1583 @item @emph{Example}:
1584 @smallexample
1585 program atomic
1586   use iso_fortran_env
1587   integer(atomic_int_kind) :: atom[*]
1588   call atomic_define (atom[1], this_image())
1589 end program atomic
1590 @end smallexample
1591
1592 @item @emph{See also}:
1593 @ref{ATOMIC_REF}, @ref{ISO_FORTRAN_ENV}
1594 @end table
1595
1596
1597
1598 @node ATOMIC_REF
1599 @section @code{ATOMIC_REF} --- Obtaining the value of a variable atomically
1600 @fnindex ATOMIC_REF
1601 @cindex Atomic subroutine, reference
1602
1603 @table @asis
1604 @item @emph{Description}:
1605 @code{ATOMIC_DEFINE(ATOM, VALUE)} atomically assigns the value of the
1606 variable @var{ATOM} to @var{VALUE}.
1607
1608 @item @emph{Standard}:
1609 Fortran 2008 and later
1610
1611 @item @emph{Class}:
1612 Atomic subroutine
1613
1614 @item @emph{Syntax}:
1615 @code{CALL ATOMIC_REF(VALUE, ATOM)}
1616
1617 @item @emph{Arguments}:
1618 @multitable @columnfractions .15 .70
1619 @item @var{VALURE} @tab Scalar and of the same type as @var{ATOM}. If the kind
1620                         is different, the value is converted to the kind of
1621                         @var{ATOM}.
1622 @item @var{ATOM}   @tab Scalar coarray or coindexed variable of either integer
1623                         type with @code{ATOMIC_INT_KIND} kind or logical type
1624                         with @code{ATOMIC_LOGICAL_KIND} kind.
1625 @end multitable
1626
1627 @item @emph{Example}:
1628 @smallexample
1629 program atomic
1630   use iso_fortran_env
1631   logical(atomic_logical_kind) :: atom[*]
1632   logical :: val
1633   call atomic_ref (atom, .false.)
1634   ! ...
1635   call atomic_ref (atom, val)
1636   if (val) then
1637     print *, "Obtained"
1638   end if
1639 end program atomic
1640 @end smallexample
1641
1642 @item @emph{See also}:
1643 @ref{ATOMIC_DEFINE}, @ref{ISO_FORTRAN_ENV}
1644 @end table
1645
1646
1647
1648 @node BACKTRACE
1649 @section @code{BACKTRACE} --- Show a backtrace
1650 @fnindex BACKTRACE
1651 @cindex backtrace
1652
1653 @table @asis
1654 @item @emph{Description}:
1655 @code{BACKTRACE} shows a backtrace at an arbitrary place in user code. Program
1656 execution continues normally afterwards. The backtrace information is printed
1657 to the unit corresponding to @code{ERROR_UNIT} in @code{ISO_FORTRAN_ENV}.
1658
1659 @item @emph{Standard}:
1660 GNU Extension
1661
1662 @item @emph{Class}:
1663 Subroutine
1664
1665 @item @emph{Syntax}:
1666 @code{CALL BACKTRACE}
1667
1668 @item @emph{Arguments}:
1669 None
1670
1671 @item @emph{See also}:
1672 @ref{ABORT}
1673 @end table
1674
1675
1676
1677 @node BESSEL_J0
1678 @section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
1679 @fnindex BESSEL_J0
1680 @fnindex BESJ0
1681 @fnindex DBESJ0
1682 @cindex Bessel function, first kind
1683
1684 @table @asis
1685 @item @emph{Description}:
1686 @code{BESSEL_J0(X)} computes the Bessel function of the first kind of
1687 order 0 of @var{X}. This function is available under the name
1688 @code{BESJ0} as a GNU extension.
1689
1690 @item @emph{Standard}:
1691 Fortran 2008 and later
1692
1693 @item @emph{Class}:
1694 Elemental function
1695
1696 @item @emph{Syntax}:
1697 @code{RESULT = BESSEL_J0(X)}
1698
1699 @item @emph{Arguments}:
1700 @multitable @columnfractions .15 .70
1701 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1702 @end multitable
1703
1704 @item @emph{Return value}:
1705 The return value is of type @code{REAL} and lies in the
1706 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
1707 kind as @var{X}.
1708
1709 @item @emph{Example}:
1710 @smallexample
1711 program test_besj0
1712   real(8) :: x = 0.0_8
1713   x = bessel_j0(x)
1714 end program test_besj0
1715 @end smallexample
1716
1717 @item @emph{Specific names}:
1718 @multitable @columnfractions .20 .20 .20 .25
1719 @item Name            @tab Argument          @tab Return type       @tab Standard
1720 @item @code{DBESJ0(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}   @tab GNU extension
1721 @end multitable
1722 @end table
1723
1724
1725
1726 @node BESSEL_J1
1727 @section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
1728 @fnindex BESSEL_J1
1729 @fnindex BESJ1
1730 @fnindex DBESJ1
1731 @cindex Bessel function, first kind
1732
1733 @table @asis
1734 @item @emph{Description}:
1735 @code{BESSEL_J1(X)} computes the Bessel function of the first kind of
1736 order 1 of @var{X}. This function is available under the name
1737 @code{BESJ1} as a GNU extension.
1738
1739 @item @emph{Standard}:
1740 Fortran 2008
1741
1742 @item @emph{Class}:
1743 Elemental function
1744
1745 @item @emph{Syntax}:
1746 @code{RESULT = BESSEL_J1(X)}
1747
1748 @item @emph{Arguments}:
1749 @multitable @columnfractions .15 .70
1750 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1751 @end multitable
1752
1753 @item @emph{Return value}:
1754 The return value is of type @code{REAL} and it lies in the
1755 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
1756 kind as @var{X}.
1757
1758 @item @emph{Example}:
1759 @smallexample
1760 program test_besj1
1761   real(8) :: x = 1.0_8
1762   x = bessel_j1(x)
1763 end program test_besj1
1764 @end smallexample
1765
1766 @item @emph{Specific names}:
1767 @multitable @columnfractions .20 .20 .20 .25
1768 @item Name             @tab Argument          @tab Return type       @tab Standard
1769 @item @code{DBESJ1(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1770 @end multitable
1771 @end table
1772
1773
1774
1775 @node BESSEL_JN
1776 @section @code{BESSEL_JN} --- Bessel function of the first kind
1777 @fnindex BESSEL_JN
1778 @fnindex BESJN
1779 @fnindex DBESJN
1780 @cindex Bessel function, first kind
1781
1782 @table @asis
1783 @item @emph{Description}:
1784 @code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
1785 order @var{N} of @var{X}. This function is available under the name
1786 @code{BESJN} as a GNU extension.  If @var{N} and @var{X} are arrays,
1787 their ranks and shapes shall conform.  
1788
1789 @code{BESSEL_JN(N1, N2, X)} returns an array with the Bessel functions
1790 of the first kind of the orders @var{N1} to @var{N2}.
1791
1792 @item @emph{Standard}:
1793 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
1794
1795 @item @emph{Class}:
1796 Elemental function, except for the transformational function
1797 @code{BESSEL_JN(N1, N2, X)}
1798
1799 @item @emph{Syntax}:
1800 @multitable @columnfractions .80
1801 @item @code{RESULT = BESSEL_JN(N, X)}
1802 @item @code{RESULT = BESSEL_JN(N1, N2, X)}
1803 @end multitable
1804
1805 @item @emph{Arguments}:
1806 @multitable @columnfractions .15 .70
1807 @item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER}.
1808 @item @var{N1} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
1809 @item @var{N2} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
1810 @item @var{X} @tab Shall be a scalar or an array of type  @code{REAL};
1811 for @code{BESSEL_JN(N1, N2, X)} it shall be scalar.
1812 @end multitable
1813
1814 @item @emph{Return value}:
1815 The return value is a scalar of type @code{REAL}. It has the same
1816 kind as @var{X}.
1817
1818 @item @emph{Note}:
1819 The transformational function uses a recurrence algorithm which might,
1820 for some values of @var{X}, lead to different results than calls to
1821 the elemental function.
1822
1823 @item @emph{Example}:
1824 @smallexample
1825 program test_besjn
1826   real(8) :: x = 1.0_8
1827   x = bessel_jn(5,x)
1828 end program test_besjn
1829 @end smallexample
1830
1831 @item @emph{Specific names}:
1832 @multitable @columnfractions .20 .20 .20 .25
1833 @item Name                @tab Argument            @tab Return type       @tab Standard
1834 @item @code{DBESJN(N, X)} @tab @code{INTEGER N}    @tab @code{REAL(8)}    @tab GNU extension
1835 @item                     @tab @code{REAL(8) X}    @tab                   @tab
1836 @end multitable
1837 @end table
1838
1839
1840
1841 @node BESSEL_Y0
1842 @section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
1843 @fnindex BESSEL_Y0
1844 @fnindex BESY0
1845 @fnindex DBESY0
1846 @cindex Bessel function, second kind
1847
1848 @table @asis
1849 @item @emph{Description}:
1850 @code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
1851 order 0 of @var{X}. This function is available under the name
1852 @code{BESY0} as a GNU extension.
1853
1854 @item @emph{Standard}:
1855 Fortran 2008 and later
1856
1857 @item @emph{Class}:
1858 Elemental function
1859
1860 @item @emph{Syntax}:
1861 @code{RESULT = BESSEL_Y0(X)}
1862
1863 @item @emph{Arguments}:
1864 @multitable @columnfractions .15 .70
1865 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1866 @end multitable
1867
1868 @item @emph{Return value}:
1869 The return value is a scalar of type @code{REAL}. It has the same
1870 kind as @var{X}.
1871
1872 @item @emph{Example}:
1873 @smallexample
1874 program test_besy0
1875   real(8) :: x = 0.0_8
1876   x = bessel_y0(x)
1877 end program test_besy0
1878 @end smallexample
1879
1880 @item @emph{Specific names}:
1881 @multitable @columnfractions .20 .20 .20 .25
1882 @item Name            @tab Argument          @tab Return type       @tab Standard
1883 @item @code{DBESY0(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1884 @end multitable
1885 @end table
1886
1887
1888
1889 @node BESSEL_Y1
1890 @section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
1891 @fnindex BESSEL_Y1
1892 @fnindex BESY1
1893 @fnindex DBESY1
1894 @cindex Bessel function, second kind
1895
1896 @table @asis
1897 @item @emph{Description}:
1898 @code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
1899 order 1 of @var{X}. This function is available under the name
1900 @code{BESY1} as a GNU extension.
1901
1902 @item @emph{Standard}:
1903 Fortran 2008 and later
1904
1905 @item @emph{Class}:
1906 Elemental function
1907
1908 @item @emph{Syntax}:
1909 @code{RESULT = BESSEL_Y1(X)}
1910
1911 @item @emph{Arguments}:
1912 @multitable @columnfractions .15 .70
1913 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1914 @end multitable
1915
1916 @item @emph{Return value}:
1917 The return value is a scalar of type @code{REAL}. It has the same
1918 kind as @var{X}.
1919
1920 @item @emph{Example}:
1921 @smallexample
1922 program test_besy1
1923   real(8) :: x = 1.0_8
1924   x = bessel_y1(x)
1925 end program test_besy1
1926 @end smallexample
1927
1928 @item @emph{Specific names}:
1929 @multitable @columnfractions .20 .20 .20 .25
1930 @item Name            @tab Argument          @tab Return type       @tab Standard
1931 @item @code{DBESY1(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1932 @end multitable
1933 @end table
1934
1935
1936
1937 @node BESSEL_YN
1938 @section @code{BESSEL_YN} --- Bessel function of the second kind
1939 @fnindex BESSEL_YN
1940 @fnindex BESYN
1941 @fnindex DBESYN
1942 @cindex Bessel function, second kind
1943
1944 @table @asis
1945 @item @emph{Description}:
1946 @code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
1947 order @var{N} of @var{X}. This function is available under the name
1948 @code{BESYN} as a GNU extension.  If @var{N} and @var{X} are arrays,
1949 their ranks and shapes shall conform.  
1950
1951 @code{BESSEL_YN(N1, N2, X)} returns an array with the Bessel functions
1952 of the first kind of the orders @var{N1} to @var{N2}.
1953
1954 @item @emph{Standard}:
1955 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
1956
1957 @item @emph{Class}:
1958 Elemental function, except for the transformational function
1959 @code{BESSEL_YN(N1, N2, X)}
1960
1961 @item @emph{Syntax}:
1962 @multitable @columnfractions .80
1963 @item @code{RESULT = BESSEL_YN(N, X)}
1964 @item @code{RESULT = BESSEL_YN(N1, N2, X)}
1965 @end multitable
1966
1967 @item @emph{Arguments}:
1968 @multitable @columnfractions .15 .70
1969 @item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER} .
1970 @item @var{N1} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
1971 @item @var{N2} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
1972 @item @var{X} @tab Shall be a scalar or an array of type  @code{REAL};
1973 for @code{BESSEL_YN(N1, N2, X)} it shall be scalar.
1974 @end multitable
1975
1976 @item @emph{Return value}:
1977 The return value is a scalar of type @code{REAL}. It has the same
1978 kind as @var{X}.
1979
1980 @item @emph{Note}:
1981 The transformational function uses a recurrence algorithm which might,
1982 for some values of @var{X}, lead to different results than calls to
1983 the elemental function.
1984
1985 @item @emph{Example}:
1986 @smallexample
1987 program test_besyn
1988   real(8) :: x = 1.0_8
1989   x = bessel_yn(5,x)
1990 end program test_besyn
1991 @end smallexample
1992
1993 @item @emph{Specific names}:
1994 @multitable @columnfractions .20 .20 .20 .25
1995 @item Name               @tab Argument            @tab Return type     @tab Standard
1996 @item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)}  @tab GNU extension
1997 @item                    @tab @code{REAL(8) X} @tab                 @tab 
1998 @end multitable
1999 @end table
2000
2001
2002
2003 @node BGE
2004 @section @code{BGE} --- Bitwise greater than or equal to
2005 @fnindex BGE
2006 @cindex bitwise comparison
2007
2008 @table @asis
2009 @item @emph{Description}:
2010 Determines whether an integral is a bitwise greater than or equal to
2011 another.
2012
2013 @item @emph{Standard}:
2014 Fortran 2008 and later
2015
2016 @item @emph{Class}:
2017 Elemental function
2018
2019 @item @emph{Syntax}:
2020 @code{RESULT = BGE(I, J)}
2021
2022 @item @emph{Arguments}:
2023 @multitable @columnfractions .15 .70
2024 @item @var{I} @tab Shall be of @code{INTEGER} type.
2025 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2026 as @var{I}.
2027 @end multitable
2028
2029 @item @emph{Return value}:
2030 The return value is of type @code{LOGICAL} and of the default kind.
2031
2032 @item @emph{See also}:
2033 @ref{BGT}, @ref{BLE}, @ref{BLT}
2034 @end table
2035
2036
2037
2038 @node BGT
2039 @section @code{BGT} --- Bitwise greater than
2040 @fnindex BGT
2041 @cindex bitwise comparison
2042
2043 @table @asis
2044 @item @emph{Description}:
2045 Determines whether an integral is a bitwise greater than another.
2046
2047 @item @emph{Standard}:
2048 Fortran 2008 and later
2049
2050 @item @emph{Class}:
2051 Elemental function
2052
2053 @item @emph{Syntax}:
2054 @code{RESULT = BGT(I, J)}
2055
2056 @item @emph{Arguments}:
2057 @multitable @columnfractions .15 .70
2058 @item @var{I} @tab Shall be of @code{INTEGER} type.
2059 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2060 as @var{I}.
2061 @end multitable
2062
2063 @item @emph{Return value}:
2064 The return value is of type @code{LOGICAL} and of the default kind.
2065
2066 @item @emph{See also}:
2067 @ref{BGE}, @ref{BLE}, @ref{BLT}
2068 @end table
2069
2070
2071
2072 @node BIT_SIZE
2073 @section @code{BIT_SIZE} --- Bit size inquiry function
2074 @fnindex BIT_SIZE
2075 @cindex bits, number of
2076 @cindex size of a variable, in bits
2077
2078 @table @asis
2079 @item @emph{Description}:
2080 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
2081 represented by the type of @var{I}.  The result of @code{BIT_SIZE(I)} is
2082 independent of the actual value of @var{I}.
2083
2084 @item @emph{Standard}:
2085 Fortran 95 and later
2086
2087 @item @emph{Class}:
2088 Inquiry function
2089
2090 @item @emph{Syntax}:
2091 @code{RESULT = BIT_SIZE(I)}
2092
2093 @item @emph{Arguments}:
2094 @multitable @columnfractions .15 .70
2095 @item @var{I} @tab The type shall be @code{INTEGER}.
2096 @end multitable
2097
2098 @item @emph{Return value}:
2099 The return value is of type @code{INTEGER}
2100
2101 @item @emph{Example}:
2102 @smallexample
2103 program test_bit_size
2104     integer :: i = 123
2105     integer :: size
2106     size = bit_size(i)
2107     print *, size
2108 end program test_bit_size
2109 @end smallexample
2110 @end table
2111
2112
2113
2114 @node BLE
2115 @section @code{BLE} --- Bitwise less than or equal to
2116 @fnindex BLE
2117 @cindex bitwise comparison
2118
2119 @table @asis
2120 @item @emph{Description}:
2121 Determines whether an integral is a bitwise less than or equal to
2122 another.
2123
2124 @item @emph{Standard}:
2125 Fortran 2008 and later
2126
2127 @item @emph{Class}:
2128 Elemental function
2129
2130 @item @emph{Syntax}:
2131 @code{RESULT = BLE(I, J)}
2132
2133 @item @emph{Arguments}:
2134 @multitable @columnfractions .15 .70
2135 @item @var{I} @tab Shall be of @code{INTEGER} type.
2136 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2137 as @var{I}.
2138 @end multitable
2139
2140 @item @emph{Return value}:
2141 The return value is of type @code{LOGICAL} and of the default kind.
2142
2143 @item @emph{See also}:
2144 @ref{BGT}, @ref{BGE}, @ref{BLT}
2145 @end table
2146
2147
2148
2149 @node BLT
2150 @section @code{BLT} --- Bitwise less than
2151 @fnindex BLT
2152 @cindex bitwise comparison
2153
2154 @table @asis
2155 @item @emph{Description}:
2156 Determines whether an integral is a bitwise less than another.
2157
2158 @item @emph{Standard}:
2159 Fortran 2008 and later
2160
2161 @item @emph{Class}:
2162 Elemental function
2163
2164 @item @emph{Syntax}:
2165 @code{RESULT = BLT(I, J)}
2166
2167 @item @emph{Arguments}:
2168 @multitable @columnfractions .15 .70
2169 @item @var{I} @tab Shall be of @code{INTEGER} type.
2170 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2171 as @var{I}.
2172 @end multitable
2173
2174 @item @emph{Return value}:
2175 The return value is of type @code{LOGICAL} and of the default kind.
2176
2177 @item @emph{See also}:
2178 @ref{BGE}, @ref{BGT}, @ref{BLE}
2179 @end table
2180
2181
2182
2183 @node BTEST
2184 @section @code{BTEST} --- Bit test function
2185 @fnindex BTEST
2186 @cindex bits, testing
2187
2188 @table @asis
2189 @item @emph{Description}:
2190 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
2191 in @var{I} is set.  The counting of the bits starts at 0.
2192
2193 @item @emph{Standard}:
2194 Fortran 95 and later
2195
2196 @item @emph{Class}:
2197 Elemental function
2198
2199 @item @emph{Syntax}:
2200 @code{RESULT = BTEST(I, POS)}
2201
2202 @item @emph{Arguments}:
2203 @multitable @columnfractions .15 .70
2204 @item @var{I} @tab The type shall be @code{INTEGER}.
2205 @item @var{POS} @tab The type shall be @code{INTEGER}.
2206 @end multitable
2207
2208 @item @emph{Return value}:
2209 The return value is of type @code{LOGICAL}
2210
2211 @item @emph{Example}:
2212 @smallexample
2213 program test_btest
2214     integer :: i = 32768 + 1024 + 64
2215     integer :: pos
2216     logical :: bool
2217     do pos=0,16
2218         bool = btest(i, pos) 
2219         print *, pos, bool
2220     end do
2221 end program test_btest
2222 @end smallexample
2223 @end table
2224
2225
2226 @node C_ASSOCIATED
2227 @section @code{C_ASSOCIATED} --- Status of a C pointer
2228 @fnindex C_ASSOCIATED
2229 @cindex association status, C pointer
2230 @cindex pointer, C association status
2231
2232 @table @asis
2233 @item @emph{Description}:
2234 @code{C_ASSOCIATED(c_prt_1[, c_ptr_2])} determines the status of the C pointer
2235 @var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
2236
2237 @item @emph{Standard}:
2238 Fortran 2003 and later
2239
2240 @item @emph{Class}:
2241 Inquiry function
2242
2243 @item @emph{Syntax}:
2244 @code{RESULT = C_ASSOCIATED(c_prt_1[, c_ptr_2])}
2245
2246 @item @emph{Arguments}:
2247 @multitable @columnfractions .15 .70
2248 @item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
2249 @item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
2250 @end multitable
2251
2252 @item @emph{Return value}:
2253 The return value is of type @code{LOGICAL}; it is @code{.false.} if either
2254 @var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
2255 point to different addresses.
2256
2257 @item @emph{Example}:
2258 @smallexample
2259 subroutine association_test(a,b)
2260   use iso_c_binding, only: c_associated, c_loc, c_ptr
2261   implicit none
2262   real, pointer :: a
2263   type(c_ptr) :: b
2264   if(c_associated(b, c_loc(a))) &
2265      stop 'b and a do not point to same target'
2266 end subroutine association_test
2267 @end smallexample
2268
2269 @item @emph{See also}:
2270 @ref{C_LOC}, @ref{C_FUNLOC}
2271 @end table
2272
2273
2274 @node C_F_POINTER
2275 @section @code{C_F_POINTER} --- Convert C into Fortran pointer
2276 @fnindex C_F_POINTER
2277 @cindex pointer, convert C to Fortran
2278
2279 @table @asis
2280 @item @emph{Description}:
2281 @code{C_F_POINTER(CPTR, FPTR[, SHAPE])} assigns the target of the C pointer
2282 @var{CPTR} to the Fortran pointer @var{FPTR} and specifies its shape.
2283
2284 @item @emph{Standard}:
2285 Fortran 2003 and later
2286
2287 @item @emph{Class}:
2288 Subroutine
2289
2290 @item @emph{Syntax}:
2291 @code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
2292
2293 @item @emph{Arguments}:
2294 @multitable @columnfractions .15 .70
2295 @item @var{CPTR}  @tab scalar of the type @code{C_PTR}. It is
2296 @code{INTENT(IN)}.
2297 @item @var{FPTR}  @tab pointer interoperable with @var{cptr}. It is
2298 @code{INTENT(OUT)}.
2299 @item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
2300 with @code{INTENT(IN)}. It shall be present
2301 if and only if @var{fptr} is an array. The size
2302 must be equal to the rank of @var{fptr}.
2303 @end multitable
2304
2305 @item @emph{Example}:
2306 @smallexample
2307 program main
2308   use iso_c_binding
2309   implicit none
2310   interface
2311     subroutine my_routine(p) bind(c,name='myC_func')
2312       import :: c_ptr
2313       type(c_ptr), intent(out) :: p
2314     end subroutine
2315   end interface
2316   type(c_ptr) :: cptr
2317   real,pointer :: a(:)
2318   call my_routine(cptr)
2319   call c_f_pointer(cptr, a, [12])
2320 end program main
2321 @end smallexample
2322
2323 @item @emph{See also}:
2324 @ref{C_LOC}, @ref{C_F_PROCPOINTER}
2325 @end table
2326
2327
2328 @node C_F_PROCPOINTER
2329 @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
2330 @fnindex C_F_PROCPOINTER
2331 @cindex pointer, C address of pointers
2332
2333 @table @asis
2334 @item @emph{Description}:
2335 @code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
2336 @var{CPTR} to the Fortran procedure pointer @var{FPTR}.
2337
2338 @item @emph{Standard}:
2339 Fortran 2003 and later
2340
2341 @item @emph{Class}:
2342 Subroutine
2343
2344 @item @emph{Syntax}:
2345 @code{CALL C_F_PROCPOINTER(cptr, fptr)}
2346
2347 @item @emph{Arguments}:
2348 @multitable @columnfractions .15 .70
2349 @item @var{CPTR}  @tab scalar of the type @code{C_FUNPTR}. It is
2350 @code{INTENT(IN)}.
2351 @item @var{FPTR}  @tab procedure pointer interoperable with @var{cptr}. It is
2352 @code{INTENT(OUT)}.
2353 @end multitable
2354
2355 @item @emph{Example}:
2356 @smallexample
2357 program main
2358   use iso_c_binding
2359   implicit none
2360   abstract interface
2361     function func(a)
2362       import :: c_float
2363       real(c_float), intent(in) :: a
2364       real(c_float) :: func
2365     end function
2366   end interface
2367   interface
2368      function getIterFunc() bind(c,name="getIterFunc")
2369        import :: c_funptr
2370        type(c_funptr) :: getIterFunc
2371      end function
2372   end interface
2373   type(c_funptr) :: cfunptr
2374   procedure(func), pointer :: myFunc
2375   cfunptr = getIterFunc()
2376   call c_f_procpointer(cfunptr, myFunc)
2377 end program main
2378 @end smallexample
2379
2380 @item @emph{See also}:
2381 @ref{C_LOC}, @ref{C_F_POINTER}
2382 @end table
2383
2384
2385 @node C_FUNLOC
2386 @section @code{C_FUNLOC} --- Obtain the C address of a procedure
2387 @fnindex C_FUNLOC
2388 @cindex pointer, C address of procedures
2389
2390 @table @asis
2391 @item @emph{Description}:
2392 @code{C_FUNLOC(x)} determines the C address of the argument.
2393
2394 @item @emph{Standard}:
2395 Fortran 2003 and later
2396
2397 @item @emph{Class}:
2398 Inquiry function
2399
2400 @item @emph{Syntax}:
2401 @code{RESULT = C_FUNLOC(x)}
2402
2403 @item @emph{Arguments}:
2404 @multitable @columnfractions .15 .70
2405 @item @var{x} @tab Interoperable function or pointer to such function.
2406 @end multitable
2407
2408 @item @emph{Return value}:
2409 The return value is of type @code{C_FUNPTR} and contains the C address
2410 of the argument.
2411
2412 @item @emph{Example}:
2413 @smallexample
2414 module x
2415   use iso_c_binding
2416   implicit none
2417 contains
2418   subroutine sub(a) bind(c)
2419     real(c_float) :: a
2420     a = sqrt(a)+5.0
2421   end subroutine sub
2422 end module x
2423 program main
2424   use iso_c_binding
2425   use x
2426   implicit none
2427   interface
2428     subroutine my_routine(p) bind(c,name='myC_func')
2429       import :: c_funptr
2430       type(c_funptr), intent(in) :: p
2431     end subroutine
2432   end interface
2433   call my_routine(c_funloc(sub))
2434 end program main
2435 @end smallexample
2436
2437 @item @emph{See also}:
2438 @ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2439 @end table
2440
2441
2442 @node C_LOC
2443 @section @code{C_LOC} --- Obtain the C address of an object
2444 @fnindex C_LOC
2445 @cindex procedure pointer, convert C to Fortran
2446
2447 @table @asis
2448 @item @emph{Description}:
2449 @code{C_LOC(X)} determines the C address of the argument.
2450
2451 @item @emph{Standard}:
2452 Fortran 2003 and later
2453
2454 @item @emph{Class}:
2455 Inquiry function
2456
2457 @item @emph{Syntax}:
2458 @code{RESULT = C_LOC(X)}
2459
2460 @item @emph{Arguments}:
2461 @multitable @columnfractions .10 .75
2462 @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.
2463
2464 @end multitable
2465
2466 @item @emph{Return value}:
2467 The return value is of type @code{C_PTR} and contains the C address
2468 of the argument.
2469
2470 @item @emph{Example}:
2471 @smallexample
2472 subroutine association_test(a,b)
2473   use iso_c_binding, only: c_associated, c_loc, c_ptr
2474   implicit none
2475   real, pointer :: a
2476   type(c_ptr) :: b
2477   if(c_associated(b, c_loc(a))) &
2478      stop 'b and a do not point to same target'
2479 end subroutine association_test
2480 @end smallexample
2481
2482 @item @emph{See also}:
2483 @ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2484 @end table
2485
2486
2487 @node C_SIZEOF
2488 @section @code{C_SIZEOF} --- Size in bytes of an expression
2489 @fnindex C_SIZEOF
2490 @cindex expression size
2491 @cindex size of an expression
2492
2493 @table @asis
2494 @item @emph{Description}:
2495 @code{C_SIZEOF(X)} calculates the number of bytes of storage the
2496 expression @code{X} occupies.
2497
2498 @item @emph{Standard}:
2499 Fortran 2008
2500
2501 @item @emph{Class}:
2502 Inquiry function of the module @code{ISO_C_BINDING}
2503
2504 @item @emph{Syntax}:
2505 @code{N = C_SIZEOF(X)}
2506
2507 @item @emph{Arguments}:
2508 @multitable @columnfractions .15 .70
2509 @item @var{X} @tab The argument shall be an interoperable data entity.
2510 @end multitable
2511
2512 @item @emph{Return value}:
2513 The return value is of type integer and of the system-dependent kind
2514 @code{C_SIZE_T} (from the @code{ISO_C_BINDING} module). Its value is the
2515 number of bytes occupied by the argument.  If the argument has the
2516 @code{POINTER} attribute, the number of bytes of the storage area pointed
2517 to is returned.  If the argument is of a derived type with @code{POINTER}
2518 or @code{ALLOCATABLE} components, the return value does not account for
2519 the sizes of the data pointed to by these components.
2520
2521 @item @emph{Example}:
2522 @smallexample
2523    use iso_c_binding
2524    integer(c_int) :: i
2525    real(c_float) :: r, s(5)
2526    print *, (c_sizeof(s)/c_sizeof(r) == 5)
2527    end
2528 @end smallexample
2529 The example will print @code{.TRUE.} unless you are using a platform
2530 where default @code{REAL} variables are unusually padded.
2531
2532 @item @emph{See also}:
2533 @ref{SIZEOF}, @ref{STORAGE_SIZE}
2534 @end table
2535
2536
2537 @node CEILING
2538 @section @code{CEILING} --- Integer ceiling function
2539 @fnindex CEILING
2540 @cindex ceiling
2541 @cindex rounding, ceiling
2542
2543 @table @asis
2544 @item @emph{Description}:
2545 @code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
2546
2547 @item @emph{Standard}:
2548 Fortran 95 and later
2549
2550 @item @emph{Class}:
2551 Elemental function
2552
2553 @item @emph{Syntax}:
2554 @code{RESULT = CEILING(A [, KIND])}
2555
2556 @item @emph{Arguments}:
2557 @multitable @columnfractions .15 .70
2558 @item @var{A} @tab The type shall be @code{REAL}.
2559 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2560 expression indicating the kind parameter of the result.
2561 @end multitable
2562
2563 @item @emph{Return value}:
2564 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
2565 and a default-kind @code{INTEGER} otherwise.
2566
2567 @item @emph{Example}:
2568 @smallexample
2569 program test_ceiling
2570     real :: x = 63.29
2571     real :: y = -63.59
2572     print *, ceiling(x) ! returns 64
2573     print *, ceiling(y) ! returns -63
2574 end program test_ceiling
2575 @end smallexample
2576
2577 @item @emph{See also}:
2578 @ref{FLOOR}, @ref{NINT}
2579
2580 @end table
2581
2582
2583
2584 @node CHAR
2585 @section @code{CHAR} --- Character conversion function
2586 @fnindex CHAR
2587 @cindex conversion, to character
2588
2589 @table @asis
2590 @item @emph{Description}:
2591 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
2592
2593 @item @emph{Standard}:
2594 Fortran 77 and later
2595
2596 @item @emph{Class}:
2597 Elemental function
2598
2599 @item @emph{Syntax}:
2600 @code{RESULT = CHAR(I [, KIND])}
2601
2602 @item @emph{Arguments}:
2603 @multitable @columnfractions .15 .70
2604 @item @var{I} @tab The type shall be @code{INTEGER}.
2605 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2606 expression indicating the kind parameter of the result.
2607 @end multitable
2608
2609 @item @emph{Return value}:
2610 The return value is of type @code{CHARACTER(1)}
2611
2612 @item @emph{Example}:
2613 @smallexample
2614 program test_char
2615     integer :: i = 74
2616     character(1) :: c
2617     c = char(i)
2618     print *, i, c ! returns 'J'
2619 end program test_char
2620 @end smallexample
2621
2622 @item @emph{Specific names}:
2623 @multitable @columnfractions .20 .20 .20 .25
2624 @item Name           @tab Argument         @tab Return type             @tab Standard
2625 @item @code{CHAR(I)} @tab @code{INTEGER I} @tab @code{CHARACTER(LEN=1)} @tab F77 and later
2626 @end multitable
2627
2628 @item @emph{Note}:
2629 See @ref{ICHAR} for a discussion of converting between numerical values
2630 and formatted string representations.
2631
2632 @item @emph{See also}:
2633 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
2634
2635 @end table
2636
2637
2638
2639 @node CHDIR
2640 @section @code{CHDIR} --- Change working directory
2641 @fnindex CHDIR
2642 @cindex system, working directory
2643
2644 @table @asis
2645 @item @emph{Description}:
2646 Change current working directory to a specified path.
2647
2648 This intrinsic is provided in both subroutine and function forms; however,
2649 only one form can be used in any given program unit.
2650
2651 @item @emph{Standard}:
2652 GNU extension
2653
2654 @item @emph{Class}:
2655 Subroutine, function
2656
2657 @item @emph{Syntax}:
2658 @multitable @columnfractions .80
2659 @item @code{CALL CHDIR(NAME [, STATUS])}
2660 @item @code{STATUS = CHDIR(NAME)}
2661 @end multitable
2662
2663 @item @emph{Arguments}:
2664 @multitable @columnfractions .15 .70
2665 @item @var{NAME}   @tab The type shall be @code{CHARACTER} of default
2666 kind and shall specify a valid path within the file system.
2667 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
2668 kind.  Returns 0 on success, and a system specific and nonzero error code
2669 otherwise.
2670 @end multitable
2671
2672 @item @emph{Example}:
2673 @smallexample
2674 PROGRAM test_chdir
2675   CHARACTER(len=255) :: path
2676   CALL getcwd(path)
2677   WRITE(*,*) TRIM(path)
2678   CALL chdir("/tmp")
2679   CALL getcwd(path)
2680   WRITE(*,*) TRIM(path)
2681 END PROGRAM
2682 @end smallexample
2683
2684 @item @emph{See also}:
2685 @ref{GETCWD}
2686 @end table
2687
2688
2689
2690 @node CHMOD
2691 @section @code{CHMOD} --- Change access permissions of files
2692 @fnindex CHMOD
2693 @cindex file system, change access mode
2694
2695 @table @asis
2696 @item @emph{Description}:
2697 @code{CHMOD} changes the permissions of a file.
2698
2699 This intrinsic is provided in both subroutine and function forms; however,
2700 only one form can be used in any given program unit.
2701
2702 @item @emph{Standard}:
2703 GNU extension
2704
2705 @item @emph{Class}:
2706 Subroutine, function
2707
2708 @item @emph{Syntax}:
2709 @multitable @columnfractions .80
2710 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
2711 @item @code{STATUS = CHMOD(NAME, MODE)}
2712 @end multitable
2713
2714 @item @emph{Arguments}:
2715 @multitable @columnfractions .15 .70
2716
2717 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
2718 file name. Trailing blanks are ignored unless the character
2719 @code{achar(0)} is present, then all characters up to and excluding
2720 @code{achar(0)} are used as the file name.
2721
2722 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
2723 file permission. @var{MODE} uses the same syntax as the @code{chmod} utility
2724 as defined by the POSIX standard. The argument shall either be a string of
2725 a nonnegative octal number or a symbolic mode.
2726
2727 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
2728 @code{0} on success and nonzero otherwise.
2729 @end multitable
2730
2731 @item @emph{Return value}:
2732 In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
2733 otherwise.
2734
2735 @item @emph{Example}:
2736 @code{CHMOD} as subroutine
2737 @smallexample
2738 program chmod_test
2739   implicit none
2740   integer :: status
2741   call chmod('test.dat','u+x',status)
2742   print *, 'Status: ', status
2743 end program chmod_test
2744 @end smallexample
2745 @code{CHMOD} as function:
2746 @smallexample
2747 program chmod_test
2748   implicit none
2749   integer :: status
2750   status = chmod('test.dat','u+x')
2751   print *, 'Status: ', status
2752 end program chmod_test
2753 @end smallexample
2754
2755 @end table
2756
2757
2758
2759 @node CMPLX
2760 @section @code{CMPLX} --- Complex conversion function
2761 @fnindex CMPLX
2762 @cindex complex numbers, conversion to
2763 @cindex conversion, to complex
2764
2765 @table @asis
2766 @item @emph{Description}:
2767 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
2768 the real component.  If @var{Y} is present it is converted to the imaginary
2769 component.  If @var{Y} is not present then the imaginary component is set to
2770 0.0.  If @var{X} is complex then @var{Y} must not be present.
2771
2772 @item @emph{Standard}:
2773 Fortran 77 and later
2774
2775 @item @emph{Class}:
2776 Elemental function
2777
2778 @item @emph{Syntax}:
2779 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2780
2781 @item @emph{Arguments}:
2782 @multitable @columnfractions .15 .70
2783 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
2784 or @code{COMPLEX}.
2785 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2786 @code{COMPLEX}.)  May be @code{INTEGER} or @code{REAL}.
2787 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2788 expression indicating the kind parameter of the result.
2789 @end multitable
2790
2791 @item @emph{Return value}:
2792 The return value is of @code{COMPLEX} type, with a kind equal to
2793 @var{KIND} if it is specified.  If @var{KIND} is not specified, the
2794 result is of the default @code{COMPLEX} kind, regardless of the kinds of
2795 @var{X} and @var{Y}. 
2796
2797 @item @emph{Example}:
2798 @smallexample
2799 program test_cmplx
2800     integer :: i = 42
2801     real :: x = 3.14
2802     complex :: z
2803     z = cmplx(i, x)
2804     print *, z, cmplx(x)
2805 end program test_cmplx
2806 @end smallexample
2807
2808 @item @emph{See also}:
2809 @ref{COMPLEX}
2810 @end table
2811
2812
2813
2814 @node COMMAND_ARGUMENT_COUNT
2815 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2816 @fnindex COMMAND_ARGUMENT_COUNT
2817 @cindex command-line arguments
2818 @cindex command-line arguments, number of
2819 @cindex arguments, to program
2820
2821 @table @asis
2822 @item @emph{Description}:
2823 @code{COMMAND_ARGUMENT_COUNT} returns the number of arguments passed on the
2824 command line when the containing program was invoked.
2825
2826 @item @emph{Standard}:
2827 Fortran 2003 and later
2828
2829 @item @emph{Class}:
2830 Inquiry function
2831
2832 @item @emph{Syntax}:
2833 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2834
2835 @item @emph{Arguments}:
2836 @multitable @columnfractions .15 .70
2837 @item None
2838 @end multitable
2839
2840 @item @emph{Return value}:
2841 The return value is an @code{INTEGER} of default kind.
2842
2843 @item @emph{Example}:
2844 @smallexample
2845 program test_command_argument_count
2846     integer :: count
2847     count = command_argument_count()
2848     print *, count
2849 end program test_command_argument_count
2850 @end smallexample
2851
2852 @item @emph{See also}:
2853 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2854 @end table
2855
2856
2857
2858 @node COMPILER_OPTIONS
2859 @section @code{COMPILER_OPTIONS} --- Options passed to the compiler
2860 @fnindex COMPILER_OPTIONS
2861 @cindex flags inquiry function
2862 @cindex options inquiry function
2863 @cindex compiler flags inquiry function
2864
2865 @table @asis
2866 @item @emph{Description}:
2867 @code{COMPILER_OPTIONS} returns a string with the options used for
2868 compiling.
2869
2870 @item @emph{Standard}:
2871 Fortran 2008
2872
2873 @item @emph{Class}:
2874 Inquiry function of the module @code{ISO_FORTRAN_ENV}
2875
2876 @item @emph{Syntax}:
2877 @code{STR = COMPILER_OPTIONS()}
2878
2879 @item @emph{Arguments}:
2880 None.
2881
2882 @item @emph{Return value}:
2883 The return value is a default-kind string with system-dependent length.
2884 It contains the compiler flags used to compile the file, which called
2885 the @code{COMPILER_OPTIONS} intrinsic.
2886
2887 @item @emph{Example}:
2888 @smallexample
2889    use iso_fortran_env
2890    print '(4a)', 'This file was compiled by ', &
2891                  compiler_version(), ' using the options ', &
2892                  compiler_options()
2893    end
2894 @end smallexample
2895
2896 @item @emph{See also}:
2897 @ref{COMPILER_VERSION}, @ref{ISO_FORTRAN_ENV}
2898 @end table
2899
2900
2901
2902 @node COMPILER_VERSION
2903 @section @code{COMPILER_VERSION} --- Compiler version string
2904 @fnindex COMPILER_VERSION
2905 @cindex compiler, name and version
2906 @cindex version of the compiler
2907
2908 @table @asis
2909 @item @emph{Description}:
2910 @code{COMPILER_VERSION} returns a string with the name and the
2911 version of the compiler.
2912
2913 @item @emph{Standard}:
2914 Fortran 2008
2915
2916 @item @emph{Class}:
2917 Inquiry function of the module @code{ISO_FORTRAN_ENV}
2918
2919 @item @emph{Syntax}:
2920 @code{STR = COMPILER_VERSION()}
2921
2922 @item @emph{Arguments}:
2923 None.
2924
2925 @item @emph{Return value}:
2926 The return value is a default-kind string with system-dependent length.
2927 It contains the name of the compiler and its version number.
2928
2929 @item @emph{Example}:
2930 @smallexample
2931    use iso_fortran_env
2932    print '(4a)', 'This file was compiled by ', &
2933                  compiler_version(), ' using the options ', &
2934                  compiler_options()
2935    end
2936 @end smallexample
2937
2938 @item @emph{See also}:
2939 @ref{COMPILER_OPTIONS}, @ref{ISO_FORTRAN_ENV}
2940 @end table
2941
2942
2943
2944 @node COMPLEX
2945 @section @code{COMPLEX} --- Complex conversion function
2946 @fnindex COMPLEX
2947 @cindex complex numbers, conversion to
2948 @cindex conversion, to complex
2949
2950 @table @asis
2951 @item @emph{Description}:
2952 @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
2953 to the real component and @var{Y} is converted to the imaginary
2954 component.
2955
2956 @item @emph{Standard}:
2957 GNU extension
2958
2959 @item @emph{Class}:
2960 Elemental function
2961
2962 @item @emph{Syntax}:
2963 @code{RESULT = COMPLEX(X, Y)}
2964
2965 @item @emph{Arguments}:
2966 @multitable @columnfractions .15 .70
2967 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
2968 @item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
2969 @end multitable
2970
2971 @item @emph{Return value}:
2972 If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
2973 value is of default @code{COMPLEX} type.
2974
2975 If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
2976 type and one is of @code{INTEGER} type, then the return value is of
2977 @code{COMPLEX} type with a kind equal to that of the @code{REAL}
2978 argument with the highest precision.  
2979
2980 @item @emph{Example}:
2981 @smallexample
2982 program test_complex
2983     integer :: i = 42
2984     real :: x = 3.14
2985     print *, complex(i, x)
2986 end program test_complex
2987 @end smallexample
2988
2989 @item @emph{See also}:
2990 @ref{CMPLX}
2991 @end table
2992
2993
2994
2995 @node CONJG
2996 @section @code{CONJG} --- Complex conjugate function 
2997 @fnindex CONJG
2998 @fnindex DCONJG
2999 @cindex complex conjugate
3000
3001 @table @asis
3002 @item @emph{Description}:
3003 @code{CONJG(Z)} returns the conjugate of @var{Z}.  If @var{Z} is @code{(x, y)}
3004 then the result is @code{(x, -y)}
3005
3006 @item @emph{Standard}:
3007 Fortran 77 and later, has overloads that are GNU extensions
3008
3009 @item @emph{Class}:
3010 Elemental function
3011
3012 @item @emph{Syntax}:
3013 @code{Z = CONJG(Z)}
3014
3015 @item @emph{Arguments}:
3016 @multitable @columnfractions .15 .70
3017 @item @var{Z} @tab The type shall be @code{COMPLEX}.
3018 @end multitable
3019
3020 @item @emph{Return value}:
3021 The return value is of type @code{COMPLEX}.
3022
3023 @item @emph{Example}:
3024 @smallexample
3025 program test_conjg
3026     complex :: z = (2.0, 3.0)
3027     complex(8) :: dz = (2.71_8, -3.14_8)
3028     z= conjg(z)
3029     print *, z
3030     dz = dconjg(dz)
3031     print *, dz
3032 end program test_conjg
3033 @end smallexample
3034
3035 @item @emph{Specific names}:
3036 @multitable @columnfractions .20 .20 .20 .25
3037 @item Name             @tab Argument             @tab Return type       @tab Standard
3038 @item @code{CONJG(Z)}  @tab @code{COMPLEX Z}     @tab @code{COMPLEX}    @tab GNU extension
3039 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z}  @tab @code{COMPLEX(8)} @tab GNU extension
3040 @end multitable
3041 @end table
3042
3043
3044
3045 @node COS
3046 @section @code{COS} --- Cosine function 
3047 @fnindex COS
3048 @fnindex DCOS
3049 @fnindex CCOS
3050 @fnindex ZCOS
3051 @fnindex CDCOS
3052 @cindex trigonometric function, cosine
3053 @cindex cosine
3054
3055 @table @asis
3056 @item @emph{Description}:
3057 @code{COS(X)} computes the cosine of @var{X}.
3058
3059 @item @emph{Standard}:
3060 Fortran 77 and later, has overloads that are GNU extensions
3061
3062 @item @emph{Class}:
3063 Elemental function
3064
3065 @item @emph{Syntax}:
3066 @code{RESULT = COS(X)}
3067
3068 @item @emph{Arguments}:
3069 @multitable @columnfractions .15 .70
3070 @item @var{X} @tab The type shall be @code{REAL} or
3071 @code{COMPLEX}.
3072 @end multitable
3073
3074 @item @emph{Return value}:
3075 The return value is of the same type and kind as @var{X}. The real part
3076 of the result is in radians. If @var{X} is of the type @code{REAL},
3077 the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}.
3078
3079 @item @emph{Example}:
3080 @smallexample
3081 program test_cos
3082   real :: x = 0.0
3083   x = cos(x)
3084 end program test_cos
3085 @end smallexample
3086
3087 @item @emph{Specific names}:
3088 @multitable @columnfractions .20 .20 .20 .25
3089 @item Name            @tab Argument            @tab Return type       @tab Standard
3090 @item @code{COS(X)}   @tab @code{REAL(4) X}    @tab @code{REAL(4)}    @tab Fortran 77 and later
3091 @item @code{DCOS(X)}  @tab @code{REAL(8) X}    @tab @code{REAL(8)}    @tab Fortran 77 and later
3092 @item @code{CCOS(X)}  @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
3093 @item @code{ZCOS(X)}  @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3094 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3095 @end multitable
3096
3097 @item @emph{See also}:
3098 Inverse function: @ref{ACOS}
3099
3100 @end table
3101
3102
3103
3104 @node COSH
3105 @section @code{COSH} --- Hyperbolic cosine function 
3106 @fnindex COSH
3107 @fnindex DCOSH
3108 @cindex hyperbolic cosine
3109 @cindex hyperbolic function, cosine
3110 @cindex cosine, hyperbolic
3111
3112 @table @asis
3113 @item @emph{Description}:
3114 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
3115
3116 @item @emph{Standard}:
3117 Fortran 77 and later, for a complex argument Fortran 2008 or later
3118
3119 @item @emph{Class}:
3120 Elemental function
3121
3122 @item @emph{Syntax}:
3123 @code{X = COSH(X)}
3124
3125 @item @emph{Arguments}:
3126 @multitable @columnfractions .15 .70
3127 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
3128 @end multitable
3129
3130 @item @emph{Return value}:
3131 The return value has same type and kind as @var{X}. If @var{X} is
3132 complex, the imaginary part of the result is in radians. If @var{X}
3133 is @code{REAL}, the return value has a lower bound of one,
3134 @math{\cosh (x) \geq 1}.
3135
3136 @item @emph{Example}:
3137 @smallexample
3138 program test_cosh
3139   real(8) :: x = 1.0_8
3140   x = cosh(x)
3141 end program test_cosh
3142 @end smallexample
3143
3144 @item @emph{Specific names}:
3145 @multitable @columnfractions .20 .20 .20 .25
3146 @item Name            @tab Argument          @tab Return type       @tab Standard
3147 @item @code{COSH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
3148 @item @code{DCOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
3149 @end multitable
3150
3151 @item @emph{See also}:
3152 Inverse function: @ref{ACOSH}
3153
3154 @end table
3155
3156
3157
3158 @node COUNT
3159 @section @code{COUNT} --- Count function
3160 @fnindex COUNT
3161 @cindex array, conditionally count elements
3162 @cindex array, element counting
3163 @cindex array, number of elements
3164
3165 @table @asis
3166 @item @emph{Description}:
3167
3168 Counts the number of @code{.TRUE.} elements in a logical @var{MASK},
3169 or, if the @var{DIM} argument is supplied, counts the number of
3170 elements along each row of the array in the @var{DIM} direction.
3171 If the array has zero size, or all of the elements of @var{MASK} are
3172 @code{.FALSE.}, then the result is @code{0}.
3173
3174 @item @emph{Standard}:
3175 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
3176
3177 @item @emph{Class}:
3178 Transformational function
3179
3180 @item @emph{Syntax}:
3181 @code{RESULT = COUNT(MASK [, DIM, KIND])}
3182
3183 @item @emph{Arguments}:
3184 @multitable @columnfractions .15 .70
3185 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
3186 @item @var{DIM}  @tab (Optional) The type shall be @code{INTEGER}.
3187 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3188 expression indicating the kind parameter of the result.
3189 @end multitable
3190
3191 @item @emph{Return value}:
3192 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
3193 @var{KIND} is absent, the return value is of default integer kind.
3194 If @var{DIM} is present, the result is an array with a rank one less
3195 than the rank of @var{ARRAY}, and a size corresponding to the shape
3196 of @var{ARRAY} with the @var{DIM} dimension removed.
3197
3198 @item @emph{Example}:
3199 @smallexample
3200 program test_count
3201     integer, dimension(2,3) :: a, b
3202     logical, dimension(2,3) :: mask
3203     a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
3204     b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
3205     print '(3i3)', a(1,:)
3206     print '(3i3)', a(2,:)
3207     print *
3208     print '(3i3)', b(1,:)
3209     print '(3i3)', b(2,:)
3210     print *
3211     mask = a.ne.b
3212     print '(3l3)', mask(1,:)
3213     print '(3l3)', mask(2,:)
3214     print *
3215     print '(3i3)', count(mask)
3216     print *
3217     print '(3i3)', count(mask, 1)
3218     print *
3219     print '(3i3)', count(mask, 2)
3220 end program test_count
3221 @end smallexample
3222 @end table
3223
3224
3225
3226 @node CPU_TIME
3227 @section @code{CPU_TIME} --- CPU elapsed time in seconds
3228 @fnindex CPU_TIME
3229 @cindex time, elapsed
3230
3231 @table @asis
3232 @item @emph{Description}:
3233 Returns a @code{REAL} value representing the elapsed CPU time in
3234 seconds.  This is useful for testing segments of code to determine
3235 execution time.
3236
3237 If a time source is available, time will be reported with microsecond
3238 resolution. If no time source is available, @var{TIME} is set to
3239 @code{-1.0}.
3240
3241 Note that @var{TIME} may contain a, system dependent, arbitrary offset
3242 and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
3243 value is meaningless, only differences between subsequent calls to
3244 this subroutine, as shown in the example below, should be used.
3245
3246
3247 @item @emph{Standard}:
3248 Fortran 95 and later
3249
3250 @item @emph{Class}:
3251 Subroutine
3252
3253 @item @emph{Syntax}:
3254 @code{CALL CPU_TIME(TIME)}
3255
3256 @item @emph{Arguments}:
3257 @multitable @columnfractions .15 .70
3258 @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
3259 @end multitable
3260
3261 @item @emph{Return value}:
3262 None
3263
3264 @item @emph{Example}:
3265 @smallexample
3266 program test_cpu_time
3267     real :: start, finish
3268     call cpu_time(start)
3269         ! put code to test here
3270     call cpu_time(finish)
3271     print '("Time = ",f6.3," seconds.")',finish-start
3272 end program test_cpu_time
3273 @end smallexample
3274
3275 @item @emph{See also}:
3276 @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
3277 @end table
3278
3279
3280
3281 @node CSHIFT
3282 @section @code{CSHIFT} --- Circular shift elements of an array
3283 @fnindex CSHIFT
3284 @cindex array, shift circularly
3285 @cindex array, permutation
3286 @cindex array, rotate
3287
3288 @table @asis
3289 @item @emph{Description}:
3290 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
3291 @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is omitted it is
3292 taken to be @code{1}.  @var{DIM} is a scalar of type @code{INTEGER} in the
3293 range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}.
3294 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
3295 by @var{SHIFT} places.  If rank is greater than one, then all complete rank one
3296 sections of @var{ARRAY} along the given dimension are shifted.  Elements
3297 shifted out one end of each rank one section are shifted back in the other end.
3298
3299 @item @emph{Standard}:
3300 Fortran 95 and later
3301
3302 @item @emph{Class}:
3303 Transformational function
3304
3305 @item @emph{Syntax}:
3306 @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
3307
3308 @item @emph{Arguments}:
3309 @multitable @columnfractions .15 .70
3310 @item @var{ARRAY}  @tab Shall be an array of any type.
3311 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
3312 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
3313 @end multitable
3314
3315 @item @emph{Return value}:
3316 Returns an array of same type and rank as the @var{ARRAY} argument.
3317
3318 @item @emph{Example}:
3319 @smallexample
3320 program test_cshift
3321     integer, dimension(3,3) :: a
3322     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3323     print '(3i3)', a(1,:)
3324     print '(3i3)', a(2,:)
3325     print '(3i3)', a(3,:)    
3326     a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
3327     print *
3328     print '(3i3)', a(1,:)
3329     print '(3i3)', a(2,:)
3330     print '(3i3)', a(3,:)
3331 end program test_cshift
3332 @end smallexample
3333 @end table
3334
3335
3336
3337 @node CTIME
3338 @section @code{CTIME} --- Convert a time into a string
3339 @fnindex CTIME
3340 @cindex time, conversion to string
3341 @cindex conversion, to string
3342
3343 @table @asis
3344 @item @emph{Description}:
3345 @code{CTIME} converts a system time value, such as returned by
3346 @code{TIME8}, to a string. Unless the application has called
3347 @code{setlocale}, the output will be in the default locale, of length
3348 24 and of the form @samp{Sat Aug 19 18:13:14 1995}. In other locales,
3349 a longer string may result.
3350
3351 This intrinsic is provided in both subroutine and function forms; however,
3352 only one form can be used in any given program unit.
3353
3354 @item @emph{Standard}:
3355 GNU extension
3356
3357 @item @emph{Class}:
3358 Subroutine, function
3359
3360 @item @emph{Syntax}:
3361 @multitable @columnfractions .80
3362 @item @code{CALL CTIME(TIME, RESULT)}.
3363 @item @code{RESULT = CTIME(TIME)}.
3364 @end multitable
3365
3366 @item @emph{Arguments}:
3367 @multitable @columnfractions .15 .70
3368 @item @var{TIME}    @tab The type shall be of type @code{INTEGER}.
3369 @item @var{RESULT}  @tab The type shall be of type @code{CHARACTER} and
3370 of default kind. It is an @code{INTENT(OUT)} argument. If the length
3371 of this variable is too short for the time and date string to fit
3372 completely, it will be blank on procedure return.
3373 @end multitable
3374
3375 @item @emph{Return value}:
3376 The converted date and time as a string. 
3377
3378 @item @emph{Example}:
3379 @smallexample
3380 program test_ctime
3381     integer(8) :: i
3382     character(len=30) :: date
3383     i = time8()
3384
3385     ! Do something, main part of the program
3386     
3387     call ctime(i,date)
3388     print *, 'Program was started on ', date
3389 end program test_ctime
3390 @end smallexample
3391
3392 @item @emph{See Also}:
3393 @ref{DATE_AND_TIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
3394 @end table
3395
3396
3397
3398 @node DATE_AND_TIME
3399 @section @code{DATE_AND_TIME} --- Date and time subroutine
3400 @fnindex DATE_AND_TIME
3401 @cindex date, current
3402 @cindex current date
3403 @cindex time, current
3404 @cindex current time
3405
3406 @table @asis
3407 @item @emph{Description}:
3408 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
3409 time information from the real-time system clock.  @var{DATE} is
3410 @code{INTENT(OUT)} and has form ccyymmdd.  @var{TIME} is @code{INTENT(OUT)} and
3411 has form hhmmss.sss.  @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
3412 representing the difference with respect to Coordinated Universal Time (UTC).
3413 Unavailable time and date parameters return blanks.
3414
3415 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
3416
3417 @multitable @columnfractions .15 .30 .40
3418 @item @tab @code{VALUE(1)}: @tab The year
3419 @item @tab @code{VALUE(2)}: @tab The month
3420 @item @tab @code{VALUE(3)}: @tab The day of the month
3421 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
3422 @item @tab @code{VALUE(5)}: @tab The hour of the day
3423 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
3424 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
3425 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
3426 @end multitable
3427
3428 @item @emph{Standard}:
3429 Fortran 95 and later
3430
3431 @item @emph{Class}:
3432 Subroutine
3433
3434 @item @emph{Syntax}:
3435 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
3436
3437 @item @emph{Arguments}:
3438 @multitable @columnfractions .15 .70
3439 @item @var{DATE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
3440 or larger, and of default kind.
3441 @item @var{TIME}  @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
3442 or larger, and of default kind.
3443 @item @var{ZONE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
3444 or larger, and of default kind.
3445 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
3446 @end multitable
3447
3448 @item @emph{Return value}:
3449 None
3450
3451 @item @emph{Example}:
3452 @smallexample
3453 program test_time_and_date
3454     character(8)  :: date
3455     character(10) :: time
3456     character(5)  :: zone
3457     integer,dimension(8) :: values
3458     ! using keyword arguments
3459     call date_and_time(date,time,zone,values)
3460     call date_and_time(DATE=date,ZONE=zone)
3461     call date_and_time(TIME=time)
3462     call date_and_time(VALUES=values)
3463     print '(a,2x,a,2x,a)', date, time, zone
3464     print '(8i5))', values
3465 end program test_time_and_date
3466 @end smallexample
3467
3468 @item @emph{See also}:
3469 @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
3470 @end table
3471
3472
3473
3474 @node DBLE
3475 @section @code{DBLE} --- Double conversion function 
3476 @fnindex DBLE
3477 @cindex conversion, to real
3478
3479 @table @asis
3480 @item @emph{Description}:
3481 @code{DBLE(A)} Converts @var{A} to double precision real type.
3482
3483 @item @emph{Standard}:
3484 Fortran 77 and later
3485
3486 @item @emph{Class}:
3487 Elemental function
3488
3489 @item @emph{Syntax}:
3490 @code{RESULT = DBLE(A)}
3491
3492 @item @emph{Arguments}:
3493 @multitable @columnfractions .15 .70
3494 @item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
3495 or @code{COMPLEX}.
3496 @end multitable
3497
3498 @item @emph{Return value}:
3499 The return value is of type double precision real.
3500
3501 @item @emph{Example}:
3502 @smallexample
3503 program test_dble
3504     real    :: x = 2.18
3505     integer :: i = 5
3506     complex :: z = (2.3,1.14)
3507     print *, dble(x), dble(i), dble(z)
3508 end program test_dble
3509 @end smallexample
3510
3511 @item @emph{See also}:
3512 @ref{REAL}
3513 @end table
3514
3515
3516
3517 @node DCMPLX
3518 @section @code{DCMPLX} --- Double complex conversion function
3519 @fnindex DCMPLX
3520 @cindex complex numbers, conversion to
3521 @cindex conversion, to complex
3522
3523 @table @asis
3524 @item @emph{Description}:
3525 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
3526 converted to the real component.  If @var{Y} is present it is converted to the
3527 imaginary component.  If @var{Y} is not present then the imaginary component is
3528 set to 0.0.  If @var{X} is complex then @var{Y} must not be present.
3529
3530 @item @emph{Standard}:
3531 GNU extension
3532
3533 @item @emph{Class}:
3534 Elemental function
3535
3536 @item @emph{Syntax}:
3537 @code{RESULT = DCMPLX(X [, Y])}
3538
3539 @item @emph{Arguments}:
3540 @multitable @columnfractions .15 .70
3541 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
3542 or @code{COMPLEX}.
3543 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
3544 @code{INTEGER} or @code{REAL}. 
3545 @end multitable
3546
3547 @item @emph{Return value}:
3548 The return value is of type @code{COMPLEX(8)}
3549
3550 @item @emph{Example}:
3551 @smallexample
3552 program test_dcmplx
3553     integer :: i = 42
3554     real :: x = 3.14
3555     complex :: z
3556     z = cmplx(i, x)
3557     print *, dcmplx(i)
3558     print *, dcmplx(x)
3559     print *, dcmplx(z)
3560     print *, dcmplx(x,i)
3561 end program test_dcmplx
3562 @end smallexample
3563 @end table
3564
3565
3566 @node DIGITS
3567 @section @code{DIGITS} --- Significant binary digits function
3568 @fnindex DIGITS
3569 @cindex model representation, significant digits
3570
3571 @table @asis
3572 @item @emph{Description}:
3573 @code{DIGITS(X)} returns the number of significant binary digits of the internal
3574 model representation of @var{X}.  For example, on a system using a 32-bit
3575 floating point representation, a default real number would likely return 24.
3576
3577 @item @emph{Standard}:
3578 Fortran 95 and later
3579
3580 @item @emph{Class}:
3581 Inquiry function
3582
3583 @item @emph{Syntax}:
3584 @code{RESULT = DIGITS(X)}
3585
3586 @item @emph{Arguments}:
3587 @multitable @columnfractions .15 .70
3588 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
3589 @end multitable
3590
3591 @item @emph{Return value}:
3592 The return value is of type @code{INTEGER}.
3593
3594 @item @emph{Example}:
3595 @smallexample
3596 program test_digits
3597     integer :: i = 12345
3598     real :: x = 3.143
3599     real(8) :: y = 2.33
3600     print *, digits(i)
3601     print *, digits(x)
3602     print *, digits(y)
3603 end program test_digits
3604 @end smallexample
3605 @end table
3606
3607
3608
3609 @node DIM
3610 @section @code{DIM} --- Positive difference
3611 @fnindex DIM
3612 @fnindex IDIM
3613 @fnindex DDIM
3614 @cindex positive difference
3615
3616 @table @asis
3617 @item @emph{Description}:
3618 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
3619 otherwise returns zero.
3620
3621 @item @emph{Standard}:
3622 Fortran 77 and later
3623
3624 @item @emph{Class}:
3625 Elemental function
3626
3627 @item @emph{Syntax}:
3628 @code{RESULT = DIM(X, Y)}
3629
3630 @item @emph{Arguments}:
3631 @multitable @columnfractions .15 .70
3632 @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
3633 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
3634 @end multitable
3635
3636 @item @emph{Return value}:
3637 The return value is of type @code{INTEGER} or @code{REAL}.
3638
3639 @item @emph{Example}:
3640 @smallexample
3641 program test_dim
3642     integer :: i
3643     real(8) :: x
3644     i = dim(4, 15)
3645     x = dim(4.345_8, 2.111_8)
3646     print *, i
3647     print *, x
3648 end program test_dim
3649 @end smallexample
3650
3651 @item @emph{Specific names}:
3652 @multitable @columnfractions .20 .20 .20 .25
3653 @item Name             @tab Argument               @tab Return type       @tab Standard
3654 @item @code{DIM(X,Y)}  @tab @code{REAL(4) X, Y}    @tab @code{REAL(4)}    @tab Fortran 77 and later
3655 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X, Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
3656 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X, Y}    @tab @code{REAL(8)}    @tab Fortran 77 and later
3657 @end multitable
3658 @end table
3659
3660
3661
3662 @node DOT_PRODUCT
3663 @section @code{DOT_PRODUCT} --- Dot product function
3664 @fnindex DOT_PRODUCT
3665 @cindex dot product
3666 @cindex vector product
3667 @cindex product, vector
3668
3669 @table @asis
3670 @item @emph{Description}:
3671 @code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
3672 of two vectors @var{VECTOR_A} and @var{VECTOR_B}.  The two vectors may be
3673 either numeric or logical and must be arrays of rank one and of equal size. If
3674 the vectors are @code{INTEGER} or @code{REAL}, the result is
3675 @code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
3676 is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
3677 the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.  
3678
3679 @item @emph{Standard}:
3680 Fortran 95 and later
3681
3682 @item @emph{Class}:
3683 Transformational function
3684
3685 @item @emph{Syntax}:
3686 @code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
3687
3688 @item @emph{Arguments}:
3689 @multitable @columnfractions .15 .70
3690 @item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
3691 @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.
3692 @end multitable
3693
3694 @item @emph{Return value}:
3695 If the arguments are numeric, the return value is a scalar of numeric type,
3696 @code{INTEGER}, @code{REAL}, or @code{COMPLEX}.  If the arguments are
3697 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
3698
3699 @item @emph{Example}:
3700 @smallexample
3701 program test_dot_prod
3702     integer, dimension(3) :: a, b
3703     a = (/ 1, 2, 3 /)
3704     b = (/ 4, 5, 6 /)
3705     print '(3i3)', a
3706     print *
3707     print '(3i3)', b
3708     print *
3709     print *, dot_product(a,b)
3710 end program test_dot_prod
3711 @end smallexample
3712 @end table
3713
3714
3715
3716 @node DPROD
3717 @section @code{DPROD} --- Double product function
3718 @fnindex DPROD
3719 @cindex product, double-precision
3720
3721 @table @asis
3722 @item @emph{Description}:
3723 @code{DPROD(X,Y)} returns the product @code{X*Y}.
3724
3725 @item @emph{Standard}:
3726 Fortran 77 and later
3727
3728 @item @emph{Class}:
3729 Elemental function
3730
3731 @item @emph{Syntax}:
3732 @code{RESULT = DPROD(X, Y)}
3733
3734 @item @emph{Arguments}:
3735 @multitable @columnfractions .15 .70
3736 @item @var{X} @tab The type shall be @code{REAL}.
3737 @item @var{Y} @tab The type shall be @code{REAL}.
3738 @end multitable
3739
3740 @item @emph{Return value}:
3741 The return value is of type @code{REAL(8)}.
3742
3743 @item @emph{Example}:
3744 @smallexample
3745 program test_dprod
3746     real :: x = 5.2
3747     real :: y = 2.3
3748     real(8) :: d
3749     d = dprod(x,y)
3750     print *, d
3751 end program test_dprod
3752 @end smallexample
3753
3754 @item @emph{Specific names}:
3755 @multitable @columnfractions .20 .20 .20 .25
3756 @item Name              @tab Argument               @tab Return type       @tab Standard
3757 @item @code{DPROD(X,Y)} @tab @code{REAL(4) X, Y}    @tab @code{REAL(4)}    @tab Fortran 77 and later
3758 @end multitable
3759
3760 @end table
3761
3762
3763 @node DREAL
3764 @section @code{DREAL} --- Double real part function
3765 @fnindex DREAL
3766 @cindex complex numbers, real part
3767
3768 @table @asis
3769 @item @emph{Description}:
3770 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
3771
3772 @item @emph{Standard}:
3773 GNU extension
3774
3775 @item @emph{Class}:
3776 Elemental function
3777
3778 @item @emph{Syntax}:
3779 @code{RESULT = DREAL(A)}
3780
3781 @item @emph{Arguments}:
3782 @multitable @columnfractions .15 .70
3783 @item @var{A} @tab The type shall be @code{COMPLEX(8)}.
3784 @end multitable
3785
3786 @item @emph{Return value}:
3787 The return value is of type @code{REAL(8)}.
3788
3789 @item @emph{Example}:
3790 @smallexample
3791 program test_dreal
3792     complex(8) :: z = (1.3_8,7.2_8)
3793     print *, dreal(z)
3794 end program test_dreal
3795 @end smallexample
3796
3797 @item @emph{See also}:
3798 @ref{AIMAG}
3799
3800 @end table
3801
3802
3803
3804 @node DSHIFTL
3805 @section @code{DSHIFTL} --- Combined left shift
3806 @fnindex DSHIFTL
3807 @cindex left shift, combined
3808 @cindex shift, left
3809
3810 @table @asis
3811 @item @emph{Description}:
3812 @code{DSHIFTL(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
3813 rightmost @var{SHIFT} bits of the result are the leftmost @var{SHIFT}
3814 bits of @var{J}, and the remaining bits are the rightmost bits of
3815 @var{I}.
3816
3817 @item @emph{Standard}:
3818 Fortran 2008 and later
3819
3820 @item @emph{Class}:
3821 Elemental function
3822
3823 @item @emph{Syntax}:
3824 @code{RESULT = DSHIFTL(I, J, SHIFT)}
3825
3826 @item @emph{Arguments}:
3827 @multitable @columnfractions .15 .70
3828 @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
3829 @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
3830 If both @var{I} and @var{J} have integer type, then they shall have
3831 the same kind type parameter. @var{I} and @var{J} shall not both be
3832 BOZ constants.
3833 @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
3834 be nonnegative.  If @var{I} is not a BOZ constant, then @var{SHIFT}
3835 shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
3836 @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
3837 @end multitable
3838
3839 @item @emph{Return value}:
3840 If either @var{I} or @var{J} is a BOZ constant, it is first converted
3841 as if by the intrinsic function @code{INT} to an integer type with the
3842 kind type parameter of the other.
3843
3844 @item @emph{See also}:
3845 @ref{DSHIFTR}
3846 @end table
3847
3848
3849 @node DSHIFTR
3850 @section @code{DSHIFTR} --- Combined right shift
3851 @fnindex DSHIFTR
3852 @cindex right shift, combined
3853 @cindex shift, right
3854
3855 @table @asis
3856 @item @emph{Description}:
3857 @code{DSHIFTR(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
3858 leftmost @var{SHIFT} bits of the result are the rightmost @var{SHIFT}
3859 bits of @var{I}, and the remaining bits are the leftmost bits of
3860 @var{J}.
3861
3862 @item @emph{Standard}:
3863 Fortran 2008 and later
3864
3865 @item @emph{Class}:
3866 Elemental function
3867
3868 @item @emph{Syntax}:
3869 @code{RESULT = DSHIFTR(I, J, SHIFT)}
3870
3871 @item @emph{Arguments}:
3872 @multitable @columnfractions .15 .70
3873 @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
3874 @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
3875 If both @var{I} and @var{J} have integer type, then they shall have
3876 the same kind type parameter. @var{I} and @var{J} shall not both be
3877 BOZ constants.
3878 @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
3879 be nonnegative.  If @var{I} is not a BOZ constant, then @var{SHIFT}
3880 shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
3881 @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
3882 @end multitable
3883
3884 @item @emph{Return value}:
3885 If either @var{I} or @var{J} is a BOZ constant, it is first converted
3886 as if by the intrinsic function @code{INT} to an integer type with the
3887 kind type parameter of the other.
3888
3889 @item @emph{See also}:
3890 @ref{DSHIFTL}
3891 @end table
3892
3893
3894 @node DTIME
3895 @section @code{DTIME} --- Execution time subroutine (or function)
3896 @fnindex DTIME
3897 @cindex time, elapsed
3898 @cindex elapsed time
3899
3900 @table @asis
3901 @item @emph{Description}:
3902 @code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime
3903 since the start of the process's execution in @var{TIME}.  @var{VALUES}
3904 returns the user and system components of this time in @code{VALUES(1)} and
3905 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) +
3906 VALUES(2)}.
3907
3908 Subsequent invocations of @code{DTIME} return values accumulated since the
3909 previous invocation.
3910
3911 On some systems, the underlying timings are represented using types with
3912 sufficiently small limits that overflows (wrap around) are possible, such as
3913 32-bit types. Therefore, the values returned by this intrinsic might be, or
3914 become, negative, or numerically less than previous values, during a single
3915 run of the compiled program.
3916
3917 Please note, that this implementation is thread safe if used within OpenMP
3918 directives, i.e., its state will be consistent while called from multiple
3919 threads. However, if @code{DTIME} is called from multiple threads, the result
3920 is still the time since the last invocation. This may not give the intended
3921 results. If possible, use @code{CPU_TIME} instead.
3922
3923 This intrinsic is provided in both subroutine and function forms; however,
3924 only one form can be used in any given program unit.
3925
3926 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
3927
3928 @multitable @columnfractions .15 .30 .40
3929 @item @tab @code{VALUES(1)}: @tab User time in seconds.
3930 @item @tab @code{VALUES(2)}: @tab System time in seconds.
3931 @item @tab @code{TIME}: @tab Run time since start in seconds.
3932 @end multitable
3933
3934 @item @emph{Standard}:
3935 GNU extension
3936
3937 @item @emph{Class}:
3938 Subroutine, function
3939
3940 @item @emph{Syntax}:
3941 @multitable @columnfractions .80
3942 @item @code{CALL DTIME(VALUES, TIME)}.
3943 @item @code{TIME = DTIME(VALUES)}, (not recommended).
3944 @end multitable
3945
3946 @item @emph{Arguments}:
3947 @multitable @columnfractions .15 .70
3948 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
3949 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
3950 @end multitable
3951
3952 @item @emph{Return value}:
3953 Elapsed time in seconds since the last invocation or since the start of program
3954 execution if not called before.
3955
3956 @item @emph{Example}:
3957 @smallexample
3958 program test_dtime
3959     integer(8) :: i, j
3960     real, dimension(2) :: tarray
3961     real :: result
3962     call dtime(tarray, result)
3963     print *, result
3964     print *, tarray(1)
3965     print *, tarray(2)   
3966     do i=1,100000000    ! Just a delay
3967         j = i * i - i
3968     end do
3969     call dtime(tarray, result)
3970     print *, result
3971     print *, tarray(1)
3972     print *, tarray(2)
3973 end program test_dtime
3974 @end smallexample
3975
3976 @item @emph{See also}:
3977 @ref{CPU_TIME}
3978
3979 @end table
3980
3981
3982
3983 @node EOSHIFT
3984 @section @code{EOSHIFT} --- End-off shift elements of an array
3985 @fnindex EOSHIFT
3986 @cindex array, shift
3987
3988 @table @asis
3989 @item @emph{Description}:
3990 @code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
3991 elements of @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is
3992 omitted it is taken to be @code{1}.  @var{DIM} is a scalar of type
3993 @code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the
3994 rank of @var{ARRAY}.  If the rank of @var{ARRAY} is one, then all elements of
3995 @var{ARRAY} are shifted by @var{SHIFT} places.  If rank is greater than one,
3996 then all complete rank one sections of @var{ARRAY} along the given dimension are
3997 shifted.  Elements shifted out one end of each rank one section are dropped.  If
3998 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
3999 is copied back in the other end.  If @var{BOUNDARY} is not present then the
4000 following are copied in depending on the type of @var{ARRAY}.
4001
4002 @multitable @columnfractions .15 .80
4003 @item @emph{Array Type} @tab @emph{Boundary Value}
4004 @item Numeric  @tab 0 of the type and kind of @var{ARRAY}.
4005 @item Logical  @tab @code{.FALSE.}.
4006 @item Character(@var{len}) @tab @var{len} blanks.
4007 @end multitable
4008
4009 @item @emph{Standard}:
4010 Fortran 95 and later
4011
4012 @item @emph{Class}:
4013 Transformational function
4014
4015 @item @emph{Syntax}:
4016 @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
4017
4018 @item @emph{Arguments}:
4019 @multitable @columnfractions .15 .70
4020 @item @var{ARRAY}  @tab May be any type, not scalar.
4021 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
4022 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}. 
4023 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
4024 @end multitable
4025
4026 @item @emph{Return value}:
4027 Returns an array of same type and rank as the @var{ARRAY} argument.
4028
4029 @item @emph{Example}:
4030 @smallexample
4031 program test_eoshift
4032     integer, dimension(3,3) :: a
4033     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
4034     print '(3i3)', a(1,:)
4035     print '(3i3)', a(2,:)
4036     print '(3i3)', a(3,:)    
4037     a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
4038     print *
4039     print '(3i3)', a(1,:)
4040     print '(3i3)', a(2,:)
4041     print '(3i3)', a(3,:)
4042 end program test_eoshift
4043 @end smallexample
4044 @end table
4045
4046
4047
4048 @node EPSILON
4049 @section @code{EPSILON} --- Epsilon function
4050 @fnindex EPSILON
4051 @cindex model representation, epsilon
4052
4053 @table @asis
4054 @item @emph{Description}:
4055 @code{EPSILON(X)} returns the smallest number @var{E} of the same kind
4056 as @var{X} such that @math{1 + E > 1}.
4057
4058 @item @emph{Standard}:
4059 Fortran 95 and later
4060
4061 @item @emph{Class}:
4062 Inquiry function
4063
4064 @item @emph{Syntax}:
4065 @code{RESULT = EPSILON(X)}
4066
4067 @item @emph{Arguments}:
4068 @multitable @columnfractions .15 .70
4069 @item @var{X} @tab The type shall be @code{REAL}.
4070 @end multitable
4071
4072 @item @emph{Return value}:
4073 The return value is of same type as the argument.
4074
4075 @item @emph{Example}:
4076 @smallexample
4077 program test_epsilon
4078     real :: x = 3.143
4079     real(8) :: y = 2.33
4080     print *, EPSILON(x)
4081     print *, EPSILON(y)
4082 end program test_epsilon
4083 @end smallexample
4084 @end table
4085
4086
4087
4088 @node ERF
4089 @section @code{ERF} --- Error function 
4090 @fnindex ERF
4091 @cindex error function
4092
4093 @table @asis
4094 @item @emph{Description}:
4095 @code{ERF(X)} computes the error function of @var{X}.
4096
4097 @item @emph{Standard}:
4098 Fortran 2008 and later
4099
4100 @item @emph{Class}:
4101 Elemental function
4102
4103 @item @emph{Syntax}:
4104 @code{RESULT = ERF(X)}
4105
4106 @item @emph{Arguments}:
4107 @multitable @columnfractions .15 .70
4108 @item @var{X} @tab The type shall be @code{REAL}.
4109 @end multitable
4110
4111 @item @emph{Return value}:
4112 The return value is of type @code{REAL}, of the same kind as
4113 @var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
4114
4115 @item @emph{Example}:
4116 @smallexample
4117 program test_erf
4118   real(8) :: x = 0.17_8
4119   x = erf(x)
4120 end program test_erf
4121 @end smallexample
4122
4123 @item @emph{Specific names}:
4124 @multitable @columnfractions .20 .20 .20 .25
4125 @item Name            @tab Argument          @tab Return type       @tab Standard
4126 @item @code{DERF(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
4127 @end multitable
4128 @end table
4129
4130
4131
4132 @node ERFC
4133 @section @code{ERFC} --- Error function 
4134 @fnindex ERFC
4135 @cindex error function, complementary
4136
4137 @table @asis
4138 @item @emph{Description}:
4139 @code{ERFC(X)} computes the complementary error function of @var{X}.
4140
4141 @item @emph{Standard}:
4142 Fortran 2008 and later
4143
4144 @item @emph{Class}:
4145 Elemental function
4146
4147 @item @emph{Syntax}:
4148 @code{RESULT = ERFC(X)}
4149
4150 @item @emph{Arguments}:
4151 @multitable @columnfractions .15 .70
4152 @item @var{X} @tab The type shall be @code{REAL}.
4153 @end multitable
4154
4155 @item @emph{Return value}:
4156 The return value is of type @code{REAL} and of the same kind as @var{X}.
4157 It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
4158
4159 @item @emph{Example}:
4160 @smallexample
4161 program test_erfc
4162   real(8) :: x = 0.17_8
4163   x = erfc(x)
4164 end program test_erfc
4165 @end smallexample
4166
4167 @item @emph{Specific names}:
4168 @multitable @columnfractions .20 .20 .20 .25
4169 @item Name            @tab Argument          @tab Return type       @tab Standard
4170 @item @code{DERFC(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
4171 @end multitable
4172 @end table
4173
4174
4175
4176 @node ERFC_SCALED
4177 @section @code{ERFC_SCALED} --- Error function 
4178 @fnindex ERFC_SCALED
4179 @cindex error function, complementary, exponentially-scaled
4180
4181 @table @asis
4182 @item @emph{Description}:
4183 @code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
4184 error function of @var{X}.
4185
4186 @item @emph{Standard}:
4187 Fortran 2008 and later
4188
4189 @item @emph{Class}:
4190 Elemental function
4191
4192 @item @emph{Syntax}:
4193 @code{RESULT = ERFC_SCALED(X)}
4194
4195 @item @emph{Arguments}:
4196 @multitable @columnfractions .15 .70
4197 @item @var{X} @tab The type shall be @code{REAL}.
4198 @end multitable
4199
4200 @item @emph{Return value}:
4201 The return value is of type @code{REAL} and of the same kind as @var{X}.
4202
4203 @item @emph{Example}:
4204 @smallexample
4205 program test_erfc_scaled
4206   real(8) :: x = 0.17_8
4207   x = erfc_scaled(x)
4208 end program test_erfc_scaled
4209 @end smallexample
4210 @end table
4211
4212
4213
4214 @node ETIME
4215 @section @code{ETIME} --- Execution time subroutine (or function)
4216 @fnindex ETIME
4217 @cindex time, elapsed
4218
4219 @table @asis
4220 @item @emph{Description}:
4221 @code{ETIME(VALUES, TIME)} returns the number of seconds of runtime
4222 since the start of the process's execution in @var{TIME}.  @var{VALUES}
4223 returns the user and system components of this time in @code{VALUES(1)} and
4224 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}.
4225
4226 On some systems, the underlying timings are represented using types with
4227 sufficiently small limits that overflows (wrap around) are possible, such as
4228 32-bit types. Therefore, the values returned by this intrinsic might be, or
4229 become, negative, or numerically less than previous values, during a single
4230 run of the compiled program.
4231
4232 This intrinsic is provided in both subroutine and function forms; however,
4233 only one form can be used in any given program unit.
4234
4235 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
4236
4237 @multitable @columnfractions .15 .30 .60
4238 @item @tab @code{VALUES(1)}: @tab User time in seconds.
4239 @item @tab @code{VALUES(2)}: @tab System time in seconds.
4240 @item @tab @code{TIME}: @tab Run time since start in seconds.
4241 @end multitable
4242
4243 @item @emph{Standard}:
4244 GNU extension
4245
4246 @item @emph{Class}:
4247 Subroutine, function
4248
4249 @item @emph{Syntax}:
4250 @multitable @columnfractions .80
4251 @item @code{CALL ETIME(VALUES, TIME)}.
4252 @item @code{TIME = ETIME(VALUES)}, (not recommended).
4253 @end multitable
4254
4255 @item @emph{Arguments}:
4256 @multitable @columnfractions .15 .70
4257 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
4258 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
4259 @end multitable
4260
4261 @item @emph{Return value}:
4262 Elapsed time in seconds since the start of program execution.
4263
4264 @item @emph{Example}:
4265 @smallexample
4266 program test_etime
4267     integer(8) :: i, j
4268     real, dimension(2) :: tarray
4269     real :: result
4270     call ETIME(tarray, result)
4271     print *, result
4272     print *, tarray(1)
4273     print *, tarray(2)   
4274     do i=1,100000000    ! Just a delay
4275         j = i * i - i
4276     end do
4277     call ETIME(tarray, result)
4278     print *, result
4279     print *, tarray(1)
4280     print *, tarray(2)
4281 end program test_etime
4282 @end smallexample
4283
4284 @item @emph{See also}:
4285 @ref{CPU_TIME}
4286
4287 @end table
4288
4289
4290
4291 @node EXECUTE_COMMAND_LINE
4292 @section @code{EXECUTE_COMMAND_LINE} --- Execute a shell command
4293 @fnindex EXECUTE_COMMAND_LINE
4294 @cindex system, system call
4295 @cindex command line
4296
4297 @table @asis
4298 @item @emph{Description}:
4299 @code{EXECUTE_COMMAND_LINE} runs a shell command, synchronously or
4300 asynchronously.
4301
4302 The @code{COMMAND} argument is passed to the shell and executed, using
4303 the C library's @code{system} call.  (The shell is @code{sh} on Unix
4304 systems, and @code{cmd.exe} on Windows.)  If @code{WAIT} is present
4305 and has the value false, the execution of the command is asynchronous
4306 if the system supports it; otherwise, the command is executed
4307 synchronously.
4308
4309 The three last arguments allow the user to get status information.  After
4310 synchronous execution, @code{EXITSTAT} contains the integer exit code of
4311 the command, as returned by @code{system}.  @code{CMDSTAT} is set to zero
4312 if the command line was executed (whatever its exit status was).
4313 @code{CMDMSG} is assigned an error message if an error has occurred.
4314
4315 Note that the @code{system} function need not be thread-safe. It is
4316 the responsibility of the user to ensure that @code{system} is not
4317 called concurrently.
4318
4319 @item @emph{Standard}:
4320 Fortran 2008 and later
4321
4322 @item @emph{Class}:
4323 Subroutine
4324
4325 @item @emph{Syntax}:
4326 @code{CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])}
4327
4328 @item @emph{Arguments}:
4329 @multitable @columnfractions .15 .70
4330 @item @var{COMMAND} @tab Shall be a default @code{CHARACTER} scalar.
4331 @item @var{WAIT} @tab (Optional) Shall be a default @code{LOGICAL} scalar.
4332 @item @var{EXITSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
4333 default kind.
4334 @item @var{CMDSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
4335 default kind.
4336 @item @var{CMDMSG} @tab (Optional) Shall be an @code{CHARACTER} scalar of the
4337 default kind.
4338 @end multitable
4339
4340 @item @emph{Example}:
4341 @smallexample
4342 program test_exec
4343   integer :: i
4344
4345   call execute_command_line ("external_prog.exe", exitstat=i)
4346   print *, "Exit status of external_prog.exe was ", i
4347
4348   call execute_command_line ("reindex_files.exe", wait=.false.)
4349   print *, "Now reindexing files in the background"
4350
4351 end program test_exec
4352 @end smallexample
4353
4354
4355 @item @emph{Note}:
4356
4357 Because this intrinsic is implemented in terms of the @code{system}
4358 function call, its behavior with respect to signaling is processor
4359 dependent. In particular, on POSIX-compliant systems, the SIGINT and
4360 SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As
4361 such, if the parent process is terminated, the child process might not be
4362 terminated alongside.
4363
4364
4365 @item @emph{See also}:
4366 @ref{SYSTEM}
4367 @end table
4368
4369
4370
4371 @node EXIT
4372 @section @code{EXIT} --- Exit the program with status. 
4373 @fnindex EXIT
4374 @cindex program termination
4375 @cindex terminate program
4376
4377 @table @asis
4378 @item @emph{Description}:
4379 @code{EXIT} causes immediate termination of the program with status.  If status
4380 is omitted it returns the canonical @emph{success} for the system.  All Fortran
4381 I/O units are closed. 
4382
4383 @item @emph{Standard}:
4384 GNU extension
4385
4386 @item @emph{Class}:
4387 Subroutine
4388
4389 @item @emph{Syntax}:
4390 @code{CALL EXIT([STATUS])}
4391
4392 @item @emph{Arguments}:
4393 @multitable @columnfractions .15 .70
4394 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
4395 @end multitable
4396
4397 @item @emph{Return value}:
4398 @code{STATUS} is passed to the parent process on exit.
4399
4400 @item @emph{Example}:
4401 @smallexample
4402 program test_exit
4403   integer :: STATUS = 0
4404   print *, 'This program is going to exit.'
4405   call EXIT(STATUS)
4406 end program test_exit
4407 @end smallexample
4408
4409 @item @emph{See also}:
4410 @ref{ABORT}, @ref{KILL}
4411 @end table
4412
4413
4414
4415 @node EXP
4416 @section @code{EXP} --- Exponential function 
4417 @fnindex EXP
4418 @fnindex DEXP
4419 @fnindex CEXP
4420 @fnindex ZEXP
4421 @fnindex CDEXP
4422 @cindex exponential function
4423 @cindex logarithm function, inverse
4424
4425 @table @asis
4426 @item @emph{Description}:
4427 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
4428
4429 @item @emph{Standard}:
4430 Fortran 77 and later, has overloads that are GNU extensions
4431
4432 @item @emph{Class}:
4433 Elemental function
4434
4435 @item @emph{Syntax}:
4436 @code{RESULT = EXP(X)}
4437
4438 @item @emph{Arguments}:
4439 @multitable @columnfractions .15 .70
4440 @item @var{X} @tab The type shall be @code{REAL} or
4441 @code{COMPLEX}.
4442 @end multitable
4443
4444 @item @emph{Return value}:
4445 The return value has same type and kind as @var{X}.
4446
4447 @item @emph{Example}:
4448 @smallexample
4449 program test_exp
4450   real :: x = 1.0
4451   x = exp(x)
4452 end program test_exp
4453 @end smallexample
4454
4455 @item @emph{Specific names}:
4456 @multitable @columnfractions .20 .20 .20 .25
4457 @item Name            @tab Argument             @tab Return type         @tab Standard
4458 @item @code{EXP(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}      @tab Fortran 77 and later
4459 @item @code{DEXP(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}      @tab Fortran 77 and later
4460 @item @code{CEXP(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}   @tab Fortran 77 and later
4461 @item @code{ZEXP(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
4462 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
4463 @end multitable
4464 @end table
4465
4466
4467
4468 @node EXPONENT
4469 @section @code{EXPONENT} --- Exponent function 
4470 @fnindex EXPONENT
4471 @cindex real number, exponent
4472 @cindex floating point, exponent
4473
4474 @table @asis
4475 @item @emph{Description}:
4476 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
4477 is zero the value returned is zero. 
4478
4479 @item @emph{Standard}:
4480 Fortran 95 and later
4481
4482 @item @emph{Class}:
4483 Elemental function
4484
4485 @item @emph{Syntax}:
4486 @code{RESULT = EXPONENT(X)}
4487
4488 @item @emph{Arguments}:
4489 @multitable @columnfractions .15 .70
4490 @item @var{X} @tab The type shall be @code{REAL}.
4491 @end multitable
4492
4493 @item @emph{Return value}:
4494 The return value is of type default @code{INTEGER}.
4495
4496 @item @emph{Example}:
4497 @smallexample
4498 program test_exponent
4499   real :: x = 1.0
4500   integer :: i
4501   i = exponent(x)
4502   print *, i
4503   print *, exponent(0.0)
4504 end program test_exponent
4505 @end smallexample
4506 @end table
4507
4508
4509
4510 @node EXTENDS_TYPE_OF
4511 @section @code{EXTENDS_TYPE_OF} ---  Query dynamic type for extension
4512 @fnindex EXTENDS_TYPE_OF
4513
4514 @table @asis
4515 @item @emph{Description}:
4516 Query dynamic type for extension.
4517
4518 @item @emph{Standard}:
4519 Fortran 2003 and later
4520
4521 @item @emph{Class}:
4522 Inquiry function
4523
4524 @item @emph{Syntax}:
4525 @code{RESULT = EXTENDS_TYPE_OF(A, MOLD)}
4526
4527 @item @emph{Arguments}:
4528 @multitable @columnfractions .15 .70
4529 @item @var{A} @tab Shall be an object of extensible declared type or
4530 unlimited polymorphic. 
4531 @item @var{MOLD} @tab Shall be an object of extensible declared type or
4532 unlimited polymorphic. 
4533 @end multitable
4534
4535 @item @emph{Return value}:
4536 The return value is a scalar of type default logical. It is true if and only if
4537 the dynamic type of A is an extension type of the dynamic type of MOLD.
4538
4539
4540 @item @emph{See also}:
4541 @ref{SAME_TYPE_AS}
4542 @end table
4543
4544
4545
4546 @node FDATE
4547 @section @code{FDATE} --- Get the current time as a string
4548 @fnindex FDATE
4549 @cindex time, current
4550 @cindex current time
4551 @cindex date, current
4552 @cindex current date
4553
4554 @table @asis
4555 @item @emph{Description}:
4556 @code{FDATE(DATE)} returns the current date (using the same format as
4557 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
4558 TIME())}.
4559
4560 This intrinsic is provided in both subroutine and function forms; however,
4561 only one form can be used in any given program unit.
4562
4563 @item @emph{Standard}:
4564 GNU extension
4565
4566 @item @emph{Class}:
4567 Subroutine, function
4568
4569 @item @emph{Syntax}:
4570 @multitable @columnfractions .80
4571 @item @code{CALL FDATE(DATE)}.
4572 @item @code{DATE = FDATE()}.
4573 @end multitable
4574
4575 @item @emph{Arguments}:
4576 @multitable @columnfractions .15 .70
4577 @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
4578 default kind. It is an @code{INTENT(OUT)} argument.  If the length of
4579 this variable is too short for the date and time string to fit
4580 completely, it will be blank on procedure return.
4581 @end multitable
4582
4583 @item @emph{Return value}:
4584 The current date and time as a string.
4585
4586 @item @emph{Example}:
4587 @smallexample
4588 program test_fdate
4589     integer(8) :: i, j
4590     character(len=30) :: date
4591     call fdate(date)
4592     print *, 'Program started on ', date
4593     do i = 1, 100000000 ! Just a delay
4594         j = i * i - i
4595     end do
4596     call fdate(date)
4597     print *, 'Program ended on ', date
4598 end program test_fdate
4599 @end smallexample
4600
4601 @item @emph{See also}:
4602 @ref{DATE_AND_TIME}, @ref{CTIME}
4603 @end table
4604
4605
4606 @node FGET
4607 @section @code{FGET} --- Read a single character in stream mode from stdin 
4608 @fnindex FGET
4609 @cindex read character, stream mode
4610 @cindex stream mode, read character
4611 @cindex file operation, read character
4612
4613 @table @asis
4614 @item @emph{Description}:
4615 Read a single character in stream mode from stdin by bypassing normal 
4616 formatted output. Stream I/O should not be mixed with normal record-oriented 
4617 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4618
4619 This intrinsic is provided in both subroutine and function forms; however,
4620 only one form can be used in any given program unit.
4621
4622 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4623 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4624 Programmers should consider the use of new stream IO feature in new code 
4625 for future portability. See also @ref{Fortran 2003 status}.
4626
4627 @item @emph{Standard}:
4628 GNU extension
4629
4630 @item @emph{Class}:
4631 Subroutine, function
4632
4633 @item @emph{Syntax}:
4634 @multitable @columnfractions .80
4635 @item @code{CALL FGET(C [, STATUS])}
4636 @item @code{STATUS = FGET(C)}
4637 @end multitable
4638
4639 @item @emph{Arguments}:
4640 @multitable @columnfractions .15 .70
4641 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4642 kind.
4643 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4644 Returns 0 on success, -1 on end-of-file, and a system specific positive
4645 error code otherwise.
4646 @end multitable
4647
4648 @item @emph{Example}:
4649 @smallexample
4650 PROGRAM test_fget
4651   INTEGER, PARAMETER :: strlen = 100
4652   INTEGER :: status, i = 1
4653   CHARACTER(len=strlen) :: str = ""
4654
4655   WRITE (*,*) 'Enter text:'
4656   DO
4657     CALL fget(str(i:i), status)
4658     if (status /= 0 .OR. i > strlen) exit
4659     i = i + 1
4660   END DO
4661   WRITE (*,*) TRIM(str)
4662 END PROGRAM
4663 @end smallexample
4664
4665 @item @emph{See also}:
4666 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
4667 @end table
4668
4669
4670
4671 @node FGETC
4672 @section @code{FGETC} --- Read a single character in stream mode
4673 @fnindex FGETC
4674 @cindex read character, stream mode
4675 @cindex stream mode, read character
4676 @cindex file operation, read character
4677
4678 @table @asis
4679 @item @emph{Description}:
4680 Read a single character in stream mode by bypassing normal formatted output. 
4681 Stream I/O should not be mixed with normal record-oriented (formatted or 
4682 unformatted) I/O on the same unit; the results are unpredictable.
4683
4684 This intrinsic is provided in both subroutine and function forms; however,
4685 only one form can be used in any given program unit.
4686
4687 Note that the @code{FGET} intrinsic is provided for backwards compatibility
4688 with @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4689 Programmers should consider the use of new stream IO feature in new code 
4690 for future portability. See also @ref{Fortran 2003 status}.
4691
4692 @item @emph{Standard}:
4693 GNU extension
4694
4695 @item @emph{Class}:
4696 Subroutine, function
4697
4698 @item @emph{Syntax}:
4699 @multitable @columnfractions .80
4700 @item @code{CALL FGETC(UNIT, C [, STATUS])}
4701 @item @code{STATUS = FGETC(UNIT, C)}
4702 @end multitable
4703
4704 @item @emph{Arguments}:
4705 @multitable @columnfractions .15 .70
4706 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4707 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4708 kind.
4709 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4710 Returns 0 on success, -1 on end-of-file and a system specific positive
4711 error code otherwise.
4712 @end multitable
4713
4714 @item @emph{Example}:
4715 @smallexample
4716 PROGRAM test_fgetc
4717   INTEGER :: fd = 42, status
4718   CHARACTER :: c
4719
4720   OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
4721   DO
4722     CALL fgetc(fd, c, status)
4723     IF (status /= 0) EXIT
4724     call fput(c)
4725   END DO
4726   CLOSE(UNIT=fd)
4727 END PROGRAM
4728 @end smallexample
4729
4730 @item @emph{See also}:
4731 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
4732 @end table
4733
4734
4735
4736 @node FLOOR
4737 @section @code{FLOOR} --- Integer floor function
4738 @fnindex FLOOR
4739 @cindex floor
4740 @cindex rounding, floor
4741
4742 @table @asis
4743 @item @emph{Description}:
4744 @code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
4745
4746 @item @emph{Standard}:
4747 Fortran 95 and later
4748
4749 @item @emph{Class}:
4750 Elemental function
4751
4752 @item @emph{Syntax}:
4753 @code{RESULT = FLOOR(A [, KIND])}
4754
4755 @item @emph{Arguments}:
4756 @multitable @columnfractions .15 .70
4757 @item @var{A} @tab The type shall be @code{REAL}.
4758 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
4759 expression indicating the kind parameter of the result.
4760 @end multitable
4761
4762 @item @emph{Return value}:
4763 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
4764 and of default-kind @code{INTEGER} otherwise.
4765
4766 @item @emph{Example}:
4767 @smallexample
4768 program test_floor
4769     real :: x = 63.29
4770     real :: y = -63.59
4771     print *, floor(x) ! returns 63
4772     print *, floor(y) ! returns -64
4773 end program test_floor
4774 @end smallexample
4775
4776 @item @emph{See also}:
4777 @ref{CEILING}, @ref{NINT}
4778
4779 @end table
4780
4781
4782
4783 @node FLUSH
4784 @section @code{FLUSH} --- Flush I/O unit(s)
4785 @fnindex FLUSH
4786 @cindex file operation, flush
4787
4788 @table @asis
4789 @item @emph{Description}:
4790 Flushes Fortran unit(s) currently open for output. Without the optional
4791 argument, all units are flushed, otherwise just the unit specified.
4792
4793 @item @emph{Standard}:
4794 GNU extension
4795
4796 @item @emph{Class}:
4797 Subroutine
4798
4799 @item @emph{Syntax}:
4800 @code{CALL FLUSH(UNIT)}
4801
4802 @item @emph{Arguments}:
4803 @multitable @columnfractions .15 .70
4804 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
4805 @end multitable
4806
4807 @item @emph{Note}:
4808 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
4809 statement that should be preferred over the @code{FLUSH} intrinsic.
4810
4811 The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement
4812 have identical effect: they flush the runtime library's I/O buffer so
4813 that the data becomes visible to other processes. This does not guarantee
4814 that the data is committed to disk.
4815
4816 On POSIX systems, you can request that all data is transferred  to  the
4817 storage device by calling the @code{fsync} function, with the POSIX file
4818 descriptor of the I/O unit as argument (retrieved with GNU intrinsic
4819 @code{FNUM}). The following example shows how:
4820
4821 @smallexample
4822   ! Declare the interface for POSIX fsync function
4823   interface
4824     function fsync (fd) bind(c,name="fsync")
4825     use iso_c_binding, only: c_int
4826       integer(c_int), value :: fd
4827       integer(c_int) :: fsync
4828     end function fsync
4829   end interface
4830
4831   ! Variable declaration
4832   integer :: ret
4833
4834   ! Opening unit 10
4835   open (10,file="foo")
4836
4837   ! ...
4838   ! Perform I/O on unit 10
4839   ! ...
4840
4841   ! Flush and sync
4842   flush(10)
4843   ret = fsync(fnum(10))
4844
4845   ! Handle possible error
4846   if (ret /= 0) stop "Error calling FSYNC"
4847 @end smallexample
4848
4849 @end table
4850
4851
4852
4853 @node FNUM
4854 @section @code{FNUM} --- File number function
4855 @fnindex FNUM
4856 @cindex file operation, file number
4857
4858 @table @asis
4859 @item @emph{Description}:
4860 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
4861 open Fortran I/O unit @code{UNIT}.
4862
4863 @item @emph{Standard}:
4864 GNU extension
4865
4866 @item @emph{Class}:
4867 Function
4868
4869 @item @emph{Syntax}:
4870 @code{RESULT = FNUM(UNIT)}
4871
4872 @item @emph{Arguments}:
4873 @multitable @columnfractions .15 .70
4874 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
4875 @end multitable
4876
4877 @item @emph{Return value}:
4878 The return value is of type @code{INTEGER}
4879
4880 @item @emph{Example}:
4881 @smallexample
4882 program test_fnum
4883   integer :: i
4884   open (unit=10, status = "scratch")
4885   i = fnum(10)
4886   print *, i
4887   close (10)
4888 end program test_fnum
4889 @end smallexample
4890 @end table
4891
4892
4893
4894 @node FPUT
4895 @section @code{FPUT} --- Write a single character in stream mode to stdout 
4896 @fnindex FPUT
4897 @cindex write character, stream mode
4898 @cindex stream mode, write character
4899 @cindex file operation, write character
4900
4901 @table @asis
4902 @item @emph{Description}:
4903 Write a single character in stream mode to stdout by bypassing normal 
4904 formatted output. Stream I/O should not be mixed with normal record-oriented 
4905 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4906
4907 This intrinsic is provided in both subroutine and function forms; however,
4908 only one form can be used in any given program unit.
4909
4910 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4911 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4912 Programmers should consider the use of new stream IO feature in new code 
4913 for future portability. See also @ref{Fortran 2003 status}.
4914
4915 @item @emph{Standard}:
4916 GNU extension
4917
4918 @item @emph{Class}:
4919 Subroutine, function
4920
4921 @item @emph{Syntax}:
4922 @multitable @columnfractions .80
4923 @item @code{CALL FPUT(C [, STATUS])}
4924 @item @code{STATUS = FPUT(C)}
4925 @end multitable
4926
4927 @item @emph{Arguments}:
4928 @multitable @columnfractions .15 .70
4929 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4930 kind.
4931 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4932 Returns 0 on success, -1 on end-of-file and a system specific positive
4933 error code otherwise.
4934 @end multitable
4935
4936 @item @emph{Example}:
4937 @smallexample
4938 PROGRAM test_fput
4939   CHARACTER(len=10) :: str = "gfortran"
4940   INTEGER :: i
4941   DO i = 1, len_trim(str)
4942     CALL fput(str(i:i))
4943   END DO
4944 END PROGRAM
4945 @end smallexample
4946
4947 @item @emph{See also}:
4948 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
4949 @end table
4950
4951
4952
4953 @node FPUTC
4954 @section @code{FPUTC} --- Write a single character in stream mode
4955 @fnindex FPUTC
4956 @cindex write character, stream mode
4957 @cindex stream mode, write character
4958 @cindex file operation, write character
4959
4960 @table @asis
4961 @item @emph{Description}:
4962 Write a single character in stream mode by bypassing normal formatted 
4963 output. Stream I/O should not be mixed with normal record-oriented 
4964 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4965
4966 This intrinsic is provided in both subroutine and function forms; however,
4967 only one form can be used in any given program unit.
4968
4969 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
4970 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
4971 Programmers should consider the use of new stream IO feature in new code 
4972 for future portability. See also @ref{Fortran 2003 status}.
4973
4974 @item @emph{Standard}:
4975 GNU extension
4976
4977 @item @emph{Class}:
4978 Subroutine, function
4979
4980 @item @emph{Syntax}:
4981 @multitable @columnfractions .80
4982 @item @code{CALL FPUTC(UNIT, C [, STATUS])}
4983 @item @code{STATUS = FPUTC(UNIT, C)}
4984 @end multitable
4985
4986 @item @emph{Arguments}:
4987 @multitable @columnfractions .15 .70
4988 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
4989 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
4990 kind.
4991 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4992 Returns 0 on success, -1 on end-of-file and a system specific positive
4993 error code otherwise.
4994 @end multitable
4995
4996 @item @emph{Example}:
4997 @smallexample
4998 PROGRAM test_fputc
4999   CHARACTER(len=10) :: str = "gfortran"
5000   INTEGER :: fd = 42, i
5001
5002   OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
5003   DO i = 1, len_trim(str)
5004     CALL fputc(fd, str(i:i))
5005   END DO
5006   CLOSE(fd)
5007 END PROGRAM
5008 @end smallexample
5009
5010 @item @emph{See also}:
5011 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
5012 @end table
5013
5014
5015
5016 @node FRACTION
5017 @section @code{FRACTION} --- Fractional part of the model representation
5018 @fnindex FRACTION
5019 @cindex real number, fraction
5020 @cindex floating point, fraction
5021
5022 @table @asis
5023 @item @emph{Description}:
5024 @code{FRACTION(X)} returns the fractional part of the model
5025 representation of @code{X}.
5026
5027 @item @emph{Standard}:
5028 Fortran 95 and later
5029
5030 @item @emph{Class}:
5031 Elemental function
5032
5033 @item @emph{Syntax}:
5034 @code{Y = FRACTION(X)}
5035
5036 @item @emph{Arguments}:
5037 @multitable @columnfractions .15 .70
5038 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
5039 @end multitable
5040
5041 @item @emph{Return value}:
5042 The return value is of the same type and kind as the argument.
5043 The fractional part of the model representation of @code{X} is returned;
5044 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
5045
5046 @item @emph{Example}:
5047 @smallexample
5048 program test_fraction
5049   real :: x
5050   x = 178.1387e-4
5051   print *, fraction(x), x * radix(x)**(-exponent(x))
5052 end program test_fraction
5053 @end smallexample
5054
5055 @end table
5056
5057
5058
5059 @node FREE
5060 @section @code{FREE} --- Frees memory
5061 @fnindex FREE
5062 @cindex pointer, cray
5063
5064 @table @asis
5065 @item @emph{Description}:
5066 Frees memory previously allocated by @code{MALLOC}. The @code{FREE}
5067 intrinsic is an extension intended to be used with Cray pointers, and is
5068 provided in GNU Fortran to allow user to compile legacy code. For
5069 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
5070 @code{DEALLOCATE}.
5071
5072 @item @emph{Standard}:
5073 GNU extension
5074
5075 @item @emph{Class}:
5076 Subroutine
5077
5078 @item @emph{Syntax}:
5079 @code{CALL FREE(PTR)}
5080
5081 @item @emph{Arguments}:
5082 @multitable @columnfractions .15 .70
5083 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
5084 location of the memory that should be de-allocated.
5085 @end multitable
5086
5087 @item @emph{Return value}:
5088 None
5089
5090 @item @emph{Example}:
5091 See @code{MALLOC} for an example.
5092
5093 @item @emph{See also}:
5094 @ref{MALLOC}
5095 @end table
5096
5097
5098
5099 @node FSEEK
5100 @section @code{FSEEK} --- Low level file positioning subroutine
5101 @fnindex FSEEK
5102 @cindex file operation, seek
5103 @cindex file operation, position
5104
5105 @table @asis
5106 @item @emph{Description}:
5107 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE} 
5108 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
5109 if set to 1, @var{OFFSET} is taken to be relative to the current position 
5110 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
5111 On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek 
5112 fails silently.
5113
5114 This intrinsic routine is not fully backwards compatible with @command{g77}. 
5115 In @command{g77}, the @code{FSEEK} takes a statement label instead of a 
5116 @var{STATUS} variable. If FSEEK is used in old code, change
5117 @smallexample
5118   CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
5119 @end smallexample 
5120 to
5121 @smallexample
5122   INTEGER :: status
5123   CALL FSEEK(UNIT, OFFSET, WHENCE, status)
5124   IF (status /= 0) GOTO label
5125 @end smallexample 
5126
5127 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
5128 Programmers should consider the use of new stream IO feature in new code 
5129 for future portability. See also @ref{Fortran 2003 status}.
5130
5131 @item @emph{Standard}:
5132 GNU extension
5133
5134 @item @emph{Class}:
5135 Subroutine
5136
5137 @item @emph{Syntax}:
5138 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
5139
5140 @item @emph{Arguments}:
5141 @multitable @columnfractions .15 .70
5142 @item @var{UNIT}   @tab Shall be a scalar of type @code{INTEGER}.
5143 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
5144 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
5145 Its value shall be either 0, 1 or 2.
5146 @item @var{STATUS} @tab (Optional) shall be a scalar of type 
5147 @code{INTEGER(4)}.
5148 @end multitable
5149
5150 @item @emph{Example}:
5151 @smallexample
5152 PROGRAM test_fseek
5153   INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
5154   INTEGER :: fd, offset, ierr
5155
5156   ierr   = 0
5157   offset = 5
5158   fd     = 10
5159
5160   OPEN(UNIT=fd, FILE="fseek.test")
5161   CALL FSEEK(fd, offset, SEEK_SET, ierr)  ! move to OFFSET
5162   print *, FTELL(fd), ierr
5163
5164   CALL FSEEK(fd, 0, SEEK_END, ierr)       ! move to end
5165   print *, FTELL(fd), ierr
5166
5167   CALL FSEEK(fd, 0, SEEK_SET, ierr)       ! move to beginning
5168   print *, FTELL(fd), ierr
5169
5170   CLOSE(UNIT=fd)
5171 END PROGRAM
5172 @end smallexample
5173
5174 @item @emph{See also}:
5175 @ref{FTELL}
5176 @end table
5177
5178
5179
5180 @node FSTAT
5181 @section @code{FSTAT} --- Get file status
5182 @fnindex FSTAT
5183 @cindex file system, file status
5184
5185 @table @asis
5186 @item @emph{Description}:
5187 @code{FSTAT} is identical to @ref{STAT}, except that information about an 
5188 already opened file is obtained.
5189
5190 The elements in @code{VALUES} are the same as described by @ref{STAT}.
5191
5192 This intrinsic is provided in both subroutine and function forms; however,
5193 only one form can be used in any given program unit.
5194
5195 @item @emph{Standard}:
5196 GNU extension
5197
5198 @item @emph{Class}:
5199 Subroutine, function
5200
5201 @item @emph{Syntax}:
5202 @multitable @columnfractions .80
5203 @item @code{CALL FSTAT(UNIT, VALUES [, STATUS])}
5204 @item @code{STATUS = FSTAT(UNIT, VALUES)}
5205 @end multitable
5206
5207 @item @emph{Arguments}:
5208 @multitable @columnfractions .15 .70
5209 @item @var{UNIT}   @tab An open I/O unit number of type @code{INTEGER}.
5210 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
5211 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
5212 on success and a system specific error code otherwise.
5213 @end multitable
5214
5215 @item @emph{Example}:
5216 See @ref{STAT} for an example.
5217
5218 @item @emph{See also}:
5219 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
5220 @end table
5221
5222
5223
5224 @node FTELL
5225 @section @code{FTELL} --- Current stream position
5226 @fnindex FTELL
5227 @cindex file operation, position
5228
5229 @table @asis
5230 @item @emph{Description}:
5231 Retrieves the current position within an open file.
5232
5233 This intrinsic is provided in both subroutine and function forms; however,
5234 only one form can be used in any given program unit.
5235
5236 @item @emph{Standard}:
5237 GNU extension
5238
5239 @item @emph{Class}:
5240 Subroutine, function
5241
5242 @item @emph{Syntax}:
5243 @multitable @columnfractions .80
5244 @item @code{CALL FTELL(UNIT, OFFSET)}
5245 @item @code{OFFSET = FTELL(UNIT)}
5246 @end multitable
5247
5248 @item @emph{Arguments}:
5249 @multitable @columnfractions .15 .70
5250 @item @var{OFFSET}  @tab Shall of type @code{INTEGER}.
5251 @item @var{UNIT}    @tab Shall of type @code{INTEGER}.
5252 @end multitable
5253
5254 @item @emph{Return value}:
5255 In either syntax, @var{OFFSET} is set to the current offset of unit
5256 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
5257
5258 @item @emph{Example}:
5259 @smallexample
5260 PROGRAM test_ftell
5261   INTEGER :: i
5262   OPEN(10, FILE="temp.dat")
5263   CALL ftell(10,i)
5264   WRITE(*,*) i
5265 END PROGRAM
5266 @end smallexample
5267
5268 @item @emph{See also}:
5269 @ref{FSEEK}
5270 @end table
5271
5272
5273
5274 @node GAMMA
5275 @section @code{GAMMA} --- Gamma function
5276 @fnindex GAMMA
5277 @fnindex DGAMMA
5278 @cindex Gamma function
5279 @cindex Factorial function
5280
5281 @table @asis
5282 @item @emph{Description}:
5283 @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
5284 integer values of @var{X} the Gamma function simplifies to the factorial
5285 function @math{\Gamma(x)=(x-1)!}.
5286
5287 @tex
5288 $$
5289 \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
5290 $$
5291 @end tex
5292
5293 @item @emph{Standard}:
5294 Fortran 2008 and later
5295
5296 @item @emph{Class}:
5297 Elemental function
5298
5299 @item @emph{Syntax}:
5300 @code{X = GAMMA(X)}
5301
5302 @item @emph{Arguments}:
5303 @multitable @columnfractions .15 .70
5304 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
5305 nor a negative integer.
5306 @end multitable
5307
5308 @item @emph{Return value}:
5309 The return value is of type @code{REAL} of the same kind as @var{X}.
5310
5311 @item @emph{Example}:
5312 @smallexample
5313 program test_gamma
5314   real :: x = 1.0
5315   x = gamma(x) ! returns 1.0
5316 end program test_gamma
5317 @end smallexample
5318
5319 @item @emph{Specific names}:
5320 @multitable @columnfractions .20 .20 .20 .25
5321 @item Name             @tab Argument         @tab Return type       @tab Standard
5322 @item @code{GAMMA(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
5323 @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
5324 @end multitable
5325
5326 @item @emph{See also}:
5327 Logarithm of the Gamma function: @ref{LOG_GAMMA}
5328
5329 @end table
5330
5331
5332
5333 @node GERROR
5334 @section @code{GERROR} --- Get last system error message
5335 @fnindex GERROR
5336 @cindex system, error handling
5337
5338 @table @asis
5339 @item @emph{Description}:
5340 Returns the system error message corresponding to the last system error.
5341 This resembles the functionality of @code{strerror(3)} in C.
5342
5343 @item @emph{Standard}:
5344 GNU extension
5345
5346 @item @emph{Class}:
5347 Subroutine
5348
5349 @item @emph{Syntax}:
5350 @code{CALL GERROR(RESULT)}
5351
5352 @item @emph{Arguments}:
5353 @multitable @columnfractions .15 .70
5354 @item @var{RESULT}  @tab Shall of type @code{CHARACTER} and of default
5355 @end multitable
5356
5357 @item @emph{Example}:
5358 @smallexample
5359 PROGRAM test_gerror
5360   CHARACTER(len=100) :: msg
5361   CALL gerror(msg)
5362   WRITE(*,*) msg
5363 END PROGRAM
5364 @end smallexample
5365
5366 @item @emph{See also}:
5367 @ref{IERRNO}, @ref{PERROR}
5368 @end table
5369
5370
5371
5372 @node GETARG
5373 @section @code{GETARG} --- Get command line arguments
5374 @fnindex GETARG
5375 @cindex command-line arguments
5376 @cindex arguments, to program
5377
5378 @table @asis
5379 @item @emph{Description}:
5380 Retrieve the @var{POS}-th argument that was passed on the
5381 command line when the containing program was invoked.
5382
5383 This intrinsic routine is provided for backwards compatibility with 
5384 GNU Fortran 77.  In new code, programmers should consider the use of 
5385 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003 
5386 standard.
5387
5388 @item @emph{Standard}:
5389 GNU extension
5390
5391 @item @emph{Class}:
5392 Subroutine
5393
5394 @item @emph{Syntax}:
5395 @code{CALL GETARG(POS, VALUE)}
5396
5397 @item @emph{Arguments}:
5398 @multitable @columnfractions .15 .70
5399 @item @var{POS}   @tab Shall be of type @code{INTEGER} and not wider than
5400 the default integer kind; @math{@var{POS} \geq 0}
5401 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
5402 kind.
5403 @item @var{VALUE} @tab Shall be of type @code{CHARACTER}. 
5404 @end multitable
5405
5406 @item @emph{Return value}:
5407 After @code{GETARG} returns, the @var{VALUE} argument holds the
5408 @var{POS}th command line argument. If @var{VALUE} can not hold the
5409 argument, it is truncated to fit the length of @var{VALUE}. If there are
5410 less than @var{POS} arguments specified at the command line, @var{VALUE}
5411 will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
5412 to the name of the program (on systems that support this feature).
5413
5414 @item @emph{Example}:
5415 @smallexample
5416 PROGRAM test_getarg
5417   INTEGER :: i
5418   CHARACTER(len=32) :: arg
5419
5420   DO i = 1, iargc()
5421     CALL getarg(i, arg)
5422     WRITE (*,*) arg
5423   END DO
5424 END PROGRAM
5425 @end smallexample
5426
5427 @item @emph{See also}:
5428 GNU Fortran 77 compatibility function: @ref{IARGC}
5429
5430 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
5431 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
5432 @end table
5433
5434
5435
5436 @node GET_COMMAND
5437 @section @code{GET_COMMAND} --- Get the entire command line
5438 @fnindex GET_COMMAND
5439 @cindex command-line arguments
5440 @cindex arguments, to program
5441
5442 @table @asis
5443 @item @emph{Description}:
5444 Retrieve the entire command line that was used to invoke the program.
5445
5446 @item @emph{Standard}:
5447 Fortran 2003 and later
5448
5449 @item @emph{Class}:
5450 Subroutine
5451
5452 @item @emph{Syntax}:
5453 @code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])}
5454
5455 @item @emph{Arguments}:
5456 @multitable @columnfractions .15 .70
5457 @item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and
5458 of default kind.
5459 @item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of
5460 default kind.
5461 @item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of
5462 default kind.
5463 @end multitable
5464
5465 @item @emph{Return value}:
5466 If @var{COMMAND} is present, stores the entire command line that was used
5467 to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is
5468 assigned the length of the command line. If @var{STATUS} is present, it
5469 is assigned 0 upon success of the command, -1 if @var{COMMAND} is too
5470 short to store the command line, or a positive value in case of an error.
5471
5472 @item @emph{Example}:
5473 @smallexample
5474 PROGRAM test_get_command
5475   CHARACTER(len=255) :: cmd
5476   CALL get_command(cmd)
5477   WRITE (*,*) TRIM(cmd)
5478 END PROGRAM
5479 @end smallexample
5480
5481 @item @emph{See also}:
5482 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
5483 @end table
5484
5485
5486
5487 @node GET_COMMAND_ARGUMENT
5488 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
5489 @fnindex GET_COMMAND_ARGUMENT
5490 @cindex command-line arguments
5491 @cindex arguments, to program
5492
5493 @table @asis
5494 @item @emph{Description}:
5495 Retrieve the @var{NUMBER}-th argument that was passed on the
5496 command line when the containing program was invoked.
5497
5498 @item @emph{Standard}:
5499 Fortran 2003 and later
5500
5501 @item @emph{Class}:
5502 Subroutine
5503
5504 @item @emph{Syntax}:
5505 @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
5506
5507 @item @emph{Arguments}:
5508 @multitable @columnfractions .15 .70
5509 @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of
5510 default kind, @math{@var{NUMBER} \geq 0}
5511 @item @var{VALUE}  @tab (Optional) Shall be a scalar of type @code{CHARACTER}
5512 and of default kind.
5513 @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
5514 and of default kind.
5515 @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
5516 and of default kind.
5517 @end multitable
5518
5519 @item @emph{Return value}:
5520 After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the 
5521 @var{NUMBER}-th command line argument. If @var{VALUE} can not hold the argument, it is 
5522 truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
5523 arguments specified at the command line, @var{VALUE} will be filled with blanks. 
5524 If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on
5525 systems that support this feature). The @var{LENGTH} argument contains the
5526 length of the @var{NUMBER}-th command line argument. If the argument retrieval
5527 fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated
5528 command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is
5529 zero.
5530
5531 @item @emph{Example}:
5532 @smallexample
5533 PROGRAM test_get_command_argument
5534   INTEGER :: i
5535   CHARACTER(len=32) :: arg
5536
5537   i = 0
5538   DO
5539     CALL get_command_argument(i, arg)
5540     IF (LEN_TRIM(arg) == 0) EXIT
5541
5542     WRITE (*,*) TRIM(arg)
5543     i = i+1
5544   END DO
5545 END PROGRAM
5546 @end smallexample
5547
5548 @item @emph{See also}:
5549 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
5550 @end table
5551
5552
5553
5554 @node GETCWD
5555 @section @code{GETCWD} --- Get current working directory
5556 @fnindex GETCWD
5557 @cindex system, working directory
5558
5559 @table @asis
5560 @item @emph{Description}:
5561 Get current working directory.
5562
5563 This intrinsic is provided in both subroutine and function forms; however,
5564 only one form can be used in any given program unit.
5565
5566 @item @emph{Standard}:
5567 GNU extension
5568
5569 @item @emph{Class}:
5570 Subroutine, function
5571
5572 @item @emph{Syntax}:
5573 @multitable @columnfractions .80
5574 @item @code{CALL GETCWD(C [, STATUS])}
5575 @item @code{STATUS = GETCWD(C)}
5576 @end multitable
5577
5578 @item @emph{Arguments}:
5579 @multitable @columnfractions .15 .70
5580 @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
5581 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success, 
5582 a system specific and nonzero error code otherwise.
5583 @end multitable
5584
5585 @item @emph{Example}:
5586 @smallexample
5587 PROGRAM test_getcwd
5588   CHARACTER(len=255) :: cwd
5589   CALL getcwd(cwd)
5590   WRITE(*,*) TRIM(cwd)
5591 END PROGRAM
5592 @end smallexample
5593
5594 @item @emph{See also}:
5595 @ref{CHDIR}
5596 @end table
5597
5598
5599
5600 @node GETENV
5601 @section @code{GETENV} --- Get an environmental variable
5602 @fnindex GETENV
5603 @cindex environment variable
5604
5605 @table @asis
5606 @item @emph{Description}:
5607 Get the @var{VALUE} of the environmental variable @var{NAME}.
5608
5609 This intrinsic routine is provided for backwards compatibility with
5610 GNU Fortran 77.  In new code, programmers should consider the use of
5611 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
5612 2003 standard.
5613
5614 Note that @code{GETENV} need not be thread-safe. It is the
5615 responsibility of the user to ensure that the environment is not being
5616 updated concurrently with a call to the @code{GETENV} intrinsic.
5617
5618 @item @emph{Standard}:
5619 GNU extension
5620
5621 @item @emph{Class}:
5622 Subroutine
5623
5624 @item @emph{Syntax}:
5625 @code{CALL GETENV(NAME, VALUE)}
5626
5627 @item @emph{Arguments}:
5628 @multitable @columnfractions .15 .70
5629 @item @var{NAME}  @tab Shall be of type @code{CHARACTER} and of default kind.
5630 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
5631 @end multitable
5632
5633 @item @emph{Return value}:
5634 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
5635 not large enough to hold the data, it is truncated. If @var{NAME}
5636 is not set, @var{VALUE} will be filled with blanks.
5637
5638 @item @emph{Example}:
5639 @smallexample
5640 PROGRAM test_getenv
5641   CHARACTER(len=255) :: homedir
5642   CALL getenv("HOME", homedir)
5643   WRITE (*,*) TRIM(homedir)
5644 END PROGRAM
5645 @end smallexample
5646
5647 @item @emph{See also}:
5648 @ref{GET_ENVIRONMENT_VARIABLE}
5649 @end table
5650
5651
5652
5653 @node GET_ENVIRONMENT_VARIABLE
5654 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
5655 @fnindex GET_ENVIRONMENT_VARIABLE
5656 @cindex environment variable
5657
5658 @table @asis
5659 @item @emph{Description}:
5660 Get the @var{VALUE} of the environmental variable @var{NAME}.
5661
5662 Note that @code{GET_ENVIRONMENT_VARIABLE} need not be thread-safe. It
5663 is the responsibility of the user to ensure that the environment is
5664 not being updated concurrently with a call to the
5665 @code{GET_ENVIRONMENT_VARIABLE} intrinsic.
5666
5667 @item @emph{Standard}:
5668 Fortran 2003 and later
5669
5670 @item @emph{Class}:
5671 Subroutine
5672
5673 @item @emph{Syntax}:
5674 @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
5675
5676 @item @emph{Arguments}:
5677 @multitable @columnfractions .15 .70
5678 @item @var{NAME}      @tab Shall be a scalar of type @code{CHARACTER}
5679 and of default kind.
5680 @item @var{VALUE}     @tab (Optional) Shall be a scalar of type @code{CHARACTER}
5681 and of default kind.
5682 @item @var{LENGTH}    @tab (Optional) Shall be a scalar of type @code{INTEGER}
5683 and of default kind.
5684 @item @var{STATUS}    @tab (Optional) Shall be a scalar of type @code{INTEGER}
5685 and of default kind.
5686 @item @var{TRIM_NAME} @tab (Optional) Shall be a scalar of type @code{LOGICAL}
5687 and of default kind.
5688 @end multitable
5689
5690 @item @emph{Return value}:
5691 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
5692 not large enough to hold the data, it is truncated. If @var{NAME}
5693 is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
5694 contains the length needed for storing the environment variable @var{NAME}
5695 or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
5696 but too short for the environment variable; it is 1 if the environment
5697 variable does not exist and 2 if the processor does not support environment
5698 variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
5699 present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
5700 are significant; otherwise they are not part of the environment variable
5701 name.
5702
5703 @item @emph{Example}:
5704 @smallexample
5705 PROGRAM test_getenv
5706   CHARACTER(len=255) :: homedir
5707   CALL get_environment_variable("HOME", homedir)
5708   WRITE (*,*) TRIM(homedir)
5709 END PROGRAM
5710 @end smallexample
5711 @end table
5712
5713
5714
5715 @node GETGID
5716 @section @code{GETGID} --- Group ID function
5717 @fnindex GETGID
5718 @cindex system, group ID
5719
5720 @table @asis
5721 @item @emph{Description}:
5722 Returns the numerical group ID of the current process.
5723
5724 @item @emph{Standard}:
5725 GNU extension
5726
5727 @item @emph{Class}:
5728 Function
5729
5730 @item @emph{Syntax}:
5731 @code{RESULT = GETGID()}
5732
5733 @item @emph{Return value}:
5734 The return value of @code{GETGID} is an @code{INTEGER} of the default
5735 kind.
5736
5737
5738 @item @emph{Example}:
5739 See @code{GETPID} for an example.
5740
5741 @item @emph{See also}:
5742 @ref{GETPID}, @ref{GETUID}
5743 @end table
5744
5745
5746
5747 @node GETLOG
5748 @section @code{GETLOG} --- Get login name
5749 @fnindex GETLOG
5750 @cindex system, login name
5751 @cindex login name
5752
5753 @table @asis
5754 @item @emph{Description}:
5755 Gets the username under which the program is running.
5756
5757 @item @emph{Standard}:
5758 GNU extension
5759
5760 @item @emph{Class}:
5761 Subroutine
5762
5763 @item @emph{Syntax}:
5764 @code{CALL GETLOG(C)}
5765
5766 @item @emph{Arguments}:
5767 @multitable @columnfractions .15 .70
5768 @item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
5769 @end multitable
5770
5771 @item @emph{Return value}:
5772 Stores the current user name in @var{LOGIN}.  (On systems where POSIX
5773 functions @code{geteuid} and @code{getpwuid} are not available, and 
5774 the @code{getlogin} function is not implemented either, this will
5775 return a blank string.)
5776
5777 @item @emph{Example}:
5778 @smallexample
5779 PROGRAM TEST_GETLOG
5780   CHARACTER(32) :: login
5781   CALL GETLOG(login)
5782   WRITE(*,*) login
5783 END PROGRAM
5784 @end smallexample
5785
5786 @item @emph{See also}:
5787 @ref{GETUID}
5788 @end table
5789
5790
5791
5792 @node GETPID
5793 @section @code{GETPID} --- Process ID function
5794 @fnindex GETPID
5795 @cindex system, process ID
5796 @cindex process ID
5797
5798 @table @asis
5799 @item @emph{Description}:
5800 Returns the numerical process identifier of the current process.
5801
5802 @item @emph{Standard}:
5803 GNU extension
5804
5805 @item @emph{Class}:
5806 Function
5807
5808 @item @emph{Syntax}:
5809 @code{RESULT = GETPID()}
5810
5811 @item @emph{Return value}:
5812 The return value of @code{GETPID} is an @code{INTEGER} of the default
5813 kind.
5814
5815
5816 @item @emph{Example}:
5817 @smallexample
5818 program info
5819   print *, "The current process ID is ", getpid()
5820   print *, "Your numerical user ID is ", getuid()
5821   print *, "Your numerical group ID is ", getgid()
5822 end program info
5823 @end smallexample
5824
5825 @item @emph{See also}:
5826 @ref{GETGID}, @ref{GETUID}
5827 @end table
5828
5829
5830
5831 @node GETUID
5832 @section @code{GETUID} --- User ID function
5833 @fnindex GETUID
5834 @cindex system, user ID
5835 @cindex user id
5836
5837 @table @asis
5838 @item @emph{Description}:
5839 Returns the numerical user ID of the current process.
5840
5841 @item @emph{Standard}:
5842 GNU extension
5843
5844 @item @emph{Class}:
5845 Function
5846
5847 @item @emph{Syntax}:
5848 @code{RESULT = GETUID()}
5849
5850 @item @emph{Return value}:
5851 The return value of @code{GETUID} is an @code{INTEGER} of the default
5852 kind.
5853
5854
5855 @item @emph{Example}:
5856 See @code{GETPID} for an example.
5857
5858 @item @emph{See also}:
5859 @ref{GETPID}, @ref{GETLOG}
5860 @end table
5861
5862
5863
5864 @node GMTIME
5865 @section @code{GMTIME} --- Convert time to GMT info
5866 @fnindex GMTIME
5867 @cindex time, conversion to GMT info
5868
5869 @table @asis
5870 @item @emph{Description}:
5871 Given a system time value @var{TIME} (as provided by the @code{TIME8}
5872 intrinsic), fills @var{VALUES} with values extracted from it appropriate
5873 to the UTC time zone (Universal Coordinated Time, also known in some
5874 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
5875
5876 @item @emph{Standard}:
5877 GNU extension
5878
5879 @item @emph{Class}:
5880 Subroutine
5881
5882 @item @emph{Syntax}:
5883 @code{CALL GMTIME(TIME, VALUES)}
5884
5885 @item @emph{Arguments}:
5886 @multitable @columnfractions .15 .70
5887 @item @var{TIME}   @tab An @code{INTEGER} scalar expression
5888 corresponding to a system time, with @code{INTENT(IN)}.
5889 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
5890 with @code{INTENT(OUT)}.
5891 @end multitable
5892
5893 @item @emph{Return value}:
5894 The elements of @var{VALUES} are assigned as follows:
5895 @enumerate
5896 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
5897 seconds
5898 @item Minutes after the hour, range 0--59
5899 @item Hours past midnight, range 0--23
5900 @item Day of month, range 0--31
5901 @item Number of months since January, range 0--12
5902 @item Years since 1900
5903 @item Number of days since Sunday, range 0--6
5904 @item Days since January 1
5905 @item Daylight savings indicator: positive if daylight savings is in
5906 effect, zero if not, and negative if the information is not available.
5907 @end enumerate
5908
5909 @item @emph{See also}:
5910 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
5911
5912 @end table
5913
5914
5915
5916 @node HOSTNM
5917 @section @code{HOSTNM} --- Get system host name
5918 @fnindex HOSTNM
5919 @cindex system, host name
5920
5921 @table @asis
5922 @item @emph{Description}:
5923 Retrieves the host name of the system on which the program is running.
5924
5925 This intrinsic is provided in both subroutine and function forms; however,
5926 only one form can be used in any given program unit.
5927
5928 @item @emph{Standard}:
5929 GNU extension
5930
5931 @item @emph{Class}:
5932 Subroutine, function
5933
5934 @item @emph{Syntax}:
5935 @multitable @columnfractions .80
5936 @item @code{CALL HOSTNM(C [, STATUS])}
5937 @item @code{STATUS = HOSTNM(NAME)}
5938 @end multitable
5939
5940 @item @emph{Arguments}:
5941 @multitable @columnfractions .15 .70
5942 @item @var{C}    @tab Shall of type @code{CHARACTER} and of default kind.
5943 @item @var{STATUS}  @tab (Optional) status flag of type @code{INTEGER}.
5944 Returns 0 on success, or a system specific error code otherwise.
5945 @end multitable
5946
5947 @item @emph{Return value}:
5948 In either syntax, @var{NAME} is set to the current hostname if it can
5949 be obtained, or to a blank string otherwise.
5950
5951 @end table
5952
5953
5954
5955 @node HUGE
5956 @section @code{HUGE} --- Largest number of a kind
5957 @fnindex HUGE
5958 @cindex limits, largest number
5959 @cindex model representation, largest number
5960
5961 @table @asis
5962 @item @emph{Description}:
5963 @code{HUGE(X)} returns the largest number that is not an infinity in
5964 the model of the type of @code{X}.
5965
5966 @item @emph{Standard}:
5967 Fortran 95 and later
5968
5969 @item @emph{Class}:
5970 Inquiry function
5971
5972 @item @emph{Syntax}:
5973 @code{RESULT = HUGE(X)}
5974
5975 @item @emph{Arguments}:
5976 @multitable @columnfractions .15 .70
5977 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
5978 @end multitable
5979
5980 @item @emph{Return value}:
5981 The return value is of the same type and kind as @var{X}
5982
5983 @item @emph{Example}:
5984 @smallexample
5985 program test_huge_tiny
5986   print *, huge(0), huge(0.0), huge(0.0d0)
5987   print *, tiny(0.0), tiny(0.0d0)
5988 end program test_huge_tiny
5989 @end smallexample
5990 @end table
5991
5992
5993
5994 @node HYPOT
5995 @section @code{HYPOT} --- Euclidean distance function
5996 @fnindex HYPOT
5997 @cindex Euclidean distance
5998
5999 @table @asis
6000 @item @emph{Description}:
6001 @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
6002 @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
6003
6004 @item @emph{Standard}:
6005 Fortran 2008 and later
6006
6007 @item @emph{Class}:
6008 Elemental function
6009
6010 @item @emph{Syntax}:
6011 @code{RESULT = HYPOT(X, Y)}
6012
6013 @item @emph{Arguments}:
6014 @multitable @columnfractions .15 .70
6015 @item @var{X} @tab The type shall be @code{REAL}.
6016 @item @var{Y} @tab The type and kind type parameter shall be the same as
6017 @var{X}.
6018 @end multitable
6019
6020 @item @emph{Return value}:
6021 The return value has the same type and kind type parameter as @var{X}.
6022
6023 @item @emph{Example}:
6024 @smallexample
6025 program test_hypot
6026   real(4) :: x = 1.e0_4, y = 0.5e0_4
6027   x = hypot(x,y)
6028 end program test_hypot
6029 @end smallexample
6030 @end table
6031
6032
6033
6034 @node IACHAR
6035 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence 
6036 @fnindex IACHAR
6037 @cindex @acronym{ASCII} collating sequence
6038 @cindex collating sequence, @acronym{ASCII}
6039 @cindex conversion, to integer
6040
6041 @table @asis
6042 @item @emph{Description}:
6043 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
6044 in the first character position of @code{C}.
6045
6046 @item @emph{Standard}:
6047 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6048
6049 @item @emph{Class}:
6050 Elemental function
6051
6052 @item @emph{Syntax}:
6053 @code{RESULT = IACHAR(C [, KIND])}
6054
6055 @item @emph{Arguments}:
6056 @multitable @columnfractions .15 .70
6057 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
6058 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6059 expression indicating the kind parameter of the result.
6060 @end multitable
6061
6062 @item @emph{Return value}:
6063 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6064 @var{KIND} is absent, the return value is of default integer kind.
6065
6066 @item @emph{Example}:
6067 @smallexample
6068 program test_iachar
6069   integer i
6070   i = iachar(' ')
6071 end program test_iachar
6072 @end smallexample
6073
6074 @item @emph{Note}:
6075 See @ref{ICHAR} for a discussion of converting between numerical values
6076 and formatted string representations.
6077
6078 @item @emph{See also}:
6079 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
6080
6081 @end table
6082
6083
6084
6085 @node IALL
6086 @section @code{IALL} --- Bitwise AND of array elements
6087 @fnindex IALL
6088 @cindex array, AND
6089 @cindex bits, AND of array elements
6090
6091 @table @asis
6092 @item @emph{Description}:
6093 Reduces with bitwise AND the elements of @var{ARRAY} along dimension @var{DIM}
6094 if the corresponding element in @var{MASK} is @code{TRUE}.
6095
6096 @item @emph{Standard}:
6097 Fortran 2008 and later
6098
6099 @item @emph{Class}:
6100 Transformational function
6101
6102 @item @emph{Syntax}:
6103 @multitable @columnfractions .80
6104 @item @code{RESULT = IALL(ARRAY[, MASK])}
6105 @item @code{RESULT = IALL(ARRAY, DIM[, MASK])}
6106 @end multitable
6107
6108 @item @emph{Arguments}:
6109 @multitable @columnfractions .15 .70
6110 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
6111 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
6112 @code{INTEGER} with a value in the range from 1 to n, where n 
6113 equals the rank of @var{ARRAY}.
6114 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
6115 and either be a scalar or an array of the same shape as @var{ARRAY}.
6116 @end multitable
6117
6118 @item @emph{Return value}:
6119 The result is of the same type as @var{ARRAY}.
6120
6121 If @var{DIM} is absent, a scalar with the bitwise ALL of all elements in
6122 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
6123 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
6124 dimension @var{DIM} dropped is returned.
6125
6126 @item @emph{Example}:
6127 @smallexample
6128 PROGRAM test_iall
6129   INTEGER(1) :: a(2)
6130
6131   a(1) = b'00100100'
6132   a(2) = b'01101010'
6133
6134   ! prints 00100000
6135   PRINT '(b8.8)', IALL(a)
6136 END PROGRAM
6137 @end smallexample
6138
6139 @item @emph{See also}:
6140 @ref{IANY}, @ref{IPARITY}, @ref{IAND}
6141 @end table
6142
6143
6144
6145 @node IAND
6146 @section @code{IAND} --- Bitwise logical and
6147 @fnindex IAND
6148 @cindex bitwise logical and
6149 @cindex logical and, bitwise
6150
6151 @table @asis
6152 @item @emph{Description}:
6153 Bitwise logical @code{AND}.
6154
6155 @item @emph{Standard}:
6156 Fortran 95 and later
6157
6158 @item @emph{Class}:
6159 Elemental function
6160
6161 @item @emph{Syntax}:
6162 @code{RESULT = IAND(I, J)}
6163
6164 @item @emph{Arguments}:
6165 @multitable @columnfractions .15 .70
6166 @item @var{I} @tab The type shall be @code{INTEGER}.
6167 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6168 kind as @var{I}.  (As a GNU extension, different kinds are also 
6169 permitted.)
6170 @end multitable
6171
6172 @item @emph{Return value}:
6173 The return type is @code{INTEGER}, of the same kind as the
6174 arguments.  (If the argument kinds differ, it is of the same kind as
6175 the larger argument.)
6176
6177 @item @emph{Example}:
6178 @smallexample
6179 PROGRAM test_iand
6180   INTEGER :: a, b
6181   DATA a / Z'F' /, b / Z'3' /
6182   WRITE (*,*) IAND(a, b)
6183 END PROGRAM
6184 @end smallexample
6185
6186 @item @emph{See also}:
6187 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6188
6189 @end table
6190
6191
6192
6193 @node IANY
6194 @section @code{IANY} --- Bitwise OR of array elements
6195 @fnindex IANY
6196 @cindex array, OR
6197 @cindex bits, OR of array elements
6198
6199 @table @asis
6200 @item @emph{Description}:
6201 Reduces with bitwise OR (inclusive or) the elements of @var{ARRAY} along
6202 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
6203
6204 @item @emph{Standard}:
6205 Fortran 2008 and later
6206
6207 @item @emph{Class}:
6208 Transformational function
6209
6210 @item @emph{Syntax}:
6211 @multitable @columnfractions .80
6212 @item @code{RESULT = IANY(ARRAY[, MASK])}
6213 @item @code{RESULT = IANY(ARRAY, DIM[, MASK])}
6214 @end multitable
6215
6216 @item @emph{Arguments}:
6217 @multitable @columnfractions .15 .70
6218 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
6219 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
6220 @code{INTEGER} with a value in the range from 1 to n, where n 
6221 equals the rank of @var{ARRAY}.
6222 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
6223 and either be a scalar or an array of the same shape as @var{ARRAY}.
6224 @end multitable
6225
6226 @item @emph{Return value}:
6227 The result is of the same type as @var{ARRAY}.
6228
6229 If @var{DIM} is absent, a scalar with the bitwise OR of all elements in
6230 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
6231 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
6232 dimension @var{DIM} dropped is returned.
6233
6234 @item @emph{Example}:
6235 @smallexample
6236 PROGRAM test_iany
6237   INTEGER(1) :: a(2)
6238
6239   a(1) = b'00100100'
6240   a(2) = b'01101010'
6241
6242   ! prints 01101110
6243   PRINT '(b8.8)', IANY(a)
6244 END PROGRAM
6245 @end smallexample
6246
6247 @item @emph{See also}:
6248 @ref{IPARITY}, @ref{IALL}, @ref{IOR}
6249 @end table
6250
6251
6252
6253 @node IARGC
6254 @section @code{IARGC} --- Get the number of command line arguments
6255 @fnindex IARGC
6256 @cindex command-line arguments
6257 @cindex command-line arguments, number of
6258 @cindex arguments, to program
6259
6260 @table @asis
6261 @item @emph{Description}:
6262 @code{IARGC} returns the number of arguments passed on the
6263 command line when the containing program was invoked.
6264
6265 This intrinsic routine is provided for backwards compatibility with 
6266 GNU Fortran 77.  In new code, programmers should consider the use of 
6267 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003 
6268 standard.
6269
6270 @item @emph{Standard}:
6271 GNU extension
6272
6273 @item @emph{Class}:
6274 Function
6275
6276 @item @emph{Syntax}:
6277 @code{RESULT = IARGC()}
6278
6279 @item @emph{Arguments}:
6280 None.
6281
6282 @item @emph{Return value}:
6283 The number of command line arguments, type @code{INTEGER(4)}.
6284
6285 @item @emph{Example}:
6286 See @ref{GETARG}
6287
6288 @item @emph{See also}:
6289 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
6290
6291 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
6292 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
6293 @end table
6294
6295
6296
6297 @node IBCLR
6298 @section @code{IBCLR} --- Clear bit
6299 @fnindex IBCLR
6300 @cindex bits, unset
6301 @cindex bits, clear
6302
6303 @table @asis
6304 @item @emph{Description}:
6305 @code{IBCLR} returns the value of @var{I} with the bit at position
6306 @var{POS} set to zero.
6307
6308 @item @emph{Standard}:
6309 Fortran 95 and later
6310
6311 @item @emph{Class}:
6312 Elemental function
6313
6314 @item @emph{Syntax}:
6315 @code{RESULT = IBCLR(I, POS)}
6316
6317 @item @emph{Arguments}:
6318 @multitable @columnfractions .15 .70
6319 @item @var{I} @tab The type shall be @code{INTEGER}.
6320 @item @var{POS} @tab The type shall be @code{INTEGER}.
6321 @end multitable
6322
6323 @item @emph{Return value}:
6324 The return value is of type @code{INTEGER} and of the same kind as
6325 @var{I}.
6326
6327 @item @emph{See also}:
6328 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
6329
6330 @end table
6331
6332
6333
6334 @node IBITS
6335 @section @code{IBITS} --- Bit extraction
6336 @fnindex IBITS
6337 @cindex bits, get
6338 @cindex bits, extract
6339
6340 @table @asis
6341 @item @emph{Description}:
6342 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
6343 starting from bit position @var{POS} and extending left for @var{LEN}
6344 bits.  The result is right-justified and the remaining bits are
6345 zeroed.  The value of @code{POS+LEN} must be less than or equal to the
6346 value @code{BIT_SIZE(I)}.
6347
6348 @item @emph{Standard}:
6349 Fortran 95 and later
6350
6351 @item @emph{Class}:
6352 Elemental function
6353
6354 @item @emph{Syntax}:
6355 @code{RESULT = IBITS(I, POS, LEN)}
6356
6357 @item @emph{Arguments}:
6358 @multitable @columnfractions .15 .70
6359 @item @var{I}   @tab The type shall be @code{INTEGER}.
6360 @item @var{POS} @tab The type shall be @code{INTEGER}.
6361 @item @var{LEN} @tab The type shall be @code{INTEGER}.
6362 @end multitable
6363
6364 @item @emph{Return value}:
6365 The return value is of type @code{INTEGER} and of the same kind as
6366 @var{I}.
6367
6368 @item @emph{See also}:
6369 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
6370 @end table
6371
6372
6373
6374 @node IBSET
6375 @section @code{IBSET} --- Set bit
6376 @fnindex IBSET
6377 @cindex bits, set
6378
6379 @table @asis
6380 @item @emph{Description}:
6381 @code{IBSET} returns the value of @var{I} with the bit at position
6382 @var{POS} set to one.
6383
6384 @item @emph{Standard}:
6385 Fortran 95 and later
6386
6387 @item @emph{Class}:
6388 Elemental function
6389
6390 @item @emph{Syntax}:
6391 @code{RESULT = IBSET(I, POS)}
6392
6393 @item @emph{Arguments}:
6394 @multitable @columnfractions .15 .70
6395 @item @var{I} @tab The type shall be @code{INTEGER}.
6396 @item @var{POS} @tab The type shall be @code{INTEGER}.
6397 @end multitable
6398
6399 @item @emph{Return value}:
6400 The return value is of type @code{INTEGER} and of the same kind as
6401 @var{I}.
6402
6403 @item @emph{See also}:
6404 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
6405
6406 @end table
6407
6408
6409
6410 @node ICHAR
6411 @section @code{ICHAR} --- Character-to-integer conversion function
6412 @fnindex ICHAR
6413 @cindex conversion, to integer
6414
6415 @table @asis
6416 @item @emph{Description}:
6417 @code{ICHAR(C)} returns the code for the character in the first character
6418 position of @code{C} in the system's native character set.
6419 The correspondence between characters and their codes is not necessarily
6420 the same across different GNU Fortran implementations.
6421
6422 @item @emph{Standard}:
6423 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6424
6425 @item @emph{Class}:
6426 Elemental function
6427
6428 @item @emph{Syntax}:
6429 @code{RESULT = ICHAR(C [, KIND])}
6430
6431 @item @emph{Arguments}:
6432 @multitable @columnfractions .15 .70
6433 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
6434 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6435 expression indicating the kind parameter of the result.
6436 @end multitable
6437
6438 @item @emph{Return value}:
6439 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6440 @var{KIND} is absent, the return value is of default integer kind.
6441
6442 @item @emph{Example}:
6443 @smallexample
6444 program test_ichar
6445   integer i
6446   i = ichar(' ')
6447 end program test_ichar
6448 @end smallexample
6449
6450 @item @emph{Specific names}:
6451 @multitable @columnfractions .20 .20 .20 .25
6452 @item Name             @tab Argument             @tab Return type       @tab Standard
6453 @item @code{ICHAR(C)}  @tab @code{CHARACTER C}   @tab @code{INTEGER(4)}    @tab Fortran 77 and later
6454 @end multitable
6455
6456 @item @emph{Note}:
6457 No intrinsic exists to convert between a numeric value and a formatted
6458 character string representation -- for instance, given the
6459 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
6460 @code{REAL} value with the value 154, or vice versa. Instead, this
6461 functionality is provided by internal-file I/O, as in the following
6462 example:
6463 @smallexample
6464 program read_val
6465   integer value
6466   character(len=10) string, string2
6467   string = '154'
6468   
6469   ! Convert a string to a numeric value
6470   read (string,'(I10)') value
6471   print *, value
6472   
6473   ! Convert a value to a formatted string
6474   write (string2,'(I10)') value
6475   print *, string2
6476 end program read_val
6477 @end smallexample
6478
6479 @item @emph{See also}:
6480 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
6481
6482 @end table
6483
6484
6485
6486 @node IDATE
6487 @section @code{IDATE} --- Get current local time subroutine (day/month/year) 
6488 @fnindex IDATE
6489 @cindex date, current
6490 @cindex current date
6491
6492 @table @asis
6493 @item @emph{Description}:
6494 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the  
6495 current local time. The day (in the range 1-31), month (in the range 1-12), 
6496 and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively. 
6497 The year has four significant digits.
6498
6499 @item @emph{Standard}:
6500 GNU extension
6501
6502 @item @emph{Class}:
6503 Subroutine
6504
6505 @item @emph{Syntax}:
6506 @code{CALL IDATE(VALUES)}
6507
6508 @item @emph{Arguments}:
6509 @multitable @columnfractions .15 .70
6510 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
6511 the kind shall be the default integer kind.
6512 @end multitable
6513
6514 @item @emph{Return value}:
6515 Does not return anything.
6516
6517 @item @emph{Example}:
6518 @smallexample
6519 program test_idate
6520   integer, dimension(3) :: tarray
6521   call idate(tarray)
6522   print *, tarray(1)
6523   print *, tarray(2)
6524   print *, tarray(3)
6525 end program test_idate
6526 @end smallexample
6527 @end table
6528
6529
6530
6531 @node IEOR
6532 @section @code{IEOR} --- Bitwise logical exclusive or
6533 @fnindex IEOR
6534 @cindex bitwise logical exclusive or
6535 @cindex logical exclusive or, bitwise
6536
6537 @table @asis
6538 @item @emph{Description}:
6539 @code{IEOR} returns the bitwise Boolean exclusive-OR of @var{I} and
6540 @var{J}.
6541
6542 @item @emph{Standard}:
6543 Fortran 95 and later
6544
6545 @item @emph{Class}:
6546 Elemental function
6547
6548 @item @emph{Syntax}:
6549 @code{RESULT = IEOR(I, J)}
6550
6551 @item @emph{Arguments}:
6552 @multitable @columnfractions .15 .70
6553 @item @var{I} @tab The type shall be @code{INTEGER}.
6554 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6555 kind as @var{I}.  (As a GNU extension, different kinds are also 
6556 permitted.)
6557 @end multitable
6558
6559 @item @emph{Return value}:
6560 The return type is @code{INTEGER}, of the same kind as the
6561 arguments.  (If the argument kinds differ, it is of the same kind as
6562 the larger argument.)
6563
6564 @item @emph{See also}:
6565 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6566 @end table
6567
6568
6569
6570 @node IERRNO
6571 @section @code{IERRNO} --- Get the last system error number
6572 @fnindex IERRNO
6573 @cindex system, error handling
6574
6575 @table @asis
6576 @item @emph{Description}:
6577 Returns the last system error number, as given by the C @code{errno}
6578 variable.
6579
6580 @item @emph{Standard}:
6581 GNU extension
6582
6583 @item @emph{Class}:
6584 Function
6585
6586 @item @emph{Syntax}:
6587 @code{RESULT = IERRNO()}
6588
6589 @item @emph{Arguments}:
6590 None.
6591
6592 @item @emph{Return value}:
6593 The return value is of type @code{INTEGER} and of the default integer
6594 kind.
6595
6596 @item @emph{See also}:
6597 @ref{PERROR}
6598 @end table
6599
6600
6601
6602 @node IMAGE_INDEX
6603 @section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index
6604 @fnindex IMAGE_INDEX
6605 @cindex coarray, @code{IMAGE_INDEX}
6606 @cindex images, cosubscript to image index conversion
6607
6608 @table @asis
6609 @item @emph{Description}:
6610 Returns the image index belonging to a cosubscript.
6611
6612 @item @emph{Standard}:
6613 Fortran 2008 and later
6614
6615 @item @emph{Class}:
6616 Inquiry function.
6617
6618 @item @emph{Syntax}:
6619 @code{RESULT = IMAGE_INDEX(COARRAY, SUB)}
6620
6621 @item @emph{Arguments}: None.
6622 @multitable @columnfractions .15 .70
6623 @item @var{COARRAY} @tab Coarray of any type.
6624 @item @var{SUB}     @tab default integer rank-1 array of a size equal to
6625 the corank of @var{COARRAY}.
6626 @end multitable
6627
6628
6629 @item @emph{Return value}:
6630 Scalar default integer with the value of the image index which corresponds
6631 to the cosubscripts. For invalid cosubscripts the result is zero.
6632
6633 @item @emph{Example}:
6634 @smallexample
6635 INTEGER :: array[2,-1:4,8,*]
6636 ! Writes  28 (or 0 if there are fewer than 28 images)
6637 WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1])
6638 @end smallexample
6639
6640 @item @emph{See also}:
6641 @ref{THIS_IMAGE}, @ref{NUM_IMAGES}
6642 @end table
6643
6644
6645
6646 @node INDEX intrinsic
6647 @section @code{INDEX} --- Position of a substring within a string
6648 @fnindex INDEX
6649 @cindex substring position
6650 @cindex string, find substring
6651
6652 @table @asis
6653 @item @emph{Description}:
6654 Returns the position of the start of the first occurrence of string
6655 @var{SUBSTRING} as a substring in @var{STRING}, counting from one.  If
6656 @var{SUBSTRING} is not present in @var{STRING}, zero is returned.  If 
6657 the @var{BACK} argument is present and true, the return value is the
6658 start of the last occurrence rather than the first.
6659
6660 @item @emph{Standard}:
6661 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
6662
6663 @item @emph{Class}:
6664 Elemental function
6665
6666 @item @emph{Syntax}:
6667 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
6668
6669 @item @emph{Arguments}:
6670 @multitable @columnfractions .15 .70
6671 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
6672 @code{INTENT(IN)}
6673 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
6674 @code{INTENT(IN)}
6675 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
6676 @code{INTENT(IN)}
6677 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6678 expression indicating the kind parameter of the result.
6679 @end multitable
6680
6681 @item @emph{Return value}:
6682 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6683 @var{KIND} is absent, the return value is of default integer kind.
6684
6685 @item @emph{Specific names}:
6686 @multitable @columnfractions .20 .20 .20 .25
6687 @item Name                            @tab Argument           @tab Return type       @tab Standard
6688 @item @code{INDEX(STRING, SUBSTRING)} @tab @code{CHARACTER}   @tab @code{INTEGER(4)} @tab Fortran 77 and later
6689 @end multitable
6690
6691 @item @emph{See also}:
6692 @ref{SCAN}, @ref{VERIFY}
6693 @end table
6694
6695
6696
6697 @node INT
6698 @section @code{INT} --- Convert to integer type
6699 @fnindex INT
6700 @fnindex IFIX
6701 @fnindex IDINT
6702 @cindex conversion, to integer
6703
6704 @table @asis
6705 @item @emph{Description}:
6706 Convert to integer type
6707
6708 @item @emph{Standard}:
6709 Fortran 77 and later
6710
6711 @item @emph{Class}:
6712 Elemental function
6713
6714 @item @emph{Syntax}:
6715 @code{RESULT = INT(A [, KIND))}
6716
6717 @item @emph{Arguments}:
6718 @multitable @columnfractions .15 .70
6719 @item @var{A}    @tab Shall be of type @code{INTEGER},
6720 @code{REAL}, or @code{COMPLEX}.
6721 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6722 expression indicating the kind parameter of the result.
6723 @end multitable
6724
6725 @item @emph{Return value}:
6726 These functions return a @code{INTEGER} variable or array under 
6727 the following rules: 
6728
6729 @table @asis
6730 @item (A)
6731 If @var{A} is of type @code{INTEGER}, @code{INT(A) = A} 
6732 @item (B)
6733 If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} equals @code{0}. 
6734 If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed 
6735 the range of @var{A} and whose sign is the same as the sign of @var{A}.
6736 @item (C)
6737 If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
6738 @end table
6739
6740 @item @emph{Example}:
6741 @smallexample
6742 program test_int
6743   integer :: i = 42
6744   complex :: z = (-3.7, 1.0)
6745   print *, int(i)
6746   print *, int(z), int(z,8)
6747 end program
6748 @end smallexample
6749
6750 @item @emph{Specific names}:
6751 @multitable @columnfractions .20 .20 .20 .25
6752 @item Name            @tab Argument          @tab Return type       @tab Standard
6753 @item @code{INT(A)}   @tab @code{REAL(4) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
6754 @item @code{IFIX(A)}  @tab @code{REAL(4) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
6755 @item @code{IDINT(A)} @tab @code{REAL(8) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
6756 @end multitable
6757
6758 @end table
6759
6760
6761 @node INT2
6762 @section @code{INT2} --- Convert to 16-bit integer type
6763 @fnindex INT2
6764 @fnindex SHORT
6765 @cindex conversion, to integer
6766
6767 @table @asis
6768 @item @emph{Description}:
6769 Convert to a @code{KIND=2} integer type. This is equivalent to the
6770 standard @code{INT} intrinsic with an optional argument of
6771 @code{KIND=2}, and is only included for backwards compatibility.
6772
6773 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
6774
6775 @item @emph{Standard}:
6776 GNU extension
6777
6778 @item @emph{Class}:
6779 Elemental function
6780
6781 @item @emph{Syntax}:
6782 @code{RESULT = INT2(A)}
6783
6784 @item @emph{Arguments}:
6785 @multitable @columnfractions .15 .70
6786 @item @var{A}    @tab Shall be of type @code{INTEGER},
6787 @code{REAL}, or @code{COMPLEX}.
6788 @end multitable
6789
6790 @item @emph{Return value}:
6791 The return value is a @code{INTEGER(2)} variable.
6792
6793 @item @emph{See also}:
6794 @ref{INT}, @ref{INT8}, @ref{LONG}
6795 @end table
6796
6797
6798
6799 @node INT8
6800 @section @code{INT8} --- Convert to 64-bit integer type
6801 @fnindex INT8
6802 @cindex conversion, to integer
6803
6804 @table @asis
6805 @item @emph{Description}:
6806 Convert to a @code{KIND=8} integer type. This is equivalent to the
6807 standard @code{INT} intrinsic with an optional argument of
6808 @code{KIND=8}, and is only included for backwards compatibility.
6809
6810 @item @emph{Standard}:
6811 GNU extension
6812
6813 @item @emph{Class}:
6814 Elemental function
6815
6816 @item @emph{Syntax}:
6817 @code{RESULT = INT8(A)}
6818
6819 @item @emph{Arguments}:
6820 @multitable @columnfractions .15 .70
6821 @item @var{A}    @tab Shall be of type @code{INTEGER},
6822 @code{REAL}, or @code{COMPLEX}.
6823 @end multitable
6824
6825 @item @emph{Return value}:
6826 The return value is a @code{INTEGER(8)} variable.
6827
6828 @item @emph{See also}:
6829 @ref{INT}, @ref{INT2}, @ref{LONG}
6830 @end table
6831
6832
6833
6834 @node IOR
6835 @section @code{IOR} --- Bitwise logical or
6836 @fnindex IOR
6837 @cindex bitwise logical or
6838 @cindex logical or, bitwise
6839
6840 @table @asis
6841 @item @emph{Description}:
6842 @code{IOR} returns the bitwise Boolean inclusive-OR of @var{I} and
6843 @var{J}.
6844
6845 @item @emph{Standard}:
6846 Fortran 95 and later
6847
6848 @item @emph{Class}:
6849 Elemental function
6850
6851 @item @emph{Syntax}:
6852 @code{RESULT = IOR(I, J)}
6853
6854 @item @emph{Arguments}:
6855 @multitable @columnfractions .15 .70
6856 @item @var{I} @tab The type shall be @code{INTEGER}.
6857 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6858 kind as @var{I}.  (As a GNU extension, different kinds are also 
6859 permitted.)
6860 @end multitable
6861
6862 @item @emph{Return value}:
6863 The return type is @code{INTEGER}, of the same kind as the
6864 arguments.  (If the argument kinds differ, it is of the same kind as
6865 the larger argument.)
6866
6867 @item @emph{See also}:
6868 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6869 @end table
6870
6871
6872
6873 @node IPARITY
6874 @section @code{IPARITY} --- Bitwise XOR of array elements
6875 @fnindex IPARITY
6876 @cindex array, parity
6877 @cindex array, XOR
6878 @cindex bits, XOR of array elements
6879
6880 @table @asis
6881 @item @emph{Description}:
6882 Reduces with bitwise XOR (exclusive or) the elements of @var{ARRAY} along
6883 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
6884
6885 @item @emph{Standard}:
6886 Fortran 2008 and later
6887
6888 @item @emph{Class}:
6889 Transformational function
6890
6891 @item @emph{Syntax}:
6892 @multitable @columnfractions .80
6893 @item @code{RESULT = IPARITY(ARRAY[, MASK])}
6894 @item @code{RESULT = IPARITY(ARRAY, DIM[, MASK])}
6895 @end multitable
6896
6897 @item @emph{Arguments}:
6898 @multitable @columnfractions .15 .70
6899 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
6900 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
6901 @code{INTEGER} with a value in the range from 1 to n, where n 
6902 equals the rank of @var{ARRAY}.
6903 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
6904 and either be a scalar or an array of the same shape as @var{ARRAY}.
6905 @end multitable
6906
6907 @item @emph{Return value}:
6908 The result is of the same type as @var{ARRAY}.
6909
6910 If @var{DIM} is absent, a scalar with the bitwise XOR of all elements in
6911 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
6912 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
6913 dimension @var{DIM} dropped is returned.
6914
6915 @item @emph{Example}:
6916 @smallexample
6917 PROGRAM test_iparity
6918   INTEGER(1) :: a(2)
6919
6920   a(1) = b'00100100'
6921   a(2) = b'01101010'
6922
6923   ! prints 01001110
6924   PRINT '(b8.8)', IPARITY(a)
6925 END PROGRAM
6926 @end smallexample
6927
6928 @item @emph{See also}:
6929 @ref{IANY}, @ref{IALL}, @ref{IEOR}, @ref{PARITY}
6930 @end table
6931
6932
6933
6934 @node IRAND
6935 @section @code{IRAND} --- Integer pseudo-random number
6936 @fnindex IRAND
6937 @cindex random number generation
6938
6939 @table @asis
6940 @item @emph{Description}:
6941 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
6942 distribution between 0 and a system-dependent limit (which is in most
6943 cases 2147483647). If @var{FLAG} is 0, the next number
6944 in the current sequence is returned; if @var{FLAG} is 1, the generator
6945 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
6946 it is used as a new seed with @code{SRAND}.
6947
6948 This intrinsic routine is provided for backwards compatibility with
6949 GNU Fortran 77. It implements a simple modulo generator as provided 
6950 by @command{g77}. For new code, one should consider the use of 
6951 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
6952
6953 @item @emph{Standard}:
6954 GNU extension
6955
6956 @item @emph{Class}:
6957 Function
6958
6959 @item @emph{Syntax}:
6960 @code{RESULT = IRAND(I)}
6961
6962 @item @emph{Arguments}:
6963 @multitable @columnfractions .15 .70
6964 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
6965 @end multitable
6966
6967 @item @emph{Return value}:
6968 The return value is of @code{INTEGER(kind=4)} type.
6969
6970 @item @emph{Example}:
6971 @smallexample
6972 program test_irand
6973   integer,parameter :: seed = 86456
6974   
6975   call srand(seed)
6976   print *, irand(), irand(), irand(), irand()
6977   print *, irand(seed), irand(), irand(), irand()
6978 end program test_irand
6979 @end smallexample
6980
6981 @end table
6982
6983
6984
6985 @node IS_IOSTAT_END
6986 @section @code{IS_IOSTAT_END} --- Test for end-of-file value
6987 @fnindex IS_IOSTAT_END
6988 @cindex @code{IOSTAT}, end of file
6989
6990 @table @asis
6991 @item @emph{Description}:
6992 @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
6993 status ``end of file''. The function is equivalent to comparing the variable
6994 with the @code{IOSTAT_END} parameter of the intrinsic module
6995 @code{ISO_FORTRAN_ENV}.
6996
6997 @item @emph{Standard}:
6998 Fortran 2003 and later
6999
7000 @item @emph{Class}:
7001 Elemental function
7002
7003 @item @emph{Syntax}:
7004 @code{RESULT = IS_IOSTAT_END(I)}
7005
7006 @item @emph{Arguments}:
7007 @multitable @columnfractions .15 .70
7008 @item @var{I} @tab Shall be of the type @code{INTEGER}.
7009 @end multitable
7010
7011 @item @emph{Return value}:
7012 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
7013 @var{I} has the value which indicates an end of file condition for
7014 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
7015
7016 @item @emph{Example}:
7017 @smallexample
7018 PROGRAM iostat
7019   IMPLICIT NONE
7020   INTEGER :: stat, i
7021   OPEN(88, FILE='test.dat')
7022   READ(88, *, IOSTAT=stat) i
7023   IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
7024 END PROGRAM
7025 @end smallexample
7026 @end table
7027
7028
7029
7030 @node IS_IOSTAT_EOR
7031 @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
7032 @fnindex IS_IOSTAT_EOR
7033 @cindex @code{IOSTAT}, end of record
7034
7035 @table @asis
7036 @item @emph{Description}:
7037 @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
7038 status ``end of record''. The function is equivalent to comparing the
7039 variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
7040 @code{ISO_FORTRAN_ENV}.
7041
7042 @item @emph{Standard}:
7043 Fortran 2003 and later
7044
7045 @item @emph{Class}:
7046 Elemental function
7047
7048 @item @emph{Syntax}:
7049 @code{RESULT = IS_IOSTAT_EOR(I)}
7050
7051 @item @emph{Arguments}:
7052 @multitable @columnfractions .15 .70
7053 @item @var{I} @tab Shall be of the type @code{INTEGER}.
7054 @end multitable
7055
7056 @item @emph{Return value}:
7057 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
7058 @var{I} has the value which indicates an end of file condition for
7059 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
7060
7061 @item @emph{Example}:
7062 @smallexample
7063 PROGRAM iostat
7064   IMPLICIT NONE
7065   INTEGER :: stat, i(50)
7066   OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
7067   READ(88, IOSTAT=stat) i
7068   IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
7069 END PROGRAM
7070 @end smallexample
7071 @end table
7072
7073
7074
7075 @node ISATTY
7076 @section @code{ISATTY} --- Whether a unit is a terminal device.
7077 @fnindex ISATTY
7078 @cindex system, terminal
7079
7080 @table @asis
7081 @item @emph{Description}:
7082 Determine whether a unit is connected to a terminal device.
7083
7084 @item @emph{Standard}:
7085 GNU extension
7086
7087 @item @emph{Class}:
7088 Function
7089
7090 @item @emph{Syntax}:
7091 @code{RESULT = ISATTY(UNIT)}
7092
7093 @item @emph{Arguments}:
7094 @multitable @columnfractions .15 .70
7095 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
7096 @end multitable
7097
7098 @item @emph{Return value}:
7099 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal 
7100 device, @code{.FALSE.} otherwise.
7101
7102 @item @emph{Example}:
7103 @smallexample
7104 PROGRAM test_isatty
7105   INTEGER(kind=1) :: unit
7106   DO unit = 1, 10
7107     write(*,*) isatty(unit=unit)
7108   END DO
7109 END PROGRAM
7110 @end smallexample
7111 @item @emph{See also}:
7112 @ref{TTYNAM}
7113 @end table
7114
7115
7116
7117 @node ISHFT
7118 @section @code{ISHFT} --- Shift bits
7119 @fnindex ISHFT
7120 @cindex bits, shift
7121
7122 @table @asis
7123 @item @emph{Description}:
7124 @code{ISHFT} returns a value corresponding to @var{I} with all of the
7125 bits shifted @var{SHIFT} places.  A value of @var{SHIFT} greater than
7126 zero corresponds to a left shift, a value of zero corresponds to no
7127 shift, and a value less than zero corresponds to a right shift.  If the
7128 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
7129 value is undefined.  Bits shifted out from the left end or right end are
7130 lost; zeros are shifted in from the opposite end.
7131
7132 @item @emph{Standard}:
7133 Fortran 95 and later
7134
7135 @item @emph{Class}:
7136 Elemental function
7137
7138 @item @emph{Syntax}:
7139 @code{RESULT = ISHFT(I, SHIFT)}
7140
7141 @item @emph{Arguments}:
7142 @multitable @columnfractions .15 .70
7143 @item @var{I} @tab The type shall be @code{INTEGER}.
7144 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
7145 @end multitable
7146
7147 @item @emph{Return value}:
7148 The return value is of type @code{INTEGER} and of the same kind as
7149 @var{I}.
7150
7151 @item @emph{See also}:
7152 @ref{ISHFTC}
7153 @end table
7154
7155
7156
7157 @node ISHFTC
7158 @section @code{ISHFTC} --- Shift bits circularly
7159 @fnindex ISHFTC
7160 @cindex bits, shift circular
7161
7162 @table @asis
7163 @item @emph{Description}:
7164 @code{ISHFTC} returns a value corresponding to @var{I} with the
7165 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
7166 is, bits shifted out one end are shifted into the opposite end.  A value
7167 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
7168 zero corresponds to no shift, and a value less than zero corresponds to
7169 a right shift.  The absolute value of @var{SHIFT} must be less than
7170 @var{SIZE}.  If the @var{SIZE} argument is omitted, it is taken to be
7171 equivalent to @code{BIT_SIZE(I)}.
7172
7173 @item @emph{Standard}:
7174 Fortran 95 and later
7175
7176 @item @emph{Class}:
7177 Elemental function
7178
7179 @item @emph{Syntax}:
7180 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
7181
7182 @item @emph{Arguments}:
7183 @multitable @columnfractions .15 .70
7184 @item @var{I} @tab The type shall be @code{INTEGER}.
7185 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
7186 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
7187 the value must be greater than zero and less than or equal to
7188 @code{BIT_SIZE(I)}.
7189 @end multitable
7190
7191 @item @emph{Return value}:
7192 The return value is of type @code{INTEGER} and of the same kind as
7193 @var{I}.
7194
7195 @item @emph{See also}:
7196 @ref{ISHFT}
7197 @end table
7198
7199
7200
7201 @node ISNAN
7202 @section @code{ISNAN} --- Test for a NaN
7203 @fnindex ISNAN
7204 @cindex IEEE, ISNAN
7205
7206 @table @asis
7207 @item @emph{Description}:
7208 @code{ISNAN} tests whether a floating-point value is an IEEE
7209 Not-a-Number (NaN).
7210 @item @emph{Standard}:
7211 GNU extension
7212
7213 @item @emph{Class}:
7214 Elemental function
7215
7216 @item @emph{Syntax}:
7217 @code{ISNAN(X)}
7218
7219 @item @emph{Arguments}:
7220 @multitable @columnfractions .15 .70
7221 @item @var{X} @tab Variable of the type @code{REAL}.
7222
7223 @end multitable
7224
7225 @item @emph{Return value}:
7226 Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
7227 if @var{X} is a NaN and @code{FALSE} otherwise.
7228
7229 @item @emph{Example}:
7230 @smallexample
7231 program test_nan
7232   implicit none
7233   real :: x
7234   x = -1.0
7235   x = sqrt(x)
7236   if (isnan(x)) stop '"x" is a NaN'
7237 end program test_nan
7238 @end smallexample
7239 @end table
7240
7241
7242
7243 @node ITIME
7244 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds) 
7245 @fnindex ITIME
7246 @cindex time, current
7247 @cindex current time
7248
7249 @table @asis
7250 @item @emph{Description}:
7251 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the  
7252 current local time. The hour (in the range 1-24), minute (in the range 1-60), 
7253 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES}, 
7254 respectively.
7255
7256 @item @emph{Standard}:
7257 GNU extension
7258
7259 @item @emph{Class}:
7260 Subroutine
7261
7262 @item @emph{Syntax}:
7263 @code{CALL ITIME(VALUES)}
7264
7265 @item @emph{Arguments}:
7266 @multitable @columnfractions .15 .70
7267 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
7268 and the kind shall be the default integer kind.
7269 @end multitable
7270
7271 @item @emph{Return value}:
7272 Does not return anything.
7273
7274
7275 @item @emph{Example}:
7276 @smallexample
7277 program test_itime
7278   integer, dimension(3) :: tarray
7279   call itime(tarray)
7280   print *, tarray(1)
7281   print *, tarray(2)
7282   print *, tarray(3)
7283 end program test_itime
7284 @end smallexample
7285 @end table
7286
7287
7288
7289 @node KILL
7290 @section @code{KILL} --- Send a signal to a process
7291 @fnindex KILL
7292
7293 @table @asis
7294 @item @emph{Description}:
7295 @item @emph{Standard}:
7296 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
7297 See @code{kill(2)}.
7298
7299 This intrinsic is provided in both subroutine and function forms; however,
7300 only one form can be used in any given program unit.
7301
7302 @item @emph{Class}:
7303 Subroutine, function
7304
7305 @item @emph{Syntax}:
7306 @multitable @columnfractions .80
7307 @item @code{CALL KILL(C, VALUE [, STATUS])}
7308 @item @code{STATUS = KILL(C, VALUE)}
7309 @end multitable
7310
7311 @item @emph{Arguments}:
7312 @multitable @columnfractions .15 .70
7313 @item @var{C} @tab Shall be a scalar @code{INTEGER}, with
7314 @code{INTENT(IN)}
7315 @item @var{VALUE} @tab Shall be a scalar @code{INTEGER}, with
7316 @code{INTENT(IN)}
7317 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
7318 @code{INTEGER(8)}. Returns 0 on success, or a system-specific error code
7319 otherwise.
7320 @end multitable
7321
7322 @item @emph{See also}:
7323 @ref{ABORT}, @ref{EXIT}
7324 @end table
7325
7326
7327
7328 @node KIND
7329 @section @code{KIND} --- Kind of an entity
7330 @fnindex KIND
7331 @cindex kind
7332
7333 @table @asis
7334 @item @emph{Description}:
7335 @code{KIND(X)} returns the kind value of the entity @var{X}.
7336
7337 @item @emph{Standard}:
7338 Fortran 95 and later
7339
7340 @item @emph{Class}:
7341 Inquiry function
7342
7343 @item @emph{Syntax}:
7344 @code{K = KIND(X)}
7345
7346 @item @emph{Arguments}:
7347 @multitable @columnfractions .15 .70
7348 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
7349 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
7350 @end multitable
7351
7352 @item @emph{Return value}:
7353 The return value is a scalar of type @code{INTEGER} and of the default
7354 integer kind.
7355
7356 @item @emph{Example}:
7357 @smallexample
7358 program test_kind
7359   integer,parameter :: kc = kind(' ')
7360   integer,parameter :: kl = kind(.true.)
7361
7362   print *, "The default character kind is ", kc
7363   print *, "The default logical kind is ", kl
7364 end program test_kind
7365 @end smallexample
7366
7367 @end table
7368
7369
7370
7371 @node LBOUND
7372 @section @code{LBOUND} --- Lower dimension bounds of an array
7373 @fnindex LBOUND
7374 @cindex array, lower bound
7375
7376 @table @asis
7377 @item @emph{Description}:
7378 Returns the lower bounds of an array, or a single lower bound
7379 along the @var{DIM} dimension.
7380 @item @emph{Standard}:
7381 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7382
7383 @item @emph{Class}:
7384 Inquiry function
7385
7386 @item @emph{Syntax}:
7387 @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
7388
7389 @item @emph{Arguments}:
7390 @multitable @columnfractions .15 .70
7391 @item @var{ARRAY} @tab Shall be an array, of any type.
7392 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
7393 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7394 expression indicating the kind parameter of the result.
7395 @end multitable
7396
7397 @item @emph{Return value}:
7398 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7399 @var{KIND} is absent, the return value is of default integer kind.
7400 If @var{DIM} is absent, the result is an array of the lower bounds of
7401 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
7402 corresponding to the lower bound of the array along that dimension.  If
7403 @var{ARRAY} is an expression rather than a whole array or array
7404 structure component, or if it has a zero extent along the relevant
7405 dimension, the lower bound is taken to be 1.
7406
7407 @item @emph{See also}:
7408 @ref{UBOUND}, @ref{LCOBOUND}
7409 @end table
7410
7411
7412
7413 @node LCOBOUND
7414 @section @code{LCOBOUND} --- Lower codimension bounds of an array
7415 @fnindex LCOBOUND
7416 @cindex coarray, lower bound
7417
7418 @table @asis
7419 @item @emph{Description}:
7420 Returns the lower bounds of a coarray, or a single lower cobound
7421 along the @var{DIM} codimension.
7422 @item @emph{Standard}:
7423 Fortran 2008 and later
7424
7425 @item @emph{Class}:
7426 Inquiry function
7427
7428 @item @emph{Syntax}:
7429 @code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])}
7430
7431 @item @emph{Arguments}:
7432 @multitable @columnfractions .15 .70
7433 @item @var{ARRAY} @tab Shall be an coarray, of any type.
7434 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
7435 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7436 expression indicating the kind parameter of the result.
7437 @end multitable
7438
7439 @item @emph{Return value}:
7440 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7441 @var{KIND} is absent, the return value is of default integer kind.
7442 If @var{DIM} is absent, the result is an array of the lower cobounds of
7443 @var{COARRAY}.  If @var{DIM} is present, the result is a scalar
7444 corresponding to the lower cobound of the array along that codimension.
7445
7446 @item @emph{See also}:
7447 @ref{UCOBOUND}, @ref{LBOUND}
7448 @end table
7449
7450
7451
7452 @node LEADZ
7453 @section @code{LEADZ} --- Number of leading zero bits of an integer
7454 @fnindex LEADZ
7455 @cindex zero bits
7456
7457 @table @asis
7458 @item @emph{Description}:
7459 @code{LEADZ} returns the number of leading zero bits of an integer.
7460
7461 @item @emph{Standard}:
7462 Fortran 2008 and later
7463
7464 @item @emph{Class}:
7465 Elemental function
7466
7467 @item @emph{Syntax}:
7468 @code{RESULT = LEADZ(I)}
7469
7470 @item @emph{Arguments}:
7471 @multitable @columnfractions .15 .70
7472 @item @var{I} @tab Shall be of type @code{INTEGER}.
7473 @end multitable
7474
7475 @item @emph{Return value}:
7476 The type of the return value is the default @code{INTEGER}.
7477 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
7478
7479 @item @emph{Example}:
7480 @smallexample
7481 PROGRAM test_leadz
7482   WRITE (*,*) BIT_SIZE(1)  ! prints 32
7483   WRITE (*,*) LEADZ(1)     ! prints 31
7484 END PROGRAM
7485 @end smallexample
7486
7487 @item @emph{See also}:
7488 @ref{BIT_SIZE}, @ref{TRAILZ}, @ref{POPCNT}, @ref{POPPAR}
7489 @end table
7490
7491
7492
7493 @node LEN
7494 @section @code{LEN} --- Length of a character entity
7495 @fnindex LEN
7496 @cindex string, length
7497
7498 @table @asis
7499 @item @emph{Description}:
7500 Returns the length of a character string.  If @var{STRING} is an array,
7501 the length of an element of @var{STRING} is returned.  Note that
7502 @var{STRING} need not be defined when this intrinsic is invoked, since
7503 only the length, not the content, of @var{STRING} is needed.
7504
7505 @item @emph{Standard}:
7506 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
7507
7508 @item @emph{Class}:
7509 Inquiry function
7510
7511 @item @emph{Syntax}:
7512 @code{L = LEN(STRING [, KIND])}
7513
7514 @item @emph{Arguments}:
7515 @multitable @columnfractions .15 .70
7516 @item @var{STRING} @tab Shall be a scalar or array of type
7517 @code{CHARACTER}, with @code{INTENT(IN)}
7518 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7519 expression indicating the kind parameter of the result.
7520 @end multitable
7521
7522 @item @emph{Return value}:
7523 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7524 @var{KIND} is absent, the return value is of default integer kind.
7525
7526
7527 @item @emph{Specific names}:
7528 @multitable @columnfractions .20 .20 .20 .25
7529 @item Name               @tab Argument          @tab Return type       @tab Standard
7530 @item @code{LEN(STRING)} @tab @code{CHARACTER}  @tab @code{INTEGER}    @tab Fortran 77 and later
7531 @end multitable
7532
7533
7534 @item @emph{See also}:
7535 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
7536 @end table
7537
7538
7539
7540 @node LEN_TRIM
7541 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
7542 @fnindex LEN_TRIM
7543 @cindex string, length, without trailing whitespace
7544
7545 @table @asis
7546 @item @emph{Description}:
7547 Returns the length of a character string, ignoring any trailing blanks.
7548
7549 @item @emph{Standard}:
7550 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7551
7552 @item @emph{Class}:
7553 Elemental function
7554
7555 @item @emph{Syntax}:
7556 @code{RESULT = LEN_TRIM(STRING [, KIND])}
7557
7558 @item @emph{Arguments}:
7559 @multitable @columnfractions .15 .70
7560 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
7561 with @code{INTENT(IN)}
7562 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7563 expression indicating the kind parameter of the result.
7564 @end multitable
7565
7566 @item @emph{Return value}:
7567 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7568 @var{KIND} is absent, the return value is of default integer kind.
7569
7570 @item @emph{See also}:
7571 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
7572 @end table
7573
7574
7575
7576 @node LGE
7577 @section @code{LGE} --- Lexical greater than or equal
7578 @fnindex LGE
7579 @cindex lexical comparison of strings
7580 @cindex string, comparison
7581
7582 @table @asis
7583 @item @emph{Description}:
7584 Determines whether one string is lexically greater than or equal to
7585 another string, where the two strings are interpreted as containing
7586 ASCII character codes.  If the String A and String B are not the same
7587 length, the shorter is compared as if spaces were appended to it to form
7588 a value that has the same length as the longer.
7589
7590 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7591 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7592 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7593 that the latter use the processor's character ordering (which is not
7594 ASCII on some targets), whereas the former always use the ASCII
7595 ordering.
7596
7597 @item @emph{Standard}:
7598 Fortran 77 and later
7599
7600 @item @emph{Class}:
7601 Elemental function
7602
7603 @item @emph{Syntax}:
7604 @code{RESULT = LGE(STRING_A, STRING_B)}
7605
7606 @item @emph{Arguments}:
7607 @multitable @columnfractions .15 .70
7608 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7609 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7610 @end multitable
7611
7612 @item @emph{Return value}:
7613 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
7614 otherwise, based on the ASCII ordering.
7615
7616 @item @emph{Specific names}:
7617 @multitable @columnfractions .20 .20 .20 .25
7618 @item Name                           @tab Argument          @tab Return type       @tab Standard
7619 @item @code{LGE(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
7620 @end multitable
7621
7622 @item @emph{See also}:
7623 @ref{LGT}, @ref{LLE}, @ref{LLT}
7624 @end table
7625
7626
7627
7628 @node LGT
7629 @section @code{LGT} --- Lexical greater than
7630 @fnindex LGT
7631 @cindex lexical comparison of strings
7632 @cindex string, comparison
7633
7634 @table @asis
7635 @item @emph{Description}:
7636 Determines whether one string is lexically greater than another string,
7637 where the two strings are interpreted as containing ASCII character
7638 codes.  If the String A and String B are not the same length, the
7639 shorter is compared as if spaces were appended to it to form a value
7640 that has the same length as the longer.
7641
7642 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7643 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7644 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7645 that the latter use the processor's character ordering (which is not
7646 ASCII on some targets), whereas the former always use the ASCII
7647 ordering.
7648
7649 @item @emph{Standard}:
7650 Fortran 77 and later
7651
7652 @item @emph{Class}:
7653 Elemental function
7654
7655 @item @emph{Syntax}:
7656 @code{RESULT = LGT(STRING_A, STRING_B)}
7657
7658 @item @emph{Arguments}:
7659 @multitable @columnfractions .15 .70
7660 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7661 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7662 @end multitable
7663
7664 @item @emph{Return value}:
7665 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
7666 otherwise, based on the ASCII ordering.
7667
7668 @item @emph{Specific names}:
7669 @multitable @columnfractions .20 .20 .20 .25
7670 @item Name                           @tab Argument          @tab Return type       @tab Standard
7671 @item @code{LGT(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
7672 @end multitable
7673
7674 @item @emph{See also}:
7675 @ref{LGE}, @ref{LLE}, @ref{LLT}
7676 @end table
7677
7678
7679
7680 @node LINK
7681 @section @code{LINK} --- Create a hard link
7682 @fnindex LINK
7683 @cindex file system, create link
7684 @cindex file system, hard link
7685
7686 @table @asis
7687 @item @emph{Description}:
7688 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
7689 character (@code{CHAR(0)}) can be used to mark the end of the names in
7690 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
7691 names are ignored.  If the @var{STATUS} argument is supplied, it
7692 contains 0 on success or a nonzero error code upon return; see
7693 @code{link(2)}.
7694
7695 This intrinsic is provided in both subroutine and function forms;
7696 however, only one form can be used in any given program unit.
7697
7698 @item @emph{Standard}:
7699 GNU extension
7700
7701 @item @emph{Class}:
7702 Subroutine, function
7703
7704 @item @emph{Syntax}:
7705 @multitable @columnfractions .80
7706 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
7707 @item @code{STATUS = LINK(PATH1, PATH2)}
7708 @end multitable
7709
7710 @item @emph{Arguments}:
7711 @multitable @columnfractions .15 .70
7712 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
7713 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
7714 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
7715 @end multitable
7716
7717 @item @emph{See also}:
7718 @ref{SYMLNK}, @ref{UNLINK}
7719 @end table
7720
7721
7722
7723 @node LLE
7724 @section @code{LLE} --- Lexical less than or equal
7725 @fnindex LLE
7726 @cindex lexical comparison of strings
7727 @cindex string, comparison
7728
7729 @table @asis
7730 @item @emph{Description}:
7731 Determines whether one string is lexically less than or equal to another
7732 string, where the two strings are interpreted as containing ASCII
7733 character codes.  If the String A and String B are not the same length,
7734 the shorter is compared as if spaces were appended to it to form a value
7735 that has the same length as the longer.
7736
7737 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7738 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7739 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7740 that the latter use the processor's character ordering (which is not
7741 ASCII on some targets), whereas the former always use the ASCII
7742 ordering.
7743
7744 @item @emph{Standard}:
7745 Fortran 77 and later
7746
7747 @item @emph{Class}:
7748 Elemental function
7749
7750 @item @emph{Syntax}:
7751 @code{RESULT = LLE(STRING_A, STRING_B)}
7752
7753 @item @emph{Arguments}:
7754 @multitable @columnfractions .15 .70
7755 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7756 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7757 @end multitable
7758
7759 @item @emph{Return value}:
7760 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
7761 otherwise, based on the ASCII ordering.
7762
7763 @item @emph{Specific names}:
7764 @multitable @columnfractions .20 .20 .20 .25
7765 @item Name                           @tab Argument          @tab Return type       @tab Standard
7766 @item @code{LLE(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
7767 @end multitable
7768
7769 @item @emph{See also}:
7770 @ref{LGE}, @ref{LGT}, @ref{LLT}
7771 @end table
7772
7773
7774
7775 @node LLT
7776 @section @code{LLT} --- Lexical less than
7777 @fnindex LLT
7778 @cindex lexical comparison of strings
7779 @cindex string, comparison
7780
7781 @table @asis
7782 @item @emph{Description}:
7783 Determines whether one string is lexically less than another string,
7784 where the two strings are interpreted as containing ASCII character
7785 codes.  If the String A and String B are not the same length, the
7786 shorter is compared as if spaces were appended to it to form a value
7787 that has the same length as the longer.
7788
7789 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7790 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7791 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7792 that the latter use the processor's character ordering (which is not
7793 ASCII on some targets), whereas the former always use the ASCII
7794 ordering.
7795
7796 @item @emph{Standard}:
7797 Fortran 77 and later
7798
7799 @item @emph{Class}:
7800 Elemental function
7801
7802 @item @emph{Syntax}:
7803 @code{RESULT = LLT(STRING_A, STRING_B)}
7804
7805 @item @emph{Arguments}:
7806 @multitable @columnfractions .15 .70
7807 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7808 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7809 @end multitable
7810
7811 @item @emph{Return value}:
7812 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
7813 otherwise, based on the ASCII ordering.
7814
7815 @item @emph{Specific names}:
7816 @multitable @columnfractions .20 .20 .20 .25
7817 @item Name                           @tab Argument          @tab Return type       @tab Standard
7818 @item @code{LLT(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
7819 @end multitable
7820
7821 @item @emph{See also}:
7822 @ref{LGE}, @ref{LGT}, @ref{LLE}
7823 @end table
7824
7825
7826
7827 @node LNBLNK
7828 @section @code{LNBLNK} --- Index of the last non-blank character in a string
7829 @fnindex LNBLNK
7830 @cindex string, find non-blank character
7831
7832 @table @asis
7833 @item @emph{Description}:
7834 Returns the length of a character string, ignoring any trailing blanks.
7835 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
7836 included for backwards compatibility.
7837
7838 @item @emph{Standard}:
7839 GNU extension
7840
7841 @item @emph{Class}:
7842 Elemental function
7843
7844 @item @emph{Syntax}:
7845 @code{RESULT = LNBLNK(STRING)}
7846
7847 @item @emph{Arguments}:
7848 @multitable @columnfractions .15 .70
7849 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
7850 with @code{INTENT(IN)}
7851 @end multitable
7852
7853 @item @emph{Return value}:
7854 The return value is of @code{INTEGER(kind=4)} type.
7855
7856 @item @emph{See also}:
7857 @ref{INDEX intrinsic}, @ref{LEN_TRIM}
7858 @end table
7859
7860
7861
7862 @node LOC
7863 @section @code{LOC} --- Returns the address of a variable
7864 @fnindex LOC
7865 @cindex location of a variable in memory
7866
7867 @table @asis
7868 @item @emph{Description}:
7869 @code{LOC(X)} returns the address of @var{X} as an integer.
7870
7871 @item @emph{Standard}:
7872 GNU extension
7873
7874 @item @emph{Class}:
7875 Inquiry function
7876
7877 @item @emph{Syntax}:
7878 @code{RESULT = LOC(X)}
7879
7880 @item @emph{Arguments}:
7881 @multitable @columnfractions .15 .70
7882 @item @var{X} @tab Variable of any type.
7883 @end multitable
7884
7885 @item @emph{Return value}:
7886 The return value is of type @code{INTEGER}, with a @code{KIND}
7887 corresponding to the size (in bytes) of a memory address on the target
7888 machine.
7889
7890 @item @emph{Example}:
7891 @smallexample
7892 program test_loc
7893   integer :: i
7894   real :: r
7895   i = loc(r)
7896   print *, i
7897 end program test_loc
7898 @end smallexample
7899 @end table
7900
7901
7902
7903 @node LOG
7904 @section @code{LOG} --- Natural logarithm function
7905 @fnindex LOG
7906 @fnindex ALOG
7907 @fnindex DLOG
7908 @fnindex CLOG
7909 @fnindex ZLOG
7910 @fnindex CDLOG
7911 @cindex exponential function, inverse
7912 @cindex logarithm function
7913 @cindex natural logarithm function
7914
7915 @table @asis
7916 @item @emph{Description}:
7917 @code{LOG(X)} computes the natural logarithm of @var{X}, i.e. the
7918 logarithm to the base @math{e}.
7919
7920 @item @emph{Standard}:
7921 Fortran 77 and later
7922
7923 @item @emph{Class}:
7924 Elemental function
7925
7926 @item @emph{Syntax}:
7927 @code{RESULT = LOG(X)}
7928
7929 @item @emph{Arguments}:
7930 @multitable @columnfractions .15 .70
7931 @item @var{X} @tab The type shall be @code{REAL} or
7932 @code{COMPLEX}.
7933 @end multitable
7934
7935 @item @emph{Return value}:
7936 The return value is of type @code{REAL} or @code{COMPLEX}.
7937 The kind type parameter is the same as @var{X}.
7938 If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range
7939 @math{-\pi \leq \omega \leq \pi}.
7940
7941 @item @emph{Example}:
7942 @smallexample
7943 program test_log
7944   real(8) :: x = 2.7182818284590451_8
7945   complex :: z = (1.0, 2.0)
7946   x = log(x)    ! will yield (approximately) 1
7947   z = log(z)
7948 end program test_log
7949 @end smallexample
7950
7951 @item @emph{Specific names}:
7952 @multitable @columnfractions .20 .20 .20 .25
7953 @item Name            @tab Argument          @tab Return type       @tab Standard
7954 @item @code{ALOG(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab f95, gnu
7955 @item @code{DLOG(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
7956 @item @code{CLOG(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
7957 @item @code{ZLOG(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
7958 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
7959 @end multitable
7960 @end table
7961
7962
7963
7964 @node LOG10
7965 @section @code{LOG10} --- Base 10 logarithm function
7966 @fnindex LOG10
7967 @fnindex ALOG10
7968 @fnindex DLOG10
7969 @cindex exponential function, inverse
7970 @cindex logarithm function with base 10
7971 @cindex base 10 logarithm function
7972
7973 @table @asis
7974 @item @emph{Description}:
7975 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
7976
7977 @item @emph{Standard}:
7978 Fortran 77 and later
7979
7980 @item @emph{Class}:
7981 Elemental function
7982
7983 @item @emph{Syntax}:
7984 @code{RESULT = LOG10(X)}
7985
7986 @item @emph{Arguments}:
7987 @multitable @columnfractions .15 .70
7988 @item @var{X} @tab The type shall be @code{REAL}.
7989 @end multitable
7990
7991 @item @emph{Return value}:
7992 The return value is of type @code{REAL} or @code{COMPLEX}.
7993 The kind type parameter is the same as @var{X}.
7994
7995 @item @emph{Example}:
7996 @smallexample
7997 program test_log10
7998   real(8) :: x = 10.0_8
7999   x = log10(x)
8000 end program test_log10
8001 @end smallexample
8002
8003 @item @emph{Specific names}:
8004 @multitable @columnfractions .20 .20 .20 .25
8005 @item Name            @tab Argument          @tab Return type       @tab Standard
8006 @item @code{ALOG10(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
8007 @item @code{DLOG10(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
8008 @end multitable
8009 @end table
8010
8011
8012
8013 @node LOG_GAMMA
8014 @section @code{LOG_GAMMA} --- Logarithm of the Gamma function
8015 @fnindex LOG_GAMMA
8016 @fnindex LGAMMA
8017 @fnindex ALGAMA
8018 @fnindex DLGAMA
8019 @cindex Gamma function, logarithm of
8020
8021 @table @asis
8022 @item @emph{Description}:
8023 @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
8024 of the Gamma (@math{\Gamma}) function.
8025
8026 @item @emph{Standard}:
8027 Fortran 2008 and later
8028
8029 @item @emph{Class}:
8030 Elemental function
8031
8032 @item @emph{Syntax}:
8033 @code{X = LOG_GAMMA(X)}
8034
8035 @item @emph{Arguments}:
8036 @multitable @columnfractions .15 .70
8037 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
8038 nor a negative integer.
8039 @end multitable
8040
8041 @item @emph{Return value}:
8042 The return value is of type @code{REAL} of the same kind as @var{X}.
8043
8044 @item @emph{Example}:
8045 @smallexample
8046 program test_log_gamma
8047   real :: x = 1.0
8048   x = lgamma(x) ! returns 0.0
8049 end program test_log_gamma
8050 @end smallexample
8051
8052 @item @emph{Specific names}:
8053 @multitable @columnfractions .20 .20 .20 .25
8054 @item Name             @tab Argument         @tab Return type       @tab Standard
8055 @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
8056 @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
8057 @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
8058 @end multitable
8059
8060 @item @emph{See also}:
8061 Gamma function: @ref{GAMMA}
8062
8063 @end table
8064
8065
8066
8067 @node LOGICAL
8068 @section @code{LOGICAL} --- Convert to logical type
8069 @fnindex LOGICAL
8070 @cindex conversion, to logical
8071
8072 @table @asis
8073 @item @emph{Description}:
8074 Converts one kind of @code{LOGICAL} variable to another.
8075
8076 @item @emph{Standard}:
8077 Fortran 95 and later
8078
8079 @item @emph{Class}:
8080 Elemental function
8081
8082 @item @emph{Syntax}:
8083 @code{RESULT = LOGICAL(L [, KIND])}
8084
8085 @item @emph{Arguments}:
8086 @multitable @columnfractions .15 .70
8087 @item @var{L}    @tab The type shall be @code{LOGICAL}.
8088 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8089 expression indicating the kind parameter of the result.
8090 @end multitable
8091
8092 @item @emph{Return value}:
8093 The return value is a @code{LOGICAL} value equal to @var{L}, with a
8094 kind corresponding to @var{KIND}, or of the default logical kind if
8095 @var{KIND} is not given.
8096
8097 @item @emph{See also}:
8098 @ref{INT}, @ref{REAL}, @ref{CMPLX}
8099 @end table
8100
8101
8102
8103 @node LONG
8104 @section @code{LONG} --- Convert to integer type
8105 @fnindex LONG
8106 @cindex conversion, to integer
8107
8108 @table @asis
8109 @item @emph{Description}:
8110 Convert to a @code{KIND=4} integer type, which is the same size as a C
8111 @code{long} integer.  This is equivalent to the standard @code{INT}
8112 intrinsic with an optional argument of @code{KIND=4}, and is only
8113 included for backwards compatibility.
8114
8115 @item @emph{Standard}:
8116 GNU extension
8117
8118 @item @emph{Class}:
8119 Elemental function
8120
8121 @item @emph{Syntax}:
8122 @code{RESULT = LONG(A)}
8123
8124 @item @emph{Arguments}:
8125 @multitable @columnfractions .15 .70
8126 @item @var{A}    @tab Shall be of type @code{INTEGER},
8127 @code{REAL}, or @code{COMPLEX}.
8128 @end multitable
8129
8130 @item @emph{Return value}:
8131 The return value is a @code{INTEGER(4)} variable.
8132
8133 @item @emph{See also}:
8134 @ref{INT}, @ref{INT2}, @ref{INT8}
8135 @end table
8136
8137
8138
8139 @node LSHIFT
8140 @section @code{LSHIFT} --- Left shift bits
8141 @fnindex LSHIFT
8142 @cindex bits, shift left
8143
8144 @table @asis
8145 @item @emph{Description}:
8146 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
8147 bits shifted left by @var{SHIFT} places.  If the absolute value of
8148 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined. 
8149 Bits shifted out from the left end are lost; zeros are shifted in from
8150 the opposite end.
8151
8152 This function has been superseded by the @code{ISHFT} intrinsic, which
8153 is standard in Fortran 95 and later, and the @code{SHIFTL} intrinsic,
8154 which is standard in Fortran 2008 and later.
8155
8156 @item @emph{Standard}:
8157 GNU extension
8158
8159 @item @emph{Class}:
8160 Elemental function
8161
8162 @item @emph{Syntax}:
8163 @code{RESULT = LSHIFT(I, SHIFT)}
8164
8165 @item @emph{Arguments}:
8166 @multitable @columnfractions .15 .70
8167 @item @var{I} @tab The type shall be @code{INTEGER}.
8168 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8169 @end multitable
8170
8171 @item @emph{Return value}:
8172 The return value is of type @code{INTEGER} and of the same kind as
8173 @var{I}.
8174
8175 @item @emph{See also}:
8176 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}, @ref{SHIFTA}, @ref{SHIFTL},
8177 @ref{SHIFTR}
8178
8179 @end table
8180
8181
8182
8183 @node LSTAT
8184 @section @code{LSTAT} --- Get file status
8185 @fnindex LSTAT
8186 @cindex file system, file status
8187
8188 @table @asis
8189 @item @emph{Description}:
8190 @code{LSTAT} is identical to @ref{STAT}, except that if path is a
8191 symbolic link, then the link itself is statted, not the file that it
8192 refers to.
8193
8194 The elements in @code{VALUES} are the same as described by @ref{STAT}.
8195
8196 This intrinsic is provided in both subroutine and function forms;
8197 however, only one form can be used in any given program unit.
8198
8199 @item @emph{Standard}:
8200 GNU extension
8201
8202 @item @emph{Class}:
8203 Subroutine, function
8204
8205 @item @emph{Syntax}:
8206 @multitable @columnfractions .80
8207 @item @code{CALL LSTAT(NAME, VALUES [, STATUS])}
8208 @item @code{STATUS = LSTAT(NAME, VALUES)}
8209 @end multitable
8210
8211 @item @emph{Arguments}:
8212 @multitable @columnfractions .15 .70
8213 @item @var{NAME}   @tab The type shall be @code{CHARACTER} of the default
8214 kind, a valid path within the file system.
8215 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
8216 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
8217 Returns 0 on success and a system specific error code otherwise.
8218 @end multitable
8219
8220 @item @emph{Example}:
8221 See @ref{STAT} for an example.
8222
8223 @item @emph{See also}:
8224 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
8225 @end table
8226
8227
8228
8229 @node LTIME
8230 @section @code{LTIME} --- Convert time to local time info
8231 @fnindex LTIME
8232 @cindex time, conversion to local time info
8233
8234 @table @asis
8235 @item @emph{Description}:
8236 Given a system time value @var{TIME} (as provided by the @code{TIME8}
8237 intrinsic), fills @var{VALUES} with values extracted from it appropriate
8238 to the local time zone using @code{localtime(3)}.
8239
8240 @item @emph{Standard}:
8241 GNU extension
8242
8243 @item @emph{Class}:
8244 Subroutine
8245
8246 @item @emph{Syntax}:
8247 @code{CALL LTIME(TIME, VALUES)}
8248
8249 @item @emph{Arguments}:
8250 @multitable @columnfractions .15 .70
8251 @item @var{TIME}  @tab An @code{INTEGER} scalar expression
8252 corresponding to a system time, with @code{INTENT(IN)}.
8253 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
8254 with @code{INTENT(OUT)}.
8255 @end multitable
8256
8257 @item @emph{Return value}:
8258 The elements of @var{VALUES} are assigned as follows:
8259 @enumerate
8260 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
8261 seconds
8262 @item Minutes after the hour, range 0--59
8263 @item Hours past midnight, range 0--23
8264 @item Day of month, range 0--31
8265 @item Number of months since January, range 0--12
8266 @item Years since 1900
8267 @item Number of days since Sunday, range 0--6
8268 @item Days since January 1
8269 @item Daylight savings indicator: positive if daylight savings is in
8270 effect, zero if not, and negative if the information is not available.
8271 @end enumerate
8272
8273 @item @emph{See also}:
8274 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
8275
8276 @end table
8277
8278
8279
8280 @node MALLOC
8281 @section @code{MALLOC} --- Allocate dynamic memory
8282 @fnindex MALLOC
8283 @cindex pointer, cray
8284
8285 @table @asis
8286 @item @emph{Description}:
8287 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
8288 returns the address of the allocated memory. The @code{MALLOC} intrinsic
8289 is an extension intended to be used with Cray pointers, and is provided
8290 in GNU Fortran to allow the user to compile legacy code. For new code
8291 using Fortran 95 pointers, the memory allocation intrinsic is
8292 @code{ALLOCATE}.
8293
8294 @item @emph{Standard}:
8295 GNU extension
8296
8297 @item @emph{Class}:
8298 Function
8299
8300 @item @emph{Syntax}:
8301 @code{PTR = MALLOC(SIZE)}
8302
8303 @item @emph{Arguments}:
8304 @multitable @columnfractions .15 .70
8305 @item @var{SIZE} @tab The type shall be @code{INTEGER}.
8306 @end multitable
8307
8308 @item @emph{Return value}:
8309 The return value is of type @code{INTEGER(K)}, with @var{K} such that
8310 variables of type @code{INTEGER(K)} have the same size as
8311 C pointers (@code{sizeof(void *)}).
8312
8313 @item @emph{Example}:
8314 The following example demonstrates the use of @code{MALLOC} and
8315 @code{FREE} with Cray pointers.
8316
8317 @smallexample
8318 program test_malloc
8319   implicit none
8320   integer i
8321   real*8 x(*), z
8322   pointer(ptr_x,x)
8323
8324   ptr_x = malloc(20*8)
8325   do i = 1, 20
8326     x(i) = sqrt(1.0d0 / i)
8327   end do
8328   z = 0
8329   do i = 1, 20
8330     z = z + x(i)
8331     print *, z
8332   end do
8333   call free(ptr_x)
8334 end program test_malloc
8335 @end smallexample
8336
8337 @item @emph{See also}:
8338 @ref{FREE}
8339 @end table
8340
8341
8342
8343 @node MASKL
8344 @section @code{MASKL} --- Left justified mask
8345 @fnindex MASKL
8346 @cindex mask, left justified
8347
8348 @table @asis
8349 @item @emph{Description}:
8350 @code{MASKL(I[, KIND])} has its leftmost @var{I} bits set to 1, and the
8351 remaining bits set to 0.
8352
8353 @item @emph{Standard}:
8354 Fortran 2008 and later
8355
8356 @item @emph{Class}:
8357 Elemental function
8358
8359 @item @emph{Syntax}:
8360 @code{RESULT = MASKL(I[, KIND])}
8361
8362 @item @emph{Arguments}:
8363 @multitable @columnfractions .15 .70
8364 @item @var{I} @tab Shall be of type @code{INTEGER}.
8365 @item @var{KIND} @tab Shall be a scalar constant expression of type
8366 @code{INTEGER}.
8367 @end multitable
8368
8369 @item @emph{Return value}:
8370 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
8371 specifies the kind value of the return type; otherwise, it is of the
8372 default integer kind.
8373
8374 @item @emph{See also}:
8375 @ref{MASKR}
8376 @end table
8377
8378
8379
8380 @node MASKR
8381 @section @code{MASKR} --- Right justified mask
8382 @fnindex MASKR
8383 @cindex mask, right justified
8384
8385 @table @asis
8386 @item @emph{Description}:
8387 @code{MASKL(I[, KIND])} has its rightmost @var{I} bits set to 1, and the
8388 remaining bits set to 0.
8389
8390 @item @emph{Standard}:
8391 Fortran 2008 and later
8392
8393 @item @emph{Class}:
8394 Elemental function
8395
8396 @item @emph{Syntax}:
8397 @code{RESULT = MASKR(I[, KIND])}
8398
8399 @item @emph{Arguments}:
8400 @multitable @columnfractions .15 .70
8401 @item @var{I} @tab Shall be of type @code{INTEGER}.
8402 @item @var{KIND} @tab Shall be a scalar constant expression of type
8403 @code{INTEGER}.
8404 @end multitable
8405
8406 @item @emph{Return value}:
8407 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
8408 specifies the kind value of the return type; otherwise, it is of the
8409 default integer kind.
8410
8411 @item @emph{See also}:
8412 @ref{MASKL}
8413 @end table
8414
8415
8416
8417 @node MATMUL
8418 @section @code{MATMUL} --- matrix multiplication
8419 @fnindex MATMUL
8420 @cindex matrix multiplication
8421 @cindex product, matrix
8422
8423 @table @asis
8424 @item @emph{Description}:
8425 Performs a matrix multiplication on numeric or logical arguments.
8426
8427 @item @emph{Standard}:
8428 Fortran 95 and later
8429
8430 @item @emph{Class}:
8431 Transformational function
8432
8433 @item @emph{Syntax}:
8434 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
8435
8436 @item @emph{Arguments}:
8437 @multitable @columnfractions .15 .70
8438 @item @var{MATRIX_A} @tab An array of @code{INTEGER},
8439 @code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of
8440 one or two.
8441 @item @var{MATRIX_B} @tab An array of @code{INTEGER},
8442 @code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric
8443 type; otherwise, an array of @code{LOGICAL} type. The rank shall be one
8444 or two, and the first (or only) dimension of @var{MATRIX_B} shall be
8445 equal to the last (or only) dimension of @var{MATRIX_A}.
8446 @end multitable
8447
8448 @item @emph{Return value}:
8449 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}.  The type and
8450 kind of the result follow the usual type and kind promotion rules, as
8451 for the @code{*} or @code{.AND.} operators.
8452
8453 @item @emph{See also}:
8454 @end table
8455
8456
8457
8458 @node MAX
8459 @section @code{MAX} --- Maximum value of an argument list
8460 @fnindex MAX
8461 @fnindex MAX0
8462 @fnindex AMAX0
8463 @fnindex MAX1
8464 @fnindex AMAX1
8465 @fnindex DMAX1
8466 @cindex maximum value
8467
8468 @table @asis
8469 @item @emph{Description}:
8470 Returns the argument with the largest (most positive) value.
8471
8472 @item @emph{Standard}:
8473 Fortran 77 and later
8474
8475 @item @emph{Class}:
8476 Elemental function
8477
8478 @item @emph{Syntax}:
8479 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
8480
8481 @item @emph{Arguments}:
8482 @multitable @columnfractions .15 .70
8483 @item @var{A1}          @tab The type shall be @code{INTEGER} or
8484 @code{REAL}.
8485 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
8486 as @var{A1}.  (As a GNU extension, arguments of different kinds are
8487 permitted.)
8488 @end multitable
8489
8490 @item @emph{Return value}:
8491 The return value corresponds to the maximum value among the arguments,
8492 and has the same type and kind as the first argument.
8493
8494 @item @emph{Specific names}:
8495 @multitable @columnfractions .20 .20 .20 .25
8496 @item Name             @tab Argument             @tab Return type         @tab Standard
8497 @item @code{MAX0(A1)}  @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)}   @tab Fortran 77 and later
8498 @item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
8499 @item @code{MAX1(A1)}  @tab @code{REAL A1}       @tab @code{INT(MAX(X))}  @tab Fortran 77 and later
8500 @item @code{AMAX1(A1)} @tab @code{REAL(4) A1}    @tab @code{REAL(4)}      @tab Fortran 77 and later
8501 @item @code{DMAX1(A1)} @tab @code{REAL(8) A1}    @tab @code{REAL(8)}      @tab Fortran 77 and later
8502 @end multitable
8503
8504 @item @emph{See also}:
8505 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
8506
8507 @end table
8508
8509
8510
8511 @node MAXEXPONENT
8512 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
8513 @fnindex MAXEXPONENT
8514 @cindex model representation, maximum exponent
8515
8516 @table @asis
8517 @item @emph{Description}:
8518 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
8519 type of @code{X}.
8520
8521 @item @emph{Standard}:
8522 Fortran 95 and later
8523
8524 @item @emph{Class}:
8525 Inquiry function
8526
8527 @item @emph{Syntax}:
8528 @code{RESULT = MAXEXPONENT(X)}
8529
8530 @item @emph{Arguments}:
8531 @multitable @columnfractions .15 .70
8532 @item @var{X} @tab Shall be of type @code{REAL}.
8533 @end multitable
8534
8535 @item @emph{Return value}:
8536 The return value is of type @code{INTEGER} and of the default integer
8537 kind.
8538
8539 @item @emph{Example}:
8540 @smallexample
8541 program exponents
8542   real(kind=4) :: x
8543   real(kind=8) :: y
8544
8545   print *, minexponent(x), maxexponent(x)
8546   print *, minexponent(y), maxexponent(y)
8547 end program exponents
8548 @end smallexample
8549 @end table
8550
8551
8552
8553 @node MAXLOC
8554 @section @code{MAXLOC} --- Location of the maximum value within an array
8555 @fnindex MAXLOC
8556 @cindex array, location of maximum element
8557
8558 @table @asis
8559 @item @emph{Description}:
8560 Determines the location of the element in the array with the maximum
8561 value, or, if the @var{DIM} argument is supplied, determines the
8562 locations of the maximum element along each row of the array in the
8563 @var{DIM} direction.  If @var{MASK} is present, only the elements for
8564 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
8565 element in the array has the maximum value, the location returned is
8566 that of the first such element in array element order.  If the array has
8567 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
8568 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
8569 and all of the elements of @var{MASK} along a given row are zero, the
8570 result value for that row is zero.
8571
8572 @item @emph{Standard}:
8573 Fortran 95 and later
8574
8575 @item @emph{Class}:
8576 Transformational function
8577
8578 @item @emph{Syntax}:
8579 @multitable @columnfractions .80
8580 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
8581 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
8582 @end multitable
8583
8584 @item @emph{Arguments}:
8585 @multitable @columnfractions .15 .70
8586 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8587 @code{REAL}.
8588 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8589 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8590 inclusive.  It may not be an optional dummy argument.
8591 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8592 and conformable with @var{ARRAY}.
8593 @end multitable
8594
8595 @item @emph{Return value}:
8596 If @var{DIM} is absent, the result is a rank-one array with a length
8597 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
8598 is an array with a rank one less than the rank of @var{ARRAY}, and a
8599 size corresponding to the size of @var{ARRAY} with the @var{DIM}
8600 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
8601 of one, the result is a scalar.  In all cases, the result is of default
8602 @code{INTEGER} type.
8603
8604 @item @emph{See also}:
8605 @ref{MAX}, @ref{MAXVAL}
8606
8607 @end table
8608
8609
8610
8611 @node MAXVAL
8612 @section @code{MAXVAL} --- Maximum value of an array
8613 @fnindex MAXVAL
8614 @cindex array, maximum value
8615 @cindex maximum value
8616
8617 @table @asis
8618 @item @emph{Description}:
8619 Determines the maximum value of the elements in an array value, or, if
8620 the @var{DIM} argument is supplied, determines the maximum value along
8621 each row of the array in the @var{DIM} direction.  If @var{MASK} is
8622 present, only the elements for which @var{MASK} is @code{.TRUE.} are
8623 considered.  If the array has zero size, or all of the elements of
8624 @var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)}
8625 if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character
8626 type.
8627
8628 @item @emph{Standard}:
8629 Fortran 95 and later
8630
8631 @item @emph{Class}:
8632 Transformational function
8633
8634 @item @emph{Syntax}:
8635 @multitable @columnfractions .80
8636 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
8637 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
8638 @end multitable
8639
8640 @item @emph{Arguments}:
8641 @multitable @columnfractions .15 .70
8642 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8643 @code{REAL}.
8644 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8645 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8646 inclusive.  It may not be an optional dummy argument.
8647 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8648 and conformable with @var{ARRAY}.
8649 @end multitable
8650
8651 @item @emph{Return value}:
8652 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
8653 is a scalar.  If @var{DIM} is present, the result is an array with a
8654 rank one less than the rank of @var{ARRAY}, and a size corresponding to
8655 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
8656 cases, the result is of the same type and kind as @var{ARRAY}.
8657
8658 @item @emph{See also}:
8659 @ref{MAX}, @ref{MAXLOC}
8660 @end table
8661
8662
8663
8664 @node MCLOCK
8665 @section @code{MCLOCK} --- Time function
8666 @fnindex MCLOCK
8667 @cindex time, clock ticks
8668 @cindex clock ticks
8669
8670 @table @asis
8671 @item @emph{Description}:
8672 Returns the number of clock ticks since the start of the process, based
8673 on the function @code{clock(3)} in the C standard library.
8674
8675 This intrinsic is not fully portable, such as to systems with 32-bit
8676 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
8677 the values returned by this intrinsic might be, or become, negative, or
8678 numerically less than previous values, during a single run of the
8679 compiled program.
8680
8681 @item @emph{Standard}:
8682 GNU extension
8683
8684 @item @emph{Class}:
8685 Function
8686
8687 @item @emph{Syntax}:
8688 @code{RESULT = MCLOCK()}
8689
8690 @item @emph{Return value}:
8691 The return value is a scalar of type @code{INTEGER(4)}, equal to the
8692 number of clock ticks since the start of the process, or @code{-1} if
8693 the system does not support @code{clock(3)}.
8694
8695 @item @emph{See also}:
8696 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
8697
8698 @end table
8699
8700
8701
8702 @node MCLOCK8
8703 @section @code{MCLOCK8} --- Time function (64-bit)
8704 @fnindex MCLOCK8
8705 @cindex time, clock ticks
8706 @cindex clock ticks
8707
8708 @table @asis
8709 @item @emph{Description}:
8710 Returns the number of clock ticks since the start of the process, based
8711 on the function @code{clock(3)} in the C standard library.
8712
8713 @emph{Warning:} this intrinsic does not increase the range of the timing
8714 values over that returned by @code{clock(3)}. On a system with a 32-bit
8715 @code{clock(3)}, @code{MCLOCK8} will return a 32-bit value, even though
8716 it is converted to a 64-bit @code{INTEGER(8)} value. That means
8717 overflows of the 32-bit value can still occur. Therefore, the values
8718 returned by this intrinsic might be or become negative or numerically
8719 less than previous values during a single run of the compiled program.
8720
8721 @item @emph{Standard}:
8722 GNU extension
8723
8724 @item @emph{Class}:
8725 Function
8726
8727 @item @emph{Syntax}:
8728 @code{RESULT = MCLOCK8()}
8729
8730 @item @emph{Return value}:
8731 The return value is a scalar of type @code{INTEGER(8)}, equal to the
8732 number of clock ticks since the start of the process, or @code{-1} if
8733 the system does not support @code{clock(3)}.
8734
8735 @item @emph{See also}:
8736 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
8737
8738 @end table
8739
8740
8741
8742 @node MERGE
8743 @section @code{MERGE} --- Merge variables
8744 @fnindex MERGE
8745 @cindex array, merge arrays
8746 @cindex array, combine arrays
8747
8748 @table @asis
8749 @item @emph{Description}:
8750 Select values from two arrays according to a logical mask.  The result
8751 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
8752 @var{FSOURCE} if it is @code{.FALSE.}.
8753
8754 @item @emph{Standard}:
8755 Fortran 95 and later
8756
8757 @item @emph{Class}:
8758 Elemental function
8759
8760 @item @emph{Syntax}:
8761 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
8762
8763 @item @emph{Arguments}:
8764 @multitable @columnfractions .15 .70
8765 @item @var{TSOURCE} @tab May be of any type.
8766 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
8767 as @var{TSOURCE}.
8768 @item @var{MASK}    @tab Shall be of type @code{LOGICAL}.
8769 @end multitable
8770
8771 @item @emph{Return value}:
8772 The result is of the same type and type parameters as @var{TSOURCE}.
8773
8774 @end table
8775
8776
8777
8778 @node MERGE_BITS
8779 @section @code{MERGE_BITS} --- Merge of bits under mask
8780 @fnindex MERGE_BITS
8781 @cindex bits, merge
8782
8783 @table @asis
8784 @item @emph{Description}:
8785 @code{MERGE_BITS(I, J, MASK)} merges the bits of @var{I} and @var{J}
8786 as determined by the mask.  The i-th bit of the result is equal to the 
8787 i-th bit of @var{I} if the i-th bit of @var{MASK} is 1; it is equal to
8788 the i-th bit of @var{J} otherwise.
8789
8790 @item @emph{Standard}:
8791 Fortran 2008 and later
8792
8793 @item @emph{Class}:
8794 Elemental function
8795
8796 @item @emph{Syntax}:
8797 @code{RESULT = MERGE_BITS(I, J, MASK)}
8798
8799 @item @emph{Arguments}:
8800 @multitable @columnfractions .15 .70
8801 @item @var{I}    @tab Shall be of type @code{INTEGER}.
8802 @item @var{J}    @tab Shall be of type @code{INTEGER} and of the same
8803 kind as @var{I}.
8804 @item @var{MASK} @tab Shall be of type @code{INTEGER} and of the same
8805 kind as @var{I}.
8806 @end multitable
8807
8808 @item @emph{Return value}:
8809 The result is of the same type and kind as @var{I}.
8810
8811 @end table
8812
8813
8814
8815 @node MIN
8816 @section @code{MIN} --- Minimum value of an argument list
8817 @fnindex MIN
8818 @fnindex MIN0
8819 @fnindex AMIN0
8820 @fnindex MIN1
8821 @fnindex AMIN1
8822 @fnindex DMIN1
8823 @cindex minimum value
8824
8825 @table @asis
8826 @item @emph{Description}:
8827 Returns the argument with the smallest (most negative) value.
8828
8829 @item @emph{Standard}:
8830 Fortran 77 and later
8831
8832 @item @emph{Class}:
8833 Elemental function
8834
8835 @item @emph{Syntax}:
8836 @code{RESULT = MIN(A1, A2 [, A3, ...])}
8837
8838 @item @emph{Arguments}:
8839 @multitable @columnfractions .15 .70
8840 @item @var{A1}          @tab The type shall be @code{INTEGER} or
8841 @code{REAL}.
8842 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
8843 as @var{A1}.  (As a GNU extension, arguments of different kinds are
8844 permitted.)
8845 @end multitable
8846
8847 @item @emph{Return value}:
8848 The return value corresponds to the maximum value among the arguments,
8849 and has the same type and kind as the first argument.
8850
8851 @item @emph{Specific names}:
8852 @multitable @columnfractions .20 .20 .20 .25
8853 @item Name              @tab Argument             @tab Return type        @tab Standard
8854 @item @code{MIN0(A1)}   @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)}  @tab Fortran 77 and later
8855 @item @code{AMIN0(A1)}  @tab @code{INTEGER(4) A1} @tab @code{REAL(4)}     @tab Fortran 77 and later
8856 @item @code{MIN1(A1)}   @tab @code{REAL A1}       @tab @code{INTEGER(4)}  @tab Fortran 77 and later
8857 @item @code{AMIN1(A1)}  @tab @code{REAL(4) A1}    @tab @code{REAL(4)}     @tab Fortran 77 and later
8858 @item @code{DMIN1(A1)}  @tab @code{REAL(8) A1}    @tab @code{REAL(8)}     @tab Fortran 77 and later
8859 @end multitable
8860
8861 @item @emph{See also}:
8862 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
8863 @end table
8864
8865
8866
8867 @node MINEXPONENT
8868 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
8869 @fnindex MINEXPONENT
8870 @cindex model representation, minimum exponent
8871
8872 @table @asis
8873 @item @emph{Description}:
8874 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
8875 type of @code{X}.
8876
8877 @item @emph{Standard}:
8878 Fortran 95 and later
8879
8880 @item @emph{Class}:
8881 Inquiry function
8882
8883 @item @emph{Syntax}:
8884 @code{RESULT = MINEXPONENT(X)}
8885
8886 @item @emph{Arguments}:
8887 @multitable @columnfractions .15 .70
8888 @item @var{X} @tab Shall be of type @code{REAL}.
8889 @end multitable
8890
8891 @item @emph{Return value}:
8892 The return value is of type @code{INTEGER} and of the default integer
8893 kind.
8894
8895 @item @emph{Example}:
8896 See @code{MAXEXPONENT} for an example.
8897 @end table
8898
8899
8900
8901 @node MINLOC
8902 @section @code{MINLOC} --- Location of the minimum value within an array
8903 @fnindex MINLOC
8904 @cindex array, location of minimum element
8905
8906 @table @asis
8907 @item @emph{Description}:
8908 Determines the location of the element in the array with the minimum
8909 value, or, if the @var{DIM} argument is supplied, determines the
8910 locations of the minimum element along each row of the array in the
8911 @var{DIM} direction.  If @var{MASK} is present, only the elements for
8912 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
8913 element in the array has the minimum value, the location returned is
8914 that of the first such element in array element order.  If the array has
8915 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
8916 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
8917 and all of the elements of @var{MASK} along a given row are zero, the
8918 result value for that row is zero.
8919
8920 @item @emph{Standard}:
8921 Fortran 95 and later
8922
8923 @item @emph{Class}:
8924 Transformational function
8925
8926 @item @emph{Syntax}:
8927 @multitable @columnfractions .80
8928 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
8929 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
8930 @end multitable
8931
8932 @item @emph{Arguments}:
8933 @multitable @columnfractions .15 .70
8934 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8935 @code{REAL}.
8936 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8937 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8938 inclusive.  It may not be an optional dummy argument.
8939 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8940 and conformable with @var{ARRAY}.
8941 @end multitable
8942
8943 @item @emph{Return value}:
8944 If @var{DIM} is absent, the result is a rank-one array with a length
8945 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
8946 is an array with a rank one less than the rank of @var{ARRAY}, and a
8947 size corresponding to the size of @var{ARRAY} with the @var{DIM}
8948 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
8949 of one, the result is a scalar.  In all cases, the result is of default
8950 @code{INTEGER} type.
8951
8952 @item @emph{See also}:
8953 @ref{MIN}, @ref{MINVAL}
8954
8955 @end table
8956
8957
8958
8959 @node MINVAL
8960 @section @code{MINVAL} --- Minimum value of an array
8961 @fnindex MINVAL
8962 @cindex array, minimum value
8963 @cindex minimum value
8964
8965 @table @asis
8966 @item @emph{Description}:
8967 Determines the minimum value of the elements in an array value, or, if
8968 the @var{DIM} argument is supplied, determines the minimum value along
8969 each row of the array in the @var{DIM} direction.  If @var{MASK} is
8970 present, only the elements for which @var{MASK} is @code{.TRUE.} are
8971 considered.  If the array has zero size, or all of the elements of
8972 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
8973 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
8974 @var{ARRAY} is of character type.
8975
8976 @item @emph{Standard}:
8977 Fortran 95 and later
8978
8979 @item @emph{Class}:
8980 Transformational function
8981
8982 @item @emph{Syntax}:
8983 @multitable @columnfractions .80
8984 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
8985 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
8986 @end multitable
8987
8988 @item @emph{Arguments}:
8989 @multitable @columnfractions .15 .70
8990 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8991 @code{REAL}.
8992 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
8993 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8994 inclusive.  It may not be an optional dummy argument.
8995 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
8996 and conformable with @var{ARRAY}.
8997 @end multitable
8998
8999 @item @emph{Return value}:
9000 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
9001 is a scalar.  If @var{DIM} is present, the result is an array with a
9002 rank one less than the rank of @var{ARRAY}, and a size corresponding to
9003 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
9004 cases, the result is of the same type and kind as @var{ARRAY}.
9005
9006 @item @emph{See also}:
9007 @ref{MIN}, @ref{MINLOC}
9008
9009 @end table
9010
9011
9012
9013 @node MOD
9014 @section @code{MOD} --- Remainder function
9015 @fnindex MOD
9016 @fnindex AMOD
9017 @fnindex DMOD
9018 @cindex remainder
9019 @cindex division, remainder
9020
9021 @table @asis
9022 @item @emph{Description}:
9023 @code{MOD(A,P)} computes the remainder of the division of A by P@. 
9024
9025 @item @emph{Standard}:
9026 Fortran 77 and later
9027
9028 @item @emph{Class}:
9029 Elemental function
9030
9031 @item @emph{Syntax}:
9032 @code{RESULT = MOD(A, P)}
9033
9034 @item @emph{Arguments}:
9035 @multitable @columnfractions .15 .70
9036 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
9037 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A} 
9038 and not equal to zero.
9039 @end multitable
9040
9041 @item @emph{Return value}:
9042 The return value is the result of @code{A - (INT(A/P) * P)}. The type
9043 and kind of the return value is the same as that of the arguments. The
9044 returned value has the same sign as A and a magnitude less than the
9045 magnitude of P.
9046
9047 @item @emph{Example}:
9048 @smallexample
9049 program test_mod
9050   print *, mod(17,3)
9051   print *, mod(17.5,5.5)
9052   print *, mod(17.5d0,5.5)
9053   print *, mod(17.5,5.5d0)
9054
9055   print *, mod(-17,3)
9056   print *, mod(-17.5,5.5)
9057   print *, mod(-17.5d0,5.5)
9058   print *, mod(-17.5,5.5d0)
9059
9060   print *, mod(17,-3)
9061   print *, mod(17.5,-5.5)
9062   print *, mod(17.5d0,-5.5)
9063   print *, mod(17.5,-5.5d0)
9064 end program test_mod
9065 @end smallexample
9066
9067 @item @emph{Specific names}:
9068 @multitable @columnfractions .20 .20 .20 .25
9069 @item Name             @tab Arguments          @tab Return type    @tab Standard
9070 @item @code{MOD(A,P)}  @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 95 and later
9071 @item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 95 and later
9072 @item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 95 and later
9073 @end multitable
9074
9075 @item @emph{See also}:
9076 @ref{MODULO}
9077
9078 @end table
9079
9080
9081
9082 @node MODULO
9083 @section @code{MODULO} --- Modulo function
9084 @fnindex MODULO
9085 @cindex modulo
9086 @cindex division, modulo
9087
9088 @table @asis
9089 @item @emph{Description}:
9090 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
9091
9092 @item @emph{Standard}:
9093 Fortran 95 and later
9094
9095 @item @emph{Class}:
9096 Elemental function
9097
9098 @item @emph{Syntax}:
9099 @code{RESULT = MODULO(A, P)}
9100
9101 @item @emph{Arguments}:
9102 @multitable @columnfractions .15 .70
9103 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
9104 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}. 
9105 It shall not be zero.
9106 @end multitable
9107
9108 @item @emph{Return value}:
9109 The type and kind of the result are those of the arguments.
9110 @table @asis
9111 @item If @var{A} and @var{P} are of type @code{INTEGER}:
9112 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
9113 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
9114 (exclusive).
9115 @item If @var{A} and @var{P} are of type @code{REAL}:
9116 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
9117 @end table
9118 The returned value has the same sign as P and a magnitude less than
9119 the magnitude of P.
9120
9121 @item @emph{Example}:
9122 @smallexample
9123 program test_modulo
9124   print *, modulo(17,3)
9125   print *, modulo(17.5,5.5)
9126
9127   print *, modulo(-17,3)
9128   print *, modulo(-17.5,5.5)
9129
9130   print *, modulo(17,-3)
9131   print *, modulo(17.5,-5.5)
9132 end program
9133 @end smallexample
9134
9135 @item @emph{See also}:
9136 @ref{MOD}
9137
9138 @end table
9139
9140
9141
9142 @node MOVE_ALLOC
9143 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
9144 @fnindex MOVE_ALLOC
9145 @cindex moving allocation
9146 @cindex allocation, moving
9147
9148 @table @asis
9149 @item @emph{Description}:
9150 @code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
9151 @var{TO}.  @var{FROM} will become deallocated in the process.
9152
9153 @item @emph{Standard}:
9154 Fortran 2003 and later
9155
9156 @item @emph{Class}:
9157 Pure subroutine
9158
9159 @item @emph{Syntax}:
9160 @code{CALL MOVE_ALLOC(FROM, TO)}
9161
9162 @item @emph{Arguments}:
9163 @multitable @columnfractions .15 .70
9164 @item @var{FROM}  @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
9165 of any type and kind.
9166 @item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
9167 of the same type, kind and rank as @var{FROM}.
9168 @end multitable
9169
9170 @item @emph{Return value}:
9171 None
9172
9173 @item @emph{Example}:
9174 @smallexample
9175 program test_move_alloc
9176     integer, allocatable :: a(:), b(:)
9177
9178     allocate(a(3))
9179     a = [ 1, 2, 3 ]
9180     call move_alloc(a, b)
9181     print *, allocated(a), allocated(b)
9182     print *, b
9183 end program test_move_alloc
9184 @end smallexample
9185 @end table
9186
9187
9188
9189 @node MVBITS
9190 @section @code{MVBITS} --- Move bits from one integer to another
9191 @fnindex MVBITS
9192 @cindex bits, move
9193
9194 @table @asis
9195 @item @emph{Description}:
9196 Moves @var{LEN} bits from positions @var{FROMPOS} through
9197 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
9198 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
9199 affected by the movement of bits is unchanged. The values of
9200 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
9201 @code{BIT_SIZE(FROM)}.
9202
9203 @item @emph{Standard}:
9204 Fortran 95 and later
9205
9206 @item @emph{Class}:
9207 Elemental subroutine
9208
9209 @item @emph{Syntax}:
9210 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
9211
9212 @item @emph{Arguments}:
9213 @multitable @columnfractions .15 .70
9214 @item @var{FROM}    @tab The type shall be @code{INTEGER}.
9215 @item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
9216 @item @var{LEN}     @tab The type shall be @code{INTEGER}.
9217 @item @var{TO}      @tab The type shall be @code{INTEGER}, of the
9218 same kind as @var{FROM}.
9219 @item @var{TOPOS}   @tab The type shall be @code{INTEGER}.
9220 @end multitable
9221
9222 @item @emph{See also}:
9223 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
9224 @end table
9225
9226
9227
9228 @node NEAREST
9229 @section @code{NEAREST} --- Nearest representable number
9230 @fnindex NEAREST
9231 @cindex real number, nearest different
9232 @cindex floating point, nearest different
9233
9234 @table @asis
9235 @item @emph{Description}:
9236 @code{NEAREST(X, S)} returns the processor-representable number nearest
9237 to @code{X} in the direction indicated by the sign of @code{S}.
9238
9239 @item @emph{Standard}:
9240 Fortran 95 and later
9241
9242 @item @emph{Class}:
9243 Elemental function
9244
9245 @item @emph{Syntax}:
9246 @code{RESULT = NEAREST(X, S)}
9247
9248 @item @emph{Arguments}:
9249 @multitable @columnfractions .15 .70
9250 @item @var{X} @tab Shall be of type @code{REAL}.
9251 @item @var{S} @tab Shall be of type @code{REAL} and
9252 not equal to zero.
9253 @end multitable
9254
9255 @item @emph{Return value}:
9256 The return value is of the same type as @code{X}. If @code{S} is
9257 positive, @code{NEAREST} returns the processor-representable number
9258 greater than @code{X} and nearest to it. If @code{S} is negative,
9259 @code{NEAREST} returns the processor-representable number smaller than
9260 @code{X} and nearest to it.
9261
9262 @item @emph{Example}:
9263 @smallexample
9264 program test_nearest
9265   real :: x, y
9266   x = nearest(42.0, 1.0)
9267   y = nearest(42.0, -1.0)
9268   write (*,"(3(G20.15))") x, y, x - y
9269 end program test_nearest
9270 @end smallexample
9271 @end table
9272
9273
9274
9275 @node NEW_LINE
9276 @section @code{NEW_LINE} --- New line character
9277 @fnindex NEW_LINE
9278 @cindex newline
9279 @cindex output, newline
9280
9281 @table @asis
9282 @item @emph{Description}:
9283 @code{NEW_LINE(C)} returns the new-line character.
9284
9285 @item @emph{Standard}:
9286 Fortran 2003 and later
9287
9288 @item @emph{Class}:
9289 Inquiry function
9290
9291 @item @emph{Syntax}:
9292 @code{RESULT = NEW_LINE(C)}
9293
9294 @item @emph{Arguments}:
9295 @multitable @columnfractions .15 .70
9296 @item @var{C}    @tab The argument shall be a scalar or array of the
9297 type @code{CHARACTER}.
9298 @end multitable
9299
9300 @item @emph{Return value}:
9301 Returns a @var{CHARACTER} scalar of length one with the new-line character of
9302 the same kind as parameter @var{C}.
9303
9304 @item @emph{Example}:
9305 @smallexample
9306 program newline
9307   implicit none
9308   write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
9309 end program newline
9310 @end smallexample
9311 @end table
9312
9313
9314
9315 @node NINT
9316 @section @code{NINT} --- Nearest whole number
9317 @fnindex NINT
9318 @fnindex IDNINT
9319 @cindex rounding, nearest whole number
9320
9321 @table @asis
9322 @item @emph{Description}:
9323 @code{NINT(A)} rounds its argument to the nearest whole number.
9324
9325 @item @emph{Standard}:
9326 Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
9327
9328 @item @emph{Class}:
9329 Elemental function
9330
9331 @item @emph{Syntax}:
9332 @code{RESULT = NINT(A [, KIND])}
9333
9334 @item @emph{Arguments}:
9335 @multitable @columnfractions .15 .70
9336 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
9337 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9338 expression indicating the kind parameter of the result.
9339 @end multitable
9340
9341 @item @emph{Return value}:
9342 Returns @var{A} with the fractional portion of its magnitude eliminated by
9343 rounding to the nearest whole number and with its sign preserved,
9344 converted to an @code{INTEGER} of the default kind.
9345
9346 @item @emph{Example}:
9347 @smallexample
9348 program test_nint
9349   real(4) x4
9350   real(8) x8
9351   x4 = 1.234E0_4
9352   x8 = 4.321_8
9353   print *, nint(x4), idnint(x8)
9354 end program test_nint
9355 @end smallexample
9356
9357 @item @emph{Specific names}:
9358 @multitable @columnfractions .20 .20 .20 .25
9359 @item Name             @tab Argument           @tab Return Type     @tab Standard
9360 @item @code{NINT(A)}   @tab @code{REAL(4) A}   @tab  @code{INTEGER} @tab Fortran 95 and later
9361 @item @code{IDNINT(A)} @tab @code{REAL(8) A}   @tab  @code{INTEGER} @tab Fortran 95 and later
9362 @end multitable
9363
9364 @item @emph{See also}:
9365 @ref{CEILING}, @ref{FLOOR}
9366
9367 @end table
9368
9369
9370
9371 @node NORM2
9372 @section @code{NORM2} --- Euclidean vector norms
9373 @fnindex NORM2
9374 @cindex Euclidean vector norm
9375 @cindex L2 vector norm
9376 @cindex norm, Euclidean
9377
9378 @table @asis
9379 @item @emph{Description}:
9380 Calculates the Euclidean vector norm (@math{L_2} norm) of
9381 of @var{ARRAY} along dimension @var{DIM}.
9382
9383 @item @emph{Standard}:
9384 Fortran 2008 and later
9385
9386 @item @emph{Class}:
9387 Transformational function
9388
9389 @item @emph{Syntax}:
9390 @multitable @columnfractions .80
9391 @item @code{RESULT = NORM2(ARRAY[, DIM])}
9392 @end multitable
9393
9394 @item @emph{Arguments}:
9395 @multitable @columnfractions .15 .70
9396 @item @var{ARRAY} @tab Shall be an array of type @code{REAL}
9397 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
9398 @code{INTEGER} with a value in the range from 1 to n, where n 
9399 equals the rank of @var{ARRAY}.
9400 @end multitable
9401
9402 @item @emph{Return value}:
9403 The result is of the same type as @var{ARRAY}.
9404
9405 If @var{DIM} is absent, a scalar with the square root of the sum of all
9406 elements in @var{ARRAY} squared  is returned. Otherwise, an array of
9407 rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, and a
9408 shape similar to that of @var{ARRAY} with dimension @var{DIM} dropped
9409 is returned.
9410
9411 @item @emph{Example}:
9412 @smallexample
9413 PROGRAM test_sum
9414   REAL :: x(5) = [ real :: 1, 2, 3, 4, 5 ]
9415   print *, NORM2(x)  ! = sqrt(55.) ~ 7.416
9416 END PROGRAM
9417 @end smallexample
9418 @end table
9419
9420
9421
9422 @node NOT
9423 @section @code{NOT} --- Logical negation
9424 @fnindex NOT
9425 @cindex bits, negate
9426 @cindex bitwise logical not
9427 @cindex logical not, bitwise
9428
9429 @table @asis
9430 @item @emph{Description}:
9431 @code{NOT} returns the bitwise Boolean inverse of @var{I}.
9432
9433 @item @emph{Standard}:
9434 Fortran 95 and later
9435
9436 @item @emph{Class}:
9437 Elemental function
9438
9439 @item @emph{Syntax}:
9440 @code{RESULT = NOT(I)}
9441
9442 @item @emph{Arguments}:
9443 @multitable @columnfractions .15 .70
9444 @item @var{I} @tab The type shall be @code{INTEGER}.
9445 @end multitable
9446
9447 @item @emph{Return value}:
9448 The return type is @code{INTEGER}, of the same kind as the
9449 argument.
9450
9451 @item @emph{See also}:
9452 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
9453
9454 @end table
9455
9456
9457
9458 @node NULL
9459 @section @code{NULL} --- Function that returns an disassociated pointer
9460 @fnindex NULL
9461 @cindex pointer, status
9462 @cindex pointer, disassociated
9463
9464 @table @asis
9465 @item @emph{Description}:
9466 Returns a disassociated pointer.
9467
9468 If @var{MOLD} is present, a disassociated pointer of the same type is
9469 returned, otherwise the type is determined by context.
9470
9471 In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
9472 includes cases where it is required.
9473
9474 @item @emph{Standard}:
9475 Fortran 95 and later
9476
9477 @item @emph{Class}:
9478 Transformational function
9479
9480 @item @emph{Syntax}:
9481 @code{PTR => NULL([MOLD])}
9482
9483 @item @emph{Arguments}:
9484 @multitable @columnfractions .15 .70
9485 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
9486 status and of any type.
9487 @end multitable
9488
9489 @item @emph{Return value}:
9490 A disassociated pointer.
9491
9492 @item @emph{Example}:
9493 @smallexample
9494 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
9495 @end smallexample
9496
9497 @item @emph{See also}:
9498 @ref{ASSOCIATED}
9499 @end table
9500
9501
9502
9503 @node NUM_IMAGES
9504 @section @code{NUM_IMAGES} --- Function that returns the number of images
9505 @fnindex NUM_IMAGES
9506 @cindex coarray, @code{NUM_IMAGES}
9507 @cindex images, number of
9508
9509 @table @asis
9510 @item @emph{Description}:
9511 Returns the number of images.
9512
9513 @item @emph{Standard}:
9514 Fortran 2008 and later
9515
9516 @item @emph{Class}:
9517 Transformational function
9518
9519 @item @emph{Syntax}:
9520 @code{RESULT = NUM_IMAGES()}
9521
9522 @item @emph{Arguments}: None.
9523
9524 @item @emph{Return value}:
9525 Scalar default-kind integer.
9526
9527 @item @emph{Example}:
9528 @smallexample
9529 INTEGER :: value[*]
9530 INTEGER :: i
9531 value = THIS_IMAGE()
9532 SYNC ALL
9533 IF (THIS_IMAGE() == 1) THEN
9534   DO i = 1, NUM_IMAGES()
9535     WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
9536   END DO
9537 END IF
9538 @end smallexample
9539
9540 @item @emph{See also}:
9541 @ref{THIS_IMAGE}, @ref{IMAGE_INDEX}
9542 @end table
9543
9544
9545
9546 @node OR
9547 @section @code{OR} --- Bitwise logical OR
9548 @fnindex OR
9549 @cindex bitwise logical or
9550 @cindex logical or, bitwise
9551
9552 @table @asis
9553 @item @emph{Description}:
9554 Bitwise logical @code{OR}.
9555
9556 This intrinsic routine is provided for backwards compatibility with 
9557 GNU Fortran 77.  For integer arguments, programmers should consider
9558 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
9559
9560 @item @emph{Standard}:
9561 GNU extension
9562
9563 @item @emph{Class}:
9564 Function
9565
9566 @item @emph{Syntax}:
9567 @code{RESULT = OR(I, J)}
9568
9569 @item @emph{Arguments}:
9570 @multitable @columnfractions .15 .70
9571 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
9572 type or a scalar @code{LOGICAL} type.
9573 @item @var{J} @tab The type shall be the same as the type of @var{J}.
9574 @end multitable
9575
9576 @item @emph{Return value}:
9577 The return type is either a scalar @code{INTEGER} or a scalar
9578 @code{LOGICAL}.  If the kind type parameters differ, then the
9579 smaller kind type is implicitly converted to larger kind, and the 
9580 return has the larger kind.
9581
9582 @item @emph{Example}:
9583 @smallexample
9584 PROGRAM test_or
9585   LOGICAL :: T = .TRUE., F = .FALSE.
9586   INTEGER :: a, b
9587   DATA a / Z'F' /, b / Z'3' /
9588
9589   WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
9590   WRITE (*,*) OR(a, b)
9591 END PROGRAM
9592 @end smallexample
9593
9594 @item @emph{See also}:
9595 Fortran 95 elemental function: @ref{IOR}
9596 @end table
9597
9598
9599
9600 @node PACK
9601 @section @code{PACK} --- Pack an array into an array of rank one
9602 @fnindex PACK
9603 @cindex array, packing
9604 @cindex array, reduce dimension
9605 @cindex array, gather elements
9606
9607 @table @asis
9608 @item @emph{Description}:
9609 Stores the elements of @var{ARRAY} in an array of rank one.
9610
9611 The beginning of the resulting array is made up of elements whose @var{MASK} 
9612 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
9613 @var{VECTOR}.
9614
9615 @item @emph{Standard}:
9616 Fortran 95 and later
9617
9618 @item @emph{Class}:
9619 Transformational function
9620
9621 @item @emph{Syntax}:
9622 @code{RESULT = PACK(ARRAY, MASK[,VECTOR]}
9623
9624 @item @emph{Arguments}:
9625 @multitable @columnfractions .15 .70
9626 @item @var{ARRAY}  @tab Shall be an array of any type.
9627 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL} and 
9628 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL} 
9629 scalar.
9630 @item @var{VECTOR} @tab (Optional) shall be an array of the same type 
9631 as @var{ARRAY} and of rank one. If present, the number of elements in 
9632 @var{VECTOR} shall be equal to or greater than the number of true elements 
9633 in @var{MASK}. If @var{MASK} is scalar, the number of elements in 
9634 @var{VECTOR} shall be equal to or greater than the number of elements in
9635 @var{ARRAY}.
9636 @end multitable
9637
9638 @item @emph{Return value}:
9639 The result is an array of rank one and the same type as that of @var{ARRAY}.
9640 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
9641 number of @code{TRUE} values in @var{MASK} otherwise.
9642
9643 @item @emph{Example}:
9644 Gathering nonzero elements from an array:
9645 @smallexample
9646 PROGRAM test_pack_1
9647   INTEGER :: m(6)
9648   m = (/ 1, 0, 0, 0, 5, 0 /)
9649   WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0)  ! "1 5"
9650 END PROGRAM
9651 @end smallexample
9652
9653 Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
9654 @smallexample
9655 PROGRAM test_pack_2
9656   INTEGER :: m(4)
9657   m = (/ 1, 0, 0, 2 /)
9658   WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /))  ! "1 2 3 4"
9659 END PROGRAM
9660 @end smallexample
9661
9662 @item @emph{See also}:
9663 @ref{UNPACK}
9664 @end table
9665
9666
9667
9668 @node PARITY
9669 @section @code{PARITY} --- Reduction with exclusive OR
9670 @fnindex PARITY
9671 @cindex Parity
9672 @cindex Reduction, XOR
9673 @cindex XOR reduction
9674
9675 @table @asis
9676 @item @emph{Description}:
9677 Calculates the parity, i.e. the reduction using @code{.XOR.},
9678 of @var{MASK} along dimension @var{DIM}.
9679
9680 @item @emph{Standard}:
9681 Fortran 2008 and later
9682
9683 @item @emph{Class}:
9684 Transformational function
9685
9686 @item @emph{Syntax}:
9687 @multitable @columnfractions .80
9688 @item @code{RESULT = PARITY(MASK[, DIM])}
9689 @end multitable
9690
9691 @item @emph{Arguments}:
9692 @multitable @columnfractions .15 .70
9693 @item @var{LOGICAL} @tab Shall be an array of type @code{LOGICAL}
9694 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
9695 @code{INTEGER} with a value in the range from 1 to n, where n 
9696 equals the rank of @var{MASK}.
9697 @end multitable
9698
9699 @item @emph{Return value}:
9700 The result is of the same type as @var{MASK}.
9701
9702 If @var{DIM} is absent, a scalar with the parity of all elements in
9703 @var{MASK} is returned, i.e. true if an odd number of elements is
9704 @code{.true.} and false otherwise.  If @var{DIM} is present, an array
9705 of rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY},
9706 and a shape similar to that of @var{MASK} with dimension @var{DIM}
9707 dropped is returned.
9708
9709 @item @emph{Example}:
9710 @smallexample
9711 PROGRAM test_sum
9712   LOGICAL :: x(2) = [ .true., .false. ]
9713   print *, PARITY(x) ! prints "T" (true).
9714 END PROGRAM
9715 @end smallexample
9716 @end table
9717
9718
9719
9720 @node PERROR
9721 @section @code{PERROR} --- Print system error message
9722 @fnindex PERROR
9723 @cindex system, error handling
9724
9725 @table @asis
9726 @item @emph{Description}:
9727 Prints (on the C @code{stderr} stream) a newline-terminated error
9728 message corresponding to the last system error. This is prefixed by
9729 @var{STRING}, a colon and a space. See @code{perror(3)}.
9730
9731 @item @emph{Standard}:
9732 GNU extension
9733
9734 @item @emph{Class}:
9735 Subroutine
9736
9737 @item @emph{Syntax}:
9738 @code{CALL PERROR(STRING)}
9739
9740 @item @emph{Arguments}:
9741 @multitable @columnfractions .15 .70
9742 @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
9743 default kind.
9744 @end multitable
9745
9746 @item @emph{See also}:
9747 @ref{IERRNO}
9748 @end table
9749
9750
9751
9752 @node POPCNT
9753 @section @code{POPCNT} --- Number of bits set
9754 @fnindex POPCNT
9755 @cindex binary representation
9756 @cindex bits set
9757
9758 @table @asis
9759 @item @emph{Description}:
9760 @code{POPCNT(I)} returns the number of bits set ('1' bits) in the binary
9761 representation of @code{I}.
9762
9763 @item @emph{Standard}:
9764 Fortran 2008 and later
9765
9766 @item @emph{Class}:
9767 Elemental function
9768
9769 @item @emph{Syntax}:
9770 @code{RESULT = POPCNT(I)}
9771
9772 @item @emph{Arguments}:
9773 @multitable @columnfractions .15 .70
9774 @item @var{I} @tab Shall be of type @code{INTEGER}.
9775 @end multitable
9776
9777 @item @emph{Return value}:
9778 The return value is of type @code{INTEGER} and of the default integer
9779 kind.
9780
9781 @item @emph{See also}:
9782 @ref{POPPAR}, @ref{LEADZ}, @ref{TRAILZ}
9783
9784 @item @emph{Example}:
9785 @smallexample
9786 program test_population
9787   print *, popcnt(127),       poppar(127)
9788   print *, popcnt(huge(0_4)), poppar(huge(0_4))
9789   print *, popcnt(huge(0_8)), poppar(huge(0_8))
9790 end program test_population
9791 @end smallexample
9792 @end table
9793
9794
9795 @node POPPAR
9796 @section @code{POPPAR} --- Parity of the number of bits set
9797 @fnindex POPPAR
9798 @cindex binary representation
9799 @cindex parity
9800
9801 @table @asis
9802 @item @emph{Description}:
9803 @code{POPPAR(I)} returns parity of the integer @code{I}, i.e. the parity
9804 of the number of bits set ('1' bits) in the binary representation of
9805 @code{I}. It is equal to 0 if @code{I} has an even number of bits set,
9806 and 1 for an odd number of '1' bits.
9807
9808 @item @emph{Standard}:
9809 Fortran 2008 and later
9810
9811 @item @emph{Class}:
9812 Elemental function
9813
9814 @item @emph{Syntax}:
9815 @code{RESULT = POPPAR(I)}
9816
9817 @item @emph{Arguments}:
9818 @multitable @columnfractions .15 .70
9819 @item @var{I} @tab Shall be of type @code{INTEGER}.
9820 @end multitable
9821
9822 @item @emph{Return value}:
9823 The return value is of type @code{INTEGER} and of the default integer
9824 kind.
9825
9826 @item @emph{See also}:
9827 @ref{POPCNT}, @ref{LEADZ}, @ref{TRAILZ}
9828
9829 @item @emph{Example}:
9830 @smallexample
9831 program test_population
9832   print *, popcnt(127),       poppar(127)
9833   print *, popcnt(huge(0_4)), poppar(huge(0_4))
9834   print *, popcnt(huge(0_8)), poppar(huge(0_8))
9835 end program test_population
9836 @end smallexample
9837 @end table
9838
9839
9840
9841 @node PRECISION
9842 @section @code{PRECISION} --- Decimal precision of a real kind
9843 @fnindex PRECISION
9844 @cindex model representation, precision
9845
9846 @table @asis
9847 @item @emph{Description}:
9848 @code{PRECISION(X)} returns the decimal precision in the model of the
9849 type of @code{X}.
9850
9851 @item @emph{Standard}:
9852 Fortran 95 and later
9853
9854 @item @emph{Class}:
9855 Inquiry function
9856
9857 @item @emph{Syntax}:
9858 @code{RESULT = PRECISION(X)}
9859
9860 @item @emph{Arguments}:
9861 @multitable @columnfractions .15 .70
9862 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
9863 @end multitable
9864
9865 @item @emph{Return value}:
9866 The return value is of type @code{INTEGER} and of the default integer
9867 kind.
9868
9869 @item @emph{See also}:
9870 @ref{SELECTED_REAL_KIND}, @ref{RANGE}
9871
9872 @item @emph{Example}:
9873 @smallexample
9874 program prec_and_range
9875   real(kind=4) :: x(2)
9876   complex(kind=8) :: y
9877
9878   print *, precision(x), range(x)
9879   print *, precision(y), range(y)
9880 end program prec_and_range
9881 @end smallexample
9882 @end table
9883
9884
9885
9886 @node PRESENT
9887 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
9888 @fnindex PRESENT
9889
9890 @table @asis
9891 @item @emph{Description}:
9892 Determines whether an optional dummy argument is present.
9893
9894 @item @emph{Standard}:
9895 Fortran 95 and later
9896
9897 @item @emph{Class}:
9898 Inquiry function
9899
9900 @item @emph{Syntax}:
9901 @code{RESULT = PRESENT(A)}
9902
9903 @item @emph{Arguments}:
9904 @multitable @columnfractions .15 .70
9905 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
9906 value, or a dummy procedure. It shall be the name of an optional dummy argument
9907 accessible within the current subroutine or function.
9908 @end multitable
9909
9910 @item @emph{Return value}:
9911 Returns either @code{TRUE} if the optional argument @var{A} is present, or
9912 @code{FALSE} otherwise.
9913
9914 @item @emph{Example}:
9915 @smallexample
9916 PROGRAM test_present
9917   WRITE(*,*) f(), f(42)      ! "F T"
9918 CONTAINS
9919   LOGICAL FUNCTION f(x)
9920     INTEGER, INTENT(IN), OPTIONAL :: x
9921     f = PRESENT(x)
9922   END FUNCTION
9923 END PROGRAM
9924 @end smallexample
9925 @end table
9926
9927
9928
9929 @node PRODUCT
9930 @section @code{PRODUCT} --- Product of array elements
9931 @fnindex PRODUCT
9932 @cindex array, product
9933 @cindex array, multiply elements
9934 @cindex array, conditionally multiply elements
9935 @cindex multiply array elements
9936
9937 @table @asis
9938 @item @emph{Description}:
9939 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
9940 the corresponding element in @var{MASK} is @code{TRUE}.
9941
9942 @item @emph{Standard}:
9943 Fortran 95 and later
9944
9945 @item @emph{Class}:
9946 Transformational function
9947
9948 @item @emph{Syntax}:
9949 @multitable @columnfractions .80
9950 @item @code{RESULT = PRODUCT(ARRAY[, MASK])}
9951 @item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
9952 @end multitable
9953
9954 @item @emph{Arguments}:
9955 @multitable @columnfractions .15 .70
9956 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
9957 @code{REAL} or @code{COMPLEX}.
9958 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
9959 @code{INTEGER} with a value in the range from 1 to n, where n 
9960 equals the rank of @var{ARRAY}.
9961 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
9962 and either be a scalar or an array of the same shape as @var{ARRAY}.
9963 @end multitable
9964
9965 @item @emph{Return value}:
9966 The result is of the same type as @var{ARRAY}.
9967
9968 If @var{DIM} is absent, a scalar with the product of all elements in 
9969 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals 
9970 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with 
9971 dimension @var{DIM} dropped is returned.
9972
9973
9974 @item @emph{Example}:
9975 @smallexample
9976 PROGRAM test_product
9977   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
9978   print *, PRODUCT(x)                    ! all elements, product = 120
9979   print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
9980 END PROGRAM
9981 @end smallexample
9982
9983 @item @emph{See also}:
9984 @ref{SUM}
9985 @end table
9986
9987
9988
9989 @node RADIX
9990 @section @code{RADIX} --- Base of a model number
9991 @fnindex RADIX
9992 @cindex model representation, base
9993 @cindex model representation, radix
9994
9995 @table @asis
9996 @item @emph{Description}:
9997 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
9998
9999 @item @emph{Standard}:
10000 Fortran 95 and later
10001
10002 @item @emph{Class}:
10003 Inquiry function
10004
10005 @item @emph{Syntax}:
10006 @code{RESULT = RADIX(X)}
10007
10008 @item @emph{Arguments}:
10009 @multitable @columnfractions .15 .70
10010 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
10011 @end multitable
10012
10013 @item @emph{Return value}:
10014 The return value is a scalar of type @code{INTEGER} and of the default
10015 integer kind.
10016
10017 @item @emph{See also}:
10018 @ref{SELECTED_REAL_KIND}
10019
10020 @item @emph{Example}:
10021 @smallexample
10022 program test_radix
10023   print *, "The radix for the default integer kind is", radix(0)
10024   print *, "The radix for the default real kind is", radix(0.0)
10025 end program test_radix
10026 @end smallexample
10027
10028 @end table
10029
10030
10031
10032 @node RAN
10033 @section @code{RAN} --- Real pseudo-random number
10034 @fnindex RAN
10035 @cindex random number generation
10036
10037 @table @asis
10038 @item @emph{Description}:
10039 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
10040 provided as an alias for @code{RAND}.  See @ref{RAND} for complete
10041 documentation.
10042
10043 @item @emph{Standard}:
10044 GNU extension
10045
10046 @item @emph{Class}:
10047 Function
10048
10049 @item @emph{See also}:
10050 @ref{RAND}, @ref{RANDOM_NUMBER}
10051 @end table
10052
10053
10054
10055 @node RAND
10056 @section @code{RAND} --- Real pseudo-random number
10057 @fnindex RAND
10058 @cindex random number generation
10059
10060 @table @asis
10061 @item @emph{Description}:
10062 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
10063 distribution between 0 and 1. If @var{FLAG} is 0, the next number
10064 in the current sequence is returned; if @var{FLAG} is 1, the generator
10065 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
10066 it is used as a new seed with @code{SRAND}.
10067
10068 This intrinsic routine is provided for backwards compatibility with
10069 GNU Fortran 77. It implements a simple modulo generator as provided 
10070 by @command{g77}. For new code, one should consider the use of 
10071 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
10072
10073 @item @emph{Standard}:
10074 GNU extension
10075
10076 @item @emph{Class}:
10077 Function
10078
10079 @item @emph{Syntax}:
10080 @code{RESULT = RAND(I)}
10081
10082 @item @emph{Arguments}:
10083 @multitable @columnfractions .15 .70
10084 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
10085 @end multitable
10086
10087 @item @emph{Return value}:
10088 The return value is of @code{REAL} type and the default kind.
10089
10090 @item @emph{Example}:
10091 @smallexample
10092 program test_rand
10093   integer,parameter :: seed = 86456
10094   
10095   call srand(seed)
10096   print *, rand(), rand(), rand(), rand()
10097   print *, rand(seed), rand(), rand(), rand()
10098 end program test_rand
10099 @end smallexample
10100
10101 @item @emph{See also}:
10102 @ref{SRAND}, @ref{RANDOM_NUMBER}
10103
10104 @end table
10105
10106
10107
10108 @node RANDOM_NUMBER
10109 @section @code{RANDOM_NUMBER} --- Pseudo-random number
10110 @fnindex RANDOM_NUMBER
10111 @cindex random number generation
10112
10113 @table @asis
10114 @item @emph{Description}:
10115 Returns a single pseudorandom number or an array of pseudorandom numbers
10116 from the uniform distribution over the range @math{ 0 \leq x < 1}.
10117
10118 The runtime-library implements George Marsaglia's KISS (Keep It Simple 
10119 Stupid) random number generator (RNG). This RNG combines:
10120 @enumerate
10121 @item The congruential generator @math{x(n) = 69069 \cdot x(n-1) + 1327217885}
10122 with a period of @math{2^{32}},
10123 @item A 3-shift shift-register generator with a period of @math{2^{32} - 1},
10124 @item  Two 16-bit multiply-with-carry generators with a period of
10125 @math{597273182964842497 > 2^{59}}.
10126 @end enumerate
10127 The overall period exceeds @math{2^{123}}.
10128
10129 Please note, this RNG is thread safe if used within OpenMP directives,
10130 i.e., its state will be consistent while called from multiple threads.
10131 However, the KISS generator does not create random numbers in parallel 
10132 from multiple sources, but in sequence from a single source. If an
10133 OpenMP-enabled application heavily relies on random numbers, one should 
10134 consider employing a dedicated parallel random number generator instead.
10135
10136 @item @emph{Standard}:
10137 Fortran 95 and later
10138
10139 @item @emph{Class}:
10140 Subroutine
10141
10142 @item @emph{Syntax}:
10143 @code{RANDOM_NUMBER(HARVEST)}
10144
10145 @item @emph{Arguments}:
10146 @multitable @columnfractions .15 .70
10147 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
10148 @end multitable
10149
10150 @item @emph{Example}:
10151 @smallexample
10152 program test_random_number
10153   REAL :: r(5,5)
10154   CALL init_random_seed()         ! see example of RANDOM_SEED
10155   CALL RANDOM_NUMBER(r)
10156 end program
10157 @end smallexample
10158
10159 @item @emph{See also}:
10160 @ref{RANDOM_SEED}
10161 @end table
10162
10163
10164
10165 @node RANDOM_SEED
10166 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
10167 @fnindex RANDOM_SEED
10168 @cindex random number generation, seeding
10169 @cindex seeding a random number generator
10170
10171 @table @asis
10172 @item @emph{Description}:
10173 Restarts or queries the state of the pseudorandom number generator used by 
10174 @code{RANDOM_NUMBER}.
10175
10176 If @code{RANDOM_SEED} is called without arguments, it is initialized
10177 to a default state. The example below shows how to initialize the
10178 random seed with a varying seed in order to ensure a different random
10179 number sequence for each invocation of the program. Note that setting
10180 any of the seed values to zero should be avoided as it can result in
10181 poor quality random numbers being generated.
10182
10183 @item @emph{Standard}:
10184 Fortran 95 and later
10185
10186 @item @emph{Class}:
10187 Subroutine
10188
10189 @item @emph{Syntax}:
10190 @code{CALL RANDOM_SEED([SIZE, PUT, GET])}
10191
10192 @item @emph{Arguments}:
10193 @multitable @columnfractions .15 .70
10194 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default 
10195 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size 
10196 of the arrays used with the @var{PUT} and @var{GET} arguments.
10197 @item @var{PUT}  @tab (Optional) Shall be an array of type default 
10198 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of 
10199 the array must be larger than or equal to the number returned by the 
10200 @var{SIZE} argument.
10201 @item @var{GET}  @tab (Optional) Shall be an array of type default 
10202 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size 
10203 of the array must be larger than or equal to the number returned by 
10204 the @var{SIZE} argument.
10205 @end multitable
10206
10207 @item @emph{Example}:
10208 @smallexample
10209 subroutine init_random_seed()
10210   implicit none
10211   integer, allocatable :: seed(:)
10212   integer :: i, n, un, istat, dt(8), pid, t(2), s
10213   integer(8) :: count, tms
10214   
10215   call random_seed(size = n)
10216   allocate(seed(n))
10217   ! First try if the OS provides a random number generator
10218   open(newunit=un, file="/dev/urandom", access="stream", &
10219        form="unformatted", action="read", status="old", iostat=istat)
10220   if (istat == 0) then
10221      read(un) seed
10222      close(un)
10223   else
10224      ! Fallback to XOR:ing the current time and pid. The PID is
10225      ! useful in case one launches multiple instances of the same
10226      ! program in parallel.
10227      call system_clock(count)
10228      if (count /= 0) then
10229         t = transfer(count, t)
10230      else
10231         call date_and_time(values=dt)
10232         tms = (dt(1) - 1970) * 365_8 * 24 * 60 * 60 * 1000 &
10233              + dt(2) * 31_8 * 24 * 60 * 60 * 1000 &
10234              + dt(3) * 24 * 60 * 60 * 60 * 1000 &
10235              + dt(5) * 60 * 60 * 1000 &
10236              + dt(6) * 60 * 1000 + dt(7) * 1000 &
10237              + dt(8)
10238         t = transfer(tms, t)
10239      end if
10240      s = ieor(t(1), t(2))
10241      pid = getpid() + 1099279 ! Add a prime
10242      s = ieor(s, pid)
10243      if (n >= 3) then
10244         seed(1) = t(1) + 36269
10245         seed(2) = t(2) + 72551
10246         seed(3) = pid
10247         if (n > 3) then
10248            seed(4:) = s + 37 * (/ (i, i = 0, n - 4) /)
10249         end if
10250      else 
10251         seed = s + 37 * (/ (i, i = 0, n - 1 ) /)
10252      end if
10253   end if
10254   call random_seed(put=seed)
10255 end subroutine init_random_seed
10256 @end smallexample
10257
10258 @item @emph{See also}:
10259 @ref{RANDOM_NUMBER}
10260 @end table
10261
10262
10263
10264 @node RANGE
10265 @section @code{RANGE} --- Decimal exponent range
10266 @fnindex RANGE
10267 @cindex model representation, range
10268
10269 @table @asis
10270 @item @emph{Description}:
10271 @code{RANGE(X)} returns the decimal exponent range in the model of the
10272 type of @code{X}.
10273
10274 @item @emph{Standard}:
10275 Fortran 95 and later
10276
10277 @item @emph{Class}:
10278 Inquiry function
10279
10280 @item @emph{Syntax}:
10281 @code{RESULT = RANGE(X)}
10282
10283 @item @emph{Arguments}:
10284 @multitable @columnfractions .15 .70
10285 @item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL}
10286 or @code{COMPLEX}.
10287 @end multitable
10288
10289 @item @emph{Return value}:
10290 The return value is of type @code{INTEGER} and of the default integer
10291 kind.
10292
10293 @item @emph{See also}:
10294 @ref{SELECTED_REAL_KIND}, @ref{PRECISION}
10295
10296 @item @emph{Example}:
10297 See @code{PRECISION} for an example.
10298 @end table
10299
10300
10301
10302 @node RANK
10303 @section @code{RANK} --- Rank of a data object
10304 @fnindex RANK
10305 @cindex rank
10306
10307 @table @asis
10308 @item @emph{Description}:
10309 @code{RANK(A)} returns the rank of a scalar or array data object.
10310
10311 @item @emph{Standard}:
10312 Technical Specification (TS) 29113
10313
10314 @item @emph{Class}:
10315 Inquiry function
10316
10317 @item @emph{Syntax}:
10318 @code{RESULT = RANGE(A)}
10319
10320 @item @emph{Arguments}:
10321 @multitable @columnfractions .15 .70
10322 @item @var{A} @tab can be of any type
10323 @end multitable
10324
10325 @item @emph{Return value}:
10326 The return value is of type @code{INTEGER} and of the default integer
10327 kind. For arrays, their rank is returned; for scalars zero is returned.
10328
10329 @item @emph{Example}:
10330 @smallexample
10331 program test_rank
10332   integer :: a
10333   real, allocatable :: b(:,:)
10334
10335   print *, rank(a), rank(b) ! Prints:  0  3
10336 end program test_rank
10337 @end smallexample
10338
10339 @end table
10340
10341
10342
10343 @node REAL
10344 @section @code{REAL} --- Convert to real type 
10345 @fnindex REAL
10346 @fnindex REALPART
10347 @fnindex FLOAT
10348 @fnindex DFLOAT
10349 @fnindex SNGL
10350 @cindex conversion, to real
10351 @cindex complex numbers, real part
10352
10353 @table @asis
10354 @item @emph{Description}:
10355 @code{REAL(A [, KIND])} converts its argument @var{A} to a real type.  The
10356 @code{REALPART} function is provided for compatibility with @command{g77},
10357 and its use is strongly discouraged.
10358
10359 @item @emph{Standard}:
10360 Fortran 77 and later
10361
10362 @item @emph{Class}:
10363 Elemental function
10364
10365 @item @emph{Syntax}:
10366 @multitable @columnfractions .80
10367 @item @code{RESULT = REAL(A [, KIND])}
10368 @item @code{RESULT = REALPART(Z)}
10369 @end multitable
10370
10371 @item @emph{Arguments}:
10372 @multitable @columnfractions .15 .70
10373 @item @var{A}    @tab Shall be @code{INTEGER}, @code{REAL}, or
10374 @code{COMPLEX}.
10375 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10376 expression indicating the kind parameter of the result.
10377 @end multitable
10378
10379 @item @emph{Return value}:
10380 These functions return a @code{REAL} variable or array under
10381 the following rules: 
10382
10383 @table @asis
10384 @item (A)
10385 @code{REAL(A)} is converted to a default real type if @var{A} is an 
10386 integer or real variable.
10387 @item (B)
10388 @code{REAL(A)} is converted to a real type with the kind type parameter
10389 of @var{A} if @var{A} is a complex variable.
10390 @item (C)
10391 @code{REAL(A, KIND)} is converted to a real type with kind type
10392 parameter @var{KIND} if @var{A} is a complex, integer, or real
10393 variable.
10394 @end table
10395
10396 @item @emph{Example}:
10397 @smallexample
10398 program test_real
10399   complex :: x = (1.0, 2.0)
10400   print *, real(x), real(x,8), realpart(x)
10401 end program test_real
10402 @end smallexample
10403
10404 @item @emph{Specific names}:
10405 @multitable @columnfractions .20 .20 .20 .25
10406 @item Name             @tab Argument           @tab Return type     @tab Standard
10407 @item @code{FLOAT(A)}  @tab @code{INTEGER(4)}  @tab @code{REAL(4)}  @tab Fortran 77 and later
10408 @item @code{DFLOAT(A)} @tab @code{INTEGER(4)}  @tab @code{REAL(8)}  @tab GNU extension
10409 @item @code{SNGL(A)}   @tab @code{INTEGER(8)}  @tab @code{REAL(4)}  @tab Fortran 77 and later
10410 @end multitable
10411
10412
10413 @item @emph{See also}:
10414 @ref{DBLE}
10415
10416 @end table
10417
10418
10419
10420 @node RENAME
10421 @section @code{RENAME} --- Rename a file
10422 @fnindex RENAME
10423 @cindex file system, rename file
10424
10425 @table @asis
10426 @item @emph{Description}:
10427 Renames a file from file @var{PATH1} to @var{PATH2}. A null
10428 character (@code{CHAR(0)}) can be used to mark the end of the names in
10429 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
10430 names are ignored.  If the @var{STATUS} argument is supplied, it
10431 contains 0 on success or a nonzero error code upon return; see
10432 @code{rename(2)}.
10433
10434 This intrinsic is provided in both subroutine and function forms;
10435 however, only one form can be used in any given program unit.
10436
10437 @item @emph{Standard}:
10438 GNU extension
10439
10440 @item @emph{Class}:
10441 Subroutine, function
10442
10443 @item @emph{Syntax}:
10444 @multitable @columnfractions .80
10445 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
10446 @item @code{STATUS = RENAME(PATH1, PATH2)}
10447 @end multitable
10448
10449 @item @emph{Arguments}:
10450 @multitable @columnfractions .15 .70
10451 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
10452 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
10453 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10454 @end multitable
10455
10456 @item @emph{See also}:
10457 @ref{LINK}
10458
10459 @end table
10460
10461
10462
10463 @node REPEAT
10464 @section @code{REPEAT} --- Repeated string concatenation 
10465 @fnindex REPEAT
10466 @cindex string, repeat
10467 @cindex string, concatenate
10468
10469 @table @asis
10470 @item @emph{Description}:
10471 Concatenates @var{NCOPIES} copies of a string.
10472
10473 @item @emph{Standard}:
10474 Fortran 95 and later
10475
10476 @item @emph{Class}:
10477 Transformational function
10478
10479 @item @emph{Syntax}:
10480 @code{RESULT = REPEAT(STRING, NCOPIES)}
10481
10482 @item @emph{Arguments}:
10483 @multitable @columnfractions .15 .70
10484 @item @var{STRING}  @tab Shall be scalar and of type @code{CHARACTER}.
10485 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
10486 @end multitable
10487
10488 @item @emph{Return value}:
10489 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies 
10490 of @var{STRING}.
10491
10492 @item @emph{Example}:
10493 @smallexample
10494 program test_repeat
10495   write(*,*) repeat("x", 5)   ! "xxxxx"
10496 end program
10497 @end smallexample
10498 @end table
10499
10500
10501
10502 @node RESHAPE
10503 @section @code{RESHAPE} --- Function to reshape an array
10504 @fnindex RESHAPE
10505 @cindex array, change dimensions
10506 @cindex array, transmogrify
10507
10508 @table @asis
10509 @item @emph{Description}:
10510 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
10511 the new array may be padded with elements from @var{PAD} or permuted
10512 as defined by @var{ORDER}.
10513
10514 @item @emph{Standard}:
10515 Fortran 95 and later
10516
10517 @item @emph{Class}:
10518 Transformational function
10519
10520 @item @emph{Syntax}:
10521 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
10522
10523 @item @emph{Arguments}:
10524 @multitable @columnfractions .15 .70
10525 @item @var{SOURCE} @tab Shall be an array of any type.
10526 @item @var{SHAPE}  @tab Shall be of type @code{INTEGER} and an 
10527 array of rank one. Its values must be positive or zero.
10528 @item @var{PAD}    @tab (Optional) shall be an array of the same 
10529 type as @var{SOURCE}.
10530 @item @var{ORDER}  @tab (Optional) shall be of type @code{INTEGER}
10531 and an array of the same shape as @var{SHAPE}. Its values shall
10532 be a permutation of the numbers from 1 to n, where n is the size of 
10533 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
10534 be assumed.
10535 @end multitable
10536
10537 @item @emph{Return value}:
10538 The result is an array of shape @var{SHAPE} with the same type as 
10539 @var{SOURCE}. 
10540
10541 @item @emph{Example}:
10542 @smallexample
10543 PROGRAM test_reshape
10544   INTEGER, DIMENSION(4) :: x
10545   WRITE(*,*) SHAPE(x)                       ! prints "4"
10546   WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/)))    ! prints "2 2"
10547 END PROGRAM
10548 @end smallexample
10549
10550 @item @emph{See also}:
10551 @ref{SHAPE}
10552 @end table
10553
10554
10555
10556 @node RRSPACING
10557 @section @code{RRSPACING} --- Reciprocal of the relative spacing
10558 @fnindex RRSPACING
10559 @cindex real number, relative spacing
10560 @cindex floating point, relative spacing
10561
10562
10563 @table @asis
10564 @item @emph{Description}:
10565 @code{RRSPACING(X)} returns the  reciprocal of the relative spacing of
10566 model numbers near @var{X}.
10567
10568 @item @emph{Standard}:
10569 Fortran 95 and later
10570
10571 @item @emph{Class}:
10572 Elemental function
10573
10574 @item @emph{Syntax}:
10575 @code{RESULT = RRSPACING(X)}
10576
10577 @item @emph{Arguments}:
10578 @multitable @columnfractions .15 .70
10579 @item @var{X} @tab Shall be of type @code{REAL}.
10580 @end multitable
10581
10582 @item @emph{Return value}:
10583 The return value is of the same type and kind as @var{X}.
10584 The value returned is equal to
10585 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
10586
10587 @item @emph{See also}:
10588 @ref{SPACING}
10589 @end table
10590
10591
10592
10593 @node RSHIFT
10594 @section @code{RSHIFT} --- Right shift bits
10595 @fnindex RSHIFT
10596 @cindex bits, shift right
10597
10598 @table @asis
10599 @item @emph{Description}:
10600 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
10601 bits shifted right by @var{SHIFT} places.  If the absolute value of
10602 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
10603 Bits shifted out from the right end are lost. The fill is arithmetic: the
10604 bits shifted in from the left end are equal to the leftmost bit, which in
10605 two's complement representation is the sign bit.
10606
10607 This function has been superseded by the @code{SHIFTA} intrinsic, which
10608 is standard in Fortran 2008 and later.
10609
10610 @item @emph{Standard}:
10611 GNU extension
10612
10613 @item @emph{Class}:
10614 Elemental function
10615
10616 @item @emph{Syntax}:
10617 @code{RESULT = RSHIFT(I, SHIFT)}
10618
10619 @item @emph{Arguments}:
10620 @multitable @columnfractions .15 .70
10621 @item @var{I} @tab The type shall be @code{INTEGER}.
10622 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
10623 @end multitable
10624
10625 @item @emph{Return value}:
10626 The return value is of type @code{INTEGER} and of the same kind as
10627 @var{I}.
10628
10629 @item @emph{See also}:
10630 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}, @ref{SHIFTA}, @ref{SHIFTR},
10631 @ref{SHIFTL}
10632
10633 @end table
10634
10635
10636
10637 @node SAME_TYPE_AS
10638 @section @code{SAME_TYPE_AS} ---  Query dynamic types for equality
10639 @fnindex SAME_TYPE_AS
10640
10641 @table @asis
10642 @item @emph{Description}:
10643 Query dynamic types for equality.
10644
10645 @item @emph{Standard}:
10646 Fortran 2003 and later
10647
10648 @item @emph{Class}:
10649 Inquiry function
10650
10651 @item @emph{Syntax}:
10652 @code{RESULT = SAME_TYPE_AS(A, B)}
10653
10654 @item @emph{Arguments}:
10655 @multitable @columnfractions .15 .70
10656 @item @var{A} @tab Shall be an object of extensible declared type or
10657 unlimited polymorphic.
10658 @item @var{B} @tab Shall be an object of extensible declared type or
10659 unlimited polymorphic.
10660 @end multitable
10661
10662 @item @emph{Return value}:
10663 The return value is a scalar of type default logical. It is true if and
10664 only if the dynamic type of A is the same as the dynamic type of B.
10665
10666 @item @emph{See also}:
10667 @ref{EXTENDS_TYPE_OF}
10668
10669 @end table
10670
10671
10672
10673 @node SCALE
10674 @section @code{SCALE} --- Scale a real value
10675 @fnindex SCALE
10676 @cindex real number, scale
10677 @cindex floating point, scale
10678
10679 @table @asis
10680 @item @emph{Description}:
10681 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
10682
10683 @item @emph{Standard}:
10684 Fortran 95 and later
10685
10686 @item @emph{Class}:
10687 Elemental function
10688
10689 @item @emph{Syntax}:
10690 @code{RESULT = SCALE(X, I)}
10691
10692 @item @emph{Arguments}:
10693 @multitable @columnfractions .15 .70
10694 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
10695 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
10696 @end multitable
10697
10698 @item @emph{Return value}:
10699 The return value is of the same type and kind as @var{X}.
10700 Its value is @code{X * RADIX(X)**I}.
10701
10702 @item @emph{Example}:
10703 @smallexample
10704 program test_scale
10705   real :: x = 178.1387e-4
10706   integer :: i = 5
10707   print *, scale(x,i), x*radix(x)**i
10708 end program test_scale
10709 @end smallexample
10710
10711 @end table
10712
10713
10714
10715 @node SCAN
10716 @section @code{SCAN} --- Scan a string for the presence of a set of characters
10717 @fnindex SCAN
10718 @cindex string, find subset
10719
10720 @table @asis
10721 @item @emph{Description}:
10722 Scans a @var{STRING} for any of the characters in a @var{SET} 
10723 of characters.
10724
10725 If @var{BACK} is either absent or equals @code{FALSE}, this function
10726 returns the position of the leftmost character of @var{STRING} that is
10727 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
10728 is returned. If no character of @var{SET} is found in @var{STRING}, the 
10729 result is zero.
10730
10731 @item @emph{Standard}:
10732 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
10733
10734 @item @emph{Class}:
10735 Elemental function
10736
10737 @item @emph{Syntax}:
10738 @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
10739
10740 @item @emph{Arguments}:
10741 @multitable @columnfractions .15 .70
10742 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
10743 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
10744 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
10745 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
10746 expression indicating the kind parameter of the result.
10747 @end multitable
10748
10749 @item @emph{Return value}:
10750 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
10751 @var{KIND} is absent, the return value is of default integer kind.
10752
10753 @item @emph{Example}:
10754 @smallexample
10755 PROGRAM test_scan
10756   WRITE(*,*) SCAN("FORTRAN", "AO")          ! 2, found 'O'
10757   WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.)  ! 6, found 'A'
10758   WRITE(*,*) SCAN("FORTRAN", "C++")         ! 0, found none
10759 END PROGRAM
10760 @end smallexample
10761
10762 @item @emph{See also}:
10763 @ref{INDEX intrinsic}, @ref{VERIFY}
10764 @end table
10765
10766
10767
10768 @node SECNDS
10769 @section @code{SECNDS} --- Time function
10770 @fnindex SECNDS
10771 @cindex time, elapsed
10772 @cindex elapsed time
10773
10774 @table @asis
10775 @item @emph{Description}:
10776 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
10777 @var{X} is a reference time, also in seconds. If this is zero, the time in
10778 seconds from midnight is returned. This function is non-standard and its
10779 use is discouraged.
10780
10781 @item @emph{Standard}:
10782 GNU extension
10783
10784 @item @emph{Class}:
10785 Function
10786
10787 @item @emph{Syntax}:
10788 @code{RESULT = SECNDS (X)}
10789
10790 @item @emph{Arguments}:
10791 @multitable @columnfractions .15 .70
10792 @item @var{T}     @tab Shall be of type @code{REAL(4)}.
10793 @item @var{X}     @tab Shall be of type @code{REAL(4)}.
10794 @end multitable
10795
10796 @item @emph{Return value}:
10797 None
10798
10799 @item @emph{Example}:
10800 @smallexample
10801 program test_secnds
10802     integer :: i
10803     real(4) :: t1, t2
10804     print *, secnds (0.0)   ! seconds since midnight
10805     t1 = secnds (0.0)       ! reference time
10806     do i = 1, 10000000      ! do something
10807     end do
10808     t2 = secnds (t1)        ! elapsed time
10809     print *, "Something took ", t2, " seconds."
10810 end program test_secnds
10811 @end smallexample
10812 @end table
10813
10814
10815
10816 @node SECOND
10817 @section @code{SECOND} --- CPU time function
10818 @fnindex SECOND
10819 @cindex time, elapsed
10820 @cindex elapsed time
10821
10822 @table @asis
10823 @item @emph{Description}:
10824 Returns a @code{REAL(4)} value representing the elapsed CPU time in
10825 seconds.  This provides the same functionality as the standard
10826 @code{CPU_TIME} intrinsic, and is only included for backwards
10827 compatibility.
10828
10829 This intrinsic is provided in both subroutine and function forms;
10830 however, only one form can be used in any given program unit.
10831
10832 @item @emph{Standard}:
10833 GNU extension
10834
10835 @item @emph{Class}:
10836 Subroutine, function
10837
10838 @item @emph{Syntax}:
10839 @multitable @columnfractions .80
10840 @item @code{CALL SECOND(TIME)}
10841 @item @code{TIME = SECOND()}
10842 @end multitable
10843
10844 @item @emph{Arguments}:
10845 @multitable @columnfractions .15 .70
10846 @item @var{TIME}  @tab Shall be of type @code{REAL(4)}.
10847 @end multitable
10848
10849 @item @emph{Return value}:
10850 In either syntax, @var{TIME} is set to the process's current runtime in
10851 seconds.
10852
10853 @item @emph{See also}:
10854 @ref{CPU_TIME}
10855
10856 @end table
10857
10858
10859
10860 @node SELECTED_CHAR_KIND
10861 @section @code{SELECTED_CHAR_KIND} --- Choose character kind
10862 @fnindex SELECTED_CHAR_KIND
10863 @cindex character kind
10864 @cindex kind, character
10865
10866 @table @asis
10867 @item @emph{Description}:
10868
10869 @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
10870 set named @var{NAME}, if a character set with such a name is supported,
10871 or @math{-1} otherwise. Currently, supported character sets include
10872 ``ASCII'' and ``DEFAULT'', which are equivalent, and ``ISO_10646''
10873 (Universal Character Set, UCS-4) which is commonly known as Unicode.
10874
10875 @item @emph{Standard}:
10876 Fortran 2003 and later
10877
10878 @item @emph{Class}:
10879 Transformational function
10880
10881 @item @emph{Syntax}:
10882 @code{RESULT = SELECTED_CHAR_KIND(NAME)}
10883
10884 @item @emph{Arguments}:
10885 @multitable @columnfractions .15 .70
10886 @item @var{NAME} @tab Shall be a scalar and of the default character type.
10887 @end multitable
10888
10889 @item @emph{Example}:
10890 @smallexample
10891 program character_kind
10892   use iso_fortran_env
10893   implicit none
10894   integer, parameter :: ascii = selected_char_kind ("ascii")
10895   integer, parameter :: ucs4  = selected_char_kind ('ISO_10646')
10896
10897   character(kind=ascii, len=26) :: alphabet
10898   character(kind=ucs4,  len=30) :: hello_world
10899
10900   alphabet = ascii_"abcdefghijklmnopqrstuvwxyz"
10901   hello_world = ucs4_'Hello World and Ni Hao -- ' &
10902                 // char (int (z'4F60'), ucs4)     &
10903                 // char (int (z'597D'), ucs4)
10904
10905   write (*,*) alphabet
10906
10907   open (output_unit, encoding='UTF-8')
10908   write (*,*) trim (hello_world)
10909 end program character_kind
10910 @end smallexample
10911 @end table
10912
10913
10914
10915 @node SELECTED_INT_KIND
10916 @section @code{SELECTED_INT_KIND} --- Choose integer kind
10917 @fnindex SELECTED_INT_KIND
10918 @cindex integer kind
10919 @cindex kind, integer
10920
10921 @table @asis
10922 @item @emph{Description}:
10923 @code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer
10924 type that can represent all values ranging from @math{-10^R} (exclusive)
10925 to @math{10^R} (exclusive). If there is no integer kind that accommodates
10926 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
10927
10928 @item @emph{Standard}:
10929 Fortran 95 and later
10930
10931 @item @emph{Class}:
10932 Transformational function
10933
10934 @item @emph{Syntax}:
10935 @code{RESULT = SELECTED_INT_KIND(R)}
10936
10937 @item @emph{Arguments}:
10938 @multitable @columnfractions .15 .70
10939 @item @var{R} @tab Shall be a scalar and of type @code{INTEGER}.
10940 @end multitable
10941
10942 @item @emph{Example}:
10943 @smallexample
10944 program large_integers
10945   integer,parameter :: k5 = selected_int_kind(5)
10946   integer,parameter :: k15 = selected_int_kind(15)
10947   integer(kind=k5) :: i5
10948   integer(kind=k15) :: i15
10949
10950   print *, huge(i5), huge(i15)
10951
10952   ! The following inequalities are always true
10953   print *, huge(i5) >= 10_k5**5-1
10954   print *, huge(i15) >= 10_k15**15-1
10955 end program large_integers
10956 @end smallexample
10957 @end table
10958
10959
10960
10961 @node SELECTED_REAL_KIND
10962 @section @code{SELECTED_REAL_KIND} --- Choose real kind
10963 @fnindex SELECTED_REAL_KIND
10964 @cindex real kind
10965 @cindex kind, real
10966 @cindex radix, real
10967
10968 @table @asis
10969 @item @emph{Description}:
10970 @code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type
10971 with decimal precision of at least @code{P} digits, exponent range of
10972 at least @code{R}, and with a radix of @code{RADIX}.
10973
10974 @item @emph{Standard}:
10975 Fortran 95 and later, with @code{RADIX} Fortran 2008 or later
10976
10977 @item @emph{Class}:
10978 Transformational function
10979
10980 @item @emph{Syntax}:
10981 @code{RESULT = SELECTED_REAL_KIND([P, R, RADIX])}
10982
10983 @item @emph{Arguments}:
10984 @multitable @columnfractions .15 .70
10985 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
10986 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
10987 @item @var{RADIX} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
10988 @end multitable
10989 Before Fortran 2008, at least one of the arguments @var{R} or @var{P} shall
10990 be present; since Fortran 2008, they are assumed to be zero if absent.
10991
10992 @item @emph{Return value}:
10993
10994 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
10995 a real data type with decimal precision of at least @code{P} digits, a
10996 decimal exponent range of at least @code{R}, and with the requested
10997 @code{RADIX}. If the @code{RADIX} parameter is absent, real kinds with
10998 any radix can be returned. If more than one real data type meet the
10999 criteria, the kind of the data type with the smallest decimal precision
11000 is returned. If no real data type matches the criteria, the result is
11001 @table @asis
11002 @item -1 if the processor does not support a real data type with a
11003 precision greater than or equal to @code{P}, but the @code{R} and
11004 @code{RADIX} requirements can be fulfilled
11005 @item -2 if the processor does not support a real type with an exponent
11006 range greater than or equal to @code{R}, but @code{P} and @code{RADIX}
11007 are fulfillable
11008 @item -3 if @code{RADIX} but not @code{P} and @code{R} requirements
11009 are fulfillable
11010 @item -4 if @code{RADIX} and either @code{P} or @code{R} requirements
11011 are fulfillable
11012 @item -5 if there is no real type with the given @code{RADIX}
11013 @end table
11014
11015 @item @emph{See also}:
11016 @ref{PRECISION}, @ref{RANGE}, @ref{RADIX}
11017
11018 @item @emph{Example}:
11019 @smallexample
11020 program real_kinds
11021   integer,parameter :: p6 = selected_real_kind(6)
11022   integer,parameter :: p10r100 = selected_real_kind(10,100)
11023   integer,parameter :: r400 = selected_real_kind(r=400)
11024   real(kind=p6) :: x
11025   real(kind=p10r100) :: y
11026   real(kind=r400) :: z
11027
11028   print *, precision(x), range(x)
11029   print *, precision(y), range(y)
11030   print *, precision(z), range(z)
11031 end program real_kinds
11032 @end smallexample
11033 @end table
11034
11035
11036
11037 @node SET_EXPONENT
11038 @section @code{SET_EXPONENT} --- Set the exponent of the model
11039 @fnindex SET_EXPONENT
11040 @cindex real number, set exponent
11041 @cindex floating point, set exponent
11042
11043 @table @asis
11044 @item @emph{Description}:
11045 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
11046 is that that of @var{X} and whose exponent part is @var{I}.
11047
11048 @item @emph{Standard}:
11049 Fortran 95 and later
11050
11051 @item @emph{Class}:
11052 Elemental function
11053
11054 @item @emph{Syntax}:
11055 @code{RESULT = SET_EXPONENT(X, I)}
11056
11057 @item @emph{Arguments}:
11058 @multitable @columnfractions .15 .70
11059 @item @var{X} @tab Shall be of type @code{REAL}.
11060 @item @var{I} @tab Shall be of type @code{INTEGER}.
11061 @end multitable
11062
11063 @item @emph{Return value}:
11064 The return value is of the same type and kind as @var{X}.
11065 The real number whose fractional part
11066 is that that of @var{X} and whose exponent part if @var{I} is returned;
11067 it is @code{FRACTION(X) * RADIX(X)**I}.
11068
11069 @item @emph{Example}:
11070 @smallexample
11071 PROGRAM test_setexp
11072   REAL :: x = 178.1387e-4
11073   INTEGER :: i = 17
11074   PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
11075 END PROGRAM
11076 @end smallexample
11077
11078 @end table
11079
11080
11081
11082 @node SHAPE
11083 @section @code{SHAPE} --- Determine the shape of an array
11084 @fnindex SHAPE
11085 @cindex array, shape
11086
11087 @table @asis
11088 @item @emph{Description}:
11089 Determines the shape of an array.
11090
11091 @item @emph{Standard}:
11092 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
11093
11094 @item @emph{Class}:
11095 Inquiry function
11096
11097 @item @emph{Syntax}:
11098 @code{RESULT = SHAPE(SOURCE [, KIND])}
11099
11100 @item @emph{Arguments}:
11101 @multitable @columnfractions .15 .70
11102 @item @var{SOURCE} @tab Shall be an array or scalar of any type. 
11103 If @var{SOURCE} is a pointer it must be associated and allocatable 
11104 arrays must be allocated.
11105 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
11106 expression indicating the kind parameter of the result.
11107 @end multitable
11108
11109 @item @emph{Return value}:
11110 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE} 
11111 has dimensions. The elements of the resulting array correspond to the extend
11112 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
11113 the result is the rank one array of size zero. If @var{KIND} is absent, the
11114 return value has the default integer kind otherwise the specified kind.
11115
11116 @item @emph{Example}:
11117 @smallexample
11118 PROGRAM test_shape
11119   INTEGER, DIMENSION(-1:1, -1:2) :: A
11120   WRITE(*,*) SHAPE(A)             ! (/ 3, 4 /)
11121   WRITE(*,*) SIZE(SHAPE(42))      ! (/ /)
11122 END PROGRAM
11123 @end smallexample
11124
11125 @item @emph{See also}:
11126 @ref{RESHAPE}, @ref{SIZE}
11127 @end table
11128
11129
11130
11131 @node SHIFTA
11132 @section @code{SHIFTA} --- Right shift with fill
11133 @fnindex SHIFTA
11134 @cindex bits, shift right
11135 @cindex shift, right with fill
11136
11137 @table @asis
11138 @item @emph{Description}:
11139 @code{SHIFTA} returns a value corresponding to @var{I} with all of the
11140 bits shifted right by @var{SHIFT} places.  If the absolute value of
11141 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
11142 Bits shifted out from the right end are lost. The fill is arithmetic: the
11143 bits shifted in from the left end are equal to the leftmost bit, which in
11144 two's complement representation is the sign bit.
11145
11146 @item @emph{Standard}:
11147 Fortran 2008 and later
11148
11149 @item @emph{Class}:
11150 Elemental function
11151
11152 @item @emph{Syntax}:
11153 @code{RESULT = SHIFTA(I, SHIFT)}
11154
11155 @item @emph{Arguments}:
11156 @multitable @columnfractions .15 .70
11157 @item @var{I} @tab The type shall be @code{INTEGER}.
11158 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
11159 @end multitable
11160
11161 @item @emph{Return value}:
11162 The return value is of type @code{INTEGER} and of the same kind as
11163 @var{I}.
11164
11165 @item @emph{See also}:
11166 @ref{SHIFTL}, @ref{SHIFTR}
11167 @end table
11168
11169
11170
11171 @node SHIFTL
11172 @section @code{SHIFTL} --- Left shift
11173 @fnindex SHIFTL
11174 @cindex bits, shift left
11175 @cindex shift, left
11176
11177 @table @asis
11178 @item @emph{Description}:
11179 @code{SHIFTL} returns a value corresponding to @var{I} with all of the
11180 bits shifted left by @var{SHIFT} places.  If the absolute value of
11181 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
11182 Bits shifted out from the left end are lost, and bits shifted in from
11183 the right end are set to 0.
11184
11185 @item @emph{Standard}:
11186 Fortran 2008 and later
11187
11188 @item @emph{Class}:
11189 Elemental function
11190
11191 @item @emph{Syntax}:
11192 @code{RESULT = SHIFTL(I, SHIFT)}
11193
11194 @item @emph{Arguments}:
11195 @multitable @columnfractions .15 .70
11196 @item @var{I} @tab The type shall be @code{INTEGER}.
11197 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
11198 @end multitable
11199
11200 @item @emph{Return value}:
11201 The return value is of type @code{INTEGER} and of the same kind as
11202 @var{I}.
11203
11204 @item @emph{See also}:
11205 @ref{SHIFTA}, @ref{SHIFTR}
11206 @end table
11207
11208
11209
11210 @node SHIFTR
11211 @section @code{SHIFTR} --- Right shift
11212 @fnindex SHIFTR
11213 @cindex bits, shift right
11214 @cindex shift, right
11215
11216 @table @asis
11217 @item @emph{Description}:
11218 @code{SHIFTR} returns a value corresponding to @var{I} with all of the
11219 bits shifted right by @var{SHIFT} places.  If the absolute value of
11220 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
11221 Bits shifted out from the right end are lost, and bits shifted in from
11222 the left end are set to 0.
11223
11224 @item @emph{Standard}:
11225 Fortran 2008 and later
11226
11227 @item @emph{Class}:
11228 Elemental function
11229
11230 @item @emph{Syntax}:
11231 @code{RESULT = SHIFTR(I, SHIFT)}
11232
11233 @item @emph{Arguments}:
11234 @multitable @columnfractions .15 .70
11235 @item @var{I} @tab The type shall be @code{INTEGER}.
11236 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
11237 @end multitable
11238
11239 @item @emph{Return value}:
11240 The return value is of type @code{INTEGER} and of the same kind as
11241 @var{I}.
11242
11243 @item @emph{See also}:
11244 @ref{SHIFTA}, @ref{SHIFTL}
11245 @end table
11246
11247
11248
11249 @node SIGN
11250 @section @code{SIGN} --- Sign copying function
11251 @fnindex SIGN
11252 @fnindex ISIGN
11253 @fnindex DSIGN
11254 @cindex sign copying
11255
11256 @table @asis
11257 @item @emph{Description}:
11258 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
11259
11260 @item @emph{Standard}:
11261 Fortran 77 and later
11262
11263 @item @emph{Class}:
11264 Elemental function
11265
11266 @item @emph{Syntax}:
11267 @code{RESULT = SIGN(A, B)}
11268
11269 @item @emph{Arguments}:
11270 @multitable @columnfractions .15 .70
11271 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
11272 @item @var{B} @tab Shall be of the same type and kind as @var{A}
11273 @end multitable
11274
11275 @item @emph{Return value}:
11276 The kind of the return value is that of @var{A} and @var{B}.
11277 If @math{B\ge 0} then the result is @code{ABS(A)}, else
11278 it is @code{-ABS(A)}.
11279
11280 @item @emph{Example}:
11281 @smallexample
11282 program test_sign
11283   print *, sign(-12,1)
11284   print *, sign(-12,0)
11285   print *, sign(-12,-1)
11286
11287   print *, sign(-12.,1.)
11288   print *, sign(-12.,0.)
11289   print *, sign(-12.,-1.)
11290 end program test_sign
11291 @end smallexample
11292
11293 @item @emph{Specific names}:
11294 @multitable @columnfractions .20 .20 .20 .25
11295 @item Name              @tab Arguments              @tab Return type       @tab Standard
11296 @item @code{SIGN(A,B)}  @tab @code{REAL(4) A, B}    @tab @code{REAL(4)}    @tab f77, gnu
11297 @item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab f77, gnu
11298 @item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B}    @tab @code{REAL(8)}    @tab f77, gnu
11299 @end multitable
11300 @end table
11301
11302
11303
11304 @node SIGNAL
11305 @section @code{SIGNAL} --- Signal handling subroutine (or function)
11306 @fnindex SIGNAL
11307 @cindex system, signal handling
11308
11309 @table @asis
11310 @item @emph{Description}:
11311 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
11312 @var{HANDLER} to be executed with a single integer argument when signal
11313 @var{NUMBER} occurs.  If @var{HANDLER} is an integer, it can be used to
11314 turn off handling of signal @var{NUMBER} or revert to its default
11315 action.  See @code{signal(2)}.
11316
11317 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
11318 is supplied, it is set to the value returned by @code{signal(2)}.
11319
11320 @item @emph{Standard}:
11321 GNU extension
11322
11323 @item @emph{Class}:
11324 Subroutine, function
11325
11326 @item @emph{Syntax}:
11327 @multitable @columnfractions .80
11328 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
11329 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
11330 @end multitable
11331
11332 @item @emph{Arguments}:
11333 @multitable @columnfractions .15 .70
11334 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
11335 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
11336 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
11337 @code{INTEGER}. It is @code{INTENT(IN)}.
11338 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
11339 integer. It has @code{INTENT(OUT)}.
11340 @end multitable
11341 @c TODO: What should the interface of the handler be?  Does it take arguments?
11342
11343 @item @emph{Return value}:
11344 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
11345
11346 @item @emph{Example}:
11347 @smallexample
11348 program test_signal
11349   intrinsic signal
11350   external handler_print
11351
11352   call signal (12, handler_print)
11353   call signal (10, 1)
11354
11355   call sleep (30)
11356 end program test_signal
11357 @end smallexample
11358 @end table
11359
11360
11361
11362 @node SIN
11363 @section @code{SIN} --- Sine function 
11364 @fnindex SIN
11365 @fnindex DSIN
11366 @fnindex CSIN
11367 @fnindex ZSIN
11368 @fnindex CDSIN
11369 @cindex trigonometric function, sine
11370 @cindex sine
11371
11372 @table @asis
11373 @item @emph{Description}:
11374 @code{SIN(X)} computes the sine of @var{X}.
11375
11376 @item @emph{Standard}:
11377 Fortran 77 and later
11378
11379 @item @emph{Class}:
11380 Elemental function
11381
11382 @item @emph{Syntax}:
11383 @code{RESULT = SIN(X)}
11384
11385 @item @emph{Arguments}:
11386 @multitable @columnfractions .15 .70
11387 @item @var{X} @tab The type shall be @code{REAL} or
11388 @code{COMPLEX}.
11389 @end multitable
11390
11391 @item @emph{Return value}:
11392 The return value has same type and kind as @var{X}.
11393
11394 @item @emph{Example}:
11395 @smallexample
11396 program test_sin
11397   real :: x = 0.0
11398   x = sin(x)
11399 end program test_sin
11400 @end smallexample
11401
11402 @item @emph{Specific names}:
11403 @multitable @columnfractions .20 .20 .20 .25
11404 @item Name            @tab Argument             @tab Return type       @tab Standard
11405 @item @code{SIN(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}    @tab f77, gnu
11406 @item @code{DSIN(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}    @tab f95, gnu
11407 @item @code{CSIN(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)} @tab f95, gnu
11408 @item @code{ZSIN(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)} @tab f95, gnu
11409 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)} @tab f95, gnu
11410 @end multitable
11411
11412 @item @emph{See also}:
11413 @ref{ASIN}
11414 @end table
11415
11416
11417
11418 @node SINH
11419 @section @code{SINH} --- Hyperbolic sine function 
11420 @fnindex SINH
11421 @fnindex DSINH
11422 @cindex hyperbolic sine
11423 @cindex hyperbolic function, sine
11424 @cindex sine, hyperbolic
11425
11426 @table @asis
11427 @item @emph{Description}:
11428 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
11429
11430 @item @emph{Standard}:
11431 Fortran 95 and later, for a complex argument Fortran 2008 or later
11432
11433 @item @emph{Class}:
11434 Elemental function
11435
11436 @item @emph{Syntax}:
11437 @code{RESULT = SINH(X)}
11438
11439 @item @emph{Arguments}:
11440 @multitable @columnfractions .15 .70
11441 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
11442 @end multitable
11443
11444 @item @emph{Return value}:
11445 The return value has same type and kind as @var{X}.
11446
11447 @item @emph{Example}:
11448 @smallexample
11449 program test_sinh
11450   real(8) :: x = - 1.0_8
11451   x = sinh(x)
11452 end program test_sinh
11453 @end smallexample
11454
11455 @item @emph{Specific names}:
11456 @multitable @columnfractions .20 .20 .20 .25
11457 @item Name            @tab Argument          @tab Return type       @tab Standard
11458 @item @code{SINH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
11459 @item @code{DSINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
11460 @end multitable
11461
11462 @item @emph{See also}:
11463 @ref{ASINH}
11464 @end table
11465
11466
11467
11468 @node SIZE
11469 @section @code{SIZE} --- Determine the size of an array
11470 @fnindex SIZE
11471 @cindex array, size
11472 @cindex array, number of elements
11473 @cindex array, count elements
11474
11475 @table @asis
11476 @item @emph{Description}:
11477 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
11478 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
11479
11480 @item @emph{Standard}:
11481 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
11482
11483 @item @emph{Class}:
11484 Inquiry function
11485
11486 @item @emph{Syntax}:
11487 @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
11488
11489 @item @emph{Arguments}:
11490 @multitable @columnfractions .15 .70
11491 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
11492 a pointer it must be associated and allocatable arrays must be allocated.
11493 @item @var{DIM}   @tab (Optional) shall be a scalar of type @code{INTEGER} 
11494 and its value shall be in the range from 1 to n, where n equals the rank 
11495 of @var{ARRAY}.
11496 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
11497 expression indicating the kind parameter of the result.
11498 @end multitable
11499
11500 @item @emph{Return value}:
11501 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11502 @var{KIND} is absent, the return value is of default integer kind.
11503
11504 @item @emph{Example}:
11505 @smallexample
11506 PROGRAM test_size
11507   WRITE(*,*) SIZE((/ 1, 2 /))    ! 2
11508 END PROGRAM
11509 @end smallexample
11510
11511 @item @emph{See also}:
11512 @ref{SHAPE}, @ref{RESHAPE}
11513 @end table
11514
11515
11516 @node SIZEOF
11517 @section @code{SIZEOF} --- Size in bytes of an expression
11518 @fnindex SIZEOF
11519 @cindex expression size
11520 @cindex size of an expression
11521
11522 @table @asis
11523 @item @emph{Description}:
11524 @code{SIZEOF(X)} calculates the number of bytes of storage the
11525 expression @code{X} occupies.
11526
11527 @item @emph{Standard}:
11528 GNU extension
11529
11530 @item @emph{Class}:
11531 Intrinsic function
11532
11533 @item @emph{Syntax}:
11534 @code{N = SIZEOF(X)}
11535
11536 @item @emph{Arguments}:
11537 @multitable @columnfractions .15 .70
11538 @item @var{X} @tab The argument shall be of any type, rank or shape.
11539 @end multitable
11540
11541 @item @emph{Return value}:
11542 The return value is of type integer and of the system-dependent kind
11543 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
11544 number of bytes occupied by the argument.  If the argument has the
11545 @code{POINTER} attribute, the number of bytes of the storage area pointed
11546 to is returned.  If the argument is of a derived type with @code{POINTER}
11547 or @code{ALLOCATABLE} components, the return value does not account for
11548 the sizes of the data pointed to by these components. If the argument is
11549 polymorphic, the size according to the declared type is returned. The argument
11550 may not be a procedure or procedure pointer.
11551
11552 @item @emph{Example}:
11553 @smallexample
11554    integer :: i
11555    real :: r, s(5)
11556    print *, (sizeof(s)/sizeof(r) == 5)
11557    end
11558 @end smallexample
11559 The example will print @code{.TRUE.} unless you are using a platform
11560 where default @code{REAL} variables are unusually padded.
11561
11562 @item @emph{See also}:
11563 @ref{C_SIZEOF}, @ref{STORAGE_SIZE}
11564 @end table
11565
11566
11567 @node SLEEP
11568 @section @code{SLEEP} --- Sleep for the specified number of seconds
11569 @fnindex SLEEP
11570 @cindex delayed execution
11571
11572 @table @asis
11573 @item @emph{Description}:
11574 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
11575
11576 @item @emph{Standard}:
11577 GNU extension
11578
11579 @item @emph{Class}:
11580 Subroutine
11581
11582 @item @emph{Syntax}:
11583 @code{CALL SLEEP(SECONDS)}
11584
11585 @item @emph{Arguments}:
11586 @multitable @columnfractions .15 .70
11587 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
11588 @end multitable
11589
11590 @item @emph{Example}:
11591 @smallexample
11592 program test_sleep
11593   call sleep(5)
11594 end
11595 @end smallexample
11596 @end table
11597
11598
11599
11600 @node SPACING
11601 @section @code{SPACING} --- Smallest distance between two numbers of a given type
11602 @fnindex SPACING
11603 @cindex real number, relative spacing
11604 @cindex floating point, relative spacing
11605
11606 @table @asis
11607 @item @emph{Description}:
11608 Determines the distance between the argument @var{X} and the nearest 
11609 adjacent number of the same type.
11610
11611 @item @emph{Standard}:
11612 Fortran 95 and later
11613
11614 @item @emph{Class}:
11615 Elemental function
11616
11617 @item @emph{Syntax}:
11618 @code{RESULT = SPACING(X)}
11619
11620 @item @emph{Arguments}:
11621 @multitable @columnfractions .15 .70
11622 @item @var{X} @tab Shall be of type @code{REAL}.
11623 @end multitable
11624
11625 @item @emph{Return value}:
11626 The result is of the same type as the input argument @var{X}.
11627
11628 @item @emph{Example}:
11629 @smallexample
11630 PROGRAM test_spacing
11631   INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
11632   INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
11633
11634   WRITE(*,*) spacing(1.0_SGL)      ! "1.1920929E-07"          on i686
11635   WRITE(*,*) spacing(1.0_DBL)      ! "2.220446049250313E-016" on i686
11636 END PROGRAM
11637 @end smallexample
11638
11639 @item @emph{See also}:
11640 @ref{RRSPACING}
11641 @end table
11642
11643
11644
11645 @node SPREAD
11646 @section @code{SPREAD} --- Add a dimension to an array
11647 @fnindex SPREAD
11648 @cindex array, increase dimension
11649 @cindex array, duplicate elements
11650 @cindex array, duplicate dimensions
11651
11652 @table @asis
11653 @item @emph{Description}:
11654 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified 
11655 dimension @var{DIM}.
11656
11657 @item @emph{Standard}:
11658 Fortran 95 and later
11659
11660 @item @emph{Class}:
11661 Transformational function
11662
11663 @item @emph{Syntax}:
11664 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
11665
11666 @item @emph{Arguments}:
11667 @multitable @columnfractions .15 .70
11668 @item @var{SOURCE}  @tab Shall be a scalar or an array of any type and 
11669 a rank less than seven.
11670 @item @var{DIM}     @tab Shall be a scalar of type @code{INTEGER} with a 
11671 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
11672 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
11673 @end multitable
11674
11675 @item @emph{Return value}:
11676 The result is an array of the same type as @var{SOURCE} and has rank n+1
11677 where n equals the rank of @var{SOURCE}.
11678
11679 @item @emph{Example}:
11680 @smallexample
11681 PROGRAM test_spread
11682   INTEGER :: a = 1, b(2) = (/ 1, 2 /)
11683   WRITE(*,*) SPREAD(A, 1, 2)            ! "1 1"
11684   WRITE(*,*) SPREAD(B, 1, 2)            ! "1 1 2 2"
11685 END PROGRAM
11686 @end smallexample
11687
11688 @item @emph{See also}:
11689 @ref{UNPACK}
11690 @end table
11691
11692
11693
11694 @node SQRT
11695 @section @code{SQRT} --- Square-root function
11696 @fnindex SQRT
11697 @fnindex DSQRT
11698 @fnindex CSQRT
11699 @fnindex ZSQRT
11700 @fnindex CDSQRT
11701 @cindex root
11702 @cindex square-root
11703
11704 @table @asis
11705 @item @emph{Description}:
11706 @code{SQRT(X)} computes the square root of @var{X}.
11707
11708 @item @emph{Standard}:
11709 Fortran 77 and later
11710
11711 @item @emph{Class}:
11712 Elemental function
11713
11714 @item @emph{Syntax}:
11715 @code{RESULT = SQRT(X)}
11716
11717 @item @emph{Arguments}:
11718 @multitable @columnfractions .15 .70
11719 @item @var{X} @tab The type shall be @code{REAL} or
11720 @code{COMPLEX}.
11721 @end multitable
11722
11723 @item @emph{Return value}:
11724 The return value is of type @code{REAL} or @code{COMPLEX}.
11725 The kind type parameter is the same as @var{X}.
11726
11727 @item @emph{Example}:
11728 @smallexample
11729 program test_sqrt
11730   real(8) :: x = 2.0_8
11731   complex :: z = (1.0, 2.0)
11732   x = sqrt(x)
11733   z = sqrt(z)
11734 end program test_sqrt
11735 @end smallexample
11736
11737 @item @emph{Specific names}:
11738 @multitable @columnfractions .20 .20 .20 .25
11739 @item Name             @tab Argument             @tab Return type          @tab Standard
11740 @item @code{SQRT(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}       @tab Fortran 95 and later
11741 @item @code{DSQRT(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}       @tab Fortran 95 and later
11742 @item @code{CSQRT(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab Fortran 95 and later
11743 @item @code{ZSQRT(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
11744 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
11745 @end multitable
11746 @end table
11747
11748
11749
11750 @node SRAND
11751 @section @code{SRAND} --- Reinitialize the random number generator
11752 @fnindex SRAND
11753 @cindex random number generation, seeding
11754 @cindex seeding a random number generator
11755
11756 @table @asis
11757 @item @emph{Description}:
11758 @code{SRAND} reinitializes the pseudo-random number generator
11759 called by @code{RAND} and @code{IRAND}. The new seed used by the
11760 generator is specified by the required argument @var{SEED}.
11761
11762 @item @emph{Standard}:
11763 GNU extension
11764
11765 @item @emph{Class}:
11766 Subroutine
11767
11768 @item @emph{Syntax}:
11769 @code{CALL SRAND(SEED)}
11770
11771 @item @emph{Arguments}:
11772 @multitable @columnfractions .15 .70
11773 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
11774 @end multitable
11775
11776 @item @emph{Return value}:
11777 Does not return anything.
11778
11779 @item @emph{Example}:
11780 See @code{RAND} and @code{IRAND} for examples.
11781
11782 @item @emph{Notes}:
11783 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
11784 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
11785 to generate pseudo-random numbers. Please note that in
11786 GNU Fortran, these two sets of intrinsics (@code{RAND},
11787 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
11788 @code{RANDOM_SEED} on the other hand) access two independent
11789 pseudo-random number generators.
11790
11791 @item @emph{See also}:
11792 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
11793
11794 @end table
11795
11796
11797
11798 @node STAT
11799 @section @code{STAT} --- Get file status
11800 @fnindex STAT
11801 @cindex file system, file status
11802
11803 @table @asis
11804 @item @emph{Description}:
11805 This function returns information about a file. No permissions are required on 
11806 the file itself, but execute (search) permission is required on all of the 
11807 directories in path that lead to the file.
11808
11809 The elements that are obtained and stored in the array @code{VALUES}:
11810 @multitable @columnfractions .15 .70
11811 @item @code{VALUES(1)}   @tab  Device ID 
11812 @item @code{VALUES(2)}   @tab  Inode number 
11813 @item @code{VALUES(3)}   @tab  File mode 
11814 @item @code{VALUES(4)}   @tab  Number of links 
11815 @item @code{VALUES(5)}   @tab  Owner's uid 
11816 @item @code{VALUES(6)}   @tab  Owner's gid 
11817 @item @code{VALUES(7)}   @tab  ID of device containing directory entry for file (0 if not available) 
11818 @item @code{VALUES(8)}   @tab  File size (bytes) 
11819 @item @code{VALUES(9)}   @tab  Last access time 
11820 @item @code{VALUES(10)}  @tab  Last modification time 
11821 @item @code{VALUES(11)}  @tab  Last file status change time 
11822 @item @code{VALUES(12)}  @tab  Preferred I/O block size (-1 if not available) 
11823 @item @code{VALUES(13)}  @tab  Number of blocks allocated (-1 if not available)
11824 @end multitable
11825
11826 Not all these elements are relevant on all systems. 
11827 If an element is not relevant, it is returned as 0.
11828
11829 This intrinsic is provided in both subroutine and function forms; however,
11830 only one form can be used in any given program unit.
11831
11832 @item @emph{Standard}:
11833 GNU extension
11834
11835 @item @emph{Class}:
11836 Subroutine, function
11837
11838 @item @emph{Syntax}:
11839 @multitable @columnfractions .80
11840 @item @code{CALL STAT(NAME, VALUES [, STATUS])}
11841 @item @code{STATUS = STAT(NAME, VALUES)}
11842 @end multitable
11843
11844 @item @emph{Arguments}:
11845 @multitable @columnfractions .15 .70
11846 @item @var{NAME}   @tab The type shall be @code{CHARACTER}, of the
11847 default kind and a valid path within the file system.
11848 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
11849 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
11850 on success and a system specific error code otherwise.
11851 @end multitable
11852
11853 @item @emph{Example}:
11854 @smallexample
11855 PROGRAM test_stat
11856   INTEGER, DIMENSION(13) :: buff
11857   INTEGER :: status
11858
11859   CALL STAT("/etc/passwd", buff, status)
11860
11861   IF (status == 0) THEN
11862     WRITE (*, FMT="('Device ID:',               T30, I19)") buff(1)
11863     WRITE (*, FMT="('Inode number:',            T30, I19)") buff(2)
11864     WRITE (*, FMT="('File mode (octal):',       T30, O19)") buff(3)
11865     WRITE (*, FMT="('Number of links:',         T30, I19)") buff(4)
11866     WRITE (*, FMT="('Owner''s uid:',            T30, I19)") buff(5)
11867     WRITE (*, FMT="('Owner''s gid:',            T30, I19)") buff(6)
11868     WRITE (*, FMT="('Device where located:',    T30, I19)") buff(7)
11869     WRITE (*, FMT="('File size:',               T30, I19)") buff(8)
11870     WRITE (*, FMT="('Last access time:',        T30, A19)") CTIME(buff(9))
11871     WRITE (*, FMT="('Last modification time',   T30, A19)") CTIME(buff(10))
11872     WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
11873     WRITE (*, FMT="('Preferred block size:',    T30, I19)") buff(12)
11874     WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
11875   END IF
11876 END PROGRAM
11877 @end smallexample
11878
11879 @item @emph{See also}:
11880 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
11881 @end table
11882
11883
11884
11885 @node STORAGE_SIZE
11886 @section @code{STORAGE_SIZE} --- Storage size in bits
11887 @fnindex STORAGE_SIZE
11888 @cindex storage size
11889
11890 @table @asis
11891 @item @emph{Description}:
11892 Returns the storage size of argument @var{A} in bits.
11893 @item @emph{Standard}:
11894 Fortran 2008 and later
11895 @item @emph{Class}:
11896 Inquiry function
11897 @item @emph{Syntax}:
11898 @code{RESULT = STORAGE_SIZE(A [, KIND])}
11899
11900 @item @emph{Arguments}:
11901 @multitable @columnfractions .15 .70
11902 @item @var{A} @tab Shall be a scalar or array of any type.
11903 @item @var{KIND} @tab (Optional) shall be a scalar integer constant expression.
11904 @end multitable
11905
11906 @item @emph{Return Value}:
11907 The result is a scalar integer with the kind type parameter specified by KIND
11908 (or default integer type if KIND is missing). The result value is the size
11909 expressed in bits for an element of an array that has the dynamic type and type
11910 parameters of A.
11911
11912 @item @emph{See also}:
11913 @ref{C_SIZEOF}, @ref{SIZEOF}
11914 @end table
11915
11916
11917
11918 @node SUM
11919 @section @code{SUM} --- Sum of array elements
11920 @fnindex SUM
11921 @cindex array, sum
11922 @cindex array, add elements
11923 @cindex array, conditionally add elements
11924 @cindex sum array elements
11925
11926 @table @asis
11927 @item @emph{Description}:
11928 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
11929 the corresponding element in @var{MASK} is @code{TRUE}.
11930
11931 @item @emph{Standard}:
11932 Fortran 95 and later
11933
11934 @item @emph{Class}:
11935 Transformational function
11936
11937 @item @emph{Syntax}:
11938 @multitable @columnfractions .80
11939 @item @code{RESULT = SUM(ARRAY[, MASK])}
11940 @item @code{RESULT = SUM(ARRAY, DIM[, MASK])}
11941 @end multitable
11942
11943 @item @emph{Arguments}:
11944 @multitable @columnfractions .15 .70
11945 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
11946 @code{REAL} or @code{COMPLEX}.
11947 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
11948 @code{INTEGER} with a value in the range from 1 to n, where n 
11949 equals the rank of @var{ARRAY}.
11950 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
11951 and either be a scalar or an array of the same shape as @var{ARRAY}.
11952 @end multitable
11953
11954 @item @emph{Return value}:
11955 The result is of the same type as @var{ARRAY}.
11956
11957 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
11958 is returned. Otherwise, an array of rank n-1, where n equals the rank of 
11959 @var{ARRAY}, and a shape similar to that of @var{ARRAY} with dimension @var{DIM} 
11960 dropped is returned.
11961
11962 @item @emph{Example}:
11963 @smallexample
11964 PROGRAM test_sum
11965   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
11966   print *, SUM(x)                        ! all elements, sum = 15
11967   print *, SUM(x, MASK=MOD(x, 2)==1)     ! odd elements, sum = 9
11968 END PROGRAM
11969 @end smallexample
11970
11971 @item @emph{See also}:
11972 @ref{PRODUCT}
11973 @end table
11974
11975
11976
11977 @node SYMLNK
11978 @section @code{SYMLNK} --- Create a symbolic link
11979 @fnindex SYMLNK
11980 @cindex file system, create link
11981 @cindex file system, soft link
11982
11983 @table @asis
11984 @item @emph{Description}:
11985 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
11986 character (@code{CHAR(0)}) can be used to mark the end of the names in
11987 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
11988 names are ignored.  If the @var{STATUS} argument is supplied, it
11989 contains 0 on success or a nonzero error code upon return; see
11990 @code{symlink(2)}.  If the system does not supply @code{symlink(2)}, 
11991 @code{ENOSYS} is returned.
11992
11993 This intrinsic is provided in both subroutine and function forms;
11994 however, only one form can be used in any given program unit.
11995
11996 @item @emph{Standard}:
11997 GNU extension
11998
11999 @item @emph{Class}:
12000 Subroutine, function
12001
12002 @item @emph{Syntax}:
12003 @multitable @columnfractions .80
12004 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
12005 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
12006 @end multitable
12007
12008 @item @emph{Arguments}:
12009 @multitable @columnfractions .15 .70
12010 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
12011 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
12012 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
12013 @end multitable
12014
12015 @item @emph{See also}:
12016 @ref{LINK}, @ref{UNLINK}
12017
12018 @end table
12019
12020
12021
12022 @node SYSTEM
12023 @section @code{SYSTEM} --- Execute a shell command
12024 @fnindex SYSTEM
12025 @cindex system, system call
12026
12027 @table @asis
12028 @item @emph{Description}:
12029 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
12030 argument @var{STATUS} is present, it contains the value returned by
12031 @code{system(3)}, which is presumably 0 if the shell command succeeded.
12032 Note that which shell is used to invoke the command is system-dependent
12033 and environment-dependent.
12034
12035 This intrinsic is provided in both subroutine and function forms;
12036 however, only one form can be used in any given program unit.
12037
12038 Note that the @code{system} function need not be thread-safe. It is
12039 the responsibility of the user to ensure that @code{system} is not
12040 called concurrently.
12041
12042 @item @emph{Standard}:
12043 GNU extension
12044
12045 @item @emph{Class}:
12046 Subroutine, function
12047
12048 @item @emph{Syntax}:
12049 @multitable @columnfractions .80
12050 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
12051 @item @code{STATUS = SYSTEM(COMMAND)}
12052 @end multitable
12053
12054 @item @emph{Arguments}:
12055 @multitable @columnfractions .15 .70
12056 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
12057 @item @var{STATUS}  @tab (Optional) Shall be of default @code{INTEGER} type.
12058 @end multitable
12059
12060 @item @emph{See also}:
12061 @ref{EXECUTE_COMMAND_LINE}, which is part of the Fortran 2008 standard
12062 and should considered in new code for future portability.
12063 @end table
12064
12065
12066
12067 @node SYSTEM_CLOCK
12068 @section @code{SYSTEM_CLOCK} --- Time function
12069 @fnindex SYSTEM_CLOCK
12070 @cindex time, clock ticks
12071 @cindex clock ticks
12072
12073 @table @asis
12074 @item @emph{Description}:
12075 Determines the @var{COUNT} of a processor clock since an unspecified
12076 time in the past modulo @var{COUNT_MAX}, @var{COUNT_RATE} determines
12077 the number of clock ticks per second.  If the platform supports a high
12078 resolution monotonic clock, that clock is used and can provide up to
12079 nanosecond resolution.  If a high resolution monotonic clock is not
12080 available, the implementation falls back to a potentially lower
12081 resolution realtime clock.
12082
12083 @var{COUNT_RATE} is system dependent and can vary depending on the kind of the
12084 arguments. For @var{kind=4} arguments, @var{COUNT} usually represents
12085 milliseconds, while for @var{kind=8} arguments, @var{COUNT} typically
12086 represents micro- or nanoseconds. @var{COUNT_MAX} usually equals
12087 @code{HUGE(COUNT_MAX)}.
12088
12089 If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and
12090 @var{COUNT_RATE} and @var{COUNT_MAX} are set to zero.
12091
12092 When running on a platform using the GNU C library (glibc), or a
12093 derivative thereof, the high resolution monotonic clock is available
12094 only when linking with the @var{rt} library.  This can be done
12095 explicitly by adding the @code{-lrt} flag when linking the
12096 application, but is also done implicitly when using OpenMP.
12097
12098 @item @emph{Standard}:
12099 Fortran 95 and later
12100
12101 @item @emph{Class}:
12102 Subroutine
12103
12104 @item @emph{Syntax}:
12105 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
12106
12107 @item @emph{Arguments}:
12108 @multitable @columnfractions .15 .70
12109 @item @var{COUNT}      @tab (Optional) shall be a scalar of type 
12110 @code{INTEGER} with @code{INTENT(OUT)}.
12111 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type 
12112 @code{INTEGER} with @code{INTENT(OUT)}.
12113 @item @var{COUNT_MAX}  @tab (Optional) shall be a scalar of type 
12114 @code{INTEGER} with @code{INTENT(OUT)}.
12115 @end multitable
12116
12117 @item @emph{Example}:
12118 @smallexample
12119 PROGRAM test_system_clock
12120   INTEGER :: count, count_rate, count_max
12121   CALL SYSTEM_CLOCK(count, count_rate, count_max)
12122   WRITE(*,*) count, count_rate, count_max
12123 END PROGRAM
12124 @end smallexample
12125
12126 @item @emph{See also}:
12127 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
12128 @end table
12129
12130
12131
12132 @node TAN
12133 @section @code{TAN} --- Tangent function
12134 @fnindex TAN
12135 @fnindex DTAN
12136 @cindex trigonometric function, tangent
12137 @cindex tangent
12138
12139 @table @asis
12140 @item @emph{Description}:
12141 @code{TAN(X)} computes the tangent of @var{X}.
12142
12143 @item @emph{Standard}:
12144 Fortran 77 and later, for a complex argument Fortran 2008 or later
12145
12146 @item @emph{Class}:
12147 Elemental function
12148
12149 @item @emph{Syntax}:
12150 @code{RESULT = TAN(X)}
12151
12152 @item @emph{Arguments}:
12153 @multitable @columnfractions .15 .70
12154 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
12155 @end multitable
12156
12157 @item @emph{Return value}:
12158 The return value has same type and kind as @var{X}.
12159
12160 @item @emph{Example}:
12161 @smallexample
12162 program test_tan
12163   real(8) :: x = 0.165_8
12164   x = tan(x)
12165 end program test_tan
12166 @end smallexample
12167
12168 @item @emph{Specific names}:
12169 @multitable @columnfractions .20 .20 .20 .25
12170 @item Name            @tab Argument          @tab Return type     @tab Standard
12171 @item @code{TAN(X)}   @tab @code{REAL(4) X}  @tab @code{REAL(4)}  @tab Fortran 95 and later
12172 @item @code{DTAN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}  @tab Fortran 95 and later
12173 @end multitable
12174
12175 @item @emph{See also}:
12176 @ref{ATAN}
12177 @end table
12178
12179
12180
12181 @node TANH
12182 @section @code{TANH} --- Hyperbolic tangent function 
12183 @fnindex TANH
12184 @fnindex DTANH
12185 @cindex hyperbolic tangent
12186 @cindex hyperbolic function, tangent
12187 @cindex tangent, hyperbolic
12188
12189 @table @asis
12190 @item @emph{Description}:
12191 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
12192
12193 @item @emph{Standard}:
12194 Fortran 77 and later, for a complex argument Fortran 2008 or later
12195
12196 @item @emph{Class}:
12197 Elemental function
12198
12199 @item @emph{Syntax}:
12200 @code{X = TANH(X)}
12201
12202 @item @emph{Arguments}:
12203 @multitable @columnfractions .15 .70
12204 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
12205 @end multitable
12206
12207 @item @emph{Return value}:
12208 The return value has same type and kind as @var{X}. If @var{X} is
12209 complex, the imaginary part of the result is in radians. If @var{X}
12210 is @code{REAL}, the return value lies in the range
12211 @math{ - 1 \leq tanh(x) \leq 1 }.
12212
12213 @item @emph{Example}:
12214 @smallexample
12215 program test_tanh
12216   real(8) :: x = 2.1_8
12217   x = tanh(x)
12218 end program test_tanh
12219 @end smallexample
12220
12221 @item @emph{Specific names}:
12222 @multitable @columnfractions .20 .20 .20 .25
12223 @item Name            @tab Argument          @tab Return type       @tab Standard
12224 @item @code{TANH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
12225 @item @code{DTANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
12226 @end multitable
12227
12228 @item @emph{See also}:
12229 @ref{ATANH}
12230 @end table
12231
12232
12233
12234 @node THIS_IMAGE
12235 @section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image
12236 @fnindex THIS_IMAGE
12237 @cindex coarray, @code{THIS_IMAGE}
12238 @cindex images, index of this image
12239
12240 @table @asis
12241 @item @emph{Description}:
12242 Returns the cosubscript for this image.
12243
12244 @item @emph{Standard}:
12245 Fortran 2008 and later
12246
12247 @item @emph{Class}:
12248 Transformational function
12249
12250 @item @emph{Syntax}:
12251 @multitable @columnfractions .80
12252 @item @code{RESULT = THIS_IMAGE()}
12253 @item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])}
12254 @end multitable
12255
12256 @item @emph{Arguments}:
12257 @multitable @columnfractions .15 .70
12258 @item @var{COARRAY} @tab Coarray of any type  (optional; if @var{DIM}
12259 present, required).
12260 @item @var{DIM}     @tab default integer scalar (optional). If present,
12261 @var{DIM} shall be between one and the corank of @var{COARRAY}.
12262 @end multitable
12263
12264
12265 @item @emph{Return value}:
12266 Default integer. If @var{COARRAY} is not present, it is scalar and its value
12267 is the index of the invoking image. Otherwise, if @var{DIM} is not present,
12268 a rank-1 array with corank elements is returned, containing the cosubscripts
12269 for @var{COARRAY} specifying the invoking image. If @var{DIM} is present,
12270 a scalar is returned, with the value of the @var{DIM} element of
12271 @code{THIS_IMAGE(COARRAY)}.
12272
12273 @item @emph{Example}:
12274 @smallexample
12275 INTEGER :: value[*]
12276 INTEGER :: i
12277 value = THIS_IMAGE()
12278 SYNC ALL
12279 IF (THIS_IMAGE() == 1) THEN
12280   DO i = 1, NUM_IMAGES()
12281     WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
12282   END DO
12283 END IF
12284 @end smallexample
12285
12286 @item @emph{See also}:
12287 @ref{NUM_IMAGES}, @ref{IMAGE_INDEX}
12288 @end table
12289
12290
12291
12292 @node TIME
12293 @section @code{TIME} --- Time function
12294 @fnindex TIME
12295 @cindex time, current
12296 @cindex current time
12297
12298 @table @asis
12299 @item @emph{Description}:
12300 Returns the current time encoded as an integer (in the manner of the
12301 function @code{time(3)} in the C standard library). This value is
12302 suitable for passing to @code{CTIME}, @code{GMTIME}, and @code{LTIME}.
12303
12304 This intrinsic is not fully portable, such as to systems with 32-bit
12305 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
12306 the values returned by this intrinsic might be, or become, negative, or
12307 numerically less than previous values, during a single run of the
12308 compiled program.
12309
12310 See @ref{TIME8}, for information on a similar intrinsic that might be
12311 portable to more GNU Fortran implementations, though to fewer Fortran
12312 compilers.
12313
12314 @item @emph{Standard}:
12315 GNU extension
12316
12317 @item @emph{Class}:
12318 Function
12319
12320 @item @emph{Syntax}:
12321 @code{RESULT = TIME()}
12322
12323 @item @emph{Return value}:
12324 The return value is a scalar of type @code{INTEGER(4)}.
12325
12326 @item @emph{See also}:
12327 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
12328
12329 @end table
12330
12331
12332
12333 @node TIME8
12334 @section @code{TIME8} --- Time function (64-bit)
12335 @fnindex TIME8
12336 @cindex time, current
12337 @cindex current time
12338
12339 @table @asis
12340 @item @emph{Description}:
12341 Returns the current time encoded as an integer (in the manner of the
12342 function @code{time(3)} in the C standard library). This value is
12343 suitable for passing to @code{CTIME}, @code{GMTIME}, and @code{LTIME}.
12344
12345 @emph{Warning:} this intrinsic does not increase the range of the timing
12346 values over that returned by @code{time(3)}. On a system with a 32-bit
12347 @code{time(3)}, @code{TIME8} will return a 32-bit value, even though
12348 it is converted to a 64-bit @code{INTEGER(8)} value. That means
12349 overflows of the 32-bit value can still occur. Therefore, the values
12350 returned by this intrinsic might be or become negative or numerically
12351 less than previous values during a single run of the compiled program.
12352
12353 @item @emph{Standard}:
12354 GNU extension
12355
12356 @item @emph{Class}:
12357 Function
12358
12359 @item @emph{Syntax}:
12360 @code{RESULT = TIME8()}
12361
12362 @item @emph{Return value}:
12363 The return value is a scalar of type @code{INTEGER(8)}.
12364
12365 @item @emph{See also}:
12366 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
12367
12368 @end table
12369
12370
12371
12372 @node TINY
12373 @section @code{TINY} --- Smallest positive number of a real kind
12374 @fnindex TINY
12375 @cindex limits, smallest number
12376 @cindex model representation, smallest number
12377
12378 @table @asis
12379 @item @emph{Description}:
12380 @code{TINY(X)} returns the smallest positive (non zero) number
12381 in the model of the type of @code{X}.
12382
12383 @item @emph{Standard}:
12384 Fortran 95 and later
12385
12386 @item @emph{Class}:
12387 Inquiry function
12388
12389 @item @emph{Syntax}:
12390 @code{RESULT = TINY(X)}
12391
12392 @item @emph{Arguments}:
12393 @multitable @columnfractions .15 .70
12394 @item @var{X} @tab Shall be of type @code{REAL}.
12395 @end multitable
12396
12397 @item @emph{Return value}:
12398 The return value is of the same type and kind as @var{X}
12399
12400 @item @emph{Example}:
12401 See @code{HUGE} for an example.
12402 @end table
12403
12404
12405
12406 @node TRAILZ
12407 @section @code{TRAILZ} --- Number of trailing zero bits of an integer
12408 @fnindex TRAILZ
12409 @cindex zero bits
12410
12411 @table @asis
12412 @item @emph{Description}:
12413 @code{TRAILZ} returns the number of trailing zero bits of an integer.
12414
12415 @item @emph{Standard}:
12416 Fortran 2008 and later
12417
12418 @item @emph{Class}:
12419 Elemental function
12420
12421 @item @emph{Syntax}:
12422 @code{RESULT = TRAILZ(I)}
12423
12424 @item @emph{Arguments}:
12425 @multitable @columnfractions .15 .70
12426 @item @var{I} @tab Shall be of type @code{INTEGER}.
12427 @end multitable
12428
12429 @item @emph{Return value}:
12430 The type of the return value is the default @code{INTEGER}.
12431 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
12432
12433 @item @emph{Example}:
12434 @smallexample
12435 PROGRAM test_trailz
12436   WRITE (*,*) TRAILZ(8)  ! prints 3
12437 END PROGRAM
12438 @end smallexample
12439
12440 @item @emph{See also}:
12441 @ref{BIT_SIZE}, @ref{LEADZ}, @ref{POPPAR}, @ref{POPCNT}
12442 @end table
12443
12444
12445
12446 @node TRANSFER
12447 @section @code{TRANSFER} --- Transfer bit patterns
12448 @fnindex TRANSFER
12449 @cindex bits, move
12450 @cindex type cast
12451
12452 @table @asis
12453 @item @emph{Description}:
12454 Interprets the bitwise representation of @var{SOURCE} in memory as if it
12455 is the representation of a variable or array of the same type and type
12456 parameters as @var{MOLD}.
12457
12458 This is approximately equivalent to the C concept of @emph{casting} one
12459 type to another.
12460
12461 @item @emph{Standard}:
12462 Fortran 95 and later
12463
12464 @item @emph{Class}:
12465 Transformational function
12466
12467 @item @emph{Syntax}:
12468 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
12469
12470 @item @emph{Arguments}:
12471 @multitable @columnfractions .15 .70
12472 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
12473 @item @var{MOLD}   @tab Shall be a scalar or an array of any type.
12474 @item @var{SIZE}   @tab (Optional) shall be a scalar of type 
12475 @code{INTEGER}.
12476 @end multitable
12477
12478 @item @emph{Return value}:
12479 The result has the same type as @var{MOLD}, with the bit level
12480 representation of @var{SOURCE}.  If @var{SIZE} is present, the result is
12481 a one-dimensional array of length @var{SIZE}.  If @var{SIZE} is absent
12482 but @var{MOLD} is an array (of any size or shape), the result is a one-
12483 dimensional array of the minimum length needed to contain the entirety
12484 of the bitwise representation of @var{SOURCE}.   If @var{SIZE} is absent
12485 and @var{MOLD} is a scalar, the result is a scalar.
12486
12487 If the bitwise representation of the result is longer than that of
12488 @var{SOURCE}, then the leading bits of the result correspond to those of
12489 @var{SOURCE} and any trailing bits are filled arbitrarily.
12490
12491 When the resulting bit representation does not correspond to a valid
12492 representation of a variable of the same type as @var{MOLD}, the results
12493 are undefined, and subsequent operations on the result cannot be
12494 guaranteed to produce sensible behavior.  For example, it is possible to
12495 create @code{LOGICAL} variables for which @code{@var{VAR}} and
12496 @code{.NOT.@var{VAR}} both appear to be true.
12497
12498 @item @emph{Example}:
12499 @smallexample
12500 PROGRAM test_transfer
12501   integer :: x = 2143289344
12502   print *, transfer(x, 1.0)    ! prints "NaN" on i686
12503 END PROGRAM
12504 @end smallexample
12505 @end table
12506
12507
12508
12509 @node TRANSPOSE
12510 @section @code{TRANSPOSE} --- Transpose an array of rank two
12511 @fnindex TRANSPOSE
12512 @cindex array, transpose
12513 @cindex matrix, transpose
12514 @cindex transpose
12515
12516 @table @asis
12517 @item @emph{Description}:
12518 Transpose an array of rank two. Element (i, j) of the result has the value 
12519 @code{MATRIX(j, i)}, for all i, j.
12520
12521 @item @emph{Standard}:
12522 Fortran 95 and later
12523
12524 @item @emph{Class}:
12525 Transformational function
12526
12527 @item @emph{Syntax}:
12528 @code{RESULT = TRANSPOSE(MATRIX)}
12529
12530 @item @emph{Arguments}:
12531 @multitable @columnfractions .15 .70
12532 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
12533 @end multitable
12534
12535 @item @emph{Return value}:
12536 The result has the same type as @var{MATRIX}, and has shape 
12537 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
12538 @end table
12539
12540
12541
12542 @node TRIM
12543 @section @code{TRIM} --- Remove trailing blank characters of a string
12544 @fnindex TRIM
12545 @cindex string, remove trailing whitespace
12546
12547 @table @asis
12548 @item @emph{Description}:
12549 Removes trailing blank characters of a string.
12550
12551 @item @emph{Standard}:
12552 Fortran 95 and later
12553
12554 @item @emph{Class}:
12555 Transformational function
12556
12557 @item @emph{Syntax}:
12558 @code{RESULT = TRIM(STRING)}
12559
12560 @item @emph{Arguments}:
12561 @multitable @columnfractions .15 .70
12562 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
12563 @end multitable
12564
12565 @item @emph{Return value}:
12566 A scalar of type @code{CHARACTER} which length is that of @var{STRING}
12567 less the number of trailing blanks.
12568
12569 @item @emph{Example}:
12570 @smallexample
12571 PROGRAM test_trim
12572   CHARACTER(len=10), PARAMETER :: s = "GFORTRAN  "
12573   WRITE(*,*) LEN(s), LEN(TRIM(s))  ! "10 8", with/without trailing blanks
12574 END PROGRAM
12575 @end smallexample
12576
12577 @item @emph{See also}:
12578 @ref{ADJUSTL}, @ref{ADJUSTR}
12579 @end table
12580
12581
12582
12583 @node TTYNAM
12584 @section @code{TTYNAM} --- Get the name of a terminal device.
12585 @fnindex TTYNAM
12586 @cindex system, terminal
12587
12588 @table @asis
12589 @item @emph{Description}:
12590 Get the name of a terminal device. For more information, 
12591 see @code{ttyname(3)}.
12592
12593 This intrinsic is provided in both subroutine and function forms; 
12594 however, only one form can be used in any given program unit. 
12595
12596 @item @emph{Standard}:
12597 GNU extension
12598
12599 @item @emph{Class}:
12600 Subroutine, function
12601
12602 @item @emph{Syntax}:
12603 @multitable @columnfractions .80
12604 @item @code{CALL TTYNAM(UNIT, NAME)}
12605 @item @code{NAME = TTYNAM(UNIT)}
12606 @end multitable
12607
12608 @item @emph{Arguments}:
12609 @multitable @columnfractions .15 .70
12610 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
12611 @item @var{NAME} @tab Shall be of type @code{CHARACTER}.
12612 @end multitable
12613
12614 @item @emph{Example}:
12615 @smallexample
12616 PROGRAM test_ttynam
12617   INTEGER :: unit
12618   DO unit = 1, 10
12619     IF (isatty(unit=unit)) write(*,*) ttynam(unit)
12620   END DO
12621 END PROGRAM
12622 @end smallexample
12623
12624 @item @emph{See also}:
12625 @ref{ISATTY}
12626 @end table
12627
12628
12629
12630 @node UBOUND
12631 @section @code{UBOUND} --- Upper dimension bounds of an array
12632 @fnindex UBOUND
12633 @cindex array, upper bound
12634
12635 @table @asis
12636 @item @emph{Description}:
12637 Returns the upper bounds of an array, or a single upper bound
12638 along the @var{DIM} dimension.
12639 @item @emph{Standard}:
12640 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
12641
12642 @item @emph{Class}:
12643 Inquiry function
12644
12645 @item @emph{Syntax}:
12646 @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
12647
12648 @item @emph{Arguments}:
12649 @multitable @columnfractions .15 .70
12650 @item @var{ARRAY} @tab Shall be an array, of any type.
12651 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
12652 @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
12653 expression indicating the kind parameter of the result.
12654 @end multitable
12655
12656 @item @emph{Return value}:
12657 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12658 @var{KIND} is absent, the return value is of default integer kind.
12659 If @var{DIM} is absent, the result is an array of the upper bounds of
12660 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
12661 corresponding to the upper bound of the array along that dimension.  If
12662 @var{ARRAY} is an expression rather than a whole array or array
12663 structure component, or if it has a zero extent along the relevant
12664 dimension, the upper bound is taken to be the number of elements along
12665 the relevant dimension.
12666
12667 @item @emph{See also}:
12668 @ref{LBOUND}, @ref{LCOBOUND}
12669 @end table
12670
12671
12672
12673 @node UCOBOUND
12674 @section @code{UCOBOUND} --- Upper codimension bounds of an array
12675 @fnindex UCOBOUND
12676 @cindex coarray, upper bound
12677
12678 @table @asis
12679 @item @emph{Description}:
12680 Returns the upper cobounds of a coarray, or a single upper cobound
12681 along the @var{DIM} codimension.
12682 @item @emph{Standard}:
12683 Fortran 2008 and later
12684
12685 @item @emph{Class}:
12686 Inquiry function
12687
12688 @item @emph{Syntax}:
12689 @code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])}
12690
12691 @item @emph{Arguments}:
12692 @multitable @columnfractions .15 .70
12693 @item @var{ARRAY} @tab Shall be an coarray, of any type.
12694 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
12695 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12696 expression indicating the kind parameter of the result.
12697 @end multitable
12698
12699 @item @emph{Return value}:
12700 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12701 @var{KIND} is absent, the return value is of default integer kind.
12702 If @var{DIM} is absent, the result is an array of the lower cobounds of
12703 @var{COARRAY}.  If @var{DIM} is present, the result is a scalar
12704 corresponding to the lower cobound of the array along that codimension.
12705
12706 @item @emph{See also}:
12707 @ref{LCOBOUND}, @ref{LBOUND}
12708 @end table
12709
12710
12711
12712 @node UMASK
12713 @section @code{UMASK} --- Set the file creation mask
12714 @fnindex UMASK
12715 @cindex file system, file creation mask
12716
12717 @table @asis
12718 @item @emph{Description}:
12719 Sets the file creation mask to @var{MASK}. If called as a function, it
12720 returns the old value. If called as a subroutine and argument @var{OLD}
12721 if it is supplied, it is set to the old value. See @code{umask(2)}.
12722
12723 @item @emph{Standard}:
12724 GNU extension
12725
12726 @item @emph{Class}:
12727 Subroutine, function
12728
12729 @item @emph{Syntax}:
12730 @multitable @columnfractions .80
12731 @item @code{CALL UMASK(MASK [, OLD])}
12732 @item @code{OLD = UMASK(MASK)}
12733 @end multitable
12734
12735 @item @emph{Arguments}:
12736 @multitable @columnfractions .15 .70
12737 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
12738 @item @var{OLD} @tab (Optional) Shall be a scalar of type
12739 @code{INTEGER}.
12740 @end multitable
12741
12742 @end table
12743
12744
12745
12746 @node UNLINK
12747 @section @code{UNLINK} --- Remove a file from the file system
12748 @fnindex UNLINK
12749 @cindex file system, remove file
12750
12751 @table @asis
12752 @item @emph{Description}:
12753 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
12754 used to mark the end of the name in @var{PATH}; otherwise, trailing
12755 blanks in the file name are ignored.  If the @var{STATUS} argument is
12756 supplied, it contains 0 on success or a nonzero error code upon return;
12757 see @code{unlink(2)}.
12758
12759 This intrinsic is provided in both subroutine and function forms;
12760 however, only one form can be used in any given program unit.
12761
12762 @item @emph{Standard}:
12763 GNU extension
12764
12765 @item @emph{Class}:
12766 Subroutine, function
12767
12768 @item @emph{Syntax}:
12769 @multitable @columnfractions .80
12770 @item @code{CALL UNLINK(PATH [, STATUS])}
12771 @item @code{STATUS = UNLINK(PATH)}
12772 @end multitable
12773
12774 @item @emph{Arguments}:
12775 @multitable @columnfractions .15 .70
12776 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
12777 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
12778 @end multitable
12779
12780 @item @emph{See also}:
12781 @ref{LINK}, @ref{SYMLNK}
12782 @end table
12783
12784
12785
12786 @node UNPACK
12787 @section @code{UNPACK} --- Unpack an array of rank one into an array
12788 @fnindex UNPACK
12789 @cindex array, unpacking
12790 @cindex array, increase dimension
12791 @cindex array, scatter elements
12792
12793 @table @asis
12794 @item @emph{Description}:
12795 Store the elements of @var{VECTOR} in an array of higher rank.
12796
12797 @item @emph{Standard}:
12798 Fortran 95 and later
12799
12800 @item @emph{Class}:
12801 Transformational function
12802
12803 @item @emph{Syntax}:
12804 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
12805
12806 @item @emph{Arguments}:
12807 @multitable @columnfractions .15 .70
12808 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It 
12809 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
12810 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL}.
12811 @item @var{FIELD}  @tab Shall be of the same type as @var{VECTOR} and have
12812 the same shape as @var{MASK}.
12813 @end multitable
12814
12815 @item @emph{Return value}:
12816 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
12817 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
12818
12819 @item @emph{Example}:
12820 @smallexample
12821 PROGRAM test_unpack
12822   integer :: vector(2)  = (/1,1/)
12823   logical :: mask(4)  = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
12824   integer :: field(2,2) = 0, unity(2,2)
12825
12826   ! result: unity matrix
12827   unity = unpack(vector, reshape(mask, (/2,2/)), field)
12828 END PROGRAM
12829 @end smallexample
12830
12831 @item @emph{See also}:
12832 @ref{PACK}, @ref{SPREAD}
12833 @end table
12834
12835
12836
12837 @node VERIFY
12838 @section @code{VERIFY} --- Scan a string for characters not a given set
12839 @fnindex VERIFY
12840 @cindex string, find missing set
12841
12842 @table @asis
12843 @item @emph{Description}:
12844 Verifies that all the characters in @var{STRING} belong to the set of
12845 characters in @var{SET}.
12846
12847 If @var{BACK} is either absent or equals @code{FALSE}, this function
12848 returns the position of the leftmost character of @var{STRING} that is
12849 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost
12850 position is returned. If all characters of @var{STRING} are found in
12851 @var{SET}, the result is zero.
12852
12853 @item @emph{Standard}:
12854 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
12855
12856 @item @emph{Class}:
12857 Elemental function
12858
12859 @item @emph{Syntax}:
12860 @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
12861
12862 @item @emph{Arguments}:
12863 @multitable @columnfractions .15 .70
12864 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
12865 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
12866 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
12867 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
12868 expression indicating the kind parameter of the result.
12869 @end multitable
12870
12871 @item @emph{Return value}:
12872 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12873 @var{KIND} is absent, the return value is of default integer kind.
12874
12875 @item @emph{Example}:
12876 @smallexample
12877 PROGRAM test_verify
12878   WRITE(*,*) VERIFY("FORTRAN", "AO")           ! 1, found 'F'
12879   WRITE(*,*) VERIFY("FORTRAN", "FOO")          ! 3, found 'R'
12880   WRITE(*,*) VERIFY("FORTRAN", "C++")          ! 1, found 'F'
12881   WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.)  ! 7, found 'N'
12882   WRITE(*,*) VERIFY("FORTRAN", "FORTRAN")      ! 0' found none
12883 END PROGRAM
12884 @end smallexample
12885
12886 @item @emph{See also}:
12887 @ref{SCAN}, @ref{INDEX intrinsic}
12888 @end table
12889
12890
12891
12892 @node XOR
12893 @section @code{XOR} --- Bitwise logical exclusive OR
12894 @fnindex XOR
12895 @cindex bitwise logical exclusive or
12896 @cindex logical exclusive or, bitwise
12897
12898 @table @asis
12899 @item @emph{Description}:
12900 Bitwise logical exclusive or. 
12901
12902 This intrinsic routine is provided for backwards compatibility with 
12903 GNU Fortran 77.  For integer arguments, programmers should consider
12904 the use of the @ref{IEOR} intrinsic and for logical arguments the
12905 @code{.NEQV.} operator, which are both defined by the Fortran standard.
12906
12907 @item @emph{Standard}:
12908 GNU extension
12909
12910 @item @emph{Class}:
12911 Function
12912
12913 @item @emph{Syntax}:
12914 @code{RESULT = XOR(I, J)}
12915
12916 @item @emph{Arguments}:
12917 @multitable @columnfractions .15 .70
12918 @item @var{I} @tab The type shall be either  a scalar @code{INTEGER}
12919 type or a scalar @code{LOGICAL} type.
12920 @item @var{J} @tab The type shall be the same as the type of @var{I}.
12921 @end multitable
12922
12923 @item @emph{Return value}:
12924 The return type is either a scalar @code{INTEGER} or a scalar
12925 @code{LOGICAL}.  If the kind type parameters differ, then the
12926 smaller kind type is implicitly converted to larger kind, and the 
12927 return has the larger kind.
12928
12929 @item @emph{Example}:
12930 @smallexample
12931 PROGRAM test_xor
12932   LOGICAL :: T = .TRUE., F = .FALSE.
12933   INTEGER :: a, b
12934   DATA a / Z'F' /, b / Z'3' /
12935
12936   WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
12937   WRITE (*,*) XOR(a, b)
12938 END PROGRAM
12939 @end smallexample
12940
12941 @item @emph{See also}:
12942 Fortran 95 elemental function: @ref{IEOR}
12943 @end table
12944
12945
12946
12947 @node Intrinsic Modules
12948 @chapter Intrinsic Modules
12949 @cindex intrinsic Modules
12950
12951 @menu
12952 * ISO_FORTRAN_ENV::
12953 * ISO_C_BINDING::
12954 * OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
12955 @end menu
12956
12957 @node ISO_FORTRAN_ENV
12958 @section @code{ISO_FORTRAN_ENV}
12959 @table @asis
12960 @item @emph{Standard}:
12961 Fortran 2003 and later, except when otherwise noted
12962 @end table
12963
12964 The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
12965 named constants:
12966
12967 @table @asis
12968 @item @code{ATOMIC_INT_KIND}:
12969 Default-kind integer constant to be used as kind parameter when defining
12970 integer variables used in atomic operations. (Fortran 2008 or later.)
12971
12972 @item @code{ATOMIC_LOGICAL_KIND}:
12973 Default-kind integer constant to be used as kind parameter when defining
12974 logical variables used in atomic operations. (Fortran 2008 or later.)
12975
12976 @item @code{CHARACTER_KINDS}:
12977 Default-kind integer constant array of rank one containing the supported kind
12978 parameters of the @code{CHARACTER} type. (Fortran 2008 or later.)
12979
12980 @item @code{CHARACTER_STORAGE_SIZE}:
12981 Size in bits of the character storage unit.
12982
12983 @item @code{ERROR_UNIT}:
12984 Identifies the preconnected unit used for error reporting.
12985
12986 @item @code{FILE_STORAGE_SIZE}:
12987 Size in bits of the file-storage unit.
12988
12989 @item @code{INPUT_UNIT}:
12990 Identifies the preconnected unit identified by the asterisk
12991 (@code{*}) in @code{READ} statement.
12992
12993 @item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}:
12994 Kind type parameters to specify an INTEGER type with a storage
12995 size of 16, 32, and 64 bits. It is negative if a target platform
12996 does not support the particular kind. (Fortran 2008 or later.)
12997
12998 @item @code{INTEGER_KINDS}:
12999 Default-kind integer constant array of rank one containing the supported kind
13000 parameters of the @code{INTEGER} type. (Fortran 2008 or later.)
13001
13002 @item @code{IOSTAT_END}:
13003 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
13004 an input/output statement if an end-of-file condition occurred.
13005
13006 @item @code{IOSTAT_EOR}:
13007 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
13008 an input/output statement if an end-of-record condition occurred.
13009
13010 @item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}:
13011 Scalar default-integer constant, used by @code{INQUIRE} for the
13012 @code{IOSTAT=} specifier to denote an that a unit number identifies an
13013 internal unit. (Fortran 2008 or later.)
13014
13015 @item @code{NUMERIC_STORAGE_SIZE}:
13016 The size in bits of the numeric storage unit.
13017
13018 @item @code{LOGICAL_KINDS}:
13019 Default-kind integer constant array of rank one containing the supported kind
13020 parameters of the @code{LOGICAL} type. (Fortran 2008 or later.)
13021
13022 @item @code{OUTPUT_UNIT}:
13023 Identifies the preconnected unit identified by the asterisk
13024 (@code{*}) in @code{WRITE} statement.
13025
13026 @item @code{REAL32}, @code{REAL64}, @code{REAL128}:
13027 Kind type parameters to specify a REAL type with a storage
13028 size of 32, 64, and 128 bits. It is negative if a target platform
13029 does not support the particular kind. (Fortran 2008 or later.)
13030
13031 @item @code{REAL_KINDS}:
13032 Default-kind integer constant array of rank one containing the supported kind
13033 parameters of the @code{REAL} type. (Fortran 2008 or later.)
13034
13035 @item @code{STAT_LOCKED}:
13036 Scalar default-integer constant used as STAT= return value by @code{LOCK} to
13037 denote that the lock variable is locked by the executing image. (Fortran 2008
13038 or later.)
13039
13040 @item @code{STAT_LOCKED_OTHER_IMAGE}:
13041 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
13042 denote that the lock variable is locked by another image. (Fortran 2008 or
13043 later.)
13044
13045 @item @code{STAT_STOPPED_IMAGE}:
13046 Positive, scalar default-integer constant used as STAT= return value if the
13047 argument in the statement requires synchronisation with an image, which has
13048 initiated the termination of the execution. (Fortran 2008 or later.)
13049
13050 @item @code{STAT_UNLOCKED}:
13051 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
13052 denote that the lock variable is unlocked. (Fortran 2008 or later.)
13053 @end table
13054
13055 The module provides the following derived type:
13056
13057 @table @asis
13058 @item @code{LOCK_TYPE}:
13059 Derived type with private components to be use with the @code{LOCK} and
13060 @code{UNLOCK} statement. A variable of its type has to be always declared
13061 as coarray and may not appear in a variable-definition context.
13062 (Fortran 2008 or later.)
13063 @end table
13064
13065 The module also provides the following intrinsic procedures:
13066 @ref{COMPILER_OPTIONS} and @ref{COMPILER_VERSION}.
13067
13068
13069
13070 @node ISO_C_BINDING
13071 @section @code{ISO_C_BINDING}
13072 @table @asis
13073 @item @emph{Standard}:
13074 Fortran 2003 and later, GNU extensions
13075 @end table
13076
13077 The following intrinsic procedures are provided by the module; their
13078 definition can be found in the section Intrinsic Procedures of this
13079 manual.
13080
13081 @table @asis
13082 @item @code{C_ASSOCIATED}
13083 @item @code{C_F_POINTER}
13084 @item @code{C_F_PROCPOINTER}
13085 @item @code{C_FUNLOC}
13086 @item @code{C_LOC}
13087 @item @code{C_SIZEOF}
13088 @end table
13089 @c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
13090 @c don't really know why.
13091
13092 The @code{ISO_C_BINDING} module provides the following named constants of
13093 type default integer, which can be used as KIND type parameters.
13094
13095 In addition to the integer named constants required by the Fortran 2003 
13096 standard and @code{C_PTRDIFF_T} of TS 29113, GNU Fortran provides as an
13097 extension named constants for the 128-bit integer types supported by the
13098 C compiler: @code{C_INT128_T, C_INT_LEAST128_T, C_INT_FAST128_T}.
13099 Furthermore, if @code{__float128} is supported in C, the named constants
13100 @code{C_FLOAT128, C_FLOAT128_COMPLEX} are defined.
13101
13102 @multitable @columnfractions .15 .35 .35 .35
13103 @item Fortran Type  @tab Named constant         @tab C type                                @tab Extension
13104 @item @code{INTEGER}@tab @code{C_INT}           @tab @code{int}
13105 @item @code{INTEGER}@tab @code{C_SHORT}         @tab @code{short int}
13106 @item @code{INTEGER}@tab @code{C_LONG}          @tab @code{long int}
13107 @item @code{INTEGER}@tab @code{C_LONG_LONG}     @tab @code{long long int}
13108 @item @code{INTEGER}@tab @code{C_SIGNED_CHAR}   @tab @code{signed char}/@code{unsigned char}
13109 @item @code{INTEGER}@tab @code{C_SIZE_T}        @tab @code{size_t}
13110 @item @code{INTEGER}@tab @code{C_INT8_T}        @tab @code{int8_t}
13111 @item @code{INTEGER}@tab @code{C_INT16_T}       @tab @code{int16_t}
13112 @item @code{INTEGER}@tab @code{C_INT32_T}       @tab @code{int32_t}
13113 @item @code{INTEGER}@tab @code{C_INT64_T}       @tab @code{int64_t}
13114 @item @code{INTEGER}@tab @code{C_INT128_T}      @tab @code{int128_t}                      @tab Ext.
13115 @item @code{INTEGER}@tab @code{C_INT_LEAST8_T}  @tab @code{int_least8_t}
13116 @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
13117 @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
13118 @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
13119 @item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t}                @tab Ext.
13120 @item @code{INTEGER}@tab @code{C_INT_FAST8_T}   @tab @code{int_fast8_t}
13121 @item @code{INTEGER}@tab @code{C_INT_FAST16_T}  @tab @code{int_fast16_t}
13122 @item @code{INTEGER}@tab @code{C_INT_FAST32_T}  @tab @code{int_fast32_t}
13123 @item @code{INTEGER}@tab @code{C_INT_FAST64_T}  @tab @code{int_fast64_t}
13124 @item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t}                 @tab Ext.
13125 @item @code{INTEGER}@tab @code{C_INTMAX_T}      @tab @code{intmax_t}
13126 @item @code{INTEGER}@tab @code{C_INTPTR_T}      @tab @code{intptr_t}
13127 @item @code{INTEGER}@tab @code{C_PTRDIFF_T}     @tab @code{intptr_t}                      @tab TS 29113
13128 @item @code{REAL}   @tab @code{C_FLOAT}         @tab @code{float}
13129 @item @code{REAL}   @tab @code{C_DOUBLE}        @tab @code{double}
13130 @item @code{REAL}   @tab @code{C_LONG_DOUBLE}   @tab @code{long double}
13131 @item @code{REAL}   @tab @code{C_FLOAT128}      @tab @code{__float128}                    @tab Ext.
13132 @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
13133 @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
13134 @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
13135 @item @code{REAL}   @tab @code{C_FLOAT128_COMPLEX}   @tab @code{__float128 _Complex}      @tab Ext.
13136 @item @code{LOGICAL}@tab @code{C_BOOL}          @tab @code{_Bool}
13137 @item @code{CHARACTER}@tab @code{C_CHAR}        @tab @code{char}
13138 @end multitable
13139
13140 Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)}
13141 are defined.
13142
13143 @multitable @columnfractions .20 .45 .15
13144 @item Name                     @tab C definition    @tab Value
13145 @item @code{C_NULL_CHAR}       @tab null character  @tab @code{'\0'}
13146 @item @code{C_ALERT}           @tab alert           @tab @code{'\a'}
13147 @item @code{C_BACKSPACE}       @tab backspace       @tab @code{'\b'}
13148 @item @code{C_FORM_FEED}       @tab form feed       @tab @code{'\f'}
13149 @item @code{C_NEW_LINE}        @tab new line        @tab @code{'\n'}
13150 @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
13151 @item @code{C_HORIZONTAL_TAB}  @tab horizontal tab  @tab @code{'\t'}
13152 @item @code{C_VERTICAL_TAB}    @tab vertical tab    @tab @code{'\v'}
13153 @end multitable
13154
13155 Moreover, the following two named constants are defined:
13156
13157 @multitable @columnfractions .20 .80
13158 @item Name                 @tab Type
13159 @item @code{C_NULL_PTR}    @tab @code{C_PTR}
13160 @item @code{C_NULL_FUNPTR} @tab @code{C_FUNPTR}
13161 @end multitable
13162
13163 Both are equivalent to the value @code{NULL} in C.
13164
13165 @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
13166 @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
13167 @table @asis
13168 @item @emph{Standard}:
13169 OpenMP Application Program Interface v3.1
13170 @end table
13171
13172
13173 The OpenMP Fortran runtime library routines are provided both in
13174 a form of two Fortran 90 modules, named @code{OMP_LIB} and 
13175 @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
13176 @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
13177 in the @ref{Top,,Introduction,libgomp,GNU OpenMP runtime library} manual,
13178 the named constants defined in the modules are listed
13179 below.
13180
13181 For details refer to the actual
13182 @uref{http://www.openmp.org/mp-documents/spec31.pdf,
13183 OpenMP Application Program Interface v3.1}.
13184
13185 @code{OMP_LIB_KINDS} provides the following scalar default-integer
13186 named constants:
13187
13188 @table @asis
13189 @item @code{omp_lock_kind}
13190 @item @code{omp_nest_lock_kind}
13191 @item @code{omp_sched_kind}
13192 @end table
13193
13194 @code{OMP_LIB} provides the scalar default-integer
13195 named constant @code{openmp_version} with a value of the form
13196 @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
13197 of the OpenMP version; for OpenMP v3.1 the value is @code{201107}.
13198
13199 And the following scalar integer named constants of the
13200 kind @code{omp_sched_kind}:
13201
13202 @table @asis
13203 @item @code{omp_sched_static}
13204 @item @code{omp_sched_dynamic}
13205 @item @code{omp_sched_guided}
13206 @item @code{omp_sched_auto}
13207 @end table