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