OSDN Git Service

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