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, 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{FNUM}: FNUM, File number function
94 * @code{FREE}: FREE, Memory de-allocation subroutine
95 * @code{LOC}: LOC, Returns the address of a variable
96 * @code{LOG}: LOG, Logarithm function
97 * @code{LOG10}: LOG10, Base 10 logarithm function
98 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
99 * @code{REAL}: REAL, Convert to real type
100 * @code{SECNDS}: SECNDS, Time function
101 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
102 * @code{SIN}: SIN, Sine function
103 * @code{SINH}: SINH, Hyperbolic sine function
104 * @code{SQRT}: SQRT, Square-root function
105 * @code{TAN}: TAN, Tangent function
106 * @code{TANH}: TANH, Hyperbolic tangent function
110 @section Introduction to intrinsic procedures
112 Gfortran provides a rich set of intrinsic procedures that includes all
113 the intrinsic procedures required by the Fortran 95 standard, a set of
114 intrinsic procedures for backwards compatibility with Gnu Fortran 77
115 (i.e., @command{g77}), and a small selection of intrinsic procedures
116 from the Fortran 2003 standard. Any description here, which conflicts with a
117 description in either the Fortran 95 standard or the Fortran 2003 standard,
118 is unintentional and the standard(s) should be considered authoritative.
120 The enumeration of the @code{KIND} type parameter is processor defined in
121 the Fortran 95 standard. Gfortran defines the default integer type and
122 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
123 respectively. The standard mandates that both data types shall have
124 another kind, which have more precision. On typical target architectures
125 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
126 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
127 In the description of generic intrinsic procedures, the kind type parameter
128 will be specified by @code{KIND=*}, and in the description of specific
129 names for an intrinsic procedure the kind type parameter will be explicitly
130 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
131 brevity the optional @code{KIND=} syntax will be omitted.
133 Many of the intrinsics procedures take one or more optional arguments.
134 This document follows the convention used in the Fortran 95 standard,
135 and denotes such arguments by square brackets.
137 @command{Gfortran} offers the @option{-std=f95} and @option{-std=gnu} options,
138 which can be used to restrict the set of intrinsic procedures to a
139 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
140 option, and so all intrinsic procedures described here are accepted. There
141 is one caveat. For a select group of intrinsic procedures, @command{g77}
142 implemented both a function and a subroutine. Both classes
143 have been implemented in @command{gfortran} for backwards compatibility
144 with @command{g77}. It is noted here that these functions and subroutines
145 cannot be intermixed in a given subprogram. In the descriptions that follow,
146 the applicable option(s) is noted.
151 @section @code{ABORT} --- Abort the program
156 @item @emph{Description}:
157 @code{ABORT} causes immediate termination of the program. On operating
158 systems that support a core dump, @code{ABORT} will produce a core dump,
159 which is suitable for debugging purposes.
165 non-elemental subroutine
170 @item @emph{Return value}:
173 @item @emph{Example}:
176 integer :: i = 1, j = 2
177 if (i /= j) call abort
178 end program test_abort
185 @section @code{ABS} --- Absolute value
186 @findex @code{ABS} intrinsic
187 @findex @code{CABS} intrinsic
188 @findex @code{DABS} intrinsic
189 @findex @code{IABS} intrinsic
190 @findex @code{ZABS} intrinsic
191 @findex @code{CDABS} intrinsic
192 @cindex absolute value
195 @item @emph{Description}:
196 @code{ABS(X)} computes the absolute value of @code{X}.
207 @item @emph{Arguments}:
208 @multitable @columnfractions .15 .80
209 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
210 @code{REAL(*)}, or @code{COMPLEX(*)}.
213 @item @emph{Return value}:
214 The return value is of the same type and
215 kind as the argument except the return value is @code{REAL(*)} for a
216 @code{COMPLEX(*)} argument.
218 @item @emph{Example}:
223 complex :: z = (-1.e0,0.e0)
230 @item @emph{Specific names}:
231 @multitable @columnfractions .24 .24 .24 .24
232 @item Name @tab Argument @tab Return type @tab Option
233 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab f95, gnu
234 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
235 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab f95, gnu
236 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
237 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
244 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
245 @findex @code{ACHAR} intrinsic
246 @cindex @acronym{ASCII} collating sequence
249 @item @emph{Description}:
250 @code{ACHAR(I)} returns the character located at position @code{I}
251 in the @acronym{ASCII} collating sequence.
262 @item @emph{Arguments}:
263 @multitable @columnfractions .15 .80
264 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
267 @item @emph{Return value}:
268 The return value is of type @code{CHARACTER} with a length of one. The
269 kind type parameter is the same as @code{KIND('A')}.
271 @item @emph{Example}:
276 end program test_achar
283 @section @code{ACOS} --- Arc cosine function
284 @findex @code{ACOS} intrinsic
285 @findex @code{DACOS} intrinsic
289 @item @emph{Description}:
290 @code{ACOS(X)} computes the arc cosine of @var{X}.
301 @item @emph{Arguments}:
302 @multitable @columnfractions .15 .80
303 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
307 @item @emph{Return value}:
308 The return value is of type @code{REAL(*)} and it lies in the
309 range @math{ 0 \leq \arccos (x) \leq \pi}. The kind type
310 parameter is the same as @var{X}.
312 @item @emph{Example}:
315 real(8) :: x = 0.866_8
317 end program test_acos
320 @item @emph{Specific names}:
321 @multitable @columnfractions .24 .24 .24 .24
322 @item Name @tab Argument @tab Return type @tab Option
323 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
330 @section @code{ADJUSTL} --- Left adjust a string
331 @findex @code{ADJUSTL} intrinsic
332 @cindex adjust string
335 @item @emph{Description}:
336 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
337 Spaces are inserted at the end of the string as needed.
346 @code{STR = ADJUSTL(STR)}
348 @item @emph{Arguments}:
349 @multitable @columnfractions .15 .80
350 @item @var{STR} @tab The type shall be @code{CHARACTER}.
353 @item @emph{Return value}:
354 The return value is of type @code{CHARACTER} where leading spaces
355 are removed and the same number of spaces are inserted on the end
358 @item @emph{Example}:
361 character(len=20) :: str = ' gfortran'
364 end program test_adjustl
371 @section @code{ADJUSTR} --- Right adjust a string
372 @findex @code{ADJUSTR} intrinsic
373 @cindex adjust string
376 @item @emph{Description}:
377 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
378 Spaces are inserted at the start of the string as needed.
387 @code{STR = ADJUSTR(STR)}
389 @item @emph{Arguments}:
390 @multitable @columnfractions .15 .80
391 @item @var{STR} @tab The type shall be @code{CHARACTER}.
394 @item @emph{Return value}:
395 The return value is of type @code{CHARACTER} where trailing spaces
396 are removed and the same number of spaces are inserted at the start
399 @item @emph{Example}:
402 character(len=20) :: str = 'gfortran'
405 end program test_adjustr
412 @section @code{AIMAG} --- Imaginary part of complex number
413 @findex @code{AIMAG} intrinsic
414 @findex @code{DIMAG} intrinsic
415 @findex @code{IMAG} intrinsic
416 @findex @code{IMAGPART} intrinsic
417 @cindex Imaginary part
420 @item @emph{Description}:
421 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
422 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
423 for compatibility with @command{g77}, and their use in new code is
424 strongly discouraged.
435 @item @emph{Arguments}:
436 @multitable @columnfractions .15 .80
437 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
440 @item @emph{Return value}:
441 The return value is of type real with the
442 kind type parameter of the argument.
444 @item @emph{Example}:
449 z4 = cmplx(1.e0_4, 0.e0_4)
450 z8 = cmplx(0.e0_8, 1.e0_8)
451 print *, aimag(z4), dimag(z8)
452 end program test_aimag
455 @item @emph{Specific names}:
456 @multitable @columnfractions .24 .24 .24 .24
457 @item Name @tab Argument @tab Return type @tab Option
458 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab f95, gnu
459 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab gnu
460 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab gnu
467 @section @code{AINT} --- Imaginary part of complex number
468 @findex @code{AINT} intrinsic
469 @findex @code{DINT} intrinsic
473 @item @emph{Description}:
474 @code{AINT(X [, KIND])} truncates its argument to a whole number.
484 @code{X = AINT(X, KIND)}
486 @item @emph{Arguments}:
487 @multitable @columnfractions .15 .80
488 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
489 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
490 initialization expression.
493 @item @emph{Return value}:
494 The return value is of type real with the kind type parameter of the
495 argument if the optional @var{KIND} is absent; otherwise, the kind
496 type parameter will be given by @var{KIND}. If the magnitude of
497 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
498 magnitude is equal to or greater than one, then it returns the largest
499 whole number that does not exceed its magnitude. The sign is the same
500 as the sign of @var{X}.
502 @item @emph{Example}:
509 print *, aint(x4), dint(x8)
511 end program test_aint
514 @item @emph{Specific names}:
515 @multitable @columnfractions .24 .24 .24 .24
516 @item Name @tab Argument @tab Return type @tab Option
517 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
524 @section @code{ALARM} --- Execute a routine after a given delay
525 @findex @code{ALARM} intrinsic
528 @item @emph{Description}:
529 @code{ALARM(SECONDS [, STATUS])} causes external subroutine @var{HANDLER}
530 to be executed after a delay of @var{SECONDS} by using @code{alarm(1)} to
531 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
532 supplied, it will be returned with the number of seconds remaining until
533 any previously scheduled alarm was due to be delivered, or zero if there
534 was no previously scheduled alarm.
543 @code{CALL ALARM(SECONDS, HANDLER)}
544 @code{CALL ALARM(SECONDS, HANDLER, STATUS)}
546 @item @emph{Arguments}:
547 @multitable @columnfractions .15 .80
548 @item @var{SECONDS} @tab The type of the argument shall be a scalar
549 @code{INTEGER}. It is @code{INTENT(IN)}.
550 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
551 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
552 @code{INTEGER}. It is @code{INTENT(IN)}.
553 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
554 @code{INTEGER} variable. It is @code{INTENT(OUT)}.
557 @item @emph{Example}:
560 external handler_print
562 call alarm (3, handler_print, i)
565 end program test_alarm
567 This will cause the external routine @var{handler_print} to be called
574 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
575 @findex @code{ALL} intrinsic
579 @item @emph{Description}:
580 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
581 in the array along dimension @var{DIM}.
587 transformational function
591 @code{L = ALL(MASK, DIM)}
593 @item @emph{Arguments}:
594 @multitable @columnfractions .15 .80
595 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
596 it shall not be scalar.
597 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
598 with a value that lies between one and the rank of @var{MASK}.
601 @item @emph{Return value}:
602 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
603 the kind type parameter is the same as the kind type parameter of
604 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
605 an array with the rank of @var{MASK} minus 1. The shape is determined from
606 the shape of @var{MASK} where the @var{DIM} dimension is elided.
610 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
611 It also is true if @var{MASK} has zero size; otherwise, it is false.
613 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
614 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
615 is determined by applying @code{ALL} to the array sections.
618 @item @emph{Example}:
622 l = all((/.true., .true., .true./))
627 integer a(2,3), b(2,3)
631 print *, all(a .eq. b, 1)
632 print *, all(a .eq. b, 2)
633 end subroutine section
641 @section @code{ALLOCATED} --- Status of an allocatable entity
642 @findex @code{ALLOCATED} intrinsic
643 @cindex allocation status
646 @item @emph{Description}:
647 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
656 @code{L = ALLOCATED(X)}
658 @item @emph{Arguments}:
659 @multitable @columnfractions .15 .80
660 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
663 @item @emph{Return value}:
664 The return value is a scalar @code{LOGICAL} with the default logical
665 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
666 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
668 @item @emph{Example}:
670 program test_allocated
672 real(4), allocatable :: x(:)
673 if (allocated(x) .eqv. .false.) allocate(x(i)
674 end program test_allocated
681 @section @code{ANINT} --- Imaginary part of complex number
682 @findex @code{ANINT} intrinsic
683 @findex @code{DNINT} intrinsic
687 @item @emph{Description}:
688 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
698 @code{X = ANINT(X, KIND)}
700 @item @emph{Arguments}:
701 @multitable @columnfractions .15 .80
702 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
703 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
704 initialization expression.
707 @item @emph{Return value}:
708 The return value is of type real with the kind type parameter of the
709 argument if the optional @var{KIND} is absent; otherwise, the kind
710 type parameter will be given by @var{KIND}. If @var{X} is greater than
711 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
712 less than or equal to zero, then return @code{AINT(X-0.5)}.
714 @item @emph{Example}:
721 print *, anint(x4), dnint(x8)
723 end program test_anint
726 @item @emph{Specific names}:
727 @multitable @columnfractions .24 .24 .24 .24
728 @item Name @tab Argument @tab Return type @tab Option
729 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
736 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
737 @findex @code{ANY} intrinsic
741 @item @emph{Description}:
742 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
743 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
749 transformational function
753 @code{L = ANY(MASK, DIM)}
755 @item @emph{Arguments}:
756 @multitable @columnfractions .15 .80
757 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
758 it shall not be scalar.
759 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
760 with a value that lies between one and the rank of @var{MASK}.
763 @item @emph{Return value}:
764 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
765 the kind type parameter is the same as the kind type parameter of
766 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
767 an array with the rank of @var{MASK} minus 1. The shape is determined from
768 the shape of @var{MASK} where the @var{DIM} dimension is elided.
772 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
773 otherwise, it is false. It also is false if @var{MASK} has zero size.
775 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
776 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
777 is determined by applying @code{ANY} to the array sections.
780 @item @emph{Example}:
784 l = any((/.true., .true., .true./))
789 integer a(2,3), b(2,3)
793 print *, any(a .eq. b, 1)
794 print *, any(a .eq. b, 2)
795 end subroutine section
803 @section @code{ASIN} --- Arcsine function
804 @findex @code{ASIN} intrinsic
805 @findex @code{DASIN} intrinsic
809 @item @emph{Description}:
810 @code{ASIN(X)} computes the arcsine of its @var{X}.
821 @item @emph{Arguments}:
822 @multitable @columnfractions .15 .80
823 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
827 @item @emph{Return value}:
828 The return value is of type @code{REAL(*)} and it lies in the
829 range @math{-\pi / 2 \leq \arccos (x) \leq \pi / 2}. The kind type
830 parameter is the same as @var{X}.
832 @item @emph{Example}:
835 real(8) :: x = 0.866_8
837 end program test_asin
840 @item @emph{Specific names}:
841 @multitable @columnfractions .24 .24 .24 .24
842 @item Name @tab Argument @tab Return type @tab Option
843 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
850 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
851 @findex @code{ASSOCIATED} intrinsic
852 @cindex pointer status
855 @item @emph{Description}:
856 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
857 or if @var{PTR} is associated with the target @var{TGT}.
866 @code{L = ASSOCIATED(PTR)}
867 @code{L = ASSOCIATED(PTR [, TGT])}
869 @item @emph{Arguments}:
870 @multitable @columnfractions .15 .80
871 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
872 it can be of any type.
873 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
874 a @code{TARGET}. It must have the same type, kind type parameter, and
875 array rank as @var{PTR}.
877 The status of neither @var{PTR} nor @var{TGT} can be undefined.
879 @item @emph{Return value}:
880 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
881 There are several cases:
883 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
884 is true if @var{PTR} is associated with a target; otherwise, it returns false.
885 @item (B) If @var{TGT} is present and a scalar target, the result is true if
887 is not a 0 sized storage sequence and the target associated with @var{PTR}
888 occupies the same storage units. If @var{PTR} is disassociated, then the
890 @item (C) If @var{TGT} is present and an array target, the result is true if
891 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
892 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
893 @var{PTR} occupy the same storage units in array element order.
894 As in case(B), the result is false, if @var{PTR} is disassociated.
895 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
896 target associated with @var{PTR} and the target associated with @var{TGT}
897 are not 0 sized storage sequences and occupy the same storage units.
898 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
899 @item (E) If @var{TGT} is present and an array pointer, the result is true if
900 target associated with @var{PTR} and the target associated with @var{TGT}
901 have the same shape, are not 0 sized arrays, are arrays whose elements are
902 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
903 storage units in array element order.
904 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
907 @item @emph{Example}:
909 program test_associated
911 real, target :: tgt(2) = (/1., 2./)
912 real, pointer :: ptr(:)
914 if (associated(ptr) .eqv. .false.) call abort
915 if (associated(ptr,tgt) .eqv. .false.) call abort
916 end program test_associated
923 @section @code{ATAN} --- Arctangent function
924 @findex @code{ATAN} intrinsic
925 @findex @code{DATAN} intrinsic
929 @item @emph{Description}:
930 @code{ATAN(X)} computes the arctangent of @var{X}.
941 @item @emph{Arguments}:
942 @multitable @columnfractions .15 .80
943 @item @var{X} @tab The type shall be @code{REAL(*)}.
946 @item @emph{Return value}:
947 The return value is of type @code{REAL(*)} and it lies in the
948 range @math{ - \pi / 2 \leq \arcsin (x) \leq \pi / 2}.
950 @item @emph{Example}:
953 real(8) :: x = 2.866_8
955 end program test_atan
958 @item @emph{Specific names}:
959 @multitable @columnfractions .24 .24 .24 .24
960 @item Name @tab Argument @tab Return type @tab Option
961 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
968 @section @code{ATAN2} --- Arctangent function
969 @findex @code{ATAN2} intrinsic
970 @findex @code{DATAN2} intrinsic
974 @item @emph{Description}:
975 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
984 @code{X = ATAN2(Y,X)}
986 @item @emph{Arguments}:
987 @multitable @columnfractions .15 .80
988 @item @var{Y} @tab The type shall be @code{REAL(*)}.
989 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
990 If @var{Y} is zero, then @var{X} must be nonzero.
993 @item @emph{Return value}:
994 The return value has the same type and kind type parameter as @var{Y}.
995 It is the principle value of the complex number @math{X + i Y}. If
996 @var{X} is nonzero, then it lies in the range @math{-\pi \le \arccos (x) \leq \pi}.
997 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
998 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
999 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1002 @item @emph{Example}:
1005 real(4) :: x = 1.e0_4, y = 0.5e0_4
1007 end program test_atan2
1010 @item @emph{Specific names}:
1011 @multitable @columnfractions .24 .24 .24 .24
1012 @item Name @tab Argument @tab Return type @tab Option
1013 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
1020 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1021 @findex @code{BESJ0} intrinsic
1022 @findex @code{DBESJ0} intrinsic
1026 @item @emph{Description}:
1027 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1030 @item @emph{Option}:
1036 @item @emph{Syntax}:
1039 @item @emph{Arguments}:
1040 @multitable @columnfractions .15 .80
1041 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1044 @item @emph{Return value}:
1045 The return value is of type @code{REAL(*)} and it lies in the
1046 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1048 @item @emph{Example}:
1051 real(8) :: x = 0.0_8
1053 end program test_besj0
1056 @item @emph{Specific names}:
1057 @multitable @columnfractions .24 .24 .24 .24
1058 @item Name @tab Argument @tab Return type @tab Option
1059 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1066 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1067 @findex @code{BESJ1} intrinsic
1068 @findex @code{DBESJ1} intrinsic
1072 @item @emph{Description}:
1073 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1076 @item @emph{Option}:
1082 @item @emph{Syntax}:
1085 @item @emph{Arguments}:
1086 @multitable @columnfractions .15 .80
1087 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1090 @item @emph{Return value}:
1091 The return value is of type @code{REAL(*)} and it lies in the
1092 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1094 @item @emph{Example}:
1097 real(8) :: x = 1.0_8
1099 end program test_besj1
1102 @item @emph{Specific names}:
1103 @multitable @columnfractions .24 .24 .24 .24
1104 @item Name @tab Argument @tab Return type @tab Option
1105 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1112 @section @code{BESJN} --- Bessel function of the first kind
1113 @findex @code{BESJN} intrinsic
1114 @findex @code{DBESJN} intrinsic
1118 @item @emph{Description}:
1119 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1122 @item @emph{Option}:
1128 @item @emph{Syntax}:
1129 @code{Y = BESJN(N, X)}
1131 @item @emph{Arguments}:
1132 @multitable @columnfractions .15 .80
1133 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1134 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1137 @item @emph{Return value}:
1138 The return value is a scalar of type @code{REAL(*)}.
1140 @item @emph{Example}:
1143 real(8) :: x = 1.0_8
1145 end program test_besjn
1148 @item @emph{Specific names}:
1149 @multitable @columnfractions .24 .24 .24 .24
1150 @item Name @tab Argument @tab Return type @tab Option
1151 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab gnu
1152 @item @tab @code{REAL(8) X} @tab @tab
1159 @section @code{BESY0} --- Bessel function of the second kind of order 0
1160 @findex @code{BESY0} intrinsic
1161 @findex @code{DBESY0} intrinsic
1165 @item @emph{Description}:
1166 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1169 @item @emph{Option}:
1175 @item @emph{Syntax}:
1178 @item @emph{Arguments}:
1179 @multitable @columnfractions .15 .80
1180 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1183 @item @emph{Return value}:
1184 The return value is a scalar of type @code{REAL(*)}.
1186 @item @emph{Example}:
1189 real(8) :: x = 0.0_8
1191 end program test_besy0
1194 @item @emph{Specific names}:
1195 @multitable @columnfractions .24 .24 .24 .24
1196 @item Name @tab Argument @tab Return type @tab Option
1197 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1204 @section @code{BESY1} --- Bessel function of the second kind of order 1
1205 @findex @code{BESY1} intrinsic
1206 @findex @code{DBESY1} intrinsic
1210 @item @emph{Description}:
1211 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1214 @item @emph{Option}:
1220 @item @emph{Syntax}:
1223 @item @emph{Arguments}:
1224 @multitable @columnfractions .15 .80
1225 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1228 @item @emph{Return value}:
1229 The return value is a scalar of type @code{REAL(*)}.
1231 @item @emph{Example}:
1234 real(8) :: x = 1.0_8
1236 end program test_besy1
1239 @item @emph{Specific names}:
1240 @multitable @columnfractions .24 .24 .24 .24
1241 @item Name @tab Argument @tab Return type @tab Option
1242 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1249 @section @code{BESYN} --- Bessel function of the second kind
1250 @findex @code{BESYN} intrinsic
1251 @findex @code{DBESYN} intrinsic
1255 @item @emph{Description}:
1256 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1259 @item @emph{Option}:
1265 @item @emph{Syntax}:
1266 @code{Y = BESYN(N, X)}
1268 @item @emph{Arguments}:
1269 @multitable @columnfractions .15 .80
1270 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1271 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1274 @item @emph{Return value}:
1275 The return value is a scalar of type @code{REAL(*)}.
1277 @item @emph{Example}:
1280 real(8) :: x = 1.0_8
1282 end program test_besyn
1285 @item @emph{Specific names}:
1286 @multitable @columnfractions .24 .24 .24 .24
1287 @item Name @tab Argument @tab Return type @tab Option
1288 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab gnu
1289 @item @tab @code{REAL(8) X} @tab @tab
1296 @section @code{BIT_SIZE} --- Bit size inquiry function
1297 @findex @code{BIT_SIZE} intrinsic
1301 @item @emph{Description}:
1302 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1303 represented by the type of @var{I}.
1305 @item @emph{Option}:
1311 @item @emph{Syntax}:
1312 @code{I = BIT_SIZE(I)}
1314 @item @emph{Arguments}:
1315 @multitable @columnfractions .15 .80
1316 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1319 @item @emph{Return value}:
1320 The return value is of type @code{INTEGER(*)}
1322 @item @emph{Example}:
1324 program test_bit_size
1329 end program test_bit_size
1336 @section @code{BTEST} --- Bit test function
1337 @findex @code{BTEST} intrinsic
1341 @item @emph{Description}:
1342 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1345 @item @emph{Option}:
1351 @item @emph{Syntax}:
1352 @code{I = BTEST(I,POS)}
1354 @item @emph{Arguments}:
1355 @multitable @columnfractions .15 .80
1356 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1357 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1360 @item @emph{Return value}:
1361 The return value is of type @code{LOGICAL}
1363 @item @emph{Example}:
1366 integer :: i = 32768 + 1024 + 64
1370 bool = btest(i, pos)
1373 end program test_btest
1380 @section @code{CEILING} --- Integer ceiling function
1381 @findex @code{CEILING} intrinsic
1385 @item @emph{Description}:
1386 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1388 @item @emph{Option}:
1394 @item @emph{Syntax}:
1395 @code{I = CEILING(X[,KIND])}
1397 @item @emph{Arguments}:
1398 @multitable @columnfractions .15 .80
1399 @item @var{X} @tab The type shall be @code{REAL(*)}.
1400 @item @var{KIND} @tab Optional scaler integer initialization expression.
1403 @item @emph{Return value}:
1404 The return value is of type @code{INTEGER(KIND)}
1406 @item @emph{Example}:
1408 program test_ceiling
1411 print *, ceiling(x) ! returns 64
1412 print *, ceiling(y) ! returns -63
1413 end program test_ceiling
1420 @section @code{CHAR} --- Character conversion function
1421 @findex @code{CHAR} intrinsic
1425 @item @emph{Description}:
1426 @code{CHAR(I,[KIND])} returns the character represented by the integer @var{I}.
1428 @item @emph{Option}:
1434 @item @emph{Syntax}:
1435 @code{C = CHAR(I[,KIND])}
1437 @item @emph{Arguments}:
1438 @multitable @columnfractions .15 .80
1439 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1440 @item @var{KIND} @tab Optional scaler integer initialization expression.
1443 @item @emph{Return value}:
1444 The return value is of type @code{CHARACTER(1)}
1446 @item @emph{Example}:
1452 print *, i, c ! returns 'J'
1453 end program test_char
1460 @section @code{CMPLX} --- Complex conversion function
1461 @findex @code{CMPLX} intrinsic
1465 @item @emph{Description}:
1466 @code{CMPLX(X,[Y,KIND])} returns a complex number where @var{X} is converted to
1467 the real component. If @var{Y} is present it is converted to the imaginary
1468 component. If @var{Y} is not present then the imaginary component is set to
1469 0.0. If @var{X} is complex then @var{Y} must not be present.
1471 @item @emph{Option}:
1477 @item @emph{Syntax}:
1478 @code{C = CMPLX(X[,Y,KIND])}
1480 @item @emph{Arguments}:
1481 @multitable @columnfractions .15 .80
1482 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
1483 @item @var{Y} @tab Optional, allowed if @var{X} is not @code{COMPLEX(*)}. May be @code{INTEGER(*)} or @code{REAL(*)}.
1484 @item @var{KIND} @tab Optional scaler integer initialization expression.
1487 @item @emph{Return value}:
1488 The return value is of type @code{COMPLEX(*)}
1490 @item @emph{Example}:
1497 print *, z, cmplx(x)
1498 end program test_cmplx
1504 @node COMMAND_ARGUMENT_COUNT
1505 @section @code{COMMAND_ARGUMENT_COUNT} --- Argument count function
1506 @findex @code{COMMAND_ARGUMENT_COUNT} intrinsic
1507 @cindex command argument count
1510 @item @emph{Description}:
1511 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
1512 command line when the containing program was invoked.
1514 @item @emph{Option}:
1518 non-elemental function
1520 @item @emph{Syntax}:
1521 @code{I = COMMAND_ARGUMENT_COUNT()}
1523 @item @emph{Arguments}:
1524 @multitable @columnfractions .15 .80
1528 @item @emph{Return value}:
1529 The return value is of type @code{INTEGER(4)}
1531 @item @emph{Example}:
1533 program test_command_argument_count
1535 count = command_argument_count()
1537 end program test_command_argument_count
1544 @section @code{CONJG} --- Complex conjugate function
1545 @findex @code{CONJG} intrinsic
1546 @findex @code{DCONJG} intrinsic
1547 @cindex complex conjugate
1549 @item @emph{Description}:
1550 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
1551 then the result is @code{(x, -y)}
1553 @item @emph{Option}:
1559 @item @emph{Syntax}:
1562 @item @emph{Arguments}:
1563 @multitable @columnfractions .15 .80
1564 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
1567 @item @emph{Return value}:
1568 The return value is of type @code{COMPLEX(*)}.
1570 @item @emph{Example}:
1573 complex :: z = (2.0, 3.0)
1574 complex(8) :: dz = (2.71_8, -3.14_8)
1579 end program test_conjg
1582 @item @emph{Specific names}:
1583 @multitable @columnfractions .24 .24 .24 .24
1584 @item Name @tab Argument @tab Return type @tab Option
1585 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
1592 @section @code{COS} --- Cosine function
1593 @findex @code{COS} intrinsic
1594 @findex @code{DCOS} intrinsic
1595 @findex @code{ZCOS} intrinsic
1596 @findex @code{CDCOS} intrinsic
1600 @item @emph{Description}:
1601 @code{COS(X)} computes the cosine of @var{X}.
1603 @item @emph{Option}:
1609 @item @emph{Syntax}:
1612 @item @emph{Arguments}:
1613 @multitable @columnfractions .15 .80
1614 @item @var{X} @tab The type shall be @code{REAL(*)} or
1618 @item @emph{Return value}:
1619 The return value has the same type and kind as @var{X}.
1621 @item @emph{Example}:
1626 end program test_cos
1629 @item @emph{Specific names}:
1630 @multitable @columnfractions .24 .24 .24 .24
1631 @item Name @tab Argument @tab Return type @tab Option
1632 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
1633 @item @code{CCOS(X)}@tab @code{COMPLEX(4) X}@tab @code{COMPLEX(4)}@tab f95, gnu
1634 @item @code{ZCOS(X)}@tab @code{COMPLEX(8) X}@tab @code{COMPLEX(8)}@tab f95, gnu
1635 @item @code{CDCOS(X)}@tab @code{COMPLEX(8) X}@tab @code{COMPLEX(8)}@tab f95, gnu
1642 @section @code{COSH} --- Hyperbolic cosine function
1643 @findex @code{COSH} intrinsic
1644 @findex @code{DCOSH} intrinsic
1645 @cindex hyperbolic cosine
1648 @item @emph{Description}:
1649 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
1651 @item @emph{Option}:
1657 @item @emph{Syntax}:
1660 @item @emph{Arguments}:
1661 @multitable @columnfractions .15 .80
1662 @item @var{X} @tab The type shall be @code{REAL(*)}.
1665 @item @emph{Return value}:
1666 The return value is of type @code{REAL(*)} and it is positive
1667 (@math{ \cosh (x) \geq 0 }.
1669 @item @emph{Example}:
1672 real(8) :: x = 1.0_8
1674 end program test_cosh
1677 @item @emph{Specific names}:
1678 @multitable @columnfractions .24 .24 .24 .24
1679 @item Name @tab Argument @tab Return type @tab Option
1680 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
1687 @section @code{COUNT} --- Count function
1688 @findex @code{COUNT} intrinsic
1692 @item @emph{Description}:
1693 @code{COUNT(MASK[,DIM])} counts the number of @code{.TRUE.} elements of
1694 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
1695 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
1696 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
1698 @item @emph{Option}:
1702 transformational function
1704 @item @emph{Syntax}:
1705 @code{I = COUNT(MASK[,DIM])}
1707 @item @emph{Arguments}:
1708 @multitable @columnfractions .15 .80
1709 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
1710 @item @var{DIM} @tab The type shall be @code{INTEGER}.
1713 @item @emph{Return value}:
1714 The return value is of type @code{INTEGER} with rank equal to that of
1717 @item @emph{Example}:
1720 integer, dimension(2,3) :: a, b
1721 logical, dimension(2,3) :: mask
1722 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
1723 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
1724 print '(3i3)', a(1,:)
1725 print '(3i3)', a(2,:)
1727 print '(3i3)', b(1,:)
1728 print '(3i3)', b(2,:)
1731 print '(3l3)', mask(1,:)
1732 print '(3l3)', mask(2,:)
1734 print '(3i3)', count(mask)
1736 print '(3i3)', count(mask, 1)
1738 print '(3i3)', count(mask, 2)
1739 end program test_count
1746 @section @code{CPU_TIME} --- CPU elapsed time in seconds
1747 @findex @code{CPU_TIME} intrinsic
1751 @item @emph{Description}:
1752 Returns a @code{REAL} value representing the elapsed CPU time in seconds. This
1753 is useful for testing segments of code to determine execution time.
1755 @item @emph{Option}:
1761 @item @emph{Syntax}:
1764 @item @emph{Arguments}:
1765 @multitable @columnfractions .15 .80
1766 @item @var{X} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
1769 @item @emph{Return value}:
1772 @item @emph{Example}:
1774 program test_cpu_time
1775 real :: start, finish
1776 call cpu_time(start)
1777 ! put code to test here
1778 call cpu_time(finish)
1779 print '("Time = ",f6.3," seconds.")',finish-start
1780 end program test_cpu_time
1787 @section @code{CSHIFT} --- Circular shift function
1788 @findex @code{CSHIFT} intrinsic
1789 @cindex cshift intrinsic
1792 @item @emph{Description}:
1793 @code{CSHIFT(ARRAY, SHIFT[,DIM])} performs a circular shift on elements of
1794 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
1795 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
1796 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
1797 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
1798 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
1799 sections of @var{ARRAY} along the given dimension are shifted. Elements
1800 shifted out one end of each rank one section are shifted back in the other end.
1802 @item @emph{Option}:
1806 transformational function
1808 @item @emph{Syntax}:
1809 @code{A = CSHIFT(A, SHIFT[,DIM])}
1811 @item @emph{Arguments}:
1812 @multitable @columnfractions .15 .80
1813 @item @var{ARRAY} @tab May be any type, not scaler.
1814 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
1815 @item @var{DIM} @tab The type shall be @code{INTEGER}.
1818 @item @emph{Return value}:
1819 Returns an array of same type and rank as the @var{ARRAY} argument.
1821 @item @emph{Example}:
1824 integer, dimension(3,3) :: a
1825 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
1826 print '(3i3)', a(1,:)
1827 print '(3i3)', a(2,:)
1828 print '(3i3)', a(3,:)
1829 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
1831 print '(3i3)', a(1,:)
1832 print '(3i3)', a(2,:)
1833 print '(3i3)', a(3,:)
1834 end program test_cshift
1840 @section @code{CTIME} --- Convert a time into a string
1841 @findex @code{CTIME} intrinsic
1842 @cindex ctime subroutine
1845 @item @emph{Description}:
1846 @code{CTIME(T,S)} converts @var{T}, a system time value, such as returned
1847 by @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14
1848 1995}, and returns that string into @var{S}.
1850 If @code{CTIME} is invoked as a function, it can not be invoked as a
1851 subroutine, and vice versa.
1853 @var{T} is an @code{INTENT(IN)} @code{INTEGER(KIND=8)} variable.
1854 @var{S} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
1856 @item @emph{Option}:
1862 @item @emph{Syntax}:
1863 @multitable @columnfractions .80
1864 @item @code{CALL CTIME(T,S)}.
1865 @item @code{S = CTIME(T)}, (not recommended).
1868 @item @emph{Arguments}:
1869 @multitable @columnfractions .15 .80
1870 @item @var{S}@tab The type shall be of type @code{CHARACTER}.
1871 @item @var{T}@tab The type shall be of type @code{INTEGER(KIND=8)}.
1874 @item @emph{Return value}:
1875 The converted date and time as a string.
1877 @item @emph{Example}:
1881 character(len=30) :: date
1884 ! Do something, main part of the program
1887 print *, 'Program was started on ', date
1888 end program test_ctime
1893 @section @code{DATE_AND_TIME} --- Date and time subroutine
1894 @findex @code{DATE_AND_TIME} intrinsic
1895 @cindex DATE_AND_TIME
1898 @item @emph{Description}:
1899 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
1900 time information from the real-time system clock. @var{DATE} is
1901 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
1902 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
1903 representing the difference with respect to Coordinated Universal Time (UTC).
1904 Unavailable time and date parameters return blanks.
1906 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
1908 @multitable @columnfractions .15 .30 .60
1909 @item @tab @code{VALUE(1)}: @tab The year
1910 @item @tab @code{VALUE(2)}: @tab The month
1911 @item @tab @code{VALUE(3)}: @tab The day of the month
1912 @item @tab @code{VAlUE(4)}: @tab Time difference with UTC in minutes
1913 @item @tab @code{VALUE(5)}: @tab The hour of the day
1914 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
1915 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
1916 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
1919 @item @emph{Option}:
1925 @item @emph{Syntax}:
1926 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
1928 @item @emph{Arguments}:
1929 @multitable @columnfractions .15 .80
1930 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
1931 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
1932 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
1933 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
1936 @item @emph{Return value}:
1939 @item @emph{Example}:
1941 program test_time_and_date
1942 character(8) :: date
1943 character(10) :: time
1944 character(5) :: zone
1945 integer,dimension(8) :: values
1946 ! using keyword arguments
1947 call date_and_time(date,time,zone,values)
1948 call date_and_time(DATE=date,ZONE=zone)
1949 call date_and_time(TIME=time)
1950 call date_and_time(VALUES=values)
1951 print '(a,2x,a,2x,a)', date, time, zone
1952 print '(8i5))', values
1953 end program test_time_and_date
1960 @section @code{DBLE} --- Double conversion function
1961 @findex @code{DBLE} intrinsic
1962 @cindex double conversion
1965 @item @emph{Description}:
1966 @code{DBLE(X)} Converts @var{X} to double precision real type.
1967 @code{DFLOAT} is an alias for @code{DBLE}
1969 @item @emph{Option}:
1975 @item @emph{Syntax}:
1977 @code{X = DFLOAT(X)}
1979 @item @emph{Arguments}:
1980 @multitable @columnfractions .15 .80
1981 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
1984 @item @emph{Return value}:
1985 The return value is of type double precision real.
1987 @item @emph{Example}:
1992 complex :: z = (2.3,1.14)
1993 print *, dble(x), dble(i), dfloat(z)
1994 end program test_dble
2001 @section @code{DCMPLX} --- Double complex conversion function
2002 @findex @code{DCMPLX} intrinsic
2006 @item @emph{Description}:
2007 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2008 converted to the real component. If @var{Y} is present it is converted to the
2009 imaginary component. If @var{Y} is not present then the imaginary component is
2010 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2012 @item @emph{Option}:
2018 @item @emph{Syntax}:
2019 @code{C = DCMPLX(X)}
2020 @code{C = DCMPLX(X,Y)}
2022 @item @emph{Arguments}:
2023 @multitable @columnfractions .15 .80
2024 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
2025 @item @var{Y} @tab Optional if @var{X} is not @code{COMPLEX(*)}. May be @code{INTEGER(*)} or @code{REAL(*)}.
2028 @item @emph{Return value}:
2029 The return value is of type @code{COMPLEX(8)}
2031 @item @emph{Example}:
2041 print *, dcmplx(x,i)
2042 end program test_dcmplx
2049 @section @code{DFLOAT} --- Double conversion function
2050 @findex @code{DFLOAT} intrinsic
2051 @cindex double float conversion
2054 @item @emph{Description}:
2055 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2056 @code{DFLOAT} is an alias for @code{DBLE}. See @code{DBLE}.
2062 @section @code{DIGITS} --- Significant digits function
2063 @findex @code{DIGITS} intrinsic
2064 @cindex digits, significant
2067 @item @emph{Description}:
2068 @code{DIGITS(X)} returns the number of significant digits of the internal model
2069 representation of @var{X}. For example, on a system using a 32-bit
2070 floating point representation, a default real number would likely return 24.
2072 @item @emph{Option}:
2078 @item @emph{Syntax}:
2079 @code{C = DIGITS(X)}
2081 @item @emph{Arguments}:
2082 @multitable @columnfractions .15 .80
2083 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2086 @item @emph{Return value}:
2087 The return value is of type @code{INTEGER}.
2089 @item @emph{Example}:
2092 integer :: i = 12345
2098 end program test_digits
2105 @section @code{DIM} --- Dim function
2106 @findex @code{DIM} intrinsic
2107 @findex @code{IDIM} intrinsic
2108 @findex @code{DDIM} intrinsic
2112 @item @emph{Description}:
2113 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2114 otherwise returns zero.
2116 @item @emph{Option}:
2122 @item @emph{Syntax}:
2125 @item @emph{Arguments}:
2126 @multitable @columnfractions .15 .80
2127 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2128 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2131 @item @emph{Return value}:
2132 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2134 @item @emph{Example}:
2140 x = dim(4.345_8, 2.111_8)
2143 end program test_dim
2146 @item @emph{Specific names}:
2147 @multitable @columnfractions .24 .24 .24 .24
2148 @item Name @tab Argument @tab Return type @tab Option
2149 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab gnu
2150 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab gnu
2157 @section @code{DOT_PRODUCT} --- Dot product function
2158 @findex @code{DOT_PRODUCT} intrinsic
2162 @item @emph{Description}:
2163 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2164 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2165 and must be arrays of rank one and of equal size. If the vectors are
2166 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2167 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2168 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2170 @item @emph{Option}:
2174 transformational function
2176 @item @emph{Syntax}:
2177 @code{S = DOT_PRODUCT(X,Y)}
2179 @item @emph{Arguments}:
2180 @multitable @columnfractions .15 .80
2181 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2182 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2185 @item @emph{Return value}:
2186 If the arguments are numeric, the return value is a scaler of numeric type,
2187 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2188 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2190 @item @emph{Example}:
2192 program test_dot_prod
2193 integer, dimension(3) :: a, b
2200 print *, dot_product(a,b)
2201 end program test_dot_prod
2208 @section @code{DPROD} --- Double product function
2209 @findex @code{DPROD} intrinsic
2210 @cindex Double product
2213 @item @emph{Description}:
2214 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2216 @item @emph{Option}:
2222 @item @emph{Syntax}:
2223 @code{D = DPROD(X,Y)}
2225 @item @emph{Arguments}:
2226 @multitable @columnfractions .15 .80
2227 @item @var{X} @tab The type shall be @code{REAL}.
2228 @item @var{Y} @tab The type shall be @code{REAL}.
2231 @item @emph{Return value}:
2232 The return value is of type @code{REAL(8)}.
2234 @item @emph{Example}:
2243 end program test_dprod
2250 @section @code{DREAL} --- Double real part function
2251 @findex @code{DREAL} intrinsic
2252 @cindex Double real part
2255 @item @emph{Description}:
2256 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2258 @item @emph{Option}:
2264 @item @emph{Syntax}:
2267 @item @emph{Arguments}:
2268 @multitable @columnfractions .15 .80
2269 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2272 @item @emph{Return value}:
2273 The return value is of type @code{REAL(8)}.
2275 @item @emph{Example}:
2278 complex(8) :: z = (1.3_8,7.2_8)
2280 end program test_dreal
2287 @section @code{DTIME} --- Execution time subroutine (or function)
2288 @findex @code{DTIME} intrinsic
2289 @cindex dtime subroutine
2292 @item @emph{Description}:
2293 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2294 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2295 returns the user and system components of this time in @code{TARRAY(1)} and
2296 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2299 Subsequent invocations of @code{DTIME} return values accumulated since the
2300 previous invocation.
2302 On some systems, the underlying timings are represented using types with
2303 sufficiently small limits that overflows (wraparounds) are possible, such as
2304 32-bit types. Therefore, the values returned by this intrinsic might be, or
2305 become, negative, or numerically less than previous values, during a single
2306 run of the compiled program.
2308 If @code{DTIME} is invoked as a function, it can not be invoked as a
2309 subroutine, and vice versa.
2311 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2313 @multitable @columnfractions .15 .30 .60
2314 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2315 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2316 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2319 @item @emph{Option}:
2325 @item @emph{Syntax}:
2326 @multitable @columnfractions .80
2327 @item @code{CALL DTIME(TARRAY, RESULT)}.
2328 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
2331 @item @emph{Arguments}:
2332 @multitable @columnfractions .15 .80
2333 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2334 @item @var{RESULT}@tab The type shall be @code{REAL}.
2337 @item @emph{Return value}:
2338 Elapsed time in seconds since the start of program execution.
2340 @item @emph{Example}:
2344 real, dimension(2) :: tarray
2346 call dtime(tarray, result)
2350 do i=1,100000000 ! Just a delay
2353 call dtime(tarray, result)
2357 end program test_dtime
2364 @section @code{EOSHIFT} --- End-off shift function
2365 @findex @code{EOSHIFT} intrinsic
2366 @cindex eoshift intrinsic
2369 @item @emph{Description}:
2370 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
2371 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
2372 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2373 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
2374 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
2375 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
2376 then all complete rank one sections of @var{ARRAY} along the given dimension are
2377 shifted. Elements shifted out one end of each rank one section are dropped. If
2378 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
2379 is copied back in the other end. If @var{BOUNDARY} is not present then the
2380 following are copied in depending on the type of @var{ARRAY}.
2382 @multitable @columnfractions .15 .80
2383 @item @emph{Array Type} @tab @emph{Boundary Value}
2384 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
2385 @item Logical @tab @code{.FALSE.}.
2386 @item Character(@var{len}) @tab @var{len} blanks.
2389 @item @emph{Option}:
2393 transformational function
2395 @item @emph{Syntax}:
2396 @code{A = EOSHIFT(A, SHIFT[,BOUNDARY, DIM])}
2398 @item @emph{Arguments}:
2399 @multitable @columnfractions .15 .80
2400 @item @var{ARRAY} @tab May be any type, not scaler.
2401 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2402 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
2403 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2406 @item @emph{Return value}:
2407 Returns an array of same type and rank as the @var{ARRAY} argument.
2409 @item @emph{Example}:
2411 program test_eoshift
2412 integer, dimension(3,3) :: a
2413 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2414 print '(3i3)', a(1,:)
2415 print '(3i3)', a(2,:)
2416 print '(3i3)', a(3,:)
2417 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
2419 print '(3i3)', a(1,:)
2420 print '(3i3)', a(2,:)
2421 print '(3i3)', a(3,:)
2422 end program test_eoshift
2429 @section @code{EPSILON} --- Epsilon function
2430 @findex @code{EPSILON} intrinsic
2431 @cindex epsilon, significant
2434 @item @emph{Description}:
2435 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
2437 @item @emph{Option}:
2443 @item @emph{Syntax}:
2444 @code{C = EPSILON(X)}
2446 @item @emph{Arguments}:
2447 @multitable @columnfractions .15 .80
2448 @item @var{X} @tab The type shall be @code{REAL(*)}.
2451 @item @emph{Return value}:
2452 The return value is of same type as the argument.
2454 @item @emph{Example}:
2456 program test_epsilon
2461 end program test_epsilon
2468 @section @code{ERF} --- Error function
2469 @findex @code{ERF} intrinsic
2470 @cindex error function
2473 @item @emph{Description}:
2474 @code{ERF(X)} computes the error function of @var{X}.
2476 @item @emph{Option}:
2482 @item @emph{Syntax}:
2485 @item @emph{Arguments}:
2486 @multitable @columnfractions .15 .80
2487 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
2490 @item @emph{Return value}:
2491 The return value is a scalar of type @code{REAL(*)} and it is positive
2492 (@math{ - 1 \leq erf (x) \leq 1 }.
2494 @item @emph{Example}:
2497 real(8) :: x = 0.17_8
2499 end program test_erf
2502 @item @emph{Specific names}:
2503 @multitable @columnfractions .24 .24 .24 .24
2504 @item Name @tab Argument @tab Return type @tab Option
2505 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
2512 @section @code{ERFC} --- Error function
2513 @findex @code{ERFC} intrinsic
2514 @cindex error function
2517 @item @emph{Description}:
2518 @code{ERFC(X)} computes the complementary error function of @var{X}.
2520 @item @emph{Option}:
2526 @item @emph{Syntax}:
2529 @item @emph{Arguments}:
2530 @multitable @columnfractions .15 .80
2531 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
2534 @item @emph{Return value}:
2535 The return value is a scalar of type @code{REAL(*)} and it is positive
2536 (@math{ 0 \leq erfc (x) \leq 2 }.
2538 @item @emph{Example}:
2541 real(8) :: x = 0.17_8
2543 end program test_erfc
2546 @item @emph{Specific names}:
2547 @multitable @columnfractions .24 .24 .24 .24
2548 @item Name @tab Argument @tab Return type @tab Option
2549 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
2556 @section @code{ETIME} --- Execution time subroutine (or function)
2557 @findex @code{ETIME} intrinsic
2558 @cindex ETIME subroutine
2561 @item @emph{Description}:
2562 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
2563 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2564 returns the user and system components of this time in @code{TARRAY(1)} and
2565 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
2567 On some systems, the underlying timings are represented using types with
2568 sufficiently small limits that overflows (wraparounds) are possible, such as
2569 32-bit types. Therefore, the values returned by this intrinsic might be, or
2570 become, negative, or numerically less than previous values, during a single
2571 run of the compiled program.
2573 If @code{ETIME} is invoked as a function, it can not be invoked as a
2574 subroutine, and vice versa.
2576 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2578 @multitable @columnfractions .15 .30 .60
2579 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2580 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2581 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2584 @item @emph{Option}:
2590 @item @emph{Syntax}:
2591 @multitable @columnfractions .8
2592 @item @code{CALL ETIME(TARRAY, RESULT)}.
2593 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
2596 @item @emph{Arguments}:
2597 @multitable @columnfractions .15 .80
2598 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2599 @item @var{RESULT}@tab The type shall be @code{REAL}.
2602 @item @emph{Return value}:
2603 Elapsed time in seconds since the start of program execution.
2605 @item @emph{Example}:
2609 real, dimension(2) :: tarray
2611 call ETIME(tarray, result)
2615 do i=1,100000000 ! Just a delay
2618 call ETIME(tarray, result)
2622 end program test_etime
2629 @section @code{EXIT} --- Exit the program with status.
2634 @item @emph{Description}:
2635 @code{EXIT} causes immediate termination of the program with status. If status
2636 is omitted it returns the canonical @emph{success} for the system. All Fortran
2637 I/O units are closed.
2639 @item @emph{Option}:
2643 non-elemental subroutine
2645 @item @emph{Syntax}:
2646 @code{CALL EXIT([STATUS])}
2648 @item @emph{Arguments}:
2649 @multitable @columnfractions .15 .80
2650 @item @var{STATUS} @tab The type of the argument shall be @code{INTEGER(*)}.
2653 @item @emph{Return value}:
2654 @code{STATUS} is passed to the parent process on exit.
2656 @item @emph{Example}:
2659 integer :: STATUS = 0
2660 print *, 'This program is going to exit.'
2662 end program test_exit
2669 @section @code{EXP} --- Exponential function
2670 @findex @code{EXP} intrinsic
2671 @findex @code{DEXP} intrinsic
2672 @findex @code{ZEXP} intrinsic
2673 @findex @code{CDEXP} intrinsic
2677 @item @emph{Description}:
2678 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
2680 @item @emph{Option}:
2686 @item @emph{Syntax}:
2689 @item @emph{Arguments}:
2690 @multitable @columnfractions .15 .80
2691 @item @var{X} @tab The type shall be @code{REAL(*)} or
2695 @item @emph{Return value}:
2696 The return value has same type and kind as @var{X}.
2698 @item @emph{Example}:
2703 end program test_exp
2706 @item @emph{Specific names}:
2707 @multitable @columnfractions .24 .24 .24 .24
2708 @item Name @tab Argument @tab Return type @tab Option
2709 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
2710 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
2711 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2712 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2719 @section @code{EXPONENT} --- Exponent function
2720 @findex @code{EXPONENT} intrinsic
2721 @cindex exponent function
2724 @item @emph{Description}:
2725 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
2726 is zero the value returned is zero.
2728 @item @emph{Option}:
2734 @item @emph{Syntax}:
2735 @code{I = EXPONENT(X)}
2737 @item @emph{Arguments}:
2738 @multitable @columnfractions .15 .80
2739 @item @var{X} @tab The type shall be @code{REAL(*)}.
2742 @item @emph{Return value}:
2743 The return value is of type default @code{INTEGER}.
2745 @item @emph{Example}:
2747 program test_exponent
2752 print *, exponent(0.0)
2753 end program test_exponent
2759 @section @code{FREE} --- Frees memory
2760 @findex @code{FREE} intrinsic
2764 @item @emph{Description}:
2765 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
2766 intrinsic is an extension intended to be used with Cray pointers, and is
2767 provided in @command{gfortran} to allow user to compile legacy code. For
2768 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
2771 @item @emph{Option}:
2777 @item @emph{Syntax}:
2780 @item @emph{Arguments}:
2781 @multitable @columnfractions .15 .80
2782 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
2783 location of the memory that should be de-allocated.
2786 @item @emph{Return value}:
2789 @item @emph{Example}:
2790 See @code{MALLOC} for an example.
2795 @section @code{FDATE} --- Get the current time as a string
2796 @findex @code{FDATE} intrinsic
2797 @cindex fdate subroutine
2800 @item @emph{Description}:
2801 @code{FDATE(DATE)} returns the current date (using the same format as
2802 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
2805 If @code{FDATE} is invoked as a function, it can not be invoked as a
2806 subroutine, and vice versa.
2808 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
2810 @item @emph{Option}:
2816 @item @emph{Syntax}:
2817 @multitable @columnfractions .80
2818 @item @code{CALL FDATE(DATE)}.
2819 @item @code{DATE = FDATE()}, (not recommended).
2822 @item @emph{Arguments}:
2823 @multitable @columnfractions .15 .80
2824 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
2827 @item @emph{Return value}:
2828 The current date and time as a string.
2830 @item @emph{Example}:
2834 character(len=30) :: date
2836 print *, 'Program started on ', date
2837 do i = 1, 100000000 ! Just a delay
2841 print *, 'Program ended on ', date
2842 end program test_fdate
2847 @section @code{FLOAT} --- Convert integer to default real
2848 @findex @code{FLOAT} intrinsic
2852 @item @emph{Description}:
2853 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
2855 @item @emph{Option}:
2861 @item @emph{Syntax}:
2864 @item @emph{Arguments}:
2865 @multitable @columnfractions .15 .80
2866 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
2869 @item @emph{Return value}:
2870 The return value is of type default @code{REAL}
2872 @item @emph{Example}:
2876 if (float(i) /= 1.) call abort
2877 end program test_float
2883 @section @code{FLOOR} --- Integer floor function
2884 @findex @code{FLOOR} intrinsic
2888 @item @emph{Description}:
2889 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
2891 @item @emph{Option}:
2897 @item @emph{Syntax}:
2898 @code{I = FLOOR(X[,KIND])}
2900 @item @emph{Arguments}:
2901 @multitable @columnfractions .15 .80
2902 @item @var{X} @tab The type shall be @code{REAL(*)}.
2903 @item @var{KIND} @tab Optional scaler integer initialization expression.
2906 @item @emph{Return value}:
2907 The return value is of type @code{INTEGER(KIND)}
2909 @item @emph{Example}:
2914 print *, floor(x) ! returns 63
2915 print *, floor(y) ! returns -64
2916 end program test_floor
2923 @section @code{FNUM} --- File number function
2924 @findex @code{FNUM} intrinsic
2928 @item @emph{Description}:
2929 @code{FNUM(UNIT)} returns the Posix file descriptor number corresponding to the
2930 open Fortran I/O unit @code{UNIT}.
2932 @item @emph{Option}:
2936 non-elemental function
2938 @item @emph{Syntax}:
2939 @code{I = FNUM(UNIT)}
2941 @item @emph{Arguments}:
2942 @multitable @columnfractions .15 .80
2943 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
2946 @item @emph{Return value}:
2947 The return value is of type @code{INTEGER}
2949 @item @emph{Example}:
2953 open (unit=10, status = "scratch")
2957 end program test_fnum
2962 @section @code{LOC} --- Returns the address of a variable
2963 @findex @code{LOC} intrinsic
2967 @item @emph{Description}:
2968 @code{LOC(X)} returns the address of @var{X} as an integer.
2970 @item @emph{Option}:
2976 @item @emph{Syntax}:
2979 @item @emph{Arguments}:
2980 @multitable @columnfractions .15 .80
2981 @item @var{X} @tab Variable of any type.
2984 @item @emph{Return value}:
2985 The return value is of type @code{INTEGER(n)}, where @code{n} is the
2986 size (in bytes) of a memory address on the target machine.
2988 @item @emph{Example}:
2995 end program test_loc
3000 @section @code{LOG} --- Logarithm function
3001 @findex @code{LOG} intrinsic
3002 @findex @code{ALOG} intrinsic
3003 @findex @code{DLOG} intrinsic
3004 @findex @code{CLOG} intrinsic
3005 @findex @code{ZLOG} intrinsic
3006 @findex @code{CDLOG} intrinsic
3010 @item @emph{Description}:
3011 @code{LOG(X)} computes the logarithm of @var{X}.
3013 @item @emph{Option}:
3019 @item @emph{Syntax}:
3022 @item @emph{Arguments}:
3023 @multitable @columnfractions .15 .80
3024 @item @var{X} @tab The type shall be @code{REAL(*)} or
3028 @item @emph{Return value}:
3029 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
3030 The kind type parameter is the same as @var{X}.
3032 @item @emph{Example}:
3035 real(8) :: x = 1.0_8
3036 complex :: z = (1.0, 2.0)
3039 end program test_log
3042 @item @emph{Specific names}:
3043 @multitable @columnfractions .24 .24 .24 .24
3044 @item Name @tab Argument @tab Return type @tab Option
3045 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
3046 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3047 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
3048 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3049 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3056 @section @code{LOG10} --- Base 10 logarithm function
3057 @findex @code{LOG10} intrinsic
3058 @findex @code{ALOG10} intrinsic
3059 @findex @code{DLOG10} intrinsic
3063 @item @emph{Description}:
3064 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
3066 @item @emph{Option}:
3072 @item @emph{Syntax}:
3075 @item @emph{Arguments}:
3076 @multitable @columnfractions .15 .80
3077 @item @var{X} @tab The type shall be @code{REAL(*)} or
3081 @item @emph{Return value}:
3082 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
3083 The kind type parameter is the same as @var{X}.
3085 @item @emph{Example}:
3088 real(8) :: x = 10.0_8
3090 end program test_log10
3093 @item @emph{Specific names}:
3094 @multitable @columnfractions .24 .24 .24 .24
3095 @item Name @tab Argument @tab Return type @tab Option
3096 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
3097 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3103 @section @code{MALLOC} --- Allocate dynamic memory
3104 @findex @code{MALLOC} intrinsic
3108 @item @emph{Description}:
3109 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
3110 returns the address of the allocated memory. The @code{MALLOC} intrinsic
3111 is an extension intended to be used with Cray pointers, and is provided
3112 in @command{gfortran} to allow user to compile legacy code. For new code
3113 using Fortran 95 pointers, the memory allocation intrinsic is
3116 @item @emph{Option}:
3120 non-elemental function
3122 @item @emph{Syntax}:
3123 @code{PTR = MALLOC(SIZE)}
3125 @item @emph{Arguments}:
3126 @multitable @columnfractions .15 .80
3127 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
3130 @item @emph{Return value}:
3131 The return value is of type @code{INTEGER(K)}, with @var{K} such that
3132 variables of type @code{INTEGER(K)} have the same size as
3133 C pointers (@code{sizeof(void *)}).
3135 @item @emph{Example}:
3136 The following example demonstrates the use of @code{MALLOC} and
3137 @code{FREE} with Cray pointers. This example is intended to run on
3138 32-bit systems, where the default integer kind is suitable to store
3139 pointers; on 64-bit systems, ptr_x would need to be declared as
3140 @code{integer(kind=8)}.
3149 ptr_x = malloc(20*8)
3151 x(i) = sqrt(1.0d0 / i)
3159 end program test_malloc
3165 @section @code{REAL} --- Convert to real type
3166 @findex @code{REAL} intrinsic
3167 @findex @code{REALPART} intrinsic
3171 @item @emph{Description}:
3172 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
3173 @code{REALPART(X)} function is provided for compatibility with @command{g77},
3174 and its use is strongly discouraged.
3176 @item @emph{Option}:
3180 transformational function
3182 @item @emph{Syntax}:
3183 @multitable @columnfractions .30 .80
3184 @item @code{X = REAL(X)}
3185 @item @code{X = REAL(X, KIND)}
3186 @item @code{X = REALPART(Z)}
3189 @item @emph{Arguments}:
3190 @multitable @columnfractions .15 .80
3191 @item @var{X} @tab shall be @code{INTEGER(*)}, @code{REAL(*)}, or
3193 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer.
3196 @item @emph{Return value}:
3197 These functions return the a @code{REAL(*)} variable or array under
3198 the following rules:
3202 @code{REAL(X)} is converted to a default real type if @var{X} is an
3203 integer or real variable.
3205 @code{REAL(X)} is converted to a real type with the kind type parameter
3206 of @var{X} if @var{X} is a complex variable.
3208 @code{REAL(X, KIND)} is converted to a real type with kind type
3209 parameter @var{KIND} if @var{X} is a complex, integer, or real
3213 @item @emph{Example}:
3216 complex :: x = (1.0, 2.0)
3217 print *, real(x), real(x,8), realpart(x)
3218 end program test_real
3225 @section @code{SIGNAL} --- Signal handling subroutine (or function)
3226 @findex @code{SIGNAL} intrinsic
3227 @cindex SIGNAL subroutine
3230 @item @emph{Description}:
3231 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
3232 @var{HANDLER} to be executed with a single integer argument when signal
3233 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
3234 turn off handling of signal @var{NUMBER} or revert to its default
3235 action. See @code{signal(2)}.
3237 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
3238 is supplied, it is set to the value returned by @code{signal(2)}.
3240 @item @emph{Option}:
3244 subroutine, non-elemental function
3246 @item @emph{Syntax}:
3247 @multitable @columnfractions .30 .80
3248 @item @code{CALL ALARM(NUMBER, HANDLER)}
3249 @item @code{CALL ALARM(NUMBER, HANDLER, STATUS)}
3250 @item @code{STATUS = ALARM(NUMBER, HANDLER)}
3253 @item @emph{Arguments}:
3254 @multitable @columnfractions .15 .80
3255 @item @var{NUMBER} @tab shall be a scalar integer, with @code{INTENT(IN)}
3256 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
3257 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
3258 @code{INTEGER}. It is @code{INTENT(IN)}.
3259 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
3260 integer. It has @code{INTENT(OUT)}.
3263 @item @emph{Return value}:
3264 The @code{SIGNAL} functions returns the value returned by @code{signal(2)}.
3266 @item @emph{Example}:
3270 external handler_print
3272 call signal (12, handler_print)
3276 end program test_signal
3284 @section @code{SECNDS} --- Time subroutine
3285 @findex @code{SECNDS} intrinsic
3289 @item @emph{Description}:
3290 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
3291 @var{X} is a reference time, also in seconds. If this is zero, the time in
3292 seconds from midnight is returned. This function is non-standard and its
3295 @item @emph{Option}:
3301 @item @emph{Syntax}:
3302 @code{T = SECNDS (X)}
3304 @item @emph{Arguments}:
3305 @multitable @columnfractions .15 .80
3306 @item Name @tab Type
3307 @item @var{T} @tab REAL(4)
3308 @item @var{X} @tab REAL(4)
3311 @item @emph{Return value}:
3314 @item @emph{Example}:
3318 print *, secnds (0.0) ! seconds since midnight
3319 t1 = secnds (0.0) ! reference time
3320 do i = 1, 10000000 ! do something
3322 t2 = secnds (t1) ! elapsed time
3323 print *, "Something took ", t2, " seconds."
3324 end program test_secnds
3331 @section @code{SIN} --- Sine function
3332 @findex @code{SIN} intrinsic
3333 @findex @code{DSIN} intrinsic
3334 @findex @code{ZSIN} intrinsic
3335 @findex @code{CDSIN} intrinsic
3339 @item @emph{Description}:
3340 @code{SIN(X)} computes the sine of @var{X}.
3342 @item @emph{Option}:
3348 @item @emph{Syntax}:
3351 @item @emph{Arguments}:
3352 @multitable @columnfractions .15 .80
3353 @item @var{X} @tab The type shall be @code{REAL(*)} or
3357 @item @emph{Return value}:
3358 The return value has same type and king than @var{X}.
3360 @item @emph{Example}:
3365 end program test_sin
3368 @item @emph{Specific names}:
3369 @multitable @columnfractions .24 .24 .24 .24
3370 @item Name @tab Argument @tab Return type @tab Option
3371 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3372 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
3373 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3374 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3381 @section @code{SINH} --- Hyperbolic sine function
3382 @findex @code{SINH} intrinsic
3383 @findex @code{DSINH} intrinsic
3384 @cindex hyperbolic sine
3387 @item @emph{Description}:
3388 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
3390 @item @emph{Option}:
3396 @item @emph{Syntax}:
3399 @item @emph{Arguments}:
3400 @multitable @columnfractions .15 .80
3401 @item @var{X} @tab The type shall be @code{REAL(*)}.
3404 @item @emph{Return value}:
3405 The return value is of type @code{REAL(*)}.
3407 @item @emph{Example}:
3410 real(8) :: x = - 1.0_8
3412 end program test_sinh
3415 @item @emph{Specific names}:
3416 @multitable @columnfractions .24 .24 .24 .24
3417 @item Name @tab Argument @tab Return type @tab Option
3418 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3425 @section @code{SQRT} --- Square-root function
3426 @findex @code{SQRT} intrinsic
3427 @findex @code{DSQRT} intrinsic
3428 @findex @code{CSQRT} intrinsic
3429 @findex @code{ZSQRT} intrinsic
3430 @findex @code{CDSQRT} intrinsic
3434 @item @emph{Description}:
3435 @code{SQRT(X)} computes the square root of @var{X}.
3437 @item @emph{Option}:
3443 @item @emph{Syntax}:
3446 @item @emph{Arguments}:
3447 @multitable @columnfractions .15 .80
3448 @item @var{X} @tab The type shall be @code{REAL(*)} or
3452 @item @emph{Return value}:
3453 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
3454 The kind type parameter is the same as @var{X}.
3456 @item @emph{Example}:
3459 real(8) :: x = 2.0_8
3460 complex :: z = (1.0, 2.0)
3463 end program test_sqrt
3466 @item @emph{Specific names}:
3467 @multitable @columnfractions .24 .24 .24 .24
3468 @item Name @tab Argument @tab Return type @tab Option
3469 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3470 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
3471 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3472 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3479 @section @code{TAN} --- Tangent function
3480 @findex @code{TAN} intrinsic
3481 @findex @code{DTAN} intrinsic
3485 @item @emph{Description}:
3486 @code{TAN(X)} computes the tangent of @var{X}.
3488 @item @emph{Option}:
3494 @item @emph{Syntax}:
3497 @item @emph{Arguments}:
3498 @multitable @columnfractions .15 .80
3499 @item @var{X} @tab The type shall be @code{REAL(*)}.
3502 @item @emph{Return value}:
3503 The return value is of type @code{REAL(*)}. The kind type parameter is
3504 the same as @var{X}.
3506 @item @emph{Example}:
3509 real(8) :: x = 0.165_8
3511 end program test_tan
3514 @item @emph{Specific names}:
3515 @multitable @columnfractions .24 .24 .24 .24
3516 @item Name @tab Argument @tab Return type @tab Option
3517 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3524 @section @code{TANH} --- Hyperbolic tangent function
3525 @findex @code{TANH} intrinsic
3526 @findex @code{DTANH} intrinsic
3527 @cindex hyperbolic tangent
3530 @item @emph{Description}:
3531 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
3533 @item @emph{Option}:
3539 @item @emph{Syntax}:
3542 @item @emph{Arguments}:
3543 @multitable @columnfractions .15 .80
3544 @item @var{X} @tab The type shall be @code{REAL(*)}.
3547 @item @emph{Return value}:
3548 The return value is of type @code{REAL(*)} and lies in the range
3549 @math{ - 1 \leq tanh(x) \leq 1 }.
3551 @item @emph{Example}:
3554 real(8) :: x = 2.1_8
3556 end program test_tanh
3559 @item @emph{Specific names}:
3560 @multitable @columnfractions .24 .24 .24 .24
3561 @item Name @tab Argument @tab Return type @tab Option
3562 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3570 @comment gen fraction
3588 @comment sub get_command
3590 @comment sub get_command_argument
3592 @comment sub get_environment_variable
3632 @comment gen len_trim
3642 @comment gen logical
3653 @comment gen maxexponent
3668 @comment gen minexponent
3682 @comment gen nearest
3693 @comment gen precision
3695 @comment gen present
3697 @comment gen product
3704 @comment sub random_number
3706 @comment sub random_seed
3716 @comment gen reshape
3718 @comment gen rrspacing
3727 @comment gen selected_int_kind
3729 @comment gen selected_real_kind
3731 @comment gen set_exponent
3741 @comment gen spacing
3755 @comment sub system_clock
3759 @comment gen transfer
3761 @comment gen transpose