OSDN Git Service

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