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{ALL}: ALL, Determine if all values are true
45 * @code{ALLOCATED}: ALLOCATED, Status of allocatable entity
46 * @code{ANINT}: ANINT, Nearest whole number
47 * @code{ANY}: ANY, Determine if any values are true
48 * @code{ASIN}: ASIN, Arcsine function
49 * @code{ASSOCIATED}: ASSOCIATED, Status of a pointer or pointer/target pair
50 * @code{ATAN}: ATAN, Arctangent function
51 * @code{ATAN2}: ATAN2, Arctangent function
52 * @code{BESJ0}: BESJ0, Bessel function of the first kind of order 0
53 * @code{BESJ1}: BESJ1, Bessel function of the first kind of order 1
54 * @code{BESJN}: BESJN, Bessel function of the first kind
55 * @code{BESY0}: BESY0, Bessel function of the second kind of order 0
56 * @code{BESY1}: BESY1, Bessel function of the second kind of order 1
57 * @code{BESYN}: BESYN, Bessel function of the second kind
58 * @code{BIT_SIZE}: BIT_SIZE, Bit size inquiry function
59 * @code{BTEST}: BTEST, Bit test function
60 * @code{CEILING}: CEILING, Integer ceiling function
61 * @code{CHAR}: CHAR, Character conversion function
62 * @code{CMPLX}: CMPLX, Complex conversion function
63 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Command line argument count
64 * @code{CONJG}: CONJG, Complex conjugate function
65 * @code{COS}: COS, Cosine function
66 * @code{COSH}: COSH, Hyperbolic cosine function
67 * @code{COUNT}: COUNT, Count occurences of .TRUE. in an array
68 * @code{CPU_TIME}: CPU_TIME, CPU time subroutine
69 * @code{CSHIFT}: CSHIFT, Circular array shift function
70 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
71 * @code{DBLE}: DBLE, Double precision conversion function
72 * @code{DCMPLX}: DCMPLX, Double complex conversion function
73 * @code{DFLOAT}: DFLOAT, Double precision conversion function
74 * @code{DIGITS}: DIGITS, Significant digits function
75 * @code{DIM}: DIM, Dim function
76 * @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
77 * @code{DPROD}: DPROD, Double product function
78 * @code{DREAL}: DREAL, Double real part function
79 * @code{DTIME}: DTIME, Execution time subroutine (or function)
80 * @code{ERF}: ERF, Error function
81 * @code{ERFC}: ERFC, Complementary error function
82 * @code{EXP}: EXP, Cosine function
83 * @code{LOG}: LOG, Logarithm function
84 * @code{LOG10}: LOG10, Base 10 logarithm function
85 * @code{SQRT}: SQRT, Square-root function
86 * @code{SIN}: SIN, Sine function
87 * @code{SINH}: SINH, Hyperbolic sine function
88 * @code{TAN}: TAN, Tangent function
89 * @code{TANH}: TANH, Hyperbolic tangent function
93 @section Introduction to intrinsic procedures
95 Gfortran provides a rich set of intrinsic procedures that includes all
96 the intrinsic procedures required by the Fortran 95 standard, a set of
97 intrinsic procedures for backwards compatibility with Gnu Fortran 77
98 (i.e., @command{g77}), and a small selection of intrinsic procedures
99 from the Fortran 2003 standard. Any description here, which conflicts with a
100 description in either the Fortran 95 standard or the Fortran 2003 standard,
101 is unintentional and the standard(s) should be considered authoritative.
103 The enumeration of the @code{KIND} type parameter is processor defined in
104 the Fortran 95 standard. Gfortran defines the default integer type and
105 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
106 respectively. The standard mandates that both data types shall have
107 another kind, which have more precision. On typical target architectures
108 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
109 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
110 In the description of generic intrinsic procedures, the kind type parameter
111 will be specified by @code{KIND=*}, and in the description of specific
112 names for an intrinsic procedure the kind type parameter will be explicitly
113 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
114 brevity the optional @code{KIND=} syntax will be omitted.
116 Many of the intrinsics procedures take one or more optional arguments.
117 This document follows the convention used in the Fortran 95 standard,
118 and denotes such arguments by square brackets.
120 @command{Gfortran} offers the @option{-std=f95} and @option{-std=gnu} options,
121 which can be used to restrict the set of intrinsic procedures to a
122 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
123 option, and so all intrinsic procedures described here are accepted. There
124 is one caveat. For a select group of intrinsic procedures, @command{g77}
125 implemented both a function and a subroutine. Both classes
126 have been implemented in @command{gfortran} for backwards compatibility
127 with @command{g77}. It is noted here that these functions and subroutines
128 cannot be intermixed in a given subprogram. In the descriptions that follow,
129 the applicable option(s) is noted.
134 @section @code{ABORT} --- Abort the program
139 @item @emph{Description}:
140 @code{ABORT} causes immediate termination of the program. On operating
141 systems that support a core dump, @code{ABORT} will produce a core dump,
142 which is suitable for debugging purposes.
148 non-elemental subroutine
153 @item @emph{Return value}:
156 @item @emph{Example}:
159 integer :: i = 1, j = 2
160 if (i /= j) call abort
161 end program test_abort
168 @section @code{ABS} --- Absolute value
169 @findex @code{ABS} intrinsic
170 @findex @code{CABS} intrinsic
171 @findex @code{DABS} intrinsic
172 @findex @code{IABS} intrinsic
173 @findex @code{ZABS} intrinsic
174 @findex @code{CDABS} intrinsic
175 @cindex absolute value
178 @item @emph{Description}:
179 @code{ABS(X)} computes the absolute value of @code{X}.
190 @item @emph{Arguments}:
191 @multitable @columnfractions .15 .80
192 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
193 @code{REAL(*)}, or @code{COMPLEX(*)}.
196 @item @emph{Return value}:
197 The return value is of the same type and
198 kind as the argument except the return value is @code{REAL(*)} for a
199 @code{COMPLEX(*)} argument.
201 @item @emph{Example}:
206 complex :: z = (-1.e0,0.e0)
213 @item @emph{Specific names}:
214 @multitable @columnfractions .24 .24 .24 .24
215 @item Name @tab Argument @tab Return type @tab Option
216 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab f95, gnu
217 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
218 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab f95, gnu
219 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
220 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
227 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
228 @findex @code{ACHAR} intrinsic
229 @cindex @acronym{ASCII} collating sequence
232 @item @emph{Description}:
233 @code{ACHAR(I)} returns the character located at position @code{I}
234 in the @acronym{ASCII} collating sequence.
245 @item @emph{Arguments}:
246 @multitable @columnfractions .15 .80
247 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
250 @item @emph{Return value}:
251 The return value is of type @code{CHARACTER} with a length of one. The
252 kind type parameter is the same as @code{KIND('A')}.
254 @item @emph{Example}:
259 end program test_achar
266 @section @code{ACOS} --- Arc cosine function
267 @findex @code{ACOS} intrinsic
268 @findex @code{DACOS} intrinsic
272 @item @emph{Description}:
273 @code{ACOS(X)} computes the arc cosine of @var{X}.
284 @item @emph{Arguments}:
285 @multitable @columnfractions .15 .80
286 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
290 @item @emph{Return value}:
291 The return value is of type @code{REAL(*)} and it lies in the
292 range @math{ 0 \leq \arccos (x) \leq \pi}. The kind type
293 parameter is the same as @var{X}.
295 @item @emph{Example}:
298 real(8) :: x = 0.866_8
300 end program test_acos
303 @item @emph{Specific names}:
304 @multitable @columnfractions .24 .24 .24 .24
305 @item Name @tab Argument @tab Return type @tab Option
306 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
313 @section @code{ADJUSTL} --- Left adjust a string
314 @findex @code{ADJUSTL} intrinsic
315 @cindex adjust string
318 @item @emph{Description}:
319 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
320 Spaces are inserted at the end of the string as needed.
329 @code{STR = ADJUSTL(STR)}
331 @item @emph{Arguments}:
332 @multitable @columnfractions .15 .80
333 @item @var{STR} @tab The type shall be @code{CHARACTER}.
336 @item @emph{Return value}:
337 The return value is of type @code{CHARACTER} where leading spaces
338 are removed and the same number of spaces are inserted on the end
341 @item @emph{Example}:
344 character(len=20) :: str = ' gfortran'
347 end program test_adjustl
354 @section @code{ADJUSTR} --- Right adjust a string
355 @findex @code{ADJUSTR} intrinsic
356 @cindex adjust string
359 @item @emph{Description}:
360 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
361 Spaces are inserted at the start of the string as needed.
370 @code{STR = ADJUSTR(STR)}
372 @item @emph{Arguments}:
373 @multitable @columnfractions .15 .80
374 @item @var{STR} @tab The type shall be @code{CHARACTER}.
377 @item @emph{Return value}:
378 The return value is of type @code{CHARACTER} where trailing spaces
379 are removed and the same number of spaces are inserted at the start
382 @item @emph{Example}:
385 character(len=20) :: str = 'gfortran'
388 end program test_adjustr
395 @section @code{AIMAG} --- Imaginary part of complex number
396 @findex @code{AIMAG} intrinsic
397 @findex @code{DIMAG} intrinsic
398 @cindex Imaginary part
401 @item @emph{Description}:
402 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
413 @item @emph{Arguments}:
414 @multitable @columnfractions .15 .80
415 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
418 @item @emph{Return value}:
419 The return value is of type real with the
420 kind type parameter of the argument.
422 @item @emph{Example}:
427 z4 = cmplx(1.e0_4, 0.e0_4)
428 z8 = cmplx(0.e0_8, 1.e0_8)
429 print *, aimag(z4), dimag(z8)
430 end program test_aimag
433 @item @emph{Specific names}:
434 @multitable @columnfractions .24 .24 .24 .24
435 @item Name @tab Argument @tab Return type @tab Option
436 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab f95, gnu
443 @section @code{AINT} --- Imaginary part of complex number
444 @findex @code{AINT} intrinsic
445 @findex @code{DINT} intrinsic
449 @item @emph{Description}:
450 @code{AINT(X [, KIND])} truncates its argument to a whole number.
460 @code{X = AINT(X, KIND)}
462 @item @emph{Arguments}:
463 @multitable @columnfractions .15 .80
464 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
465 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
466 initialization expression.
469 @item @emph{Return value}:
470 The return value is of type real with the kind type parameter of the
471 argument if the optional @var{KIND} is absent; otherwise, the kind
472 type parameter will be given by @var{KIND}. If the magnitude of
473 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
474 magnitude is equal to or greater than one, then it returns the largest
475 whole number that does not exceed its magnitude. The sign is the same
476 as the sign of @var{X}.
478 @item @emph{Example}:
485 print *, aint(x4), dint(x8)
487 end program test_aint
490 @item @emph{Specific names}:
491 @multitable @columnfractions .24 .24 .24 .24
492 @item Name @tab Argument @tab Return type @tab Option
493 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
500 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
501 @findex @code{ALL} intrinsic
505 @item @emph{Description}:
506 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
507 in the array along dimension @var{DIM}.
513 transformational function
517 @code{L = ALL(MASK, DIM)}
519 @item @emph{Arguments}:
520 @multitable @columnfractions .15 .80
521 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
522 it shall not be scalar.
523 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
524 with a value that lies between one and the rank of @var{MASK}.
527 @item @emph{Return value}:
528 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
529 the kind type parameter is the same as the kind type parameter of
530 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
531 an array with the rank of @var{MASK} minus 1. The shape is determined from
532 the shape of @var{MASK} where the @var{DIM} dimension is elided.
536 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
537 It also is true if @var{MASK} has zero size; otherwise, it is false.
539 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
540 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
541 is determined by applying @code{ALL} to the array sections.
544 @item @emph{Example}:
548 l = all((/.true., .true., .true./))
553 integer a(2,3), b(2,3)
557 print *, all(a .eq. b, 1)
558 print *, all(a .eq. b, 2)
559 end subroutine section
567 @section @code{ALLOCATED} --- Status of an allocatable entity
568 @findex @code{ALLOCATED} intrinsic
569 @cindex allocation status
572 @item @emph{Description}:
573 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
582 @code{L = ALLOCATED(X)}
584 @item @emph{Arguments}:
585 @multitable @columnfractions .15 .80
586 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
589 @item @emph{Return value}:
590 The return value is a scalar @code{LOGICAL} with the default logical
591 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
592 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
594 @item @emph{Example}:
596 program test_allocated
598 real(4), allocatable :: x(:)
599 if (allocated(x) .eqv. .false.) allocate(x(i)
600 end program test_allocated
607 @section @code{ANINT} --- Imaginary part of complex number
608 @findex @code{ANINT} intrinsic
609 @findex @code{DNINT} intrinsic
613 @item @emph{Description}:
614 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
624 @code{X = ANINT(X, KIND)}
626 @item @emph{Arguments}:
627 @multitable @columnfractions .15 .80
628 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
629 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
630 initialization expression.
633 @item @emph{Return value}:
634 The return value is of type real with the kind type parameter of the
635 argument if the optional @var{KIND} is absent; otherwise, the kind
636 type parameter will be given by @var{KIND}. If @var{X} is greater than
637 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
638 less than or equal to zero, then return @code{AINT(X-0.5)}.
640 @item @emph{Example}:
647 print *, anint(x4), dnint(x8)
649 end program test_anint
652 @item @emph{Specific names}:
653 @multitable @columnfractions .24 .24 .24 .24
654 @item Name @tab Argument @tab Return type @tab Option
655 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
662 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
663 @findex @code{ANY} intrinsic
667 @item @emph{Description}:
668 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array @var{MASK}
669 along dimension @var{DIM} are @code{.TRUE.}.
675 transformational function
679 @code{L = ANY(MASK, DIM)}
681 @item @emph{Arguments}:
682 @multitable @columnfractions .15 .80
683 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
684 it shall not be scalar.
685 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
686 with a value that lies between one and the rank of @var{MASK}.
689 @item @emph{Return value}:
690 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
691 the kind type parameter is the same as the kind type parameter of
692 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
693 an array with the rank of @var{MASK} minus 1. The shape is determined from
694 the shape of @var{MASK} where the @var{DIM} dimension is elided.
698 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
699 otherwise, it is false. It also is false if @var{MASK} has zero size.
701 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
702 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
703 is determined by applying @code{ANY} to the array sections.
706 @item @emph{Example}:
710 l = any((/.true., .true., .true./))
715 integer a(2,3), b(2,3)
719 print *, any(a .eq. b, 1)
720 print *, any(a .eq. b, 2)
721 end subroutine section
729 @section @code{ASIN} --- Arcsine function
730 @findex @code{ASIN} intrinsic
731 @findex @code{DASIN} intrinsic
735 @item @emph{Description}:
736 @code{ASIN(X)} computes the arcsine of its @var{X}.
747 @item @emph{Arguments}:
748 @multitable @columnfractions .15 .80
749 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
753 @item @emph{Return value}:
754 The return value is of type @code{REAL(*)} and it lies in the
755 range @math{-\pi / 2 \leq \arccos (x) \leq \pi / 2}. The kind type
756 parameter is the same as @var{X}.
758 @item @emph{Example}:
761 real(8) :: x = 0.866_8
763 end program test_asin
766 @item @emph{Specific names}:
767 @multitable @columnfractions .24 .24 .24 .24
768 @item Name @tab Argument @tab Return type @tab Option
769 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
776 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
777 @findex @code{ASSOCIATED} intrinsic
778 @cindex pointer status
781 @item @emph{Description}:
782 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
783 or if @var{PTR} is associated with the target @var{TGT}.
792 @code{L = ASSOCIATED(PTR)}
793 @code{L = ASSOCIATED(PTR [, TGT])}
795 @item @emph{Arguments}:
796 @multitable @columnfractions .15 .80
797 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
798 it can be of any type.
799 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
800 a @code{TARGET}. It must have the same type, kind type parameter, and
801 array rank as @var{PTR}.
803 The status of neither @var{PTR} nor @var{TGT} can be undefined.
805 @item @emph{Return value}:
806 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
807 There are several cases:
809 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
810 is true if @var{PTR} is associated with a target; otherwise, it returns false.
811 @item (B) If @var{TGT} is present and a scalar target, the result is true if
813 is not a 0 sized storage sequence and the target associated with @var{PTR}
814 occupies the same storage units. If @var{PTR} is disassociated, then the
816 @item (C) If @var{TGT} is present and an array target, the result is true if
817 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
818 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
819 @var{PTR} occupy the same storage units in array element order.
820 As in case(B), the result is false, if @var{PTR} is disassociated.
821 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
822 target associated with @var{PTR} and the target associated with @var{TGT}
823 are not 0 sized storage sequences and occupy the same storage units.
824 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
825 @item (E) If @var{TGT} is present and an array pointer, the result is true if
826 target associated with @var{PTR} and the target associated with @var{TGT}
827 have the same shape, are not 0 sized arrays, are arrays whose elements are
828 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
829 storage units in array element order.
830 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
833 @item @emph{Example}:
835 program test_associated
837 real, target :: tgt(2) = (/1., 2./)
838 real, pointer :: ptr(:)
840 if (associated(ptr) .eqv. .false.) call abort
841 if (associated(ptr,tgt) .eqv. .false.) call abort
842 end program test_associated
849 @section @code{ATAN} --- Arctangent function
850 @findex @code{ATAN} intrinsic
851 @findex @code{DATAN} intrinsic
855 @item @emph{Description}:
856 @code{ATAN(X)} computes the arctangent of @var{X}.
867 @item @emph{Arguments}:
868 @multitable @columnfractions .15 .80
869 @item @var{X} @tab The type shall be @code{REAL(*)}.
872 @item @emph{Return value}:
873 The return value is of type @code{REAL(*)} and it lies in the
874 range @math{ - \pi / 2 \leq \arcsin (x) \leq \pi / 2}.
876 @item @emph{Example}:
879 real(8) :: x = 2.866_8
881 end program test_atan
884 @item @emph{Specific names}:
885 @multitable @columnfractions .24 .24 .24 .24
886 @item Name @tab Argument @tab Return type @tab Option
887 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
894 @section @code{ATAN2} --- Arctangent function
895 @findex @code{ATAN2} intrinsic
896 @findex @code{DATAN2} intrinsic
900 @item @emph{Description}:
901 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
910 @code{X = ATAN2(Y,X)}
912 @item @emph{Arguments}:
913 @multitable @columnfractions .15 .80
914 @item @var{Y} @tab The type shall be @code{REAL(*)}.
915 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
916 If @var{Y} is zero, then @var{X} must be nonzero.
919 @item @emph{Return value}:
920 The return value has the same type and kind type parameter as @var{Y}.
921 It is the principle value of the complex number @math{X + i Y}. If
922 @var{X} is nonzero, then it lies in the range @math{-\pi \le \arccos (x) \leq \pi}.
923 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
924 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
925 is negative. Finally, if @var{X} is zero, then the magnitude of the result
928 @item @emph{Example}:
931 real(4) :: x = 1.e0_4, y = 0.5e0_4
933 end program test_atan2
936 @item @emph{Specific names}:
937 @multitable @columnfractions .24 .24 .24 .24
938 @item Name @tab Argument @tab Return type @tab Option
939 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
946 @section @code{BESJ0} --- Bessel function of the first kind of order 0
947 @findex @code{BESJ0} intrinsic
948 @findex @code{DBESJ0} intrinsic
952 @item @emph{Description}:
953 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
965 @item @emph{Arguments}:
966 @multitable @columnfractions .15 .80
967 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
970 @item @emph{Return value}:
971 The return value is of type @code{REAL(*)} and it lies in the
972 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
974 @item @emph{Example}:
979 end program test_besj0
982 @item @emph{Specific names}:
983 @multitable @columnfractions .24 .24 .24 .24
984 @item Name @tab Argument @tab Return type @tab Option
985 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
992 @section @code{BESJ1} --- Bessel function of the first kind of order 1
993 @findex @code{BESJ1} intrinsic
994 @findex @code{DBESJ1} intrinsic
998 @item @emph{Description}:
999 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1002 @item @emph{Option}:
1008 @item @emph{Syntax}:
1011 @item @emph{Arguments}:
1012 @multitable @columnfractions .15 .80
1013 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1016 @item @emph{Return value}:
1017 The return value is of type @code{REAL(*)} and it lies in the
1018 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1020 @item @emph{Example}:
1023 real(8) :: x = 1.0_8
1025 end program test_besj1
1028 @item @emph{Specific names}:
1029 @multitable @columnfractions .24 .24 .24 .24
1030 @item Name @tab Argument @tab Return type @tab Option
1031 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1038 @section @code{BESJN} --- Bessel function of the first kind
1039 @findex @code{BESJN} intrinsic
1040 @findex @code{DBESJN} intrinsic
1044 @item @emph{Description}:
1045 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1048 @item @emph{Option}:
1054 @item @emph{Syntax}:
1055 @code{Y = BESJN(N, X)}
1057 @item @emph{Arguments}:
1058 @multitable @columnfractions .15 .80
1059 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1060 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1063 @item @emph{Return value}:
1064 The return value is a scalar of type @code{REAL(*)}.
1066 @item @emph{Example}:
1069 real(8) :: x = 1.0_8
1071 end program test_besjn
1074 @item @emph{Specific names}:
1075 @multitable @columnfractions .24 .24 .24 .24
1076 @item Name @tab Argument @tab Return type @tab Option
1077 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab gnu
1078 @item @tab @code{REAL(8) X} @tab @tab
1085 @section @code{BESY0} --- Bessel function of the second kind of order 0
1086 @findex @code{BESY0} intrinsic
1087 @findex @code{DBESY0} intrinsic
1091 @item @emph{Description}:
1092 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1095 @item @emph{Option}:
1101 @item @emph{Syntax}:
1104 @item @emph{Arguments}:
1105 @multitable @columnfractions .15 .80
1106 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1109 @item @emph{Return value}:
1110 The return value is a scalar of type @code{REAL(*)}.
1112 @item @emph{Example}:
1115 real(8) :: x = 0.0_8
1117 end program test_besy0
1120 @item @emph{Specific names}:
1121 @multitable @columnfractions .24 .24 .24 .24
1122 @item Name @tab Argument @tab Return type @tab Option
1123 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1130 @section @code{BESY1} --- Bessel function of the second kind of order 1
1131 @findex @code{BESY1} intrinsic
1132 @findex @code{DBESY1} intrinsic
1136 @item @emph{Description}:
1137 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1140 @item @emph{Option}:
1146 @item @emph{Syntax}:
1149 @item @emph{Arguments}:
1150 @multitable @columnfractions .15 .80
1151 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1154 @item @emph{Return value}:
1155 The return value is a scalar of type @code{REAL(*)}.
1157 @item @emph{Example}:
1160 real(8) :: x = 1.0_8
1162 end program test_besy1
1165 @item @emph{Specific names}:
1166 @multitable @columnfractions .24 .24 .24 .24
1167 @item Name @tab Argument @tab Return type @tab Option
1168 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1175 @section @code{BESYN} --- Bessel function of the second kind
1176 @findex @code{BESYN} intrinsic
1177 @findex @code{DBESYN} intrinsic
1181 @item @emph{Description}:
1182 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1185 @item @emph{Option}:
1191 @item @emph{Syntax}:
1192 @code{Y = BESYN(N, X)}
1194 @item @emph{Arguments}:
1195 @multitable @columnfractions .15 .80
1196 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1197 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1200 @item @emph{Return value}:
1201 The return value is a scalar of type @code{REAL(*)}.
1203 @item @emph{Example}:
1206 real(8) :: x = 1.0_8
1208 end program test_besyn
1211 @item @emph{Specific names}:
1212 @multitable @columnfractions .24 .24 .24 .24
1213 @item Name @tab Argument @tab Return type @tab Option
1214 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab gnu
1215 @item @tab @code{REAL(8) X} @tab @tab
1222 @section @code{BIT_SIZE} --- Bit size inquiry function
1223 @findex @code{BIT_SIZE} intrinsic
1227 @item @emph{Description}:
1228 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit) represented by the type of @var{I}.
1230 @item @emph{Option}:
1236 @item @emph{Syntax}:
1237 @code{I = BIT_SIZE(I)}
1239 @item @emph{Arguments}:
1240 @multitable @columnfractions .15 .80
1241 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1244 @item @emph{Return value}:
1245 The return value is of type @code{INTEGER(*)}
1247 @item @emph{Example}:
1249 program test_bit_size
1254 end program test_bit_size
1261 @section @code{BTEST} --- Bit test function
1262 @findex @code{BTEST} intrinsic
1266 @item @emph{Description}:
1267 @code{BTEST(I,POS)} returns logical .TRUE. if the bit at @var{POS} in @var{I} is set.
1269 @item @emph{Option}:
1275 @item @emph{Syntax}:
1276 @code{I = BTEST(I,POS)}
1278 @item @emph{Arguments}:
1279 @multitable @columnfractions .15 .80
1280 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1281 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1284 @item @emph{Return value}:
1285 The return value is of type @code{LOGICAL}
1287 @item @emph{Example}:
1290 integer :: i = 32768 + 1024 + 64
1294 bool = btest(i, pos)
1297 end program test_btest
1304 @section @code{CEILING} --- Integer ceiling function
1305 @findex @code{CEILING} intrinsic
1309 @item @emph{Description}:
1310 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1312 @item @emph{Option}:
1318 @item @emph{Syntax}:
1319 @code{X = CEILING(X[,KIND])}
1321 @item @emph{Arguments}:
1322 @multitable @columnfractions .15 .80
1323 @item @var{X} @tab The type shall be @code{REAL(*)}.
1324 @item @var{KIND} @tab Optional scaler integer initialization expression.
1327 @item @emph{Return value}:
1328 The return value is of type @code{INTEGER(KIND)}
1330 @item @emph{Example}:
1332 program test_ceiling
1335 print *, ceiling(x) ! returns 64
1336 print *, ceiling(y) ! returns -63
1337 end program test_ceiling
1344 @section @code{CHAR} --- Character conversion function
1345 @findex @code{CHAR} intrinsic
1349 @item @emph{Description}:
1350 @code{CHAR(I,[KIND])} returns the character represented by the integer @var{I}.
1352 @item @emph{Option}:
1358 @item @emph{Syntax}:
1359 @code{C = CHAR(I[,KIND])}
1361 @item @emph{Arguments}:
1362 @multitable @columnfractions .15 .80
1363 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1364 @item @var{KIND} @tab Optional scaler integer initialization expression.
1367 @item @emph{Return value}:
1368 The return value is of type @code{CHARACTER(1)}
1370 @item @emph{Example}:
1376 print *, i, c ! returns 'J'
1377 end program test_char
1384 @section @code{CMPLX} --- Complex conversion function
1385 @findex @code{CMPLX} intrinsic
1389 @item @emph{Description}:
1390 @code{CMPLX(X,[Y,KIND])} returns a complex number where @var{X} is converted to
1391 the real component. If @var{Y} is present it is converted to the imaginary
1392 component. If @var{Y} is not present then the imaginary component is set to
1393 0.0. If @var{X} is complex then @var{Y} must not be present.
1395 @item @emph{Option}:
1401 @item @emph{Syntax}:
1402 @code{C = CMPLX(X[,Y,KIND])}
1404 @item @emph{Arguments}:
1405 @multitable @columnfractions .15 .80
1406 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
1407 @item @var{Y} @tab Optional, allowed if @var{X} is not @code{COMPLEX(*)}. May be @code{INTEGER(*)} or @code{REAL(*)}.
1408 @item @var{KIND} @tab Optional scaler integer initialization expression.
1411 @item @emph{Return value}:
1412 The return value is of type @code{COMPLEX(*)}
1414 @item @emph{Example}:
1421 print *, z, cmplx(x)
1422 end program test_cmplx
1428 @node COMMAND_ARGUMENT_COUNT
1429 @section @code{COMMAND_ARGUMENT_COUNT} --- Argument count function
1430 @findex @code{COMMAND_ARGUMENT_COUNT} intrinsic
1431 @cindex command argument count
1434 @item @emph{Description}:
1435 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
1436 command line when the containing program was invoked.
1438 @item @emph{Option}:
1442 non-elemental function
1444 @item @emph{Syntax}:
1445 @code{I = COMMAND_ARGUMENT_COUNT()}
1447 @item @emph{Arguments}:
1448 @multitable @columnfractions .15 .80
1452 @item @emph{Return value}:
1453 The return value is of type @code{INTEGER(4)}
1455 @item @emph{Example}:
1457 program test_command_argument_count
1459 count = command_argument_count()
1461 end program test_command_argument_count
1468 @section @code{CONJG} --- Complex conjugate function
1469 @findex @code{CONJG} intrinsic
1470 @findex @code{DCONJG} intrinsic
1471 @cindex complex conjugate
1473 @item @emph{Description}:
1474 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
1475 then the result is @code{(x, -y)}
1477 @item @emph{Option}:
1483 @item @emph{Syntax}:
1486 @item @emph{Arguments}:
1487 @multitable @columnfractions .15 .80
1488 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
1491 @item @emph{Return value}:
1492 The return value is of type @code{COMPLEX(*)}.
1494 @item @emph{Example}:
1497 complex :: z = (2.0, 3.0)
1498 complex(8) :: dz = (2.71_8, -3.14_8)
1503 end program test_conjg
1506 @item @emph{Specific names}:
1507 @multitable @columnfractions .24 .24 .24 .24
1508 @item Name @tab Argument @tab Return type @tab Option
1509 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
1516 @section @code{COS} --- Cosine function
1517 @findex @code{COS} intrinsic
1518 @findex @code{DCOS} intrinsic
1519 @findex @code{ZCOS} intrinsic
1520 @findex @code{CDCOS} intrinsic
1524 @item @emph{Description}:
1525 @code{COS(X)} computes the cosine of @var{X}.
1527 @item @emph{Option}:
1533 @item @emph{Syntax}:
1536 @item @emph{Arguments}:
1537 @multitable @columnfractions .15 .80
1538 @item @var{X} @tab The type shall be @code{REAL(*)} or
1542 @item @emph{Return value}:
1543 The return value has the same type and kind as @var{X}.
1545 @item @emph{Example}:
1550 end program test_cos
1553 @item @emph{Specific names}:
1554 @multitable @columnfractions .24 .24 .24 .24
1555 @item Name @tab Argument @tab Return type @tab Option
1556 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
1557 @item @code{CCOS(X)}@tab @code{COMPLEX(4) X}@tab @code{COMPLEX(4)}@tab f95, gnu
1558 @item @code{ZCOS(X)}@tab @code{COMPLEX(8) X}@tab @code{COMPLEX(8)}@tab f95, gnu
1559 @item @code{CDCOS(X)}@tab @code{COMPLEX(8) X}@tab @code{COMPLEX(8)}@tab f95, gnu
1566 @section @code{COSH} --- Hyperbolic cosine function
1567 @findex @code{COSH} intrinsic
1568 @findex @code{DCOSH} intrinsic
1569 @cindex hyperbolic cosine
1572 @item @emph{Description}:
1573 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
1575 @item @emph{Option}:
1581 @item @emph{Syntax}:
1584 @item @emph{Arguments}:
1585 @multitable @columnfractions .15 .80
1586 @item @var{X} @tab The type shall be @code{REAL(*)}.
1589 @item @emph{Return value}:
1590 The return value is of type @code{REAL(*)} and it is positive
1591 (@math{ \cosh (x) \geq 0 }.
1593 @item @emph{Example}:
1596 real(8) :: x = 1.0_8
1598 end program test_cosh
1601 @item @emph{Specific names}:
1602 @multitable @columnfractions .24 .24 .24 .24
1603 @item Name @tab Argument @tab Return type @tab Option
1604 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
1611 @section @code{COUNT} --- Count function
1612 @findex @code{COUNT} intrinsic
1616 @item @emph{Description}:
1617 @code{COUNT(MASK[,DIM])} counts the number of @code{.TRUE.} elements of
1618 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
1619 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
1620 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
1622 @item @emph{Option}:
1626 transformational function
1628 @item @emph{Syntax}:
1629 @code{I = COUNT(MASK[,DIM])}
1631 @item @emph{Arguments}:
1632 @multitable @columnfractions .15 .80
1633 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
1634 @item @var{DIM} @tab The type shall be @code{INTEGER}.
1637 @item @emph{Return value}:
1638 The return value is of type @code{INTEGER} with rank equal to that of
1641 @item @emph{Example}:
1644 integer, dimension(2,3) :: a, b
1645 logical, dimension(2,3) :: mask
1646 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
1647 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
1648 print '(3i3)', a(1,:)
1649 print '(3i3)', a(2,:)
1651 print '(3i3)', b(1,:)
1652 print '(3i3)', b(2,:)
1655 print '(3l3)', mask(1,:)
1656 print '(3l3)', mask(2,:)
1658 print '(3i3)', count(mask)
1660 print '(3i3)', count(mask, 1)
1662 print '(3i3)', count(mask, 2)
1663 end program test_count
1670 @section @code{CPU_TIME} --- CPU elapsed time in seconds
1671 @findex @code{CPU_TIME} intrinsic
1675 @item @emph{Description}:
1676 Returns a @code{REAL} value representing the elapsed CPU time in seconds. This
1677 is useful for testing segments of code to determine execution time.
1679 @item @emph{Option}:
1685 @item @emph{Syntax}:
1688 @item @emph{Arguments}:
1689 @multitable @columnfractions .15 .80
1690 @item @var{X} @tab The type shall be @code{REAL} with intent out.
1693 @item @emph{Return value}:
1696 @item @emph{Example}:
1698 program test_cpu_time
1699 real :: start, finish
1700 call cpu_time(start)
1701 ! put code to test here
1702 call cpu_time(finish)
1703 print '("Time = ",f6.3," seconds.")',finish-start
1704 end program test_cpu_time
1711 @section @code{CSHIFT} --- Circular shift function
1712 @findex @code{CSHIFT} intrinsic
1713 @cindex cshift intrinsic
1716 @item @emph{Description}:
1717 @code{CSHIFT(ARRAY, SHIFT[,DIM])} performs a circular shift on elements of
1718 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
1719 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
1720 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
1721 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
1722 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
1723 sections of @var{ARRAY} along the given dimension are shifted. Elements
1724 shifted out one end of each rank one section are shifted back in the other end.
1726 @item @emph{Option}:
1730 transformational function
1732 @item @emph{Syntax}:
1733 @code{A = CSHIFT(A, SHIFT[,DIM])}
1735 @item @emph{Arguments}:
1736 @multitable @columnfractions .15 .80
1737 @item @var{ARRAY} @tab May be any type, not scaler.
1738 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
1739 @item @var{DIM} @tab The type shall be @code{INTEGER}.
1742 @item @emph{Return value}:
1743 Returns an array of same type and rank as the @var{ARRAY} argument.
1745 @item @emph{Example}:
1748 integer, dimension(3,3) :: a
1749 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
1750 print '(3i3)', a(1,:)
1751 print '(3i3)', a(2,:)
1752 print '(3i3)', a(3,:)
1753 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
1755 print '(3i3)', a(1,:)
1756 print '(3i3)', a(2,:)
1757 print '(3i3)', a(3,:)
1758 end program test_cshift
1765 @section @code{DATE_AND_TIME} --- Date and time subroutine
1766 @findex @code{DATE_AND_TIME} intrinsic
1767 @cindex DATE_AND_TIME
1770 @item @emph{Description}:
1771 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
1772 time information from the real-time system clock. @var{DATE} is
1773 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
1774 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
1775 representing the difference with respect to Coordinated Universal Time (UTC).
1776 Unavailable time and date parameters return blanks.
1778 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
1780 @multitable @columnfractions .15 .30 .60
1781 @item @tab @code{VALUE(1)}: @tab The year
1782 @item @tab @code{VALUE(2)}: @tab The month
1783 @item @tab @code{VALUE(3)}: @tab The day of the month
1784 @item @tab @code{VAlUE(4)}: @tab Time difference with UTC in minutes
1785 @item @tab @code{VALUE(5)}: @tab The hour of the day
1786 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
1787 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
1788 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
1791 @item @emph{Option}:
1797 @item @emph{Syntax}:
1798 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
1800 @item @emph{Arguments}:
1801 @multitable @columnfractions .15 .80
1802 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
1803 @item @var{TIME} @tab (OPtional) The type shall be @code{CHARACTER(10)} or larger.
1804 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
1805 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
1808 @item @emph{Return value}:
1811 @item @emph{Example}:
1813 program test_time_and_date
1814 character(8) :: date
1815 character(10) :: time
1816 character(5) :: zone
1817 integer,dimension(8) :: values
1818 ! using keyword arguments
1819 call date_and_time(date,time,zone,values)
1820 call date_and_time(DATE=date,ZONE=zone)
1821 call date_and_time(TIME=time)
1822 call date_and_time(VALUES=values)
1823 print '(a,2x,a,2x,a)', date, time, zone
1824 print '(8i5))', values
1825 end program test_time_and_date
1832 @section @code{DBLE} --- Double conversion function
1833 @findex @code{DBLE} intrinsic
1834 @cindex double conversion
1837 @item @emph{Description}:
1838 @code{DBLE(X)} Converts @var{X} to double precision real type.
1839 @code{DFLOAT} is an alias for @code{DBLE}
1841 @item @emph{Option}:
1847 @item @emph{Syntax}:
1849 @code{X = DFLOAT(X)}
1851 @item @emph{Arguments}:
1852 @multitable @columnfractions .15 .80
1853 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
1856 @item @emph{Return value}:
1857 The return value is of type double precision real.
1859 @item @emph{Example}:
1864 complex :: z = (2.3,1.14)
1865 print *, dble(x), dble(i), dfloat(z)
1866 end program test_dble
1873 @section @code{DCMPLX} --- Double complex conversion function
1874 @findex @code{DCMPLX} intrinsic
1878 @item @emph{Description}:
1879 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
1880 converted to the real component. If @var{Y} is present it is converted to the
1881 imaginary component. If @var{Y} is not present then the imaginary component is
1882 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
1884 @item @emph{Option}:
1890 @item @emph{Syntax}:
1891 @code{C = DCMPLX(X)}
1892 @code{C = DCMPLX(X,Y)}
1894 @item @emph{Arguments}:
1895 @multitable @columnfractions .15 .80
1896 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
1897 @item @var{Y} @tab Optional if @var{X} is not @code{COMPLEX(*)}. May be @code{INTEGER(*)} or @code{REAL(*)}.
1900 @item @emph{Return value}:
1901 The return value is of type @code{COMPLEX(8)}
1903 @item @emph{Example}:
1913 print *, dcmplx(x,i)
1914 end program test_dcmplx
1921 @section @code{DFLOAT} --- Double conversion function
1922 @findex @code{DFLOAT} intrinsic
1923 @cindex double float conversion
1926 @item @emph{Description}:
1927 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
1928 @code{DFLOAT} is an alias for @code{DBLE}. See @code{DBLE}.
1934 @section @code{DIGITS} --- Significant digits function
1935 @findex @code{DIGITS} intrinsic
1936 @cindex digits, significant
1939 @item @emph{Description}:
1940 @code{DIGITS(X)} returns the number of significant digits of the internal model
1941 representation of @var{X}. For example, on a system using a 32-bit
1942 floating point representation, a default real number would likely return 24.
1944 @item @emph{Option}:
1950 @item @emph{Syntax}:
1951 @code{C = DIGITS(X)}
1953 @item @emph{Arguments}:
1954 @multitable @columnfractions .15 .80
1955 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
1958 @item @emph{Return value}:
1959 The return value is of type @code{INTEGER}.
1961 @item @emph{Example}:
1964 integer :: i = 12345
1967 complex :: z = (23.0,45.6)
1971 end program test_digits
1978 @section @code{DIM} --- Dim function
1979 @findex @code{DIM} intrinsic
1980 @findex @code{IDIM} intrinsic
1981 @findex @code{DDIM} intrinsic
1985 @item @emph{Description}:
1986 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
1987 otherwise returns zero.
1989 @item @emph{Option}:
1995 @item @emph{Syntax}:
1998 @item @emph{Arguments}:
1999 @multitable @columnfractions .15 .80
2000 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2001 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2004 @item @emph{Return value}:
2005 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2007 @item @emph{Example}:
2013 x = dim(4.345_8, 2.111_8)
2016 end program test_dim
2019 @item @emph{Specific names}:
2020 @multitable @columnfractions .24 .24 .24 .24
2021 @item Name @tab Argument @tab Return type @tab Option
2022 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab gnu
2023 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab gnu
2030 @section @code{DOT_PRODUCT} --- Dot product function
2031 @findex @code{DOT_PRODUCT} intrinsic
2035 @item @emph{Description}:
2036 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2037 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2038 and must be arrays of rank one and of equal size. If the vectors are
2039 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2040 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2041 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2043 @item @emph{Option}:
2047 transformational function
2049 @item @emph{Syntax}:
2050 @code{S = DOT_PRODUCT(X,Y)}
2052 @item @emph{Arguments}:
2053 @multitable @columnfractions .15 .80
2054 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2055 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2058 @item @emph{Return value}:
2059 If the arguments are numeric, the return value is a scaler of numeric type,
2060 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2061 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2063 @item @emph{Example}:
2065 program test_dot_prod
2066 integer, dimension(3) :: a, b
2073 print *, dot_product(a,b)
2074 end program test_dot_prod
2081 @section @code{DPROD} --- Double product function
2082 @findex @code{DPROD} intrinsic
2083 @cindex Double product
2086 @item @emph{Description}:
2087 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2089 @item @emph{Option}:
2095 @item @emph{Syntax}:
2096 @code{D = DPROD(X,Y)}
2098 @item @emph{Arguments}:
2099 @multitable @columnfractions .15 .80
2100 @item @var{X} @tab The type shall be @code{REAL}.
2101 @item @var{Y} @tab The type shall be @code{REAL}.
2104 @item @emph{Return value}:
2105 The return value is of type @code{REAL(8)}.
2107 @item @emph{Example}:
2116 end program test_dprod
2123 @section @code{DREAL} --- Double real part function
2124 @findex @code{DREAL} intrinsic
2125 @cindex Double real part
2128 @item @emph{Description}:
2129 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2131 @item @emph{Option}:
2137 @item @emph{Syntax}:
2140 @item @emph{Arguments}:
2141 @multitable @columnfractions .15 .80
2142 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2145 @item @emph{Return value}:
2146 The return value is of type @code{REAL(8)}.
2148 @item @emph{Example}:
2151 complex(8) :: z = (1.3_8,7.2_8)
2153 end program test_dreal
2160 @section @code{DTIME} --- Execution time subroutine (or function)
2161 @findex @code{DTIME} intrinsic
2162 @cindex dtime subroutine
2165 @item @emph{Description}:
2166 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2167 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2168 returns the user and system components of this time in @code{TARRAY(1)} and
2169 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
2171 Subsequent invocations of @code{DTIME} return values accumulated since the previous invocation.
2173 On some systems, the underlying timings are represented using types with
2174 sufficiently small limits that overflows (wraparounds) are possible, such as
2175 32-bit types. Therefore, the values returned by this intrinsic might be, or
2176 become, negative, or numerically less than previous values, during a single
2177 run of the compiled program.
2179 If @code{DTIME} is invoked as a function, it can not be invoked as a
2180 subroutine, and vice versa.
2182 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2184 @multitable @columnfractions .15 .30 .60
2185 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2186 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2187 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2190 @item @emph{Option}:
2196 @item @emph{Syntax}:
2197 @code{CALL DTIME(TARRAY, RESULT)}
2198 @code{RESULT = DTIME(TARRAY)}, (not recommended)
2200 @item @emph{Arguments}:
2201 @multitable @columnfractions .15 .80
2202 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2203 @item @var{RESULT}@tab The type shall be @code{REAL}.
2206 @item @emph{Return value}:
2207 Elapsed time in seconds since the start of program execution.
2209 @item @emph{Example}:
2213 real, dimension(2) :: tarray
2215 call dtime(tarray, result)
2219 do i=1,100000000 ! Just a delay
2222 call dtime(tarray, result)
2226 end program test_dtime
2233 @section @code{ERF} --- Error function
2234 @findex @code{ERF} intrinsic
2235 @cindex error function
2238 @item @emph{Description}:
2239 @code{ERF(X)} computes the error function of @var{X}.
2241 @item @emph{Option}:
2247 @item @emph{Syntax}:
2250 @item @emph{Arguments}:
2251 @multitable @columnfractions .15 .80
2252 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
2255 @item @emph{Return value}:
2256 The return value is a scalar of type @code{REAL(*)} and it is positive
2257 (@math{ - 1 \leq erf (x) \leq 1 }.
2259 @item @emph{Example}:
2262 real(8) :: x = 0.17_8
2264 end program test_erf
2267 @item @emph{Specific names}:
2268 @multitable @columnfractions .24 .24 .24 .24
2269 @item Name @tab Argument @tab Return type @tab Option
2270 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
2277 @section @code{ERFC} --- Error function
2278 @findex @code{ERFC} intrinsic
2279 @cindex error function
2282 @item @emph{Description}:
2283 @code{ERFC(X)} computes the complementary error function of @var{X}.
2285 @item @emph{Option}:
2291 @item @emph{Syntax}:
2294 @item @emph{Arguments}:
2295 @multitable @columnfractions .15 .80
2296 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
2299 @item @emph{Return value}:
2300 The return value is a scalar of type @code{REAL(*)} and it is positive
2301 (@math{ 0 \leq erfc (x) \leq 2 }.
2303 @item @emph{Example}:
2306 real(8) :: x = 0.17_8
2308 end program test_erfc
2311 @item @emph{Specific names}:
2312 @multitable @columnfractions .24 .24 .24 .24
2313 @item Name @tab Argument @tab Return type @tab Option
2314 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
2321 @section @code{EXP} --- Exponential function
2322 @findex @code{EXP} intrinsic
2323 @findex @code{DEXP} intrinsic
2324 @findex @code{ZEXP} intrinsic
2325 @findex @code{CDEXP} intrinsic
2329 @item @emph{Description}:
2330 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
2332 @item @emph{Option}:
2338 @item @emph{Syntax}:
2341 @item @emph{Arguments}:
2342 @multitable @columnfractions .15 .80
2343 @item @var{X} @tab The type shall be @code{REAL(*)} or
2347 @item @emph{Return value}:
2348 The return value has same type and kind as @var{X}.
2350 @item @emph{Example}:
2355 end program test_exp
2358 @item @emph{Specific names}:
2359 @multitable @columnfractions .24 .24 .24 .24
2360 @item Name @tab Argument @tab Return type @tab Option
2361 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
2362 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
2363 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2364 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2371 @section @code{LOG} --- Logarithm function
2372 @findex @code{LOG} intrinsic
2373 @findex @code{ALOG} intrinsic
2374 @findex @code{DLOG} intrinsic
2375 @findex @code{CLOG} intrinsic
2376 @findex @code{ZLOG} intrinsic
2377 @findex @code{CDLOG} intrinsic
2381 @item @emph{Description}:
2382 @code{LOG(X)} computes the logarithm of @var{X}.
2384 @item @emph{Option}:
2390 @item @emph{Syntax}:
2393 @item @emph{Arguments}:
2394 @multitable @columnfractions .15 .80
2395 @item @var{X} @tab The type shall be @code{REAL(*)} or
2399 @item @emph{Return value}:
2400 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
2401 The kind type parameter is the same as @var{X}.
2403 @item @emph{Example}:
2406 real(8) :: x = 1.0_8
2407 complex :: z = (1.0, 2.0)
2410 end program test_log
2413 @item @emph{Specific names}:
2414 @multitable @columnfractions .24 .24 .24 .24
2415 @item Name @tab Argument @tab Return type @tab Option
2416 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
2417 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
2418 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
2419 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2420 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2427 @section @code{LOG10} --- Base 10 logarithm function
2428 @findex @code{LOG10} intrinsic
2429 @findex @code{ALOG10} intrinsic
2430 @findex @code{DLOG10} intrinsic
2434 @item @emph{Description}:
2435 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
2437 @item @emph{Option}:
2443 @item @emph{Syntax}:
2446 @item @emph{Arguments}:
2447 @multitable @columnfractions .15 .80
2448 @item @var{X} @tab The type shall be @code{REAL(*)} or
2452 @item @emph{Return value}:
2453 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
2454 The kind type parameter is the same as @var{X}.
2456 @item @emph{Example}:
2459 real(8) :: x = 10.0_8
2461 end program test_log10
2464 @item @emph{Specific names}:
2465 @multitable @columnfractions .24 .24 .24 .24
2466 @item Name @tab Argument @tab Return type @tab Option
2467 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
2468 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
2475 @section @code{SIN} --- Sine function
2476 @findex @code{SIN} intrinsic
2477 @findex @code{DSIN} intrinsic
2478 @findex @code{ZSIN} intrinsic
2479 @findex @code{CDSIN} intrinsic
2483 @item @emph{Description}:
2484 @code{SIN(X)} computes the sine of @var{X}.
2486 @item @emph{Option}:
2492 @item @emph{Syntax}:
2495 @item @emph{Arguments}:
2496 @multitable @columnfractions .15 .80
2497 @item @var{X} @tab The type shall be @code{REAL(*)} or
2501 @item @emph{Return value}:
2502 The return value has same type and king than @var{X}.
2504 @item @emph{Example}:
2509 end program test_sin
2512 @item @emph{Specific names}:
2513 @multitable @columnfractions .24 .24 .24 .24
2514 @item Name @tab Argument @tab Return type @tab Option
2515 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
2516 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
2517 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2518 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2525 @section @code{SINH} --- Hyperbolic sine function
2526 @findex @code{SINH} intrinsic
2527 @findex @code{DSINH} intrinsic
2528 @cindex hyperbolic sine
2531 @item @emph{Description}:
2532 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
2534 @item @emph{Option}:
2540 @item @emph{Syntax}:
2543 @item @emph{Arguments}:
2544 @multitable @columnfractions .15 .80
2545 @item @var{X} @tab The type shall be @code{REAL(*)}.
2548 @item @emph{Return value}:
2549 The return value is of type @code{REAL(*)}.
2551 @item @emph{Example}:
2554 real(8) :: x = - 1.0_8
2556 end program test_sinh
2559 @item @emph{Specific names}:
2560 @multitable @columnfractions .24 .24 .24 .24
2561 @item Name @tab Argument @tab Return type @tab Option
2562 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
2569 @section @code{SQRT} --- Square-root function
2570 @findex @code{SQRT} intrinsic
2571 @findex @code{DSQRT} intrinsic
2572 @findex @code{CSQRT} intrinsic
2573 @findex @code{ZSQRT} intrinsic
2574 @findex @code{CDSQRT} intrinsic
2578 @item @emph{Description}:
2579 @code{SQRT(X)} computes the square root of @var{X}.
2581 @item @emph{Option}:
2587 @item @emph{Syntax}:
2590 @item @emph{Arguments}:
2591 @multitable @columnfractions .15 .80
2592 @item @var{X} @tab The type shall be @code{REAL(*)} or
2596 @item @emph{Return value}:
2597 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
2598 The kind type parameter is the same as @var{X}.
2600 @item @emph{Example}:
2603 real(8) :: x = 2.0_8
2604 complex :: z = (1.0, 2.0)
2607 end program test_sqrt
2610 @item @emph{Specific names}:
2611 @multitable @columnfractions .24 .24 .24 .24
2612 @item Name @tab Argument @tab Return type @tab Option
2613 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
2614 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
2615 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2616 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2623 @section @code{TAN} --- Tangent function
2624 @findex @code{TAN} intrinsic
2625 @findex @code{DTAN} intrinsic
2629 @item @emph{Description}:
2630 @code{TAN(X)} computes the tangent of @var{X}.
2632 @item @emph{Option}:
2638 @item @emph{Syntax}:
2641 @item @emph{Arguments}:
2642 @multitable @columnfractions .15 .80
2643 @item @var{X} @tab The type shall be @code{REAL(*)}.
2646 @item @emph{Return value}:
2647 The return value is of type @code{REAL(*)}. The kind type parameter is
2648 the same as @var{X}.
2650 @item @emph{Example}:
2653 real(8) :: x = 0.165_8
2655 end program test_tan
2658 @item @emph{Specific names}:
2659 @multitable @columnfractions .24 .24 .24 .24
2660 @item Name @tab Argument @tab Return type @tab Option
2661 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
2668 @section @code{TANH} --- Hyperbolic tangent function
2669 @findex @code{TANH} intrinsic
2670 @findex @code{DTANH} intrinsic
2671 @cindex hyperbolic tangent
2674 @item @emph{Description}:
2675 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
2677 @item @emph{Option}:
2683 @item @emph{Syntax}:
2686 @item @emph{Arguments}:
2687 @multitable @columnfractions .15 .80
2688 @item @var{X} @tab The type shall be @code{REAL(*)}.
2691 @item @emph{Return value}:
2692 The return value is of type @code{REAL(*)} and lies in the range
2693 @math{ - 1 \leq tanh(x) \leq 1 }.
2695 @item @emph{Example}:
2698 real(8) :: x = 2.1_8
2700 end program test_tanh
2703 @item @emph{Specific names}:
2704 @multitable @columnfractions .24 .24 .24 .24
2705 @item Name @tab Argument @tab Return type @tab Option
2706 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
2712 @comment gen eoshift
2714 @comment gen epsilon
2721 @comment gen exponent
2729 @comment gen fraction
2747 @comment sub get_command
2749 @comment sub get_command_argument
2751 @comment sub get_environment_variable
2791 @comment gen len_trim
2801 @comment gen logical
2812 @comment gen maxexponent
2827 @comment gen minexponent
2841 @comment gen nearest
2852 @comment gen precision
2854 @comment gen present
2856 @comment gen product
2863 @comment sub random_number
2865 @comment sub random_seed
2875 @comment gen reshape
2877 @comment gen rrspacing
2886 @comment gen selected_int_kind
2888 @comment gen selected_real_kind
2890 @comment gen set_exponent
2900 @comment gen spacing
2914 @comment sub system_clock
2918 @comment gen transfer
2920 @comment gen transpose