OSDN Git Service

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