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.
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.
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
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.
180 @section @code{ABORT} --- Abort the program
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.
194 non-elemental subroutine
199 @item @emph{Return value}:
202 @item @emph{Example}:
205 integer :: i = 1, j = 2
206 if (i /= j) call abort
207 end program test_abort
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
224 @item @emph{Description}:
225 @code{ABS(X)} computes the absolute value of @code{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(*)}.
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}:
252 complex :: z = (-1.e0,0.e0)
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
273 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
274 @findex @code{ACHAR} intrinsic
275 @cindex @acronym{ASCII} collating sequence
278 @item @emph{Description}:
279 @code{ACHAR(I)} returns the character located at position @code{I}
280 in the @acronym{ASCII} collating sequence.
291 @item @emph{Arguments}:
292 @multitable @columnfractions .15 .80
293 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
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}:
305 end program test_achar
312 @section @code{ACOS} --- Arc cosine function
313 @findex @code{ACOS} intrinsic
314 @findex @code{DACOS} intrinsic
318 @item @emph{Description}:
319 @code{ACOS(X)} computes the arc cosine of @var{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
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}:
344 real(8) :: x = 0.866_8
346 end program test_acos
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
359 @section @code{ADJUSTL} --- Left adjust a string
360 @findex @code{ADJUSTL} intrinsic
361 @cindex adjust string
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.
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}.
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
387 @item @emph{Example}:
390 character(len=20) :: str = ' gfortran'
393 end program test_adjustl
400 @section @code{ADJUSTR} --- Right adjust a string
401 @findex @code{ADJUSTR} intrinsic
402 @cindex adjust string
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.
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}.
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
428 @item @emph{Example}:
431 character(len=20) :: str = 'gfortran'
434 end program test_adjustr
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
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.
464 @item @emph{Arguments}:
465 @multitable @columnfractions .15 .80
466 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
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}:
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
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
496 @section @code{AINT} --- Imaginary part of complex number
497 @findex @code{AINT} intrinsic
498 @findex @code{DINT} intrinsic
502 @item @emph{Description}:
503 @code{AINT(X [, KIND])} truncates its argument to a whole number.
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.
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}:
538 print *, aint(x4), dint(x8)
540 end program test_aint
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
553 @section @code{ALARM} --- Execute a routine after a given delay
554 @findex @code{ALARM} intrinsic
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.
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)}.
586 @item @emph{Example}:
589 external handler_print
591 call alarm (3, handler_print, i)
594 end program test_alarm
596 This will cause the external routine @var{handler_print} to be called
603 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
604 @findex @code{ALL} intrinsic
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}.
616 transformational function
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}.
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.
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.
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.
647 @item @emph{Example}:
651 l = all((/.true., .true., .true./))
656 integer a(2,3), b(2,3)
660 print *, all(a .eq. b, 1)
661 print *, all(a .eq. b, 2)
662 end subroutine section
670 @section @code{ALLOCATED} --- Status of an allocatable entity
671 @findex @code{ALLOCATED} intrinsic
672 @cindex allocation status
675 @item @emph{Description}:
676 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
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.
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}:
699 program test_allocated
701 real(4), allocatable :: x(:)
702 if (allocated(x) .eqv. .false.) allocate(x(i)
703 end program test_allocated
710 @section @code{ANINT} --- Nearest whole number
711 @findex @code{ANINT} intrinsic
712 @findex @code{DNINT} intrinsic
716 @item @emph{Description}:
717 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
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.
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}:
750 print *, anint(x4), dnint(x8)
752 end program test_anint
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
765 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
766 @findex @code{ANY} intrinsic
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.}.
778 transformational function
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}.
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.
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.
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.
809 @item @emph{Example}:
813 l = any((/.true., .true., .true./))
818 integer a(2,3), b(2,3)
822 print *, any(a .eq. b, 1)
823 print *, any(a .eq. b, 2)
824 end subroutine section
832 @section @code{ASIN} --- Arcsine function
833 @findex @code{ASIN} intrinsic
834 @findex @code{DASIN} intrinsic
838 @item @emph{Description}:
839 @code{ASIN(X)} computes the arcsine of its @var{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
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}:
864 real(8) :: x = 0.866_8
866 end program test_asin
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
879 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
880 @findex @code{ASSOCIATED} intrinsic
881 @cindex pointer status
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}.
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}.
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:
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
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
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.
936 @item @emph{Example}:
938 program test_associated
940 real, target :: tgt(2) = (/1., 2./)
941 real, pointer :: ptr(:)
943 if (associated(ptr) .eqv. .false.) call abort
944 if (associated(ptr,tgt) .eqv. .false.) call abort
945 end program test_associated
952 @section @code{ATAN} --- Arctangent function
953 @findex @code{ATAN} intrinsic
954 @findex @code{DATAN} intrinsic
958 @item @emph{Description}:
959 @code{ATAN(X)} computes the arctangent of @var{X}.
970 @item @emph{Arguments}:
971 @multitable @columnfractions .15 .80
972 @item @var{X} @tab The type shall be @code{REAL(*)}.
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}:
982 real(8) :: x = 2.866_8
984 end program test_atan
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
997 @section @code{ATAN2} --- Arctangent function
998 @findex @code{ATAN2} intrinsic
999 @findex @code{DATAN2} intrinsic
1003 @item @emph{Description}:
1004 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
1006 @item @emph{Option}:
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.
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
1031 @item @emph{Example}:
1034 real(4) :: x = 1.e0_4, y = 0.5e0_4
1036 end program test_atan2
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
1049 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1050 @findex @code{BESJ0} intrinsic
1051 @findex @code{DBESJ0} intrinsic
1055 @item @emph{Description}:
1056 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1059 @item @emph{Option}:
1065 @item @emph{Syntax}:
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.
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}:
1080 real(8) :: x = 0.0_8
1082 end program test_besj0
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
1095 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1096 @findex @code{BESJ1} intrinsic
1097 @findex @code{DBESJ1} intrinsic
1101 @item @emph{Description}:
1102 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1105 @item @emph{Option}:
1111 @item @emph{Syntax}:
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.
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}:
1126 real(8) :: x = 1.0_8
1128 end program test_besj1
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
1141 @section @code{BESJN} --- Bessel function of the first kind
1142 @findex @code{BESJN} intrinsic
1143 @findex @code{DBESJN} intrinsic
1147 @item @emph{Description}:
1148 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1151 @item @emph{Option}:
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.
1166 @item @emph{Return value}:
1167 The return value is a scalar of type @code{REAL(*)}.
1169 @item @emph{Example}:
1172 real(8) :: x = 1.0_8
1174 end program test_besjn
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
1188 @section @code{BESY0} --- Bessel function of the second kind of order 0
1189 @findex @code{BESY0} intrinsic
1190 @findex @code{DBESY0} intrinsic
1194 @item @emph{Description}:
1195 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1198 @item @emph{Option}:
1204 @item @emph{Syntax}:
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.
1212 @item @emph{Return value}:
1213 The return value is a scalar of type @code{REAL(*)}.
1215 @item @emph{Example}:
1218 real(8) :: x = 0.0_8
1220 end program test_besy0
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
1233 @section @code{BESY1} --- Bessel function of the second kind of order 1
1234 @findex @code{BESY1} intrinsic
1235 @findex @code{DBESY1} intrinsic
1239 @item @emph{Description}:
1240 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1243 @item @emph{Option}:
1249 @item @emph{Syntax}:
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.
1257 @item @emph{Return value}:
1258 The return value is a scalar of type @code{REAL(*)}.
1260 @item @emph{Example}:
1263 real(8) :: x = 1.0_8
1265 end program test_besy1
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
1278 @section @code{BESYN} --- Bessel function of the second kind
1279 @findex @code{BESYN} intrinsic
1280 @findex @code{DBESYN} intrinsic
1284 @item @emph{Description}:
1285 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1288 @item @emph{Option}:
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.
1303 @item @emph{Return value}:
1304 The return value is a scalar of type @code{REAL(*)}.
1306 @item @emph{Example}:
1309 real(8) :: x = 1.0_8
1311 end program test_besyn
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
1325 @section @code{BIT_SIZE} --- Bit size inquiry function
1326 @findex @code{BIT_SIZE} intrinsic
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}:
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(*)}.
1348 @item @emph{Return value}:
1349 The return value is of type @code{INTEGER(*)}
1351 @item @emph{Example}:
1353 program test_bit_size
1358 end program test_bit_size
1365 @section @code{BTEST} --- Bit test function
1366 @findex @code{BTEST} intrinsic
1370 @item @emph{Description}:
1371 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1374 @item @emph{Option}:
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(*)}.
1389 @item @emph{Return value}:
1390 The return value is of type @code{LOGICAL}
1392 @item @emph{Example}:
1395 integer :: i = 32768 + 1024 + 64
1399 bool = btest(i, pos)
1402 end program test_btest
1409 @section @code{CEILING} --- Integer ceiling function
1410 @findex @code{CEILING} intrinsic
1414 @item @emph{Description}:
1415 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1417 @item @emph{Option}:
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.
1432 @item @emph{Return value}:
1433 The return value is of type @code{INTEGER(KIND)}
1435 @item @emph{Example}:
1437 program test_ceiling
1440 print *, ceiling(x) ! returns 64
1441 print *, ceiling(y) ! returns -63
1442 end program test_ceiling
1449 @section @code{CHAR} --- Character conversion function
1450 @findex @code{CHAR} intrinsic
1454 @item @emph{Description}:
1455 @code{CHAR(I,[KIND])} returns the character represented by the integer @var{I}.
1457 @item @emph{Option}:
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.
1472 @item @emph{Return value}:
1473 The return value is of type @code{CHARACTER(1)}
1475 @item @emph{Example}:
1481 print *, i, c ! returns 'J'
1482 end program test_char
1489 @section @code{CMPLX} --- Complex conversion function
1490 @findex @code{CMPLX} intrinsic
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}:
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.
1516 @item @emph{Return value}:
1517 The return value is of type @code{COMPLEX(*)}
1519 @item @emph{Example}:
1526 print *, z, cmplx(x)
1527 end program test_cmplx
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
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}:
1547 non-elemental function
1549 @item @emph{Syntax}:
1550 @code{I = COMMAND_ARGUMENT_COUNT()}
1552 @item @emph{Arguments}:
1553 @multitable @columnfractions .15 .80
1557 @item @emph{Return value}:
1558 The return value is of type @code{INTEGER(4)}
1560 @item @emph{Example}:
1562 program test_command_argument_count
1564 count = command_argument_count()
1566 end program test_command_argument_count
1573 @section @code{CONJG} --- Complex conjugate function
1574 @findex @code{CONJG} intrinsic
1575 @findex @code{DCONJG} intrinsic
1576 @cindex complex conjugate
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}:
1588 @item @emph{Syntax}:
1591 @item @emph{Arguments}:
1592 @multitable @columnfractions .15 .80
1593 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
1596 @item @emph{Return value}:
1597 The return value is of type @code{COMPLEX(*)}.
1599 @item @emph{Example}:
1602 complex :: z = (2.0, 3.0)
1603 complex(8) :: dz = (2.71_8, -3.14_8)
1608 end program test_conjg
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
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
1629 @item @emph{Description}:
1630 @code{COS(X)} computes the cosine of @var{X}.
1632 @item @emph{Option}:
1638 @item @emph{Syntax}:
1641 @item @emph{Arguments}:
1642 @multitable @columnfractions .15 .80
1643 @item @var{X} @tab The type shall be @code{REAL(*)} or
1647 @item @emph{Return value}:
1648 The return value has the same type and kind as @var{X}.
1650 @item @emph{Example}:
1655 end program test_cos
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
1671 @section @code{COSH} --- Hyperbolic cosine function
1672 @findex @code{COSH} intrinsic
1673 @findex @code{DCOSH} intrinsic
1674 @cindex hyperbolic cosine
1677 @item @emph{Description}:
1678 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
1680 @item @emph{Option}:
1686 @item @emph{Syntax}:
1689 @item @emph{Arguments}:
1690 @multitable @columnfractions .15 .80
1691 @item @var{X} @tab The type shall be @code{REAL(*)}.
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}:
1701 real(8) :: x = 1.0_8
1703 end program test_cosh
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
1716 @section @code{COUNT} --- Count function
1717 @findex @code{COUNT} intrinsic
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}:
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}.
1742 @item @emph{Return value}:
1743 The return value is of type @code{INTEGER} with rank equal to that of
1746 @item @emph{Example}:
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,:)
1756 print '(3i3)', b(1,:)
1757 print '(3i3)', b(2,:)
1760 print '(3l3)', mask(1,:)
1761 print '(3l3)', mask(2,:)
1763 print '(3i3)', count(mask)
1765 print '(3i3)', count(mask, 1)
1767 print '(3i3)', count(mask, 2)
1768 end program test_count
1775 @section @code{CPU_TIME} --- CPU elapsed time in seconds
1776 @findex @code{CPU_TIME} intrinsic
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}:
1790 @item @emph{Syntax}:
1793 @item @emph{Arguments}:
1794 @multitable @columnfractions .15 .80
1795 @item @var{X} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
1798 @item @emph{Return value}:
1801 @item @emph{Example}:
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
1816 @section @code{CSHIFT} --- Circular shift function
1817 @findex @code{CSHIFT} intrinsic
1818 @cindex cshift intrinsic
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}:
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}.
1847 @item @emph{Return value}:
1848 Returns an array of same type and rank as the @var{ARRAY} argument.
1850 @item @emph{Example}:
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)
1860 print '(3i3)', a(1,:)
1861 print '(3i3)', a(2,:)
1862 print '(3i3)', a(3,:)
1863 end program test_cshift
1869 @section @code{CTIME} --- Convert a time into a string
1870 @findex @code{CTIME} intrinsic
1871 @cindex ctime subroutine
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}:
1891 @item @emph{Syntax}:
1892 @multitable @columnfractions .80
1893 @item @code{CALL CTIME(T,S)}.
1894 @item @code{S = CTIME(T)}, (not recommended).
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)}.
1903 @item @emph{Return value}:
1904 The converted date and time as a string.
1906 @item @emph{Example}:
1910 character(len=30) :: date
1913 ! Do something, main part of the program
1916 print *, 'Program was started on ', date
1917 end program test_ctime
1922 @section @code{DATE_AND_TIME} --- Date and time subroutine
1923 @findex @code{DATE_AND_TIME} intrinsic
1924 @cindex DATE_AND_TIME
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
1948 @item @emph{Option}:
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)}.
1965 @item @emph{Return value}:
1968 @item @emph{Example}:
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
1989 @section @code{DBLE} --- Double conversion function
1990 @findex @code{DBLE} intrinsic
1991 @cindex double conversion
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}:
2004 @item @emph{Syntax}:
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(*)}.
2013 @item @emph{Return value}:
2014 The return value is of type double precision real.
2016 @item @emph{Example}:
2021 complex :: z = (2.3,1.14)
2022 print *, dble(x), dble(i), dfloat(z)
2023 end program test_dble
2030 @section @code{DCMPLX} --- Double complex conversion function
2031 @findex @code{DCMPLX} intrinsic
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}:
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(*)}.
2057 @item @emph{Return value}:
2058 The return value is of type @code{COMPLEX(8)}
2060 @item @emph{Example}:
2070 print *, dcmplx(x,i)
2071 end program test_dcmplx
2078 @section @code{DFLOAT} --- Double conversion function
2079 @findex @code{DFLOAT} intrinsic
2080 @cindex double float conversion
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}.
2091 @section @code{DIGITS} --- Significant digits function
2092 @findex @code{DIGITS} intrinsic
2093 @cindex digits, significant
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}:
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(*)}.
2115 @item @emph{Return value}:
2116 The return value is of type @code{INTEGER}.
2118 @item @emph{Example}:
2121 integer :: i = 12345
2127 end program test_digits
2134 @section @code{DIM} --- Dim function
2135 @findex @code{DIM} intrinsic
2136 @findex @code{IDIM} intrinsic
2137 @findex @code{DDIM} intrinsic
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}:
2151 @item @emph{Syntax}:
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}.
2160 @item @emph{Return value}:
2161 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2163 @item @emph{Example}:
2169 x = dim(4.345_8, 2.111_8)
2172 end program test_dim
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
2186 @section @code{DOT_PRODUCT} --- Dot product function
2187 @findex @code{DOT_PRODUCT} intrinsic
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}:
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.
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}:
2221 program test_dot_prod
2222 integer, dimension(3) :: a, b
2229 print *, dot_product(a,b)
2230 end program test_dot_prod
2237 @section @code{DPROD} --- Double product function
2238 @findex @code{DPROD} intrinsic
2239 @cindex Double product
2242 @item @emph{Description}:
2243 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2245 @item @emph{Option}:
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}.
2260 @item @emph{Return value}:
2261 The return value is of type @code{REAL(8)}.
2263 @item @emph{Example}:
2272 end program test_dprod
2279 @section @code{DREAL} --- Double real part function
2280 @findex @code{DREAL} intrinsic
2281 @cindex Double real part
2284 @item @emph{Description}:
2285 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2287 @item @emph{Option}:
2293 @item @emph{Syntax}:
2296 @item @emph{Arguments}:
2297 @multitable @columnfractions .15 .80
2298 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2301 @item @emph{Return value}:
2302 The return value is of type @code{REAL(8)}.
2304 @item @emph{Example}:
2307 complex(8) :: z = (1.3_8,7.2_8)
2309 end program test_dreal
2316 @section @code{DTIME} --- Execution time subroutine (or function)
2317 @findex @code{DTIME} intrinsic
2318 @cindex dtime subroutine
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) +
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.
2348 @item @emph{Option}:
2354 @item @emph{Syntax}:
2355 @multitable @columnfractions .80
2356 @item @code{CALL DTIME(TARRAY, RESULT)}.
2357 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
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}.
2366 @item @emph{Return value}:
2367 Elapsed time in seconds since the start of program execution.
2369 @item @emph{Example}:
2373 real, dimension(2) :: tarray
2375 call dtime(tarray, result)
2379 do i=1,100000000 ! Just a delay
2382 call dtime(tarray, result)
2386 end program test_dtime
2393 @section @code{EOSHIFT} --- End-off shift function
2394 @findex @code{EOSHIFT} intrinsic
2395 @cindex eoshift intrinsic
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.
2418 @item @emph{Option}:
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}.
2435 @item @emph{Return value}:
2436 Returns an array of same type and rank as the @var{ARRAY} argument.
2438 @item @emph{Example}:
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)
2448 print '(3i3)', a(1,:)
2449 print '(3i3)', a(2,:)
2450 print '(3i3)', a(3,:)
2451 end program test_eoshift
2458 @section @code{EPSILON} --- Epsilon function
2459 @findex @code{EPSILON} intrinsic
2460 @cindex epsilon, significant
2463 @item @emph{Description}:
2464 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
2466 @item @emph{Option}:
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(*)}.
2480 @item @emph{Return value}:
2481 The return value is of same type as the argument.
2483 @item @emph{Example}:
2485 program test_epsilon
2490 end program test_epsilon
2497 @section @code{ERF} --- Error function
2498 @findex @code{ERF} intrinsic
2499 @cindex error function
2502 @item @emph{Description}:
2503 @code{ERF(X)} computes the error function of @var{X}.
2505 @item @emph{Option}:
2511 @item @emph{Syntax}:
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.
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}:
2526 real(8) :: x = 0.17_8
2528 end program test_erf
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
2541 @section @code{ERFC} --- Error function
2542 @findex @code{ERFC} intrinsic
2543 @cindex error function
2546 @item @emph{Description}:
2547 @code{ERFC(X)} computes the complementary error function of @var{X}.
2549 @item @emph{Option}:
2555 @item @emph{Syntax}:
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.
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}:
2570 real(8) :: x = 0.17_8
2572 end program test_erfc
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
2585 @section @code{ETIME} --- Execution time subroutine (or function)
2586 @findex @code{ETIME} intrinsic
2587 @cindex ETIME subroutine
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.
2613 @item @emph{Option}:
2619 @item @emph{Syntax}:
2620 @multitable @columnfractions .8
2621 @item @code{CALL ETIME(TARRAY, RESULT)}.
2622 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
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}.
2631 @item @emph{Return value}:
2632 Elapsed time in seconds since the start of program execution.
2634 @item @emph{Example}:
2638 real, dimension(2) :: tarray
2640 call ETIME(tarray, result)
2644 do i=1,100000000 ! Just a delay
2647 call ETIME(tarray, result)
2651 end program test_etime
2658 @section @code{EXIT} --- Exit the program with status.
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}:
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(*)}.
2682 @item @emph{Return value}:
2683 @code{STATUS} is passed to the parent process on exit.
2685 @item @emph{Example}:
2688 integer :: STATUS = 0
2689 print *, 'This program is going to exit.'
2691 end program test_exit
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
2706 @item @emph{Description}:
2707 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
2709 @item @emph{Option}:
2715 @item @emph{Syntax}:
2718 @item @emph{Arguments}:
2719 @multitable @columnfractions .15 .80
2720 @item @var{X} @tab The type shall be @code{REAL(*)} or
2724 @item @emph{Return value}:
2725 The return value has same type and kind as @var{X}.
2727 @item @emph{Example}:
2732 end program test_exp
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
2748 @section @code{EXPONENT} --- Exponent function
2749 @findex @code{EXPONENT} intrinsic
2750 @cindex exponent function
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}:
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(*)}.
2771 @item @emph{Return value}:
2772 The return value is of type default @code{INTEGER}.
2774 @item @emph{Example}:
2776 program test_exponent
2781 print *, exponent(0.0)
2782 end program test_exponent
2788 @section @code{FDATE} --- Get the current time as a string
2789 @findex @code{FDATE} intrinsic
2790 @cindex fdate subroutine
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,
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}:
2809 @item @emph{Syntax}:
2810 @multitable @columnfractions .80
2811 @item @code{CALL FDATE(DATE)}.
2812 @item @code{DATE = FDATE()}, (not recommended).
2815 @item @emph{Arguments}:
2816 @multitable @columnfractions .15 .80
2817 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
2820 @item @emph{Return value}:
2821 The current date and time as a string.
2823 @item @emph{Example}:
2827 character(len=30) :: date
2829 print *, 'Program started on ', date
2830 do i = 1, 100000000 ! Just a delay
2834 print *, 'Program ended on ', date
2835 end program test_fdate
2840 @section @code{FLOAT} --- Convert integer to default real
2841 @findex @code{FLOAT} intrinsic
2845 @item @emph{Description}:
2846 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
2848 @item @emph{Option}:
2854 @item @emph{Syntax}:
2857 @item @emph{Arguments}:
2858 @multitable @columnfractions .15 .80
2859 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
2862 @item @emph{Return value}:
2863 The return value is of type default @code{REAL}
2865 @item @emph{Example}:
2869 if (float(i) /= 1.) call abort
2870 end program test_float
2876 @section @code{FLOOR} --- Integer floor function
2877 @findex @code{FLOOR} intrinsic
2881 @item @emph{Description}:
2882 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
2884 @item @emph{Option}:
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.
2899 @item @emph{Return value}:
2900 The return value is of type @code{INTEGER(KIND)}
2902 @item @emph{Example}:
2907 print *, floor(x) ! returns 63
2908 print *, floor(y) ! returns -64
2909 end program test_floor
2916 @section @code{FLUSH} --- Flush I/O unit(s)
2917 @findex @code{FLUSH}
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}:
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}.
2940 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
2941 statement that should be prefered over the @code{FLUSH} intrinsic.
2948 @section @code{FNUM} --- File number function
2949 @findex @code{FNUM} intrinsic
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}:
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}.
2971 @item @emph{Return value}:
2972 The return value is of type @code{INTEGER}
2974 @item @emph{Example}:
2978 open (unit=10, status = "scratch")
2982 end program test_fnum
2989 @section @code{FRACTION} --- Fractional part of the model representation
2990 @findex @code{FRACTION} intrinsic
2991 @cindex fractional part
2994 @item @emph{Description}:
2995 @code{FRACTION(X)} returns the fractional part of the model
2996 representation of @code{X}.
2998 @item @emph{Option}:
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}.
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}:
3019 program test_fraction
3022 print *, fraction(x), x * radix(x)**(-exponent(x))
3023 end program test_fraction
3031 @section @code{FREE} --- Frees memory
3032 @findex @code{FREE} intrinsic
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
3043 @item @emph{Option}:
3049 @item @emph{Syntax}:
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.
3058 @item @emph{Return value}:
3061 @item @emph{Example}:
3062 See @code{MALLOC} for an example.
3068 @section @code{GETGID} --- Group ID function
3069 @findex @code{GETGID} intrinsic
3073 @item @emph{Description}:
3074 Returns the numerical group ID of the current process.
3076 @item @emph{Option}:
3082 @item @emph{Syntax}:
3085 @item @emph{Return value}:
3086 The return value of @code{GETGID} is an @code{INTEGER} of the default
3090 @item @emph{Example}:
3091 See @code{GETPID} for an example.
3098 @section @code{GETPID} --- Process ID function
3099 @findex @code{GETPID} intrinsic
3103 @item @emph{Description}:
3104 Returns the process numerical identificator of the current process.
3106 @item @emph{Option}:
3112 @item @emph{Syntax}:
3115 @item @emph{Return value}:
3116 The return value of @code{GETPID} is an @code{INTEGER} of the default
3120 @item @emph{Example}:
3123 print *, "The current process ID is ", getpid()
3124 print *, "Your numerical user ID is ", getuid()
3125 print *, "Your numerical group ID is ", getgid()
3134 @section @code{GETUID} --- User ID function
3135 @findex @code{GETUID} intrinsic
3139 @item @emph{Description}:
3140 Returns the numerical user ID of the current process.
3142 @item @emph{Option}:
3148 @item @emph{Syntax}:
3151 @item @emph{Return value}:
3152 The return value of @code{GETUID} is an @code{INTEGER} of the default
3156 @item @emph{Example}:
3157 See @code{GETPID} for an example.
3164 @section @code{HUGE} --- Largest number of a kind
3165 @findex @code{HUGE} intrinsic
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}:
3179 @item @emph{Syntax}:
3182 @item @emph{Arguments}:
3183 @multitable @columnfractions .15 .80
3184 @item @var{X} @tab shall be of type @code{REAL} or @code{INTEGER}.
3187 @item @emph{Return value}:
3188 The return value is of the same type and kind as @var{X}
3190 @item @emph{Example}:
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
3202 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
3203 @findex @code{IACHAR} intrinsic
3204 @cindex @acronym{ASCII} collating sequence
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}:
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)}
3225 @item @emph{Return value}:
3226 The return value is of type @code{INTEGER} and of the default integer
3229 @item @emph{Example}:
3234 end program test_iachar
3241 @section @code{ICHAR} --- Character-to-integer conversion function
3242 @findex @code{ICHAR} intrinsic
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}:
3257 @item @emph{Syntax}:
3260 @item @emph{Arguments}:
3261 @multitable @columnfractions .15 .80
3262 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
3265 @item @emph{Return value}:
3266 The return value is of type @code{INTEGER} and of the default integer
3269 @item @emph{Example}:
3274 end program test_ichar
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
3283 Instead, you can use internal-file I/O to do this kind of conversion. For
3288 character(len=10) string
3291 read (string,'(I10)') value
3293 end program read_val
3300 @section @code{IRAND} --- Integer pseudo-random number
3301 @findex @code{IRAND} intrinsic
3302 @cindex random number
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}:
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.
3327 @item @emph{Return value}:
3328 The return value is of @code{INTEGER(kind=4)} type.
3330 @item @emph{Example}:
3333 integer,parameter :: seed = 86456
3336 print *, irand(), irand(), irand(), irand()
3337 print *, irand(seed), irand(), irand(), irand()
3338 end program test_irand
3346 @section @code{KIND} --- Kind of an entity
3347 @findex @code{KIND} intrinsic
3350 @item @emph{Description}:
3351 @code{KIND(X)} returns the kind value of the entity @var{X}.
3353 @item @emph{Option}:
3359 @item @emph{Syntax}:
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}.
3368 @item @emph{Return value}:
3369 The return value is a scalar of type @code{INTEGER} and of the default
3372 @item @emph{Example}:
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
3388 @section @code{LOC} --- Returns the address of a variable
3389 @findex @code{LOC} intrinsic
3393 @item @emph{Description}:
3394 @code{LOC(X)} returns the address of @var{X} as an integer.
3396 @item @emph{Option}:
3402 @item @emph{Syntax}:
3405 @item @emph{Arguments}:
3406 @multitable @columnfractions .15 .80
3407 @item @var{X} @tab Variable of any type.
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}:
3421 end program test_loc
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
3436 @item @emph{Description}:
3437 @code{LOG(X)} computes the logarithm of @var{X}.
3439 @item @emph{Option}:
3445 @item @emph{Syntax}:
3448 @item @emph{Arguments}:
3449 @multitable @columnfractions .15 .80
3450 @item @var{X} @tab The type shall be @code{REAL(*)} or
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}:
3461 real(8) :: x = 1.0_8
3462 complex :: z = (1.0, 2.0)
3465 end program test_log
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
3482 @section @code{LOG10} --- Base 10 logarithm function
3483 @findex @code{LOG10} intrinsic
3484 @findex @code{ALOG10} intrinsic
3485 @findex @code{DLOG10} intrinsic
3489 @item @emph{Description}:
3490 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
3492 @item @emph{Option}:
3498 @item @emph{Syntax}:
3501 @item @emph{Arguments}:
3502 @multitable @columnfractions .15 .80
3503 @item @var{X} @tab The type shall be @code{REAL(*)} or
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}:
3514 real(8) :: x = 10.0_8
3516 end program test_log10
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
3529 @section @code{MALLOC} --- Allocate dynamic memory
3530 @findex @code{MALLOC} intrinsic
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
3542 @item @emph{Option}:
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(*)}.
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)}.
3575 ptr_x = malloc(20*8)
3577 x(i) = sqrt(1.0d0 / i)
3585 end program test_malloc
3592 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
3593 @findex @code{MAXEXPONENT} intrinsic
3597 @item @emph{Description}:
3598 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
3601 @item @emph{Option}:
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}.
3615 @item @emph{Return value}:
3616 The return value is of type @code{INTEGER} and of the default integer
3619 @item @emph{Example}:
3625 print *, minexponent(x), maxexponent(x)
3626 print *, minexponent(y), maxexponent(y)
3627 end program exponents
3634 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
3635 @findex @code{MINEXPONENT} intrinsic
3639 @item @emph{Description}:
3640 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
3643 @item @emph{Option}:
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}.
3657 @item @emph{Return value}:
3658 The return value is of type @code{INTEGER} and of the default integer
3661 @item @emph{Example}:
3662 See @code{MAXEXPONENT} for an example.
3668 @section @code{MOD} --- Remainder function
3669 @findex @code{MOD} intrinsic
3670 @findex @code{AMOD} intrinsic
3671 @findex @code{DMOD} intrinsic
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}:
3685 @item @emph{Syntax}:
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
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}:
3703 print *, mod(17.5,5.5)
3704 print *, mod(17.5d0,5.5)
3705 print *, mod(17.5,5.5d0)
3708 print *, mod(-17.5,5.5)
3709 print *, mod(-17.5d0,5.5)
3710 print *, mod(-17.5,5.5d0)
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
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
3730 @section @code{MODULO} --- Modulo function
3731 @findex @code{MODULO} intrinsic
3735 @item @emph{Description}:
3736 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
3738 @item @emph{Option}:
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}
3753 @item @emph{Return value}:
3754 The type and kind of the result are those of the arguments.
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}
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}.
3763 In all cases, if @var{P} is zero the result is processor-dependent.
3765 @item @emph{Example}:
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
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
3790 @section @code{NEAREST} --- Nearest representable number
3791 @findex @code{NEAREST} intrinsic
3792 @cindex processor-representable number
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}:
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
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}:
3824 program test_nearest
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
3836 @section @code{NINT} --- Nearest whole number
3837 @findex @code{NINT} intrinsic
3838 @findex @code{IDNINT} intrinsic
3839 @cindex whole number
3842 @item @emph{Description}:
3843 @code{NINT(X)} rounds its argument to the nearest whole number.
3845 @item @emph{Option}:
3851 @item @emph{Syntax}:
3854 @item @emph{Arguments}:
3855 @multitable @columnfractions .15 .80
3856 @item @var{X} @tab The type of the argument shall be @code{REAL}.
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}:
3871 print *, nint(x4), idnint(x8)
3872 end program test_nint
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
3885 @section @code{PRECISION} --- Decimal precision of a real kind
3886 @findex @code{PRECISION} intrinsic
3890 @item @emph{Description}:
3891 @code{PRECISION(X)} returns the decimal precision in the model of the
3894 @item @emph{Option}:
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}.
3908 @item @emph{Return value}:
3909 The return value is of type @code{INTEGER} and of the default integer
3912 @item @emph{Example}:
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
3927 @section @code{RADIX} --- Base of a model number
3928 @findex @code{RADIX} intrinsic
3932 @item @emph{Description}:
3933 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
3935 @item @emph{Option}:
3941 @item @emph{Syntax}:
3944 @item @emph{Arguments}:
3945 @multitable @columnfractions .15 .80
3946 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
3949 @item @emph{Return value}:
3950 The return value is a scalar of type @code{INTEGER} and of the default
3953 @item @emph{Example}:
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
3966 @section @code{RAND} --- Real pseudo-random number
3967 @findex @code{RAND} intrinsic
3968 @findex @code{RAN} intrinsic
3969 @cindex random number
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}:
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.
3993 @item @emph{Return value}:
3994 The return value is of @code{REAL} type and the default kind.
3996 @item @emph{Example}:
3999 integer,parameter :: seed = 86456
4002 print *, rand(), rand(), rand(), rand()
4003 print *, rand(seed), rand(), rand(), rand()
4004 end program test_rand
4008 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
4009 provided as an alias for @code{RAND}.
4016 @section @code{RANGE} --- Decimal exponent range of a real kind
4017 @findex @code{RANGE} intrinsic
4021 @item @emph{Description}:
4022 @code{RANGE(X)} returns the decimal exponent range in the model of the
4025 @item @emph{Option}:
4031 @item @emph{Syntax}:
4034 @item @emph{Arguments}:
4035 @multitable @columnfractions .15 .80
4036 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
4039 @item @emph{Return value}:
4040 The return value is of type @code{INTEGER} and of the default integer
4043 @item @emph{Example}:
4044 See @code{PRECISION} for an example.
4050 @section @code{REAL} --- Convert to real type
4051 @findex @code{REAL} intrinsic
4052 @findex @code{REALPART} intrinsic
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}:
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)}
4074 @item @emph{Arguments}:
4075 @multitable @columnfractions .15 .80
4076 @item @var{X} @tab shall be @code{INTEGER(*)}, @code{REAL(*)}, or
4078 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer.
4081 @item @emph{Return value}:
4082 These functions return the a @code{REAL(*)} variable or array under
4083 the following rules:
4087 @code{REAL(X)} is converted to a default real type if @var{X} is an
4088 integer or real variable.
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.
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
4098 @item @emph{Example}:
4101 complex :: x = (1.0, 2.0)
4102 print *, real(x), real(x,8), realpart(x)
4103 end program test_real
4110 @section @code{RRSPACING} --- Reciprocal of the relative spacing
4111 @findex @code{RRSPACING} intrinsic
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}:
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}.
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)}.
4142 @section @code{SCALE} --- Scale a real value
4143 @findex @code{SCALE} intrinsic
4146 @item @emph{Description}:
4147 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
4149 @item @emph{Option}:
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}.
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}:
4171 real :: x = 178.1387e-4
4173 print *, scale(x,i), x*radix(x)**i
4174 end program test_scale
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
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}:
4197 transformational function
4199 @item @emph{Syntax}:
4200 @multitable @columnfractions .30 .80
4201 @item @code{J = SELECTED_INT_KIND(I)}
4204 @item @emph{Arguments}:
4205 @multitable @columnfractions .15 .80
4206 @item @var{I} @tab shall be a scalar and of type @code{INTEGER}.
4209 @item @emph{Example}:
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
4228 @node SELECTED_REAL_KIND
4229 @section @code{SELECTED_REAL_KIND} --- Choose real kind
4230 @findex @code{SELECTED_REAL_KIND} intrinsic
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}:
4243 transformational function
4245 @item @emph{Syntax}:
4246 @multitable @columnfractions .30 .80
4247 @item @code{I = SELECTED_REAL_KIND(P,R)}
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}.
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,
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.
4273 @item @emph{Example}:
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)
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
4293 @section @code{SECNDS} --- Time subroutine
4294 @findex @code{SECNDS} intrinsic
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
4304 @item @emph{Option}:
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)
4320 @item @emph{Return value}:
4323 @item @emph{Example}:
4327 print *, secnds (0.0) ! seconds since midnight
4328 t1 = secnds (0.0) ! reference time
4329 do i = 1, 10000000 ! do something
4331 t2 = secnds (t1) ! elapsed time
4332 print *, "Something took ", t2, " seconds."
4333 end program test_secnds
4340 @section @code{SET_EXPONENT} --- Set the exponent of the model
4341 @findex @code{SET_EXPONENT} intrinsic
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}:
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}.
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}:
4373 real :: x = 178.1387e-4
4375 print *, set_exponent(x), fraction(x) * radix(x)**i
4376 end program test_setexp
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
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}:
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}
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}:
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
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
4438 @section @code{SIGNAL} --- Signal handling subroutine (or function)
4439 @findex @code{SIGNAL} intrinsic
4440 @cindex SIGNAL subroutine
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}:
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)}
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)}.
4476 @item @emph{Return value}:
4477 The @code{SIGNAL} functions returns the value returned by @code{signal(2)}.
4479 @item @emph{Example}:
4483 external handler_print
4485 call signal (12, handler_print)
4489 end program test_signal
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
4505 @item @emph{Description}:
4506 @code{SIN(X)} computes the sine of @var{X}.
4508 @item @emph{Option}:
4514 @item @emph{Syntax}:
4517 @item @emph{Arguments}:
4518 @multitable @columnfractions .15 .80
4519 @item @var{X} @tab The type shall be @code{REAL(*)} or
4523 @item @emph{Return value}:
4524 The return value has same type and king than @var{X}.
4526 @item @emph{Example}:
4531 end program test_sin
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
4547 @section @code{SINH} --- Hyperbolic sine function
4548 @findex @code{SINH} intrinsic
4549 @findex @code{DSINH} intrinsic
4550 @cindex hyperbolic sine
4553 @item @emph{Description}:
4554 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
4556 @item @emph{Option}:
4562 @item @emph{Syntax}:
4565 @item @emph{Arguments}:
4566 @multitable @columnfractions .15 .80
4567 @item @var{X} @tab The type shall be @code{REAL(*)}.
4570 @item @emph{Return value}:
4571 The return value is of type @code{REAL(*)}.
4573 @item @emph{Example}:
4576 real(8) :: x = - 1.0_8
4578 end program test_sinh
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
4591 @section @code{SNGL} --- Convert double precision real to default real
4592 @findex @code{SNGL} intrinsic
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}:
4607 @item @emph{Syntax}:
4610 @item @emph{Arguments}:
4611 @multitable @columnfractions .15 .80
4612 @item @var{A} @tab The type shall be a double precision @code{REAL}.
4615 @item @emph{Return value}:
4616 The return value is of type default @code{REAL}.
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
4632 @item @emph{Description}:
4633 @code{SQRT(X)} computes the square root of @var{X}.
4635 @item @emph{Option}:
4641 @item @emph{Syntax}:
4644 @item @emph{Arguments}:
4645 @multitable @columnfractions .15 .80
4646 @item @var{X} @tab The type shall be @code{REAL(*)} or
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}:
4657 real(8) :: x = 2.0_8
4658 complex :: z = (1.0, 2.0)
4661 end program test_sqrt
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
4677 @section @code{SRAND} --- Reinitialize the random number generator
4678 @findex @code{SRAND} intrinsic
4679 @cindex random number
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}:
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)}.
4701 @item @emph{Return value}:
4704 @item @emph{Example}:
4705 See @code{RAND} and @code{IRAND} for examples.
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.
4721 @section @code{TAN} --- Tangent function
4722 @findex @code{TAN} intrinsic
4723 @findex @code{DTAN} intrinsic
4727 @item @emph{Description}:
4728 @code{TAN(X)} computes the tangent of @var{X}.
4730 @item @emph{Option}:
4736 @item @emph{Syntax}:
4739 @item @emph{Arguments}:
4740 @multitable @columnfractions .15 .80
4741 @item @var{X} @tab The type shall be @code{REAL(*)}.
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}:
4751 real(8) :: x = 0.165_8
4753 end program test_tan
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
4766 @section @code{TANH} --- Hyperbolic tangent function
4767 @findex @code{TANH} intrinsic
4768 @findex @code{DTANH} intrinsic
4769 @cindex hyperbolic tangent
4772 @item @emph{Description}:
4773 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
4775 @item @emph{Option}:
4781 @item @emph{Syntax}:
4784 @item @emph{Arguments}:
4785 @multitable @columnfractions .15 .80
4786 @item @var{X} @tab The type shall be @code{REAL(*)}.
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}:
4796 real(8) :: x = 2.1_8
4798 end program test_tanh
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
4811 @section @code{TINY} --- Smallest positive number of a real kind
4812 @findex @code{TINY} intrinsic
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}:
4826 @item @emph{Syntax}:
4829 @item @emph{Arguments}:
4830 @multitable @columnfractions .15 .80
4831 @item @var{X} @tab shall be of type @code{REAL}.
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.
4853 @comment sub get_command
4855 @comment sub get_command_argument
4857 @comment sub get_environment_variable
4887 @comment gen len_trim
4897 @comment gen logical
4935 @comment gen present
4937 @comment gen product
4939 @comment sub random_number
4941 @comment sub random_seed
4945 @comment gen reshape
4956 @comment gen spacing
4968 @comment sub system_clock
4970 @comment gen transfer
4972 @comment gen transpose