* match.c (gfc_match_name): Expanded comment.
[official-gcc.git] / gcc / fortran / intrinsic.texi
blob26244b505ad40584fddd85cb7880b98776eea0a2
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.
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.
16 Some basic guidelines for editing this document:
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.
25 @end ignore
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
37 @node Intrinsic Procedures
38 @chapter Intrinsic Procedures
39 @cindex intrinsic procedures
41 This portion of the document is incomplete and undergoing massive expansion 
42 and editing.  All contributions and corrections are strongly encouraged. 
44 Implemented intrinsics are fully functional and available to the user to apply. 
45 Some intrinsics have documentation yet to be completed as indicated by 'documentation pending'.
47 @comment Missing intrinsics (double check with #19292)
48 @comment  - MClock
49 @comment  - Short
51 @menu
52 * Introduction:         Introduction to Intrinsics
53 * @code{ABORT}:         ABORT,     Abort the program     
54 * @code{ABS}:           ABS,       Absolute value     
55 * @code{ACCESS}:        ACCESS,    Checks file access modes
56 * @code{ACHAR}:         ACHAR,     Character in @acronym{ASCII} collating sequence
57 * @code{ACOS}:          ACOS,      Arccosine function
58 * @code{ACOSH}:         ACOSH,     Hyperbolic arccosine function
59 * @code{ADJUSTL}:       ADJUSTL,   Left adjust a string
60 * @code{ADJUSTR}:       ADJUSTR,   Right adjust a string
61 * @code{AIMAG}:         AIMAG,     Imaginary part of complex number
62 * @code{AINT}:          AINT,      Truncate to a whole number
63 * @code{ALARM}:         ALARM,     Set an alarm clock
64 * @code{ALL}:           ALL,       Determine if all values are true
65 * @code{ALLOCATED}:     ALLOCATED, Status of allocatable entity
66 * @code{AND}:           AND,       Bitwise logical AND
67 * @code{ANINT}:         ANINT,     Nearest whole number
68 * @code{ANY}:           ANY,       Determine if any values are true
69 * @code{ASIN}:          ASIN,      Arcsine function
70 * @code{ASINH}:         ASINH,     Hyperbolic arcsine function
71 * @code{ASSOCIATED}:    ASSOCIATED, Status of a pointer or pointer/target pair
72 * @code{ATAN}:          ATAN,      Arctangent function
73 * @code{ATAN2}:         ATAN2,     Arctangent function
74 * @code{ATANH}:         ATANH,     Hyperbolic arctangent function
75 * @code{BESJ0}:         BESJ0,     Bessel function of the first kind of order 0
76 * @code{BESJ1}:         BESJ1,     Bessel function of the first kind of order 1
77 * @code{BESJN}:         BESJN,     Bessel function of the first kind
78 * @code{BESY0}:         BESY0,     Bessel function of the second kind of order 0
79 * @code{BESY1}:         BESY1,     Bessel function of the second kind of order 1
80 * @code{BESYN}:         BESYN,     Bessel function of the second kind
81 * @code{BIT_SIZE}:      BIT_SIZE,  Bit size inquiry function
82 * @code{BTEST}:         BTEST,     Bit test function
83 * @code{CEILING}:       CEILING,   Integer ceiling function
84 * @code{CHAR}:          CHAR,      Integer-to-character conversion function
85 * @code{CHDIR}:         CHDIR,     Change working directory
86 * @code{CHMOD}:         CHMOD,     Change access permissions of files
87 * @code{CMPLX}:         CMPLX,     Complex conversion function
88 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
89 * @code{CONJG}:         CONJG,     Complex conjugate function
90 * @code{COS}:           COS,       Cosine function
91 * @code{COSH}:          COSH,      Hyperbolic cosine function
92 * @code{COUNT}:         COUNT,     Count occurrences of TRUE in an array
93 * @code{CPU_TIME}:      CPU_TIME,  CPU time subroutine
94 * @code{CSHIFT}:        CSHIFT,    Circular array shift function
95 * @code{CTIME}:         CTIME,     Subroutine (or function) to convert a time into a string
96 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
97 * @code{DBLE}:          DBLE,      Double precision conversion function
98 * @code{DCMPLX}:        DCMPLX,    Double complex conversion function
99 * @code{DFLOAT}:        DFLOAT,    Double precision conversion function
100 * @code{DIGITS}:        DIGITS,    Significant digits function
101 * @code{DIM}:           DIM,       Dim function
102 * @code{DOT_PRODUCT}:   DOT_PRODUCT, Dot product function
103 * @code{DPROD}:         DPROD,     Double product function
104 * @code{DREAL}:         DREAL,     Double real part function
105 * @code{DTIME}:         DTIME,     Execution time subroutine (or function)
106 * @code{EOSHIFT}:       EOSHIFT,   End-off shift function
107 * @code{EPSILON}:       EPSILON,   Epsilon function
108 * @code{ERF}:           ERF,       Error function
109 * @code{ERFC}:          ERFC,      Complementary error function
110 * @code{ETIME}:         ETIME,     Execution time subroutine (or function)
111 * @code{EXIT}:          EXIT,      Exit the program with status.
112 * @code{EXP}:           EXP,       Exponential function
113 * @code{EXPONENT}:      EXPONENT,  Exponent function
114 * @code{FDATE}:         FDATE,     Subroutine (or function) to get the current time as a string
115 * @code{FGET}:          FGET,      Read a single character in stream mode from stdin
116 * @code{FGETC}:         FGETC,     Read a single character in stream mode
117 * @code{FLOAT}:         FLOAT,     Convert integer to default real
118 * @code{FLOOR}:         FLOOR,     Integer floor function
119 * @code{FLUSH}:         FLUSH,     Flush I/O unit(s)
120 * @code{FNUM}:          FNUM,      File number function
121 * @code{FPUT}:          FPUT,      Write a single character in stream mode to stdout
122 * @code{FPUTC}:         FPUTC,     Write a single character in stream mode
123 * @code{FRACTION}:      FRACTION,  Fractional part of the model representation
124 * @code{FREE}:          FREE,      Memory de-allocation subroutine
125 * @code{FSEEK}:         FSEEK,     Low level file positioning subroutine
126 * @code{FSTAT}:         FSTAT,     Get file status
127 * @code{FTELL}:         FTELL,     Current stream position
128 * @code{GETARG}:        GETARG,    Get command line arguments
129 * @code{GET_COMMAND}:   GET_COMMAND, Get the entire command line
130 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
131 * @code{GETCWD}:        GETCWD,    Get current working directory
132 * @code{GETENV}:        GETENV,    Get an environmental variable
133 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
134 * @code{GETGID}:        GETGID,    Group ID function
135 * @code{GETLOG}:        GETLOG,    Get login name
136 * @code{GETPID}:        GETPID,    Process ID function
137 * @code{GETUID}:        GETUID,    User ID function
138 * @code{GMTIME}:        GMTIME,    Convert time to GMT info
139 * @code{HOSTNM}:        HOSTNM,    Get system host name
140 * @code{HUGE}:          HUGE,      Largest number of a kind
141 * @code{IACHAR}:        IACHAR,    Code in @acronym{ASCII} collating sequence
142 * @code{IAND}:          IAND,      Bitwise logical and
143 * @code{IARGC}:         IARGC,     Get the number of command line arguments
144 * @code{IBCLR}:         IBCLR,     Clear bit
145 * @code{IBITS}:         IBITS,     Bit extraction
146 * @code{IBSET}:         IBSET,     Set bit
147 * @code{ICHAR}:         ICHAR,     Character-to-integer conversion function
148 * @code{IDATE}:         IDATE,     Current local time (day/month/year)
149 * @code{IEOR}:          IEOR,      Bitwise logical exclusive or
150 * @code{IERRNO}:        IERRNO,    Function to get the last system error number
151 * @code{INDEX}:         INDEX,     Position of a substring within a string
152 * @code{INT}:           INT,       Convert to integer type
153 * @code{IOR}:           IOR,       Bitwise logical or
154 * @code{IRAND}:         IRAND,     Integer pseudo-random number
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{LSHIFT}:        LSHIFT,    Left shift bits
174 * @code{LSTAT}:         LSTAT,     Get file status
175 * @code{LTIME}:         LTIME,     Convert time to local time info
176 * @code{MALLOC}:        MALLOC,    Dynamic memory allocation function
177 * @code{MATMUL}:        MATMUL,    matrix multiplication
178 * @code{MAX}:           MAX,       Maximum value of an argument list
179 * @code{MAXEXPONENT}:   MAXEXPONENT, Maximum exponent of a real kind
180 * @code{MAXLOC}:        MAXLOC,    Location of the maximum value within an array
181 * @code{MAXVAL}:        MAXVAL,    Maximum value of an array
182 * @code{MERGE}:         MERGE,     Merge arrays
183 * @code{MIN}:           MIN,       Minimum value of an argument list
184 * @code{MINEXPONENT}:   MINEXPONENT, Minimum exponent of a real kind
185 * @code{MINLOC}:        MINLOC,    Location of the minimum value within an array
186 * @code{MINVAL}:        MINVAL,    Minimum value of an array
187 * @code{MOD}:           MOD,       Remainder function
188 * @code{MODULO}:        MODULO,    Modulo function
189 * @code{MOVE_ALLOC}:    MOVE_ALLOC, Move allocation from one object to another
190 * @code{MVBITS}:        MVBITS,    Move bits from one integer to another
191 * @code{NEAREST}:       NEAREST,   Nearest representable number
192 * @code{NEW_LINE}:      NEW_LINE,  New line character
193 * @code{NINT}:          NINT,      Nearest whole number
194 * @code{NOT}:           NOT,       Logical negation
195 * @code{NULL}:          NULL,      Function that returns an disassociated pointer
196 * @code{OR}:            OR,        Bitwise logical OR
197 * @code{PACK}:          PACK,      Pack an array into an array of rank one
198 * @code{PERROR}:        PERROR,    Print system error message
199 * @code{PRECISION}:     PRECISION, Decimal precision of a real kind
200 * @code{PRESENT}:       PRESENT,   Determine whether an optional argument is specified
201 * @code{PRODUCT}:       PRODUCT,   Product of array elements
202 * @code{RADIX}:         RADIX,     Base of a data model
203 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
204 * @code{RANDOM_SEED}:   RANDOM_SEED, Initialize a pseudo-random number sequence
205 * @code{RAND}:          RAND,      Real pseudo-random number
206 * @code{RANGE}:         RANGE,     Decimal exponent range of a real kind
207 * @code{RAN}:           RAN,       Real pseudo-random number
208 * @code{REAL}:          REAL,      Convert to real type 
209 * @code{RENAME}:        RENAME,    Rename a file
210 * @code{REPEAT}:        REPEAT,    Repeated string concatenation
211 * @code{RESHAPE}:       RESHAPE,   Function to reshape an array
212 * @code{RRSPACING}:     RRSPACING, Reciprocal of the relative spacing
213 * @code{RSHIFT}:        RSHIFT,    Right shift bits
214 * @code{SCALE}:         SCALE,     Scale a real value
215 * @code{SCAN}:          SCAN,      Scan a string for the presence of a set of characters
216 * @code{SECNDS}:        SECNDS,    Time function
217 @comment * @code{SECOND}:        SECOND,    (?)
218 @comment * @code{SECONDS}:       SECONDS,   (?)
219 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND,  Choose integer kind
220 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND,  Choose real kind
221 * @code{SET_EXPONENT}:  SET_EXPONENT, Set the exponent of the model
222 * @code{SHAPE}:         SHAPE,     Determine the shape of an array
223 * @code{SIGN}:          SIGN,      Sign copying function
224 * @code{SIGNAL}:        SIGNAL,    Signal handling subroutine (or function)
225 * @code{SIN}:           SIN,       Sine function
226 * @code{SINH}:          SINH,      Hyperbolic sine function
227 * @code{SIZE}:          SIZE,      Function to determine the size of an array
228 * @code{SLEEP}:         SLEEP,     Sleep for the specified number of seconds
229 * @code{SNGL}:          SNGL,      Convert double precision real to default real
230 * @code{SPACING}:       SPACING,   Smallest distance between two numbers of a given type
231 * @code{SPREAD}:        SPREAD,    Add a dimension to an array 
232 * @code{SQRT}:          SQRT,      Square-root function
233 * @code{SRAND}:         SRAND,     Reinitialize the random number generator
234 * @code{STAT}:          STAT,      Get file status
235 * @code{SUM}:           SUM,       Sum of array elements
236 * @code{SYMLNK}:        SYMLNK,    Create a symbolic link
237 * @code{SYSTEM}:        SYSTEM,    Execute a shell command
238 * @code{SYSTEM_CLOCK}:  SYSTEM_CLOCK, Time function
239 * @code{TAN}:           TAN,       Tangent function
240 * @code{TANH}:          TANH,      Hyperbolic tangent function
241 * @code{TIME}:          TIME,      Time function
242 * @code{TIME8}:         TIME8,     Time function (64-bit)
243 * @code{TINY}:          TINY,      Smallest positive number of a real kind
244 * @code{TRANSFER}:      TRANSFER,  Transfer bit patterns
245 * @code{TRANSPOSE}:     TRANSPOSE, Transpose an array of rank two
246 * @code{TRIM}:          TRIM,      Function to remove trailing blank characters of a string
247 * @code{UBOUND}:        UBOUND,    Upper dimension bounds of an array
248 * @code{UMASK}:         UMASK,     Set the file creation mask
249 * @code{UNLINK}:        UNLINK,    Remove a file from the file system
250 * @code{UNPACK}:        UNPACK,    Unpack an array of rank one into an array
251 * @code{VERIFY}:        VERIFY,    Scan a string for the absence of a set of characters
252 * @code{XOR}:           XOR,       Bitwise logical exclusive or
253 @end menu
255 @node Introduction to Intrinsics
256 @section Introduction to intrinsic procedures
258 The intrinsic procedures provided by GNU Fortran include all of the
259 intrinsic procedures required by the Fortran 95 standard, a set of
260 intrinsic procedures for backwards compatibility with G77, and a small
261 selection of intrinsic procedures from the Fortran 2003 standard.  Any
262 conflict between a description here and a description in either the
263 Fortran 95 standard or the Fortran 2003 standard is unintentional, and
264 the standard(s) should be considered authoritative.
266 The enumeration of the @code{KIND} type parameter is processor defined in
267 the Fortran 95 standard.  GNU Fortran defines the default integer type and
268 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
269 respectively.  The standard mandates that both data types shall have
270 another kind, which have more precision.  On typical target architectures
271 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
272 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
273 In the description of generic intrinsic procedures, the kind type parameter
274 will be specified by @code{KIND=*}, and in the description of specific
275 names for an intrinsic procedure the kind type parameter will be explicitly
276 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}).  Finally, for
277 brevity the optional @code{KIND=} syntax will be omitted.
279 Many of the intrinsic procedures take one or more optional arguments.
280 This document follows the convention used in the Fortran 95 standard,
281 and denotes such arguments by square brackets.
283 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
284 which can be used to restrict the set of intrinsic procedures to a 
285 given standard.  By default, @command{gfortran} sets the @option{-std=gnu}
286 option, and so all intrinsic procedures described here are accepted.  There
287 is one caveat.  For a select group of intrinsic procedures, @command{g77}
288 implemented both a function and a subroutine.  Both classes 
289 have been implemented in @command{gfortran} for backwards compatibility
290 with @command{g77}.  It is noted here that these functions and subroutines
291 cannot be intermixed in a given subprogram.  In the descriptions that follow,
292 the applicable standard for each intrinsic procedure is noted.
296 @node ABORT
297 @section @code{ABORT} --- Abort the program  
298 @cindex @code{ABORT} intrinsic
299 @cindex abort
301 @table @asis
302 @item @emph{Description}:
303 @code{ABORT} causes immediate termination of the program.  On operating
304 systems that support a core dump, @code{ABORT} will produce a core dump,
305 which is suitable for debugging purposes.
307 @item @emph{Standard}:
308 GNU extension
310 @item @emph{Class}:
311 non-elemental subroutine
313 @item @emph{Syntax}:
314 @code{CALL ABORT}
316 @item @emph{Return value}:
317 Does not return.
319 @item @emph{Example}:
320 @smallexample
321 program test_abort
322   integer :: i = 1, j = 2
323   if (i /= j) call abort
324 end program test_abort
325 @end smallexample
327 @item @emph{See also}:
328 @ref{EXIT}, @ref{KILL}
330 @end table
333 @node ABS
334 @section @code{ABS} --- Absolute value  
335 @cindex @code{ABS} intrinsic
336 @cindex @code{CABS} intrinsic
337 @cindex @code{DABS} intrinsic
338 @cindex @code{IABS} intrinsic
339 @cindex @code{ZABS} intrinsic
340 @cindex @code{CDABS} intrinsic
341 @cindex absolute value
343 @table @asis
344 @item @emph{Description}:
345 @code{ABS(X)} computes the absolute value of @code{X}.
347 @item @emph{Standard}:
348 F77 and later, has overloads that are GNU extensions
350 @item @emph{Class}:
351 Elemental function
353 @item @emph{Syntax}:
354 @code{RESULT = ABS(X)}
356 @item @emph{Arguments}:
357 @multitable @columnfractions .15 .80
358 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
359 @code{REAL(*)}, or @code{COMPLEX(*)}.
360 @end multitable
362 @item @emph{Return value}:
363 The return value is of the same type and
364 kind as the argument except the return value is @code{REAL(*)} for a
365 @code{COMPLEX(*)} argument.
367 @item @emph{Example}:
368 @smallexample
369 program test_abs
370   integer :: i = -1
371   real :: x = -1.e0
372   complex :: z = (-1.e0,0.e0)
373   i = abs(i)
374   x = abs(x)
375   x = abs(z)
376 end program test_abs
377 @end smallexample
379 @item @emph{Specific names}:
380 @multitable @columnfractions .20 .20 .20 .40
381 @item Name            @tab Argument            @tab Return type       @tab Standard
382 @item @code{CABS(Z)}  @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)}    @tab F77 and later
383 @item @code{DABS(X)}  @tab @code{REAL(8)    X} @tab @code{REAL(8)}    @tab F77 and later
384 @item @code{IABS(I)}  @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
385 @item @code{ZABS(Z)}  @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
386 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
387 @end multitable
388 @end table
391 @node ACCESS
392 @section @code{ACCESS} --- Checks file access modes
393 @cindex @code{ACCESS} 
394 @cindex file system operations
396 @table @asis
397 @item @emph{Description}:
398 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME} 
399 exists, is readable, writable or executable. Except for the
400 executable check, @code{ACCESS} can be replaced by
401 Fortran 95's @code{INQUIRE}.
403 @item @emph{Standard}:
404 GNU extension
406 @item @emph{Class}:
407 Inquiry function
409 @item @emph{Syntax}:
410 @code{RESULT = ACCESS(NAME, MODE)}
412 @item @emph{Arguments}:
413 @multitable @columnfractions .15 .80
414 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
415 Tailing blank are ignored unless the character @code{achar(0)} is
416 present, then all characters up to and excluding @code{achar(0)} are
417 used as file name.
418 @item @var{MODE} @tab Scalar @code{CHARACTER} with the file access mode,
419 may be any concatenation of @code{"r"} (readable), @code{"w"} (writable)
420 and @code{"x"} (executable), or @code{" "} to check for existence.
421 @end multitable
423 @item @emph{Return value}:
424 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
425 accessible in the given mode; otherwise or if an invalid argument
426 has been given for @code{MODE} the value @code{1} is returned.
428 @item @emph{Example}:
429 @smallexample
430 program access_test
431   implicit none
432   character(len=*), parameter :: file  = 'test.dat'
433   character(len=*), parameter :: file2 = 'test.dat  '//achar(0)
434   if(access(file,' ') == 0) print *, trim(file),' is exists'
435   if(access(file,'r') == 0) print *, trim(file),' is readable'
436   if(access(file,'w') == 0) print *, trim(file),' is writable'
437   if(access(file,'x') == 0) print *, trim(file),' is executable'
438   if(access(file2,'rwx') == 0) &
439     print *, trim(file2),' is readable, writable and executable'
440 end program access_test
441 @end smallexample
442 @item @emph{Specific names}:
443 @item @emph{See also}:
445 @end table
448 @node ACHAR
449 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence 
450 @cindex @code{ACHAR} intrinsic
451 @cindex @acronym{ASCII} collating sequence
453 @table @asis
454 @item @emph{Description}:
455 @code{ACHAR(I)} returns the character located at position @code{I}
456 in the @acronym{ASCII} collating sequence.
458 @item @emph{Standard}:
459 F77 and later
461 @item @emph{Class}:
462 Elemental function
464 @item @emph{Syntax}:
465 @code{RESULT = ACHAR(I)}
467 @item @emph{Arguments}:
468 @multitable @columnfractions .15 .80
469 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
470 @end multitable
472 @item @emph{Return value}:
473 The return value is of type @code{CHARACTER} with a length of one.  The
474 kind type parameter is the same as  @code{KIND('A')}.
476 @item @emph{Example}:
477 @smallexample
478 program test_achar
479   character c
480   c = achar(32)
481 end program test_achar
482 @end smallexample
484 @item @emph{See also}:
485 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
487 @end table
491 @node ACOS
492 @section @code{ACOS} --- Arccosine function 
493 @cindex @code{ACOS} intrinsic
494 @cindex @code{DACOS} intrinsic
495 @cindex trigonometric functions (inverse)
497 @table @asis
498 @item @emph{Description}:
499 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
501 @item @emph{Standard}:
502 F77 and later
504 @item @emph{Class}:
505 Elemental function
507 @item @emph{Syntax}:
508 @code{RESULT = ACOS(X)}
510 @item @emph{Arguments}:
511 @multitable @columnfractions .15 .80
512 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
513 less than one.
514 @end multitable
516 @item @emph{Return value}:
517 The return value is of type @code{REAL(*)} and it lies in the
518 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter 
519 is the same as @var{X}.
521 @item @emph{Example}:
522 @smallexample
523 program test_acos
524   real(8) :: x = 0.866_8
525   x = acos(x)
526 end program test_acos
527 @end smallexample
529 @item @emph{Specific names}:
530 @multitable @columnfractions .20 .20 .20 .40
531 @item Name            @tab Argument          @tab Return type       @tab Standard
532 @item @code{DACOS(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab F77 and later
533 @end multitable
535 @item @emph{See also}:
536 Inverse function: @ref{COS}
538 @end table
541 @node ACOSH
542 @section @code{ACOSH} --- Hyperbolic arccosine function
543 @cindex @code{ACOSH} intrinsic
544 @cindex hyperbolic arccosine
545 @cindex hyperbolic cosine (inverse)
547 @table @asis
548 @item @emph{Description}:
549 @code{ACOSH(X)} computes the area hyperbolic cosine of @var{X} (inverse of @code{COSH(X)}).
551 @item @emph{Standard}:
552 GNU extension
554 @item @emph{Class}:
555 Elemental function
557 @item @emph{Syntax}:
558 @code{RESULT = ACOSH(X)}
560 @item @emph{Arguments}:
561 @multitable @columnfractions .15 .80
562 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
563 greater or equal to one.
564 @end multitable
566 @item @emph{Return value}:
567 The return value is of type @code{REAL(*)} and it lies in the
568 range @math{0 \leq \acosh (x) \leq \infty}.
570 @item @emph{Example}:
571 @smallexample
572 PROGRAM test_acosh
573   REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
574   WRITE (*,*) ACOSH(x)
575 END PROGRAM
576 @end smallexample
578 @item @emph{See also}:
579 Inverse function: @ref{COSH}
580 @end table
584 @node ADJUSTL
585 @section @code{ADJUSTL} --- Left adjust a string 
586 @cindex @code{ADJUSTL} intrinsic
587 @cindex adjust string
589 @table @asis
590 @item @emph{Description}:
591 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
592 Spaces are inserted at the end of the string as needed.
594 @item @emph{Standard}:
595 F95 and later
597 @item @emph{Class}:
598 Elemental function
600 @item @emph{Syntax}:
601 @code{RESULT = ADJUSTL(STR)}
603 @item @emph{Arguments}:
604 @multitable @columnfractions .15 .80
605 @item @var{STR} @tab The type shall be @code{CHARACTER}.
606 @end multitable
608 @item @emph{Return value}:
609 The return value is of type @code{CHARACTER} where leading spaces 
610 are removed and the same number of spaces are inserted on the end
611 of @var{STR}.
613 @item @emph{Example}:
614 @smallexample
615 program test_adjustl
616   character(len=20) :: str = '   gfortran'
617   str = adjustl(str)
618   print *, str
619 end program test_adjustl
620 @end smallexample
621 @end table
625 @node ADJUSTR
626 @section @code{ADJUSTR} --- Right adjust a string 
627 @cindex @code{ADJUSTR} intrinsic
628 @cindex adjust string
630 @table @asis
631 @item @emph{Description}:
632 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
633 Spaces are inserted at the start of the string as needed.
635 @item @emph{Standard}:
636 F95 and later
638 @item @emph{Class}:
639 Elemental function
641 @item @emph{Syntax}:
642 @code{RESULT = ADJUSTR(STR)}
644 @item @emph{Arguments}:
645 @multitable @columnfractions .15 .80
646 @item @var{STR} @tab The type shall be @code{CHARACTER}.
647 @end multitable
649 @item @emph{Return value}:
650 The return value is of type @code{CHARACTER} where trailing spaces 
651 are removed and the same number of spaces are inserted at the start
652 of @var{STR}.
654 @item @emph{Example}:
655 @smallexample
656 program test_adjustr
657   character(len=20) :: str = 'gfortran'
658   str = adjustr(str)
659   print *, str
660 end program test_adjustr
661 @end smallexample
662 @end table
666 @node AIMAG
667 @section @code{AIMAG} --- Imaginary part of complex number  
668 @cindex @code{AIMAG} intrinsic
669 @cindex @code{DIMAG} intrinsic
670 @cindex @code{IMAG} intrinsic
671 @cindex @code{IMAGPART} intrinsic
672 @cindex imaginary part of a complex number
674 @table @asis
675 @item @emph{Description}:
676 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
677 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
678 for compatibility with @command{g77}, and their use in new code is 
679 strongly discouraged.
681 @item @emph{Standard}:
682 F77 and later, has overloads that are GNU extensions
684 @item @emph{Class}:
685 Elemental function
687 @item @emph{Syntax}:
688 @code{RESULT = AIMAG(Z)}
690 @item @emph{Arguments}:
691 @multitable @columnfractions .15 .80
692 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
693 @end multitable
695 @item @emph{Return value}:
696 The return value is of type real with the
697 kind type parameter of the argument.
699 @item @emph{Example}:
700 @smallexample
701 program test_aimag
702   complex(4) z4
703   complex(8) z8
704   z4 = cmplx(1.e0_4, 0.e0_4)
705   z8 = cmplx(0.e0_8, 1.e0_8)
706   print *, aimag(z4), dimag(z8)
707 end program test_aimag
708 @end smallexample
710 @item @emph{Specific names}:
711 @multitable @columnfractions .20 .20 .20 .40
712 @item Name            @tab Argument            @tab Return type       @tab Standard
713 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)}    @tab GNU extension
714 @item @code{IMAG(Z)}  @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)}    @tab GNU extension
715 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
716 @end multitable
717 @end table
721 @node AINT
722 @section @code{AINT} --- Truncate to a whole number
723 @cindex @code{AINT} intrinsic
724 @cindex @code{DINT} intrinsic
725 @cindex whole number
727 @table @asis
728 @item @emph{Description}:
729 @code{AINT(X [, KIND])} truncates its argument to a whole number.
731 @item @emph{Standard}:
732 F77 and later
734 @item @emph{Class}:
735 Elemental function
737 @item @emph{Syntax}:
738 @code{RESULT = AINT(X [, KIND])} 
740 @item @emph{Arguments}:
741 @multitable @columnfractions .15 .80
742 @item @var{X}    @tab The type of the argument shall be @code{REAL(*)}.
743 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
744                       expression indicating the kind parameter of
745                       the result.
746 @end multitable
748 @item @emph{Return value}:
749 The return value is of type real with the kind type parameter of the
750 argument if the optional @var{KIND} is absent; otherwise, the kind
751 type parameter will be given by @var{KIND}.  If the magnitude of 
752 @var{X} is less than one, then @code{AINT(X)} returns zero.  If the
753 magnitude is equal to or greater than one, then it returns the largest
754 whole number that does not exceed its magnitude.  The sign is the same
755 as the sign of @var{X}. 
757 @item @emph{Example}:
758 @smallexample
759 program test_aint
760   real(4) x4
761   real(8) x8
762   x4 = 1.234E0_4
763   x8 = 4.321_8
764   print *, aint(x4), dint(x8)
765   x8 = aint(x4,8)
766 end program test_aint
767 @end smallexample
769 @item @emph{Specific names}:
770 @multitable @columnfractions .20 .20 .20 .40
771 @item Name           @tab Argument         @tab Return type      @tab Standard
772 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}   @tab F77 and later
773 @end multitable
774 @end table
778 @node ALARM
779 @section @code{ALARM} --- Execute a routine after a given delay
780 @cindex @code{ALARM} intrinsic
782 @table @asis
783 @item @emph{Description}:
784 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
785 to be executed after a delay of @var{SECONDS} by using @code{alarm(1)} to
786 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
787 supplied, it will be returned with the number of seconds remaining until
788 any previously scheduled alarm was due to be delivered, or zero if there
789 was no previously scheduled alarm.
791 @item @emph{Standard}:
792 GNU extension
794 @item @emph{Class}:
795 Subroutine
797 @item @emph{Syntax}:
798 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
800 @item @emph{Arguments}:
801 @multitable @columnfractions .15 .80
802 @item @var{SECONDS} @tab The type of the argument shall be a scalar
803 @code{INTEGER}. It is @code{INTENT(IN)}.
804 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
805 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
806 @code{INTEGER}. It is @code{INTENT(IN)}.
807 @item @var{STATUS}  @tab (Optional) @var{STATUS} shall be a scalar
808 @code{INTEGER} variable. It is @code{INTENT(OUT)}.
809 @end multitable
811 @item @emph{Example}:
812 @smallexample
813 program test_alarm
814   external handler_print
815   integer i
816   call alarm (3, handler_print, i)
817   print *, i
818   call sleep(10)
819 end program test_alarm
820 @end smallexample
821 This will cause the external routine @var{handler_print} to be called
822 after 3 seconds.
823 @end table
827 @node ALL
828 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true 
829 @cindex @code{ALL} intrinsic
830 @cindex true values
832 @table @asis
833 @item @emph{Description}:
834 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
835 in the array along dimension @var{DIM}.
837 @item @emph{Standard}:
838 F95 and later
840 @item @emph{Class}:
841 transformational function
843 @item @emph{Syntax}:
844 @code{RESULT = ALL(MASK [, DIM])}
846 @item @emph{Arguments}:
847 @multitable @columnfractions .15 .80
848 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
849 it shall not be scalar.
850 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
851 with a value that lies between one and the rank of @var{MASK}.
852 @end multitable
854 @item @emph{Return value}:
855 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
856 the kind type parameter is the same as the kind type parameter of
857 @var{MASK}.  If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
858 an array with the rank of @var{MASK} minus 1.  The shape is determined from
859 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
861 @table @asis
862 @item (A)
863 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
864 It also is true if @var{MASK} has zero size; otherwise, it is false.
865 @item (B)
866 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
867 to @code{ALL(MASK)}.  If the rank is greater than one, then @code{ALL(MASK,DIM)}
868 is determined by applying @code{ALL} to the array sections.
869 @end table
871 @item @emph{Example}:
872 @smallexample
873 program test_all
874   logical l
875   l = all((/.true., .true., .true./))
876   print *, l
877   call section
878   contains
879     subroutine section
880       integer a(2,3), b(2,3)
881       a = 1
882       b = 1
883       b(2,2) = 2
884       print *, all(a .eq. b, 1)
885       print *, all(a .eq. b, 2)
886     end subroutine section
887 end program test_all
888 @end smallexample
889 @end table
893 @node ALLOCATED
894 @section @code{ALLOCATED} --- Status of an allocatable entity
895 @cindex @code{ALLOCATED} intrinsic
896 @cindex allocation status
898 @table @asis
899 @item @emph{Description}:
900 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
902 @item @emph{Standard}:
903 F95 and later
905 @item @emph{Class}:
906 Inquiry function
908 @item @emph{Syntax}:
909 @code{RESULT = ALLOCATED(X)}
911 @item @emph{Arguments}:
912 @multitable @columnfractions .15 .80
913 @item @var{X}    @tab The argument shall be an @code{ALLOCATABLE} array.
914 @end multitable
916 @item @emph{Return value}:
917 The return value is a scalar @code{LOGICAL} with the default logical
918 kind type parameter.  If @var{X} is allocated, @code{ALLOCATED(X)}
919 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.} 
921 @item @emph{Example}:
922 @smallexample
923 program test_allocated
924   integer :: i = 4
925   real(4), allocatable :: x(:)
926   if (allocated(x) .eqv. .false.) allocate(x(i))
927 end program test_allocated
928 @end smallexample
929 @end table
932 @node AND
933 @section @code{AND} --- Bitwise logical AND
934 @cindex @code{AND} intrinsic
935 @cindex bit operations
937 @table @asis
938 @item @emph{Description}:
939 Bitwise logical @code{AND}.
941 This intrinsic routine is provided for backwards compatibility with 
942 GNU Fortran 77.  For integer arguments, programmers should consider
943 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
945 @item @emph{Standard}:
946 GNU extension
948 @item @emph{Class}:
949 Non-elemental function
951 @item @emph{Syntax}:
952 @code{RESULT = AND(X, Y)}
954 @item @emph{Arguments}:
955 @multitable @columnfractions .15 .80
956 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
957 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
958 @end multitable
960 @item @emph{Return value}:
961 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
962 cross-promotion of the arguments. 
964 @item @emph{Example}:
965 @smallexample
966 PROGRAM test_and
967   LOGICAL :: T = .TRUE., F = ..FALSE.
968   INTEGER :: a, b
969   DATA a / Z'F' /, b / Z'3' /
971   WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
972   WRITE (*,*) AND(a, b)
973 END PROGRAM
974 @end smallexample
976 @item @emph{See also}:
977 F95 elemental function: @ref{IAND}
978 @end table
982 @node ANINT
983 @section @code{ANINT} --- Nearest whole number
984 @cindex @code{ANINT} intrinsic
985 @cindex @code{DNINT} intrinsic
986 @cindex whole number
988 @table @asis
989 @item @emph{Description}:
990 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
992 @item @emph{Standard}:
993 F77 and later
995 @item @emph{Class}:
996 Elemental function
998 @item @emph{Syntax}:
999 @code{RESULT = ANINT(X [, KIND])}
1001 @item @emph{Arguments}:
1002 @multitable @columnfractions .15 .80
1003 @item @var{X}    @tab The type of the argument shall be @code{REAL(*)}.
1004 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1005                       expression indicating the kind parameter of
1006                       the result.
1007 @end multitable
1009 @item @emph{Return value}:
1010 The return value is of type real with the kind type parameter of the
1011 argument if the optional @var{KIND} is absent; otherwise, the kind
1012 type parameter will be given by @var{KIND}.  If @var{X} is greater than
1013 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}.  If @var{X} is
1014 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1016 @item @emph{Example}:
1017 @smallexample
1018 program test_anint
1019   real(4) x4
1020   real(8) x8
1021   x4 = 1.234E0_4
1022   x8 = 4.321_8
1023   print *, anint(x4), dnint(x8)
1024   x8 = anint(x4,8)
1025 end program test_anint
1026 @end smallexample
1028 @item @emph{Specific names}:
1029 @multitable @columnfractions .20 .20 .20 .40
1030 @item Name            @tab Argument         @tab Return type      @tab Standard
1031 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}   @tab F77 and later
1032 @end multitable
1033 @end table
1037 @node ANY
1038 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true 
1039 @cindex @code{ANY} intrinsic
1040 @cindex true values
1042 @table @asis
1043 @item @emph{Description}:
1044 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1045 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1047 @item @emph{Standard}:
1048 F95 and later
1050 @item @emph{Class}:
1051 transformational function
1053 @item @emph{Syntax}:
1054 @code{RESULT = ANY(MASK [, DIM])}
1056 @item @emph{Arguments}:
1057 @multitable @columnfractions .15 .80
1058 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1059 it shall not be scalar.
1060 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
1061 with a value that lies between one and the rank of @var{MASK}.
1062 @end multitable
1064 @item @emph{Return value}:
1065 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1066 the kind type parameter is the same as the kind type parameter of
1067 @var{MASK}.  If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1068 an array with the rank of @var{MASK} minus 1.  The shape is determined from
1069 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
1071 @table @asis
1072 @item (A)
1073 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1074 otherwise, it is false.  It also is false if @var{MASK} has zero size.
1075 @item (B)
1076 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1077 to @code{ANY(MASK)}.  If the rank is greater than one, then @code{ANY(MASK,DIM)}
1078 is determined by applying @code{ANY} to the array sections.
1079 @end table
1081 @item @emph{Example}:
1082 @smallexample
1083 program test_any
1084   logical l
1085   l = any((/.true., .true., .true./))
1086   print *, l
1087   call section
1088   contains
1089     subroutine section
1090       integer a(2,3), b(2,3)
1091       a = 1
1092       b = 1
1093       b(2,2) = 2
1094       print *, any(a .eq. b, 1)
1095       print *, any(a .eq. b, 2)
1096     end subroutine section
1097 end program test_any
1098 @end smallexample
1099 @end table
1103 @node ASIN
1104 @section @code{ASIN} --- Arcsine function 
1105 @cindex @code{ASIN} intrinsic
1106 @cindex @code{DASIN} intrinsic
1107 @cindex trigonometric functions (inverse)
1109 @table @asis
1110 @item @emph{Description}:
1111 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1113 @item @emph{Standard}:
1114 F77 and later
1116 @item @emph{Class}:
1117 Elemental function
1119 @item @emph{Syntax}:
1120 @code{RESULT = ASIN(X)}
1122 @item @emph{Arguments}:
1123 @multitable @columnfractions .15 .80
1124 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1125 less than one.
1126 @end multitable
1128 @item @emph{Return value}:
1129 The return value is of type @code{REAL(*)} and it lies in the
1130 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}.  The kind type
1131 parameter is the same as @var{X}.
1133 @item @emph{Example}:
1134 @smallexample
1135 program test_asin
1136   real(8) :: x = 0.866_8
1137   x = asin(x)
1138 end program test_asin
1139 @end smallexample
1141 @item @emph{Specific names}:
1142 @multitable @columnfractions .20 .20 .20 .40
1143 @item Name            @tab Argument          @tab Return type       @tab Standard
1144 @item @code{DASIN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab F77 and later
1145 @end multitable
1147 @item @emph{See also}:
1148 Inverse function: @ref{SIN}
1150 @end table
1153 @node ASINH
1154 @section @code{ASINH} --- Hyperbolic arcsine function
1155 @cindex @code{ASINH} intrinsic
1156 @cindex hyperbolic arcsine
1157 @cindex hyperbolic sine (inverse)
1159 @table @asis
1160 @item @emph{Description}:
1161 @code{ASINH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{SINH(X)}).
1163 @item @emph{Standard}:
1164 GNU extension
1166 @item @emph{Class}:
1167 Elemental function
1169 @item @emph{Syntax}:
1170 @code{RESULT = ASINH(X)}
1172 @item @emph{Arguments}:
1173 @multitable @columnfractions .15 .80
1174 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1175 @end multitable
1177 @item @emph{Return value}:
1178 The return value is of type @code{REAL(*)} and it lies in the
1179 range @math{-\infty \leq \asinh (x) \leq \infty}.
1181 @item @emph{Example}:
1182 @smallexample
1183 PROGRAM test_asinh
1184   REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1185   WRITE (*,*) ASINH(x)
1186 END PROGRAM
1187 @end smallexample
1189 @item @emph{See also}:
1190 Inverse function: @ref{SINH}
1191 @end table
1195 @node ASSOCIATED
1196 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair 
1197 @cindex @code{ASSOCIATED} intrinsic
1198 @cindex pointer status
1200 @table @asis
1201 @item @emph{Description}:
1202 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1203 or if @var{PTR} is associated with the target @var{TGT}.
1205 @item @emph{Standard}:
1206 F95 and later
1208 @item @emph{Class}:
1209 Inquiry function
1211 @item @emph{Syntax}:
1212 @code{RESULT = ASSOCIATED(PTR [, TGT])}
1214 @item @emph{Arguments}:
1215 @multitable @columnfractions .15 .80
1216 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1217 it can be of any type.
1218 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1219 a @code{TARGET}.  It must have the same type, kind type parameter, and
1220 array rank as @var{PTR}.
1221 @end multitable
1222 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1224 @item @emph{Return value}:
1225 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1226 There are several cases:
1227 @table @asis
1228 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1229 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1230 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1231 @var{TGT}
1232 is not a 0 sized storage sequence and the target associated with @var{PTR}
1233 occupies the same storage units.  If @var{PTR} is disassociated, then the 
1234 result is false.
1235 @item (C) If @var{TGT} is present and an array target, the result is true if
1236 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1237 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1238 @var{PTR} occupy the same storage units in array element order.
1239 As in case(B), the result is false, if @var{PTR} is disassociated.
1240 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1241 target associated with @var{PTR} and the target associated with @var{TGT}
1242 are not 0 sized storage sequences and occupy the same storage units.
1243 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1244 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1245 target associated with @var{PTR} and the target associated with @var{TGT}
1246 have the same shape, are not 0 sized arrays, are arrays whose elements are
1247 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1248 storage units in array element order.
1249 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1250 @end table
1252 @item @emph{Example}:
1253 @smallexample
1254 program test_associated
1255    implicit none
1256    real, target  :: tgt(2) = (/1., 2./)
1257    real, pointer :: ptr(:)
1258    ptr => tgt
1259    if (associated(ptr)     .eqv. .false.) call abort
1260    if (associated(ptr,tgt) .eqv. .false.) call abort
1261 end program test_associated
1262 @end smallexample
1264 @item @emph{See also}:
1265 @ref{NULL}
1266 @end table
1270 @node ATAN
1271 @section @code{ATAN} --- Arctangent function 
1272 @cindex @code{ATAN} intrinsic
1273 @cindex @code{DATAN} intrinsic
1274 @cindex trigonometric functions (inverse)
1276 @table @asis
1277 @item @emph{Description}:
1278 @code{ATAN(X)} computes the arctangent of @var{X}.
1280 @item @emph{Standard}:
1281 F77 and later
1283 @item @emph{Class}:
1284 Elemental function
1286 @item @emph{Syntax}:
1287 @code{RESULT = ATAN(X)}
1289 @item @emph{Arguments}:
1290 @multitable @columnfractions .15 .80
1291 @item @var{X} @tab The type shall be @code{REAL(*)}.
1292 @end multitable
1294 @item @emph{Return value}:
1295 The return value is of type @code{REAL(*)} and it lies in the
1296 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1298 @item @emph{Example}:
1299 @smallexample
1300 program test_atan
1301   real(8) :: x = 2.866_8
1302   x = atan(x)
1303 end program test_atan
1304 @end smallexample
1306 @item @emph{Specific names}:
1307 @multitable @columnfractions .20 .20 .20 .40
1308 @item Name            @tab Argument          @tab Return type       @tab Standard
1309 @item @code{DATAN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab F77 and later
1310 @end multitable
1312 @item @emph{See also}:
1313 Inverse function: @ref{TAN}
1315 @end table
1319 @node ATAN2
1320 @section @code{ATAN2} --- Arctangent function 
1321 @cindex @code{ATAN2} intrinsic
1322 @cindex @code{DATAN2} intrinsic
1323 @cindex trigonometric functions (inverse)
1325 @table @asis
1326 @item @emph{Description}:
1327 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
1329 @item @emph{Standard}:
1330 F77 and later
1332 @item @emph{Class}:
1333 Elemental function
1335 @item @emph{Syntax}:
1336 @code{RESULT = ATAN2(Y,X)}
1338 @item @emph{Arguments}:
1339 @multitable @columnfractions .15 .80
1340 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1341 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1342 If @var{Y} is zero, then @var{X} must be nonzero.
1343 @end multitable
1345 @item @emph{Return value}:
1346 The return value has the same type and kind type parameter as @var{Y}.
1347 It is the principal value of the complex number @math{X + i Y}.  If
1348 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1349 The sign is positive if @var{Y} is positive.  If @var{Y} is zero, then
1350 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1351 is negative.  Finally, if @var{X} is zero, then the magnitude of the result
1352 is @math{\pi/2}.
1354 @item @emph{Example}:
1355 @smallexample
1356 program test_atan2
1357   real(4) :: x = 1.e0_4, y = 0.5e0_4
1358   x = atan2(y,x)
1359 end program test_atan2
1360 @end smallexample
1362 @item @emph{Specific names}:
1363 @multitable @columnfractions .20 .20 .20 .40
1364 @item Name            @tab Argument          @tab Return type    @tab Standard
1365 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1366 @end multitable
1367 @end table
1371 @node ATANH
1372 @section @code{ATANH} --- Hyperbolic arctangent function
1373 @cindex @code{ASINH} intrinsic
1374 @cindex hyperbolic arctangent
1375 @cindex hyperbolic tangent (inverse)
1377 @table @asis
1378 @item @emph{Description}:
1379 @code{ATANH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{TANH(X)}).
1381 @item @emph{Standard}:
1382 GNU extension
1384 @item @emph{Class}:
1385 Elemental function
1387 @item @emph{Syntax}:
1388 @code{RESULT = ATANH(X)}
1390 @item @emph{Arguments}:
1391 @multitable @columnfractions .15 .80
1392 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude
1393 that is less than or equal to one.
1394 @end multitable
1396 @item @emph{Return value}:
1397 The return value is of type @code{REAL(*)} and it lies in the
1398 range @math{-\infty \leq \atanh(x) \leq \infty}.
1400 @item @emph{Example}:
1401 @smallexample
1402 PROGRAM test_atanh
1403   REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1404   WRITE (*,*) ATANH(x)
1405 END PROGRAM
1406 @end smallexample
1408 @item @emph{See also}:
1409 Inverse function: @ref{TANH}
1410 @end table
1415 @node BESJ0
1416 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1417 @cindex @code{BESJ0} intrinsic
1418 @cindex @code{DBESJ0} intrinsic
1419 @cindex Bessel
1421 @table @asis
1422 @item @emph{Description}:
1423 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1424 of @var{X}.
1426 @item @emph{Standard}:
1427 GNU extension
1429 @item @emph{Class}:
1430 Elemental function
1432 @item @emph{Syntax}:
1433 @code{RESULT = BESJ0(X)}
1435 @item @emph{Arguments}:
1436 @multitable @columnfractions .15 .80
1437 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1438 @end multitable
1440 @item @emph{Return value}:
1441 The return value is of type @code{REAL(*)} and it lies in the
1442 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1444 @item @emph{Example}:
1445 @smallexample
1446 program test_besj0
1447   real(8) :: x = 0.0_8
1448   x = besj0(x)
1449 end program test_besj0
1450 @end smallexample
1452 @item @emph{Specific names}:
1453 @multitable @columnfractions .20 .20 .20 .40
1454 @item Name            @tab Argument          @tab Return type       @tab Standard
1455 @item @code{DBESJ0(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}   @tab GNU extension
1456 @end multitable
1457 @end table
1461 @node BESJ1
1462 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1463 @cindex @code{BESJ1} intrinsic
1464 @cindex @code{DBESJ1} intrinsic
1465 @cindex Bessel
1467 @table @asis
1468 @item @emph{Description}:
1469 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1470 of @var{X}.
1472 @item @emph{Standard}:
1473 GNU extension
1475 @item @emph{Class}:
1476 Elemental function
1478 @item @emph{Syntax}:
1479 @code{RESULT = BESJ1(X)}
1481 @item @emph{Arguments}:
1482 @multitable @columnfractions .15 .80
1483 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1484 @end multitable
1486 @item @emph{Return value}:
1487 The return value is of type @code{REAL(*)} and it lies in the
1488 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1490 @item @emph{Example}:
1491 @smallexample
1492 program test_besj1
1493   real(8) :: x = 1.0_8
1494   x = besj1(x)
1495 end program test_besj1
1496 @end smallexample
1498 @item @emph{Specific names}:
1499 @multitable @columnfractions .20 .20 .20 .40
1500 @item Name            @tab Argument          @tab Return type       @tab Standard
1501 @item @code{DBESJ1(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1502 @end multitable
1503 @end table
1507 @node BESJN
1508 @section @code{BESJN} --- Bessel function of the first kind
1509 @cindex @code{BESJN} intrinsic
1510 @cindex @code{DBESJN} intrinsic
1511 @cindex Bessel
1513 @table @asis
1514 @item @emph{Description}:
1515 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1516 @var{N} of @var{X}.
1518 @item @emph{Standard}:
1519 GNU extension
1521 @item @emph{Class}:
1522 Elemental function
1524 @item @emph{Syntax}:
1525 @code{RESULT = BESJN(N, X)}
1527 @item @emph{Arguments}:
1528 @multitable @columnfractions .15 .80
1529 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1530 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1531 @end multitable
1533 @item @emph{Return value}:
1534 The return value is a scalar of type @code{REAL(*)}.
1536 @item @emph{Example}:
1537 @smallexample
1538 program test_besjn
1539   real(8) :: x = 1.0_8
1540   x = besjn(5,x)
1541 end program test_besjn
1542 @end smallexample
1544 @item @emph{Specific names}:
1545 @multitable @columnfractions .20 .20 .20 .40
1546 @item Name             @tab Argument            @tab Return type       @tab Standard
1547 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)}    @tab GNU extension
1548 @item                  @tab @code{REAL(8) X}    @tab                   @tab
1549 @end multitable
1550 @end table
1554 @node BESY0
1555 @section @code{BESY0} --- Bessel function of the second kind of order 0
1556 @cindex @code{BESY0} intrinsic
1557 @cindex @code{DBESY0} intrinsic
1558 @cindex Bessel
1560 @table @asis
1561 @item @emph{Description}:
1562 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1563 of @var{X}.
1565 @item @emph{Standard}:
1566 GNU extension
1568 @item @emph{Class}:
1569 Elemental function
1571 @item @emph{Syntax}:
1572 @code{RESULT = BESY0(X)}
1574 @item @emph{Arguments}:
1575 @multitable @columnfractions .15 .80
1576 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1577 @end multitable
1579 @item @emph{Return value}:
1580 The return value is a scalar of type @code{REAL(*)}.
1582 @item @emph{Example}:
1583 @smallexample
1584 program test_besy0
1585   real(8) :: x = 0.0_8
1586   x = besy0(x)
1587 end program test_besy0
1588 @end smallexample
1590 @item @emph{Specific names}:
1591 @multitable @columnfractions .20 .20 .20 .40
1592 @item Name            @tab Argument          @tab Return type       @tab Standard
1593 @item @code{DBESY0(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1594 @end multitable
1595 @end table
1599 @node BESY1
1600 @section @code{BESY1} --- Bessel function of the second kind of order 1
1601 @cindex @code{BESY1} intrinsic
1602 @cindex @code{DBESY1} intrinsic
1603 @cindex Bessel
1605 @table @asis
1606 @item @emph{Description}:
1607 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1608 of @var{X}.
1610 @item @emph{Standard}:
1611 GNU extension
1613 @item @emph{Class}:
1614 Elemental function
1616 @item @emph{Syntax}:
1617 @code{RESULT = BESY1(X)}
1619 @item @emph{Arguments}:
1620 @multitable @columnfractions .15 .80
1621 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1622 @end multitable
1624 @item @emph{Return value}:
1625 The return value is a scalar of type @code{REAL(*)}.
1627 @item @emph{Example}:
1628 @smallexample
1629 program test_besy1
1630   real(8) :: x = 1.0_8
1631   x = besy1(x)
1632 end program test_besy1
1633 @end smallexample
1635 @item @emph{Specific names}:
1636 @multitable @columnfractions .20 .20 .20 .40
1637 @item Name            @tab Argument          @tab Return type       @tab Standard
1638 @item @code{DBESY1(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1639 @end multitable
1640 @end table
1644 @node BESYN
1645 @section @code{BESYN} --- Bessel function of the second kind
1646 @cindex @code{BESYN} intrinsic
1647 @cindex @code{DBESYN} intrinsic
1648 @cindex Bessel
1650 @table @asis
1651 @item @emph{Description}:
1652 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1653 @var{N} of @var{X}.
1655 @item @emph{Standard}:
1656 GNU extension
1658 @item @emph{Class}:
1659 Elemental function
1661 @item @emph{Syntax}:
1662 @code{RESULT = BESYN(N, X)}
1664 @item @emph{Arguments}:
1665 @multitable @columnfractions .15 .80
1666 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1667 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1668 @end multitable
1670 @item @emph{Return value}:
1671 The return value is a scalar of type @code{REAL(*)}.
1673 @item @emph{Example}:
1674 @smallexample
1675 program test_besyn
1676   real(8) :: x = 1.0_8
1677   x = besyn(5,x)
1678 end program test_besyn
1679 @end smallexample
1681 @item @emph{Specific names}:
1682 @multitable @columnfractions .20 .20 .20 .40
1683 @item Name               @tab Argument            @tab Return type     @tab Standard
1684 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)}  @tab GNU extension
1685 @item                    @tab @code{REAL(8)    X} @tab                 @tab 
1686 @end multitable
1687 @end table
1691 @node BIT_SIZE
1692 @section @code{BIT_SIZE} --- Bit size inquiry function
1693 @cindex @code{BIT_SIZE} intrinsic
1694 @cindex bit size of a variable
1695 @cindex size of a variable, in bits
1697 @table @asis
1698 @item @emph{Description}:
1699 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1700 represented by the type of @var{I}.
1702 @item @emph{Standard}:
1703 F95 and later
1705 @item @emph{Class}:
1706 Inquiry function
1708 @item @emph{Syntax}:
1709 @code{RESULT = BIT_SIZE(I)}
1711 @item @emph{Arguments}:
1712 @multitable @columnfractions .15 .80
1713 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1714 @end multitable
1716 @item @emph{Return value}:
1717 The return value is of type @code{INTEGER(*)}
1719 @item @emph{Example}:
1720 @smallexample
1721 program test_bit_size
1722     integer :: i = 123
1723     integer :: size
1724     size = bit_size(i)
1725     print *, size
1726 end program test_bit_size
1727 @end smallexample
1728 @end table
1732 @node BTEST
1733 @section @code{BTEST} --- Bit test function
1734 @cindex @code{BTEST} intrinsic
1735 @cindex bit operations
1737 @table @asis
1738 @item @emph{Description}:
1739 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1740 in @var{I} is set.
1742 @item @emph{Standard}:
1743 F95 and later
1745 @item @emph{Class}:
1746 Elemental function
1748 @item @emph{Syntax}:
1749 @code{RESULT = BTEST(I, POS)}
1751 @item @emph{Arguments}:
1752 @multitable @columnfractions .15 .80
1753 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1754 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1755 @end multitable
1757 @item @emph{Return value}:
1758 The return value is of type @code{LOGICAL}
1760 @item @emph{Example}:
1761 @smallexample
1762 program test_btest
1763     integer :: i = 32768 + 1024 + 64
1764     integer :: pos
1765     logical :: bool
1766     do pos=0,16
1767         bool = btest(i, pos) 
1768         print *, pos, bool
1769     end do
1770 end program test_btest
1771 @end smallexample
1772 @end table
1776 @node CEILING
1777 @section @code{CEILING} --- Integer ceiling function
1778 @cindex @code{CEILING} intrinsic
1779 @cindex ceiling
1781 @table @asis
1782 @item @emph{Description}:
1783 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1785 @item @emph{Standard}:
1786 F95 and later
1788 @item @emph{Class}:
1789 Elemental function
1791 @item @emph{Syntax}:
1792 @code{RESULT = CEILING(X [, KIND])}
1794 @item @emph{Arguments}:
1795 @multitable @columnfractions .15 .80
1796 @item @var{X} @tab The type shall be @code{REAL(*)}.
1797 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1798                       expression indicating the kind parameter of
1799                       the result.
1800 @end multitable
1802 @item @emph{Return value}:
1803 The return value is of type @code{INTEGER(KIND)}
1805 @item @emph{Example}:
1806 @smallexample
1807 program test_ceiling
1808     real :: x = 63.29
1809     real :: y = -63.59
1810     print *, ceiling(x) ! returns 64
1811     print *, ceiling(y) ! returns -63
1812 end program test_ceiling
1813 @end smallexample
1815 @item @emph{See also}:
1816 @ref{FLOOR}, @ref{NINT}
1818 @end table
1822 @node CHAR
1823 @section @code{CHAR} --- Character conversion function
1824 @cindex @code{CHAR} intrinsic
1825 @cindex conversion function (character)
1827 @table @asis
1828 @item @emph{Description}:
1829 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
1831 @item @emph{Standard}:
1832 F77 and later
1834 @item @emph{Class}:
1835 Elemental function
1837 @item @emph{Syntax}:
1838 @code{RESULT = CHAR(I [, KIND])}
1840 @item @emph{Arguments}:
1841 @multitable @columnfractions .15 .80
1842 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1843 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1844                       expression indicating the kind parameter of
1845                       the result.
1846 @end multitable
1848 @item @emph{Return value}:
1849 The return value is of type @code{CHARACTER(1)}
1851 @item @emph{Example}:
1852 @smallexample
1853 program test_char
1854     integer :: i = 74
1855     character(1) :: c
1856     c = char(i)
1857     print *, i, c ! returns 'J'
1858 end program test_char
1859 @end smallexample
1861 @item @emph{See also}:
1862 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
1864 @end table
1867 @node CHDIR
1868 @section @code{CHDIR} --- Change working directory
1869 @cindex @code{CHDIR} intrinsic
1870 @cindex file system operations
1872 @table @asis
1873 @item @emph{Description}:
1874 Change current working directory to a specified @var{PATH}.
1876 @item @emph{Standard}:
1877 GNU extension
1879 @item @emph{Class}:
1880 Non-elemental subroutine
1882 @item @emph{Syntax}:
1883 @code{CALL CHDIR(PATH [, STATUS])}
1885 @item @emph{Arguments}:
1886 @multitable @columnfractions .15 .80
1887 @item @var{PATH}   @tab The type shall be @code{CHARACTER(*)} and shall
1888                         specify a valid path within the file system.
1889 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success, 
1890                         a system specific and non-zero error code otherwise.
1891 @end multitable
1893 @item @emph{Example}:
1894 @smallexample
1895 PROGRAM test_chdir
1896   CHARACTER(len=255) :: path
1897   CALL getcwd(path)
1898   WRITE(*,*) TRIM(path)
1899   CALL chdir("/tmp")
1900   CALL getcwd(path)
1901   WRITE(*,*) TRIM(path)
1902 END PROGRAM
1903 @end smallexample
1905 @item @emph{See also}:
1906 @ref{GETCWD}
1907 @end table
1911 @node CHMOD
1912 @section @code{CHMOD} --- Change access permissions of files
1913 @cindex @code{CHMOD} intrinsic
1914 @cindex file system operations
1916 @table @asis
1917 @item @emph{Description}:
1918 @code{CHMOD} changes the permissions of a file. This function invokes
1919 @code{/bin/chmod} and might therefore not work on all platforms.
1921 This intrinsic is provided in both subroutine and function forms; however,
1922 only one form can be used in any given program unit.
1924 @item @emph{Standard}:
1925 GNU extension
1927 @item @emph{Class}:
1928 Subroutine, non-elemental function
1930 @item @emph{Syntax}:
1931 @multitable @columnfractions .80
1932 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
1933 @item @code{STATUS = CHMOD(NAME, MODE)}
1934 @end multitable
1936 @item @emph{Arguments}:
1937 @multitable @columnfractions .15 .80
1938 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
1939 Trailing blanks are ignored unless the character @code{achar(0)} is
1940 present, then all characters up to and excluding @code{achar(0)} are
1941 used as the file name.
1943 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
1944 @var{MODE} uses the same syntax as the @var{MODE} argument of
1945 @code{/bin/chmod}.
1947 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
1948 @code{0} on success and non-zero otherwise.
1949 @end multitable
1951 @item @emph{Return value}:
1952 In either syntax, @var{STATUS} is set to @code{0} on success and non-zero
1953 otherwise.
1955 @item @emph{Example}:
1956 @code{CHMOD} as subroutine
1957 @smallexample
1958 program chmod_test
1959   implicit none
1960   integer :: status
1961   call chmod('test.dat','u+x',status)
1962   print *, 'Status: ', status
1963 end program chmod_test
1964 @end smallexample
1965 @code{CHMOD} as non-elemental function:
1966 @smallexample
1967 program chmod_test
1968   implicit none
1969   integer :: status
1970   status = chmod('test.dat','u+x')
1971   print *, 'Status: ', status
1972 end program chmod_test
1973 @end smallexample
1974 @item @emph{Specific names}:
1975 @item @emph{See also}:
1977 @end table
1980 @node CMPLX
1981 @section @code{CMPLX} --- Complex conversion function
1982 @cindex @code{CMPLX} intrinsic
1983 @cindex complex numbers, conversion to
1985 @table @asis
1986 @item @emph{Description}:
1987 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
1988 the real component.  If @var{Y} is present it is converted to the imaginary
1989 component.  If @var{Y} is not present then the imaginary component is set to
1990 0.0.  If @var{X} is complex then @var{Y} must not be present.
1992 @item @emph{Standard}:
1993 F77 and later
1995 @item @emph{Class}:
1996 Elemental function
1998 @item @emph{Syntax}:
1999 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2001 @item @emph{Arguments}:
2002 @multitable @columnfractions .15 .80
2003 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2004                    or @code{COMPLEX(*)}.
2005 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2006                    @code{COMPLEX(*)}.)  May be @code{INTEGER(*)}
2007                    or @code{REAL(*)}.
2008 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2009                       expression indicating the kind parameter of
2010                       the result.
2011 @end multitable
2013 @item @emph{Return value}:
2014 The return value is of type @code{COMPLEX(*)}
2016 @item @emph{Example}:
2017 @smallexample
2018 program test_cmplx
2019     integer :: i = 42
2020     real :: x = 3.14
2021     complex :: z
2022     z = cmplx(i, x)
2023     print *, z, cmplx(x)
2024 end program test_cmplx
2025 @end smallexample
2026 @end table
2030 @node COMMAND_ARGUMENT_COUNT
2031 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2032 @cindex @code{COMMAND_ARGUMENT_COUNT} intrinsic
2033 @cindex command-line arguments, to program
2035 @table @asis
2036 @item @emph{Description}:
2037 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2038 command line when the containing program was invoked.
2040 @item @emph{Standard}:
2041 F2003
2043 @item @emph{Class}:
2044 Inquiry function
2046 @item @emph{Syntax}:
2047 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2049 @item @emph{Arguments}:
2050 @multitable @columnfractions .15 .80
2051 @item None
2052 @end multitable
2054 @item @emph{Return value}:
2055 The return value is of type @code{INTEGER(4)}
2057 @item @emph{Example}:
2058 @smallexample
2059 program test_command_argument_count
2060     integer :: count
2061     count = command_argument_count()
2062     print *, count
2063 end program test_command_argument_count
2064 @end smallexample
2066 @item @emph{See also}:
2067 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2068 @end table
2070 @node CONJG
2071 @section @code{CONJG} --- Complex conjugate function 
2072 @cindex @code{CONJG} intrinsic
2073 @cindex @code{DCONJG} intrinsic
2074 @cindex complex conjugate
2075 @table @asis
2076 @item @emph{Description}:
2077 @code{CONJG(Z)} returns the conjugate of @var{Z}.  If @var{Z} is @code{(x, y)}
2078 then the result is @code{(x, -y)}
2080 @item @emph{Standard}:
2081 F77 and later, has overloads that are GNU extensions
2083 @item @emph{Class}:
2084 Elemental function
2086 @item @emph{Syntax}:
2087 @code{Z = CONJG(Z)}
2089 @item @emph{Arguments}:
2090 @multitable @columnfractions .15 .80
2091 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2092 @end multitable
2094 @item @emph{Return value}:
2095 The return value is of type @code{COMPLEX(*)}.
2097 @item @emph{Example}:
2098 @smallexample
2099 program test_conjg
2100     complex :: z = (2.0, 3.0)
2101     complex(8) :: dz = (2.71_8, -3.14_8)
2102     z= conjg(z)
2103     print *, z
2104     dz = dconjg(dz)
2105     print *, dz
2106 end program test_conjg
2107 @end smallexample
2109 @item @emph{Specific names}:
2110 @multitable @columnfractions .20 .20 .20 .40
2111 @item Name             @tab Argument             @tab Return type          @tab Standard
2112 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z}  @tab @code{COMPLEX(8)}    @tab GNU extension
2113 @end multitable
2114 @end table
2118 @node COS
2119 @section @code{COS} --- Cosine function 
2120 @cindex @code{COS} intrinsic
2121 @cindex @code{DCOS} intrinsic
2122 @cindex @code{ZCOS} intrinsic
2123 @cindex @code{CDCOS} intrinsic
2124 @cindex trigonometric functions
2126 @table @asis
2127 @item @emph{Description}:
2128 @code{COS(X)} computes the cosine of @var{X}.
2130 @item @emph{Standard}:
2131 F77 and later, has overloads that are GNU extensions
2133 @item @emph{Class}:
2134 Elemental function
2136 @item @emph{Syntax}:
2137 @code{RESULT = COS(X)}
2139 @item @emph{Arguments}:
2140 @multitable @columnfractions .15 .80
2141 @item @var{X} @tab The type shall be @code{REAL(*)} or
2142 @code{COMPLEX(*)}.
2143 @end multitable
2145 @item @emph{Return value}:
2146 The return value is of type @code{REAL(*)} and it lies in the
2147 range @math{ -1 \leq \cos (x) \leq 1}.  The kind type
2148 parameter is the same as @var{X}.
2150 @item @emph{Example}:
2151 @smallexample
2152 program test_cos
2153   real :: x = 0.0
2154   x = cos(x)
2155 end program test_cos
2156 @end smallexample
2158 @item @emph{Specific names}:
2159 @multitable @columnfractions .20 .20 .20 .40
2160 @item Name            @tab Argument            @tab Return type       @tab Standard
2161 @item @code{DCOS(X)}  @tab @code{REAL(8) X}    @tab @code{REAL(8)}    @tab F77 and later
2162 @item @code{CCOS(X)}  @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2163 @item @code{ZCOS(X)}  @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2164 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2165 @end multitable
2167 @item @emph{See also}:
2168 Inverse function: @ref{ACOS}
2170 @end table
2174 @node COSH
2175 @section @code{COSH} --- Hyperbolic cosine function 
2176 @cindex @code{COSH} intrinsic
2177 @cindex @code{DCOSH} intrinsic
2178 @cindex hyperbolic cosine
2180 @table @asis
2181 @item @emph{Description}:
2182 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2184 @item @emph{Standard}:
2185 F77 and later
2187 @item @emph{Class}:
2188 Elemental function
2190 @item @emph{Syntax}:
2191 @code{X = COSH(X)}
2193 @item @emph{Arguments}:
2194 @multitable @columnfractions .15 .80
2195 @item @var{X} @tab The type shall be @code{REAL(*)}.
2196 @end multitable
2198 @item @emph{Return value}:
2199 The return value is of type @code{REAL(*)} and it is positive
2200 (@math{ \cosh (x) \geq 0 }.
2202 @item @emph{Example}:
2203 @smallexample
2204 program test_cosh
2205   real(8) :: x = 1.0_8
2206   x = cosh(x)
2207 end program test_cosh
2208 @end smallexample
2210 @item @emph{Specific names}:
2211 @multitable @columnfractions .20 .20 .20 .40
2212 @item Name            @tab Argument          @tab Return type       @tab Standard
2213 @item @code{DCOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab F77 and later
2214 @end multitable
2216 @item @emph{See also}:
2217 Inverse function: @ref{ACOSH}
2219 @end table
2223 @node COUNT
2224 @section @code{COUNT} --- Count function
2225 @cindex @code{COUNT} intrinsic
2226 @cindex count
2228 @table @asis
2229 @item @emph{Description}:
2230 @code{COUNT(MASK [, DIM])} counts the number of @code{.TRUE.} elements of
2231 @var{MASK} along the dimension of @var{DIM}.  If @var{DIM} is omitted it is
2232 taken to be @code{1}.  @var{DIM} is a scaler of type @code{INTEGER} in the
2233 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
2235 @item @emph{Standard}:
2236 F95 and later
2238 @item @emph{Class}:
2239 transformational function
2241 @item @emph{Syntax}:
2242 @code{RESULT = COUNT(MASK [, DIM])}
2244 @item @emph{Arguments}:
2245 @multitable @columnfractions .15 .80
2246 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2247 @item @var{DIM}  @tab The type shall be @code{INTEGER}.
2248 @end multitable
2250 @item @emph{Return value}:
2251 The return value is of type @code{INTEGER} with rank equal to that of
2252 @var{MASK}.
2254 @item @emph{Example}:
2255 @smallexample
2256 program test_count
2257     integer, dimension(2,3) :: a, b
2258     logical, dimension(2,3) :: mask
2259     a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2260     b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2261     print '(3i3)', a(1,:)
2262     print '(3i3)', a(2,:)
2263     print *
2264     print '(3i3)', b(1,:)
2265     print '(3i3)', b(2,:)
2266     print *
2267     mask = a.ne.b
2268     print '(3l3)', mask(1,:)
2269     print '(3l3)', mask(2,:)
2270     print *
2271     print '(3i3)', count(mask)
2272     print *
2273     print '(3i3)', count(mask, 1)
2274     print *
2275     print '(3i3)', count(mask, 2)
2276 end program test_count
2277 @end smallexample
2278 @end table
2282 @node CPU_TIME
2283 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2284 @cindex @code{CPU_TIME} intrinsic
2285 @cindex time, elapsed
2286 @cindex elapsed time
2288 @table @asis
2289 @item @emph{Description}:
2290 Returns a @code{REAL} value representing the elapsed CPU time in seconds.  This
2291 is useful for testing segments of code to determine execution time.
2293 @item @emph{Standard}:
2294 F95 and later
2296 @item @emph{Class}:
2297 Subroutine
2299 @item @emph{Syntax}:
2300 @code{CALL CPU_TIME(X)}
2302 @item @emph{Arguments}:
2303 @multitable @columnfractions .15 .80
2304 @item @var{X} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2305 @end multitable
2307 @item @emph{Return value}:
2308 None
2310 @item @emph{Example}:
2311 @smallexample
2312 program test_cpu_time
2313     real :: start, finish
2314     call cpu_time(start)
2315         ! put code to test here
2316     call cpu_time(finish)
2317     print '("Time = ",f6.3," seconds.")',finish-start
2318 end program test_cpu_time
2319 @end smallexample
2320 @end table
2324 @node CSHIFT
2325 @section @code{CSHIFT} --- Circular shift function
2326 @cindex @code{CSHIFT} intrinsic
2327 @cindex bit operations
2329 @table @asis
2330 @item @emph{Description}:
2331 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2332 @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is omitted it is
2333 taken to be @code{1}.  @var{DIM} is a scaler of type @code{INTEGER} in the
2334 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2335 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2336 by @var{SHIFT} places.  If rank is greater than one, then all complete rank one
2337 sections of @var{ARRAY} along the given dimension are shifted.  Elements
2338 shifted out one end of each rank one section are shifted back in the other end.
2340 @item @emph{Standard}:
2341 F95 and later
2343 @item @emph{Class}:
2344 transformational function
2346 @item @emph{Syntax}:
2347 @code{RESULT = CSHIFT(A, SHIFT [, DIM])}
2349 @item @emph{Arguments}:
2350 @multitable @columnfractions .15 .80
2351 @item @var{ARRAY}  @tab May be any type, not scaler.
2352 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
2353 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
2354 @end multitable
2356 @item @emph{Return value}:
2357 Returns an array of same type and rank as the @var{ARRAY} argument.
2359 @item @emph{Example}:
2360 @smallexample
2361 program test_cshift
2362     integer, dimension(3,3) :: a
2363     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2364     print '(3i3)', a(1,:)
2365     print '(3i3)', a(2,:)
2366     print '(3i3)', a(3,:)    
2367     a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2368     print *
2369     print '(3i3)', a(1,:)
2370     print '(3i3)', a(2,:)
2371     print '(3i3)', a(3,:)
2372 end program test_cshift
2373 @end smallexample
2374 @end table
2377 @node CTIME
2378 @section @code{CTIME} --- Convert a time into a string
2379 @cindex @code{CTIME} intrinsic
2380 @cindex time, conversion function
2382 @table @asis
2383 @item @emph{Description}:
2384 @code{CTIME(T,S)} converts @var{T}, a system time value, such as returned
2385 by @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14
2386 1995}, and returns that string into @var{S}.
2388 If @code{CTIME} is invoked as a function, it can not be invoked as a
2389 subroutine, and vice versa.
2391 @var{T} is an @code{INTENT(IN)} @code{INTEGER(KIND=8)} variable.
2392 @var{S} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
2394 @item @emph{Standard}:
2395 GNU extension
2397 @item @emph{Class}:
2398 Subroutine
2400 @item @emph{Syntax}:
2401 @multitable @columnfractions .80
2402 @item @code{CALL CTIME(T,S)}.
2403 @item @code{S = CTIME(T)}, (not recommended).
2404 @end multitable
2406 @item @emph{Arguments}:
2407 @multitable @columnfractions .15 .80
2408 @item @var{S}@tab The type shall be of type @code{CHARACTER}.
2409 @item @var{T}@tab The type shall be of type @code{INTEGER(KIND=8)}.
2410 @end multitable
2412 @item @emph{Return value}:
2413 The converted date and time as a string.
2415 @item @emph{Example}:
2416 @smallexample
2417 program test_ctime
2418     integer(8) :: i
2419     character(len=30) :: date
2420     i = time8()
2422     ! Do something, main part of the program
2423     
2424     call ctime(i,date)
2425     print *, 'Program was started on ', date
2426 end program test_ctime
2427 @end smallexample
2429 @item @emph{See Also}:
2430 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2432 @end table
2436 @node DATE_AND_TIME
2437 @section @code{DATE_AND_TIME} --- Date and time subroutine
2438 @cindex @code{DATE_AND_TIME} intrinsic
2439 @cindex date, current
2440 @cindex current date
2441 @cindex time, current
2442 @cindex current time
2444 @table @asis
2445 @item @emph{Description}:
2446 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2447 time information from the real-time system clock.  @var{DATE} is
2448 @code{INTENT(OUT)} and has form ccyymmdd.  @var{TIME} is @code{INTENT(OUT)} and
2449 has form hhmmss.sss.  @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2450 representing the difference with respect to Coordinated Universal Time (UTC).
2451 Unavailable time and date parameters return blanks.
2453 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2455 @multitable @columnfractions .15 .30 .60
2456 @item @tab @code{VALUE(1)}: @tab The year
2457 @item @tab @code{VALUE(2)}: @tab The month
2458 @item @tab @code{VALUE(3)}: @tab The day of the month
2459 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2460 @item @tab @code{VALUE(5)}: @tab The hour of the day
2461 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2462 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2463 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2464 @end multitable     
2466 @item @emph{Standard}:
2467 F95 and later
2469 @item @emph{Class}:
2470 Subroutine
2472 @item @emph{Syntax}:
2473 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2475 @item @emph{Arguments}:
2476 @multitable @columnfractions .15 .80
2477 @item @var{DATE}  @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2478 @item @var{TIME}  @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2479 @item @var{ZONE}  @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2480 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2481 @end multitable
2483 @item @emph{Return value}:
2484 None
2486 @item @emph{Example}:
2487 @smallexample
2488 program test_time_and_date
2489     character(8)  :: date
2490     character(10) :: time
2491     character(5)  :: zone
2492     integer,dimension(8) :: values
2493     ! using keyword arguments
2494     call date_and_time(date,time,zone,values)
2495     call date_and_time(DATE=date,ZONE=zone)
2496     call date_and_time(TIME=time)
2497     call date_and_time(VALUES=values)
2498     print '(a,2x,a,2x,a)', date, time, zone
2499     print '(8i5))', values
2500 end program test_time_and_date
2501 @end smallexample
2502 @end table
2506 @node DBLE
2507 @section @code{DBLE} --- Double conversion function 
2508 @cindex @code{DBLE} intrinsic
2509 @cindex double conversion
2511 @table @asis
2512 @item @emph{Description}:
2513 @code{DBLE(X)} Converts @var{X} to double precision real type.
2515 @item @emph{Standard}:
2516 F77 and later
2518 @item @emph{Class}:
2519 Elemental function
2521 @item @emph{Syntax}:
2522 @code{RESULT = DBLE(X)}
2524 @item @emph{Arguments}:
2525 @multitable @columnfractions .15 .80
2526 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)},
2527                    or @code{COMPLEX(*)}.
2528 @end multitable
2530 @item @emph{Return value}:
2531 The return value is of type double precision real.
2533 @item @emph{Example}:
2534 @smallexample
2535 program test_dble
2536     real    :: x = 2.18
2537     integer :: i = 5
2538     complex :: z = (2.3,1.14)
2539     print *, dble(x), dble(i), dble(z)
2540 end program test_dble
2541 @end smallexample
2543 @item @emph{See also}:
2544 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2545 @end table
2549 @node DCMPLX
2550 @section @code{DCMPLX} --- Double complex conversion function
2551 @cindex @code{DCMPLX} intrinsic
2552 @cindex complex numbers, conversion to
2554 @table @asis
2555 @item @emph{Description}:
2556 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2557 converted to the real component.  If @var{Y} is present it is converted to the
2558 imaginary component.  If @var{Y} is not present then the imaginary component is
2559 set to 0.0.  If @var{X} is complex then @var{Y} must not be present.
2561 @item @emph{Standard}:
2562 GNU extension
2564 @item @emph{Class}:
2565 Elemental function
2567 @item @emph{Syntax}:
2568 @code{RESULT = DCMPLX(X [, Y])}
2570 @item @emph{Arguments}:
2571 @multitable @columnfractions .15 .80
2572 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2573                    or @code{COMPLEX(*)}.
2574 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX(*)}.) May be
2575                    @code{INTEGER(*)} or @code{REAL(*)}. 
2576 @end multitable
2578 @item @emph{Return value}:
2579 The return value is of type @code{COMPLEX(8)}
2581 @item @emph{Example}:
2582 @smallexample
2583 program test_dcmplx
2584     integer :: i = 42
2585     real :: x = 3.14
2586     complex :: z
2587     z = cmplx(i, x)
2588     print *, dcmplx(i)
2589     print *, dcmplx(x)
2590     print *, dcmplx(z)
2591     print *, dcmplx(x,i)
2592 end program test_dcmplx
2593 @end smallexample
2594 @end table
2598 @node DFLOAT
2599 @section @code{DFLOAT} --- Double conversion function 
2600 @cindex @code{DFLOAT} intrinsic
2601 @cindex double float conversion
2603 @table @asis
2604 @item @emph{Description}:
2605 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2607 @item @emph{Standard}:
2608 GNU extension
2610 @item @emph{Class}:
2611 Elemental function
2613 @item @emph{Syntax}:
2614 @code{RESULT = DFLOAT(X)}
2616 @item @emph{Arguments}:
2617 @multitable @columnfractions .15 .80
2618 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
2619 @end multitable
2621 @item @emph{Return value}:
2622 The return value is of type double precision real.
2624 @item @emph{Example}:
2625 @smallexample
2626 program test_dfloat
2627     integer :: i = 5
2628     print *, dfloat(i)
2629 end program test_dfloat
2630 @end smallexample
2632 @item @emph{See also}:
2633 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
2634 @end table
2638 @node DIGITS
2639 @section @code{DIGITS} --- Significant digits function
2640 @cindex @code{DIGITS} intrinsic
2641 @cindex digits, significant
2643 @table @asis
2644 @item @emph{Description}:
2645 @code{DIGITS(X)} returns the number of significant digits of the internal model
2646 representation of @var{X}.  For example, on a system using a 32-bit
2647 floating point representation, a default real number would likely return 24.
2649 @item @emph{Standard}:
2650 F95 and later
2652 @item @emph{Class}:
2653 Inquiry function
2655 @item @emph{Syntax}:
2656 @code{RESULT = DIGITS(X)}
2658 @item @emph{Arguments}:
2659 @multitable @columnfractions .15 .80
2660 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2661 @end multitable
2663 @item @emph{Return value}:
2664 The return value is of type @code{INTEGER}.
2666 @item @emph{Example}:
2667 @smallexample
2668 program test_digits
2669     integer :: i = 12345
2670     real :: x = 3.143
2671     real(8) :: y = 2.33
2672     print *, digits(i)
2673     print *, digits(x)
2674     print *, digits(y)
2675 end program test_digits
2676 @end smallexample
2677 @end table
2681 @node DIM
2682 @section @code{DIM} --- Dim function
2683 @cindex @code{DIM} intrinsic
2684 @cindex @code{IDIM} intrinsic
2685 @cindex @code{DDIM} intrinsic
2686 @cindex dim
2688 @table @asis
2689 @item @emph{Description}:
2690 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2691 otherwise returns zero.
2693 @item @emph{Standard}:
2694 F77 and later
2696 @item @emph{Class}:
2697 Elemental function
2699 @item @emph{Syntax}:
2700 @code{RESULT = DIM(X, Y)}
2702 @item @emph{Arguments}:
2703 @multitable @columnfractions .15 .80
2704 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2705 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2706 @end multitable
2708 @item @emph{Return value}:
2709 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2711 @item @emph{Example}:
2712 @smallexample
2713 program test_dim
2714     integer :: i
2715     real(8) :: x
2716     i = dim(4, 15)
2717     x = dim(4.345_8, 2.111_8)
2718     print *, i
2719     print *, x
2720 end program test_dim
2721 @end smallexample
2723 @item @emph{Specific names}:
2724 @multitable @columnfractions .20 .20 .20 .40
2725 @item Name             @tab Argument              @tab Return type       @tab Standard
2726 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
2727 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y}    @tab @code{REAL(8)}    @tab F77 and later
2728 @end multitable
2729 @end table
2733 @node DOT_PRODUCT
2734 @section @code{DOT_PRODUCT} --- Dot product function
2735 @cindex @code{DOT_PRODUCT} intrinsic
2736 @cindex dot product
2738 @table @asis
2739 @item @emph{Description}:
2740 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2741 @var{X} and @var{Y}.  The two vectors may be either numeric or logical
2742 and must be arrays of rank one and of equal size. If the vectors are
2743 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2744 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the 
2745 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2747 @item @emph{Standard}:
2748 F95 and later
2750 @item @emph{Class}:
2751 transformational function
2753 @item @emph{Syntax}:
2754 @code{RESULT = DOT_PRODUCT(X, Y)}
2756 @item @emph{Arguments}:
2757 @multitable @columnfractions .15 .80
2758 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2759 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2760 @end multitable
2762 @item @emph{Return value}:
2763 If the arguments are numeric, the return value is a scaler of numeric type,
2764 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.  If the arguments are
2765 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2767 @item @emph{Example}:
2768 @smallexample
2769 program test_dot_prod
2770     integer, dimension(3) :: a, b
2771     a = (/ 1, 2, 3 /)
2772     b = (/ 4, 5, 6 /)
2773     print '(3i3)', a
2774     print *
2775     print '(3i3)', b
2776     print *
2777     print *, dot_product(a,b)
2778 end program test_dot_prod
2779 @end smallexample
2780 @end table
2784 @node DPROD
2785 @section @code{DPROD} --- Double product function
2786 @cindex @code{DPROD} intrinsic
2787 @cindex double-precision product
2789 @table @asis
2790 @item @emph{Description}:
2791 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2793 @item @emph{Standard}:
2794 F77 and later
2796 @item @emph{Class}:
2797 Elemental function
2799 @item @emph{Syntax}:
2800 @code{RESULT = DPROD(X, Y)}
2802 @item @emph{Arguments}:
2803 @multitable @columnfractions .15 .80
2804 @item @var{X} @tab The type shall be @code{REAL}.
2805 @item @var{Y} @tab The type shall be @code{REAL}.
2806 @end multitable
2808 @item @emph{Return value}:
2809 The return value is of type @code{REAL(8)}.
2811 @item @emph{Example}:
2812 @smallexample
2813 program test_dprod
2814     integer :: i
2815     real :: x = 5.2
2816     real :: y = 2.3
2817     real(8) :: d
2818     d = dprod(x,y)
2819     print *, d
2820 end program test_dprod
2821 @end smallexample
2822 @end table
2826 @node DREAL
2827 @section @code{DREAL} --- Double real part function
2828 @cindex @code{DREAL} intrinsic
2829 @cindex double-precision real part
2831 @table @asis
2832 @item @emph{Description}:
2833 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2835 @item @emph{Standard}:
2836 GNU extension
2838 @item @emph{Class}:
2839 Elemental function
2841 @item @emph{Syntax}:
2842 @code{RESULT = DREAL(Z)}
2844 @item @emph{Arguments}:
2845 @multitable @columnfractions .15 .80
2846 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2847 @end multitable
2849 @item @emph{Return value}:
2850 The return value is of type @code{REAL(8)}.
2852 @item @emph{Example}:
2853 @smallexample
2854 program test_dreal
2855     complex(8) :: z = (1.3_8,7.2_8)
2856     print *, dreal(z)
2857 end program test_dreal
2858 @end smallexample
2860 @item @emph{See also}:
2861 @ref{AIMAG}
2863 @end table
2867 @node DTIME
2868 @section @code{DTIME} --- Execution time subroutine (or function)
2869 @cindex @code{DTIME} intrinsic
2870 @cindex time, elapsed
2871 @cindex elapsed time
2873 @table @asis
2874 @item @emph{Description}:
2875 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2876 since the start of the process's execution in @var{RESULT}.  @var{TARRAY}
2877 returns the user and system components of this time in @code{TARRAY(1)} and
2878 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2879 TARRAY(2)}.
2881 Subsequent invocations of @code{DTIME} return values accumulated since the
2882 previous invocation.
2884 On some systems, the underlying timings are represented using types with
2885 sufficiently small limits that overflows (wrap around) are possible, such as
2886 32-bit types. Therefore, the values returned by this intrinsic might be, or
2887 become, negative, or numerically less than previous values, during a single
2888 run of the compiled program.
2890 If @code{DTIME} is invoked as a function, it can not be invoked as a
2891 subroutine, and vice versa.
2893 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2895 @multitable @columnfractions .15 .30 .60
2896 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2897 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2898 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2899 @end multitable
2901 @item @emph{Standard}:
2902 GNU extension
2904 @item @emph{Class}:
2905 Subroutine
2907 @item @emph{Syntax}:
2908 @multitable @columnfractions .80
2909 @item @code{CALL DTIME(TARRAY, RESULT)}.
2910 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
2911 @end multitable
2913 @item @emph{Arguments}:
2914 @multitable @columnfractions .15 .80
2915 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2916 @item @var{RESULT}@tab The type shall be @code{REAL}.
2917 @end multitable
2919 @item @emph{Return value}:
2920 Elapsed time in seconds since the start of program execution.
2922 @item @emph{Example}:
2923 @smallexample
2924 program test_dtime
2925     integer(8) :: i, j
2926     real, dimension(2) :: tarray
2927     real :: result
2928     call dtime(tarray, result)
2929     print *, result
2930     print *, tarray(1)
2931     print *, tarray(2)   
2932     do i=1,100000000    ! Just a delay
2933         j = i * i - i
2934     end do
2935     call dtime(tarray, result)
2936     print *, result
2937     print *, tarray(1)
2938     print *, tarray(2)
2939 end program test_dtime
2940 @end smallexample
2941 @end table
2945 @node EOSHIFT
2946 @section @code{EOSHIFT} --- End-off shift function
2947 @cindex @code{EOSHIFT} intrinsic
2948 @cindex bit operations
2950 @table @asis
2951 @item @emph{Description}:
2952 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
2953 elements of @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is
2954 omitted it is taken to be @code{1}.  @var{DIM} is a scaler of type
2955 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
2956 rank of @var{ARRAY}.  If the rank of @var{ARRAY} is one, then all elements of
2957 @var{ARRAY} are shifted by @var{SHIFT} places.  If rank is greater than one,
2958 then all complete rank one sections of @var{ARRAY} along the given dimension are
2959 shifted.  Elements shifted out one end of each rank one section are dropped.  If
2960 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
2961 is copied back in the other end.  If @var{BOUNDARY} is not present then the
2962 following are copied in depending on the type of @var{ARRAY}.
2964 @multitable @columnfractions .15 .80
2965 @item @emph{Array Type} @tab @emph{Boundary Value}
2966 @item Numeric  @tab 0 of the type and kind of @var{ARRAY}.
2967 @item Logical  @tab @code{.FALSE.}.
2968 @item Character(@var{len}) @tab @var{len} blanks.
2969 @end multitable
2971 @item @emph{Standard}:
2972 F95 and later
2974 @item @emph{Class}:
2975 transformational function
2977 @item @emph{Syntax}:
2978 @code{RESULT = EOSHIFT(A, SHIFT [, BOUNDARY, DIM])}
2980 @item @emph{Arguments}:
2981 @multitable @columnfractions .15 .80
2982 @item @var{ARRAY}  @tab May be any type, not scaler.
2983 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
2984 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}. 
2985 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
2986 @end multitable
2988 @item @emph{Return value}:
2989 Returns an array of same type and rank as the @var{ARRAY} argument.
2991 @item @emph{Example}:
2992 @smallexample
2993 program test_eoshift
2994     integer, dimension(3,3) :: a
2995     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2996     print '(3i3)', a(1,:)
2997     print '(3i3)', a(2,:)
2998     print '(3i3)', a(3,:)    
2999     a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3000     print *
3001     print '(3i3)', a(1,:)
3002     print '(3i3)', a(2,:)
3003     print '(3i3)', a(3,:)
3004 end program test_eoshift
3005 @end smallexample
3006 @end table
3010 @node EPSILON
3011 @section @code{EPSILON} --- Epsilon function
3012 @cindex @code{EPSILON} intrinsic
3013 @cindex epsilon, significant
3015 @table @asis
3016 @item @emph{Description}:
3017 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3019 @item @emph{Standard}:
3020 F95 and later
3022 @item @emph{Class}:
3023 Inquiry function
3025 @item @emph{Syntax}:
3026 @code{RESULT = EPSILON(X)}
3028 @item @emph{Arguments}:
3029 @multitable @columnfractions .15 .80
3030 @item @var{X} @tab The type shall be @code{REAL(*)}.
3031 @end multitable
3033 @item @emph{Return value}:
3034 The return value is of same type as the argument.
3036 @item @emph{Example}:
3037 @smallexample
3038 program test_epsilon
3039     real :: x = 3.143
3040     real(8) :: y = 2.33
3041     print *, EPSILON(x)
3042     print *, EPSILON(y)
3043 end program test_epsilon
3044 @end smallexample
3045 @end table
3049 @node ERF
3050 @section @code{ERF} --- Error function 
3051 @cindex @code{ERF} intrinsic
3052 @cindex error function
3054 @table @asis
3055 @item @emph{Description}:
3056 @code{ERF(X)} computes the error function of @var{X}.
3058 @item @emph{Standard}:
3059 GNU Extension
3061 @item @emph{Class}:
3062 Elemental function
3064 @item @emph{Syntax}:
3065 @code{RESULT = ERF(X)}
3067 @item @emph{Arguments}:
3068 @multitable @columnfractions .15 .80
3069 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3070 @end multitable
3072 @item @emph{Return value}:
3073 The return value is a scalar of type @code{REAL(*)} and it is positive
3074 (@math{ - 1 \leq erf (x) \leq 1 }.
3076 @item @emph{Example}:
3077 @smallexample
3078 program test_erf
3079   real(8) :: x = 0.17_8
3080   x = erf(x)
3081 end program test_erf
3082 @end smallexample
3084 @item @emph{Specific names}:
3085 @multitable @columnfractions .20 .20 .20 .40
3086 @item Name            @tab Argument          @tab Return type       @tab Standard
3087 @item @code{DERF(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
3088 @end multitable
3089 @end table
3093 @node ERFC
3094 @section @code{ERFC} --- Error function 
3095 @cindex @code{ERFC} intrinsic
3096 @cindex error function
3098 @table @asis
3099 @item @emph{Description}:
3100 @code{ERFC(X)} computes the complementary error function of @var{X}.
3102 @item @emph{Standard}:
3103 GNU extension
3105 @item @emph{Class}:
3106 Elemental function
3108 @item @emph{Syntax}:
3109 @code{RESULT = ERFC(X)}
3111 @item @emph{Arguments}:
3112 @multitable @columnfractions .15 .80
3113 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3114 @end multitable
3116 @item @emph{Return value}:
3117 The return value is a scalar of type @code{REAL(*)} and it is positive
3118 (@math{ 0 \leq erfc (x) \leq 2 }.
3120 @item @emph{Example}:
3121 @smallexample
3122 program test_erfc
3123   real(8) :: x = 0.17_8
3124   x = erfc(x)
3125 end program test_erfc
3126 @end smallexample
3128 @item @emph{Specific names}:
3129 @multitable @columnfractions .20 .20 .20 .40
3130 @item Name            @tab Argument          @tab Return type       @tab Standard
3131 @item @code{DERFC(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
3132 @end multitable
3133 @end table
3137 @node ETIME
3138 @section @code{ETIME} --- Execution time subroutine (or function)
3139 @cindex @code{ETIME} intrinsic
3140 @cindex time, elapsed
3142 @table @asis
3143 @item @emph{Description}:
3144 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3145 since the start of the process's execution in @var{RESULT}.  @var{TARRAY}
3146 returns the user and system components of this time in @code{TARRAY(1)} and
3147 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3149 On some systems, the underlying timings are represented using types with
3150 sufficiently small limits that overflows (wrap around) are possible, such as
3151 32-bit types. Therefore, the values returned by this intrinsic might be, or
3152 become, negative, or numerically less than previous values, during a single
3153 run of the compiled program.
3155 If @code{ETIME} is invoked as a function, it can not be invoked as a
3156 subroutine, and vice versa.
3158 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3160 @multitable @columnfractions .15 .30 .60
3161 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3162 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3163 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3164 @end multitable
3166 @item @emph{Standard}:
3167 GNU extension
3169 @item @emph{Class}:
3170 Subroutine
3172 @item @emph{Syntax}:
3173 @multitable @columnfractions .8
3174 @item @code{CALL ETIME(TARRAY, RESULT)}.
3175 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3176 @end multitable
3178 @item @emph{Arguments}:
3179 @multitable @columnfractions .15 .80
3180 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3181 @item @var{RESULT}@tab The type shall be @code{REAL}.
3182 @end multitable
3184 @item @emph{Return value}:
3185 Elapsed time in seconds since the start of program execution.
3187 @item @emph{Example}:
3188 @smallexample
3189 program test_etime
3190     integer(8) :: i, j
3191     real, dimension(2) :: tarray
3192     real :: result
3193     call ETIME(tarray, result)
3194     print *, result
3195     print *, tarray(1)
3196     print *, tarray(2)   
3197     do i=1,100000000    ! Just a delay
3198         j = i * i - i
3199     end do
3200     call ETIME(tarray, result)
3201     print *, result
3202     print *, tarray(1)
3203     print *, tarray(2)
3204 end program test_etime
3205 @end smallexample
3207 @item @emph{See also}:
3208 @ref{CPU_TIME}
3210 @end table
3214 @node EXIT
3215 @section @code{EXIT} --- Exit the program with status. 
3216 @cindex @code{EXIT} intrinsic
3217 @cindex exit program
3219 @table @asis
3220 @item @emph{Description}:
3221 @code{EXIT} causes immediate termination of the program with status.  If status
3222 is omitted it returns the canonical @emph{success} for the system.  All Fortran
3223 I/O units are closed. 
3225 @item @emph{Standard}:
3226 GNU extension
3228 @item @emph{Class}:
3229 Subroutine
3231 @item @emph{Syntax}:
3232 @code{CALL EXIT([STATUS])}
3234 @item @emph{Arguments}:
3235 @multitable @columnfractions .15 .80
3236 @item @var{STATUS} @tab The type of the argument shall be @code{INTEGER(*)}.
3237 @end multitable
3239 @item @emph{Return value}:
3240 @code{STATUS} is passed to the parent process on exit.
3242 @item @emph{Example}:
3243 @smallexample
3244 program test_exit
3245   integer :: STATUS = 0
3246   print *, 'This program is going to exit.'
3247   call EXIT(STATUS)
3248 end program test_exit
3249 @end smallexample
3251 @item @emph{See also}:
3252 @ref{ABORT}, @ref{KILL}
3253 @end table
3257 @node EXP
3258 @section @code{EXP} --- Exponential function 
3259 @cindex @code{EXP} intrinsic
3260 @cindex @code{DEXP} intrinsic
3261 @cindex @code{ZEXP} intrinsic
3262 @cindex @code{CDEXP} intrinsic
3263 @cindex exponential
3265 @table @asis
3266 @item @emph{Description}:
3267 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3269 @item @emph{Standard}:
3270 F77 and later, has overloads that are GNU extensions
3272 @item @emph{Class}:
3273 Elemental function
3275 @item @emph{Syntax}:
3276 @code{RESULT = EXP(X)}
3278 @item @emph{Arguments}:
3279 @multitable @columnfractions .15 .80
3280 @item @var{X} @tab The type shall be @code{REAL(*)} or
3281 @code{COMPLEX(*)}.
3282 @end multitable
3284 @item @emph{Return value}:
3285 The return value has same type and kind as @var{X}.
3287 @item @emph{Example}:
3288 @smallexample
3289 program test_exp
3290   real :: x = 1.0
3291   x = exp(x)
3292 end program test_exp
3293 @end smallexample
3295 @item @emph{Specific names}:
3296 @multitable @columnfractions .20 .20 .20 .40
3297 @item Name            @tab Argument             @tab Return type         @tab Standard
3298 @item @code{DEXP(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}      @tab F77 and later
3299 @item @code{CEXP(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}   @tab F77 and later
3300 @item @code{ZEXP(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
3301 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
3302 @end multitable
3303 @end table
3307 @node EXPONENT
3308 @section @code{EXPONENT} --- Exponent function 
3309 @cindex @code{EXPONENT} intrinsic
3310 @cindex exponent part of a real number
3312 @table @asis
3313 @item @emph{Description}:
3314 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3315 is zero the value returned is zero. 
3317 @item @emph{Standard}:
3318 F95 and later
3320 @item @emph{Class}:
3321 Elemental function
3323 @item @emph{Syntax}:
3324 @code{RESULT = EXPONENT(X)}
3326 @item @emph{Arguments}:
3327 @multitable @columnfractions .15 .80
3328 @item @var{X} @tab The type shall be @code{REAL(*)}.
3329 @end multitable
3331 @item @emph{Return value}:
3332 The return value is of type default @code{INTEGER}.
3334 @item @emph{Example}:
3335 @smallexample
3336 program test_exponent
3337   real :: x = 1.0
3338   integer :: i
3339   i = exponent(x)
3340   print *, i
3341   print *, exponent(0.0)
3342 end program test_exponent
3343 @end smallexample
3344 @end table
3347 @node FDATE
3348 @section @code{FDATE} --- Get the current time as a string
3349 @cindex @code{FDATE} intrinsic
3350 @cindex time, current
3351 @cindex current time
3352 @cindex date, current
3353 @cindex current date
3355 @table @asis
3356 @item @emph{Description}:
3357 @code{FDATE(DATE)} returns the current date (using the same format as
3358 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3359 TIME())}.
3361 If @code{FDATE} is invoked as a function, it can not be invoked as a
3362 subroutine, and vice versa.
3364 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
3366 @item @emph{Standard}:
3367 GNU extension
3369 @item @emph{Class}:
3370 Subroutine
3372 @item @emph{Syntax}:
3373 @multitable @columnfractions .80
3374 @item @code{CALL FDATE(DATE)}.
3375 @item @code{DATE = FDATE()}, (not recommended).
3376 @end multitable
3378 @item @emph{Arguments}:
3379 @multitable @columnfractions .15 .80
3380 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
3381 @end multitable
3383 @item @emph{Return value}:
3384 The current date as a string.
3386 @item @emph{Example}:
3387 @smallexample
3388 program test_fdate
3389     integer(8) :: i, j
3390     character(len=30) :: date
3391     call fdate(date)
3392     print *, 'Program started on ', date
3393     do i = 1, 100000000 ! Just a delay
3394         j = i * i - i
3395     end do
3396     call fdate(date)
3397     print *, 'Program ended on ', date
3398 end program test_fdate
3399 @end smallexample
3400 @end table
3402 @node FLOAT
3404 @section @code{FLOAT} --- Convert integer to default real
3405 @cindex @code{FLOAT} intrinsic
3406 @cindex conversion function (float)
3408 @table @asis
3409 @item @emph{Description}:
3410 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
3412 @item @emph{Standard}:
3413 GNU extension
3415 @item @emph{Class}:
3416 Elemental function
3418 @item @emph{Syntax}:
3419 @code{RESULT = FLOAT(I)}
3421 @item @emph{Arguments}:
3422 @multitable @columnfractions .15 .80
3423 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
3424 @end multitable
3426 @item @emph{Return value}:
3427 The return value is of type default @code{REAL}.
3429 @item @emph{Example}:
3430 @smallexample
3431 program test_float
3432     integer :: i = 1
3433     if (float(i) /= 1.) call abort
3434 end program test_float
3435 @end smallexample
3437 @item @emph{See also}:
3438 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
3439 @end table
3443 @node FGET
3444 @section @code{FGET} --- Read a single character in stream mode from stdin 
3445 @cindex @code{FGET} intrinsic
3446 @cindex file operations
3447 @cindex stream operations
3449 @table @asis
3450 @item @emph{Description}:
3451 Read a single character in stream mode from stdin by bypassing normal 
3452 formatted output. Stream I/O should not be mixed with normal record-oriented 
3453 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3455 This intrinsic routine is provided for backwards compatibility with 
3456 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
3457 Programmers should consider the use of new stream IO feature in new code 
3458 for future portability. See also @ref{Fortran 2003 status}.
3460 @item @emph{Standard}:
3461 GNU extension
3463 @item @emph{Class}:
3464 Non-elemental subroutine
3466 @item @emph{Syntax}:
3467 @code{CALL FGET(C [, STATUS])}
3469 @item @emph{Arguments}:
3470 @multitable @columnfractions .15 .80
3471 @item @var{C}      @tab The type shall be @code{CHARACTER}.
3472 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
3473                         Returns 0 on success, -1 on end-of-file, and a
3474                         system specific positive error code otherwise.
3475 @end multitable
3477 @item @emph{Example}:
3478 @smallexample
3479 PROGRAM test_fget
3480   INTEGER, PARAMETER :: strlen = 100
3481   INTEGER :: status, i = 1
3482   CHARACTER(len=strlen) :: str = ""
3484   WRITE (*,*) 'Enter text:'
3485   DO
3486     CALL fget(str(i:i), status)
3487     if (status /= 0 .OR. i > strlen) exit
3488     i = i + 1
3489   END DO
3490   WRITE (*,*) TRIM(str)
3491 END PROGRAM
3492 @end smallexample
3494 @item @emph{See also}:
3495 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
3496 @end table
3499 @node FGETC
3500 @section @code{FGETC} --- Read a single character in stream mode
3501 @cindex @code{FGETC} intrinsic
3502 @cindex file operations
3503 @cindex stream operations
3505 @table @asis
3506 @item @emph{Description}:
3507 Read a single character in stream mode by bypassing normal formatted output. 
3508 Stream I/O should not be mixed with normal record-oriented (formatted or 
3509 unformatted) I/O on the same unit; the results are unpredictable.
3511 This intrinsic routine is provided for backwards compatibility with 
3512 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
3513 Programmers should consider the use of new stream IO feature in new code 
3514 for future portability. See also @ref{Fortran 2003 status}.
3516 @item @emph{Standard}:
3517 GNU extension
3519 @item @emph{Class}:
3520 Non-elemental subroutine
3522 @item @emph{Syntax}:
3523 @code{CALL FGETC(UNIT, C [, STATUS])}
3525 @item @emph{Arguments}:
3526 @multitable @columnfractions .15 .80
3527 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
3528 @item @var{C}      @tab The type shall be @code{CHARACTER}.
3529 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3530                         -1 on end-of-file and a system specific positive error code otherwise.
3531 @end multitable
3533 @item @emph{Example}:
3534 @smallexample
3535 PROGRAM test_fgetc
3536   INTEGER :: fd = 42, status
3537   CHARACTER :: c
3539   OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
3540   DO
3541     CALL fgetc(fd, c, status)
3542     IF (status /= 0) EXIT
3543     call fput(c)
3544   END DO
3545   CLOSE(UNIT=fd)
3546 END PROGRAM
3547 @end smallexample
3549 @item @emph{See also}:
3550 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
3551 @end table
3555 @node FLOOR
3556 @section @code{FLOOR} --- Integer floor function
3557 @cindex @code{FLOOR} intrinsic
3558 @cindex floor
3560 @table @asis
3561 @item @emph{Description}:
3562 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
3564 @item @emph{Standard}:
3565 F95 and later
3567 @item @emph{Class}:
3568 Elemental function
3570 @item @emph{Syntax}:
3571 @code{RESULT = FLOOR(X [, KIND])}
3573 @item @emph{Arguments}:
3574 @multitable @columnfractions .15 .80
3575 @item @var{X} @tab The type shall be @code{REAL(*)}.
3576 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
3577                       expression indicating the kind parameter of
3578                       the result.
3579 @end multitable
3581 @item @emph{Return value}:
3582 The return value is of type @code{INTEGER(KIND)}
3584 @item @emph{Example}:
3585 @smallexample
3586 program test_floor
3587     real :: x = 63.29
3588     real :: y = -63.59
3589     print *, floor(x) ! returns 63
3590     print *, floor(y) ! returns -64
3591 end program test_floor
3592 @end smallexample
3594 @item @emph{See also}:
3595 @ref{CEILING}, @ref{NINT}
3597 @end table
3601 @node FLUSH
3602 @section @code{FLUSH} --- Flush I/O unit(s)
3603 @cindex @code{FLUSH} intrinsic
3604 @cindex flush output files
3606 @table @asis
3607 @item @emph{Description}:
3608 Flushes Fortran unit(s) currently open for output. Without the optional
3609 argument, all units are flushed, otherwise just the unit specified.
3611 @item @emph{Standard}:
3612 GNU extension
3614 @item @emph{Class}:
3615 non-elemental subroutine
3617 @item @emph{Syntax}:
3618 @code{CALL FLUSH(UNIT)}
3620 @item @emph{Arguments}:
3621 @multitable @columnfractions .15 .80
3622 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
3623 @end multitable
3625 @item @emph{Note}:
3626 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
3627 statement that should be preferred over the @code{FLUSH} intrinsic.
3629 @end table
3633 @node FNUM
3634 @section @code{FNUM} --- File number function
3635 @cindex @code{FNUM} intrinsic
3636 @cindex fnum
3638 @table @asis
3639 @item @emph{Description}:
3640 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
3641 open Fortran I/O unit @code{UNIT}.
3643 @item @emph{Standard}:
3644 GNU extension
3646 @item @emph{Class}:
3647 non-elemental function
3649 @item @emph{Syntax}:
3650 @code{RESULT = FNUM(UNIT)}
3652 @item @emph{Arguments}:
3653 @multitable @columnfractions .15 .80
3654 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3655 @end multitable
3657 @item @emph{Return value}:
3658 The return value is of type @code{INTEGER}
3660 @item @emph{Example}:
3661 @smallexample
3662 program test_fnum
3663   integer :: i
3664   open (unit=10, status = "scratch")
3665   i = fnum(10)
3666   print *, i
3667   close (10)
3668 end program test_fnum
3669 @end smallexample
3670 @end table
3674 @node FPUT
3675 @section @code{FPUT} --- Write a single character in stream mode to stdout 
3676 @cindex @code{FPUT} intrinsic
3677 @cindex file operations
3678 @cindex stream operations
3680 @table @asis
3681 @item @emph{Description}:
3682 Write a single character in stream mode to stdout by bypassing normal 
3683 formatted output. Stream I/O should not be mixed with normal record-oriented 
3684 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3686 This intrinsic routine is provided for backwards compatibility with 
3687 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
3688 Programmers should consider the use of new stream IO feature in new code 
3689 for future portability. See also @ref{Fortran 2003 status}.
3691 @item @emph{Standard}:
3692 GNU extension
3694 @item @emph{Class}:
3695 Non-elemental subroutine
3697 @item @emph{Syntax}:
3698 @code{CALL FPUT(C [, STATUS])}
3700 @item @emph{Arguments}:
3701 @multitable @columnfractions .15 .80
3702 @item @var{C}      @tab The type shall be @code{CHARACTER}.
3703 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3704                         -1 on end-of-file and a system specific positive error code otherwise.
3705 @end multitable
3707 @item @emph{Example}:
3708 @smallexample
3709 PROGRAM test_fput
3710   CHARACTER(len=*) :: str = "gfortran"
3711   INTEGER :: i
3712   DO i = 1, len_trim(str)
3713     CALL fput(str(i:i))
3714   END DO
3715 END PROGRAM
3716 @end smallexample
3718 @item @emph{See also}:
3719 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
3720 @end table
3724 @node FPUTC
3725 @section @code{FPUTC} --- Write a single character in stream mode
3726 @cindex @code{FPUTC} intrinsic
3727 @cindex file operations
3728 @cindex stream operations
3730 @table @asis
3731 @item @emph{Description}:
3732 Write a single character in stream mode by bypassing normal formatted 
3733 output. Stream I/O should not be mixed with normal record-oriented 
3734 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3736 This intrinsic routine is provided for backwards compatibility with 
3737 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
3738 Programmers should consider the use of new stream IO feature in new code 
3739 for future portability. See also @ref{Fortran 2003 status}.
3741 @item @emph{Standard}:
3742 GNU extension
3744 @item @emph{Class}:
3745 Non-elemental subroutine
3747 @item @emph{Syntax}:
3748 @code{CALL FPUTC(UNIT, C [, STATUS])}
3750 @item @emph{Arguments}:
3751 @multitable @columnfractions .15 .80
3752 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
3753 @item @var{C}      @tab The type shall be @code{CHARACTER}.
3754 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3755                         -1 on end-of-file and a system specific positive error code otherwise.
3756 @end multitable
3758 @item @emph{Example}:
3759 @smallexample
3760 PROGRAM test_fputc
3761   CHARACTER(len=*) :: str = "gfortran"
3762   INTEGER :: fd = 42, i
3764   OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
3765   DO i = 1, len_trim(str)
3766     CALL fputc(fd, str(i:i))
3767   END DO
3768   CLOSE(fd)
3769 END PROGRAM
3770 @end smallexample
3772 @item @emph{See also}:
3773 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
3774 @end table
3778 @node FRACTION
3779 @section @code{FRACTION} --- Fractional part of the model representation
3780 @cindex @code{FRACTION} intrinsic
3781 @cindex fractional part
3783 @table @asis
3784 @item @emph{Description}:
3785 @code{FRACTION(X)} returns the fractional part of the model
3786 representation of @code{X}.
3788 @item @emph{Standard}:
3789 F95 and later
3791 @item @emph{Class}:
3792 Elemental function
3794 @item @emph{Syntax}:
3795 @code{Y = FRACTION(X)}
3797 @item @emph{Arguments}:
3798 @multitable @columnfractions .15 .80
3799 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
3800 @end multitable
3802 @item @emph{Return value}:
3803 The return value is of the same type and kind as the argument.
3804 The fractional part of the model representation of @code{X} is returned;
3805 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
3807 @item @emph{Example}:
3808 @smallexample
3809 program test_fraction
3810   real :: x
3811   x = 178.1387e-4
3812   print *, fraction(x), x * radix(x)**(-exponent(x))
3813 end program test_fraction
3814 @end smallexample
3816 @end table
3820 @node FREE
3821 @section @code{FREE} --- Frees memory
3822 @cindex @code{FREE} intrinsic
3823 @cindex Cray pointers
3825 @table @asis
3826 @item @emph{Description}:
3827 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
3828 intrinsic is an extension intended to be used with Cray pointers, and is
3829 provided in GNU Fortran to allow user to compile legacy code. For
3830 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
3831 @code{DEALLOCATE}.
3833 @item @emph{Standard}:
3834 GNU extension
3836 @item @emph{Class}:
3837 Subroutine
3839 @item @emph{Syntax}:
3840 @code{FREE(PTR)}
3842 @item @emph{Arguments}:
3843 @multitable @columnfractions .15 .80
3844 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
3845 location of the memory that should be de-allocated.
3846 @end multitable
3848 @item @emph{Return value}:
3849 None
3851 @item @emph{Example}:
3852 See @code{MALLOC} for an example.
3854 @item @emph{See also}:
3855 @ref{MALLOC}
3856 @end table
3861 @node FSTAT
3862 @section @code{FSTAT} --- Get file status
3863 @cindex @code{FSTAT} intrinsic
3864 @cindex file system operations 
3866 @table @asis
3867 @item @emph{Description}:
3868 @code{FSTAT} is identical to @ref{STAT}, except that information about an 
3869 already opened file is obtained.
3871 The elements in @code{BUFF} are the same as described by @ref{STAT}.
3873 @item @emph{Standard}:
3874 GNU extension
3876 @item @emph{Class}:
3877 Non-elemental subroutine
3879 @item @emph{Syntax}:
3880 @code{CALL FSTAT(UNIT, BUFF [, STATUS])}
3882 @item @emph{Arguments}:
3883 @multitable @columnfractions .15 .80
3884 @item @var{UNIT}   @tab An open I/O unit number of type @code{INTEGER}.
3885 @item @var{BUFF}   @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
3886 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
3887                         on success and a system specific error code otherwise.
3888 @end multitable
3890 @item @emph{Example}:
3891 See @ref{STAT} for an example.
3893 @item @emph{See also}:
3894 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
3895 @end table
3899 @node FSEEK
3900 @section @code{FSEEK} --- Low level file positioning subroutine
3901 @cindex @code{FSEEK} intrinsic
3902 @cindex file system operations
3904 Not yet implemented in GNU Fortran.
3906 @table @asis
3907 @item @emph{Description}:
3909 @item @emph{Standard}:
3910 GNU extension
3912 @item @emph{Class}:
3913 Subroutine
3915 @item @emph{Syntax}:
3916 @item @emph{Arguments}:
3917 @item @emph{Return value}:
3918 @item @emph{Example}:
3919 @item @emph{Specific names}:
3920 @item @emph{See also}:
3921 @uref{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19292, g77 features lacking in gfortran}
3923 @end table
3927 @node FTELL
3928 @section @code{FTELL} --- Current stream position
3929 @cindex @code{FTELL} intrinsic
3931 @table @asis
3932 @item @emph{Description}:
3933 Retrieves the current position within an open file.
3935 This intrinsic is provided in both subroutine and function forms; however,
3936 only one form can be used in any given program unit.
3938 @item @emph{Standard}:
3939 GNU extension
3941 @item @emph{Class}:
3942 Subroutine, function
3944 @item @emph{Syntax}:
3945 @multitable @columnfractions .80
3946 @item @code{CALL FTELL(UNIT, OFFSET)}
3947 @item @code{OFFSET = FTELL(UNIT)}
3948 @end multitable
3950 @item @emph{Arguments}:
3951 @multitable @columnfractions .15 .80
3952 @item @var{OFFSET}  @tab Shall of type @code{INTEGER}.
3953 @item @var{UNIT}    @tab Shall of type @code{INTEGER}.
3954 @end multitable
3956 @item @emph{Return value}:
3957 In either syntax, @var{OFFSET} is set to the current offset of unit
3958 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
3960 @item @emph{Example}:
3961 @smallexample
3962 PROGRAM test_ftell
3963   INTEGER :: i
3964   OPEN(10, FILE="temp.dat")
3965   CALL ftell(10,i)
3966   WRITE(*,*) i
3967 END PROGRAM
3968 @end smallexample
3970 @item @emph{See also}:
3971 @ref{FSEEK}
3972 @end table
3976 @node GETARG
3977 @section @code{GETARG} --- Get command line arguments
3978 @cindex @code{GETARG} intrinsic
3979 @cindex command-line arguments, to program
3981 @table @asis
3982 @item @emph{Description}:
3983 Retrieve the @var{N}th argument that was passed on the
3984 command line when the containing program was invoked.
3986 This intrinsic routine is provided for backwards compatibility with 
3987 GNU Fortran 77.  In new code, programmers should consider the use of 
3988 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003 
3989 standard.
3991 @item @emph{Standard}:
3992 GNU extension
3994 @item @emph{Class}:
3995 Subroutine
3997 @item @emph{Syntax}:
3998 @code{CALL GETARG(N, ARG)}
4000 @item @emph{Arguments}:
4001 @multitable @columnfractions .15 .80
4002 @item @var{N}   @tab Shall of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4003 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}. 
4004 @end multitable
4006 @item @emph{Return value}:
4007 After @code{GETARG} returns, the @var{ARG} argument holds the @var{N}th 
4008 command line argument. If @var{ARG} can not hold the argument, it is 
4009 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4010 arguments specified at the command line, @var{ARG} will be filled with blanks.
4011 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4012 that support this feature).
4014 @item @emph{Example}:
4015 @smallexample
4016 PROGRAM test_getarg
4017   INTEGER :: i
4018   CHARACTER(len=32) :: arg
4020   DO i = 1, iargc()
4021     CALL getarg(i, arg)
4022     WRITE (*,*) arg
4023   END DO
4024 END PROGRAM
4025 @end smallexample
4027 @item @emph{See also}:
4028 GNU Fortran 77 compatibility function: @ref{IARGC}
4030 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4031 @ref{COMMAND_ARGUMENT_COUNT}
4032 @end table
4036 @node GET_COMMAND
4037 @section @code{GET_COMMAND} --- Get the entire command line
4038 @cindex @code{GET_COMMAND} intrinsic
4039 @cindex command-line arguments, to program
4041 @table @asis
4042 @item @emph{Description}:
4043 Retrieve the entire command line that was used to invoke the program.
4045 @item @emph{Standard}:
4046 F2003
4048 @item @emph{Class}:
4049 Subroutine
4051 @item @emph{Syntax}:
4052 @code{CALL GET_COMMAND(CMD)}
4054 @item @emph{Arguments}:
4055 @multitable @columnfractions .15 .80
4056 @item @var{CMD} @tab Shall be of type @code{CHARACTER(*)}. 
4057 @end multitable
4059 @item @emph{Return value}:
4060 Stores the entire command line that was used to invoke the program in @var{ARG}. 
4061 If @var{ARG} is not large enough, the command will be truncated. 
4063 @item @emph{Example}:
4064 @smallexample
4065 PROGRAM test_get_command
4066   CHARACTER(len=255) :: cmd
4067   CALL get_command(cmd)
4068   WRITE (*,*) TRIM(cmd)
4069 END PROGRAM
4070 @end smallexample
4072 @item @emph{See also}:
4073 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4074 @end table
4078 @node GET_COMMAND_ARGUMENT
4079 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4080 @cindex @code{GET_COMMAND_ARGUMENT} intrinsic
4081 @cindex command-line arguments, to program
4083 @table @asis
4084 @item @emph{Description}:
4085 Retrieve the @var{N}th argument that was passed on the
4086 command line when the containing program was invoked.
4088 @item @emph{Standard}:
4089 F2003
4091 @item @emph{Class}:
4092 Subroutine
4094 @item @emph{Syntax}:
4095 @code{CALL GET_COMMAND_ARGUMENT(N, ARG)}
4097 @item @emph{Arguments}:
4098 @multitable @columnfractions .15 .80
4099 @item @var{N}   @tab Shall of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4100 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}. 
4101 @end multitable
4103 @item @emph{Return value}:
4104 After @code{GET_COMMAND_ARGUMENT} returns, the @var{ARG} argument holds the 
4105 @var{N}th command line argument. If @var{ARG} can not hold the argument, it is 
4106 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4107 arguments specified at the command line, @var{ARG} will be filled with blanks. 
4108 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4109 that support this feature).
4111 @item @emph{Example}:
4112 @smallexample
4113 PROGRAM test_get_command_argument
4114   INTEGER :: i
4115   CHARACTER(len=32) :: arg
4117   i = 0
4118   DO
4119     CALL get_command_argument(i, arg)
4120     IF (LEN_TRIM(arg) == 0) EXIT
4122     WRITE (*,*) TRIM(arg)
4123     i = i+1
4124   END DO
4125 END PROGRAM
4126 @end smallexample
4128 @item @emph{See also}:
4129 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4130 @end table
4134 @node GETCWD
4135 @section @code{GETCWD} --- Get current working directory
4136 @cindex @code{GETCWD} intrinsic
4137 @cindex file system operations
4139 @table @asis
4140 @item @emph{Description}:
4141 Get current working directory.
4143 @item @emph{Standard}:
4144 GNU extension
4146 @item @emph{Class}:
4147 Non-elemental subroutine.
4149 @item @emph{Syntax}:
4150 @code{CALL GETCWD(CWD [, STATUS])}
4152 @item @emph{Arguments}:
4153 @multitable @columnfractions .15 .80
4154 @item @var{CWD}    @tab The type shall be @code{CHARACTER(*)}.
4155 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success, 
4156                         a system specific and non-zero error code otherwise.
4157 @end multitable
4159 @item @emph{Example}:
4160 @smallexample
4161 PROGRAM test_getcwd
4162   CHARACTER(len=255) :: cwd
4163   CALL getcwd(cwd)
4164   WRITE(*,*) TRIM(cwd)
4165 END PROGRAM
4166 @end smallexample
4168 @item @emph{See also}:
4169 @ref{CHDIR}
4170 @end table
4174 @node GETENV
4175 @section @code{GETENV} --- Get an environmental variable
4176 @cindex @code{GETENV} intrinsic
4177 @cindex environment variable
4179 @table @asis
4180 @item @emph{Description}:
4181 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4183 This intrinsic routine is provided for backwards compatibility with 
4184 GNU Fortran 77.  In new code, programmers should consider the use of 
4185 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4186 2003 standard.
4188 @item @emph{Standard}:
4189 GNU extension
4191 @item @emph{Class}:
4192 Subroutine
4194 @item @emph{Syntax}:
4195 @code{CALL GETENV(ENVVAR, VALUE)}
4197 @item @emph{Arguments}:
4198 @multitable @columnfractions .15 .80
4199 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}. 
4200 @item @var{VALUE}  @tab Shall be of type @code{CHARACTER(*)}. 
4201 @end multitable
4203 @item @emph{Return value}:
4204 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is 
4205 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4206 is not set, @var{VALUE} will be filled with blanks.
4208 @item @emph{Example}:
4209 @smallexample
4210 PROGRAM test_getenv
4211   CHARACTER(len=255) :: homedir
4212   CALL getenv("HOME", homedir)
4213   WRITE (*,*) TRIM(homedir)
4214 END PROGRAM
4215 @end smallexample
4217 @item @emph{See also}:
4218 @ref{GET_ENVIRONMENT_VARIABLE}
4219 @end table
4223 @node GET_ENVIRONMENT_VARIABLE
4224 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
4225 @cindex @code{GET_ENVIRONMENT_VARIABLE} intrinsic
4226 @cindex environment variable
4228 @table @asis
4229 @item @emph{Description}:
4230 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4232 @item @emph{Standard}:
4233 F2003
4235 @item @emph{Class}:
4236 Subroutine
4238 @item @emph{Syntax}:
4239 @code{CALL GET_ENVIRONMENT_VARIABLE(ENVVAR, VALUE)}
4241 @item @emph{Arguments}:
4242 @multitable @columnfractions .15 .80
4243 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}. 
4244 @item @var{VALUE}  @tab Shall be of type @code{CHARACTER(*)}. 
4245 @end multitable
4247 @item @emph{Return value}:
4248 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is 
4249 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4250 is not set, @var{VALUE} will be filled with blanks.
4252 @item @emph{Example}:
4253 @smallexample
4254 PROGRAM test_getenv
4255   CHARACTER(len=255) :: homedir
4256   CALL get_environment_variable("HOME", homedir)
4257   WRITE (*,*) TRIM(homedir)
4258 END PROGRAM
4259 @end smallexample
4260 @end table
4264 @node GETGID
4265 @section @code{GETGID} --- Group ID function
4266 @cindex @code{GETGID} intrinsic
4267 @cindex file system operations
4269 @table @asis
4270 @item @emph{Description}:
4271 Returns the numerical group ID of the current process.
4273 @item @emph{Standard}:
4274 GNU extension
4276 @item @emph{Class}:
4277 function
4279 @item @emph{Syntax}:
4280 @code{RESULT = GETGID()}
4282 @item @emph{Return value}:
4283 The return value of @code{GETGID} is an @code{INTEGER} of the default
4284 kind.
4287 @item @emph{Example}:
4288 See @code{GETPID} for an example.
4290 @item @emph{See also}:
4291 @ref{GETPID}, @ref{GETUID}
4292 @end table
4296 @node GETLOG
4297 @section @code{GETLOG} --- Get login name
4298 @cindex @code{GETLOG} intrinsic
4300 @table @asis
4301 @item @emph{Description}:
4302 Gets the username under which the program is running.
4304 @item @emph{Standard}:
4305 GNU extension
4307 @item @emph{Class}:
4308 Subroutine
4310 @item @emph{Syntax}:
4311 @code{CALL GETLOG(LOGIN)}
4313 @item @emph{Arguments}:
4314 @multitable @columnfractions .15 .80
4315 @item @var{LOGIN} @tab Shall be of type @code{CHARACTER(*)}.
4316 @end multitable
4318 @item @emph{Return value}:
4319 Stores the current user name in @var{LOGIN}.  (On systems where 
4320 the @code{getlogin(3)} function is not implemented, this will
4321 return a blank string.)
4323 @item @emph{Example}:
4324 @smallexample
4325 PROGRAM TEST_GETLOG
4326   CHARACTER(32) :: login
4327   CALL GETLOG(login)
4328   WRITE(*,*) login
4329 END PROGRAM
4330 @end smallexample
4332 @item @emph{See also}:
4333 @ref{GETUID}
4334 @end table
4338 @node GETPID
4339 @section @code{GETPID} --- Process ID function
4340 @cindex @code{GETPID} intrinsic
4341 @cindex process ID, current
4343 @table @asis
4344 @item @emph{Description}:
4345 Returns the numerical process identifier of the current process.
4347 @item @emph{Standard}:
4348 GNU extension
4350 @item @emph{Class}:
4351 function
4353 @item @emph{Syntax}:
4354 @code{RESULT = GETPID()}
4356 @item @emph{Return value}:
4357 The return value of @code{GETPID} is an @code{INTEGER} of the default
4358 kind.
4361 @item @emph{Example}:
4362 @smallexample
4363 program info
4364   print *, "The current process ID is ", getpid()
4365   print *, "Your numerical user ID is ", getuid()
4366   print *, "Your numerical group ID is ", getgid()
4367 end program info
4368 @end smallexample
4370 @item @emph{See also}:
4371 @ref{GETGID}, @ref{GETUID}
4372 @end table
4376 @node GETUID
4377 @section @code{GETUID} --- User ID function
4378 @cindex @code{GETUID} intrinsic
4379 @cindex user ID, current
4381 @table @asis
4382 @item @emph{Description}:
4383 Returns the numerical user ID of the current process.
4385 @item @emph{Standard}:
4386 GNU extension
4388 @item @emph{Class}:
4389 function
4391 @item @emph{Syntax}:
4392 @code{RESULT = GETUID()}
4394 @item @emph{Return value}:
4395 The return value of @code{GETUID} is an @code{INTEGER} of the default
4396 kind.
4399 @item @emph{Example}:
4400 See @code{GETPID} for an example.
4402 @item @emph{See also}:
4403 @ref{GETPID}, @ref{GETLOG}
4404 @end table
4408 @node GMTIME
4409 @section @code{GMTIME} --- Convert time to GMT info
4410 @cindex @code{GMTIME} intrinsic
4411 @cindex time, conversion function
4413 @table @asis
4414 @item @emph{Description}:
4415 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
4416 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
4417 to the UTC time zone (Universal Coordinated Time, also known in some
4418 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
4420 @item @emph{Standard}:
4421 GNU extension
4423 @item @emph{Class}:
4424 Subroutine
4426 @item @emph{Syntax}:
4427 @code{CALL GMTIME(STIME, TARRAY)}
4429 @item @emph{Arguments}:
4430 @multitable @columnfractions .15 .80
4431 @item @var{STIME}  @tab An @code{INTEGER(*)} scalar expression
4432                         corresponding to a system time, with 
4433                         @code{INTENT(IN)}.
4434 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
4435                         with @code{INTENT(OUT)}.
4436 @end multitable
4438 @item @emph{Return value}:
4439 The elements of @var{TARRAY} are assigned as follows:
4440 @enumerate
4441 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
4442       seconds
4443 @item Minutes after the hour, range 0--59
4444 @item Hours past midnight, range 0--23
4445 @item Day of month, range 0--31
4446 @item Number of months since January, range 0--12
4447 @item Years since 1900
4448 @item Number of days since Sunday, range 0--6
4449 @item Days since January 1
4450 @item Daylight savings indicator: positive if daylight savings is in
4451       effect, zero if not, and negative if the information is not
4452       available.
4453 @end enumerate
4455 @item @emph{See also}:
4456 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
4458 @end table
4462 @node HOSTNM
4463 @section @code{HOSTNM} --- Get system host name
4464 @cindex @code{HOSTNM} intrinsic
4466 @table @asis
4467 @item @emph{Description}:
4468 Retrieves the host name of the system on which the program is running.
4470 This intrinsic is provided in both subroutine and function forms; however,
4471 only one form can be used in any given program unit.
4473 @item @emph{Standard}:
4474 GNU extension
4476 @item @emph{Class}:
4477 Subroutine, function
4479 @item @emph{Syntax}:
4480 @multitable @columnfractions .80
4481 @item @code{CALL HOSTNM(NAME[, STATUS])}
4482 @item @code{STATUS = HOSTNM(NAME)}
4483 @end multitable
4485 @item @emph{Arguments}:
4486 @multitable @columnfractions .15 .80
4487 @item @var{NAME}    @tab Shall of type @code{CHARACTER(*)}.
4488 @item @var{STATUS}  @tab (Optional) status flag of type @code{INTEGER}.
4489                          Returns 0 on success, or a system specific error
4490                          code otherwise.
4491 @end multitable
4493 @item @emph{Return value}:
4494 In either syntax, @var{NAME} is set to the current hostname if it can
4495 be obtained, or to a blank string otherwise.
4497 @end table
4501 @node HUGE
4502 @section @code{HUGE} --- Largest number of a kind
4503 @cindex @code{HUGE} intrinsic
4504 @cindex huge
4506 @table @asis
4507 @item @emph{Description}:
4508 @code{HUGE(X)} returns the largest number that is not an infinity in
4509 the model of the type of @code{X}.
4511 @item @emph{Standard}:
4512 F95 and later
4514 @item @emph{Class}:
4515 Elemental function
4517 @item @emph{Syntax}:
4518 @code{RESULT = HUGE(X)}
4520 @item @emph{Arguments}:
4521 @multitable @columnfractions .15 .80
4522 @item @var{X} @tab shall be of type @code{REAL} or @code{INTEGER}.
4523 @end multitable
4525 @item @emph{Return value}:
4526 The return value is of the same type and kind as @var{X}
4528 @item @emph{Example}:
4529 @smallexample
4530 program test_huge_tiny
4531   print *, huge(0), huge(0.0), huge(0.0d0)
4532   print *, tiny(0.0), tiny(0.0d0)
4533 end program test_huge_tiny
4534 @end smallexample
4535 @end table
4539 @node IACHAR
4540 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence 
4541 @cindex @code{IACHAR} intrinsic
4542 @cindex @acronym{ASCII} collating sequence
4543 @cindex conversion function (character)
4545 @table @asis
4546 @item @emph{Description}:
4547 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
4548 in the first character position of @code{C}.
4550 @item @emph{Standard}:
4551 F95 and later
4553 @item @emph{Class}:
4554 Elemental function
4556 @item @emph{Syntax}:
4557 @code{RESULT = IACHAR(C)}
4559 @item @emph{Arguments}:
4560 @multitable @columnfractions .15 .80
4561 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4562 @end multitable
4564 @item @emph{Return value}:
4565 The return value is of type @code{INTEGER} and of the default integer
4566 kind.
4568 @item @emph{Example}:
4569 @smallexample
4570 program test_iachar
4571   integer i
4572   i = iachar(' ')
4573 end program test_iachar
4574 @end smallexample
4576 @item @emph{See also}:
4577 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
4579 @end table
4582 @node IAND
4583 @section @code{IAND} --- Bitwise logical and
4584 @cindex @code{IAND} intrinsic
4585 @cindex bit operations
4587 @table @asis
4588 @item @emph{Description}:
4589 Bitwise logical @code{AND}.
4591 @item @emph{Standard}:
4592 F95 and later
4594 @item @emph{Class}:
4595 Elemental function
4597 @item @emph{Syntax}:
4598 @code{RESULT = IAND(I, J)}
4600 @item @emph{Arguments}:
4601 @multitable @columnfractions .15 .80
4602 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4603 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4604 kind as @var{I}.  (As a GNU extension, different kinds are also 
4605 permitted.)
4606 @end multitable
4608 @item @emph{Return value}:
4609 The return type is @code{INTEGER(*)}, of the same kind as the
4610 arguments.  (If the argument kinds differ, it is of the same kind as
4611 the larger argument.)
4613 @item @emph{Example}:
4614 @smallexample
4615 PROGRAM test_iand
4616   INTEGER :: a, b
4617   DATA a / Z'F' /, b / Z'3' /
4618   WRITE (*,*) IAND(a, b)
4619 END PROGRAM
4620 @end smallexample
4622 @item @emph{See also}:
4623 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4625 @end table
4629 @node IARGC
4630 @section @code{IARGC} --- Get the number of command line arguments
4631 @cindex @code{IARGC} intrinsic
4632 @cindex command-line arguments, to program
4634 @table @asis
4635 @item @emph{Description}:
4636 @code{IARGC()} returns the number of arguments passed on the
4637 command line when the containing program was invoked.
4639 This intrinsic routine is provided for backwards compatibility with 
4640 GNU Fortran 77.  In new code, programmers should consider the use of 
4641 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003 
4642 standard.
4644 @item @emph{Standard}:
4645 GNU extension
4647 @item @emph{Class}:
4648 Non-elemental Function
4650 @item @emph{Syntax}:
4651 @code{RESULT = IARGC()}
4653 @item @emph{Arguments}:
4654 None.
4656 @item @emph{Return value}:
4657 The number of command line arguments, type @code{INTEGER(4)}.
4659 @item @emph{Example}:
4660 See @ref{GETARG}
4662 @item @emph{See also}:
4663 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
4665 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4666 @ref{COMMAND_ARGUMENT_COUNT}
4667 @end table
4671 @node IBCLR
4672 @section @code{IBCLR} --- Clear bit
4673 @cindex @code{IBCLR} intrinsic
4674 @cindex bit operations
4676 @table @asis
4677 @item @emph{Description}:
4678 @code{IBCLR} returns the value of @var{I} with the bit at position
4679 @var{POS} set to zero.
4681 @item @emph{Standard}:
4682 F95 and later
4684 @item @emph{Class}:
4685 Elemental function
4687 @item @emph{Syntax}:
4688 @code{RESULT = IBCLR(I, POS)}
4690 @item @emph{Arguments}:
4691 @multitable @columnfractions .15 .80
4692 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4693 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4694 @end multitable
4696 @item @emph{Return value}:
4697 The return value is of type @code{INTEGER(*)} and of the same kind as
4698 @var{I}.
4700 @item @emph{See also}:
4701 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4703 @end table
4707 @node IBITS
4708 @section @code{IBITS} --- Bit extraction
4709 @cindex @code{IBITS} intrinsic
4710 @cindex bit operations
4712 @table @asis
4713 @item @emph{Description}:
4714 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
4715 starting from bit position @var{POS} and extending left for @var{LEN}
4716 bits.  The result is right-justified and the remaining bits are
4717 zeroed.  The value of @code{POS+LEN} must be less than or equal to the
4718 value @code{BIT_SIZE(I)}.
4720 @item @emph{Standard}:
4721 F95 and later
4723 @item @emph{Class}:
4724 Elemental function
4726 @item @emph{Syntax}:
4727 @code{RESULT = IBITS(I, POS, LEN)}
4729 @item @emph{Arguments}:
4730 @multitable @columnfractions .15 .80
4731 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4732 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4733 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
4734 @end multitable
4736 @item @emph{Return value}:
4737 The return value is of type @code{INTEGER(*)} and of the same kind as
4738 @var{I}.
4740 @item @emph{See also}:
4741 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4742 @end table
4746 @node IBSET
4747 @section @code{IBSET} --- Set bit
4748 @cindex @code{IBSET} intrinsic
4749 @cindex bit operations
4751 @table @asis
4752 @item @emph{Description}:
4753 @code{IBSET} returns the value of @var{I} with the bit at position
4754 @var{POS} set to one.
4756 @item @emph{Standard}:
4757 F95 and later
4759 @item @emph{Class}:
4760 Elemental function
4762 @item @emph{Syntax}:
4763 @code{RESULT = IBSET(I, POS)}
4765 @item @emph{Arguments}:
4766 @multitable @columnfractions .15 .80
4767 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4768 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4769 @end multitable
4771 @item @emph{Return value}:
4772 The return value is of type @code{INTEGER(*)} and of the same kind as
4773 @var{I}.
4775 @item @emph{See also}:
4776 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4778 @end table
4782 @node ICHAR
4783 @section @code{ICHAR} --- Character-to-integer conversion function
4784 @cindex @code{ICHAR} intrinsic
4785 @cindex conversion function (character)
4787 @table @asis
4788 @item @emph{Description}:
4789 @code{ICHAR(C)} returns the code for the character in the first character
4790 position of @code{C} in the system's native character set.
4791 The correspondence between characters and their codes is not necessarily
4792 the same across different GNU Fortran implementations.
4794 @item @emph{Standard}:
4795 F95 and later
4797 @item @emph{Class}:
4798 Elemental function
4800 @item @emph{Syntax}:
4801 @code{RESULT = ICHAR(C)}
4803 @item @emph{Arguments}:
4804 @multitable @columnfractions .15 .80
4805 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4806 @end multitable
4808 @item @emph{Return value}:
4809 The return value is of type @code{INTEGER} and of the default integer
4810 kind.
4812 @item @emph{Example}:
4813 @smallexample
4814 program test_ichar
4815   integer i
4816   i = ichar(' ')
4817 end program test_ichar
4818 @end smallexample
4820 @item @emph{Note}:
4821 No intrinsic exists to convert a printable character string to a numerical
4822 value. For example, there is no intrinsic that, given the @code{CHARACTER}
4823 value 154, returns an @code{INTEGER} or @code{REAL} value with the
4824 value 154.
4826 Instead, you can use internal-file I/O to do this kind of conversion. For
4827 example:
4828 @smallexample
4829 program read_val
4830   integer value
4831   character(len=10) string
4833   string = '154'
4834   read (string,'(I10)') value
4835   print *, value
4836 end program read_val
4837 @end smallexample
4839 @item @emph{See also}:
4840 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
4842 @end table
4846 @node IDATE
4847 @section @code{IDATE} --- Get current local time subroutine (day/month/year) 
4848 @cindex @code{IDATE} intrinsic
4850 @table @asis
4851 @item @emph{Description}:
4852 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the  
4853 current local time. The day (in the range 1-31), month (in the range 1-12), 
4854 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively. 
4855 The year has four significant digits.
4857 @item @emph{Standard}:
4858 GNU extension
4860 @item @emph{Class}:
4861 Subroutine
4863 @item @emph{Syntax}:
4864 @code{CALL IDATE(TARRAY)}
4866 @item @emph{Arguments}:
4867 @multitable @columnfractions .15 .80
4868 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
4869 the kind shall be the default integer kind.
4870 @end multitable
4872 @item @emph{Return value}:
4873 Does not return.
4875 @item @emph{Example}:
4876 @smallexample
4877 program test_idate
4878   integer, dimension(3) :: tarray
4879   call idate(tarray)
4880   print *, tarray(1)
4881   print *, tarray(2)
4882   print *, tarray(3)
4883 end program test_idate
4884 @end smallexample
4885 @end table
4889 @node IEOR
4890 @section @code{IEOR} --- Bitwise logical exclusive or
4891 @cindex @code{IEOR} intrinsic
4892 @cindex bit operations
4894 @table @asis
4895 @item @emph{Description}:
4896 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
4897 @var{J}.
4899 @item @emph{Standard}:
4900 F95 and later
4902 @item @emph{Class}:
4903 Elemental function
4905 @item @emph{Syntax}:
4906 @code{RESULT = IEOR(I, J)}
4908 @item @emph{Arguments}:
4909 @multitable @columnfractions .15 .80
4910 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4911 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4912 kind as @var{I}.  (As a GNU extension, different kinds are also 
4913 permitted.)
4914 @end multitable
4916 @item @emph{Return value}:
4917 The return type is @code{INTEGER(*)}, of the same kind as the
4918 arguments.  (If the argument kinds differ, it is of the same kind as
4919 the larger argument.)
4921 @item @emph{See also}:
4922 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4923 @end table
4927 @node IERRNO
4928 @section @code{IERRNO} --- Get the last system error number
4929 @cindex @code{IERRNO} intrinsic
4931 @table @asis
4932 @item @emph{Description}:
4933 Returns the last system error number, as given by the C @code{errno()}
4934 function.
4936 @item @emph{Standard}:
4937 GNU extension
4939 @item @emph{Class}:
4940 Elemental function
4942 @item @emph{Syntax}:
4943 @code{RESULT = IERRNO()}
4945 @item @emph{Arguments}:
4946 None.
4948 @item @emph{Return value}:
4949 The return value is of type @code{INTEGER} and of the default integer
4950 kind.
4952 @item @emph{See also}:
4953 @ref{PERROR}
4954 @end table
4958 @node INDEX
4959 @section @code{INDEX} --- Position of a substring within a string
4960 @cindex @code{INDEX} intrinsic
4962 @table @asis
4963 @item @emph{Description}:
4964 Returns the position of the start of the first occurrence of string
4965 @var{SUBSTRING} as a substring in @var{STRING}, counting from one.  If
4966 @var{SUBSTRING} is not present in @var{STRING}, zero is returned.  If 
4967 the @var{BACK} argument is present and true, the return value is the
4968 start of the last occurrence rather than the first.
4970 @item @emph{Standard}:
4971 F77 and later
4973 @item @emph{Class}:
4974 Elemental function
4976 @item @emph{Syntax}:
4977 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK])}
4979 @item @emph{Arguments}:
4980 @multitable @columnfractions .15 .80
4981 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
4982 @code{INTENT(IN)}
4983 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
4984 @code{INTENT(IN)}
4985 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL(*)}, with
4986 @code{INTENT(IN)}
4987 @end multitable
4989 @item @emph{Return value}:
4990 The return value is of type @code{INTEGER} and of the default integer
4991 kind.
4993 @item @emph{See also}:
4994 @end table
4998 @node INT
4999 @section @code{INT} --- Convert to integer type
5000 @cindex @code{INT} intrinsic
5001 @cindex @code{IFIX} intrinsic
5002 @cindex @code{IDINT} intrinsic
5003 @cindex conversion function (integer)
5005 @table @asis
5006 @item @emph{Description}:
5007 Convert to integer type
5009 @item @emph{Standard}:
5010 F77 and later
5012 @item @emph{Class}:
5013 Elemental function
5015 @item @emph{Syntax}:
5016 @item @code{RESULT = INT(X [, KIND))}
5018 @item @emph{Arguments}:
5019 @multitable @columnfractions .15 .80
5020 @item @var{X}    @tab shall be of type @code{INTEGER(*)},
5021                       @code{REAL(*)}, or @code{COMPLEX(*)}.
5022 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5023                       expression indicating the kind parameter of
5024                       the result.
5025 @end multitable
5027 @item @emph{Return value}:
5028 These functions return a @code{INTEGER(*)} variable or array under 
5029 the following rules: 
5031 @table @asis
5032 @item (A)
5033 If @var{X} is of type @code{INTEGER(*)}, @code{INT(X) = X} 
5034 @item (B)
5035 If @var{X} is of type @code{REAL(*)} and @math{|X| < 1}, @code{INT(X)} equals @var{0}. 
5036 If @math{|X| \geq 1}, then @code{INT(X)} equals the largest integer that does not exceed 
5037 the range of @var{X} and whose sign is the same as the sign of @var{X}.
5038 @item (C)
5039 If @var{X} is of type @code{COMPLEX(*)}, rule B is applied to the real part of X.
5040 @end table
5042 @item @emph{Example}:
5043 @smallexample
5044 program test_int
5045   integer :: i = 42
5046   complex :: z = (-3.7, 1.0)
5047   print *, int(i)
5048   print *, int(z), int(z,8)
5049 end program
5050 @end smallexample
5052 @item @emph{Specific names}:
5053 @multitable @columnfractions .20 .20 .20 .40
5054 @item Name             @tab Argument            @tab Return type       @tab Standard
5055 @item @code{IFIX(X)}   @tab @code{REAL(4) X}    @tab @code{INTEGER}    @tab F77 and later
5056 @item @code{IDINT(X)}  @tab @code{REAL(8) X}    @tab @code{INTEGER}    @tab F77 and later
5057 @end multitable
5059 @comment @item @emph{See also}:
5060 @end table
5064 @node IOR
5065 @section @code{IOR} --- Bitwise logical or
5066 @cindex @code{IOR} intrinsic
5067 @cindex bit operations
5069 @table @asis
5070 @item @emph{Description}:
5071 @code{IEOR} returns the bitwise boolean OR of @var{I} and
5072 @var{J}.
5074 @item @emph{Standard}:
5075 F95 and later
5077 @item @emph{Class}:
5078 Elemental function
5080 @item @emph{Syntax}:
5081 @code{RESULT = IEOR(I, J)}
5083 @item @emph{Arguments}:
5084 @multitable @columnfractions .15 .80
5085 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5086 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5087 kind as @var{I}.  (As a GNU extension, different kinds are also 
5088 permitted.)
5089 @end multitable
5091 @item @emph{Return value}:
5092 The return type is @code{INTEGER(*)}, of the same kind as the
5093 arguments.  (If the argument kinds differ, it is of the same kind as
5094 the larger argument.)
5096 @item @emph{See also}:
5097 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5098 @end table
5103 @node IRAND
5104 @section @code{IRAND} --- Integer pseudo-random number
5105 @cindex @code{IRAND} intrinsic
5106 @cindex random numbers
5108 @table @asis
5109 @item @emph{Description}:
5110 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
5111 distribution between 0 and a system-dependent limit (which is in most
5112 cases 2147483647). If @var{FLAG} is 0, the next number
5113 in the current sequence is returned; if @var{FLAG} is 1, the generator
5114 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
5115 it is used as a new seed with @code{SRAND}.
5117 @item @emph{Standard}:
5118 GNU extension
5120 @item @emph{Class}:
5121 non-elemental function
5123 @item @emph{Syntax}:
5124 @code{RESULT = IRAND(FLAG)}
5126 @item @emph{Arguments}:
5127 @multitable @columnfractions .15 .80
5128 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
5129 @end multitable
5131 @item @emph{Return value}:
5132 The return value is of @code{INTEGER(kind=4)} type.
5134 @item @emph{Example}:
5135 @smallexample
5136 program test_irand
5137   integer,parameter :: seed = 86456
5138   
5139   call srand(seed)
5140   print *, irand(), irand(), irand(), irand()
5141   print *, irand(seed), irand(), irand(), irand()
5142 end program test_irand
5143 @end smallexample
5145 @end table
5149 @node ISHFT
5150 @section @code{ISHFT} --- Shift bits
5151 @cindex @code{ISHFT} intrinsic
5152 @cindex bit operations
5154 @table @asis
5155 @item @emph{Description}:
5156 @code{ISHFT} returns a value corresponding to @var{I} with all of the
5157 bits shifted @var{SHIFT} places.  A value of @var{SHIFT} greater than
5158 zero corresponds to a left shift, a value of zero corresponds to no
5159 shift, and a value less than zero corresponds to a right shift.  If the
5160 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
5161 value is undefined.  Bits shifted out from the left end or right end are
5162 lost; zeros are shifted in from the opposite end.
5164 @item @emph{Standard}:
5165 F95 and later
5167 @item @emph{Class}:
5168 Elemental function
5170 @item @emph{Syntax}:
5171 @code{RESULT = ISHFT(I, SHIFT)}
5173 @item @emph{Arguments}:
5174 @multitable @columnfractions .15 .80
5175 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5176 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5177 @end multitable
5179 @item @emph{Return value}:
5180 The return value is of type @code{INTEGER(*)} and of the same kind as
5181 @var{I}.
5183 @item @emph{See also}:
5184 @ref{ISHFTC}
5185 @end table
5190 @node ISHFTC
5191 @section @code{ISHFTC} --- Shift bits circularly
5192 @cindex @code{ISHFTC} intrinsic
5193 @cindex bit operations
5195 @table @asis
5196 @item @emph{Description}:
5197 @code{ISHFTC} returns a value corresponding to @var{I} with the
5198 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
5199 is, bits shifted out one end are shifted into the opposite end.  A value
5200 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
5201 zero corresponds to no shift, and a value less than zero corresponds to
5202 a right shift.  The absolute value of @var{SHIFT} must be less than
5203 @var{SIZE}.  If the @var{SIZE} argument is omitted, it is taken to be
5204 equivalent to @code{BIT_SIZE(I)}.
5206 @item @emph{Standard}:
5207 F95 and later
5209 @item @emph{Class}:
5210 Elemental function
5212 @item @emph{Syntax}:
5213 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
5215 @item @emph{Arguments}:
5216 @multitable @columnfractions .15 .80
5217 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5218 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5219 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER(*)};
5220 the value must be greater than zero and less than or equal to
5221 @code{BIT_SIZE(I)}.
5222 @end multitable
5224 @item @emph{Return value}:
5225 The return value is of type @code{INTEGER(*)} and of the same kind as
5226 @var{I}.
5228 @item @emph{See also}:
5229 @ref{ISHFT}
5230 @end table
5234 @node ITIME
5235 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds) 
5236 @cindex @code{ITIME} intrinsic
5238 @table @asis
5239 @item @emph{Description}:
5240 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the  
5241 current local time. The hour (in the range 1-24), minute (in the range 1-60), 
5242 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{TARRAY}, 
5243 respectively.
5245 @item @emph{Standard}:
5246 GNU extension
5248 @item @emph{Class}:
5249 Subroutine
5251 @item @emph{Syntax}:
5252 @code{CALL ITIME(TARRAY)}
5254 @item @emph{Arguments}:
5255 @multitable @columnfractions .15 .80
5256 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)}
5257 and the kind shall be the default integer kind.
5258 @end multitable
5260 @item @emph{Return value}:
5261 Does not return.
5264 @item @emph{Example}:
5265 @smallexample
5266 program test_itime
5267   integer, dimension(3) :: tarray
5268   call itime(tarray)
5269   print *, tarray(1)
5270   print *, tarray(2)
5271   print *, tarray(3)
5272 end program test_itime
5273 @end smallexample
5274 @end table
5278 @node KILL
5279 @section @code{KILL} --- Send a signal to a process
5280 @cindex @code{KILL} intrinsic
5282 @table @asis
5283 @item @emph{Description}:
5284 @item @emph{Standard}:
5285 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
5286 See @code{kill(2)}.
5288 @item @emph{Class}:
5289 Subroutine
5291 @item @emph{Syntax}:
5292 @code{CALL KILL(PID, SIGNAL [, STATUS])}
5294 @item @emph{Arguments}:
5295 @multitable @columnfractions .15 .80
5296 @item @var{PID} @tab Shall be a scalar @code{INTEGER}, with
5297 @code{INTENT(IN)}
5298 @item @var{SIGNAL} @tab Shall be a scalar @code{INTEGER}, with
5299 @code{INTENT(IN)}
5300 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
5301                         @code{INTEGER(8)}. Returns 0 on success, or a
5302                         system-specific error code otherwise.
5303 @end multitable
5305 @item @emph{See also}:
5306 @ref{ABORT}, @ref{EXIT}
5307 @end table
5311 @node KIND
5312 @section @code{KIND} --- Kind of an entity
5313 @cindex @code{KIND} intrinsic
5315 @table @asis
5316 @item @emph{Description}:
5317 @code{KIND(X)} returns the kind value of the entity @var{X}.
5319 @item @emph{Standard}:
5320 F95 and later
5322 @item @emph{Class}:
5323 Inquiry function
5325 @item @emph{Syntax}:
5326 @code{K = KIND(X)}
5328 @item @emph{Arguments}:
5329 @multitable @columnfractions .15 .80
5330 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
5331 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
5332 @end multitable
5334 @item @emph{Return value}:
5335 The return value is a scalar of type @code{INTEGER} and of the default
5336 integer kind.
5338 @item @emph{Example}:
5339 @smallexample
5340 program test_kind
5341   integer,parameter :: kc = kind(' ')
5342   integer,parameter :: kl = kind(.true.)
5344   print *, "The default character kind is ", kc
5345   print *, "The default logical kind is ", kl
5346 end program test_kind
5347 @end smallexample
5349 @end table
5353 @node LBOUND
5354 @section @code{LBOUND} --- Lower dimension bounds of an array
5355 @cindex @code{LBOUND} intrinsic
5357 @table @asis
5358 @item @emph{Description}:
5359 Returns the lower bounds of an array, or a single lower bound
5360 along the @var{DIM} dimension.
5361 @item @emph{Standard}:
5362 F95 and later
5364 @item @emph{Class}:
5365 Inquiry function
5367 @item @emph{Syntax}:
5368 @code{RESULT = LBOUND(ARRAY [, DIM])}
5370 @item @emph{Arguments}:
5371 @multitable @columnfractions .15 .80
5372 @item @var{ARRAY} @tab Shall be an array, of any type.
5373 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
5374 @end multitable
5376 @item @emph{Return value}:
5377 If @var{DIM} is absent, the result is an array of the lower bounds of
5378 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
5379 corresponding to the lower bound of the array along that dimension.  If
5380 @var{ARRAY} is an expression rather than a whole array or array
5381 structure component, or if it has a zero extent along the relevant
5382 dimension, the lower bound is taken to be 1.
5384 @item @emph{See also}:
5385 @ref{UBOUND}
5386 @end table
5390 @node LEN
5391 @section @code{LEN} --- Length of a character entity
5392 @cindex @code{LEN} intrinsic
5394 @table @asis
5395 @item @emph{Description}:
5396 Returns the length of a character string.  If @var{STRING} is an array,
5397 the length of an element of @var{STRING} is returned.  Note that
5398 @var{STRING} need not be defined when this intrinsic is invoked, since
5399 only the length, not the content, of @var{STRING} is needed.
5401 @item @emph{Standard}:
5402 F77 and later
5404 @item @emph{Class}:
5405 Inquiry function
5407 @item @emph{Syntax}:
5408 @code{L = LEN(STRING)}
5410 @item @emph{Arguments}:
5411 @multitable @columnfractions .15 .80
5412 @item @var{STRING} @tab Shall be a scalar or array of type
5413 @code{CHARACTER(*)}, with @code{INTENT(IN)}
5414 @end multitable
5416 @item @emph{Return value}:
5417 The return value is an @code{INTEGER} of the default kind.
5419 @item @emph{See also}:
5420 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
5421 @end table
5425 @node LEN_TRIM
5426 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
5427 @cindex @code{LEN_TRIM} intrinsic
5429 @table @asis
5430 @item @emph{Description}:
5431 Returns the length of a character string, ignoring any trailing blanks.
5433 @item @emph{Standard}:
5434 F95 and later
5436 @item @emph{Class}:
5437 Elemental function
5439 @item @emph{Syntax}:
5440 @code{RESULT = LEN_TRIM(STRING)}
5442 @item @emph{Arguments}:
5443 @multitable @columnfractions .15 .80
5444 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5445 with @code{INTENT(IN)}
5446 @end multitable
5448 @item @emph{Return value}:
5449 The return value is an @code{INTEGER} of the default kind.
5451 @item @emph{See also}:
5452 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
5453 @end table
5457 @node LGE
5458 @section @code{LGE} --- Lexical greater than or equal
5459 @cindex @code{LGE} intrinsic
5460 @cindex comparison (lexical)
5461 @cindex lexical comparison
5463 @table @asis
5464 @item @emph{Description}:
5465 Determines whether one string is lexically greater than or equal to
5466 another string, where the two strings are interpreted as containing
5467 ASCII character codes.  If the String A and String B are not the same
5468 length, the shorter is compared as if spaces were appended to it to form
5469 a value that has the same length as the longer.
5471 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5472 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5473 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5474 that the latter use the processor's character ordering (which is not
5475 ASCII on some targets), whereas the former always use the ASCII
5476 ordering.
5478 @item @emph{Standard}:
5479 F77 and later
5481 @item @emph{Class}:
5482 Elemental function
5484 @item @emph{Syntax}:
5485 @code{RESULT = LGE(STRING_A, STRING_B)}
5487 @item @emph{Arguments}:
5488 @multitable @columnfractions .15 .80
5489 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5490 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5491 @end multitable
5493 @item @emph{Return value}:
5494 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
5495 otherwise, based on the ASCII ordering.
5497 @item @emph{See also}:
5498 @ref{LGT}, @ref{LLE}, @ref{LLT}
5499 @end table
5503 @node LGT
5504 @section @code{LGT} --- Lexical greater than
5505 @cindex @code{LGT} intrinsic
5506 @cindex comparison (lexical)
5507 @cindex lexical comparison
5509 @table @asis
5510 @item @emph{Description}:
5511 Determines whether one string is lexically greater than another string,
5512 where the two strings are interpreted as containing ASCII character
5513 codes.  If the String A and String B are not the same length, the
5514 shorter is compared as if spaces were appended to it to form a value
5515 that has the same length as the longer.
5517 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5518 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5519 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5520 that the latter use the processor's character ordering (which is not
5521 ASCII on some targets), whereas the former always use the ASCII
5522 ordering.
5524 @item @emph{Standard}:
5525 F77 and later
5527 @item @emph{Class}:
5528 Elemental function
5530 @item @emph{Syntax}:
5531 @code{RESULT = LGT(STRING_A, STRING_B)}
5533 @item @emph{Arguments}:
5534 @multitable @columnfractions .15 .80
5535 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5536 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5537 @end multitable
5539 @item @emph{Return value}:
5540 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
5541 otherwise, based on the ASCII ordering.
5543 @item @emph{See also}:
5544 @ref{LGE}, @ref{LLE}, @ref{LLT}
5545 @end table
5549 @node LINK
5550 @section @code{LINK} --- Create a hard link
5551 @cindex @code{LINK} intrinsic
5552 @cindex file system operations
5554 @table @asis
5555 @item @emph{Description}:
5556 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
5557 character (@code{CHAR(0)}) can be used to mark the end of the names in
5558 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
5559 names are ignored.  If the @var{STATUS} argument is supplied, it
5560 contains 0 on success or a nonzero error code upon return; see
5561 @code{link(2)}.
5563 @item @emph{Standard}:
5564 GNU extension
5566 @item @emph{Class}:
5567 Subroutine
5569 @item @emph{Syntax}:
5570 @code{CALL LINK(PATH1, PATH2 [, STATUS])}
5572 @item @emph{Arguments}:
5573 @multitable @columnfractions .15 .80
5574 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
5575 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
5576 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
5577 @end multitable
5579 @item @emph{See also}:
5580 @ref{SYMLNK}, @ref{UNLINK}
5581 @end table
5585 @node LLE
5586 @section @code{LLE} --- Lexical less than or equal
5587 @cindex @code{LLE} intrinsic
5588 @cindex comparison (lexical)
5589 @cindex lexical comparison
5591 @table @asis
5592 @item @emph{Description}:
5593 Determines whether one string is lexically less than or equal to another
5594 string, where the two strings are interpreted as containing ASCII
5595 character codes.  If the String A and String B are not the same length,
5596 the shorter is compared as if spaces were appended to it to form a value
5597 that has the same length as the longer.
5599 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5600 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5601 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5602 that the latter use the processor's character ordering (which is not
5603 ASCII on some targets), whereas the former always use the ASCII
5604 ordering.
5606 @item @emph{Standard}:
5607 F77 and later
5609 @item @emph{Class}:
5610 Elemental function
5612 @item @emph{Syntax}:
5613 @code{RESULT = LLE(STRING_A, STRING_B)}
5615 @item @emph{Arguments}:
5616 @multitable @columnfractions .15 .80
5617 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5618 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5619 @end multitable
5621 @item @emph{Return value}:
5622 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
5623 otherwise, based on the ASCII ordering.
5625 @item @emph{See also}:
5626 @ref{LGE}, @ref{LGT}, @ref{LLT}
5627 @end table
5631 @node LLT
5632 @section @code{LLT} --- Lexical less than
5633 @cindex @code{LLT} intrinsic
5634 @cindex comparison (lexical)
5635 @cindex lexical comparison
5637 @table @asis
5638 @item @emph{Description}:
5639 Determines whether one string is lexically less than another string,
5640 where the two strings are interpreted as containing ASCII character
5641 codes.  If the String A and String B are not the same length, the
5642 shorter is compared as if spaces were appended to it to form a value
5643 that has the same length as the longer.
5645 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5646 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5647 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5648 that the latter use the processor's character ordering (which is not
5649 ASCII on some targets), whereas the former always use the ASCII
5650 ordering.
5652 @item @emph{Standard}:
5653 F77 and later
5655 @item @emph{Class}:
5656 Elemental function
5658 @item @emph{Syntax}:
5659 @code{RESULT = LLT(STRING_A, STRING_B)}
5661 @item @emph{Arguments}:
5662 @multitable @columnfractions .15 .80
5663 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5664 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5665 @end multitable
5667 @item @emph{Return value}:
5668 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
5669 otherwise, based on the ASCII ordering.
5671 @item @emph{See also}:
5672 @ref{LGE}, @ref{LGT}, @ref{LLE}
5673 @end table
5677 @node LNBLNK
5678 @section @code{LNBLNK} --- Index of the last non-blank character in a string
5679 @cindex @code{LNBLNK} intrinsic
5681 @table @asis
5682 @item @emph{Description}:
5683 Returns the length of a character string, ignoring any trailing blanks.
5684 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
5685 included for backwards compatibility.
5687 @item @emph{Standard}:
5688 GNU extension
5690 @item @emph{Class}:
5691 Elemental function
5693 @item @emph{Syntax}:
5694 @code{RESULT = LNBLNK(STRING)}
5696 @item @emph{Arguments}:
5697 @multitable @columnfractions .15 .80
5698 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5699 with @code{INTENT(IN)}
5700 @end multitable
5702 @item @emph{Return value}:
5703 The return value is of @code{INTEGER(kind=4)} type.
5705 @item @emph{See also}:
5706 @ref{INDEX}, @ref{LEN_TRIM}
5707 @end table
5711 @node LOC
5712 @section @code{LOC} --- Returns the address of a variable
5713 @cindex @code{LOC} intrinsic
5714 @cindex location of a variable in memory
5716 @table @asis
5717 @item @emph{Description}:
5718 @code{LOC(X)} returns the address of @var{X} as an integer.
5720 @item @emph{Standard}:
5721 GNU extension
5723 @item @emph{Class}:
5724 Inquiry function
5726 @item @emph{Syntax}:
5727 @code{RESULT = LOC(X)}
5729 @item @emph{Arguments}:
5730 @multitable @columnfractions .15 .80
5731 @item @var{X} @tab Variable of any type.
5732 @end multitable
5734 @item @emph{Return value}:
5735 The return value is of type @code{INTEGER}, with a @code{KIND}
5736 corresponding to the size (in bytes) of a memory address on the target
5737 machine.
5739 @item @emph{Example}:
5740 @smallexample
5741 program test_loc
5742   integer :: i
5743   real :: r
5744   i = loc(r)
5745   print *, i
5746 end program test_loc
5747 @end smallexample
5748 @end table
5752 @node LOG
5753 @section @code{LOG} --- Logarithm function
5754 @cindex @code{LOG} intrinsic
5755 @cindex @code{ALOG} intrinsic
5756 @cindex @code{DLOG} intrinsic
5757 @cindex @code{CLOG} intrinsic
5758 @cindex @code{ZLOG} intrinsic
5759 @cindex @code{CDLOG} intrinsic
5760 @cindex logarithm
5762 @table @asis
5763 @item @emph{Description}:
5764 @code{LOG(X)} computes the logarithm of @var{X}.
5766 @item @emph{Standard}:
5767 F77 and later
5769 @item @emph{Class}:
5770 Elemental function
5772 @item @emph{Syntax}:
5773 @code{RESULT = LOG(X)}
5775 @item @emph{Arguments}:
5776 @multitable @columnfractions .15 .80
5777 @item @var{X} @tab The type shall be @code{REAL(*)} or
5778 @code{COMPLEX(*)}.
5779 @end multitable
5781 @item @emph{Return value}:
5782 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5783 The kind type parameter is the same as @var{X}.
5785 @item @emph{Example}:
5786 @smallexample
5787 program test_log
5788   real(8) :: x = 1.0_8
5789   complex :: z = (1.0, 2.0)
5790   x = log(x)
5791   z = log(z)
5792 end program test_log
5793 @end smallexample
5795 @item @emph{Specific names}:
5796 @multitable @columnfractions .20 .20 .20 .40
5797 @item Name            @tab Argument          @tab Return type       @tab Standard
5798 @item @code{ALOG(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab f95, gnu
5799 @item @code{DLOG(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
5800 @item @code{CLOG(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
5801 @item @code{ZLOG(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
5802 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
5803 @end multitable
5804 @end table
5808 @node LOG10
5809 @section @code{LOG10} --- Base 10 logarithm function
5810 @cindex @code{LOG10} intrinsic
5811 @cindex @code{ALOG10} intrinsic
5812 @cindex @code{DLOG10} intrinsic
5813 @cindex logarithm
5815 @table @asis
5816 @item @emph{Description}:
5817 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
5819 @item @emph{Standard}:
5820 F77 and later
5822 @item @emph{Class}:
5823 Elemental function
5825 @item @emph{Syntax}:
5826 @code{RESULT = LOG10(X)}
5828 @item @emph{Arguments}:
5829 @multitable @columnfractions .15 .80
5830 @item @var{X} @tab The type shall be @code{REAL(*)} or
5831 @code{COMPLEX(*)}.
5832 @end multitable
5834 @item @emph{Return value}:
5835 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5836 The kind type parameter is the same as @var{X}.
5838 @item @emph{Example}:
5839 @smallexample
5840 program test_log10
5841   real(8) :: x = 10.0_8
5842   x = log10(x)
5843 end program test_log10
5844 @end smallexample
5846 @item @emph{Specific names}:
5847 @multitable @columnfractions .20 .20 .20 .40
5848 @item Name            @tab Argument          @tab Return type       @tab Standard
5849 @item @code{ALOG10(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab F95 and later
5850 @item @code{DLOG10(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab F95 and later
5851 @end multitable
5852 @end table
5856 @node LOGICAL
5857 @section @code{LOGICAL} --- Convert to logical type
5858 @cindex @code{LOGICAL} intrinsic
5859 @cindex conversion function (logical)
5861 @table @asis
5862 @item @emph{Description}:
5863 Converts one kind of @code{LOGICAL} variable to another.
5865 @item @emph{Standard}:
5866 F95 and later
5868 @item @emph{Class}:
5869 Elemental function
5871 @item @emph{Syntax}:
5872 @code{RESULT = LOGICAL(L [, KIND])}
5874 @item @emph{Arguments}:
5875 @multitable @columnfractions .15 .80
5876 @item @var{L}    @tab The type shall be @code{LOGICAL(*)}.
5877 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5878                       expression indicating the kind parameter of
5879                       the result.
5880 @end multitable
5882 @item @emph{Return value}:
5883 The return value is a @code{LOGICAL} value equal to @var{L}, with a
5884 kind corresponding to @var{KIND}, or of the default logical kind if
5885 @var{KIND} is not given.
5887 @item @emph{See also}:
5888 @ref{INT}, @ref{REAL}, @ref{CMPLX}
5889 @end table
5894 @node LSHIFT
5895 @section @code{LSHIFT} --- Left shift bits
5896 @cindex @code{LSHIFT} intrinsic
5897 @cindex bit operations
5899 @table @asis
5900 @item @emph{Description}:
5901 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
5902 bits shifted left by @var{SHIFT} places.  If the absolute value of
5903 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined. 
5904 Bits shifted out from the left end are lost; zeros are shifted in from
5905 the opposite end.
5907 This function has been superseded by the @code{ISHFT} intrinsic, which
5908 is standard in Fortran 95 and later.
5910 @item @emph{Standard}:
5911 GNU extension
5913 @item @emph{Class}:
5914 Elemental function
5916 @item @emph{Syntax}:
5917 @code{RESULT = LSHIFT(I, SHIFT)}
5919 @item @emph{Arguments}:
5920 @multitable @columnfractions .15 .80
5921 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5922 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5923 @end multitable
5925 @item @emph{Return value}:
5926 The return value is of type @code{INTEGER(*)} and of the same kind as
5927 @var{I}.
5929 @item @emph{See also}:
5930 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
5932 @end table
5935 @node LSTAT
5936 @section @code{LSTAT} --- Get file status
5937 @cindex @code{LSTAT} intrinsic
5938 @cindex file system operations 
5940 @table @asis
5941 @item @emph{Description}:
5942 @code{LSTAT} is identical to @ref{STAT}, except that if path is a symbolic link, 
5943 then the link itself is statted, not the file that it refers to.
5945 The elements in @code{BUFF} are the same as described by @ref{STAT}.
5947 @item @emph{Standard}:
5948 GNU extension
5950 @item @emph{Class}:
5951 Non-elemental subroutine
5953 @item @emph{Syntax}:
5954 @code{CALL LSTAT(FILE, BUFF [, STATUS])}
5956 @item @emph{Arguments}:
5957 @multitable @columnfractions .15 .80
5958 @item @var{FILE}   @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
5959 @item @var{BUFF}   @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
5960 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
5961                         on success and a system specific error code otherwise.
5962 @end multitable
5964 @item @emph{Example}:
5965 See @ref{STAT} for an example.
5967 @item @emph{See also}:
5968 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
5969 @end table
5973 @node LTIME
5974 @section @code{LTIME} --- Convert time to local time info
5975 @cindex @code{LTIME} intrinsic
5976 @cindex time, conversion function
5978 @table @asis
5979 @item @emph{Description}:
5980 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
5981 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
5982 to the local time zone using @code{localtime(3)}.
5984 @item @emph{Standard}:
5985 GNU extension
5987 @item @emph{Class}:
5988 Subroutine
5990 @item @emph{Syntax}:
5991 @code{CALL LTIME(STIME, TARRAY)}
5993 @item @emph{Arguments}:
5994 @multitable @columnfractions .15 .80
5995 @item @var{STIME}  @tab An @code{INTEGER(*)} scalar expression
5996                         corresponding to a system time, with 
5997                         @code{INTENT(IN)}.
5998 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
5999                         with @code{INTENT(OUT)}.
6000 @end multitable
6002 @item @emph{Return value}:
6003 The elements of @var{TARRAY} are assigned as follows:
6004 @enumerate
6005 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
6006       seconds
6007 @item Minutes after the hour, range 0--59
6008 @item Hours past midnight, range 0--23
6009 @item Day of month, range 0--31
6010 @item Number of months since January, range 0--12
6011 @item Years since 1900
6012 @item Number of days since Sunday, range 0--6
6013 @item Days since January 1
6014 @item Daylight savings indicator: positive if daylight savings is in
6015       effect, zero if not, and negative if the information is not
6016       available.
6017 @end enumerate
6019 @item @emph{See also}:
6020 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
6022 @end table
6026 @node MALLOC
6027 @section @code{MALLOC} --- Allocate dynamic memory
6028 @cindex @code{MALLOC} intrinsic
6029 @cindex Cray pointers
6031 @table @asis
6032 @item @emph{Description}:
6033 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
6034 returns the address of the allocated memory. The @code{MALLOC} intrinsic
6035 is an extension intended to be used with Cray pointers, and is provided
6036 in GNU Fortran to allow the user to compile legacy code. For new code
6037 using Fortran 95 pointers, the memory allocation intrinsic is
6038 @code{ALLOCATE}.
6040 @item @emph{Standard}:
6041 GNU extension
6043 @item @emph{Class}:
6044 non-elemental function
6046 @item @emph{Syntax}:
6047 @code{PTR = MALLOC(SIZE)}
6049 @item @emph{Arguments}:
6050 @multitable @columnfractions .15 .80
6051 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
6052 @end multitable
6054 @item @emph{Return value}:
6055 The return value is of type @code{INTEGER(K)}, with @var{K} such that
6056 variables of type @code{INTEGER(K)} have the same size as
6057 C pointers (@code{sizeof(void *)}).
6059 @item @emph{Example}:
6060 The following example demonstrates the use of @code{MALLOC} and
6061 @code{FREE} with Cray pointers. This example is intended to run on
6062 32-bit systems, where the default integer kind is suitable to store
6063 pointers; on 64-bit systems, ptr_x would need to be declared as
6064 @code{integer(kind=8)}.
6066 @smallexample
6067 program test_malloc
6068   integer i
6069   integer ptr_x
6070   real*8 x(*), z
6071   pointer(ptr_x,x)
6073   ptr_x = malloc(20*8)
6074   do i = 1, 20
6075     x(i) = sqrt(1.0d0 / i)
6076   end do
6077   z = 0
6078   do i = 1, 20
6079     z = z + x(i)
6080     print *, z
6081   end do
6082   call free(ptr_x)
6083 end program test_malloc
6084 @end smallexample
6086 @item @emph{See also}:
6087 @ref{FREE}
6088 @end table
6092 @node MATMUL
6093 @section @code{MATMUL} --- matrix multiplication
6094 @cindex @code{MATMUL} intrinsic
6095 @cindex matrix operations
6097 @table @asis
6098 @item @emph{Description}:
6099 Performs a matrix multiplication on numeric or logical arguments.
6101 @item @emph{Standard}:
6102 F95 and later
6104 @item @emph{Class}:
6105 Transformational function
6107 @item @emph{Syntax}:
6108 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
6110 @item @emph{Arguments}:
6111 @multitable @columnfractions .15 .80
6112 @item @var{MATRIX_A} @tab An array of @code{INTEGER(*)},
6113                           @code{REAL(*)}, @code{COMPLEX(*)}, or
6114                           @code{LOGICAL(*)} type, with a rank of
6115                           one or two.
6116 @item @var{MATRIX_B} @tab An array of @code{INTEGER(*)},
6117                           @code{REAL(*)}, or @code{COMPLEX(*)} type if
6118                           @var{MATRIX_A} is of a numeric type;
6119                           otherwise, an array of @code{LOGICAL(*)}
6120                           type. The rank shall be one or two, and the
6121                           first (or only) dimension of @var{MATRIX_B}
6122                           shall be equal to the last (or only)
6123                           dimension of @var{MATRIX_A}.
6124 @end multitable
6126 @item @emph{Return value}:
6127 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}.  The type and
6128 kind of the result follow the usual type and kind promotion rules, as
6129 for the @code{*} or @code{.AND.} operators.
6131 @item @emph{See also}:
6132 @end table
6136 @node MAX
6137 @section @code{MAX} --- Maximum value of an argument list
6138 @cindex @code{MAX} intrinsic
6140 @table @asis
6141 @item @emph{Description}:
6142 Returns the argument with the largest (most positive) value.
6144 @item @emph{Standard}:
6145 F77 and later
6147 @item @emph{Class}:
6148 Elemental function
6150 @item @emph{Syntax}:
6151 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
6153 @item @emph{Arguments}:
6154 @multitable @columnfractions .15 .80
6155 @item @var{A1}          @tab The type shall be @code{INTEGER(*)} or
6156                              @code{REAL(*)}.
6157 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6158                              as @var{A1}.  (As a GNU extension, 
6159                              arguments of different kinds are
6160                              permitted.)
6161 @end multitable
6163 @item @emph{Return value}:
6164 The return value corresponds to the maximum value among the arguments,
6165 and has the same type and kind as the first argument.
6167 @item @emph{Specific names}:
6168 @multitable @columnfractions .20 .20 .20 .40
6169 @item Name             @tab Argument            @tab Return type         @tab Standard
6170 @item @code{MAX0(I)}   @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)}   @tab F77 and later
6171 @item @code{AMAX0(I)}  @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab F77 and later
6172 @item @code{MAX1(X)}   @tab @code{REAL(*) X}    @tab @code{INT(MAX(X))}  @tab F77 and later
6173 @item @code{AMAX1(X)}  @tab @code{REAL(4)    X} @tab @code{REAL(4)}      @tab F77 and later
6174 @item @code{DMAX1(X)}  @tab @code{REAL(8)    X} @tab @code{REAL(8)}      @tab F77 and later
6175 @end multitable
6177 @item @emph{See also}:
6178 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
6180 @end table
6184 @node MAXEXPONENT
6185 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
6186 @cindex @code{MAXEXPONENT} intrinsic
6187 @cindex maximum exponent
6188 @cindex exponent, maximum
6190 @table @asis
6191 @item @emph{Description}:
6192 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
6193 type of @code{X}.
6195 @item @emph{Standard}:
6196 F95 and later
6198 @item @emph{Class}:
6199 Inquiry function
6201 @item @emph{Syntax}:
6202 @code{RESULT = MAXEXPONENT(X)}
6204 @item @emph{Arguments}:
6205 @multitable @columnfractions .15 .80
6206 @item @var{X} @tab shall be of type @code{REAL}.
6207 @end multitable
6209 @item @emph{Return value}:
6210 The return value is of type @code{INTEGER} and of the default integer
6211 kind.
6213 @item @emph{Example}:
6214 @smallexample
6215 program exponents
6216   real(kind=4) :: x
6217   real(kind=8) :: y
6219   print *, minexponent(x), maxexponent(x)
6220   print *, minexponent(y), maxexponent(y)
6221 end program exponents
6222 @end smallexample
6223 @end table
6227 @node MAXLOC
6228 @section @code{MAXLOC} --- Location of the maximum value within an array
6229 @cindex @code{MAXLOC} intrinsic
6231 @table @asis
6232 @item @emph{Description}:
6233 Determines the location of the element in the array with the maximum
6234 value, or, if the @var{DIM} argument is supplied, determines the
6235 locations of the maximum element along each row of the array in the
6236 @var{DIM} direction.  If @var{MASK} is present, only the elements for
6237 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
6238 element in the array has the maximum value, the location returned is
6239 that of the first such element in array element order.  If the array has
6240 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6241 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
6242 and all of the elements of @var{MASK} along a given row are zero, the
6243 result value for that row is zero.
6245 @item @emph{Standard}:
6246 F95 and later
6248 @item @emph{Class}:
6249 Transformational function
6251 @item @emph{Syntax}:
6252 @multitable @columnfractions .80
6253 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
6254 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
6255 @end multitable
6257 @item @emph{Arguments}:
6258 @multitable @columnfractions .15 .80
6259 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6260                        @code{REAL(*)}, or @code{CHARACTER(*)}.
6261 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
6262                        @code{INTEGER(*)}, with a value between one
6263                        and the rank of @var{ARRAY}, inclusive.  It
6264                        may not be an optional dummy argument.
6265 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL(*)},
6266                        and conformable with @var{ARRAY}.
6267 @end multitable
6269 @item @emph{Return value}:
6270 If @var{DIM} is absent, the result is a rank-one array with a length
6271 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
6272 is an array with a rank one less than the rank of @var{ARRAY}, and a
6273 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6274 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
6275 of one, the result is a scalar.  In all cases, the result is of default
6276 @code{INTEGER} type.
6278 @item @emph{See also}:
6279 @ref{MAX}, @ref{MAXVAL}
6281 @end table
6285 @node MAXVAL
6286 @section @code{MAXVAL} --- Maximum value of an array
6287 @cindex @code{MAXVAL} intrinsic
6289 @table @asis
6290 @item @emph{Description}:
6291 Determines the maximum value of the elements in an array value, or, if
6292 the @var{DIM} argument is supplied, determines the maximum value along
6293 each row of the array in the @var{DIM} direction.  If @var{MASK} is
6294 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6295 considered.  If the array has zero size, or all of the elements of
6296 @var{MASK} are @code{.FALSE.}, then the result is the most negative
6297 number of the type and kind of @var{ARRAY} if @var{ARRAY} is numeric, or
6298 a string of nulls if @var{ARRAY} is of character type.
6300 @item @emph{Standard}:
6301 F95 and later
6303 @item @emph{Class}:
6304 Transformational function
6306 @item @emph{Syntax}:
6307 @multitable @columnfractions .80
6308 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
6309 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
6310 @end multitable
6312 @item @emph{Arguments}:
6313 @multitable @columnfractions .15 .80
6314 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6315                        @code{REAL(*)}, or @code{CHARACTER(*)}.
6316 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
6317                        @code{INTEGER(*)}, with a value between one
6318                        and the rank of @var{ARRAY}, inclusive.  It
6319                        may not be an optional dummy argument.
6320 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL(*)},
6321                        and conformable with @var{ARRAY}.
6322 @end multitable
6324 @item @emph{Return value}:
6325 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6326 is a scalar.  If @var{DIM} is present, the result is an array with a
6327 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6328 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
6329 cases, the result is of the same type and kind as @var{ARRAY}.
6331 @item @emph{See also}:
6332 @ref{MAX}, @ref{MAXLOC}
6333 @end table
6337 @node MERGE
6338 @section @code{MERGE} --- Merge variables
6339 @cindex @code{MERGE} intrinsic
6341 @table @asis
6342 @item @emph{Description}:
6343 Select values from two arrays according to a logical mask.  The result
6344 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
6345 @var{FSOURCE} if it is @code{.FALSE.}.
6347 @item @emph{Standard}:
6348 F95 and later
6350 @item @emph{Class}:
6351 Elemental function
6353 @item @emph{Syntax}:
6354 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
6356 @item @emph{Arguments}:
6357 @multitable @columnfractions .15 .80
6358 @item @var{TSOURCE} @tab May be of any type.
6359 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
6360                          as @var{TSOURCE}.
6361 @item @var{MASK}    @tab Shall be of type @code{LOGICAL(*)}.
6362 @end multitable
6364 @item @emph{Return value}:
6365 The result is of the same type and type parameters as @var{TSOURCE}.
6367 @end table
6371 @node MIN
6372 @section @code{MIN} --- Minimum value of an argument list
6373 @cindex @code{MIN} intrinsic
6375 @table @asis
6376 @item @emph{Description}:
6377 Returns the argument with the smallest (most negative) value.
6379 @item @emph{Standard}:
6380 F77 and later
6382 @item @emph{Class}:
6383 Elemental function
6385 @item @emph{Syntax}:
6386 @code{RESULT = MIN(A1, A2 [, A3, ...])}
6388 @item @emph{Arguments}:
6389 @multitable @columnfractions .15 .80
6390 @item @var{A1}          @tab The type shall be @code{INTEGER(*)} or
6391                              @code{REAL(*)}.
6392 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6393                              as @var{A1}.  (As a GNU extension, 
6394                              arguments of different kinds are
6395                              permitted.)
6396 @end multitable
6398 @item @emph{Return value}:
6399 The return value corresponds to the maximum value among the arguments,
6400 and has the same type and kind as the first argument.
6402 @item @emph{Specific names}:
6403 @multitable @columnfractions .20 .20 .20 .40
6404 @item Name             @tab Argument            @tab Return type         @tab Standard
6405 @item @code{MIN0(I)}   @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)}   @tab F77 and later
6406 @item @code{AMIN0(I)}  @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab F77 and later
6407 @item @code{MIN1(X)}   @tab @code{REAL(*) X}    @tab @code{INT(MIN(X))}  @tab F77 and later
6408 @item @code{AMIN1(X)}  @tab @code{REAL(4)    X} @tab @code{REAL(4)}      @tab F77 and later
6409 @item @code{DMIN1(X)}  @tab @code{REAL(8)    X} @tab @code{REAL(8)}      @tab F77 and later
6410 @end multitable
6412 @item @emph{See also}:
6413 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
6414 @end table
6416 @node MINEXPONENT
6417 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
6418 @cindex @code{MINEXPONENT} intrinsic
6419 @cindex minimum exponent
6420 @cindex exponent, minimum
6422 @table @asis
6423 @item @emph{Description}:
6424 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
6425 type of @code{X}.
6427 @item @emph{Standard}:
6428 F95 and later
6430 @item @emph{Class}:
6431 Inquiry function
6433 @item @emph{Syntax}:
6434 @code{RESULT = MINEXPONENT(X)}
6436 @item @emph{Arguments}:
6437 @multitable @columnfractions .15 .80
6438 @item @var{X} @tab shall be of type @code{REAL}.
6439 @end multitable
6441 @item @emph{Return value}:
6442 The return value is of type @code{INTEGER} and of the default integer
6443 kind.
6445 @item @emph{Example}:
6446 See @code{MAXEXPONENT} for an example.
6447 @end table
6451 @node MINLOC
6452 @section @code{MINLOC} --- Location of the minimum value within an array
6453 @cindex @code{MINLOC} intrinsic
6455 @table @asis
6456 @item @emph{Description}:
6457 Determines the location of the element in the array with the minimum
6458 value, or, if the @var{DIM} argument is supplied, determines the
6459 locations of the minimum element along each row of the array in the
6460 @var{DIM} direction.  If @var{MASK} is present, only the elements for
6461 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
6462 element in the array has the minimum value, the location returned is
6463 that of the first such element in array element order.  If the array has
6464 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6465 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
6466 and all of the elements of @var{MASK} along a given row are zero, the
6467 result value for that row is zero.
6469 @item @emph{Standard}:
6470 F95 and later
6472 @item @emph{Class}:
6473 Transformational function
6475 @item @emph{Syntax}:
6476 @multitable @columnfractions .80
6477 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
6478 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
6479 @end multitable
6481 @item @emph{Arguments}:
6482 @multitable @columnfractions .15 .80
6483 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6484                        @code{REAL(*)}, or @code{CHARACTER(*)}.
6485 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
6486                        @code{INTEGER(*)}, with a value between one
6487                        and the rank of @var{ARRAY}, inclusive.  It
6488                        may not be an optional dummy argument.
6489 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL(*)},
6490                        and conformable with @var{ARRAY}.
6491 @end multitable
6493 @item @emph{Return value}:
6494 If @var{DIM} is absent, the result is a rank-one array with a length
6495 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
6496 is an array with a rank one less than the rank of @var{ARRAY}, and a
6497 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6498 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
6499 of one, the result is a scalar.  In all cases, the result is of default
6500 @code{INTEGER} type.
6502 @item @emph{See also}:
6503 @ref{MIN}, @ref{MINVAL}
6505 @end table
6509 @node MINVAL
6510 @section @code{MINVAL} --- Minimum value of an array
6511 @cindex @code{MINVAL} intrinsic
6513 @table @asis
6514 @item @emph{Description}:
6515 Determines the minimum value of the elements in an array value, or, if
6516 the @var{DIM} argument is supplied, determines the minimum value along
6517 each row of the array in the @var{DIM} direction.  If @var{MASK} is
6518 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6519 considered.  If the array has zero size, or all of the elements of
6520 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
6521 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
6522 @var{ARRAY} is of character type.
6524 @item @emph{Standard}:
6525 F95 and later
6527 @item @emph{Class}:
6528 Transformational function
6530 @item @emph{Syntax}:
6531 @multitable @columnfractions .80
6532 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
6533 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
6534 @end multitable
6536 @item @emph{Arguments}:
6537 @multitable @columnfractions .15 .80
6538 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6539                        @code{REAL(*)}, or @code{CHARACTER(*)}.
6540 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
6541                        @code{INTEGER(*)}, with a value between one
6542                        and the rank of @var{ARRAY}, inclusive.  It
6543                        may not be an optional dummy argument.
6544 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL(*)},
6545                        and conformable with @var{ARRAY}.
6546 @end multitable
6548 @item @emph{Return value}:
6549 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6550 is a scalar.  If @var{DIM} is present, the result is an array with a
6551 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6552 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
6553 cases, the result is of the same type and kind as @var{ARRAY}.
6555 @item @emph{See also}:
6556 @ref{MIN}, @ref{MINLOC}
6558 @end table
6562 @node MOD
6563 @section @code{MOD} --- Remainder function
6564 @cindex @code{MOD} intrinsic
6565 @cindex @code{AMOD} intrinsic
6566 @cindex @code{DMOD} intrinsic
6567 @cindex remainder
6569 @table @asis
6570 @item @emph{Description}:
6571 @code{MOD(A,P)} computes the remainder of the division of A by P. It is
6572 calculated as @code{A - (INT(A/P) * P)}.
6574 @item @emph{Standard}:
6575 F77 and later
6577 @item @emph{Class}:
6578 Elemental function
6580 @item @emph{Syntax}:
6581 @code{RESULT = MOD(A, P)}
6583 @item @emph{Arguments}:
6584 @multitable @columnfractions .15 .80
6585 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6586 @item @var{P} @tab shall be a scalar of the same type as @var{A} and not
6587 equal to zero
6588 @end multitable
6590 @item @emph{Return value}:
6591 The kind of the return value is the result of cross-promoting
6592 the kinds of the arguments.
6594 @item @emph{Example}:
6595 @smallexample
6596 program test_mod
6597   print *, mod(17,3)
6598   print *, mod(17.5,5.5)
6599   print *, mod(17.5d0,5.5)
6600   print *, mod(17.5,5.5d0)
6602   print *, mod(-17,3)
6603   print *, mod(-17.5,5.5)
6604   print *, mod(-17.5d0,5.5)
6605   print *, mod(-17.5,5.5d0)
6607   print *, mod(17,-3)
6608   print *, mod(17.5,-5.5)
6609   print *, mod(17.5d0,-5.5)
6610   print *, mod(17.5,-5.5d0)
6611 end program test_mod
6612 @end smallexample
6614 @item @emph{Specific names}:
6615 @multitable @columnfractions .20 .20 .20 .40
6616 @item Name             @tab Arguments      @tab Return type    @tab Standard
6617 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab F95 and later
6618 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab F95 and later
6619 @end multitable
6620 @end table
6624 @node MODULO
6625 @section @code{MODULO} --- Modulo function
6626 @cindex @code{MODULO} intrinsic
6627 @cindex modulo
6629 @table @asis
6630 @item @emph{Description}:
6631 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
6633 @item @emph{Standard}:
6634 F95 and later
6636 @item @emph{Class}:
6637 Elemental function
6639 @item @emph{Syntax}:
6640 @code{RESULT = MODULO(A, P)}
6642 @item @emph{Arguments}:
6643 @multitable @columnfractions .15 .80
6644 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6645 @item @var{P} @tab shall be a scalar of the same type and kind as @var{A}
6646 @end multitable
6648 @item @emph{Return value}:
6649 The type and kind of the result are those of the arguments.
6650 @table @asis
6651 @item If @var{A} and @var{P} are of type @code{INTEGER}:
6652 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
6653 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
6654 (exclusive).
6655 @item If @var{A} and @var{P} are of type @code{REAL}:
6656 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
6657 @end table
6658 In all cases, if @var{P} is zero the result is processor-dependent.
6660 @item @emph{Example}:
6661 @smallexample
6662 program test_modulo
6663   print *, modulo(17,3)
6664   print *, modulo(17.5,5.5)
6666   print *, modulo(-17,3)
6667   print *, modulo(-17.5,5.5)
6669   print *, modulo(17,-3)
6670   print *, modulo(17.5,-5.5)
6671 end program test_mod
6672 @end smallexample
6674 @end table
6678 @node MOVE_ALLOC
6679 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
6680 @cindex @code{MOVE_ALLOC} intrinsic
6681 @cindex moving allocation
6682 @cindex allocation, moving
6684 @table @asis
6685 @item @emph{Description}:
6686 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
6687 @var{DEST}.  @var{SRC} will become deallocated in the process.
6689 @item @emph{Standard}:
6690 F2003 and later
6692 @item @emph{Class}:
6693 Subroutine
6695 @item @emph{Syntax}:
6696 @code{CALL MOVE_ALLOC(SRC, DEST)}
6698 @item @emph{Arguments}:
6699 @multitable @columnfractions .15 .80
6700 @item @var{SRC}  @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
6701                       of any type and kind.
6702 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
6703                       of the same type, kind and rank as @var{SRC}
6704 @end multitable
6706 @item @emph{Return value}:
6707 None
6709 @item @emph{Example}:
6710 @smallexample
6711 program test_move_alloc
6712     integer, allocatable :: a(:), b(:)
6714     allocate(a(3))
6715     a = [ 1, 2, 3 ]
6716     call move_alloc(a, b)
6717     print *, allocated(a), allocated(b)
6718     print *, b
6719 end program test_move_alloc
6720 @end smallexample
6721 @end table
6725 @node MVBITS
6726 @section @code{MVBITS} --- Move bits from one integer to another
6727 @cindex @code{MVBITS} intrinsic
6728 @cindex bit operations
6730 @table @asis
6731 @item @emph{Description}:
6732 Moves @var{LEN} bits from positions @var{FROMPOS} through
6733 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
6734 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
6735 affected by the movement of bits is unchanged. The values of
6736 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
6737 @code{BIT_SIZE(FROM)}.
6739 @item @emph{Standard}:
6740 F95 and later
6742 @item @emph{Class}:
6743 Elemental function
6745 @item @emph{Syntax}:
6746 @code{RESULT = MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
6748 @item @emph{Arguments}:
6749 @multitable @columnfractions .15 .80
6750 @item @var{FROM}    @tab The type shall be @code{INTEGER(*)}.
6751 @item @var{FROMPOS} @tab The type shall be @code{INTEGER(*)}.
6752 @item @var{LEN}     @tab The type shall be @code{INTEGER(*)}.
6753 @item @var{TO}      @tab The type shall be @code{INTEGER(*)}, of the
6754                          same kind as @var{FROM}.
6755 @item @var{TOPOS}   @tab The type shall be @code{INTEGER(*)}.
6756 @end multitable
6758 @item @emph{Return value}:
6759 The return value is of type @code{INTEGER(*)} and of the same kind as
6760 @var{FROM}.
6762 @item @emph{See also}:
6763 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
6765 @end table
6769 @node NEAREST
6770 @section @code{NEAREST} --- Nearest representable number
6771 @cindex @code{NEAREST} intrinsic
6772 @cindex processor-representable number
6774 @table @asis
6775 @item @emph{Description}:
6776 @code{NEAREST(X, S)} returns the processor-representable number nearest
6777 to @code{X} in the direction indicated by the sign of @code{S}.
6779 @item @emph{Standard}:
6780 F95 and later
6782 @item @emph{Class}:
6783 Elemental function
6785 @item @emph{Syntax}:
6786 @code{RESULT = NEAREST(X, S)}
6788 @item @emph{Arguments}:
6789 @multitable @columnfractions .15 .80
6790 @item @var{X} @tab shall be of type @code{REAL}.
6791 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
6792 not equal to zero.
6793 @end multitable
6795 @item @emph{Return value}:
6796 The return value is of the same type as @code{X}. If @code{S} is
6797 positive, @code{NEAREST} returns the processor-representable number
6798 greater than @code{X} and nearest to it. If @code{S} is negative,
6799 @code{NEAREST} returns the processor-representable number smaller than
6800 @code{X} and nearest to it.
6802 @item @emph{Example}:
6803 @smallexample
6804 program test_nearest
6805   real :: x, y
6806   x = nearest(42.0, 1.0)
6807   y = nearest(42.0, -1.0)
6808   write (*,"(3(G20.15))") x, y, x - y
6809 end program test_nearest
6810 @end smallexample
6811 @end table
6815 @node NEW_LINE
6816 @section @code{NEW_LINE} --- New line character
6817 @cindex @code{NEW_LINE} intrinsic
6818 @cindex @code{NEW_LINE} intrinsic
6820 @table @asis
6821 @item @emph{Description}:
6822 @code{NEW_LINE(C)} returns the new-line character.
6824 @item @emph{Standard}:
6825 F2003 and later
6827 @item @emph{Class}:
6828 Elemental function
6830 @item @emph{Syntax}:
6831 @code{RESULT = NEW_LINE(C)}
6833 @item @emph{Arguments}:
6834 @multitable @columnfractions .15 .80
6835 @item @var{C}    @tab The argument shall be a scalar or array of the
6836                       type @code{CHARACTER}.
6837 @end multitable
6839 @item @emph{Return value}:
6840 Returns a @var{CHARACTER} scalar of length one with the new-line character of
6841 the same kind as parameter @var{C}.
6843 @item @emph{Example}:
6844 @smallexample
6845 program newline
6846   implicit none
6847   write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
6848 end program newline
6849 @end smallexample
6850 @end table
6854 @node NINT
6855 @section @code{NINT} --- Nearest whole number
6856 @cindex @code{NINT} intrinsic
6857 @cindex @code{IDNINT} intrinsic
6858 @cindex whole number
6860 @table @asis
6861 @item @emph{Description}:
6862 @code{NINT(X)} rounds its argument to the nearest whole number.
6864 @item @emph{Standard}:
6865 F77 and later
6867 @item @emph{Class}:
6868 Elemental function
6870 @item @emph{Syntax}:
6871 @code{RESULT = NINT(X)}
6873 @item @emph{Arguments}:
6874 @multitable @columnfractions .15 .80
6875 @item @var{X}    @tab The type of the argument shall be @code{REAL}.
6876 @end multitable
6878 @item @emph{Return value}:
6879 Returns @var{A} with the fractional portion of its magnitude eliminated by
6880 rounding to the nearest whole number and with its sign preserved,
6881 converted to an @code{INTEGER} of the default kind.
6883 @item @emph{Example}:
6884 @smallexample
6885 program test_nint
6886   real(4) x4
6887   real(8) x8
6888   x4 = 1.234E0_4
6889   x8 = 4.321_8
6890   print *, nint(x4), idnint(x8)
6891 end program test_nint
6892 @end smallexample
6894 @item @emph{Specific names}:
6895 @multitable @columnfractions .33 .33 .33
6896 @item Name             @tab Argument         @tab Standard
6897 @item @code{IDNINT(X)} @tab @code{REAL(8)}   @tab F95 and later
6898 @end multitable
6900 @item @emph{See also}:
6901 @ref{CEILING}, @ref{FLOOR}
6903 @end table
6906 @node NOT
6907 @section @code{NOT} --- Logical negation
6908 @cindex @code{NOT} intrinsic
6909 @cindex bit operations
6911 @table @asis
6912 @item @emph{Description}:
6913 @code{NOT} returns the bitwise boolean inverse of @var{I}.
6915 @item @emph{Standard}:
6916 F95 and later
6918 @item @emph{Class}:
6919 Elemental function
6921 @item @emph{Syntax}:
6922 @code{RESULT = NOT(I)}
6924 @item @emph{Arguments}:
6925 @multitable @columnfractions .15 .80
6926 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
6927 @end multitable
6929 @item @emph{Return value}:
6930 The return type is @code{INTEGER(*)}, of the same kind as the
6931 argument.
6933 @item @emph{See also}:
6934 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
6936 @end table
6941 @node NULL
6942 @section @code{NULL} --- Function that returns an disassociated pointer
6943 @cindex @code{NULL} intrinsic
6944 @cindex undocumented intrinsic 
6946 Intrinsic implemented, documentation pending.
6948 @table @asis
6949 @item @emph{Description}:
6950 @item @emph{Standard}:
6951 F95 and later
6953 @item @emph{Class}:
6954 Transformational function
6956 @item @emph{Syntax}:
6957 @item @emph{Arguments}:
6958 @item @emph{Return value}:
6959 @item @emph{Example}:
6960 @item @emph{See also}:
6961 @ref{ASSOCIATED}
6962 @end table
6967 @node OR
6968 @section @code{OR} --- Bitwise logical OR
6969 @cindex @code{OR} intrinsic
6970 @cindex bit operations
6972 @table @asis
6973 @item @emph{Description}:
6974 Bitwise logical @code{OR}.
6976 This intrinsic routine is provided for backwards compatibility with 
6977 GNU Fortran 77.  For integer arguments, programmers should consider
6978 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
6980 @item @emph{Standard}:
6981 GNU extension
6983 @item @emph{Class}:
6984 Non-elemental function
6986 @item @emph{Syntax}:
6987 @code{RESULT = OR(X, Y)}
6989 @item @emph{Arguments}:
6990 @multitable @columnfractions .15 .80
6991 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
6992 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
6993 @end multitable
6995 @item @emph{Return value}:
6996 The return type is either @code{INTEGER(*)} or @code{LOGICAL} 
6997 after cross-promotion of the arguments.
6999 @item @emph{Example}:
7000 @smallexample
7001 PROGRAM test_or
7002   LOGICAL :: T = .TRUE., F = ..FALSE.
7003   INTEGER :: a, b
7004   DATA a / Z'F' /, b / Z'3' /
7006   WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
7007   WRITE (*,*) OR(a, b)
7008 END PROGRAM
7009 @end smallexample
7011 @item @emph{See also}:
7012 F95 elemental function: @ref{IOR}
7013 @end table
7018 @node PACK
7019 @section @code{PACK} --- Pack an array into an array of rank one
7020 @cindex @code{PACK} intrinsic
7021 @cindex undocumented intrinsic 
7023 Intrinsic implemented, documentation pending.
7025 @table @asis
7026 @item @emph{Description}:
7027 @item @emph{Standard}:
7028 F95 and later
7030 @item @emph{Class}:
7031 Transformational function
7033 @item @emph{Syntax}:
7034 @item @emph{Arguments}:
7035 @item @emph{Return value}:
7036 @item @emph{Example}:
7037 @item @emph{Specific names}:
7038 @item @emph{See also}:
7039 @ref{UNPACK}
7040 @end table
7044 @node PERROR
7045 @section @code{PERROR} --- Print system error message
7046 @cindex @code{PERROR} intrinsic
7048 @table @asis
7049 @item @emph{Description}:
7050 Prints (on the C @code{stderr} stream) a newline-terminated error
7051 message corresponding to the last system error. This is prefixed by
7052 @var{STRING}, a colon and a space. See @code{perror(3)}.
7054 @item @emph{Standard}:
7055 GNU extension
7057 @item @emph{Class}:
7058 Subroutine
7060 @item @emph{Syntax}:
7061 @code{CALL PERROR(STRING)}
7063 @item @emph{Arguments}:
7064 @multitable @columnfractions .15 .80
7065 @item @var{STRING} @tab A scalar of default @code{CHARACTER} type.
7066 @end multitable
7068 @item @emph{See also}:
7069 @ref{IERRNO}
7070 @end table
7074 @node PRECISION
7075 @section @code{PRECISION} --- Decimal precision of a real kind
7076 @cindex @code{PRECISION} intrinsic
7077 @cindex precision of a real variable
7079 @table @asis
7080 @item @emph{Description}:
7081 @code{PRECISION(X)} returns the decimal precision in the model of the
7082 type of @code{X}.
7084 @item @emph{Standard}:
7085 F95 and later
7087 @item @emph{Class}:
7088 Inquiry function
7090 @item @emph{Syntax}:
7091 @code{RESULT = PRECISION(X)}
7093 @item @emph{Arguments}:
7094 @multitable @columnfractions .15 .80
7095 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
7096 @end multitable
7098 @item @emph{Return value}:
7099 The return value is of type @code{INTEGER} and of the default integer
7100 kind.
7102 @item @emph{Example}:
7103 @smallexample
7104 program prec_and_range
7105   real(kind=4) :: x(2)
7106   complex(kind=8) :: y
7108   print *, precision(x), range(x)
7109   print *, precision(y), range(y)
7110 end program prec_and_range
7111 @end smallexample
7112 @end table
7116 @node PRESENT
7117 @section @code{PRESENT} --- Determine whether an optional argument is specified
7118 @cindex @code{PRESENT} intrinsic
7119 @cindex undocumented intrinsic 
7121 Intrinsic implemented, documentation pending.
7123 @table @asis
7124 @item @emph{Description}:
7125 @item @emph{Standard}:
7126 F95 and later
7128 @item @emph{Class}:
7129 Inquiry function
7131 @item @emph{Syntax}:
7132 @item @emph{Arguments}:
7133 @item @emph{Return value}:
7134 @item @emph{Example}:
7135 @item @emph{See also}:
7136 @end table
7140 @node PRODUCT
7141 @section @code{PRODUCT} --- Product of array elements
7142 @cindex @code{PRODUCT} intrinsic
7143 @cindex undocumented intrinsic 
7145 Intrinsic implemented, documentation pending.
7147 @table @asis
7148 @item @emph{Description}:
7149 @item @emph{Standard}:
7150 F95 and later
7152 @item @emph{Class}:
7153 Transformational function
7155 @item @emph{Syntax}:
7156 @item @emph{Arguments}:
7157 @item @emph{Return value}:
7158 @item @emph{Example}:
7159 @item @emph{Specific names}:
7160 @item @emph{See also}:
7161 @ref{SUM}
7162 @end table
7166 @node RADIX
7167 @section @code{RADIX} --- Base of a model number
7168 @cindex @code{RADIX} intrinsic
7169 @cindex base
7171 @table @asis
7172 @item @emph{Description}:
7173 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
7175 @item @emph{Standard}:
7176 F95 and later
7178 @item @emph{Class}:
7179 Inquiry function
7181 @item @emph{Syntax}:
7182 @code{RESULT = RADIX(X)}
7184 @item @emph{Arguments}:
7185 @multitable @columnfractions .15 .80
7186 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
7187 @end multitable
7189 @item @emph{Return value}:
7190 The return value is a scalar of type @code{INTEGER} and of the default
7191 integer kind.
7193 @item @emph{Example}:
7194 @smallexample
7195 program test_radix
7196   print *, "The radix for the default integer kind is", radix(0)
7197   print *, "The radix for the default real kind is", radix(0.0)
7198 end program test_radix
7199 @end smallexample
7201 @end table
7205 @node RAN
7206 @section @code{RAN} --- Real pseudo-random number
7207 @cindex @code{RAN} intrinsic
7208 @cindex random numbers
7210 @table @asis
7211 @item @emph{Description}:
7212 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
7213 provided as an alias for @code{RAND}.  See @ref{RAND} for complete
7214 documentation.
7216 @item @emph{Standard}:
7217 GNU extension
7219 @item @emph{Class}:
7220 Non-elemental function
7222 @item @emph{See also}:
7223 @ref{RAND}, @ref{RANDOM_NUMBER}
7224 @end table
7228 @node RAND
7229 @section @code{RAND} --- Real pseudo-random number
7230 @cindex @code{RAND} intrinsic
7231 @cindex random numbers
7233 @table @asis
7234 @item @emph{Description}:
7235 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
7236 distribution between 0 and 1. If @var{FLAG} is 0, the next number
7237 in the current sequence is returned; if @var{FLAG} is 1, the generator
7238 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
7239 it is used as a new seed with @code{SRAND}.
7241 @item @emph{Standard}:
7242 GNU extension
7244 @item @emph{Class}:
7245 Non-elemental function
7247 @item @emph{Syntax}:
7248 @code{RESULT = RAND(FLAG)}
7250 @item @emph{Arguments}:
7251 @multitable @columnfractions .15 .80
7252 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
7253 @end multitable
7255 @item @emph{Return value}:
7256 The return value is of @code{REAL} type and the default kind.
7258 @item @emph{Example}:
7259 @smallexample
7260 program test_rand
7261   integer,parameter :: seed = 86456
7262   
7263   call srand(seed)
7264   print *, rand(), rand(), rand(), rand()
7265   print *, rand(seed), rand(), rand(), rand()
7266 end program test_rand
7267 @end smallexample
7269 @item @emph{See also}:
7270 @ref{SRAND}, @ref{RANDOM_NUMBER}
7272 @end table
7276 @node RANDOM_NUMBER
7277 @section @code{RANDOM_NUMBER} --- Pseudo-random number
7278 @cindex @code{RANDOM_NUMBER} intrinsic
7279 @cindex random numbers
7281 Intrinsic implemented, documentation pending.
7283 @table @asis
7284 @item @emph{Description}:
7285 @item @emph{Standard}:
7286 F95 and later
7288 @item @emph{Class}:
7289 Elemental subroutine
7291 @item @emph{Syntax}:
7292 @item @emph{Arguments}:
7293 @item @emph{Return value}:
7294 @item @emph{Example}:
7295 @item @emph{See also}:
7296 @ref{RANDOM_SEED}
7297 @end table
7301 @node RANDOM_SEED
7302 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
7303 @cindex @code{RANDOM_SEED} intrinsic
7304 @cindex random numbers
7306 Intrinsic implemented, documentation pending.
7308 @table @asis
7309 @item @emph{Description}:
7310 @item @emph{Standard}:
7311 F95 and later
7313 @item @emph{Class}:
7314 Subroutine
7316 @item @emph{Syntax}:
7317 @item @emph{Arguments}:
7318 @item @emph{Return value}:
7319 @item @emph{Example}:
7320 @item @emph{See also}:
7321 @ref{RANDOM_NUMBER}
7322 @end table
7326 @node RANGE
7327 @section @code{RANGE} --- Decimal exponent range of a real kind
7328 @cindex @code{RANGE} intrinsic
7329 @cindex range of a real variable
7331 @table @asis
7332 @item @emph{Description}:
7333 @code{RANGE(X)} returns the decimal exponent range in the model of the
7334 type of @code{X}.
7336 @item @emph{Standard}:
7337 F95 and later
7339 @item @emph{Class}:
7340 Inquiry function
7342 @item @emph{Syntax}:
7343 @code{RESULT = RANGE(X)}
7345 @item @emph{Arguments}:
7346 @multitable @columnfractions .15 .80
7347 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
7348 @end multitable
7350 @item @emph{Return value}:
7351 The return value is of type @code{INTEGER} and of the default integer
7352 kind.
7354 @item @emph{Example}:
7355 See @code{PRECISION} for an example.
7356 @end table
7360 @node REAL
7361 @section @code{REAL} --- Convert to real type 
7362 @cindex @code{REAL} intrinsic
7363 @cindex @code{REALPART} intrinsic
7364 @cindex true values
7366 @table @asis
7367 @item @emph{Description}:
7368 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type.  The
7369 @code{REALPART(X)} function is provided for compatibility with @command{g77},
7370 and its use is strongly discouraged.
7372 @item @emph{Standard}:
7373 F77 and later
7375 @item @emph{Class}:
7376 Elemental function
7378 @item @emph{Syntax}:
7379 @multitable @columnfractions .30 .80
7380 @item @code{RESULT = REAL(X [, KIND])}
7381 @item @code{RESULT = REALPART(Z)}
7382 @end multitable
7384 @item @emph{Arguments}:
7385 @multitable @columnfractions .15 .80
7386 @item @var{X}    @tab shall be @code{INTEGER(*)}, @code{REAL(*)}, or
7387                       @code{COMPLEX(*)}.
7388 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
7389                       expression indicating the kind parameter of
7390                       the result.
7391 @end multitable
7393 @item @emph{Return value}:
7394 These functions return a @code{REAL(*)} variable or array under
7395 the following rules: 
7397 @table @asis
7398 @item (A)
7399 @code{REAL(X)} is converted to a default real type if @var{X} is an 
7400 integer or real variable.
7401 @item (B)
7402 @code{REAL(X)} is converted to a real type with the kind type parameter
7403 of @var{X} if @var{X} is a complex variable.
7404 @item (C)
7405 @code{REAL(X, KIND)} is converted to a real type with kind type
7406 parameter @var{KIND} if @var{X} is a complex, integer, or real
7407 variable.
7408 @end table
7410 @item @emph{Example}:
7411 @smallexample
7412 program test_real
7413   complex :: x = (1.0, 2.0)
7414   print *, real(x), real(x,8), realpart(x)
7415 end program test_real
7416 @end smallexample
7418 @item @emph{See also}:
7419 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
7421 @end table
7425 @node RENAME
7426 @section @code{RENAME} --- Rename a file
7427 @cindex @code{RENAME} intrinsic
7428 @cindex file system operations
7430 @table @asis
7431 @item @emph{Description}:
7432 Renames a file from file @var{PATH1} to @var{PATH2}. A null
7433 character (@code{CHAR(0)}) can be used to mark the end of the names in
7434 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
7435 names are ignored.  If the @var{STATUS} argument is supplied, it
7436 contains 0 on success or a nonzero error code upon return; see
7437 @code{rename(2)}.
7439 @item @emph{Standard}:
7440 GNU extension
7442 @item @emph{Class}:
7443 Subroutine
7445 @item @emph{Syntax}:
7446 @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
7448 @item @emph{Arguments}:
7449 @multitable @columnfractions .15 .80
7450 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
7451 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
7452 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
7453 @end multitable
7455 @item @emph{See also}:
7456 @ref{LINK}
7458 @end table
7462 @node REPEAT
7463 @section @code{REPEAT} --- Repeated string concatenation 
7464 @cindex @code{REPEAT} intrinsic
7465 @cindex string manipulation
7467 Intrinsic implemented, documentation pending.
7469 @table @asis
7470 @item @emph{Description}:
7471 @item @emph{Standard}:
7472 F95 and later
7474 @item @emph{Class}:
7475 Transformational function
7477 @item @emph{Syntax}:
7478 @item @emph{Arguments}:
7479 @item @emph{Return value}:
7480 @item @emph{Example}:
7481 @item @emph{See also}:
7482 @end table
7487 @node RESHAPE
7488 @section @code{RESHAPE} --- Function to reshape an array
7489 @cindex @code{RESHAPE} intrinsic
7490 @cindex array manipulation
7492 Intrinsic implemented, documentation pending.
7494 @table @asis
7495 @item @emph{Description}:
7496 @item @emph{Standard}:
7497 F95 and later
7499 @item @emph{Class}:
7500 Transformational function
7502 @item @emph{Syntax}:
7503 @item @emph{Arguments}:
7504 @item @emph{Return value}:
7505 @item @emph{Example}:
7506 @item @emph{See also}:
7507 @ref{SHAPE}
7508 @end table
7512 @node RRSPACING
7513 @section @code{RRSPACING} --- Reciprocal of the relative spacing
7514 @cindex @code{RRSPACING} intrinsic
7516 @table @asis
7517 @item @emph{Description}:
7518 @code{RRSPACING(X)} returns the  reciprocal of the relative spacing of
7519 model numbers near @var{X}.
7521 @item @emph{Standard}:
7522 F95 and later
7524 @item @emph{Class}:
7525 Elemental function
7527 @item @emph{Syntax}:
7528 @code{RESULT = RRSPACING(X)}
7530 @item @emph{Arguments}:
7531 @multitable @columnfractions .15 .80
7532 @item @var{X} @tab shall be of type @code{REAL}.
7533 @end multitable
7535 @item @emph{Return value}:
7536 The return value is of the same type and kind as @var{X}.
7537 The value returned is equal to
7538 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
7540 @end table
7544 @node RSHIFT
7545 @section @code{RSHIFT} --- Right shift bits
7546 @cindex @code{RSHIFT} intrinsic
7547 @cindex bit operations
7549 @table @asis
7550 @item @emph{Description}:
7551 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
7552 bits shifted right by @var{SHIFT} places.  If the absolute value of
7553 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined. 
7554 Bits shifted out from the left end are lost; zeros are shifted in from
7555 the opposite end.
7557 This function has been superseded by the @code{ISHFT} intrinsic, which
7558 is standard in Fortran 95 and later.
7560 @item @emph{Standard}:
7561 GNU extension
7563 @item @emph{Class}:
7564 Elemental function
7566 @item @emph{Syntax}:
7567 @code{RESULT = RSHIFT(I, SHIFT)}
7569 @item @emph{Arguments}:
7570 @multitable @columnfractions .15 .80
7571 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
7572 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
7573 @end multitable
7575 @item @emph{Return value}:
7576 The return value is of type @code{INTEGER(*)} and of the same kind as
7577 @var{I}.
7579 @item @emph{See also}:
7580 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
7582 @end table
7586 @node SCALE
7587 @section @code{SCALE} --- Scale a real value
7588 @cindex @code{SCALE} intrinsic
7590 @table @asis
7591 @item @emph{Description}:
7592 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
7594 @item @emph{Standard}:
7595 F95 and later
7597 @item @emph{Class}:
7598 Elemental function
7600 @item @emph{Syntax}:
7601 @code{RESULT = SCALE(X, I)}
7603 @item @emph{Arguments}:
7604 @multitable @columnfractions .15 .80
7605 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
7606 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
7607 @end multitable
7609 @item @emph{Return value}:
7610 The return value is of the same type and kind as @var{X}.
7611 Its value is @code{X * RADIX(X)**I}.
7613 @item @emph{Example}:
7614 @smallexample
7615 program test_scale
7616   real :: x = 178.1387e-4
7617   integer :: i = 5
7618   print *, scale(x,i), x*radix(x)**i
7619 end program test_scale
7620 @end smallexample
7622 @end table
7625 @node SCAN
7626 @section @code{SCAN} --- Scan a string for the presence of a set of characters
7627 @cindex @code{SCAN} intrinsic
7628 @cindex string manipulation
7630 Intrinsic implemented, documentation pending.
7632 @table @asis
7633 @item @emph{Description}:
7634 @item @emph{Standard}:
7635 F95 and later
7637 @item @emph{Class}:
7638 Elemental function
7640 @item @emph{Syntax}:
7641 @item @emph{Arguments}:
7642 @item @emph{Return value}:
7643 @item @emph{Example}:
7644 @item @emph{See also}:
7645 @end table
7650 @node SECNDS
7651 @section @code{SECNDS} --- Time function
7652 @cindex @code{SECNDS} intrinsic
7653 @cindex time, current
7654 @cindex current time
7656 @table @asis
7657 @item @emph{Description}:
7658 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
7659 @var{X} is a reference time, also in seconds. If this is zero, the time in
7660 seconds from midnight is returned. This function is non-standard and its
7661 use is discouraged.
7663 @item @emph{Standard}:
7664 GNU extension
7666 @item @emph{Class}:
7667 function
7669 @item @emph{Syntax}:
7670 @code{RESULT = SECNDS (X)}
7672 @item @emph{Arguments}:
7673 @multitable @columnfractions .15 .80
7674 @item Name        @tab Type
7675 @item @var{T}     @tab REAL(4)
7676 @item @var{X}     @tab REAL(4)
7677 @end multitable
7679 @item @emph{Return value}:
7680 None
7682 @item @emph{Example}:
7683 @smallexample
7684 program test_secnds
7685     real(4) :: t1, t2
7686     print *, secnds (0.0)   ! seconds since midnight
7687     t1 = secnds (0.0)       ! reference time
7688     do i = 1, 10000000      ! do something
7689     end do
7690     t2 = secnds (t1)        ! elapsed time
7691     print *, "Something took ", t2, " seconds."
7692 end program test_secnds
7693 @end smallexample
7694 @end table
7698 @node SELECTED_INT_KIND
7699 @section @code{SELECTED_INT_KIND} --- Choose integer kind
7700 @cindex @code{SELECTED_INT_KIND} intrinsic
7701 @cindex integer kind
7703 @table @asis
7704 @item @emph{Description}:
7705 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
7706 type that can represent all values ranging from @math{-10^I} (exclusive)
7707 to @math{10^I} (exclusive). If there is no integer kind that accommodates
7708 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
7710 @item @emph{Standard}:
7711 F95 and later
7713 @item @emph{Class}:
7714 Transformational function
7716 @item @emph{Syntax}:
7717 @code{RESULT = SELECTED_INT_KIND(I)}
7719 @item @emph{Arguments}:
7720 @multitable @columnfractions .15 .80
7721 @item @var{I} @tab shall be a scalar and of type @code{INTEGER}.
7722 @end multitable
7724 @item @emph{Example}:
7725 @smallexample
7726 program large_integers
7727   integer,parameter :: k5 = selected_int_kind(5)
7728   integer,parameter :: k15 = selected_int_kind(15)
7729   integer(kind=k5) :: i5
7730   integer(kind=k15) :: i15
7732   print *, huge(i5), huge(i15)
7734   ! The following inequalities are always true
7735   print *, huge(i5) >= 10_k5**5-1
7736   print *, huge(i15) >= 10_k15**15-1
7737 end program large_integers
7738 @end smallexample
7739 @end table
7743 @node SELECTED_REAL_KIND
7744 @section @code{SELECTED_REAL_KIND} --- Choose real kind
7745 @cindex @code{SELECTED_REAL_KIND} intrinsic
7746 @cindex real kind
7748 @table @asis
7749 @item @emph{Description}:
7750 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
7751 with decimal precision greater of at least @code{P} digits and exponent
7752 range greater at least @code{R}. 
7754 @item @emph{Standard}:
7755 F95 and later
7757 @item @emph{Class}:
7758 Transformational function
7760 @item @emph{Syntax}:
7761 @code{RESULT = SELECTED_REAL_KIND(P, R)}
7763 @item @emph{Arguments}:
7764 @multitable @columnfractions .15 .80
7765 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7766 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7767 @end multitable
7768 At least one argument shall be present.
7770 @item @emph{Return value}:
7772 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
7773 a real data type with decimal precision of at least @code{P} digits and a
7774 decimal exponent range of at least @code{R}. If more than one real data
7775 type meet the criteria, the kind of the data type with the smallest
7776 decimal precision is returned. If no real data type matches the criteria,
7777 the result is
7778 @table @asis
7779 @item -1 if the processor does not support a real data type with a
7780 precision greater than or equal to @code{P}
7781 @item -2 if the processor does not support a real type with an exponent
7782 range greater than or equal to @code{R}
7783 @item -3 if neither is supported.
7784 @end table
7786 @item @emph{Example}:
7787 @smallexample
7788 program real_kinds
7789   integer,parameter :: p6 = selected_real_kind(6)
7790   integer,parameter :: p10r100 = selected_real_kind(10,100)
7791   integer,parameter :: r400 = selected_real_kind(r=400)
7792   real(kind=p6) :: x
7793   real(kind=p10r100) :: y
7794   real(kind=r400) :: z
7796   print *, precision(x), range(x)
7797   print *, precision(y), range(y)
7798   print *, precision(z), range(z)
7799 end program real_kinds
7800 @end smallexample
7801 @end table
7805 @node SET_EXPONENT
7806 @section @code{SET_EXPONENT} --- Set the exponent of the model
7807 @cindex @code{SET_EXPONENT} intrinsic
7808 @cindex exponent part of a real number
7810 @table @asis
7811 @item @emph{Description}:
7812 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
7813 is that that of @var{X} and whose exponent part is @var{I}.
7815 @item @emph{Standard}:
7816 F95 and later
7818 @item @emph{Class}:
7819 Elemental function
7821 @item @emph{Syntax}:
7822 @code{RESULT = SET_EXPONENT(X, I)}
7824 @item @emph{Arguments}:
7825 @multitable @columnfractions .15 .80
7826 @item @var{X} @tab shall be of type @code{REAL}.
7827 @item @var{I} @tab shall be of type @code{INTEGER}.
7828 @end multitable
7830 @item @emph{Return value}:
7831 The return value is of the same type and kind as @var{X}.
7832 The real number whose fractional part
7833 is that that of @var{X} and whose exponent part if @var{I} is returned;
7834 it is @code{FRACTION(X) * RADIX(X)**I}.
7836 @item @emph{Example}:
7837 @smallexample
7838 program test_setexp
7839   real :: x = 178.1387e-4
7840   integer :: i = 17
7841   print *, set_exponent(x), fraction(x) * radix(x)**i
7842 end program test_setexp
7843 @end smallexample
7845 @end table
7849 @node SHAPE
7850 @section @code{SHAPE} --- Determine the shape of an array
7851 @cindex @code{SHAPE} intrinsic
7852 @cindex array manipulation
7854 Intrinsic implemented, documentation pending.
7856 @table @asis
7857 @item @emph{Description}:
7858 @item @emph{Standard}:
7859 F95 and later
7861 @item @emph{Class}:
7862 Inquiry function
7864 @item @emph{Syntax}:
7865 @item @emph{Arguments}:
7866 @item @emph{Return value}:
7867 @item @emph{Example}:
7868 @item @emph{See also}:
7869 @ref{RESHAPE}
7870 @end table
7874 @node SIGN
7875 @section @code{SIGN} --- Sign copying function
7876 @cindex @code{SIGN} intrinsic
7877 @cindex @code{ISIGN} intrinsic
7878 @cindex @code{DSIGN} intrinsic
7879 @cindex sign copying
7881 @table @asis
7882 @item @emph{Description}:
7883 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
7885 @item @emph{Standard}:
7886 F77 and later
7888 @item @emph{Class}:
7889 Elemental function
7891 @item @emph{Syntax}:
7892 @code{RESULT = SIGN(A, B)}
7894 @item @emph{Arguments}:
7895 @multitable @columnfractions .15 .80
7896 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
7897 @item @var{B} @tab shall be a scalar of the same type and kind as @var{A}
7898 @end multitable
7900 @item @emph{Return value}:
7901 The kind of the return value is that of @var{A} and @var{B}.
7902 If @math{B\ge 0} then the result is @code{ABS(A)}, else
7903 it is @code{-ABS(A)}.
7905 @item @emph{Example}:
7906 @smallexample
7907 program test_sign
7908   print *, sign(-12,1)
7909   print *, sign(-12,0)
7910   print *, sign(-12,-1)
7912   print *, sign(-12.,1.)
7913   print *, sign(-12.,0.)
7914   print *, sign(-12.,-1.)
7915 end program test_sign
7916 @end smallexample
7918 @item @emph{Specific names}:
7919 @multitable @columnfractions .20 .20 .20 .40
7920 @item Name              @tab Arguments      @tab Return type    @tab Standard
7921 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
7922 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
7923 @end multitable
7924 @end table
7928 @node SIGNAL
7929 @section @code{SIGNAL} --- Signal handling subroutine (or function)
7930 @cindex @code{SIGNAL} intrinsic
7931 @cindex signal handling
7933 @table @asis
7934 @item @emph{Description}:
7935 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
7936 @var{HANDLER} to be executed with a single integer argument when signal
7937 @var{NUMBER} occurs.  If @var{HANDLER} is an integer, it can be used to
7938 turn off handling of signal @var{NUMBER} or revert to its default
7939 action.  See @code{signal(2)}.
7941 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
7942 is supplied, it is set to the value returned by @code{signal(2)}.
7944 @item @emph{Standard}:
7945 GNU extension
7947 @item @emph{Class}:
7948 subroutine, non-elemental function
7950 @item @emph{Syntax}:
7951 @multitable @columnfractions .80
7952 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
7953 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
7954 @end multitable
7956 @item @emph{Arguments}:
7957 @multitable @columnfractions .15 .80
7958 @item @var{NUMBER} @tab shall be a scalar integer, with @code{INTENT(IN)}
7959 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
7960 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
7961 @code{INTEGER}. It is @code{INTENT(IN)}.
7962 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
7963 integer. It has @code{INTENT(OUT)}.
7964 @end multitable
7966 @item @emph{Return value}:
7967 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
7969 @item @emph{Example}:
7970 @smallexample
7971 program test_signal
7972   intrinsic signal
7973   external handler_print
7975   call signal (12, handler_print)
7976   call signal (10, 1)
7978   call sleep (30)
7979 end program test_signal
7980 @end smallexample
7981 @end table
7985 @node SIN
7986 @section @code{SIN} --- Sine function 
7987 @cindex @code{SIN} intrinsic
7988 @cindex @code{DSIN} intrinsic
7989 @cindex @code{ZSIN} intrinsic
7990 @cindex @code{CDSIN} intrinsic
7991 @cindex trigonometric functions
7993 @table @asis
7994 @item @emph{Description}:
7995 @code{SIN(X)} computes the sine of @var{X}.
7997 @item @emph{Standard}:
7998 F77 and later
8000 @item @emph{Class}:
8001 Elemental function
8003 @item @emph{Syntax}:
8004 @code{RESULT = SIN(X)}
8006 @item @emph{Arguments}:
8007 @multitable @columnfractions .15 .80
8008 @item @var{X} @tab The type shall be @code{REAL(*)} or
8009 @code{COMPLEX(*)}.
8010 @end multitable
8012 @item @emph{Return value}:
8013 The return value has same type and kind as @var{X}.
8015 @item @emph{Example}:
8016 @smallexample
8017 program test_sin
8018   real :: x = 0.0
8019   x = sin(x)
8020 end program test_sin
8021 @end smallexample
8023 @item @emph{Specific names}:
8024 @multitable @columnfractions .20 .20 .20 .40
8025 @item Name            @tab Argument          @tab Return type       @tab Standard
8026 @item @code{DSIN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
8027 @item @code{CSIN(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
8028 @item @code{ZSIN(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
8029 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
8030 @end multitable
8032 @item @emph{See also}:
8033 @ref{ASIN}
8034 @end table
8038 @node SINH
8039 @section @code{SINH} --- Hyperbolic sine function 
8040 @cindex @code{SINH} intrinsic
8041 @cindex @code{DSINH} intrinsic
8042 @cindex hyperbolic sine
8044 @table @asis
8045 @item @emph{Description}:
8046 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
8048 @item @emph{Standard}:
8049 F95 and later
8051 @item @emph{Class}:
8052 Elemental function
8054 @item @emph{Syntax}:
8055 @code{RESULT = SINH(X)}
8057 @item @emph{Arguments}:
8058 @multitable @columnfractions .15 .80
8059 @item @var{X} @tab The type shall be @code{REAL(*)}.
8060 @end multitable
8062 @item @emph{Return value}:
8063 The return value is of type @code{REAL(*)}.
8065 @item @emph{Example}:
8066 @smallexample
8067 program test_sinh
8068   real(8) :: x = - 1.0_8
8069   x = sinh(x)
8070 end program test_sinh
8071 @end smallexample
8073 @item @emph{Specific names}:
8074 @multitable @columnfractions .20 .20 .20 .40
8075 @item Name            @tab Argument          @tab Return type       @tab Standard
8076 @item @code{DSINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab F95 and later
8077 @end multitable
8079 @item @emph{See also}:
8080 @ref{ASINH}
8081 @end table
8085 @node SIZE
8086 @section @code{SIZE} --- Determine the size of an array
8087 @cindex @code{SIZE} intrinsic
8088 @cindex array manipulation
8090 Intrinsic implemented, documentation pending.
8092 @table @asis
8093 @item @emph{Description}:
8094 @item @emph{Standard}:
8095 F95 and later
8097 @item @emph{Class}:
8098 Inquiry function
8100 @item @emph{Syntax}:
8101 @item @emph{Arguments}:
8102 @item @emph{Return value}:
8103 @item @emph{Example}:
8104 @item @emph{See also}:
8105 @end table
8109 @node SLEEP
8110 @section @code{SLEEP} --- Sleep for the specified number of seconds
8111 @cindex @code{SLEEP} intrinsic
8113 @table @asis
8114 @item @emph{Description}:
8115 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
8117 @item @emph{Standard}:
8118 GNU extension
8120 @item @emph{Class}:
8121 Subroutine
8123 @item @emph{Syntax}:
8124 @code{CALL SLEEP(SECONDS)}
8126 @item @emph{Arguments}:
8127 @multitable @columnfractions .15 .80
8128 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
8129 @end multitable
8131 @item @emph{Example}:
8132 @smallexample
8133 program test_sleep
8134   call sleep(5)
8136 @end smallexample
8137 @end table
8141 @node SNGL
8142 @section @code{SNGL} --- Convert double precision real to default real
8143 @cindex @code{SNGL} intrinsic
8144 @cindex conversion function (real)
8146 @table @asis
8147 @item @emph{Description}:
8148 @code{SNGL(A)} converts the double precision real @var{A}
8149 to a default real value. This is an archaic form of @code{REAL}
8150 that is specific to one type for @var{A}.
8152 @item @emph{Standard}:
8153 GNU extension
8155 @item @emph{Class}:
8156 function
8158 @item @emph{Syntax}:
8159 @code{RESULT = SNGL(A)}
8161 @item @emph{Arguments}:
8162 @multitable @columnfractions .15 .80
8163 @item @var{A} @tab The type shall be a double precision @code{REAL}.
8164 @end multitable
8166 @item @emph{Return value}:
8167 The return value is of type default @code{REAL}.
8169 @item @emph{See also}:
8170 @ref{DBLE}
8171 @end table
8175 @node SPACING
8176 @section @code{SPACING} --- Smallest distance between two numbers of a given type
8177 @cindex @code{SPACING} intrinsic
8178 @cindex undocumented intrinsic 
8180 Intrinsic implemented, documentation pending.
8182 @table @asis
8183 @item @emph{Description}:
8184 @item @emph{Standard}:
8185 F95 and later
8187 @item @emph{Class}:
8188 Elemental function
8190 @item @emph{Syntax}:
8191 @item @emph{Arguments}:
8192 @item @emph{Return value}:
8193 @item @emph{Example}:
8194 @item @emph{See also}:
8195 @end table
8200 @node SPREAD
8201 @section @code{SPREAD} --- Add a dimension to an array
8202 @cindex @code{SPREAD} intrinsic
8203 @cindex array manipulation
8205 Intrinsic implemented, documentation pending.
8207 @table @asis
8208 @item @emph{Description}:
8209 @item @emph{Standard}:
8210 F95 and later
8212 @item @emph{Class}:
8213 Transformational function
8215 @item @emph{Syntax}:
8216 @item @emph{Arguments}:
8217 @item @emph{Return value}:
8218 @item @emph{Example}:
8219 @item @emph{See also}:
8220 @end table
8225 @node SQRT
8226 @section @code{SQRT} --- Square-root function
8227 @cindex @code{SQRT} intrinsic
8228 @cindex @code{DSQRT} intrinsic
8229 @cindex @code{CSQRT} intrinsic
8230 @cindex @code{ZSQRT} intrinsic
8231 @cindex @code{CDSQRT} intrinsic
8232 @cindex square-root
8234 @table @asis
8235 @item @emph{Description}:
8236 @code{SQRT(X)} computes the square root of @var{X}.
8238 @item @emph{Standard}:
8239 F77 and later
8241 @item @emph{Class}:
8242 Elemental function
8244 @item @emph{Syntax}:
8245 @code{RESULT = SQRT(X)}
8247 @item @emph{Arguments}:
8248 @multitable @columnfractions .15 .80
8249 @item @var{X} @tab The type shall be @code{REAL(*)} or
8250 @code{COMPLEX(*)}.
8251 @end multitable
8253 @item @emph{Return value}:
8254 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
8255 The kind type parameter is the same as @var{X}.
8257 @item @emph{Example}:
8258 @smallexample
8259 program test_sqrt
8260   real(8) :: x = 2.0_8
8261   complex :: z = (1.0, 2.0)
8262   x = sqrt(x)
8263   z = sqrt(z)
8264 end program test_sqrt
8265 @end smallexample
8267 @item @emph{Specific names}:
8268 @multitable @columnfractions .20 .20 .20 .40
8269 @item Name             @tab Argument             @tab Return type          @tab Standard
8270 @item @code{DSQRT(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}       @tab F95 and later
8271 @item @code{CSQRT(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab F95 and later
8272 @item @code{ZSQRT(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
8273 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
8274 @end multitable
8275 @end table
8279 @node SRAND
8280 @section @code{SRAND} --- Reinitialize the random number generator
8281 @cindex @code{SRAND} intrinsic
8282 @cindex random numbers
8284 @table @asis
8285 @item @emph{Description}:
8286 @code{SRAND} reinitializes the pseudo-random number generator
8287 called by @code{RAND} and @code{IRAND}. The new seed used by the
8288 generator is specified by the required argument @var{SEED}.
8290 @item @emph{Standard}:
8291 GNU extension
8293 @item @emph{Class}:
8294 non-elemental subroutine
8296 @item @emph{Syntax}:
8297 @code{CALL SRAND(SEED)}
8299 @item @emph{Arguments}:
8300 @multitable @columnfractions .15 .80
8301 @item @var{SEED} @tab shall be a scalar @code{INTEGER(kind=4)}.
8302 @end multitable
8304 @item @emph{Return value}:
8305 Does not return.
8307 @item @emph{Example}:
8308 See @code{RAND} and @code{IRAND} for examples.
8310 @item @emph{Notes}:
8311 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
8312 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
8313 to generate pseudo-random numbers. Please note that in
8314 GNU Fortran, these two sets of intrinsics (@code{RAND},
8315 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
8316 @code{RANDOM_SEED} on the other hand) access two independent
8317 pseudo-random number generators.
8319 @item @emph{See also}:
8320 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
8322 @end table
8326 @node STAT
8327 @section @code{STAT} --- Get file status
8328 @cindex @code{STAT} intrinsic
8329 @cindex file system operations
8331 @table @asis
8332 @item @emph{Description}:
8333 This function returns information about a file. No permissions are required on 
8334 the file itself, but execute (search) permission is required on all of the 
8335 directories in path that lead to the file.
8337 The elements that are obtained and stored in the array @code{BUFF}:
8338 @multitable @columnfractions .15 .80
8339 @item @code{buff(1)}   @tab  Device ID 
8340 @item @code{buff(2)}   @tab  Inode number 
8341 @item @code{buff(3)}   @tab  File mode 
8342 @item @code{buff(4)}   @tab  Number of links 
8343 @item @code{buff(5)}   @tab  Owner's uid 
8344 @item @code{buff(6)}   @tab  Owner's gid 
8345 @item @code{buff(7)}   @tab  ID of device containing directory entry for file (0 if not available) 
8346 @item @code{buff(8)}   @tab  File size (bytes) 
8347 @item @code{buff(9)}   @tab  Last access time 
8348 @item @code{buff(10)}  @tab  Last modification time 
8349 @item @code{buff(11)}  @tab  Last file status change time 
8350 @item @code{buff(12)}  @tab  Preferred I/O block size (-1 if not available) 
8351 @item @code{buff(13)}  @tab  Number of blocks allocated (-1 if not available)
8352 @end multitable
8354 Not all these elements are relevant on all systems. 
8355 If an element is not relevant, it is returned as 0.
8358 @item @emph{Standard}:
8359 GNU extension
8361 @item @emph{Class}:
8362 Non-elemental subroutine
8364 @item @emph{Syntax}:
8365 @code{CALL STAT(FILE,BUFF[,STATUS])}
8367 @item @emph{Arguments}:
8368 @multitable @columnfractions .15 .80
8369 @item @var{FILE}   @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
8370 @item @var{BUFF}   @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
8371 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
8372                         on success and a system specific error code otherwise.
8373 @end multitable
8375 @item @emph{Example}:
8376 @smallexample
8377 PROGRAM test_stat
8378   INTEGER, DIMENSION(13) :: buff
8379   INTEGER :: status
8381   CALL STAT("/etc/passwd", buff, status)
8383   IF (status == 0) THEN
8384     WRITE (*, FMT="('Device ID:',               T30, I19)") buff(1)
8385     WRITE (*, FMT="('Inode number:',            T30, I19)") buff(2)
8386     WRITE (*, FMT="('File mode (octal):',       T30, O19)") buff(3)
8387     WRITE (*, FMT="('Number of links:',         T30, I19)") buff(4)
8388     WRITE (*, FMT="('Owner''s uid:',            T30, I19)") buff(5)
8389     WRITE (*, FMT="('Owner''s gid:',            T30, I19)") buff(6)
8390     WRITE (*, FMT="('Device where located:',    T30, I19)") buff(7)
8391     WRITE (*, FMT="('File size:',               T30, I19)") buff(8)
8392     WRITE (*, FMT="('Last access time:',        T30, A19)") CTIME(buff(9))
8393     WRITE (*, FMT="('Last modification time',   T30, A19)") CTIME(buff(10))
8394     WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
8395     WRITE (*, FMT="('Preferred block size:',    T30, I19)") buff(12)
8396     WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
8397   END IF
8398 END PROGRAM
8399 @end smallexample
8401 @item @emph{See also}:
8402 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
8403 @end table
8407 @node SUM
8408 @section @code{SUM} --- Sum of array elements
8409 @cindex @code{SUM} intrinsic
8410 @cindex array manipulation
8412 Intrinsic implemented, documentation pending.
8414 @table @asis
8415 @item @emph{Description}:
8416 @item @emph{Standard}:
8417 F95 and later
8419 @item @emph{Class}:
8420 Transformational function
8422 @item @emph{Syntax}:
8423 @item @emph{Arguments}:
8424 @item @emph{Return value}:
8425 @item @emph{Example}:
8426 @item @emph{See also}:
8427 @ref{PRODUCT}
8428 @end table
8432 @node SYMLNK
8433 @section @code{SYMLNK} --- Create a symbolic link
8434 @cindex @code{SYMLNK} intrinsic
8435 @cindex file system operations
8437 @table @asis
8438 @item @emph{Description}:
8439 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
8440 character (@code{CHAR(0)}) can be used to mark the end of the names in
8441 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
8442 names are ignored.  If the @var{STATUS} argument is supplied, it
8443 contains 0 on success or a nonzero error code upon return; see
8444 @code{symlink(2)}.  If the system does not supply @code{symlink(2)}, 
8445 @code{ENOSYS} is returned.
8447 @item @emph{Standard}:
8448 GNU extension
8450 @item @emph{Class}:
8451 Subroutine
8453 @item @emph{Syntax}:
8454 @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
8456 @item @emph{Arguments}:
8457 @multitable @columnfractions .15 .80
8458 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
8459 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
8460 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8461 @end multitable
8463 @item @emph{See also}:
8464 @ref{LINK}, @ref{UNLINK}
8466 @end table
8470 @node SYSTEM
8471 @section @code{SYSTEM} --- Execute a shell command
8472 @cindex @code{SYSTEM} intrinsic
8474 @table @asis
8475 @item @emph{Description}:
8476 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
8477 argument @var{STATUS} is present, it contains the value returned by
8478 @code{system(3)}, which is presumably 0 if the shell command succeeded.
8479 Note that which shell is used to invoke the command is system-dependent
8480 and environment-dependent.
8482 @item @emph{Standard}:
8483 GNU extension
8485 @item @emph{Class}:
8486 Subroutine
8488 @item @emph{Syntax}:
8489 @code{CALL SYSTEM(COMMAND [, STATUS])}
8491 @item @emph{Arguments}:
8492 @multitable @columnfractions .15 .80
8493 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
8494 @item @var{STATUS}  @tab (Optional) Shall be of default @code{INTEGER} type.
8495 @end multitable
8497 @item @emph{See also}:
8498 @end table
8502 @node SYSTEM_CLOCK
8503 @section @code{SYSTEM_CLOCK} --- Time function
8504 @cindex @code{SYSTEM_CLOCK} intrinsic
8505 @cindex time, current
8506 @cindex current time
8508 Intrinsic implemented, documentation pending.
8510 @table @asis
8511 @item @emph{Description}:
8512 @item @emph{Standard}:
8513 F95 and later
8515 @item @emph{Class}:
8516 Subroutine
8518 @item @emph{Syntax}:
8519 @item @emph{Arguments}:
8520 @item @emph{Return value}:
8521 @item @emph{Example}:
8522 @item @emph{See also}:
8523 @end table
8527 @node TAN
8528 @section @code{TAN} --- Tangent function
8529 @cindex @code{TAN} intrinsic
8530 @cindex @code{DTAN} intrinsic
8531 @cindex trigonometric functions
8533 @table @asis
8534 @item @emph{Description}:
8535 @code{TAN(X)} computes the tangent of @var{X}.
8537 @item @emph{Standard}:
8538 F77 and later
8540 @item @emph{Class}:
8541 Elemental function
8543 @item @emph{Syntax}:
8544 @code{RESULT = TAN(X)}
8546 @item @emph{Arguments}:
8547 @multitable @columnfractions .15 .80
8548 @item @var{X} @tab The type shall be @code{REAL(*)}.
8549 @end multitable
8551 @item @emph{Return value}:
8552 The return value is of type @code{REAL(*)}.  The kind type parameter is
8553 the same as @var{X}.
8555 @item @emph{Example}:
8556 @smallexample
8557 program test_tan
8558   real(8) :: x = 0.165_8
8559   x = tan(x)
8560 end program test_tan
8561 @end smallexample
8563 @item @emph{Specific names}:
8564 @multitable @columnfractions .20 .20 .20 .40
8565 @item Name            @tab Argument          @tab Return type       @tab Standard
8566 @item @code{DTAN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab F95 and later
8567 @end multitable
8569 @item @emph{See also}:
8570 @ref{ATAN}
8571 @end table
8575 @node TANH
8576 @section @code{TANH} --- Hyperbolic tangent function 
8577 @cindex @code{TANH} intrinsic
8578 @cindex @code{DTANH} intrinsic
8579 @cindex hyperbolic tangent
8581 @table @asis
8582 @item @emph{Description}:
8583 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
8585 @item @emph{Standard}:
8586 F77 and later
8588 @item @emph{Class}:
8589 Elemental function
8591 @item @emph{Syntax}:
8592 @code{X = TANH(X)}
8594 @item @emph{Arguments}:
8595 @multitable @columnfractions .15 .80
8596 @item @var{X} @tab The type shall be @code{REAL(*)}.
8597 @end multitable
8599 @item @emph{Return value}:
8600 The return value is of type @code{REAL(*)} and lies in the range
8601 @math{ - 1 \leq tanh(x) \leq 1 }.
8603 @item @emph{Example}:
8604 @smallexample
8605 program test_tanh
8606   real(8) :: x = 2.1_8
8607   x = tanh(x)
8608 end program test_tanh
8609 @end smallexample
8611 @item @emph{Specific names}:
8612 @multitable @columnfractions .20 .20 .20 .40
8613 @item Name            @tab Argument          @tab Return type       @tab Standard
8614 @item @code{DTANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab F95 and later
8615 @end multitable
8617 @item @emph{See also}:
8618 @ref{ATANH}
8619 @end table
8623 @node TIME
8624 @section @code{TIME} --- Time function
8625 @cindex @code{TIME} intrinsic
8626 @cindex time, current
8627 @cindex current time
8629 @table @asis
8630 @item @emph{Description}:
8631 Returns the current time encoded as an integer (in the manner of the
8632 UNIX function @code{time(3)}). This value is suitable for passing to
8633 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
8635 This intrinsic is not fully portable, such as to systems with 32-bit
8636 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
8637 the values returned by this intrinsic might be, or become, negative, or
8638 numerically less than previous values, during a single run of the
8639 compiled program.
8641 See @ref{TIME8}, for information on a similar intrinsic that might be
8642 portable to more GNU Fortran implementations, though to fewer Fortran
8643 compilers.
8645 @item @emph{Standard}:
8646 GNU extension
8648 @item @emph{Class}:
8649 Non-elemental function
8651 @item @emph{Syntax}:
8652 @code{RESULT = TIME()}
8654 @item @emph{Return value}:
8655 The return value is a scalar of type @code{INTEGER(4)}.
8657 @item @emph{See also}:
8658 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME8}
8660 @end table
8664 @node TIME8
8665 @section @code{TIME8} --- Time function (64-bit)
8666 @cindex @code{TIME8} intrinsic
8667 @cindex time, current
8668 @cindex current time
8670 @table @asis
8671 @item @emph{Description}:
8672 Returns the current time encoded as an integer (in the manner of the
8673 UNIX function @code{time(3)}). This value is suitable for passing to
8674 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
8676 @emph{Warning:} this intrinsic does not increase the range of the timing
8677 values over that returned by @code{time(3)}. On a system with a 32-bit
8678 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
8679 it is converted to a 64-bit @code{INTEGER(8)} value. That means
8680 overflows of the 32-bit value can still occur. Therefore, the values
8681 returned by this intrinsic might be or become negative or numerically
8682 less than previous values during a single run of the compiled program.
8684 @item @emph{Standard}:
8685 GNU extension
8687 @item @emph{Class}:
8688 Non-elemental function
8690 @item @emph{Syntax}:
8691 @code{RESULT = TIME8()}
8693 @item @emph{Return value}:
8694 The return value is a scalar of type @code{INTEGER(8)}.
8696 @item @emph{See also}:
8697 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME}
8699 @end table
8703 @node TINY
8704 @section @code{TINY} --- Smallest positive number of a real kind
8705 @cindex @code{TINY} intrinsic
8706 @cindex tiny
8708 @table @asis
8709 @item @emph{Description}:
8710 @code{TINY(X)} returns the smallest positive (non zero) number
8711 in the model of the type of @code{X}.
8713 @item @emph{Standard}:
8714 F95 and later
8716 @item @emph{Class}:
8717 Elemental function
8719 @item @emph{Syntax}:
8720 @code{RESULT = TINY(X)}
8722 @item @emph{Arguments}:
8723 @multitable @columnfractions .15 .80
8724 @item @var{X} @tab shall be of type @code{REAL}.
8725 @end multitable
8727 @item @emph{Return value}:
8728 The return value is of the same type and kind as @var{X}
8730 @item @emph{Example}:
8731 See @code{HUGE} for an example.
8732 @end table
8736 @node TRANSFER
8737 @section @code{TRANSFER} --- Transfer bit patterns
8738 @cindex @code{TRANSFER} intrinsic
8739 @cindex bit operations
8741 Intrinsic implemented, documentation pending.
8743 @table @asis
8744 @item @emph{Description}:
8745 @item @emph{Standard}:
8746 F95 and later
8748 @item @emph{Class}:
8749 Transformational function
8751 @item @emph{Syntax}:
8752 @item @emph{Arguments}:
8753 @item @emph{Return value}:
8754 @item @emph{Example}:
8755 @item @emph{See also}:
8756 @end table
8760 @node TRANSPOSE
8761 @section @code{TRANSPOSE} --- Transpose an array of rank two
8762 @cindex @code{TRANSPOSE} intrinsic
8763 @cindex matrix manipulation
8765 Intrinsic implemented, documentation pending.
8767 @table @asis
8768 @item @emph{Description}:
8769 @item @emph{Standard}:
8770 F95 and later
8772 @item @emph{Class}:
8773 Transformational function
8775 @item @emph{Syntax}:
8776 @item @emph{Arguments}:
8777 @item @emph{Return value}:
8778 @item @emph{Example}:
8779 @item @emph{See also}:
8780 @end table
8784 @node TRIM
8785 @section @code{TRIM} --- Function to remove trailing blank characters of a string
8786 @cindex @code{TRIM} intrinsic
8787 @cindex string manipulation
8789 Intrinsic implemented, documentation pending.
8791 @table @asis
8792 @item @emph{Description}:
8793 @item @emph{Standard}:
8794 F95 and later
8796 @item @emph{Class}:
8797 Transformational function
8799 @item @emph{Syntax}:
8800 @item @emph{Arguments}:
8801 @item @emph{Return value}:
8802 @item @emph{Example}:
8803 @item @emph{See also}:
8804 @end table
8808 @node UBOUND
8809 @section @code{UBOUND} --- Upper dimension bounds of an array
8810 @cindex @code{UBOUND} intrinsic
8812 @table @asis
8813 @item @emph{Description}:
8814 Returns the upper bounds of an array, or a single upper bound
8815 along the @var{DIM} dimension.
8816 @item @emph{Standard}:
8817 F95 and later
8819 @item @emph{Class}:
8820 Inquiry function
8822 @item @emph{Syntax}:
8823 @code{RESULT = UBOUND(ARRAY [, DIM])}
8825 @item @emph{Arguments}:
8826 @multitable @columnfractions .15 .80
8827 @item @var{ARRAY} @tab Shall be an array, of any type.
8828 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
8829 @end multitable
8831 @item @emph{Return value}:
8832 If @var{DIM} is absent, the result is an array of the upper bounds of
8833 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
8834 corresponding to the upper bound of the array along that dimension.  If
8835 @var{ARRAY} is an expression rather than a whole array or array
8836 structure component, or if it has a zero extent along the relevant
8837 dimension, the upper bound is taken to be the number of elements along
8838 the relevant dimension.
8840 @item @emph{See also}:
8841 @ref{LBOUND}
8842 @end table
8846 @node UMASK
8847 @section @code{UMASK} --- Set the file creation mask
8848 @cindex @code{UMASK} intrinsic
8849 @cindex file system operations
8851 @table @asis
8852 @item @emph{Description}:
8853 Sets the file creation mask to @var{MASK} and returns the old value in
8854 argument @var{OLD} if it is supplied. See @code{umask(2)}.
8856 @item @emph{Standard}:
8857 GNU extension
8859 @item @emph{Class}:
8860 Subroutine
8862 @item @emph{Syntax}:
8863 @code{CALL UMASK(MASK [, OLD])}
8865 @item @emph{Arguments}:
8866 @multitable @columnfractions .15 .80
8867 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER(*)}.
8868 @item @var{MASK} @tab (Optional) Shall be a scalar of type
8869                       @code{INTEGER(*)}.
8870 @end multitable
8872 @end table
8876 @node UNLINK
8877 @section @code{UNLINK} --- Remove a file from the file system
8878 @cindex @code{UNLINK} intrinsic
8879 @cindex file system operations
8881 @table @asis
8882 @item @emph{Description}:
8883 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
8884 used to mark the end of the name in @var{PATH}; otherwise, trailing
8885 blanks in the file name are ignored.  If the @var{STATUS} argument is
8886 supplied, it contains 0 on success or a nonzero error code upon return;
8887 see @code{unlink(2)}.
8889 @item @emph{Standard}:
8890 GNU extension
8892 @item @emph{Class}:
8893 Subroutine
8895 @item @emph{Syntax}:
8896 @code{CALL UNLINK(PATH [, STATUS])}
8898 @item @emph{Arguments}:
8899 @multitable @columnfractions .15 .80
8900 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
8901 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8902 @end multitable
8904 @item @emph{See also}:
8905 @ref{LINK}, @ref{SYMLNK}
8906 @end table
8910 @node UNPACK
8911 @section @code{UNPACK} --- Unpack an array of rank one into an array
8912 @cindex @code{UNPACK} intrinsic
8913 @cindex array manipulation
8915 Intrinsic implemented, documentation pending.
8917 @table @asis
8918 @item @emph{Description}:
8919 @item @emph{Standard}:
8920 F95 and later
8922 @item @emph{Class}:
8923 Transformational function
8925 @item @emph{Syntax}:
8926 @item @emph{Arguments}:
8927 @item @emph{Return value}:
8928 @item @emph{Example}:
8930 @item @emph{See also}:
8931 @ref{PACK}
8932 @end table
8936 @node VERIFY
8937 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
8938 @cindex @code{VERIFY} intrinsic
8939 @cindex string manipulation
8941 Intrinsic implemented, documentation pending.
8943 @table @asis
8944 @item @emph{Description}:
8945 @item @emph{Standard}:
8946 F95 and later
8948 @item @emph{Class}:
8949 Elemental function
8951 @item @emph{Syntax}:
8952 @item @emph{Arguments}:
8953 @item @emph{Return value}:
8954 @item @emph{Example}:
8955 @item @emph{Specific names}:
8956 @item @emph{See also}:
8957 @end table
8961 @node XOR
8962 @section @code{XOR} --- Bitwise logical exclusive OR
8963 @cindex @code{XOR} intrinsic
8964 @cindex bit operations
8966 @table @asis
8967 @item @emph{Description}:
8968 Bitwise logical exclusive or. 
8970 This intrinsic routine is provided for backwards compatibility with 
8971 GNU Fortran 77.  For integer arguments, programmers should consider
8972 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
8974 @item @emph{Standard}:
8975 GNU extension
8977 @item @emph{Class}:
8978 Non-elemental function
8980 @item @emph{Syntax}:
8981 @code{RESULT = XOR(X, Y)}
8983 @item @emph{Arguments}:
8984 @multitable @columnfractions .15 .80
8985 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8986 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8987 @end multitable
8989 @item @emph{Return value}:
8990 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
8991 after cross-promotion of the arguments.
8993 @item @emph{Example}:
8994 @smallexample
8995 PROGRAM test_xor
8996   LOGICAL :: T = .TRUE., F = .FALSE.
8997   INTEGER :: a, b
8998   DATA a / Z,'F' /, b / Z'3' /
9000   WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
9001   WRITE (*,*) XOR(a, b)
9002 END PROGRAM
9003 @end smallexample
9005 @item @emph{See also}:
9006 F95 elemental function: @ref{IEOR}
9007 @end table