* intrinsic.texi: Document new intrinsics.
[official-gcc.git] / gcc / fortran / intrinsic.texi
blob6bc7759feeabeb1e0e88bbdbb4b07a94774b2d26
1 @ignore
2 Copyright (C) 2005
3 Free Software Foundation, Inc.
4 This is part of the GFORTRAN 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 use.
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 @node Intrinsic Procedures
28 @chapter Intrinsic Procedures
29 @cindex Intrinsic Procedures
31 This portion of the document is incomplete and undergoing massive expansion 
32 and editing.  All contributions and corrections are strongly encouraged. 
34 @menu
35 * Introduction:         Introduction
36 * @code{ABORT}:         ABORT,     Abort the program     
37 * @code{ABS}:           ABS,       Absolute value     
38 * @code{ACHAR}:         ACHAR,     Character in @acronym{ASCII} collating sequence
39 * @code{ACOS}:          ACOS,      Arc cosine function
40 * @code{ADJUSTL}:       ADJUSTL,   Left adjust a string
41 * @code{ADJUSTR}:       ADJUSTR,   Right adjust a string
42 * @code{AIMAG}:         AIMAG,     Imaginary part of complex number
43 * @code{AINT}:          AINT,      Truncate to a whole number
44 * @code{ALARM}:         ALARM,     Set an alarm clock
45 * @code{ALL}:           ALL,       Determine if all values are true
46 * @code{ALLOCATED}:     ALLOCATED, Status of allocatable entity
47 * @code{ANINT}:         ANINT,     Nearest whole number
48 * @code{ANY}:           ANY,       Determine if any values are true
49 * @code{ASIN}:          ASIN,      Arcsine function
50 * @code{ASSOCIATED}:    ASSOCIATED, Status of a pointer or pointer/target pair
51 * @code{ATAN}:          ATAN,      Arctangent function
52 * @code{ATAN2}:         ATAN2,     Arctangent function
53 * @code{BESJ0}:         BESJ0,     Bessel function of the first kind of order 0
54 * @code{BESJ1}:         BESJ1,     Bessel function of the first kind of order 1
55 * @code{BESJN}:         BESJN,     Bessel function of the first kind
56 * @code{BESY0}:         BESY0,     Bessel function of the second kind of order 0
57 * @code{BESY1}:         BESY1,     Bessel function of the second kind of order 1
58 * @code{BESYN}:         BESYN,     Bessel function of the second kind
59 * @code{BIT_SIZE}:      BIT_SIZE,  Bit size inquiry function
60 * @code{BTEST}:         BTEST,     Bit test function
61 * @code{CEILING}:       CEILING,   Integer ceiling function
62 * @code{CHAR}:          CHAR,      Integer-to-character conversion function
63 * @code{CMPLX}:         CMPLX,     Complex conversion function
64 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT,  Command line argument count
65 * @code{CONJG}:         CONJG,     Complex conjugate function
66 * @code{COS}:           COS,       Cosine function
67 * @code{COSH}:          COSH,      Hyperbolic cosine function
68 * @code{COUNT}:         COUNT,     Count occurrences of .TRUE. in an array
69 * @code{CPU_TIME}:      CPU_TIME,  CPU time subroutine
70 * @code{CSHIFT}:        CSHIFT,    Circular array shift function
71 * @code{CTIME}:         CTIME,     Subroutine (or function) to convert a time into a string
72 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
73 * @code{DBLE}:          DBLE,      Double precision conversion function
74 * @code{DCMPLX}:        DCMPLX,    Double complex conversion function
75 * @code{DFLOAT}:        DFLOAT,    Double precision conversion function
76 * @code{DIGITS}:        DIGITS,    Significant digits function
77 * @code{DIM}:           DIM,       Dim function
78 * @code{DOT_PRODUCT}:   DOT_PRODUCT, Dot product function
79 * @code{DPROD}:         DPROD,     Double product function
80 * @code{DREAL}:         DREAL,     Double real part function
81 * @code{DTIME}:         DTIME,     Execution time subroutine (or function)
82 * @code{EOSHIFT}:       EOSHIFT,   End-off shift function
83 * @code{EPSILON}:       EPSILON,   Epsilon function
84 * @code{ERF}:           ERF,       Error function
85 * @code{ERFC}:          ERFC,      Complementary error function
86 * @code{ETIME}:         ETIME,     Execution time subroutine (or function)
87 * @code{EXIT}:          EXIT,      Exit the program with status.
88 * @code{EXP}:           EXP,       Exponential function
89 * @code{EXPONENT}:      EXPONENT,  Exponent function
90 * @code{FDATE}:         FDATE,     Subroutine (or function) to get the current time as a string
91 * @code{FLOAT}:         FLOAT,     Convert integer to default real
92 * @code{FLOOR}:         FLOOR,     Integer floor function
93 * @code{FLUSH}:         FLUSH,     Flush I/O unit(s)
94 * @code{FNUM}:          FNUM,      File number function
95 * @code{FRACTION}:      FRACTION,  Fractional part of the model representation
96 * @code{FREE}:          FREE,      Memory de-allocation subroutine
97 * @code{GETGID}:        GETGID,    Group ID function
98 * @code{GETPID}:        GETPID,    Process ID function
99 * @code{GETUID}:        GETUID,    User ID function
100 * @code{HUGE}:          HUGE,      Largest number of a kind
101 * @code{IACHAR}:        IACHAR,    Code in @acronym{ASCII} collating sequence
102 * @code{ICHAR}:         ICHAR,     Character-to-integer conversion function
103 * @code{IRAND}:         IRAND,     Integer pseudo-random number
104 * @code{KIND}:          KIND,      Kind of an entity
105 * @code{LOC}:           LOC,       Returns the address of a variable
106 * @code{LOG}:           LOG,       Logarithm function
107 * @code{LOG10}:         LOG10,     Base 10 logarithm function 
108 * @code{MALLOC}:        MALLOC,    Dynamic memory allocation function
109 * @code{MAXEXPONENT}:   MAXEXPONENT, Maximum exponent of a real kind
110 * @code{MINEXPONENT}:   MINEXPONENT, Minimum exponent of a real kind
111 * @code{MOD}:           MOD,       Remainder function
112 * @code{MODULO}:        MODULO,    Modulo function
113 * @code{NEAREST}:       NEAREST,   Nearest representable number
114 * @code{NINT}:          NINT,      Nearest whole number
115 * @code{PRECISION}:     PRECISION, Decimal precision of a real kind
116 * @code{RADIX}:         RADIX,     Base of a data model
117 * @code{RAND}:          RAND,      Real pseudo-random number
118 * @code{RANGE}:         RANGE,     Decimal exponent range of a real kind
119 * @code{REAL}:          REAL,      Convert to real type 
120 * @code{RRSPACING}:     RRSPACING, Reciprocal of the relative spacing
121 * @code{SCALE}:         SCALE,     Scale a real value
122 * @code{SECNDS}:        SECNDS,    Time function
123 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND,  Choose integer kind
124 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND,  Choose real kind
125 * @code{SET_EXPONENT}:  SET_EXPONENT, Set the exponent of the model
126 * @code{SIGN}:          SIGN,      Sign copying function
127 * @code{SIGNAL}:        SIGNAL,    Signal handling subroutine (or function)
128 * @code{SIN}:           SIN,       Sine function
129 * @code{SINH}:          SINH,      Hyperbolic sine function
130 * @code{SNGL}:          SNGL,      Convert double precision real to default real
131 * @code{SQRT}:          SQRT,      Square-root function
132 * @code{SRAND}:         SRAND,     Reinitialize the random number generator
133 * @code{TAN}:           TAN,       Tangent function
134 * @code{TANH}:          TANH,      Hyperbolic tangent function
135 * @code{TINY}:          TINY,      Smallest positive number of a real kind
136 @end menu
138 @node Introduction
139 @section Introduction to intrinsic procedures
141 Gfortran provides a rich set of intrinsic procedures that includes all
142 the intrinsic procedures required by the Fortran 95 standard, a set of
143 intrinsic procedures for backwards compatibility with Gnu Fortran 77
144 (i.e., @command{g77}), and a small selection of intrinsic procedures
145 from the Fortran 2003 standard.  Any description here, which conflicts with a 
146 description in either the Fortran 95 standard or the Fortran 2003 standard,
147 is unintentional and the standard(s) should be considered authoritative.
149 The enumeration of the @code{KIND} type parameter is processor defined in
150 the Fortran 95 standard.  Gfortran defines the default integer type and
151 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
152 respectively.  The standard mandates that both data types shall have
153 another kind, which have more precision.  On typical target architectures
154 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
155 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
156 In the description of generic intrinsic procedures, the kind type parameter
157 will be specified by @code{KIND=*}, and in the description of specific
158 names for an intrinsic procedure the kind type parameter will be explicitly
159 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}).  Finally, for
160 brevity the optional @code{KIND=} syntax will be omitted.
162 Many of the intrinsics procedures take one or more optional arguments.
163 This document follows the convention used in the Fortran 95 standard,
164 and denotes such arguments by square brackets.
166 @command{Gfortran} offers the @option{-std=f95} and @option{-std=gnu} options,
167 which can be used to restrict the set of intrinsic procedures to a 
168 given standard.  By default, @command{gfortran} sets the @option{-std=gnu}
169 option, and so all intrinsic procedures described here are accepted.  There
170 is one caveat.  For a select group of intrinsic procedures, @command{g77}
171 implemented both a function and a subroutine.  Both classes 
172 have been implemented in @command{gfortran} for backwards compatibility
173 with @command{g77}.  It is noted here that these functions and subroutines
174 cannot be intermixed in a given subprogram.  In the descriptions that follow,
175 the applicable option(s) is noted.
179 @node ABORT
180 @section @code{ABORT} --- Abort the program  
181 @findex @code{ABORT}
182 @cindex abort
184 @table @asis
185 @item @emph{Description}:
186 @code{ABORT} causes immediate termination of the program.  On operating
187 systems that support a core dump, @code{ABORT} will produce a core dump,
188 which is suitable for debugging purposes.
190 @item @emph{Option}:
193 @item @emph{Class}:
194 non-elemental subroutine
196 @item @emph{Syntax}:
197 @code{CALL ABORT}
199 @item @emph{Return value}:
200 Does not return.
202 @item @emph{Example}:
203 @smallexample
204 program test_abort
205   integer :: i = 1, j = 2
206   if (i /= j) call abort
207 end program test_abort
208 @end smallexample
209 @end table
213 @node ABS
214 @section @code{ABS} --- Absolute value  
215 @findex @code{ABS} intrinsic
216 @findex @code{CABS} intrinsic
217 @findex @code{DABS} intrinsic
218 @findex @code{IABS} intrinsic
219 @findex @code{ZABS} intrinsic
220 @findex @code{CDABS} intrinsic
221 @cindex absolute value
223 @table @asis
224 @item @emph{Description}:
225 @code{ABS(X)} computes the absolute value of @code{X}.
227 @item @emph{Option}:
228 f95, gnu
230 @item @emph{Class}:
231 elemental function
233 @item @emph{Syntax}:
234 @code{X = ABS(X)}
236 @item @emph{Arguments}:
237 @multitable @columnfractions .15 .80
238 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
239 @code{REAL(*)}, or @code{COMPLEX(*)}.
240 @end multitable
242 @item @emph{Return value}:
243 The return value is of the same type and
244 kind as the argument except the return value is @code{REAL(*)} for a
245 @code{COMPLEX(*)} argument.
247 @item @emph{Example}:
248 @smallexample
249 program test_abs
250   integer :: i = -1
251   real :: x = -1.e0
252   complex :: z = (-1.e0,0.e0)
253   i = abs(i)
254   x = abs(x)
255   x = abs(z)
256 end program test_abs
257 @end smallexample
259 @item @emph{Specific names}:
260 @multitable @columnfractions .24 .24 .24 .24
261 @item Name            @tab Argument            @tab Return type       @tab Option
262 @item @code{CABS(Z)}  @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)}    @tab f95, gnu
263 @item @code{DABS(X)}  @tab @code{REAL(8)    X} @tab @code{REAL(8)}    @tab f95, gnu
264 @item @code{IABS(I)}  @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab f95, gnu
265 @item @code{ZABS(Z)}  @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
266 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
267 @end multitable
268 @end table
272 @node ACHAR
273 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence 
274 @findex @code{ACHAR} intrinsic
275 @cindex @acronym{ASCII} collating sequence
277 @table @asis
278 @item @emph{Description}:
279 @code{ACHAR(I)} returns the character located at position @code{I}
280 in the @acronym{ASCII} collating sequence.
282 @item @emph{Option}:
283 f95, gnu
285 @item @emph{Class}:
286 elemental function
288 @item @emph{Syntax}:
289 @code{C = ACHAR(I)}
291 @item @emph{Arguments}:
292 @multitable @columnfractions .15 .80
293 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
294 @end multitable
296 @item @emph{Return value}:
297 The return value is of type @code{CHARACTER} with a length of one.  The
298 kind type parameter is the same as  @code{KIND('A')}.
300 @item @emph{Example}:
301 @smallexample
302 program test_achar
303   character c
304   c = achar(32)
305 end program test_achar
306 @end smallexample
307 @end table
311 @node ACOS
312 @section @code{ACOS} --- Arc cosine function 
313 @findex @code{ACOS} intrinsic
314 @findex @code{DACOS} intrinsic
315 @cindex arc cosine
317 @table @asis
318 @item @emph{Description}:
319 @code{ACOS(X)} computes the arc cosine of @var{X}.
321 @item @emph{Option}:
322 f95, gnu
324 @item @emph{Class}:
325 elemental function
327 @item @emph{Syntax}:
328 @code{X = ACOS(X)}
330 @item @emph{Arguments}:
331 @multitable @columnfractions .15 .80
332 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
333 less than one.
334 @end multitable
336 @item @emph{Return value}:
337 The return value is of type @code{REAL(*)} and it lies in the
338 range @math{ 0 \leq \arccos (x) \leq \pi}.  The kind type
339 parameter is the same as @var{X}.
341 @item @emph{Example}:
342 @smallexample
343 program test_acos
344   real(8) :: x = 0.866_8
345   x = achar(x)
346 end program test_acos
347 @end smallexample
349 @item @emph{Specific names}:
350 @multitable @columnfractions .24 .24 .24 .24
351 @item Name            @tab Argument          @tab Return type       @tab Option
352 @item @code{DACOS(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
353 @end multitable
354 @end table
358 @node ADJUSTL
359 @section @code{ADJUSTL} --- Left adjust a string 
360 @findex @code{ADJUSTL} intrinsic
361 @cindex adjust string
363 @table @asis
364 @item @emph{Description}:
365 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
366 Spaces are inserted at the end of the string as needed.
368 @item @emph{Option}:
369 f95, gnu
371 @item @emph{Class}:
372 elemental function
374 @item @emph{Syntax}:
375 @code{STR = ADJUSTL(STR)}
377 @item @emph{Arguments}:
378 @multitable @columnfractions .15 .80
379 @item @var{STR} @tab The type shall be @code{CHARACTER}.
380 @end multitable
382 @item @emph{Return value}:
383 The return value is of type @code{CHARACTER} where leading spaces 
384 are removed and the same number of spaces are inserted on the end
385 of @var{STR}.
387 @item @emph{Example}:
388 @smallexample
389 program test_adjustl
390   character(len=20) :: str = '   gfortran'
391   str = adjustl(str)
392   print *, str
393 end program test_adjustl
394 @end smallexample
395 @end table
399 @node ADJUSTR
400 @section @code{ADJUSTR} --- Right adjust a string 
401 @findex @code{ADJUSTR} intrinsic
402 @cindex adjust string
404 @table @asis
405 @item @emph{Description}:
406 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
407 Spaces are inserted at the start of the string as needed.
409 @item @emph{Option}:
410 f95, gnu
412 @item @emph{Class}:
413 elemental function
415 @item @emph{Syntax}:
416 @code{STR = ADJUSTR(STR)}
418 @item @emph{Arguments}:
419 @multitable @columnfractions .15 .80
420 @item @var{STR} @tab The type shall be @code{CHARACTER}.
421 @end multitable
423 @item @emph{Return value}:
424 The return value is of type @code{CHARACTER} where trailing spaces 
425 are removed and the same number of spaces are inserted at the start
426 of @var{STR}.
428 @item @emph{Example}:
429 @smallexample
430 program test_adjustr
431   character(len=20) :: str = 'gfortran'
432   str = adjustr(str)
433   print *, str
434 end program test_adjustr
435 @end smallexample
436 @end table
440 @node AIMAG
441 @section @code{AIMAG} --- Imaginary part of complex number  
442 @findex @code{AIMAG} intrinsic
443 @findex @code{DIMAG} intrinsic
444 @findex @code{IMAG} intrinsic
445 @findex @code{IMAGPART} intrinsic
446 @cindex Imaginary part
448 @table @asis
449 @item @emph{Description}:
450 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
451 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
452 for compatibility with @command{g77}, and their use in new code is 
453 strongly discouraged.
455 @item @emph{Option}:
456 f95, gnu
458 @item @emph{Class}:
459 elemental function
461 @item @emph{Syntax}:
462 @code{X = AIMAG(Z)}
464 @item @emph{Arguments}:
465 @multitable @columnfractions .15 .80
466 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
467 @end multitable
469 @item @emph{Return value}:
470 The return value is of type real with the
471 kind type parameter of the argument.
473 @item @emph{Example}:
474 @smallexample
475 program test_aimag
476   complex(4) z4
477   complex(8) z8
478   z4 = cmplx(1.e0_4, 0.e0_4)
479   z8 = cmplx(0.e0_8, 1.e0_8)
480   print *, aimag(z4), dimag(z8)
481 end program test_aimag
482 @end smallexample
484 @item @emph{Specific names}:
485 @multitable @columnfractions .24 .24 .24 .24
486 @item Name            @tab Argument            @tab Return type       @tab Option
487 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)}    @tab f95, gnu
488 @item @code{IMAG(Z)}  @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)}    @tab gnu
489 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab gnu
490 @end multitable
491 @end table
495 @node AINT
496 @section @code{AINT} --- Imaginary part of complex number  
497 @findex @code{AINT} intrinsic
498 @findex @code{DINT} intrinsic
499 @cindex whole number
501 @table @asis
502 @item @emph{Description}:
503 @code{AINT(X [, KIND])} truncates its argument to a whole number.
505 @item @emph{Option}:
506 f95, gnu
508 @item @emph{Class}:
509 elemental function
511 @item @emph{Syntax}:
512 @code{X = AINT(X)} 
513 @code{X = AINT(X, KIND)}
515 @item @emph{Arguments}:
516 @multitable @columnfractions .15 .80
517 @item @var{X}    @tab The type of the argument shall be @code{REAL(*)}.
518 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
519 initialization expression.
520 @end multitable
522 @item @emph{Return value}:
523 The return value is of type real with the kind type parameter of the
524 argument if the optional @var{KIND} is absent; otherwise, the kind
525 type parameter will be given by @var{KIND}.  If the magnitude of 
526 @var{X} is less than one, then @code{AINT(X)} returns zero.  If the
527 magnitude is equal to or greater than one, then it returns the largest
528 whole number that does not exceed its magnitude.  The sign is the same
529 as the sign of @var{X}. 
531 @item @emph{Example}:
532 @smallexample
533 program test_aint
534   real(4) x4
535   real(8) x8
536   x4 = 1.234E0_4
537   x8 = 4.321_8
538   print *, aint(x4), dint(x8)
539   x8 = aint(x4,8)
540 end program test_aint
541 @end smallexample
543 @item @emph{Specific names}:
544 @multitable @columnfractions .24 .24 .24 .24
545 @item Name           @tab Argument         @tab Return type      @tab Option
546 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}   @tab f95, gnu
547 @end multitable
548 @end table
552 @node ALARM
553 @section @code{ALARM} --- Execute a routine after a given delay
554 @findex @code{ALARM} intrinsic
556 @table @asis
557 @item @emph{Description}:
558 @code{ALARM(SECONDS [, STATUS])} causes external subroutine @var{HANDLER}
559 to be executed after a delay of @var{SECONDS} by using @code{alarm(1)} to
560 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
561 supplied, it will be returned with the number of seconds remaining until
562 any previously scheduled alarm was due to be delivered, or zero if there
563 was no previously scheduled alarm.
565 @item @emph{Option}:
568 @item @emph{Class}:
569 subroutine
571 @item @emph{Syntax}:
572 @code{CALL ALARM(SECONDS, HANDLER)} 
573 @code{CALL ALARM(SECONDS, HANDLER, STATUS)}
575 @item @emph{Arguments}:
576 @multitable @columnfractions .15 .80
577 @item @var{SECONDS} @tab The type of the argument shall be a scalar
578 @code{INTEGER}. It is @code{INTENT(IN)}.
579 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
580 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
581 @code{INTEGER}. It is @code{INTENT(IN)}.
582 @item @var{STATUS}  @tab (Optional) @var{STATUS} shall be a scalar
583 @code{INTEGER} variable. It is @code{INTENT(OUT)}.
584 @end multitable
586 @item @emph{Example}:
587 @smallexample
588 program test_alarm
589   external handler_print
590   integer i
591   call alarm (3, handler_print, i)
592   print *, i
593   call sleep(10)
594 end program test_alarm
595 @end smallexample
596 This will cause the external routine @var{handler_print} to be called
597 after 3 seconds.
598 @end table
602 @node ALL
603 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true 
604 @findex @code{ALL} intrinsic
605 @cindex true values
607 @table @asis
608 @item @emph{Description}:
609 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
610 in the array along dimension @var{DIM}.
612 @item @emph{Option}:
613 f95, gnu
615 @item @emph{Class}:
616 transformational function
618 @item @emph{Syntax}:
619 @code{L = ALL(MASK)} 
620 @code{L = ALL(MASK, DIM)}
622 @item @emph{Arguments}:
623 @multitable @columnfractions .15 .80
624 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
625 it shall not be scalar.
626 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
627 with a value that lies between one and the rank of @var{MASK}.
628 @end multitable
630 @item @emph{Return value}:
631 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
632 the kind type parameter is the same as the kind type parameter of
633 @var{MASK}.  If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
634 an array with the rank of @var{MASK} minus 1.  The shape is determined from
635 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
637 @table @asis
638 @item (A)
639 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
640 It also is true if @var{MASK} has zero size; otherwise, it is false.
641 @item (B)
642 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
643 to @code{ALL(MASK)}.  If the rank is greater than one, then @code{ALL(MASK,DIM)}
644 is determined by applying @code{ALL} to the array sections.
645 @end table
647 @item @emph{Example}:
648 @smallexample
649 program test_all
650   logical l
651   l = all((/.true., .true., .true./))
652   print *, l
653   call section
654   contains
655     subroutine section
656       integer a(2,3), b(2,3)
657       a = 1
658       b = 1
659       b(2,2) = 2
660       print *, all(a .eq. b, 1)
661       print *, all(a .eq. b, 2)
662     end subroutine section
663 end program test_all
664 @end smallexample
665 @end table
669 @node ALLOCATED
670 @section @code{ALLOCATED} --- Status of an allocatable entity
671 @findex @code{ALLOCATED} intrinsic
672 @cindex allocation status
674 @table @asis
675 @item @emph{Description}:
676 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
678 @item @emph{Option}:
679 f95, gnu
681 @item @emph{Class}:
682 inquiry function
684 @item @emph{Syntax}:
685 @code{L = ALLOCATED(X)}
687 @item @emph{Arguments}:
688 @multitable @columnfractions .15 .80
689 @item @var{X}    @tab The argument shall be an @code{ALLOCATABLE} array.
690 @end multitable
692 @item @emph{Return value}:
693 The return value is a scalar @code{LOGICAL} with the default logical
694 kind type parameter.  If @var{X} is allocated, @code{ALLOCATED(X)}
695 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.} 
697 @item @emph{Example}:
698 @smallexample
699 program test_allocated
700   integer :: i = 4
701   real(4), allocatable :: x(:)
702   if (allocated(x) .eqv. .false.) allocate(x(i)
703 end program test_allocated
704 @end smallexample
705 @end table
709 @node ANINT
710 @section @code{ANINT} --- Nearest whole number
711 @findex @code{ANINT} intrinsic
712 @findex @code{DNINT} intrinsic
713 @cindex whole number
715 @table @asis
716 @item @emph{Description}:
717 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
719 @item @emph{Option}:
720 f95, gnu
722 @item @emph{Class}:
723 elemental function
725 @item @emph{Syntax}:
726 @code{X = ANINT(X)}
727 @code{X = ANINT(X, KIND)}
729 @item @emph{Arguments}:
730 @multitable @columnfractions .15 .80
731 @item @var{X}    @tab The type of the argument shall be @code{REAL(*)}.
732 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
733 initialization expression.
734 @end multitable
736 @item @emph{Return value}:
737 The return value is of type real with the kind type parameter of the
738 argument if the optional @var{KIND} is absent; otherwise, the kind
739 type parameter will be given by @var{KIND}.  If @var{X} is greater than
740 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}.  If @var{X} is
741 less than or equal to zero, then return @code{AINT(X-0.5)}.
743 @item @emph{Example}:
744 @smallexample
745 program test_anint
746   real(4) x4
747   real(8) x8
748   x4 = 1.234E0_4
749   x8 = 4.321_8
750   print *, anint(x4), dnint(x8)
751   x8 = anint(x4,8)
752 end program test_anint
753 @end smallexample
755 @item @emph{Specific names}:
756 @multitable @columnfractions .24 .24 .24 .24
757 @item Name            @tab Argument         @tab Return type      @tab Option
758 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}   @tab f95, gnu
759 @end multitable
760 @end table
764 @node ANY
765 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true 
766 @findex @code{ANY} intrinsic
767 @cindex true values
769 @table @asis
770 @item @emph{Description}:
771 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
772 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
774 @item @emph{Option}:
775 f95, gnu
777 @item @emph{Class}:
778 transformational function
780 @item @emph{Syntax}:
781 @code{L = ANY(MASK)} 
782 @code{L = ANY(MASK, DIM)}
784 @item @emph{Arguments}:
785 @multitable @columnfractions .15 .80
786 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
787 it shall not be scalar.
788 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
789 with a value that lies between one and the rank of @var{MASK}.
790 @end multitable
792 @item @emph{Return value}:
793 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
794 the kind type parameter is the same as the kind type parameter of
795 @var{MASK}.  If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
796 an array with the rank of @var{MASK} minus 1.  The shape is determined from
797 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
799 @table @asis
800 @item (A)
801 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
802 otherwise, it is false.  It also is false if @var{MASK} has zero size.
803 @item (B)
804 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
805 to @code{ANY(MASK)}.  If the rank is greater than one, then @code{ANY(MASK,DIM)}
806 is determined by applying @code{ANY} to the array sections.
807 @end table
809 @item @emph{Example}:
810 @smallexample
811 program test_any
812   logical l
813   l = any((/.true., .true., .true./))
814   print *, l
815   call section
816   contains
817     subroutine section
818       integer a(2,3), b(2,3)
819       a = 1
820       b = 1
821       b(2,2) = 2
822       print *, any(a .eq. b, 1)
823       print *, any(a .eq. b, 2)
824     end subroutine section
825 end program test_any
826 @end smallexample
827 @end table
831 @node ASIN
832 @section @code{ASIN} --- Arcsine function 
833 @findex @code{ASIN} intrinsic
834 @findex @code{DASIN} intrinsic
835 @cindex arcsine
837 @table @asis
838 @item @emph{Description}:
839 @code{ASIN(X)} computes the arcsine of its @var{X}.
841 @item @emph{Option}:
842 f95, gnu
844 @item @emph{Class}:
845 elemental function
847 @item @emph{Syntax}:
848 @code{X = ASIN(X)}
850 @item @emph{Arguments}:
851 @multitable @columnfractions .15 .80
852 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
853 less than one.
854 @end multitable
856 @item @emph{Return value}:
857 The return value is of type @code{REAL(*)} and it lies in the
858 range @math{-\pi / 2 \leq \arccos (x) \leq \pi / 2}.  The kind type
859 parameter is the same as @var{X}.
861 @item @emph{Example}:
862 @smallexample
863 program test_asin
864   real(8) :: x = 0.866_8
865   x = asin(x)
866 end program test_asin
867 @end smallexample
869 @item @emph{Specific names}:
870 @multitable @columnfractions .24 .24 .24 .24
871 @item Name            @tab Argument          @tab Return type       @tab Option
872 @item @code{DASIN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
873 @end multitable
874 @end table
878 @node ASSOCIATED
879 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair 
880 @findex @code{ASSOCIATED} intrinsic
881 @cindex pointer status
883 @table @asis
884 @item @emph{Description}:
885 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
886 or if @var{PTR} is associated with the target @var{TGT}.
888 @item @emph{Option}:
889 f95, gnu
891 @item @emph{Class}:
892 inquiry function
894 @item @emph{Syntax}:
895 @code{L = ASSOCIATED(PTR)} 
896 @code{L = ASSOCIATED(PTR [, TGT])}
898 @item @emph{Arguments}:
899 @multitable @columnfractions .15 .80
900 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
901 it can be of any type.
902 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
903 a @code{TARGET}.  It must have the same type, kind type parameter, and
904 array rank as @var{PTR}.
905 @end multitable
906 The status of neither @var{PTR} nor @var{TGT} can be undefined.
908 @item @emph{Return value}:
909 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
910 There are several cases:
911 @table @asis
912 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
913 is true if @var{PTR} is associated with a target; otherwise, it returns false.
914 @item (B) If @var{TGT} is present and a scalar target, the result is true if
915 @var{TGT}
916 is not a 0 sized storage sequence and the target associated with @var{PTR}
917 occupies the same storage units.  If @var{PTR} is disassociated, then the 
918 result is false.
919 @item (C) If @var{TGT} is present and an array target, the result is true if
920 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
921 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
922 @var{PTR} occupy the same storage units in array element order.
923 As in case(B), the result is false, if @var{PTR} is disassociated.
924 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
925 target associated with @var{PTR} and the target associated with @var{TGT}
926 are not 0 sized storage sequences and occupy the same storage units.
927 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
928 @item (E) If @var{TGT} is present and an array pointer, the result is true if
929 target associated with @var{PTR} and the target associated with @var{TGT}
930 have the same shape, are not 0 sized arrays, are arrays whose elements are
931 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
932 storage units in array element order.
933 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
934 @end table
936 @item @emph{Example}:
937 @smallexample
938 program test_associated
939    implicit none
940    real, target  :: tgt(2) = (/1., 2./)
941    real, pointer :: ptr(:)
942    ptr => tgt
943    if (associated(ptr)     .eqv. .false.) call abort
944    if (associated(ptr,tgt) .eqv. .false.) call abort
945 end program test_associated
946 @end smallexample
947 @end table
951 @node ATAN
952 @section @code{ATAN} --- Arctangent function 
953 @findex @code{ATAN} intrinsic
954 @findex @code{DATAN} intrinsic
955 @cindex arctangent
957 @table @asis
958 @item @emph{Description}:
959 @code{ATAN(X)} computes the arctangent of @var{X}.
961 @item @emph{Option}:
962 f95, gnu
964 @item @emph{Class}:
965 elemental function
967 @item @emph{Syntax}:
968 @code{X = ATAN(X)}
970 @item @emph{Arguments}:
971 @multitable @columnfractions .15 .80
972 @item @var{X} @tab The type shall be @code{REAL(*)}.
973 @end multitable
975 @item @emph{Return value}:
976 The return value is of type @code{REAL(*)} and it lies in the
977 range @math{ - \pi / 2 \leq \arcsin (x) \leq \pi / 2}.
979 @item @emph{Example}:
980 @smallexample
981 program test_atan
982   real(8) :: x = 2.866_8
983   x = atan(x)
984 end program test_atan
985 @end smallexample
987 @item @emph{Specific names}:
988 @multitable @columnfractions .24 .24 .24 .24
989 @item Name            @tab Argument          @tab Return type       @tab Option
990 @item @code{DATAN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
991 @end multitable
992 @end table
996 @node ATAN2
997 @section @code{ATAN2} --- Arctangent function 
998 @findex @code{ATAN2} intrinsic
999 @findex @code{DATAN2} intrinsic
1000 @cindex arctangent
1002 @table @asis
1003 @item @emph{Description}:
1004 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
1006 @item @emph{Option}:
1007 f95, gnu
1009 @item @emph{Class}:
1010 elemental function
1012 @item @emph{Syntax}:
1013 @code{X = ATAN2(Y,X)}
1015 @item @emph{Arguments}:
1016 @multitable @columnfractions .15 .80
1017 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1018 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1019 If @var{Y} is zero, then @var{X} must be nonzero.
1020 @end multitable
1022 @item @emph{Return value}:
1023 The return value has the same type and kind type parameter as @var{Y}.
1024 It is the principle value of the complex number @math{X + i Y}.  If
1025 @var{X} is nonzero, then it lies in the range @math{-\pi \le \arccos (x) \leq \pi}.
1026 The sign is positive if @var{Y} is positive.  If @var{Y} is zero, then
1027 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1028 is negative.  Finally, if @var{X} is zero, then the magnitude of the result
1029 is @math{\pi/2}.
1031 @item @emph{Example}:
1032 @smallexample
1033 program test_atan2
1034   real(4) :: x = 1.e0_4, y = 0.5e0_4
1035   x = atan2(y,x)
1036 end program test_atan2
1037 @end smallexample
1039 @item @emph{Specific names}:
1040 @multitable @columnfractions .24 .24 .24 .24
1041 @item Name            @tab Argument          @tab Return type    @tab Option
1042 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
1043 @end multitable
1044 @end table
1048 @node BESJ0
1049 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1050 @findex @code{BESJ0} intrinsic
1051 @findex @code{DBESJ0} intrinsic
1052 @cindex Bessel
1054 @table @asis
1055 @item @emph{Description}:
1056 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1057 of @var{X}.
1059 @item @emph{Option}:
1062 @item @emph{Class}:
1063 elemental function
1065 @item @emph{Syntax}:
1066 @code{X = BESJ0(X)}
1068 @item @emph{Arguments}:
1069 @multitable @columnfractions .15 .80
1070 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1071 @end multitable
1073 @item @emph{Return value}:
1074 The return value is of type @code{REAL(*)} and it lies in the
1075 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1077 @item @emph{Example}:
1078 @smallexample
1079 program test_besj0
1080   real(8) :: x = 0.0_8
1081   x = besj0(x)
1082 end program test_besj0
1083 @end smallexample
1085 @item @emph{Specific names}:
1086 @multitable @columnfractions .24 .24 .24 .24
1087 @item Name            @tab Argument          @tab Return type       @tab Option
1088 @item @code{DBESJ0(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab gnu
1089 @end multitable
1090 @end table
1094 @node BESJ1
1095 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1096 @findex @code{BESJ1} intrinsic
1097 @findex @code{DBESJ1} intrinsic
1098 @cindex Bessel
1100 @table @asis
1101 @item @emph{Description}:
1102 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1103 of @var{X}.
1105 @item @emph{Option}:
1108 @item @emph{Class}:
1109 elemental function
1111 @item @emph{Syntax}:
1112 @code{X = BESJ1(X)}
1114 @item @emph{Arguments}:
1115 @multitable @columnfractions .15 .80
1116 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1117 @end multitable
1119 @item @emph{Return value}:
1120 The return value is of type @code{REAL(*)} and it lies in the
1121 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1123 @item @emph{Example}:
1124 @smallexample
1125 program test_besj1
1126   real(8) :: x = 1.0_8
1127   x = besj1(x)
1128 end program test_besj1
1129 @end smallexample
1131 @item @emph{Specific names}:
1132 @multitable @columnfractions .24 .24 .24 .24
1133 @item Name            @tab Argument          @tab Return type       @tab Option
1134 @item @code{DBESJ1(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab gnu
1135 @end multitable
1136 @end table
1140 @node BESJN
1141 @section @code{BESJN} --- Bessel function of the first kind
1142 @findex @code{BESJN} intrinsic
1143 @findex @code{DBESJN} intrinsic
1144 @cindex Bessel
1146 @table @asis
1147 @item @emph{Description}:
1148 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1149 @var{N} of @var{X}.
1151 @item @emph{Option}:
1154 @item @emph{Class}:
1155 elemental function
1157 @item @emph{Syntax}:
1158 @code{Y = BESJN(N, X)}
1160 @item @emph{Arguments}:
1161 @multitable @columnfractions .15 .80
1162 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1163 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1164 @end multitable
1166 @item @emph{Return value}:
1167 The return value is a scalar of type @code{REAL(*)}.
1169 @item @emph{Example}:
1170 @smallexample
1171 program test_besjn
1172   real(8) :: x = 1.0_8
1173   x = besjn(5,x)
1174 end program test_besjn
1175 @end smallexample
1177 @item @emph{Specific names}:
1178 @multitable @columnfractions .24 .24 .24 .24
1179 @item Name             @tab Argument            @tab Return type       @tab Option
1180 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)}    @tab gnu
1181 @item                  @tab @code{REAL(8) X}    @tab                   @tab
1182 @end multitable
1183 @end table
1187 @node BESY0
1188 @section @code{BESY0} --- Bessel function of the second kind of order 0
1189 @findex @code{BESY0} intrinsic
1190 @findex @code{DBESY0} intrinsic
1191 @cindex Bessel
1193 @table @asis
1194 @item @emph{Description}:
1195 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1196 of @var{X}.
1198 @item @emph{Option}:
1201 @item @emph{Class}:
1202 elemental function
1204 @item @emph{Syntax}:
1205 @code{X = BESY0(X)}
1207 @item @emph{Arguments}:
1208 @multitable @columnfractions .15 .80
1209 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1210 @end multitable
1212 @item @emph{Return value}:
1213 The return value is a scalar of type @code{REAL(*)}.
1215 @item @emph{Example}:
1216 @smallexample
1217 program test_besy0
1218   real(8) :: x = 0.0_8
1219   x = besy0(x)
1220 end program test_besy0
1221 @end smallexample
1223 @item @emph{Specific names}:
1224 @multitable @columnfractions .24 .24 .24 .24
1225 @item Name            @tab Argument          @tab Return type       @tab Option
1226 @item @code{DBESY0(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab gnu
1227 @end multitable
1228 @end table
1232 @node BESY1
1233 @section @code{BESY1} --- Bessel function of the second kind of order 1
1234 @findex @code{BESY1} intrinsic
1235 @findex @code{DBESY1} intrinsic
1236 @cindex Bessel
1238 @table @asis
1239 @item @emph{Description}:
1240 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1241 of @var{X}.
1243 @item @emph{Option}:
1246 @item @emph{Class}:
1247 elemental function
1249 @item @emph{Syntax}:
1250 @code{X = BESY1(X)}
1252 @item @emph{Arguments}:
1253 @multitable @columnfractions .15 .80
1254 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1255 @end multitable
1257 @item @emph{Return value}:
1258 The return value is a scalar of type @code{REAL(*)}.
1260 @item @emph{Example}:
1261 @smallexample
1262 program test_besy1
1263   real(8) :: x = 1.0_8
1264   x = besy1(x)
1265 end program test_besy1
1266 @end smallexample
1268 @item @emph{Specific names}:
1269 @multitable @columnfractions .24 .24 .24 .24
1270 @item Name            @tab Argument          @tab Return type       @tab Option
1271 @item @code{DBESY1(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab gnu
1272 @end multitable
1273 @end table
1277 @node BESYN
1278 @section @code{BESYN} --- Bessel function of the second kind
1279 @findex @code{BESYN} intrinsic
1280 @findex @code{DBESYN} intrinsic
1281 @cindex Bessel
1283 @table @asis
1284 @item @emph{Description}:
1285 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1286 @var{N} of @var{X}.
1288 @item @emph{Option}:
1291 @item @emph{Class}:
1292 elemental function
1294 @item @emph{Syntax}:
1295 @code{Y = BESYN(N, X)}
1297 @item @emph{Arguments}:
1298 @multitable @columnfractions .15 .80
1299 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1300 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1301 @end multitable
1303 @item @emph{Return value}:
1304 The return value is a scalar of type @code{REAL(*)}.
1306 @item @emph{Example}:
1307 @smallexample
1308 program test_besyn
1309   real(8) :: x = 1.0_8
1310   x = besyn(5,x)
1311 end program test_besyn
1312 @end smallexample
1314 @item @emph{Specific names}:
1315 @multitable @columnfractions .24 .24 .24 .24
1316 @item Name               @tab Argument            @tab Return type     @tab Option
1317 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)}  @tab gnu
1318 @item                    @tab @code{REAL(8)    X} @tab                 @tab 
1319 @end multitable
1320 @end table
1324 @node BIT_SIZE
1325 @section @code{BIT_SIZE} --- Bit size inquiry function
1326 @findex @code{BIT_SIZE} intrinsic
1327 @cindex bit_size
1329 @table @asis
1330 @item @emph{Description}:
1331 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1332 represented by the type of @var{I}.
1334 @item @emph{Option}:
1335 f95, gnu
1337 @item @emph{Class}:
1338 elemental function
1340 @item @emph{Syntax}:
1341 @code{I = BIT_SIZE(I)}
1343 @item @emph{Arguments}:
1344 @multitable @columnfractions .15 .80
1345 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1346 @end multitable
1348 @item @emph{Return value}:
1349 The return value is of type @code{INTEGER(*)}
1351 @item @emph{Example}:
1352 @smallexample
1353 program test_bit_size
1354     integer :: i = 123
1355     integer :: size
1356     size = bit_size(i)
1357     print *, size
1358 end program test_bit_size
1359 @end smallexample
1360 @end table
1364 @node BTEST
1365 @section @code{BTEST} --- Bit test function
1366 @findex @code{BTEST} intrinsic
1367 @cindex BTEST
1369 @table @asis
1370 @item @emph{Description}:
1371 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1372 in @var{I} is set.
1374 @item @emph{Option}:
1375 f95, gnu
1377 @item @emph{Class}:
1378 elemental function
1380 @item @emph{Syntax}:
1381 @code{I = BTEST(I,POS)}
1383 @item @emph{Arguments}:
1384 @multitable @columnfractions .15 .80
1385 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1386 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1387 @end multitable
1389 @item @emph{Return value}:
1390 The return value is of type @code{LOGICAL}
1392 @item @emph{Example}:
1393 @smallexample
1394 program test_btest
1395     integer :: i = 32768 + 1024 + 64
1396     integer :: pos
1397     logical :: bool
1398     do pos=0,16
1399         bool = btest(i, pos) 
1400         print *, pos, bool
1401     end do
1402 end program test_btest
1403 @end smallexample
1404 @end table
1408 @node CEILING
1409 @section @code{CEILING} --- Integer ceiling function
1410 @findex @code{CEILING} intrinsic
1411 @cindex CEILING
1413 @table @asis
1414 @item @emph{Description}:
1415 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1417 @item @emph{Option}:
1418 f95, gnu
1420 @item @emph{Class}:
1421 elemental function
1423 @item @emph{Syntax}:
1424 @code{I = CEILING(X[,KIND])}
1426 @item @emph{Arguments}:
1427 @multitable @columnfractions .15 .80
1428 @item @var{X} @tab The type shall be @code{REAL(*)}.
1429 @item @var{KIND} @tab Optional scaler integer initialization expression.
1430 @end multitable
1432 @item @emph{Return value}:
1433 The return value is of type @code{INTEGER(KIND)}
1435 @item @emph{Example}:
1436 @smallexample
1437 program test_ceiling
1438     real :: x = 63.29
1439     real :: y = -63.59
1440     print *, ceiling(x) ! returns 64
1441     print *, ceiling(y) ! returns -63
1442 end program test_ceiling
1443 @end smallexample
1444 @end table
1448 @node CHAR
1449 @section @code{CHAR} --- Character conversion function
1450 @findex @code{CHAR} intrinsic
1451 @cindex CHAR
1453 @table @asis
1454 @item @emph{Description}:
1455 @code{CHAR(I,[KIND])} returns the character represented by the integer @var{I}.
1457 @item @emph{Option}:
1458 f95, gnu
1460 @item @emph{Class}:
1461 elemental function
1463 @item @emph{Syntax}:
1464 @code{C = CHAR(I[,KIND])}
1466 @item @emph{Arguments}:
1467 @multitable @columnfractions .15 .80
1468 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1469 @item @var{KIND} @tab Optional scaler integer initialization expression.
1470 @end multitable
1472 @item @emph{Return value}:
1473 The return value is of type @code{CHARACTER(1)}
1475 @item @emph{Example}:
1476 @smallexample
1477 program test_char
1478     integer :: i = 74
1479     character(1) :: c
1480     c = char(i)
1481     print *, i, c ! returns 'J'
1482 end program test_char
1483 @end smallexample
1484 @end table
1488 @node CMPLX
1489 @section @code{CMPLX} --- Complex conversion function
1490 @findex @code{CMPLX} intrinsic
1491 @cindex CMPLX
1493 @table @asis
1494 @item @emph{Description}:
1495 @code{CMPLX(X,[Y,KIND])} returns a complex number where @var{X} is converted to
1496 the real component.  If @var{Y} is present it is converted to the imaginary
1497 component.  If @var{Y} is not present then the imaginary component is set to
1498 0.0.  If @var{X} is complex then @var{Y} must not be present.
1500 @item @emph{Option}:
1501 f95, gnu
1503 @item @emph{Class}:
1504 elemental function
1506 @item @emph{Syntax}:
1507 @code{C = CMPLX(X[,Y,KIND])}
1509 @item @emph{Arguments}:
1510 @multitable @columnfractions .15 .80
1511 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
1512 @item @var{Y} @tab Optional, allowed if @var{X} is not @code{COMPLEX(*)}.  May be @code{INTEGER(*)} or @code{REAL(*)}. 
1513 @item @var{KIND} @tab Optional scaler integer initialization expression.
1514 @end multitable
1516 @item @emph{Return value}:
1517 The return value is of type @code{COMPLEX(*)}
1519 @item @emph{Example}:
1520 @smallexample
1521 program test_cmplx
1522     integer :: i = 42
1523     real :: x = 3.14
1524     complex :: z
1525     z = cmplx(i, x)
1526     print *, z, cmplx(x)
1527 end program test_cmplx
1528 @end smallexample
1529 @end table
1533 @node COMMAND_ARGUMENT_COUNT
1534 @section @code{COMMAND_ARGUMENT_COUNT} --- Argument count function 
1535 @findex @code{COMMAND_ARGUMENT_COUNT} intrinsic
1536 @cindex command argument count
1538 @table @asis
1539 @item @emph{Description}:
1540 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
1541 command line when the containing program was invoked.
1543 @item @emph{Option}:
1544 f2003, gnu
1546 @item @emph{Class}:
1547 non-elemental function
1549 @item @emph{Syntax}:
1550 @code{I = COMMAND_ARGUMENT_COUNT()}
1552 @item @emph{Arguments}:
1553 @multitable @columnfractions .15 .80
1554 @item None
1555 @end multitable
1557 @item @emph{Return value}:
1558 The return value is of type @code{INTEGER(4)}
1560 @item @emph{Example}:
1561 @smallexample
1562 program test_command_argument_count
1563     integer :: count
1564     count = command_argument_count()
1565     print *, count
1566 end program test_command_argument_count
1567 @end smallexample
1568 @end table
1572 @node CONJG
1573 @section @code{CONJG} --- Complex conjugate function 
1574 @findex @code{CONJG} intrinsic
1575 @findex @code{DCONJG} intrinsic
1576 @cindex complex conjugate
1577 @table @asis
1578 @item @emph{Description}:
1579 @code{CONJG(Z)} returns the conjugate of @var{Z}.  If @var{Z} is @code{(x, y)}
1580 then the result is @code{(x, -y)}
1582 @item @emph{Option}:
1583 f95, gnu
1585 @item @emph{Class}:
1586 elemental function
1588 @item @emph{Syntax}:
1589 @code{Z = CONJG(Z)}
1591 @item @emph{Arguments}:
1592 @multitable @columnfractions .15 .80
1593 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
1594 @end multitable
1596 @item @emph{Return value}:
1597 The return value is of type @code{COMPLEX(*)}.
1599 @item @emph{Example}:
1600 @smallexample
1601 program test_conjg
1602     complex :: z = (2.0, 3.0)
1603     complex(8) :: dz = (2.71_8, -3.14_8)
1604     z= conjg(z)
1605     print *, z
1606     dz = dconjg(dz)
1607     print *, dz
1608 end program test_conjg
1609 @end smallexample
1611 @item @emph{Specific names}:
1612 @multitable @columnfractions .24 .24 .24 .24
1613 @item Name             @tab Argument             @tab Return type          @tab Option
1614 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z}  @tab @code{COMPLEX(8)}    @tab gnu
1615 @end multitable
1616 @end table
1620 @node COS
1621 @section @code{COS} --- Cosine function 
1622 @findex @code{COS} intrinsic
1623 @findex @code{DCOS} intrinsic
1624 @findex @code{ZCOS} intrinsic
1625 @findex @code{CDCOS} intrinsic
1626 @cindex cosine
1628 @table @asis
1629 @item @emph{Description}:
1630 @code{COS(X)} computes the cosine of @var{X}.
1632 @item @emph{Option}:
1633 f95, gnu
1635 @item @emph{Class}:
1636 elemental function
1638 @item @emph{Syntax}:
1639 @code{X = COS(X)}
1641 @item @emph{Arguments}:
1642 @multitable @columnfractions .15 .80
1643 @item @var{X} @tab The type shall be @code{REAL(*)} or
1644 @code{COMPLEX(*)}.
1645 @end multitable
1647 @item @emph{Return value}:
1648 The return value has the same type and kind as @var{X}.
1650 @item @emph{Example}:
1651 @smallexample
1652 program test_cos
1653   real :: x = 0.0
1654   x = cos(x)
1655 end program test_cos
1656 @end smallexample
1658 @item @emph{Specific names}:
1659 @multitable @columnfractions .24 .24 .24 .24
1660 @item Name            @tab Argument          @tab Return type     @tab Option
1661 @item @code{DCOS(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}  @tab f95, gnu
1662 @item @code{CCOS(X)}@tab @code{COMPLEX(4) X}@tab @code{COMPLEX(4)}@tab f95, gnu
1663 @item @code{ZCOS(X)}@tab @code{COMPLEX(8) X}@tab @code{COMPLEX(8)}@tab f95, gnu
1664 @item @code{CDCOS(X)}@tab @code{COMPLEX(8) X}@tab @code{COMPLEX(8)}@tab f95, gnu
1665 @end multitable
1666 @end table
1670 @node COSH
1671 @section @code{COSH} --- Hyperbolic cosine function 
1672 @findex @code{COSH} intrinsic
1673 @findex @code{DCOSH} intrinsic
1674 @cindex hyperbolic cosine
1676 @table @asis
1677 @item @emph{Description}:
1678 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
1680 @item @emph{Option}:
1681 f95, gnu
1683 @item @emph{Class}:
1684 elemental function
1686 @item @emph{Syntax}:
1687 @code{X = COSH(X)}
1689 @item @emph{Arguments}:
1690 @multitable @columnfractions .15 .80
1691 @item @var{X} @tab The type shall be @code{REAL(*)}.
1692 @end multitable
1694 @item @emph{Return value}:
1695 The return value is of type @code{REAL(*)} and it is positive
1696 (@math{ \cosh (x) \geq 0 }.
1698 @item @emph{Example}:
1699 @smallexample
1700 program test_cosh
1701   real(8) :: x = 1.0_8
1702   x = cosh(x)
1703 end program test_cosh
1704 @end smallexample
1706 @item @emph{Specific names}:
1707 @multitable @columnfractions .24 .24 .24 .24
1708 @item Name            @tab Argument          @tab Return type       @tab Option
1709 @item @code{DCOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
1710 @end multitable
1711 @end table
1715 @node COUNT
1716 @section @code{COUNT} --- Count function
1717 @findex @code{COUNT} intrinsic
1718 @cindex count
1720 @table @asis
1721 @item @emph{Description}:
1722 @code{COUNT(MASK[,DIM])} counts the number of @code{.TRUE.} elements of
1723 @var{MASK} along the dimension of @var{DIM}.  If @var{DIM} is omitted it is
1724 taken to be @code{1}.  @var{DIM} is a scaler of type @code{INTEGER} in the
1725 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
1727 @item @emph{Option}:
1728 f95, gnu
1730 @item @emph{Class}:
1731 transformational function
1733 @item @emph{Syntax}:
1734 @code{I = COUNT(MASK[,DIM])}
1736 @item @emph{Arguments}:
1737 @multitable @columnfractions .15 .80
1738 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
1739 @item @var{DIM}  @tab The type shall be @code{INTEGER}.
1740 @end multitable
1742 @item @emph{Return value}:
1743 The return value is of type @code{INTEGER} with rank equal to that of
1744 @var{MASK}.
1746 @item @emph{Example}:
1747 @smallexample
1748 program test_count
1749     integer, dimension(2,3) :: a, b
1750     logical, dimension(2,3) :: mask
1751     a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
1752     b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
1753     print '(3i3)', a(1,:)
1754     print '(3i3)', a(2,:)
1755     print *
1756     print '(3i3)', b(1,:)
1757     print '(3i3)', b(2,:)
1758     print *
1759     mask = a.ne.b
1760     print '(3l3)', mask(1,:)
1761     print '(3l3)', mask(2,:)
1762     print *
1763     print '(3i3)', count(mask)
1764     print *
1765     print '(3i3)', count(mask, 1)
1766     print *
1767     print '(3i3)', count(mask, 2)
1768 end program test_count
1769 @end smallexample
1770 @end table
1774 @node CPU_TIME
1775 @section @code{CPU_TIME} --- CPU elapsed time in seconds
1776 @findex @code{CPU_TIME} intrinsic
1777 @cindex CPU_TIME
1779 @table @asis
1780 @item @emph{Description}:
1781 Returns a @code{REAL} value representing the elapsed CPU time in seconds.  This
1782 is useful for testing segments of code to determine execution time.
1784 @item @emph{Option}:
1785 f95, gnu
1787 @item @emph{Class}:
1788 subroutine
1790 @item @emph{Syntax}:
1791 @code{CPU_TIME(X)}
1793 @item @emph{Arguments}:
1794 @multitable @columnfractions .15 .80
1795 @item @var{X} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
1796 @end multitable
1798 @item @emph{Return value}:
1799 None
1801 @item @emph{Example}:
1802 @smallexample
1803 program test_cpu_time
1804     real :: start, finish
1805     call cpu_time(start)
1806         ! put code to test here
1807     call cpu_time(finish)
1808     print '("Time = ",f6.3," seconds.")',finish-start
1809 end program test_cpu_time
1810 @end smallexample
1811 @end table
1815 @node CSHIFT
1816 @section @code{CSHIFT} --- Circular shift function
1817 @findex @code{CSHIFT} intrinsic
1818 @cindex cshift intrinsic
1820 @table @asis
1821 @item @emph{Description}:
1822 @code{CSHIFT(ARRAY, SHIFT[,DIM])} performs a circular shift on elements of
1823 @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is omitted it is
1824 taken to be @code{1}.  @var{DIM} is a scaler of type @code{INTEGER} in the
1825 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
1826 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
1827 by @var{SHIFT} places.  If rank is greater than one, then all complete rank one
1828 sections of @var{ARRAY} along the given dimension are shifted.  Elements
1829 shifted out one end of each rank one section are shifted back in the other end.
1831 @item @emph{Option}:
1832 f95, gnu
1834 @item @emph{Class}:
1835 transformational function
1837 @item @emph{Syntax}:
1838 @code{A = CSHIFT(A, SHIFT[,DIM])}
1840 @item @emph{Arguments}:
1841 @multitable @columnfractions .15 .80
1842 @item @var{ARRAY}  @tab May be any type, not scaler.
1843 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
1844 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
1845 @end multitable
1847 @item @emph{Return value}:
1848 Returns an array of same type and rank as the @var{ARRAY} argument.
1850 @item @emph{Example}:
1851 @smallexample
1852 program test_cshift
1853     integer, dimension(3,3) :: a
1854     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
1855     print '(3i3)', a(1,:)
1856     print '(3i3)', a(2,:)
1857     print '(3i3)', a(3,:)    
1858     a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
1859     print *
1860     print '(3i3)', a(1,:)
1861     print '(3i3)', a(2,:)
1862     print '(3i3)', a(3,:)
1863 end program test_cshift
1864 @end smallexample
1865 @end table
1868 @node CTIME
1869 @section @code{CTIME} --- Convert a time into a string
1870 @findex @code{CTIME} intrinsic
1871 @cindex ctime subroutine 
1873 @table @asis
1874 @item @emph{Description}:
1875 @code{CTIME(T,S)} converts @var{T}, a system time value, such as returned
1876 by @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14
1877 1995}, and returns that string into @var{S}.
1879 If @code{CTIME} is invoked as a function, it can not be invoked as a
1880 subroutine, and vice versa.
1882 @var{T} is an @code{INTENT(IN)} @code{INTEGER(KIND=8)} variable.
1883 @var{S} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
1885 @item @emph{Option}:
1888 @item @emph{Class}:
1889 subroutine
1891 @item @emph{Syntax}:
1892 @multitable @columnfractions .80
1893 @item @code{CALL CTIME(T,S)}.
1894 @item @code{S = CTIME(T)}, (not recommended).
1895 @end multitable
1897 @item @emph{Arguments}:
1898 @multitable @columnfractions .15 .80
1899 @item @var{S}@tab The type shall be of type @code{CHARACTER}.
1900 @item @var{T}@tab The type shall be of type @code{INTEGER(KIND=8)}.
1901 @end multitable
1903 @item @emph{Return value}:
1904 The converted date and time as a string.
1906 @item @emph{Example}:
1907 @smallexample
1908 program test_ctime
1909     integer(8) :: i
1910     character(len=30) :: date
1911     i = time8()
1913     ! Do something, main part of the program
1914     
1915     call ctime(i,date)
1916     print *, 'Program was started on ', date
1917 end program test_ctime
1918 @end smallexample
1919 @end table
1921 @node DATE_AND_TIME
1922 @section @code{DATE_AND_TIME} --- Date and time subroutine
1923 @findex @code{DATE_AND_TIME} intrinsic
1924 @cindex DATE_AND_TIME
1926 @table @asis
1927 @item @emph{Description}:
1928 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
1929 time information from the real-time system clock.  @var{DATE} is
1930 @code{INTENT(OUT)} and has form ccyymmdd.  @var{TIME} is @code{INTENT(OUT)} and
1931 has form hhmmss.sss.  @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
1932 representing the difference with respect to Coordinated Universal Time (UTC).
1933 Unavailable time and date parameters return blanks.
1935 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
1937 @multitable @columnfractions .15 .30 .60
1938 @item @tab @code{VALUE(1)}: @tab The year
1939 @item @tab @code{VALUE(2)}: @tab The month
1940 @item @tab @code{VALUE(3)}: @tab The day of the month
1941 @item @tab @code{VAlUE(4)}: @tab Time difference with UTC in minutes
1942 @item @tab @code{VALUE(5)}: @tab The hour of the day
1943 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
1944 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
1945 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
1946 @end multitable     
1948 @item @emph{Option}:
1949 f95, gnu
1951 @item @emph{Class}:
1952 subroutine
1954 @item @emph{Syntax}:
1955 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
1957 @item @emph{Arguments}:
1958 @multitable @columnfractions .15 .80
1959 @item @var{DATE}  @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
1960 @item @var{TIME}  @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
1961 @item @var{ZONE}  @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
1962 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
1963 @end multitable
1965 @item @emph{Return value}:
1966 None
1968 @item @emph{Example}:
1969 @smallexample
1970 program test_time_and_date
1971     character(8)  :: date
1972     character(10) :: time
1973     character(5)  :: zone
1974     integer,dimension(8) :: values
1975     ! using keyword arguments
1976     call date_and_time(date,time,zone,values)
1977     call date_and_time(DATE=date,ZONE=zone)
1978     call date_and_time(TIME=time)
1979     call date_and_time(VALUES=values)
1980     print '(a,2x,a,2x,a)', date, time, zone
1981     print '(8i5))', values
1982 end program test_time_and_date
1983 @end smallexample
1984 @end table
1988 @node DBLE
1989 @section @code{DBLE} --- Double conversion function 
1990 @findex @code{DBLE} intrinsic
1991 @cindex double conversion
1993 @table @asis
1994 @item @emph{Description}:
1995 @code{DBLE(X)} Converts @var{X} to double precision real type.
1996 @code{DFLOAT} is an alias for @code{DBLE}
1998 @item @emph{Option}:
1999 f95, gnu
2001 @item @emph{Class}:
2002 elemental function
2004 @item @emph{Syntax}:
2005 @code{X = DBLE(X)}
2006 @code{X = DFLOAT(X)}
2008 @item @emph{Arguments}:
2009 @multitable @columnfractions .15 .80
2010 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
2011 @end multitable
2013 @item @emph{Return value}:
2014 The return value is of type double precision real.
2016 @item @emph{Example}:
2017 @smallexample
2018 program test_dble
2019     real    :: x = 2.18
2020     integer :: i = 5
2021     complex :: z = (2.3,1.14)
2022     print *, dble(x), dble(i), dfloat(z)
2023 end program test_dble
2024 @end smallexample
2025 @end table
2029 @node DCMPLX
2030 @section @code{DCMPLX} --- Double complex conversion function
2031 @findex @code{DCMPLX} intrinsic
2032 @cindex DCMPLX
2034 @table @asis
2035 @item @emph{Description}:
2036 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2037 converted to the real component.  If @var{Y} is present it is converted to the
2038 imaginary component.  If @var{Y} is not present then the imaginary component is
2039 set to 0.0.  If @var{X} is complex then @var{Y} must not be present.
2041 @item @emph{Option}:
2042 f95, gnu
2044 @item @emph{Class}:
2045 elemental function
2047 @item @emph{Syntax}:
2048 @code{C = DCMPLX(X)}
2049 @code{C = DCMPLX(X,Y)}
2051 @item @emph{Arguments}:
2052 @multitable @columnfractions .15 .80
2053 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
2054 @item @var{Y} @tab Optional if @var{X} is not @code{COMPLEX(*)}. May be @code{INTEGER(*)} or @code{REAL(*)}. 
2055 @end multitable
2057 @item @emph{Return value}:
2058 The return value is of type @code{COMPLEX(8)}
2060 @item @emph{Example}:
2061 @smallexample
2062 program test_dcmplx
2063     integer :: i = 42
2064     real :: x = 3.14
2065     complex :: z
2066     z = cmplx(i, x)
2067     print *, dcmplx(i)
2068     print *, dcmplx(x)
2069     print *, dcmplx(z)
2070     print *, dcmplx(x,i)
2071 end program test_dcmplx
2072 @end smallexample
2073 @end table
2077 @node DFLOAT
2078 @section @code{DFLOAT} --- Double conversion function 
2079 @findex @code{DFLOAT} intrinsic
2080 @cindex double float conversion
2082 @table @asis
2083 @item @emph{Description}:
2084 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2085 @code{DFLOAT} is an alias for @code{DBLE}.  See @code{DBLE}.
2086 @end table
2090 @node DIGITS
2091 @section @code{DIGITS} --- Significant digits function
2092 @findex @code{DIGITS} intrinsic
2093 @cindex digits, significant
2095 @table @asis
2096 @item @emph{Description}:
2097 @code{DIGITS(X)} returns the number of significant digits of the internal model
2098 representation of @var{X}.  For example, on a system using a 32-bit
2099 floating point representation, a default real number would likely return 24.
2101 @item @emph{Option}:
2102 f95, gnu
2104 @item @emph{Class}:
2105 inquiry function
2107 @item @emph{Syntax}:
2108 @code{C = DIGITS(X)}
2110 @item @emph{Arguments}:
2111 @multitable @columnfractions .15 .80
2112 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2113 @end multitable
2115 @item @emph{Return value}:
2116 The return value is of type @code{INTEGER}.
2118 @item @emph{Example}:
2119 @smallexample
2120 program test_digits
2121     integer :: i = 12345
2122     real :: x = 3.143
2123     real(8) :: y = 2.33
2124     print *, digits(i)
2125     print *, digits(x)
2126     print *, digits(y)
2127 end program test_digits
2128 @end smallexample
2129 @end table
2133 @node DIM
2134 @section @code{DIM} --- Dim function
2135 @findex @code{DIM} intrinsic
2136 @findex @code{IDIM} intrinsic
2137 @findex @code{DDIM} intrinsic
2138 @cindex dim
2140 @table @asis
2141 @item @emph{Description}:
2142 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2143 otherwise returns zero.
2145 @item @emph{Option}:
2146 f95, gnu
2148 @item @emph{Class}:
2149 elemental function
2151 @item @emph{Syntax}:
2152 @code{X = DIM(X,Y)}
2154 @item @emph{Arguments}:
2155 @multitable @columnfractions .15 .80
2156 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2157 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2158 @end multitable
2160 @item @emph{Return value}:
2161 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2163 @item @emph{Example}:
2164 @smallexample
2165 program test_dim
2166     integer :: i
2167     real(8) :: x
2168     i = dim(4, 15)
2169     x = dim(4.345_8, 2.111_8)
2170     print *, i
2171     print *, x
2172 end program test_dim
2173 @end smallexample
2175 @item @emph{Specific names}:
2176 @multitable @columnfractions .24 .24 .24 .24
2177 @item Name            @tab Argument          @tab Return type       @tab Option
2178 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab gnu
2179 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y}  @tab @code{REAL(8)} @tab gnu
2180 @end multitable
2181 @end table
2185 @node DOT_PRODUCT
2186 @section @code{DOT_PRODUCT} --- Dot product function
2187 @findex @code{DOT_PRODUCT} intrinsic
2188 @cindex Dot product
2190 @table @asis
2191 @item @emph{Description}:
2192 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2193 @var{X} and @var{Y}.  The two vectors may be either numeric or logical
2194 and must be arrays of rank one and of equal size. If the vectors are
2195 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2196 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the 
2197 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2199 @item @emph{Option}:
2202 @item @emph{Class}:
2203 transformational function
2205 @item @emph{Syntax}:
2206 @code{S = DOT_PRODUCT(X,Y)}
2208 @item @emph{Arguments}:
2209 @multitable @columnfractions .15 .80
2210 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2211 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2212 @end multitable
2214 @item @emph{Return value}:
2215 If the arguments are numeric, the return value is a scaler of numeric type,
2216 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.  If the arguments are
2217 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2219 @item @emph{Example}:
2220 @smallexample
2221 program test_dot_prod
2222     integer, dimension(3) :: a, b
2223     a = (/ 1, 2, 3 /)
2224     b = (/ 4, 5, 6 /)
2225     print '(3i3)', a
2226     print *
2227     print '(3i3)', b
2228     print *
2229     print *, dot_product(a,b)
2230 end program test_dot_prod
2231 @end smallexample
2232 @end table
2236 @node DPROD
2237 @section @code{DPROD} --- Double product function
2238 @findex @code{DPROD} intrinsic
2239 @cindex Double product
2241 @table @asis
2242 @item @emph{Description}:
2243 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2245 @item @emph{Option}:
2246 f95, gnu
2248 @item @emph{Class}:
2249 elemental function
2251 @item @emph{Syntax}:
2252 @code{D = DPROD(X,Y)}
2254 @item @emph{Arguments}:
2255 @multitable @columnfractions .15 .80
2256 @item @var{X} @tab The type shall be @code{REAL}.
2257 @item @var{Y} @tab The type shall be @code{REAL}.
2258 @end multitable
2260 @item @emph{Return value}:
2261 The return value is of type @code{REAL(8)}.
2263 @item @emph{Example}:
2264 @smallexample
2265 program test_dprod
2266     integer :: i
2267     real :: x = 5.2
2268     real :: y = 2.3
2269     real(8) :: d
2270     d = dprod(x,y)
2271     print *, d
2272 end program test_dprod
2273 @end smallexample
2274 @end table
2278 @node DREAL
2279 @section @code{DREAL} --- Double real part function
2280 @findex @code{DREAL} intrinsic
2281 @cindex Double real part
2283 @table @asis
2284 @item @emph{Description}:
2285 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2287 @item @emph{Option}:
2290 @item @emph{Class}:
2291 elemental function
2293 @item @emph{Syntax}:
2294 @code{D = DREAL(Z)}
2296 @item @emph{Arguments}:
2297 @multitable @columnfractions .15 .80
2298 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2299 @end multitable
2301 @item @emph{Return value}:
2302 The return value is of type @code{REAL(8)}.
2304 @item @emph{Example}:
2305 @smallexample
2306 program test_dreal
2307     complex(8) :: z = (1.3_8,7.2_8)
2308     print *, dreal(z)
2309 end program test_dreal
2310 @end smallexample
2311 @end table
2315 @node DTIME
2316 @section @code{DTIME} --- Execution time subroutine (or function)
2317 @findex @code{DTIME} intrinsic
2318 @cindex dtime subroutine 
2320 @table @asis
2321 @item @emph{Description}:
2322 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2323 since the start of the process's execution in @var{RESULT}.  @var{TARRAY}
2324 returns the user and system components of this time in @code{TARRAY(1)} and
2325 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2326 TARRAY(2)}.
2328 Subsequent invocations of @code{DTIME} return values accumulated since the
2329 previous invocation.
2331 On some systems, the underlying timings are represented using types with
2332 sufficiently small limits that overflows (wraparounds) are possible, such as
2333 32-bit types. Therefore, the values returned by this intrinsic might be, or
2334 become, negative, or numerically less than previous values, during a single
2335 run of the compiled program.
2337 If @code{DTIME} is invoked as a function, it can not be invoked as a
2338 subroutine, and vice versa.
2340 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2342 @multitable @columnfractions .15 .30 .60
2343 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2344 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2345 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2346 @end multitable
2348 @item @emph{Option}:
2351 @item @emph{Class}:
2352 subroutine
2354 @item @emph{Syntax}:
2355 @multitable @columnfractions .80
2356 @item @code{CALL DTIME(TARRAY, RESULT)}.
2357 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
2358 @end multitable
2360 @item @emph{Arguments}:
2361 @multitable @columnfractions .15 .80
2362 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2363 @item @var{RESULT}@tab The type shall be @code{REAL}.
2364 @end multitable
2366 @item @emph{Return value}:
2367 Elapsed time in seconds since the start of program execution.
2369 @item @emph{Example}:
2370 @smallexample
2371 program test_dtime
2372     integer(8) :: i, j
2373     real, dimension(2) :: tarray
2374     real :: result
2375     call dtime(tarray, result)
2376     print *, result
2377     print *, tarray(1)
2378     print *, tarray(2)   
2379     do i=1,100000000    ! Just a delay
2380         j = i * i - i
2381     end do
2382     call dtime(tarray, result)
2383     print *, result
2384     print *, tarray(1)
2385     print *, tarray(2)
2386 end program test_dtime
2387 @end smallexample
2388 @end table
2392 @node EOSHIFT
2393 @section @code{EOSHIFT} --- End-off shift function
2394 @findex @code{EOSHIFT} intrinsic
2395 @cindex eoshift intrinsic
2397 @table @asis
2398 @item @emph{Description}:
2399 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
2400 elements of @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is
2401 omitted it is taken to be @code{1}.  @var{DIM} is a scaler of type
2402 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
2403 rank of @var{ARRAY}.  If the rank of @var{ARRAY} is one, then all elements of
2404 @var{ARRAY} are shifted by @var{SHIFT} places.  If rank is greater than one,
2405 then all complete rank one sections of @var{ARRAY} along the given dimension are
2406 shifted.  Elements shifted out one end of each rank one section are dropped.  If
2407 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
2408 is copied back in the other end.  If @var{BOUNDARY} is not present then the
2409 following are copied in depending on the type of @var{ARRAY}.
2411 @multitable @columnfractions .15 .80
2412 @item @emph{Array Type} @tab @emph{Boundary Value}
2413 @item Numeric  @tab 0 of the type and kind of @var{ARRAY}.
2414 @item Logical  @tab @code{.FALSE.}.
2415 @item Character(@var{len}) @tab @var{len} blanks.
2416 @end multitable
2418 @item @emph{Option}:
2419 f95, gnu
2421 @item @emph{Class}:
2422 transformational function
2424 @item @emph{Syntax}:
2425 @code{A = EOSHIFT(A, SHIFT[,BOUNDARY, DIM])}
2427 @item @emph{Arguments}:
2428 @multitable @columnfractions .15 .80
2429 @item @var{ARRAY}  @tab May be any type, not scaler.
2430 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
2431 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}. 
2432 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
2433 @end multitable
2435 @item @emph{Return value}:
2436 Returns an array of same type and rank as the @var{ARRAY} argument.
2438 @item @emph{Example}:
2439 @smallexample
2440 program test_eoshift
2441     integer, dimension(3,3) :: a
2442     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2443     print '(3i3)', a(1,:)
2444     print '(3i3)', a(2,:)
2445     print '(3i3)', a(3,:)    
2446     a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
2447     print *
2448     print '(3i3)', a(1,:)
2449     print '(3i3)', a(2,:)
2450     print '(3i3)', a(3,:)
2451 end program test_eoshift
2452 @end smallexample
2453 @end table
2457 @node EPSILON
2458 @section @code{EPSILON} --- Epsilon function
2459 @findex @code{EPSILON} intrinsic
2460 @cindex epsilon, significant
2462 @table @asis
2463 @item @emph{Description}:
2464 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
2466 @item @emph{Option}:
2467 f95, gnu
2469 @item @emph{Class}:
2470 inquiry function
2472 @item @emph{Syntax}:
2473 @code{C = EPSILON(X)}
2475 @item @emph{Arguments}:
2476 @multitable @columnfractions .15 .80
2477 @item @var{X} @tab The type shall be @code{REAL(*)}.
2478 @end multitable
2480 @item @emph{Return value}:
2481 The return value is of same type as the argument.
2483 @item @emph{Example}:
2484 @smallexample
2485 program test_epsilon
2486     real :: x = 3.143
2487     real(8) :: y = 2.33
2488     print *, EPSILON(x)
2489     print *, EPSILON(y)
2490 end program test_epsilon
2491 @end smallexample
2492 @end table
2496 @node ERF
2497 @section @code{ERF} --- Error function 
2498 @findex @code{ERF} intrinsic
2499 @cindex error function
2501 @table @asis
2502 @item @emph{Description}:
2503 @code{ERF(X)} computes the error function of @var{X}.
2505 @item @emph{Option}:
2508 @item @emph{Class}:
2509 elemental function
2511 @item @emph{Syntax}:
2512 @code{X = ERF(X)}
2514 @item @emph{Arguments}:
2515 @multitable @columnfractions .15 .80
2516 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
2517 @end multitable
2519 @item @emph{Return value}:
2520 The return value is a scalar of type @code{REAL(*)} and it is positive
2521 (@math{ - 1 \leq erf (x) \leq 1 }.
2523 @item @emph{Example}:
2524 @smallexample
2525 program test_erf
2526   real(8) :: x = 0.17_8
2527   x = erf(x)
2528 end program test_erf
2529 @end smallexample
2531 @item @emph{Specific names}:
2532 @multitable @columnfractions .24 .24 .24 .24
2533 @item Name            @tab Argument          @tab Return type       @tab Option
2534 @item @code{DERF(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab gnu
2535 @end multitable
2536 @end table
2540 @node ERFC
2541 @section @code{ERFC} --- Error function 
2542 @findex @code{ERFC} intrinsic
2543 @cindex error function
2545 @table @asis
2546 @item @emph{Description}:
2547 @code{ERFC(X)} computes the complementary error function of @var{X}.
2549 @item @emph{Option}:
2552 @item @emph{Class}:
2553 elemental function
2555 @item @emph{Syntax}:
2556 @code{X = ERFC(X)}
2558 @item @emph{Arguments}:
2559 @multitable @columnfractions .15 .80
2560 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
2561 @end multitable
2563 @item @emph{Return value}:
2564 The return value is a scalar of type @code{REAL(*)} and it is positive
2565 (@math{ 0 \leq erfc (x) \leq 2 }.
2567 @item @emph{Example}:
2568 @smallexample
2569 program test_erfc
2570   real(8) :: x = 0.17_8
2571   x = erfc(x)
2572 end program test_erfc
2573 @end smallexample
2575 @item @emph{Specific names}:
2576 @multitable @columnfractions .24 .24 .24 .24
2577 @item Name            @tab Argument          @tab Return type       @tab Option
2578 @item @code{DERFC(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab gnu
2579 @end multitable
2580 @end table
2584 @node ETIME
2585 @section @code{ETIME} --- Execution time subroutine (or function)
2586 @findex @code{ETIME} intrinsic
2587 @cindex ETIME subroutine 
2589 @table @asis
2590 @item @emph{Description}:
2591 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
2592 since the start of the process's execution in @var{RESULT}.  @var{TARRAY}
2593 returns the user and system components of this time in @code{TARRAY(1)} and
2594 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
2596 On some systems, the underlying timings are represented using types with
2597 sufficiently small limits that overflows (wraparounds) are possible, such as
2598 32-bit types. Therefore, the values returned by this intrinsic might be, or
2599 become, negative, or numerically less than previous values, during a single
2600 run of the compiled program.
2602 If @code{ETIME} is invoked as a function, it can not be invoked as a
2603 subroutine, and vice versa.
2605 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2607 @multitable @columnfractions .15 .30 .60
2608 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2609 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2610 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2611 @end multitable
2613 @item @emph{Option}:
2616 @item @emph{Class}:
2617 subroutine
2619 @item @emph{Syntax}:
2620 @multitable @columnfractions .8
2621 @item @code{CALL ETIME(TARRAY, RESULT)}.
2622 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
2623 @end multitable
2625 @item @emph{Arguments}:
2626 @multitable @columnfractions .15 .80
2627 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2628 @item @var{RESULT}@tab The type shall be @code{REAL}.
2629 @end multitable
2631 @item @emph{Return value}:
2632 Elapsed time in seconds since the start of program execution.
2634 @item @emph{Example}:
2635 @smallexample
2636 program test_etime
2637     integer(8) :: i, j
2638     real, dimension(2) :: tarray
2639     real :: result
2640     call ETIME(tarray, result)
2641     print *, result
2642     print *, tarray(1)
2643     print *, tarray(2)   
2644     do i=1,100000000    ! Just a delay
2645         j = i * i - i
2646     end do
2647     call ETIME(tarray, result)
2648     print *, result
2649     print *, tarray(1)
2650     print *, tarray(2)
2651 end program test_etime
2652 @end smallexample
2653 @end table
2657 @node EXIT
2658 @section @code{EXIT} --- Exit the program with status. 
2659 @findex @code{EXIT}
2660 @cindex exit
2662 @table @asis
2663 @item @emph{Description}:
2664 @code{EXIT} causes immediate termination of the program with status.  If status
2665 is omitted it returns the canonical @emph{success} for the system.  All Fortran
2666 I/O units are closed. 
2668 @item @emph{Option}:
2671 @item @emph{Class}:
2672 non-elemental subroutine
2674 @item @emph{Syntax}:
2675 @code{CALL EXIT([STATUS])}
2677 @item @emph{Arguments}:
2678 @multitable @columnfractions .15 .80
2679 @item @var{STATUS} @tab The type of the argument shall be @code{INTEGER(*)}.
2680 @end multitable
2682 @item @emph{Return value}:
2683 @code{STATUS} is passed to the parent process on exit.
2685 @item @emph{Example}:
2686 @smallexample
2687 program test_exit
2688   integer :: STATUS = 0
2689   print *, 'This program is going to exit.'
2690   call EXIT(STATUS)
2691 end program test_exit
2692 @end smallexample
2693 @end table
2697 @node EXP
2698 @section @code{EXP} --- Exponential function 
2699 @findex @code{EXP} intrinsic
2700 @findex @code{DEXP} intrinsic
2701 @findex @code{ZEXP} intrinsic
2702 @findex @code{CDEXP} intrinsic
2703 @cindex exponential
2705 @table @asis
2706 @item @emph{Description}:
2707 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
2709 @item @emph{Option}:
2710 f95, gnu
2712 @item @emph{Class}:
2713 elemental function
2715 @item @emph{Syntax}:
2716 @code{X = EXP(X)}
2718 @item @emph{Arguments}:
2719 @multitable @columnfractions .15 .80
2720 @item @var{X} @tab The type shall be @code{REAL(*)} or
2721 @code{COMPLEX(*)}.
2722 @end multitable
2724 @item @emph{Return value}:
2725 The return value has same type and kind as @var{X}.
2727 @item @emph{Example}:
2728 @smallexample
2729 program test_exp
2730   real :: x = 1.0
2731   x = exp(x)
2732 end program test_exp
2733 @end smallexample
2735 @item @emph{Specific names}:
2736 @multitable @columnfractions .24 .24 .24 .24
2737 @item Name            @tab Argument          @tab Return type       @tab Option
2738 @item @code{DEXP(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
2739 @item @code{CEXP(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
2740 @item @code{ZEXP(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
2741 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
2742 @end multitable
2743 @end table
2747 @node EXPONENT
2748 @section @code{EXPONENT} --- Exponent function 
2749 @findex @code{EXPONENT} intrinsic
2750 @cindex exponent function
2752 @table @asis
2753 @item @emph{Description}:
2754 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
2755 is zero the value returned is zero. 
2757 @item @emph{Option}:
2758 f95, gnu
2760 @item @emph{Class}:
2761 elemental function
2763 @item @emph{Syntax}:
2764 @code{I = EXPONENT(X)}
2766 @item @emph{Arguments}:
2767 @multitable @columnfractions .15 .80
2768 @item @var{X} @tab The type shall be @code{REAL(*)}.
2769 @end multitable
2771 @item @emph{Return value}:
2772 The return value is of type default @code{INTEGER}.
2774 @item @emph{Example}:
2775 @smallexample
2776 program test_exponent
2777   real :: x = 1.0
2778   integer :: i
2779   i = exponent(x)
2780   print *, i
2781   print *, exponent(0.0)
2782 end program test_exponent
2783 @end smallexample
2784 @end table
2787 @node FDATE
2788 @section @code{FDATE} --- Get the current time as a string
2789 @findex @code{FDATE} intrinsic
2790 @cindex fdate subroutine 
2792 @table @asis
2793 @item @emph{Description}:
2794 @code{FDATE(DATE)} returns the current date (using the same format as
2795 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
2796 TIME8())}.
2798 If @code{FDATE} is invoked as a function, it can not be invoked as a
2799 subroutine, and vice versa.
2801 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
2803 @item @emph{Option}:
2806 @item @emph{Class}:
2807 subroutine
2809 @item @emph{Syntax}:
2810 @multitable @columnfractions .80
2811 @item @code{CALL FDATE(DATE)}.
2812 @item @code{DATE = FDATE()}, (not recommended).
2813 @end multitable
2815 @item @emph{Arguments}:
2816 @multitable @columnfractions .15 .80
2817 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
2818 @end multitable
2820 @item @emph{Return value}:
2821 The current date and time as a string.
2823 @item @emph{Example}:
2824 @smallexample
2825 program test_fdate
2826     integer(8) :: i, j
2827     character(len=30) :: date
2828     call fdate(date)
2829     print *, 'Program started on ', date
2830     do i = 1, 100000000 ! Just a delay
2831         j = i * i - i
2832     end do
2833     call fdate(date)
2834     print *, 'Program ended on ', date
2835 end program test_fdate
2836 @end smallexample
2837 @end table
2839 @node FLOAT
2840 @section @code{FLOAT} --- Convert integer to default real
2841 @findex @code{FLOAT} intrinsic
2842 @cindex float
2844 @table @asis
2845 @item @emph{Description}:
2846 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
2848 @item @emph{Option}:
2851 @item @emph{Class}:
2852 function
2854 @item @emph{Syntax}:
2855 @code{X = FLOAT(I)}
2857 @item @emph{Arguments}:
2858 @multitable @columnfractions .15 .80
2859 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
2860 @end multitable
2862 @item @emph{Return value}:
2863 The return value is of type default @code{REAL}
2865 @item @emph{Example}:
2866 @smallexample
2867 program test_float
2868     integer :: i = 1
2869     if (float(i) /= 1.) call abort
2870 end program test_float
2871 @end smallexample
2872 @end table
2875 @node FLOOR
2876 @section @code{FLOOR} --- Integer floor function
2877 @findex @code{FLOOR} intrinsic
2878 @cindex floor
2880 @table @asis
2881 @item @emph{Description}:
2882 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
2884 @item @emph{Option}:
2885 f95, gnu
2887 @item @emph{Class}:
2888 elemental function
2890 @item @emph{Syntax}:
2891 @code{I = FLOOR(X[,KIND])}
2893 @item @emph{Arguments}:
2894 @multitable @columnfractions .15 .80
2895 @item @var{X} @tab The type shall be @code{REAL(*)}.
2896 @item @var{KIND} @tab Optional scaler integer initialization expression.
2897 @end multitable
2899 @item @emph{Return value}:
2900 The return value is of type @code{INTEGER(KIND)}
2902 @item @emph{Example}:
2903 @smallexample
2904 program test_floor
2905     real :: x = 63.29
2906     real :: y = -63.59
2907     print *, floor(x) ! returns 63
2908     print *, floor(y) ! returns -64
2909 end program test_floor
2910 @end smallexample
2911 @end table
2915 @node FLUSH
2916 @section @code{FLUSH} --- Flush I/O unit(s)
2917 @findex @code{FLUSH}
2918 @cindex flush
2920 @table @asis
2921 @item @emph{Description}:
2922 Flushes Fortran unit(s) currently open for output. Without the optional
2923 argument, all units are flushed, otherwise just the unit specified.
2925 @item @emph{Option}:
2928 @item @emph{Class}:
2929 non-elemental subroutine
2931 @item @emph{Syntax}:
2932 @code{CALL FLUSH(UNIT)}
2934 @item @emph{Arguments}:
2935 @multitable @columnfractions .15 .80
2936 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
2937 @end multitable
2939 @item @emph{Note}:
2940 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
2941 statement that should be prefered over the @code{FLUSH} intrinsic.
2943 @end table
2947 @node FNUM
2948 @section @code{FNUM} --- File number function
2949 @findex @code{FNUM} intrinsic
2950 @cindex fnum
2952 @table @asis
2953 @item @emph{Description}:
2954 @code{FNUM(UNIT)} returns the Posix file descriptor number corresponding to the
2955 open Fortran I/O unit @code{UNIT}.
2957 @item @emph{Option}:
2960 @item @emph{Class}:
2961 non-elemental function
2963 @item @emph{Syntax}:
2964 @code{I = FNUM(UNIT)}
2966 @item @emph{Arguments}:
2967 @multitable @columnfractions .15 .80
2968 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
2969 @end multitable
2971 @item @emph{Return value}:
2972 The return value is of type @code{INTEGER}
2974 @item @emph{Example}:
2975 @smallexample
2976 program test_fnum
2977   integer :: i
2978   open (unit=10, status = "scratch")
2979   i = fnum(10)
2980   print *, i
2981   close (10)
2982 end program test_fnum
2983 @end smallexample
2984 @end table
2988 @node FRACTION
2989 @section @code{FRACTION} --- Fractional part of the model representation
2990 @findex @code{FRACTION} intrinsic
2991 @cindex fractional part
2993 @table @asis
2994 @item @emph{Description}:
2995 @code{FRACTION(X)} returns the fractional part of the model
2996 representation of @code{X}.
2998 @item @emph{Option}:
2999 f95, gnu
3001 @item @emph{Class}:
3002 elemental function
3004 @item @emph{Syntax}:
3005 @code{Y = FRACTION(X)}
3007 @item @emph{Arguments}:
3008 @multitable @columnfractions .15 .80
3009 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
3010 @end multitable
3012 @item @emph{Return value}:
3013 The return value is of the same type and kind as the argument.
3014 The fractional part of the model representation of @code{X} is returned;
3015 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
3017 @item @emph{Example}:
3018 @smallexample
3019 program test_fraction
3020   real :: x
3021   x = 178.1387e-4
3022   print *, fraction(x), x * radix(x)**(-exponent(x))
3023 end program test_fraction
3024 @end smallexample
3026 @end table
3030 @node FREE
3031 @section @code{FREE} --- Frees memory
3032 @findex @code{FREE} intrinsic
3033 @cindex FREE
3035 @table @asis
3036 @item @emph{Description}:
3037 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
3038 intrinsic is an extension intended to be used with Cray pointers, and is
3039 provided in @command{gfortran} to allow user to compile legacy code. For
3040 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
3041 @code{DEALLOCATE}.
3043 @item @emph{Option}:
3046 @item @emph{Class}:
3047 subroutine
3049 @item @emph{Syntax}:
3050 @code{FREE(PTR)}
3052 @item @emph{Arguments}:
3053 @multitable @columnfractions .15 .80
3054 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
3055 location of the memory that should be de-allocated.
3056 @end multitable
3058 @item @emph{Return value}:
3059 None
3061 @item @emph{Example}:
3062 See @code{MALLOC} for an example.
3063 @end table
3067 @node GETGID
3068 @section @code{GETGID} --- Group ID function
3069 @findex @code{GETGID} intrinsic
3070 @cindex GETGID
3072 @table @asis
3073 @item @emph{Description}:
3074 Returns the numerical group ID of the current process.
3076 @item @emph{Option}:
3079 @item @emph{Class}:
3080 function
3082 @item @emph{Syntax}:
3083 @code{I = GETGID()}
3085 @item @emph{Return value}:
3086 The return value of @code{GETGID} is an @code{INTEGER} of the default
3087 kind.
3090 @item @emph{Example}:
3091 See @code{GETPID} for an example.
3093 @end table
3097 @node GETPID
3098 @section @code{GETPID} --- Process ID function
3099 @findex @code{GETPID} intrinsic
3100 @cindex GETPID
3102 @table @asis
3103 @item @emph{Description}:
3104 Returns the process numerical identificator of the current process.
3106 @item @emph{Option}:
3109 @item @emph{Class}:
3110 function
3112 @item @emph{Syntax}:
3113 @code{I = GETPID()}
3115 @item @emph{Return value}:
3116 The return value of @code{GETPID} is an @code{INTEGER} of the default
3117 kind.
3120 @item @emph{Example}:
3121 @smallexample
3122 program info
3123   print *, "The current process ID is ", getpid()
3124   print *, "Your numerical user ID is ", getuid()
3125   print *, "Your numerical group ID is ", getgid()
3126 end program info
3127 @end smallexample
3129 @end table
3133 @node GETUID
3134 @section @code{GETUID} --- User ID function
3135 @findex @code{GETUID} intrinsic
3136 @cindex GETUID
3138 @table @asis
3139 @item @emph{Description}:
3140 Returns the numerical user ID of the current process.
3142 @item @emph{Option}:
3145 @item @emph{Class}:
3146 function
3148 @item @emph{Syntax}:
3149 @code{GETUID()}
3151 @item @emph{Return value}:
3152 The return value of @code{GETUID} is an @code{INTEGER} of the default
3153 kind.
3156 @item @emph{Example}:
3157 See @code{GETPID} for an example.
3159 @end table
3163 @node HUGE
3164 @section @code{HUGE} --- Largest number of a kind
3165 @findex @code{HUGE} intrinsic
3166 @cindex huge
3168 @table @asis
3169 @item @emph{Description}:
3170 @code{HUGE(X)} returns the largest number that is not an infinity in
3171 the model of the type of @code{X}.
3173 @item @emph{Option}:
3174 f95, gnu
3176 @item @emph{Class}:
3177 elemental function
3179 @item @emph{Syntax}:
3180 @code{Y = HUGE(X)}
3182 @item @emph{Arguments}:
3183 @multitable @columnfractions .15 .80
3184 @item @var{X} @tab shall be of type @code{REAL} or @code{INTEGER}.
3185 @end multitable
3187 @item @emph{Return value}:
3188 The return value is of the same type and kind as @var{X}
3190 @item @emph{Example}:
3191 @smallexample
3192 program test_huge_tiny
3193   print *, huge(0), huge(0.0), huge(0.0d0)
3194   print *, tiny(0.0), tiny(0.0d0)
3195 end program test_huge_tiny
3196 @end smallexample
3197 @end table
3201 @node IACHAR
3202 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence 
3203 @findex @code{IACHAR} intrinsic
3204 @cindex @acronym{ASCII} collating sequence
3206 @table @asis
3207 @item @emph{Description}:
3208 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
3209 in the first character position of @code{C}.
3211 @item @emph{Option}:
3212 f95, gnu
3214 @item @emph{Class}:
3215 elemental function
3217 @item @emph{Syntax}:
3218 @code{I = IACHAR(C)}
3220 @item @emph{Arguments}:
3221 @multitable @columnfractions .15 .80
3222 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
3223 @end multitable
3225 @item @emph{Return value}:
3226 The return value is of type @code{INTEGER} and of the default integer
3227 kind.
3229 @item @emph{Example}:
3230 @smallexample
3231 program test_iachar
3232   integer i
3233   i = iachar(' ')
3234 end program test_iachar
3235 @end smallexample
3236 @end table
3240 @node ICHAR
3241 @section @code{ICHAR} --- Character-to-integer conversion function
3242 @findex @code{ICHAR} intrinsic
3244 @table @asis
3245 @item @emph{Description}:
3246 @code{ICHAR(C)} returns the code for the character in the first character
3247 position of @code{C} in the system's native character set.
3248 The correspondence between character and their codes is not necessarily
3249 the same between GNU Fortran implementations.
3251 @item @emph{Option}:
3252 f95, gnu
3254 @item @emph{Class}:
3255 elemental function
3257 @item @emph{Syntax}:
3258 @code{I = ICHAR(C)}
3260 @item @emph{Arguments}:
3261 @multitable @columnfractions .15 .80
3262 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
3263 @end multitable
3265 @item @emph{Return value}:
3266 The return value is of type @code{INTEGER} and of the default integer
3267 kind.
3269 @item @emph{Example}:
3270 @smallexample
3271 program test_ichar
3272   integer i
3273   i = ichar(' ')
3274 end program test_ichar
3275 @end smallexample
3277 @item @emph{Note}:
3278 No intrinsic exists to convert a printable character string to a numerical
3279 value. For example, there is no intrinsic that, given the @code{CHARACTER}
3280 value 154, returns an @code{INTEGER} or @code{REAL} value with the
3281 value 154.
3283 Instead, you can use internal-file I/O to do this kind of conversion. For
3284 example:
3285 @smallexample
3286 program read_val
3287   integer value
3288   character(len=10) string
3290   string = '154'
3291   read (string,'(I10)') value
3292   print *, value
3293 end program read_val
3294 @end smallexample
3295 @end table
3299 @node IRAND
3300 @section @code{IRAND} --- Integer pseudo-random number
3301 @findex @code{IRAND} intrinsic
3302 @cindex random number
3304 @table @asis
3305 @item @emph{Description}:
3306 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
3307 distribution between 0 and a system-dependent limit (which is in most
3308 cases 2147483647). If @var{FLAG} is 0, the next number
3309 in the current sequence is returned; if @var{FLAG} is 1, the generator
3310 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
3311 it is used as a new seed with @code{SRAND}.
3313 @item @emph{Option}:
3316 @item @emph{Class}:
3317 non-elemental function
3319 @item @emph{Syntax}:
3320 @code{I = IRAND(FLAG)}
3322 @item @emph{Arguments}:
3323 @multitable @columnfractions .15 .80
3324 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
3325 @end multitable
3327 @item @emph{Return value}:
3328 The return value is of @code{INTEGER(kind=4)} type.
3330 @item @emph{Example}:
3331 @smallexample
3332 program test_irand
3333   integer,parameter :: seed = 86456
3334   
3335   call srand(seed)
3336   print *, irand(), irand(), irand(), irand()
3337   print *, irand(seed), irand(), irand(), irand()
3338 end program test_irand
3339 @end smallexample
3341 @end table
3345 @node KIND
3346 @section @code{KIND} --- Kind of an entity
3347 @findex @code{KIND} intrinsic
3349 @table @asis
3350 @item @emph{Description}:
3351 @code{KIND(X)} returns the kind value of the entity @var{X}.
3353 @item @emph{Option}:
3354 f95, gnu
3356 @item @emph{Class}:
3357 inquiry function
3359 @item @emph{Syntax}:
3360 @code{K = KIND(X)}
3362 @item @emph{Arguments}:
3363 @multitable @columnfractions .15 .80
3364 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
3365 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
3366 @end multitable
3368 @item @emph{Return value}:
3369 The return value is a scalar of type @code{INTEGER} and of the default
3370 integer kind.
3372 @item @emph{Example}:
3373 @smallexample
3374 program test_kind
3375   integer,parameter :: kc = kind(' ')
3376   integer,parameter :: kl = kind(.true.)
3378   print *, "The default character kind is ", kc
3379   print *, "The default logical kind is ", kl
3380 end program test_kind
3381 @end smallexample
3383 @end table
3387 @node LOC
3388 @section @code{LOC} --- Returns the address of a variable
3389 @findex @code{LOC} intrinsic
3390 @cindex loc
3392 @table @asis
3393 @item @emph{Description}:
3394 @code{LOC(X)} returns the address of @var{X} as an integer.
3396 @item @emph{Option}:
3399 @item @emph{Class}:
3400 inquiry function
3402 @item @emph{Syntax}:
3403 @code{I = LOC(X)}
3405 @item @emph{Arguments}:
3406 @multitable @columnfractions .15 .80
3407 @item @var{X} @tab Variable of any type.
3408 @end multitable
3410 @item @emph{Return value}:
3411 The return value is of type @code{INTEGER(n)}, where @code{n} is the
3412 size (in bytes) of a memory address on the target machine.
3414 @item @emph{Example}:
3415 @smallexample
3416 program test_loc
3417   integer :: i
3418   real :: r
3419   i = loc(r)
3420   print *, i
3421 end program test_loc
3422 @end smallexample
3423 @end table
3425 @node LOG
3426 @section @code{LOG} --- Logarithm function
3427 @findex @code{LOG} intrinsic
3428 @findex @code{ALOG} intrinsic
3429 @findex @code{DLOG} intrinsic
3430 @findex @code{CLOG} intrinsic
3431 @findex @code{ZLOG} intrinsic
3432 @findex @code{CDLOG} intrinsic
3433 @cindex logarithm
3435 @table @asis
3436 @item @emph{Description}:
3437 @code{LOG(X)} computes the logarithm of @var{X}.
3439 @item @emph{Option}:
3440 f95, gnu
3442 @item @emph{Class}:
3443 elemental function
3445 @item @emph{Syntax}:
3446 @code{X = LOG(X)}
3448 @item @emph{Arguments}:
3449 @multitable @columnfractions .15 .80
3450 @item @var{X} @tab The type shall be @code{REAL(*)} or
3451 @code{COMPLEX(*)}.
3452 @end multitable
3454 @item @emph{Return value}:
3455 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
3456 The kind type parameter is the same as @var{X}.
3458 @item @emph{Example}:
3459 @smallexample
3460 program test_log
3461   real(8) :: x = 1.0_8
3462   complex :: z = (1.0, 2.0)
3463   x = log(x)
3464   z = log(z)
3465 end program test_log
3466 @end smallexample
3468 @item @emph{Specific names}:
3469 @multitable @columnfractions .24 .24 .24 .24
3470 @item Name            @tab Argument          @tab Return type       @tab Option
3471 @item @code{ALOG(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab f95, gnu
3472 @item @code{DLOG(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
3473 @item @code{CLOG(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
3474 @item @code{ZLOG(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
3475 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
3476 @end multitable
3477 @end table
3481 @node LOG10
3482 @section @code{LOG10} --- Base 10 logarithm function
3483 @findex @code{LOG10} intrinsic
3484 @findex @code{ALOG10} intrinsic
3485 @findex @code{DLOG10} intrinsic
3486 @cindex logarithm
3488 @table @asis
3489 @item @emph{Description}:
3490 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
3492 @item @emph{Option}:
3493 f95, gnu
3495 @item @emph{Class}:
3496 elemental function
3498 @item @emph{Syntax}:
3499 @code{X = LOG10(X)}
3501 @item @emph{Arguments}:
3502 @multitable @columnfractions .15 .80
3503 @item @var{X} @tab The type shall be @code{REAL(*)} or
3504 @code{COMPLEX(*)}.
3505 @end multitable
3507 @item @emph{Return value}:
3508 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
3509 The kind type parameter is the same as @var{X}.
3511 @item @emph{Example}:
3512 @smallexample
3513 program test_log10
3514   real(8) :: x = 10.0_8
3515   x = log10(x)
3516 end program test_log10
3517 @end smallexample
3519 @item @emph{Specific names}:
3520 @multitable @columnfractions .24 .24 .24 .24
3521 @item Name            @tab Argument          @tab Return type       @tab Option
3522 @item @code{ALOG10(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab f95, gnu
3523 @item @code{DLOG10(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
3524 @end multitable
3525 @end table
3528 @node MALLOC
3529 @section @code{MALLOC} --- Allocate dynamic memory
3530 @findex @code{MALLOC} intrinsic
3531 @cindex MALLOC
3533 @table @asis
3534 @item @emph{Description}:
3535 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
3536 returns the address of the allocated memory. The @code{MALLOC} intrinsic
3537 is an extension intended to be used with Cray pointers, and is provided
3538 in @command{gfortran} to allow user to compile legacy code. For new code
3539 using Fortran 95 pointers, the memory allocation intrinsic is
3540 @code{ALLOCATE}.
3542 @item @emph{Option}:
3545 @item @emph{Class}:
3546 non-elemental function
3548 @item @emph{Syntax}:
3549 @code{PTR = MALLOC(SIZE)}
3551 @item @emph{Arguments}:
3552 @multitable @columnfractions .15 .80
3553 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
3554 @end multitable
3556 @item @emph{Return value}:
3557 The return value is of type @code{INTEGER(K)}, with @var{K} such that
3558 variables of type @code{INTEGER(K)} have the same size as
3559 C pointers (@code{sizeof(void *)}).
3561 @item @emph{Example}:
3562 The following example demonstrates the use of @code{MALLOC} and
3563 @code{FREE} with Cray pointers. This example is intended to run on
3564 32-bit systems, where the default integer kind is suitable to store
3565 pointers; on 64-bit systems, ptr_x would need to be declared as
3566 @code{integer(kind=8)}.
3568 @smallexample
3569 program test_malloc
3570   integer i
3571   integer ptr_x
3572   real*8 x(*), z
3573   pointer(ptr_x,x)
3575   ptr_x = malloc(20*8)
3576   do i = 1, 20
3577     x(i) = sqrt(1.0d0 / i)
3578   end do
3579   z = 0
3580   do i = 1, 20
3581     z = z + x(i)
3582     print *, z
3583   end do
3584   call free(ptr_x)
3585 end program test_malloc
3586 @end smallexample
3587 @end table
3591 @node MAXEXPONENT
3592 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
3593 @findex @code{MAXEXPONENT} intrinsic
3594 @cindex MAXEXPONENT
3596 @table @asis
3597 @item @emph{Description}:
3598 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
3599 type of @code{X}.
3601 @item @emph{Option}:
3602 f95, gnu
3604 @item @emph{Class}:
3605 elemental function
3607 @item @emph{Syntax}:
3608 @code{I = MAXEXPONENT(X)}
3610 @item @emph{Arguments}:
3611 @multitable @columnfractions .15 .80
3612 @item @var{X} @tab shall be of type @code{REAL}.
3613 @end multitable
3615 @item @emph{Return value}:
3616 The return value is of type @code{INTEGER} and of the default integer
3617 kind.
3619 @item @emph{Example}:
3620 @smallexample
3621 program exponents
3622   real(kind=4) :: x
3623   real(kind=8) :: y
3625   print *, minexponent(x), maxexponent(x)
3626   print *, minexponent(y), maxexponent(y)
3627 end program exponents
3628 @end smallexample
3629 @end table
3633 @node MINEXPONENT
3634 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
3635 @findex @code{MINEXPONENT} intrinsic
3636 @cindex MINEXPONENT
3638 @table @asis
3639 @item @emph{Description}:
3640 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
3641 type of @code{X}.
3643 @item @emph{Option}:
3644 f95, gnu
3646 @item @emph{Class}:
3647 elemental function
3649 @item @emph{Syntax}:
3650 @code{I = MINEXPONENT(X)}
3652 @item @emph{Arguments}:
3653 @multitable @columnfractions .15 .80
3654 @item @var{X} @tab shall be of type @code{REAL}.
3655 @end multitable
3657 @item @emph{Return value}:
3658 The return value is of type @code{INTEGER} and of the default integer
3659 kind.
3661 @item @emph{Example}:
3662 See @code{MAXEXPONENT} for an example.
3663 @end table
3667 @node MOD
3668 @section @code{MOD} --- Remainder function
3669 @findex @code{MOD} intrinsic
3670 @findex @code{AMOD} intrinsic
3671 @findex @code{DMOD} intrinsic
3672 @cindex remainder
3674 @table @asis
3675 @item @emph{Description}:
3676 @code{MOD(A,P)} computes the remainder of the division of A by P. It is
3677 calculated as @code{A - (INT(A/P) * P)}.
3679 @item @emph{Option}:
3680 f95, gnu
3682 @item @emph{Class}:
3683 elemental function
3685 @item @emph{Syntax}:
3686 @code{X = MOD(A,P)}
3688 @item @emph{Arguments}:
3689 @multitable @columnfractions .15 .80
3690 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
3691 @item @var{P} @tab shall be a scalar of the same type as @var{A} and not
3692 equal to zero
3693 @end multitable
3695 @item @emph{Return value}:
3696 The kind of the return value is the result of cross-promoting
3697 the kinds of the arguments.
3699 @item @emph{Example}:
3700 @smallexample
3701 program test_mod
3702   print *, mod(17,3)
3703   print *, mod(17.5,5.5)
3704   print *, mod(17.5d0,5.5)
3705   print *, mod(17.5,5.5d0)
3707   print *, mod(-17,3)
3708   print *, mod(-17.5,5.5)
3709   print *, mod(-17.5d0,5.5)
3710   print *, mod(-17.5,5.5d0)
3712   print *, mod(17,-3)
3713   print *, mod(17.5,-5.5)
3714   print *, mod(17.5d0,-5.5)
3715   print *, mod(17.5,-5.5d0)
3716 end program test_mod
3717 @end smallexample
3719 @item @emph{Specific names}:
3720 @multitable @columnfractions .24 .24 .24 .24
3721 @item Name             @tab Arguments      @tab Return type    @tab Option
3722 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab f95, gnu
3723 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
3724 @end multitable
3725 @end table
3729 @node MODULO
3730 @section @code{MODULO} --- Modulo function
3731 @findex @code{MODULO} intrinsic
3732 @cindex modulo
3734 @table @asis
3735 @item @emph{Description}:
3736 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
3738 @item @emph{Option}:
3739 f95, gnu
3741 @item @emph{Class}:
3742 elemental function
3744 @item @emph{Syntax}:
3745 @code{X = MODULO(A,P)}
3747 @item @emph{Arguments}:
3748 @multitable @columnfractions .15 .80
3749 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
3750 @item @var{P} @tab shall be a scalar of the same type and kind as @var{A}
3751 @end multitable
3753 @item @emph{Return value}:
3754 The type and kind of the result are those of the arguments.
3755 @table @asis
3756 @item If @var{A} and @var{P} are of type @code{INTEGER}:
3757 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
3758 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
3759 (exclusive).
3760 @item If @var{A} and @var{P} are of type @code{REAL}:
3761 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
3762 @end table
3763 In all cases, if @var{P} is zero the result is processor-dependent.
3765 @item @emph{Example}:
3766 @smallexample
3767 program test_mod
3768   print *, modulo(17,3)
3769   print *, modulo(17.5,5.5)
3771   print *, modulo(-17,3)
3772   print *, modulo(-17.5,5.5)
3774   print *, modulo(17,-3)
3775   print *, modulo(17.5,-5.5)
3776 end program test_mod
3777 @end smallexample
3779 @item @emph{Specific names}:
3780 @multitable @columnfractions .24 .24 .24 .24
3781 @item Name             @tab Arguments      @tab Return type    @tab Option
3782 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab f95, gnu
3783 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
3784 @end multitable
3785 @end table
3789 @node NEAREST
3790 @section @code{NEAREST} --- Nearest representable number
3791 @findex @code{NEAREST} intrinsic
3792 @cindex processor-representable number
3794 @table @asis
3795 @item @emph{Description}:
3796 @code{NEAREST(X, S)} returns the processor-representable number nearest
3797 to @code{X} in the direction indicated by the sign of @code{S}.
3799 @item @emph{Option}:
3800 f95, gnu
3802 @item @emph{Class}:
3803 elemental function
3805 @item @emph{Syntax}:
3806 @code{Y = NEAREST(X, S)}
3808 @item @emph{Arguments}:
3809 @multitable @columnfractions .15 .80
3810 @item @var{X} @tab shall be of type @code{REAL}.
3811 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
3812 not equal to zero.
3813 @end multitable
3815 @item @emph{Return value}:
3816 The return value is of the same type as @code{X}. If @code{S} is
3817 positive, @code{NEAREST} returns the processor-representable number
3818 greater than @code{X} and nearest to it. If @code{S} is negative,
3819 @code{NEAREST} returns the processor-representable number smaller than
3820 @code{X} and nearest to it.
3822 @item @emph{Example}:
3823 @smallexample
3824 program test_nearest
3825   real :: x, y
3826   x = nearest(42.0, 1.0)
3827   y = nearest(42.0, -1.0)
3828   write (*,"(3(G20.15))") x, y, x - y
3829 end program test_nearest
3830 @end smallexample
3831 @end table
3835 @node NINT
3836 @section @code{NINT} --- Nearest whole number
3837 @findex @code{NINT} intrinsic
3838 @findex @code{IDNINT} intrinsic
3839 @cindex whole number
3841 @table @asis
3842 @item @emph{Description}:
3843 @code{NINT(X)} rounds its argument to the nearest whole number.
3845 @item @emph{Option}:
3846 f95, gnu
3848 @item @emph{Class}:
3849 elemental function
3851 @item @emph{Syntax}:
3852 @code{X = NINT(X)}
3854 @item @emph{Arguments}:
3855 @multitable @columnfractions .15 .80
3856 @item @var{X}    @tab The type of the argument shall be @code{REAL}.
3857 @end multitable
3859 @item @emph{Return value}:
3860 Returns @var{A} with the fractional portion of its magnitude eliminated by
3861 rounding to the nearest whole number and with its sign preserved,
3862 converted to an @code{INTEGER} of the default kind.
3864 @item @emph{Example}:
3865 @smallexample
3866 program test_nint
3867   real(4) x4
3868   real(8) x8
3869   x4 = 1.234E0_4
3870   x8 = 4.321_8
3871   print *, nint(x4), idnint(x8)
3872 end program test_nint
3873 @end smallexample
3875 @item @emph{Specific names}:
3876 @multitable @columnfractions .33 .33 .33
3877 @item Name             @tab Argument         @tab Option
3878 @item @code{IDNINT(X)} @tab @code{REAL(8)} @tab f95, gnu
3879 @end multitable
3880 @end table
3884 @node PRECISION
3885 @section @code{PRECISION} --- Decimal precision of a real kind
3886 @findex @code{PRECISION} intrinsic
3887 @cindex PRECISION
3889 @table @asis
3890 @item @emph{Description}:
3891 @code{PRECISION(X)} returns the decimal precision in the model of the
3892 type of @code{X}.
3894 @item @emph{Option}:
3895 f95, gnu
3897 @item @emph{Class}:
3898 elemental function
3900 @item @emph{Syntax}:
3901 @code{I = PRECISION(X)}
3903 @item @emph{Arguments}:
3904 @multitable @columnfractions .15 .80
3905 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
3906 @end multitable
3908 @item @emph{Return value}:
3909 The return value is of type @code{INTEGER} and of the default integer
3910 kind.
3912 @item @emph{Example}:
3913 @smallexample
3914 program prec_and_range
3915   real(kind=4) :: x(2)
3916   complex(kind=8) :: y
3918   print *, precision(x), range(x)
3919   print *, precision(y), range(y)
3920 end program prec_and_range
3921 @end smallexample
3922 @end table
3926 @node RADIX
3927 @section @code{RADIX} --- Base of a model number
3928 @findex @code{RADIX} intrinsic
3929 @cindex base
3931 @table @asis
3932 @item @emph{Description}:
3933 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
3935 @item @emph{Option}:
3936 f95, gnu
3938 @item @emph{Class}:
3939 inquiry function
3941 @item @emph{Syntax}:
3942 @code{R = RADIX(X)}
3944 @item @emph{Arguments}:
3945 @multitable @columnfractions .15 .80
3946 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
3947 @end multitable
3949 @item @emph{Return value}:
3950 The return value is a scalar of type @code{INTEGER} and of the default
3951 integer kind.
3953 @item @emph{Example}:
3954 @smallexample
3955 program test_radix
3956   print *, "The radix for the default integer kind is", radix(0)
3957   print *, "The radix for the default real kind is", radix(0.0)
3958 end program test_radix
3959 @end smallexample
3961 @end table
3965 @node RAND
3966 @section @code{RAND} --- Real pseudo-random number
3967 @findex @code{RAND} intrinsic
3968 @findex @code{RAN} intrinsic
3969 @cindex random number
3971 @table @asis
3972 @item @emph{Description}:
3973 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
3974 distribution between 0 and 1. If @var{FLAG} is 0, the next number
3975 in the current sequence is returned; if @var{FLAG} is 1, the generator
3976 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
3977 it is used as a new seed with @code{SRAND}.
3979 @item @emph{Option}:
3982 @item @emph{Class}:
3983 non-elemental function
3985 @item @emph{Syntax}:
3986 @code{X = RAND(FLAG)}
3988 @item @emph{Arguments}:
3989 @multitable @columnfractions .15 .80
3990 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
3991 @end multitable
3993 @item @emph{Return value}:
3994 The return value is of @code{REAL} type and the default kind.
3996 @item @emph{Example}:
3997 @smallexample
3998 program test_rand
3999   integer,parameter :: seed = 86456
4000   
4001   call srand(seed)
4002   print *, rand(), rand(), rand(), rand()
4003   print *, rand(seed), rand(), rand(), rand()
4004 end program test_rand
4005 @end smallexample
4007 @item @emph{Note}:
4008 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
4009 provided as an alias for @code{RAND}.
4011 @end table
4015 @node RANGE
4016 @section @code{RANGE} --- Decimal exponent range of a real kind
4017 @findex @code{RANGE} intrinsic
4018 @cindex RANGE
4020 @table @asis
4021 @item @emph{Description}:
4022 @code{RANGE(X)} returns the decimal exponent range in the model of the
4023 type of @code{X}.
4025 @item @emph{Option}:
4026 f95, gnu
4028 @item @emph{Class}:
4029 elemental function
4031 @item @emph{Syntax}:
4032 @code{I = RANGE(X)}
4034 @item @emph{Arguments}:
4035 @multitable @columnfractions .15 .80
4036 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
4037 @end multitable
4039 @item @emph{Return value}:
4040 The return value is of type @code{INTEGER} and of the default integer
4041 kind.
4043 @item @emph{Example}:
4044 See @code{PRECISION} for an example.
4045 @end table
4049 @node REAL
4050 @section @code{REAL} --- Convert to real type 
4051 @findex @code{REAL} intrinsic
4052 @findex @code{REALPART} intrinsic
4053 @cindex true values
4055 @table @asis
4056 @item @emph{Description}:
4057 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type.  The
4058 @code{REALPART(X)} function is provided for compatibility with @command{g77},
4059 and its use is strongly discouraged.
4061 @item @emph{Option}:
4062 f95, gnu
4064 @item @emph{Class}:
4065 transformational function
4067 @item @emph{Syntax}:
4068 @multitable @columnfractions .30 .80
4069 @item @code{X = REAL(X)}
4070 @item @code{X = REAL(X, KIND)}
4071 @item @code{X = REALPART(Z)}
4072 @end multitable
4074 @item @emph{Arguments}:
4075 @multitable @columnfractions .15 .80
4076 @item @var{X} @tab shall be @code{INTEGER(*)}, @code{REAL(*)}, or  
4077 @code{COMPLEX(*)}.
4078 @item @var{KIND}  @tab (Optional) @var{KIND} shall be a scalar integer.
4079 @end multitable
4081 @item @emph{Return value}:
4082 These functions return the a @code{REAL(*)} variable or array under
4083 the following rules: 
4085 @table @asis
4086 @item (A)
4087 @code{REAL(X)} is converted to a default real type if @var{X} is an 
4088 integer or real variable.
4089 @item (B)
4090 @code{REAL(X)} is converted to a real type with the kind type parameter
4091 of @var{X} if @var{X} is a complex variable.
4092 @item (C)
4093 @code{REAL(X, KIND)} is converted to a real type with kind type
4094 parameter @var{KIND} if @var{X} is a complex, integer, or real
4095 variable.
4096 @end table
4098 @item @emph{Example}:
4099 @smallexample
4100 program test_real
4101   complex :: x = (1.0, 2.0)
4102   print *, real(x), real(x,8), realpart(x)
4103 end program test_real
4104 @end smallexample
4105 @end table
4109 @node RRSPACING
4110 @section @code{RRSPACING} --- Reciprocal of the relative spacing
4111 @findex @code{RRSPACING} intrinsic
4113 @table @asis
4114 @item @emph{Description}:
4115 @code{RRSPACING(X)} returns the  reciprocal of the relative spacing of
4116 model numbers near @var{X}.
4118 @item @emph{Option}:
4119 f95, gnu
4121 @item @emph{Class}:
4122 elemental function
4124 @item @emph{Syntax}:
4125 @code{Y = RRSPACING(X)}
4127 @item @emph{Arguments}:
4128 @multitable @columnfractions .15 .80
4129 @item @var{X} @tab shall be of type @code{REAL}.
4130 @end multitable
4132 @item @emph{Return value}:
4133 The return value is of the same type and kind as @var{X}.
4134 The value returned is equal to
4135 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
4137 @end table
4141 @node SCALE
4142 @section @code{SCALE} --- Scale a real value
4143 @findex @code{SCALE} intrinsic
4145 @table @asis
4146 @item @emph{Description}:
4147 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
4149 @item @emph{Option}:
4150 f95, gnu
4152 @item @emph{Class}:
4153 elemental function
4155 @item @emph{Syntax}:
4156 @code{Y = SCALE(X, I)}
4158 @item @emph{Arguments}:
4159 @multitable @columnfractions .15 .80
4160 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
4161 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
4162 @end multitable
4164 @item @emph{Return value}:
4165 The return value is of the same type and kind as @var{X}.
4166 Its value is @code{X * RADIX(X)**I}.
4168 @item @emph{Example}:
4169 @smallexample
4170 program test_scale
4171   real :: x = 178.1387e-4
4172   integer :: i = 5
4173   print *, scale(x,i), x*radix(x)**i
4174 end program test_scale
4175 @end smallexample
4177 @end table
4181 @node SELECTED_INT_KIND
4182 @section @code{SELECTED_INT_KIND} --- Choose integer kind
4183 @findex @code{SELECTED_INT_KIND} intrinsic
4184 @cindex integer kind
4186 @table @asis
4187 @item @emph{Description}:
4188 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
4189 type that can represent all values ranging from @math{-10^I} (exclusive)
4190 to @math{10^I} (exclusive). If there is no integer kind that accomodates
4191 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
4193 @item @emph{Option}:
4196 @item @emph{Class}:
4197 transformational function
4199 @item @emph{Syntax}:
4200 @multitable @columnfractions .30 .80
4201 @item @code{J = SELECTED_INT_KIND(I)}
4202 @end multitable
4204 @item @emph{Arguments}:
4205 @multitable @columnfractions .15 .80
4206 @item @var{I} @tab shall be a scalar and of type @code{INTEGER}.
4207 @end multitable
4209 @item @emph{Example}:
4210 @smallexample
4211 program large_integers
4212   integer,parameter :: k5 = selected_int_kind(5)
4213   integer,parameter :: k15 = selected_int_kind(15)
4214   integer(kind=k5) :: i5
4215   integer(kind=k15) :: i15
4217   print *, huge(i5), huge(i15)
4219   ! The following inequalities are always true
4220   print *, huge(i5) >= 10_k5**5-1
4221   print *, huge(i15) >= 10_k15**15-1
4222 end program large_integers
4223 @end smallexample
4224 @end table
4228 @node SELECTED_REAL_KIND
4229 @section @code{SELECTED_REAL_KIND} --- Choose real kind
4230 @findex @code{SELECTED_REAL_KIND} intrinsic
4231 @cindex real kind
4233 @table @asis
4234 @item @emph{Description}:
4235 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
4236 with decimal precision greater of at least @code{P} digits and exponent
4237 range greater at least @code{R}. 
4239 @item @emph{Option}:
4242 @item @emph{Class}:
4243 transformational function
4245 @item @emph{Syntax}:
4246 @multitable @columnfractions .30 .80
4247 @item @code{I = SELECTED_REAL_KIND(P,R)}
4248 @end multitable
4250 @item @emph{Arguments}:
4251 @multitable @columnfractions .15 .80
4252 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
4253 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
4254 @end multitable
4255 At least one argument shall be present.
4257 @item @emph{Return value}:
4259 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
4260 a real data type with decimal precision of at least @code{P} digits and a
4261 decimal exponent range of at least @code{R}. If more than one real data
4262 type meet the criteria, the kind of the data type with the smallest
4263 decimal precision is returned. If no real data type matches the criteria,
4264 the result is
4265 @table @asis
4266 @item -1 if the processor does not support a real data type with a
4267 precision greater than or equal to @code{P}
4268 @item -2 if the processor does not support a real type with an exponent
4269 range greater than or equal to @code{R}
4270 @item -3 if neither is supported.
4271 @end table
4273 @item @emph{Example}:
4274 @smallexample
4275 program real_kinds
4276   integer,parameter :: p6 = selected_real_kind(6)
4277   integer,parameter :: p10r100 = selected_real_kind(10,100)
4278   integer,parameter :: r400 = selected_real_kind(r=400)
4279   real(kind=p6) :: x
4280   real(kind=p10r100) :: y
4281   real(kind=r400) :: z
4283   print *, precision(x), range(x)
4284   print *, precision(y), range(y)
4285   print *, precision(z), range(z)
4286 end program real_kinds
4287 @end smallexample
4288 @end table
4292 @node SECNDS
4293 @section @code{SECNDS} --- Time subroutine
4294 @findex @code{SECNDS} intrinsic
4295 @cindex SECNDS
4297 @table @asis
4298 @item @emph{Description}:
4299 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
4300 @var{X} is a reference time, also in seconds. If this is zero, the time in
4301 seconds from midnight is returned. This function is non-standard and its
4302 use is discouraged.
4304 @item @emph{Option}:
4307 @item @emph{Class}:
4308 function
4310 @item @emph{Syntax}:
4311 @code{T = SECNDS (X)}
4313 @item @emph{Arguments}:
4314 @multitable @columnfractions .15 .80
4315 @item Name        @tab Type
4316 @item @var{T}     @tab REAL(4)
4317 @item @var{X}     @tab REAL(4)
4318 @end multitable
4320 @item @emph{Return value}:
4321 None
4323 @item @emph{Example}:
4324 @smallexample
4325 program test_secnds
4326     real(4) :: t1, t2
4327     print *, secnds (0.0)   ! seconds since midnight
4328     t1 = secnds (0.0)       ! reference time
4329     do i = 1, 10000000      ! do something
4330     end do
4331     t2 = secnds (t1)        ! elapsed time
4332     print *, "Something took ", t2, " seconds."
4333 end program test_secnds
4334 @end smallexample
4335 @end table
4339 @node SET_EXPONENT
4340 @section @code{SET_EXPONENT} --- Set the exponent of the model
4341 @findex @code{SET_EXPONENT} intrinsic
4342 @cindex exponent
4344 @table @asis
4345 @item @emph{Description}:
4346 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
4347 is that that of @var{X} and whose exponent part if @var{I}.
4349 @item @emph{Option}:
4350 f95, gnu
4352 @item @emph{Class}:
4353 elemental function
4355 @item @emph{Syntax}:
4356 @code{Y = SET_EXPONENT(X, I)}
4358 @item @emph{Arguments}:
4359 @multitable @columnfractions .15 .80
4360 @item @var{X} @tab shall be of type @code{REAL}.
4361 @item @var{I} @tab shall be of type @code{INTEGER}.
4362 @end multitable
4364 @item @emph{Return value}:
4365 The return value is of the same type and kind as @var{X}.
4366 The real number whose fractional part
4367 is that that of @var{X} and whose exponent part if @var{I} is returned;
4368 it is @code{FRACTION(X) * RADIX(X)**I}.
4370 @item @emph{Example}:
4371 @smallexample
4372 program test_setexp
4373   real :: x = 178.1387e-4
4374   integer :: i = 17
4375   print *, set_exponent(x), fraction(x) * radix(x)**i
4376 end program test_setexp
4377 @end smallexample
4379 @end table
4383 @node SIGN
4384 @section @code{SIGN} --- Sign copying function
4385 @findex @code{SIGN} intrinsic
4386 @findex @code{ISIGN} intrinsic
4387 @findex @code{DSIGN} intrinsic
4388 @cindex sign copying
4390 @table @asis
4391 @item @emph{Description}:
4392 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
4394 @item @emph{Option}:
4395 f95, gnu
4397 @item @emph{Class}:
4398 elemental function
4400 @item @emph{Syntax}:
4401 @code{X = SIGN(A,B)}
4403 @item @emph{Arguments}:
4404 @multitable @columnfractions .15 .80
4405 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
4406 @item @var{B} @tab shall be a scalar of the same type and kind as @var{A}
4407 @end multitable
4409 @item @emph{Return value}:
4410 The kind of the return value is that of @var{A} and @var{B}.
4411 If @math{B\ge 0} then the result is @code{ABS(A)}, else
4412 it is @code{-ABS(A)}.
4414 @item @emph{Example}:
4415 @smallexample
4416 program test_sign
4417   print *, sign(-12,1)
4418   print *, sign(-12,0)
4419   print *, sign(-12,-1)
4421   print *, sign(-12.,1.)
4422   print *, sign(-12.,0.)
4423   print *, sign(-12.,-1.)
4424 end program test_sign
4425 @end smallexample
4427 @item @emph{Specific names}:
4428 @multitable @columnfractions .24 .24 .24 .24
4429 @item Name              @tab Arguments      @tab Return type    @tab Option
4430 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
4431 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
4432 @end multitable
4433 @end table
4437 @node SIGNAL
4438 @section @code{SIGNAL} --- Signal handling subroutine (or function)
4439 @findex @code{SIGNAL} intrinsic
4440 @cindex SIGNAL subroutine 
4442 @table @asis
4443 @item @emph{Description}:
4444 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
4445 @var{HANDLER} to be executed with a single integer argument when signal
4446 @var{NUMBER} occurs.  If @var{HANDLER} is an integer, it can be used to
4447 turn off handling of signal @var{NUMBER} or revert to its default
4448 action.  See @code{signal(2)}.
4450 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
4451 is supplied, it is set to the value returned by @code{signal(2)}.
4453 @item @emph{Option}:
4456 @item @emph{Class}:
4457 subroutine, non-elemental function
4459 @item @emph{Syntax}:
4460 @multitable @columnfractions .30 .80
4461 @item @code{CALL ALARM(NUMBER, HANDLER)}
4462 @item @code{CALL ALARM(NUMBER, HANDLER, STATUS)}
4463 @item @code{STATUS = ALARM(NUMBER, HANDLER)}
4464 @end multitable
4466 @item @emph{Arguments}:
4467 @multitable @columnfractions .15 .80
4468 @item @var{NUMBER} @tab shall be a scalar integer, with @code{INTENT(IN)}
4469 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
4470 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
4471 @code{INTEGER}. It is @code{INTENT(IN)}.
4472 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
4473 integer. It has @code{INTENT(OUT)}.
4474 @end multitable
4476 @item @emph{Return value}:
4477 The @code{SIGNAL} functions returns the value returned by @code{signal(2)}.
4479 @item @emph{Example}:
4480 @smallexample
4481 program test_signal
4482   intrinsic signal
4483   external handler_print
4485   call signal (12, handler_print)
4486   call signal (10, 1)
4488   call sleep (30)
4489 end program test_signal
4490 @end smallexample
4491 @end table
4496 @node SIN
4497 @section @code{SIN} --- Sine function 
4498 @findex @code{SIN} intrinsic
4499 @findex @code{DSIN} intrinsic
4500 @findex @code{ZSIN} intrinsic
4501 @findex @code{CDSIN} intrinsic
4502 @cindex sine
4504 @table @asis
4505 @item @emph{Description}:
4506 @code{SIN(X)} computes the sine of @var{X}.
4508 @item @emph{Option}:
4509 f95, gnu
4511 @item @emph{Class}:
4512 elemental function
4514 @item @emph{Syntax}:
4515 @code{X = SIN(X)}
4517 @item @emph{Arguments}:
4518 @multitable @columnfractions .15 .80
4519 @item @var{X} @tab The type shall be @code{REAL(*)} or
4520 @code{COMPLEX(*)}.
4521 @end multitable
4523 @item @emph{Return value}:
4524 The return value has same type and king than @var{X}.
4526 @item @emph{Example}:
4527 @smallexample
4528 program test_sin
4529   real :: x = 0.0
4530   x = sin(x)
4531 end program test_sin
4532 @end smallexample
4534 @item @emph{Specific names}:
4535 @multitable @columnfractions .24 .24 .24 .24
4536 @item Name            @tab Argument          @tab Return type       @tab Option
4537 @item @code{DSIN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
4538 @item @code{CSIN(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
4539 @item @code{ZSIN(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
4540 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
4541 @end multitable
4542 @end table
4546 @node SINH
4547 @section @code{SINH} --- Hyperbolic sine function 
4548 @findex @code{SINH} intrinsic
4549 @findex @code{DSINH} intrinsic
4550 @cindex hyperbolic sine
4552 @table @asis
4553 @item @emph{Description}:
4554 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
4556 @item @emph{Option}:
4557 f95, gnu
4559 @item @emph{Class}:
4560 elemental function
4562 @item @emph{Syntax}:
4563 @code{X = SINH(X)}
4565 @item @emph{Arguments}:
4566 @multitable @columnfractions .15 .80
4567 @item @var{X} @tab The type shall be @code{REAL(*)}.
4568 @end multitable
4570 @item @emph{Return value}:
4571 The return value is of type @code{REAL(*)}.
4573 @item @emph{Example}:
4574 @smallexample
4575 program test_sinh
4576   real(8) :: x = - 1.0_8
4577   x = sinh(x)
4578 end program test_sinh
4579 @end smallexample
4581 @item @emph{Specific names}:
4582 @multitable @columnfractions .24 .24 .24 .24
4583 @item Name            @tab Argument          @tab Return type       @tab Option
4584 @item @code{DSINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
4585 @end multitable
4586 @end table
4590 @node SNGL
4591 @section @code{SNGL} --- Convert double precision real to default real
4592 @findex @code{SNGL} intrinsic
4593 @cindex sngl
4595 @table @asis
4596 @item @emph{Description}:
4597 @code{SNGL(A)} converts the double precision real @var{A}
4598 to a default real value. This is an archaic form of @code{REAL}
4599 that is specific to one type for @var{A}.
4601 @item @emph{Option}:
4604 @item @emph{Class}:
4605 function
4607 @item @emph{Syntax}:
4608 @code{X = SNGL(A)}
4610 @item @emph{Arguments}:
4611 @multitable @columnfractions .15 .80
4612 @item @var{A} @tab The type shall be a double precision @code{REAL}.
4613 @end multitable
4615 @item @emph{Return value}:
4616 The return value is of type default @code{REAL}.
4618 @end table
4622 @node SQRT
4623 @section @code{SQRT} --- Square-root function
4624 @findex @code{SQRT} intrinsic
4625 @findex @code{DSQRT} intrinsic
4626 @findex @code{CSQRT} intrinsic
4627 @findex @code{ZSQRT} intrinsic
4628 @findex @code{CDSQRT} intrinsic
4629 @cindex square-root
4631 @table @asis
4632 @item @emph{Description}:
4633 @code{SQRT(X)} computes the square root of @var{X}.
4635 @item @emph{Option}:
4636 f95, gnu
4638 @item @emph{Class}:
4639 elemental function
4641 @item @emph{Syntax}:
4642 @code{X = SQRT(X)}
4644 @item @emph{Arguments}:
4645 @multitable @columnfractions .15 .80
4646 @item @var{X} @tab The type shall be @code{REAL(*)} or
4647 @code{COMPLEX(*)}.
4648 @end multitable
4650 @item @emph{Return value}:
4651 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
4652 The kind type parameter is the same as @var{X}.
4654 @item @emph{Example}:
4655 @smallexample
4656 program test_sqrt
4657   real(8) :: x = 2.0_8
4658   complex :: z = (1.0, 2.0)
4659   x = sqrt(x)
4660   z = sqrt(z)
4661 end program test_sqrt
4662 @end smallexample
4664 @item @emph{Specific names}:
4665 @multitable @columnfractions .24 .24 .24 .24
4666 @item Name            @tab Argument          @tab Return type       @tab Option
4667 @item @code{DSQRT(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
4668 @item @code{CSQRT(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
4669 @item @code{ZSQRT(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
4670 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
4671 @end multitable
4672 @end table
4676 @node SRAND
4677 @section @code{SRAND} --- Reinitialize the random number generator
4678 @findex @code{SRAND} intrinsic
4679 @cindex random number
4681 @table @asis
4682 @item @emph{Description}:
4683 @code{SRAND} reinitializes the pseudo-random number generator
4684 called by @code{RAND} and @code{IRAND}. The new seed used by the
4685 generator is specified by the required argument @var{SEED}.
4687 @item @emph{Option}:
4690 @item @emph{Class}:
4691 non-elemental subroutine
4693 @item @emph{Syntax}:
4694 @code{CALL SRAND(SEED)}
4696 @item @emph{Arguments}:
4697 @multitable @columnfractions .15 .80
4698 @item @var{SEED} @tab shall be a scalar @code{INTEGER(kind=4)}.
4699 @end multitable
4701 @item @emph{Return value}:
4702 Does not return.
4704 @item @emph{Example}:
4705 See @code{RAND} and @code{IRAND} for examples.
4707 @item @emph{Notes}:
4708 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
4709 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
4710 to generate pseudo-random numbers. Please note that in
4711 @command{gfortran}, these two sets of intrinsics (@code{RAND},
4712 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
4713 @code{RANDOM_SEED} on the other hand) access two independent
4714 pseudo-random numbers generators.
4716 @end table
4720 @node TAN
4721 @section @code{TAN} --- Tangent function
4722 @findex @code{TAN} intrinsic
4723 @findex @code{DTAN} intrinsic
4724 @cindex tangent
4726 @table @asis
4727 @item @emph{Description}:
4728 @code{TAN(X)} computes the tangent of @var{X}.
4730 @item @emph{Option}:
4731 f95, gnu
4733 @item @emph{Class}:
4734 elemental function
4736 @item @emph{Syntax}:
4737 @code{X = TAN(X)}
4739 @item @emph{Arguments}:
4740 @multitable @columnfractions .15 .80
4741 @item @var{X} @tab The type shall be @code{REAL(*)}.
4742 @end multitable
4744 @item @emph{Return value}:
4745 The return value is of type @code{REAL(*)}.  The kind type parameter is
4746 the same as @var{X}.
4748 @item @emph{Example}:
4749 @smallexample
4750 program test_tan
4751   real(8) :: x = 0.165_8
4752   x = tan(x)
4753 end program test_tan
4754 @end smallexample
4756 @item @emph{Specific names}:
4757 @multitable @columnfractions .24 .24 .24 .24
4758 @item Name            @tab Argument          @tab Return type       @tab Option
4759 @item @code{DTAN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
4760 @end multitable
4761 @end table
4765 @node TANH
4766 @section @code{TANH} --- Hyperbolic tangent function 
4767 @findex @code{TANH} intrinsic
4768 @findex @code{DTANH} intrinsic
4769 @cindex hyperbolic tangent
4771 @table @asis
4772 @item @emph{Description}:
4773 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
4775 @item @emph{Option}:
4776 f95, gnu
4778 @item @emph{Class}:
4779 elemental function
4781 @item @emph{Syntax}:
4782 @code{X = TANH(X)}
4784 @item @emph{Arguments}:
4785 @multitable @columnfractions .15 .80
4786 @item @var{X} @tab The type shall be @code{REAL(*)}.
4787 @end multitable
4789 @item @emph{Return value}:
4790 The return value is of type @code{REAL(*)} and lies in the range
4791 @math{ - 1 \leq tanh(x) \leq 1 }.
4793 @item @emph{Example}:
4794 @smallexample
4795 program test_tanh
4796   real(8) :: x = 2.1_8
4797   x = tanh(x)
4798 end program test_tanh
4799 @end smallexample
4801 @item @emph{Specific names}:
4802 @multitable @columnfractions .24 .24 .24 .24
4803 @item Name            @tab Argument          @tab Return type       @tab Option
4804 @item @code{DTANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
4805 @end multitable
4806 @end table
4810 @node TINY
4811 @section @code{TINY} --- Smallest positive number of a real kind
4812 @findex @code{TINY} intrinsic
4813 @cindex tiny
4815 @table @asis
4816 @item @emph{Description}:
4817 @code{TINY(X)} returns the smallest positive (non zero) number
4818 in the model of the type of @code{X}.
4820 @item @emph{Option}:
4821 f95, gnu
4823 @item @emph{Class}:
4824 elemental function
4826 @item @emph{Syntax}:
4827 @code{Y = TINY(X)}
4829 @item @emph{Arguments}:
4830 @multitable @columnfractions .15 .80
4831 @item @var{X} @tab shall be of type @code{REAL}.
4832 @end multitable
4834 @item @emph{Return value}:
4835 The return value is of the same type and kind as @var{X}
4837 @item @emph{Example}:
4838 See @code{HUGE} for an example.
4839 @end table
4843 @comment gen   fstat
4844 @comment sub   fstat
4845 @comment 
4846 @comment sub   getarg
4847 @comment 
4848 @comment gen   getcwd
4849 @comment sub   getcwd
4850 @comment 
4851 @comment sub   getenv
4852 @comment 
4853 @comment sub   get_command
4854 @comment 
4855 @comment sub   get_command_argument
4856 @comment 
4857 @comment sub   get_environment_variable
4858 @comment 
4859 @comment gen   iand
4860 @comment 
4861 @comment gen   iargc
4862 @comment 
4863 @comment gen   ibclr
4864 @comment 
4865 @comment gen   ibits
4866 @comment 
4867 @comment gen   ibset
4868 @comment 
4869 @comment gen   ieor
4870 @comment 
4871 @comment gen   index
4872 @comment 
4873 @comment gen   int
4874 @comment       ifix
4875 @comment       idint
4876 @comment 
4877 @comment gen   ior
4878 @comment 
4879 @comment gen   ishft
4880 @comment 
4881 @comment gen   ishftc
4882 @comment 
4883 @comment gen   lbound
4884 @comment 
4885 @comment gen   len
4886 @comment 
4887 @comment gen   len_trim
4888 @comment 
4889 @comment gen   lge
4890 @comment 
4891 @comment gen   lgt
4892 @comment 
4893 @comment gen   lle
4894 @comment 
4895 @comment gen   llt
4896 @comment 
4897 @comment gen   logical
4898 @comment 
4899 @comment gen   matmul
4900 @comment 
4901 @comment gen   max
4902 @comment       max0
4903 @comment       amax0
4904 @comment       amax1
4905 @comment       max1
4906 @comment       dmax1
4907 @comment 
4908 @comment gen   maxloc
4909 @comment 
4910 @comment gen   maxval
4911 @comment 
4912 @comment gen   merge
4913 @comment 
4914 @comment gen   min
4915 @comment       min0
4916 @comment       amin0
4917 @comment       amin1
4918 @comment       min1
4919 @comment       dmin1
4920 @comment 
4921 @comment gen   minloc
4922 @comment 
4923 @comment gen   minval
4924 @comment 
4925 @comment sub   mvbits
4926 @comment 
4927 @comment gen   not
4928 @comment 
4929 @comment gen   null
4930 @comment 
4931 @comment gen   pack
4932 @comment 
4933 @comment gen   perror
4934 @comment 
4935 @comment gen   present
4936 @comment 
4937 @comment gen   product
4938 @comment 
4939 @comment sub   random_number
4940 @comment 
4941 @comment sub   random_seed
4942 @comment 
4943 @comment gen   repeat
4944 @comment 
4945 @comment gen   reshape
4946 @comment 
4947 @comment gen   scan
4948 @comment 
4949 @comment gen   second
4950 @comment sub   second
4951 @comment 
4952 @comment gen   shape
4953 @comment 
4954 @comment gen   size
4955 @comment 
4956 @comment gen   spacing
4957 @comment 
4958 @comment gen   spread
4959 @comment 
4960 @comment gen   stat
4961 @comment sub   stat
4962 @comment 
4963 @comment gen   sum
4964 @comment 
4965 @comment gen   system
4966 @comment sub   system
4967 @comment 
4968 @comment sub system_clock
4969 @comment 
4970 @comment gen   transfer
4971 @comment 
4972 @comment gen   transpose
4973 @comment 
4974 @comment gen   trim
4975 @comment 
4976 @comment gen   ubound
4977 @comment 
4978 @comment gen   umask
4979 @comment sub   umask
4980 @comment 
4981 @comment gen   unlink
4982 @comment sub   unlink
4983 @comment 
4984 @comment gen   unpack
4985 @comment 
4986 @comment gen   verify