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{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
72 * @code{DBLE}: DBLE, Double precision conversion function
73 * @code{DCMPLX}: DCMPLX, Double complex conversion function
74 * @code{DFLOAT}: DFLOAT, Double precision conversion function
75 * @code{DIGITS}: DIGITS, Significant digits function
76 * @code{DIM}: DIM, Dim function
77 * @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
78 * @code{DPROD}: DPROD, Double product function
79 * @code{DREAL}: DREAL, Double real part function
80 * @code{DTIME}: DTIME, Execution time subroutine (or function)
81 * @code{EOSHIFT}: EOSHIFT, End-off shift function
82 * @code{EPSILON}: EPSILON, Epsilon function
83 * @code{ERF}: ERF, Error function
84 * @code{ERFC}: ERFC, Complementary error function
85 * @code{ETIME}: ETIME, Execution time subroutine (or function)
86 * @code{EXIT}: EXIT, Exit the program with status.
87 * @code{EXP}: EXP, Exponential function
88 * @code{EXPONENT}: EXPONENT, Exponent function
89 * @code{FLOOR}: FLOOR, Integer floor function
90 * @code{FNUM}: FNUM, File number function
91 * @code{FREE}: FREE, Memory de-allocation subroutine
92 * @code{LOC}: LOC, Returns the address of a variable
93 * @code{LOG}: LOG, Logarithm function
94 * @code{LOG10}: LOG10, Base 10 logarithm function
95 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
96 * @code{REAL}: REAL, Convert to real type
97 * @code{SECNDS}: SECNDS, Time function
98 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
99 * @code{SIN}: SIN, Sine function
100 * @code{SINH}: SINH, Hyperbolic sine function
101 * @code{SQRT}: SQRT, Square-root function
102 * @code{TAN}: TAN, Tangent function
103 * @code{TANH}: TANH, Hyperbolic tangent function
107 @section Introduction to intrinsic procedures
109 Gfortran provides a rich set of intrinsic procedures that includes all
110 the intrinsic procedures required by the Fortran 95 standard, a set of
111 intrinsic procedures for backwards compatibility with Gnu Fortran 77
112 (i.e., @command{g77}), and a small selection of intrinsic procedures
113 from the Fortran 2003 standard. Any description here, which conflicts with a
114 description in either the Fortran 95 standard or the Fortran 2003 standard,
115 is unintentional and the standard(s) should be considered authoritative.
117 The enumeration of the @code{KIND} type parameter is processor defined in
118 the Fortran 95 standard. Gfortran defines the default integer type and
119 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
120 respectively. The standard mandates that both data types shall have
121 another kind, which have more precision. On typical target architectures
122 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
123 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
124 In the description of generic intrinsic procedures, the kind type parameter
125 will be specified by @code{KIND=*}, and in the description of specific
126 names for an intrinsic procedure the kind type parameter will be explicitly
127 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
128 brevity the optional @code{KIND=} syntax will be omitted.
130 Many of the intrinsics procedures take one or more optional arguments.
131 This document follows the convention used in the Fortran 95 standard,
132 and denotes such arguments by square brackets.
134 @command{Gfortran} offers the @option{-std=f95} and @option{-std=gnu} options,
135 which can be used to restrict the set of intrinsic procedures to a
136 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
137 option, and so all intrinsic procedures described here are accepted. There
138 is one caveat. For a select group of intrinsic procedures, @command{g77}
139 implemented both a function and a subroutine. Both classes
140 have been implemented in @command{gfortran} for backwards compatibility
141 with @command{g77}. It is noted here that these functions and subroutines
142 cannot be intermixed in a given subprogram. In the descriptions that follow,
143 the applicable option(s) is noted.
148 @section @code{ABORT} --- Abort the program
153 @item @emph{Description}:
154 @code{ABORT} causes immediate termination of the program. On operating
155 systems that support a core dump, @code{ABORT} will produce a core dump,
156 which is suitable for debugging purposes.
162 non-elemental subroutine
167 @item @emph{Return value}:
170 @item @emph{Example}:
173 integer :: i = 1, j = 2
174 if (i /= j) call abort
175 end program test_abort
182 @section @code{ABS} --- Absolute value
183 @findex @code{ABS} intrinsic
184 @findex @code{CABS} intrinsic
185 @findex @code{DABS} intrinsic
186 @findex @code{IABS} intrinsic
187 @findex @code{ZABS} intrinsic
188 @findex @code{CDABS} intrinsic
189 @cindex absolute value
192 @item @emph{Description}:
193 @code{ABS(X)} computes the absolute value of @code{X}.
204 @item @emph{Arguments}:
205 @multitable @columnfractions .15 .80
206 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
207 @code{REAL(*)}, or @code{COMPLEX(*)}.
210 @item @emph{Return value}:
211 The return value is of the same type and
212 kind as the argument except the return value is @code{REAL(*)} for a
213 @code{COMPLEX(*)} argument.
215 @item @emph{Example}:
220 complex :: z = (-1.e0,0.e0)
227 @item @emph{Specific names}:
228 @multitable @columnfractions .24 .24 .24 .24
229 @item Name @tab Argument @tab Return type @tab Option
230 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab f95, gnu
231 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
232 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab f95, gnu
233 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
234 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
241 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
242 @findex @code{ACHAR} intrinsic
243 @cindex @acronym{ASCII} collating sequence
246 @item @emph{Description}:
247 @code{ACHAR(I)} returns the character located at position @code{I}
248 in the @acronym{ASCII} collating sequence.
259 @item @emph{Arguments}:
260 @multitable @columnfractions .15 .80
261 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
264 @item @emph{Return value}:
265 The return value is of type @code{CHARACTER} with a length of one. The
266 kind type parameter is the same as @code{KIND('A')}.
268 @item @emph{Example}:
273 end program test_achar
280 @section @code{ACOS} --- Arc cosine function
281 @findex @code{ACOS} intrinsic
282 @findex @code{DACOS} intrinsic
286 @item @emph{Description}:
287 @code{ACOS(X)} computes the arc cosine of @var{X}.
298 @item @emph{Arguments}:
299 @multitable @columnfractions .15 .80
300 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
304 @item @emph{Return value}:
305 The return value is of type @code{REAL(*)} and it lies in the
306 range @math{ 0 \leq \arccos (x) \leq \pi}. The kind type
307 parameter is the same as @var{X}.
309 @item @emph{Example}:
312 real(8) :: x = 0.866_8
314 end program test_acos
317 @item @emph{Specific names}:
318 @multitable @columnfractions .24 .24 .24 .24
319 @item Name @tab Argument @tab Return type @tab Option
320 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
327 @section @code{ADJUSTL} --- Left adjust a string
328 @findex @code{ADJUSTL} intrinsic
329 @cindex adjust string
332 @item @emph{Description}:
333 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
334 Spaces are inserted at the end of the string as needed.
343 @code{STR = ADJUSTL(STR)}
345 @item @emph{Arguments}:
346 @multitable @columnfractions .15 .80
347 @item @var{STR} @tab The type shall be @code{CHARACTER}.
350 @item @emph{Return value}:
351 The return value is of type @code{CHARACTER} where leading spaces
352 are removed and the same number of spaces are inserted on the end
355 @item @emph{Example}:
358 character(len=20) :: str = ' gfortran'
361 end program test_adjustl
368 @section @code{ADJUSTR} --- Right adjust a string
369 @findex @code{ADJUSTR} intrinsic
370 @cindex adjust string
373 @item @emph{Description}:
374 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
375 Spaces are inserted at the start of the string as needed.
384 @code{STR = ADJUSTR(STR)}
386 @item @emph{Arguments}:
387 @multitable @columnfractions .15 .80
388 @item @var{STR} @tab The type shall be @code{CHARACTER}.
391 @item @emph{Return value}:
392 The return value is of type @code{CHARACTER} where trailing spaces
393 are removed and the same number of spaces are inserted at the start
396 @item @emph{Example}:
399 character(len=20) :: str = 'gfortran'
402 end program test_adjustr
409 @section @code{AIMAG} --- Imaginary part of complex number
410 @findex @code{AIMAG} intrinsic
411 @findex @code{DIMAG} intrinsic
412 @findex @code{IMAG} intrinsic
413 @findex @code{IMAGPART} intrinsic
414 @cindex Imaginary part
417 @item @emph{Description}:
418 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
419 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
420 for compatibility with @command{g77}, and their use in new code is
421 strongly discouraged.
432 @item @emph{Arguments}:
433 @multitable @columnfractions .15 .80
434 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
437 @item @emph{Return value}:
438 The return value is of type real with the
439 kind type parameter of the argument.
441 @item @emph{Example}:
446 z4 = cmplx(1.e0_4, 0.e0_4)
447 z8 = cmplx(0.e0_8, 1.e0_8)
448 print *, aimag(z4), dimag(z8)
449 end program test_aimag
452 @item @emph{Specific names}:
453 @multitable @columnfractions .24 .24 .24 .24
454 @item Name @tab Argument @tab Return type @tab Option
455 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab f95, gnu
456 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab gnu
457 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab gnu
464 @section @code{AINT} --- Imaginary part of complex number
465 @findex @code{AINT} intrinsic
466 @findex @code{DINT} intrinsic
470 @item @emph{Description}:
471 @code{AINT(X [, KIND])} truncates its argument to a whole number.
481 @code{X = AINT(X, KIND)}
483 @item @emph{Arguments}:
484 @multitable @columnfractions .15 .80
485 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
486 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
487 initialization expression.
490 @item @emph{Return value}:
491 The return value is of type real with the kind type parameter of the
492 argument if the optional @var{KIND} is absent; otherwise, the kind
493 type parameter will be given by @var{KIND}. If the magnitude of
494 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
495 magnitude is equal to or greater than one, then it returns the largest
496 whole number that does not exceed its magnitude. The sign is the same
497 as the sign of @var{X}.
499 @item @emph{Example}:
506 print *, aint(x4), dint(x8)
508 end program test_aint
511 @item @emph{Specific names}:
512 @multitable @columnfractions .24 .24 .24 .24
513 @item Name @tab Argument @tab Return type @tab Option
514 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
521 @section @code{ALARM} --- Execute a routine after a given delay
522 @findex @code{ALARM} intrinsic
525 @item @emph{Description}:
526 @code{ALARM(SECONDS [, STATUS])} causes external subroutine @var{HANDLER}
527 to be executed after a delay of @var{SECONDS} by using @code{alarm(1)} to
528 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
529 supplied, it will be returned with the number of seconds remaining until
530 any previously scheduled alarm was due to be delivered, or zero if there
531 was no previously scheduled alarm.
540 @code{CALL ALARM(SECONDS, HANDLER)}
541 @code{CALL ALARM(SECONDS, HANDLER, STATUS)}
543 @item @emph{Arguments}:
544 @multitable @columnfractions .15 .80
545 @item @var{SECONDS} @tab The type of the argument shall be a scalar
546 @code{INTEGER}. It is @code{INTENT(IN)}.
547 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
548 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
549 @code{INTEGER}. It is @code{INTENT(IN)}.
550 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
551 @code{INTEGER} variable. It is @code{INTENT(OUT)}.
554 @item @emph{Example}:
557 external handler_print
559 call alarm (3, handler_print, i)
562 end program test_alarm
564 This will cause the external routine @var{handler_print} to be called
571 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
572 @findex @code{ALL} intrinsic
576 @item @emph{Description}:
577 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
578 in the array along dimension @var{DIM}.
584 transformational function
588 @code{L = ALL(MASK, DIM)}
590 @item @emph{Arguments}:
591 @multitable @columnfractions .15 .80
592 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
593 it shall not be scalar.
594 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
595 with a value that lies between one and the rank of @var{MASK}.
598 @item @emph{Return value}:
599 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
600 the kind type parameter is the same as the kind type parameter of
601 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
602 an array with the rank of @var{MASK} minus 1. The shape is determined from
603 the shape of @var{MASK} where the @var{DIM} dimension is elided.
607 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
608 It also is true if @var{MASK} has zero size; otherwise, it is false.
610 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
611 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
612 is determined by applying @code{ALL} to the array sections.
615 @item @emph{Example}:
619 l = all((/.true., .true., .true./))
624 integer a(2,3), b(2,3)
628 print *, all(a .eq. b, 1)
629 print *, all(a .eq. b, 2)
630 end subroutine section
638 @section @code{ALLOCATED} --- Status of an allocatable entity
639 @findex @code{ALLOCATED} intrinsic
640 @cindex allocation status
643 @item @emph{Description}:
644 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
653 @code{L = ALLOCATED(X)}
655 @item @emph{Arguments}:
656 @multitable @columnfractions .15 .80
657 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
660 @item @emph{Return value}:
661 The return value is a scalar @code{LOGICAL} with the default logical
662 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
663 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
665 @item @emph{Example}:
667 program test_allocated
669 real(4), allocatable :: x(:)
670 if (allocated(x) .eqv. .false.) allocate(x(i)
671 end program test_allocated
678 @section @code{ANINT} --- Imaginary part of complex number
679 @findex @code{ANINT} intrinsic
680 @findex @code{DNINT} intrinsic
684 @item @emph{Description}:
685 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
695 @code{X = ANINT(X, KIND)}
697 @item @emph{Arguments}:
698 @multitable @columnfractions .15 .80
699 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
700 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
701 initialization expression.
704 @item @emph{Return value}:
705 The return value is of type real with the kind type parameter of the
706 argument if the optional @var{KIND} is absent; otherwise, the kind
707 type parameter will be given by @var{KIND}. If @var{X} is greater than
708 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
709 less than or equal to zero, then return @code{AINT(X-0.5)}.
711 @item @emph{Example}:
718 print *, anint(x4), dnint(x8)
720 end program test_anint
723 @item @emph{Specific names}:
724 @multitable @columnfractions .24 .24 .24 .24
725 @item Name @tab Argument @tab Return type @tab Option
726 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
733 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
734 @findex @code{ANY} intrinsic
738 @item @emph{Description}:
739 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
740 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
746 transformational function
750 @code{L = ANY(MASK, DIM)}
752 @item @emph{Arguments}:
753 @multitable @columnfractions .15 .80
754 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
755 it shall not be scalar.
756 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
757 with a value that lies between one and the rank of @var{MASK}.
760 @item @emph{Return value}:
761 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
762 the kind type parameter is the same as the kind type parameter of
763 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
764 an array with the rank of @var{MASK} minus 1. The shape is determined from
765 the shape of @var{MASK} where the @var{DIM} dimension is elided.
769 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
770 otherwise, it is false. It also is false if @var{MASK} has zero size.
772 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
773 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
774 is determined by applying @code{ANY} to the array sections.
777 @item @emph{Example}:
781 l = any((/.true., .true., .true./))
786 integer a(2,3), b(2,3)
790 print *, any(a .eq. b, 1)
791 print *, any(a .eq. b, 2)
792 end subroutine section
800 @section @code{ASIN} --- Arcsine function
801 @findex @code{ASIN} intrinsic
802 @findex @code{DASIN} intrinsic
806 @item @emph{Description}:
807 @code{ASIN(X)} computes the arcsine of its @var{X}.
818 @item @emph{Arguments}:
819 @multitable @columnfractions .15 .80
820 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
824 @item @emph{Return value}:
825 The return value is of type @code{REAL(*)} and it lies in the
826 range @math{-\pi / 2 \leq \arccos (x) \leq \pi / 2}. The kind type
827 parameter is the same as @var{X}.
829 @item @emph{Example}:
832 real(8) :: x = 0.866_8
834 end program test_asin
837 @item @emph{Specific names}:
838 @multitable @columnfractions .24 .24 .24 .24
839 @item Name @tab Argument @tab Return type @tab Option
840 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
847 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
848 @findex @code{ASSOCIATED} intrinsic
849 @cindex pointer status
852 @item @emph{Description}:
853 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
854 or if @var{PTR} is associated with the target @var{TGT}.
863 @code{L = ASSOCIATED(PTR)}
864 @code{L = ASSOCIATED(PTR [, TGT])}
866 @item @emph{Arguments}:
867 @multitable @columnfractions .15 .80
868 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
869 it can be of any type.
870 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
871 a @code{TARGET}. It must have the same type, kind type parameter, and
872 array rank as @var{PTR}.
874 The status of neither @var{PTR} nor @var{TGT} can be undefined.
876 @item @emph{Return value}:
877 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
878 There are several cases:
880 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
881 is true if @var{PTR} is associated with a target; otherwise, it returns false.
882 @item (B) If @var{TGT} is present and a scalar target, the result is true if
884 is not a 0 sized storage sequence and the target associated with @var{PTR}
885 occupies the same storage units. If @var{PTR} is disassociated, then the
887 @item (C) If @var{TGT} is present and an array target, the result is true if
888 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
889 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
890 @var{PTR} occupy the same storage units in array element order.
891 As in case(B), the result is false, if @var{PTR} is disassociated.
892 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
893 target associated with @var{PTR} and the target associated with @var{TGT}
894 are not 0 sized storage sequences and occupy the same storage units.
895 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
896 @item (E) If @var{TGT} is present and an array pointer, the result is true if
897 target associated with @var{PTR} and the target associated with @var{TGT}
898 have the same shape, are not 0 sized arrays, are arrays whose elements are
899 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
900 storage units in array element order.
901 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
904 @item @emph{Example}:
906 program test_associated
908 real, target :: tgt(2) = (/1., 2./)
909 real, pointer :: ptr(:)
911 if (associated(ptr) .eqv. .false.) call abort
912 if (associated(ptr,tgt) .eqv. .false.) call abort
913 end program test_associated
920 @section @code{ATAN} --- Arctangent function
921 @findex @code{ATAN} intrinsic
922 @findex @code{DATAN} intrinsic
926 @item @emph{Description}:
927 @code{ATAN(X)} computes the arctangent of @var{X}.
938 @item @emph{Arguments}:
939 @multitable @columnfractions .15 .80
940 @item @var{X} @tab The type shall be @code{REAL(*)}.
943 @item @emph{Return value}:
944 The return value is of type @code{REAL(*)} and it lies in the
945 range @math{ - \pi / 2 \leq \arcsin (x) \leq \pi / 2}.
947 @item @emph{Example}:
950 real(8) :: x = 2.866_8
952 end program test_atan
955 @item @emph{Specific names}:
956 @multitable @columnfractions .24 .24 .24 .24
957 @item Name @tab Argument @tab Return type @tab Option
958 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
965 @section @code{ATAN2} --- Arctangent function
966 @findex @code{ATAN2} intrinsic
967 @findex @code{DATAN2} intrinsic
971 @item @emph{Description}:
972 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
981 @code{X = ATAN2(Y,X)}
983 @item @emph{Arguments}:
984 @multitable @columnfractions .15 .80
985 @item @var{Y} @tab The type shall be @code{REAL(*)}.
986 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
987 If @var{Y} is zero, then @var{X} must be nonzero.
990 @item @emph{Return value}:
991 The return value has the same type and kind type parameter as @var{Y}.
992 It is the principle value of the complex number @math{X + i Y}. If
993 @var{X} is nonzero, then it lies in the range @math{-\pi \le \arccos (x) \leq \pi}.
994 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
995 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
996 is negative. Finally, if @var{X} is zero, then the magnitude of the result
999 @item @emph{Example}:
1002 real(4) :: x = 1.e0_4, y = 0.5e0_4
1004 end program test_atan2
1007 @item @emph{Specific names}:
1008 @multitable @columnfractions .24 .24 .24 .24
1009 @item Name @tab Argument @tab Return type @tab Option
1010 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
1017 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1018 @findex @code{BESJ0} intrinsic
1019 @findex @code{DBESJ0} intrinsic
1023 @item @emph{Description}:
1024 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1027 @item @emph{Option}:
1033 @item @emph{Syntax}:
1036 @item @emph{Arguments}:
1037 @multitable @columnfractions .15 .80
1038 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1041 @item @emph{Return value}:
1042 The return value is of type @code{REAL(*)} and it lies in the
1043 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1045 @item @emph{Example}:
1048 real(8) :: x = 0.0_8
1050 end program test_besj0
1053 @item @emph{Specific names}:
1054 @multitable @columnfractions .24 .24 .24 .24
1055 @item Name @tab Argument @tab Return type @tab Option
1056 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1063 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1064 @findex @code{BESJ1} intrinsic
1065 @findex @code{DBESJ1} intrinsic
1069 @item @emph{Description}:
1070 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1073 @item @emph{Option}:
1079 @item @emph{Syntax}:
1082 @item @emph{Arguments}:
1083 @multitable @columnfractions .15 .80
1084 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1087 @item @emph{Return value}:
1088 The return value is of type @code{REAL(*)} and it lies in the
1089 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1091 @item @emph{Example}:
1094 real(8) :: x = 1.0_8
1096 end program test_besj1
1099 @item @emph{Specific names}:
1100 @multitable @columnfractions .24 .24 .24 .24
1101 @item Name @tab Argument @tab Return type @tab Option
1102 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1109 @section @code{BESJN} --- Bessel function of the first kind
1110 @findex @code{BESJN} intrinsic
1111 @findex @code{DBESJN} intrinsic
1115 @item @emph{Description}:
1116 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1119 @item @emph{Option}:
1125 @item @emph{Syntax}:
1126 @code{Y = BESJN(N, X)}
1128 @item @emph{Arguments}:
1129 @multitable @columnfractions .15 .80
1130 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1131 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1134 @item @emph{Return value}:
1135 The return value is a scalar of type @code{REAL(*)}.
1137 @item @emph{Example}:
1140 real(8) :: x = 1.0_8
1142 end program test_besjn
1145 @item @emph{Specific names}:
1146 @multitable @columnfractions .24 .24 .24 .24
1147 @item Name @tab Argument @tab Return type @tab Option
1148 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab gnu
1149 @item @tab @code{REAL(8) X} @tab @tab
1156 @section @code{BESY0} --- Bessel function of the second kind of order 0
1157 @findex @code{BESY0} intrinsic
1158 @findex @code{DBESY0} intrinsic
1162 @item @emph{Description}:
1163 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1166 @item @emph{Option}:
1172 @item @emph{Syntax}:
1175 @item @emph{Arguments}:
1176 @multitable @columnfractions .15 .80
1177 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1180 @item @emph{Return value}:
1181 The return value is a scalar of type @code{REAL(*)}.
1183 @item @emph{Example}:
1186 real(8) :: x = 0.0_8
1188 end program test_besy0
1191 @item @emph{Specific names}:
1192 @multitable @columnfractions .24 .24 .24 .24
1193 @item Name @tab Argument @tab Return type @tab Option
1194 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1201 @section @code{BESY1} --- Bessel function of the second kind of order 1
1202 @findex @code{BESY1} intrinsic
1203 @findex @code{DBESY1} intrinsic
1207 @item @emph{Description}:
1208 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1211 @item @emph{Option}:
1217 @item @emph{Syntax}:
1220 @item @emph{Arguments}:
1221 @multitable @columnfractions .15 .80
1222 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1225 @item @emph{Return value}:
1226 The return value is a scalar of type @code{REAL(*)}.
1228 @item @emph{Example}:
1231 real(8) :: x = 1.0_8
1233 end program test_besy1
1236 @item @emph{Specific names}:
1237 @multitable @columnfractions .24 .24 .24 .24
1238 @item Name @tab Argument @tab Return type @tab Option
1239 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1246 @section @code{BESYN} --- Bessel function of the second kind
1247 @findex @code{BESYN} intrinsic
1248 @findex @code{DBESYN} intrinsic
1252 @item @emph{Description}:
1253 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1256 @item @emph{Option}:
1262 @item @emph{Syntax}:
1263 @code{Y = BESYN(N, X)}
1265 @item @emph{Arguments}:
1266 @multitable @columnfractions .15 .80
1267 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1268 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1271 @item @emph{Return value}:
1272 The return value is a scalar of type @code{REAL(*)}.
1274 @item @emph{Example}:
1277 real(8) :: x = 1.0_8
1279 end program test_besyn
1282 @item @emph{Specific names}:
1283 @multitable @columnfractions .24 .24 .24 .24
1284 @item Name @tab Argument @tab Return type @tab Option
1285 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab gnu
1286 @item @tab @code{REAL(8) X} @tab @tab
1293 @section @code{BIT_SIZE} --- Bit size inquiry function
1294 @findex @code{BIT_SIZE} intrinsic
1298 @item @emph{Description}:
1299 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1300 represented by the type of @var{I}.
1302 @item @emph{Option}:
1308 @item @emph{Syntax}:
1309 @code{I = BIT_SIZE(I)}
1311 @item @emph{Arguments}:
1312 @multitable @columnfractions .15 .80
1313 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1316 @item @emph{Return value}:
1317 The return value is of type @code{INTEGER(*)}
1319 @item @emph{Example}:
1321 program test_bit_size
1326 end program test_bit_size
1333 @section @code{BTEST} --- Bit test function
1334 @findex @code{BTEST} intrinsic
1338 @item @emph{Description}:
1339 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1342 @item @emph{Option}:
1348 @item @emph{Syntax}:
1349 @code{I = BTEST(I,POS)}
1351 @item @emph{Arguments}:
1352 @multitable @columnfractions .15 .80
1353 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1354 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1357 @item @emph{Return value}:
1358 The return value is of type @code{LOGICAL}
1360 @item @emph{Example}:
1363 integer :: i = 32768 + 1024 + 64
1367 bool = btest(i, pos)
1370 end program test_btest
1377 @section @code{CEILING} --- Integer ceiling function
1378 @findex @code{CEILING} intrinsic
1382 @item @emph{Description}:
1383 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1385 @item @emph{Option}:
1391 @item @emph{Syntax}:
1392 @code{I = CEILING(X[,KIND])}
1394 @item @emph{Arguments}:
1395 @multitable @columnfractions .15 .80
1396 @item @var{X} @tab The type shall be @code{REAL(*)}.
1397 @item @var{KIND} @tab Optional scaler integer initialization expression.
1400 @item @emph{Return value}:
1401 The return value is of type @code{INTEGER(KIND)}
1403 @item @emph{Example}:
1405 program test_ceiling
1408 print *, ceiling(x) ! returns 64
1409 print *, ceiling(y) ! returns -63
1410 end program test_ceiling
1417 @section @code{CHAR} --- Character conversion function
1418 @findex @code{CHAR} intrinsic
1422 @item @emph{Description}:
1423 @code{CHAR(I,[KIND])} returns the character represented by the integer @var{I}.
1425 @item @emph{Option}:
1431 @item @emph{Syntax}:
1432 @code{C = CHAR(I[,KIND])}
1434 @item @emph{Arguments}:
1435 @multitable @columnfractions .15 .80
1436 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1437 @item @var{KIND} @tab Optional scaler integer initialization expression.
1440 @item @emph{Return value}:
1441 The return value is of type @code{CHARACTER(1)}
1443 @item @emph{Example}:
1449 print *, i, c ! returns 'J'
1450 end program test_char
1457 @section @code{CMPLX} --- Complex conversion function
1458 @findex @code{CMPLX} intrinsic
1462 @item @emph{Description}:
1463 @code{CMPLX(X,[Y,KIND])} returns a complex number where @var{X} is converted to
1464 the real component. If @var{Y} is present it is converted to the imaginary
1465 component. If @var{Y} is not present then the imaginary component is set to
1466 0.0. If @var{X} is complex then @var{Y} must not be present.
1468 @item @emph{Option}:
1474 @item @emph{Syntax}:
1475 @code{C = CMPLX(X[,Y,KIND])}
1477 @item @emph{Arguments}:
1478 @multitable @columnfractions .15 .80
1479 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
1480 @item @var{Y} @tab Optional, allowed if @var{X} is not @code{COMPLEX(*)}. May be @code{INTEGER(*)} or @code{REAL(*)}.
1481 @item @var{KIND} @tab Optional scaler integer initialization expression.
1484 @item @emph{Return value}:
1485 The return value is of type @code{COMPLEX(*)}
1487 @item @emph{Example}:
1494 print *, z, cmplx(x)
1495 end program test_cmplx
1501 @node COMMAND_ARGUMENT_COUNT
1502 @section @code{COMMAND_ARGUMENT_COUNT} --- Argument count function
1503 @findex @code{COMMAND_ARGUMENT_COUNT} intrinsic
1504 @cindex command argument count
1507 @item @emph{Description}:
1508 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
1509 command line when the containing program was invoked.
1511 @item @emph{Option}:
1515 non-elemental function
1517 @item @emph{Syntax}:
1518 @code{I = COMMAND_ARGUMENT_COUNT()}
1520 @item @emph{Arguments}:
1521 @multitable @columnfractions .15 .80
1525 @item @emph{Return value}:
1526 The return value is of type @code{INTEGER(4)}
1528 @item @emph{Example}:
1530 program test_command_argument_count
1532 count = command_argument_count()
1534 end program test_command_argument_count
1541 @section @code{CONJG} --- Complex conjugate function
1542 @findex @code{CONJG} intrinsic
1543 @findex @code{DCONJG} intrinsic
1544 @cindex complex conjugate
1546 @item @emph{Description}:
1547 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
1548 then the result is @code{(x, -y)}
1550 @item @emph{Option}:
1556 @item @emph{Syntax}:
1559 @item @emph{Arguments}:
1560 @multitable @columnfractions .15 .80
1561 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
1564 @item @emph{Return value}:
1565 The return value is of type @code{COMPLEX(*)}.
1567 @item @emph{Example}:
1570 complex :: z = (2.0, 3.0)
1571 complex(8) :: dz = (2.71_8, -3.14_8)
1576 end program test_conjg
1579 @item @emph{Specific names}:
1580 @multitable @columnfractions .24 .24 .24 .24
1581 @item Name @tab Argument @tab Return type @tab Option
1582 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
1589 @section @code{COS} --- Cosine function
1590 @findex @code{COS} intrinsic
1591 @findex @code{DCOS} intrinsic
1592 @findex @code{ZCOS} intrinsic
1593 @findex @code{CDCOS} intrinsic
1597 @item @emph{Description}:
1598 @code{COS(X)} computes the cosine of @var{X}.
1600 @item @emph{Option}:
1606 @item @emph{Syntax}:
1609 @item @emph{Arguments}:
1610 @multitable @columnfractions .15 .80
1611 @item @var{X} @tab The type shall be @code{REAL(*)} or
1615 @item @emph{Return value}:
1616 The return value has the same type and kind as @var{X}.
1618 @item @emph{Example}:
1623 end program test_cos
1626 @item @emph{Specific names}:
1627 @multitable @columnfractions .24 .24 .24 .24
1628 @item Name @tab Argument @tab Return type @tab Option
1629 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
1630 @item @code{CCOS(X)}@tab @code{COMPLEX(4) X}@tab @code{COMPLEX(4)}@tab f95, gnu
1631 @item @code{ZCOS(X)}@tab @code{COMPLEX(8) X}@tab @code{COMPLEX(8)}@tab f95, gnu
1632 @item @code{CDCOS(X)}@tab @code{COMPLEX(8) X}@tab @code{COMPLEX(8)}@tab f95, gnu
1639 @section @code{COSH} --- Hyperbolic cosine function
1640 @findex @code{COSH} intrinsic
1641 @findex @code{DCOSH} intrinsic
1642 @cindex hyperbolic cosine
1645 @item @emph{Description}:
1646 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
1648 @item @emph{Option}:
1654 @item @emph{Syntax}:
1657 @item @emph{Arguments}:
1658 @multitable @columnfractions .15 .80
1659 @item @var{X} @tab The type shall be @code{REAL(*)}.
1662 @item @emph{Return value}:
1663 The return value is of type @code{REAL(*)} and it is positive
1664 (@math{ \cosh (x) \geq 0 }.
1666 @item @emph{Example}:
1669 real(8) :: x = 1.0_8
1671 end program test_cosh
1674 @item @emph{Specific names}:
1675 @multitable @columnfractions .24 .24 .24 .24
1676 @item Name @tab Argument @tab Return type @tab Option
1677 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
1684 @section @code{COUNT} --- Count function
1685 @findex @code{COUNT} intrinsic
1689 @item @emph{Description}:
1690 @code{COUNT(MASK[,DIM])} counts the number of @code{.TRUE.} elements of
1691 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
1692 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
1693 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
1695 @item @emph{Option}:
1699 transformational function
1701 @item @emph{Syntax}:
1702 @code{I = COUNT(MASK[,DIM])}
1704 @item @emph{Arguments}:
1705 @multitable @columnfractions .15 .80
1706 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
1707 @item @var{DIM} @tab The type shall be @code{INTEGER}.
1710 @item @emph{Return value}:
1711 The return value is of type @code{INTEGER} with rank equal to that of
1714 @item @emph{Example}:
1717 integer, dimension(2,3) :: a, b
1718 logical, dimension(2,3) :: mask
1719 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
1720 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
1721 print '(3i3)', a(1,:)
1722 print '(3i3)', a(2,:)
1724 print '(3i3)', b(1,:)
1725 print '(3i3)', b(2,:)
1728 print '(3l3)', mask(1,:)
1729 print '(3l3)', mask(2,:)
1731 print '(3i3)', count(mask)
1733 print '(3i3)', count(mask, 1)
1735 print '(3i3)', count(mask, 2)
1736 end program test_count
1743 @section @code{CPU_TIME} --- CPU elapsed time in seconds
1744 @findex @code{CPU_TIME} intrinsic
1748 @item @emph{Description}:
1749 Returns a @code{REAL} value representing the elapsed CPU time in seconds. This
1750 is useful for testing segments of code to determine execution time.
1752 @item @emph{Option}:
1758 @item @emph{Syntax}:
1761 @item @emph{Arguments}:
1762 @multitable @columnfractions .15 .80
1763 @item @var{X} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
1766 @item @emph{Return value}:
1769 @item @emph{Example}:
1771 program test_cpu_time
1772 real :: start, finish
1773 call cpu_time(start)
1774 ! put code to test here
1775 call cpu_time(finish)
1776 print '("Time = ",f6.3," seconds.")',finish-start
1777 end program test_cpu_time
1784 @section @code{CSHIFT} --- Circular shift function
1785 @findex @code{CSHIFT} intrinsic
1786 @cindex cshift intrinsic
1789 @item @emph{Description}:
1790 @code{CSHIFT(ARRAY, SHIFT[,DIM])} performs a circular shift on elements of
1791 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
1792 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
1793 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
1794 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
1795 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
1796 sections of @var{ARRAY} along the given dimension are shifted. Elements
1797 shifted out one end of each rank one section are shifted back in the other end.
1799 @item @emph{Option}:
1803 transformational function
1805 @item @emph{Syntax}:
1806 @code{A = CSHIFT(A, SHIFT[,DIM])}
1808 @item @emph{Arguments}:
1809 @multitable @columnfractions .15 .80
1810 @item @var{ARRAY} @tab May be any type, not scaler.
1811 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
1812 @item @var{DIM} @tab The type shall be @code{INTEGER}.
1815 @item @emph{Return value}:
1816 Returns an array of same type and rank as the @var{ARRAY} argument.
1818 @item @emph{Example}:
1821 integer, dimension(3,3) :: a
1822 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
1823 print '(3i3)', a(1,:)
1824 print '(3i3)', a(2,:)
1825 print '(3i3)', a(3,:)
1826 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
1828 print '(3i3)', a(1,:)
1829 print '(3i3)', a(2,:)
1830 print '(3i3)', a(3,:)
1831 end program test_cshift
1838 @section @code{DATE_AND_TIME} --- Date and time subroutine
1839 @findex @code{DATE_AND_TIME} intrinsic
1840 @cindex DATE_AND_TIME
1843 @item @emph{Description}:
1844 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
1845 time information from the real-time system clock. @var{DATE} is
1846 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
1847 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
1848 representing the difference with respect to Coordinated Universal Time (UTC).
1849 Unavailable time and date parameters return blanks.
1851 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
1853 @multitable @columnfractions .15 .30 .60
1854 @item @tab @code{VALUE(1)}: @tab The year
1855 @item @tab @code{VALUE(2)}: @tab The month
1856 @item @tab @code{VALUE(3)}: @tab The day of the month
1857 @item @tab @code{VAlUE(4)}: @tab Time difference with UTC in minutes
1858 @item @tab @code{VALUE(5)}: @tab The hour of the day
1859 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
1860 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
1861 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
1864 @item @emph{Option}:
1870 @item @emph{Syntax}:
1871 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
1873 @item @emph{Arguments}:
1874 @multitable @columnfractions .15 .80
1875 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
1876 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
1877 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
1878 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
1881 @item @emph{Return value}:
1884 @item @emph{Example}:
1886 program test_time_and_date
1887 character(8) :: date
1888 character(10) :: time
1889 character(5) :: zone
1890 integer,dimension(8) :: values
1891 ! using keyword arguments
1892 call date_and_time(date,time,zone,values)
1893 call date_and_time(DATE=date,ZONE=zone)
1894 call date_and_time(TIME=time)
1895 call date_and_time(VALUES=values)
1896 print '(a,2x,a,2x,a)', date, time, zone
1897 print '(8i5))', values
1898 end program test_time_and_date
1905 @section @code{DBLE} --- Double conversion function
1906 @findex @code{DBLE} intrinsic
1907 @cindex double conversion
1910 @item @emph{Description}:
1911 @code{DBLE(X)} Converts @var{X} to double precision real type.
1912 @code{DFLOAT} is an alias for @code{DBLE}
1914 @item @emph{Option}:
1920 @item @emph{Syntax}:
1922 @code{X = DFLOAT(X)}
1924 @item @emph{Arguments}:
1925 @multitable @columnfractions .15 .80
1926 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
1929 @item @emph{Return value}:
1930 The return value is of type double precision real.
1932 @item @emph{Example}:
1937 complex :: z = (2.3,1.14)
1938 print *, dble(x), dble(i), dfloat(z)
1939 end program test_dble
1946 @section @code{DCMPLX} --- Double complex conversion function
1947 @findex @code{DCMPLX} intrinsic
1951 @item @emph{Description}:
1952 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
1953 converted to the real component. If @var{Y} is present it is converted to the
1954 imaginary component. If @var{Y} is not present then the imaginary component is
1955 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
1957 @item @emph{Option}:
1963 @item @emph{Syntax}:
1964 @code{C = DCMPLX(X)}
1965 @code{C = DCMPLX(X,Y)}
1967 @item @emph{Arguments}:
1968 @multitable @columnfractions .15 .80
1969 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
1970 @item @var{Y} @tab Optional if @var{X} is not @code{COMPLEX(*)}. May be @code{INTEGER(*)} or @code{REAL(*)}.
1973 @item @emph{Return value}:
1974 The return value is of type @code{COMPLEX(8)}
1976 @item @emph{Example}:
1986 print *, dcmplx(x,i)
1987 end program test_dcmplx
1994 @section @code{DFLOAT} --- Double conversion function
1995 @findex @code{DFLOAT} intrinsic
1996 @cindex double float conversion
1999 @item @emph{Description}:
2000 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2001 @code{DFLOAT} is an alias for @code{DBLE}. See @code{DBLE}.
2007 @section @code{DIGITS} --- Significant digits function
2008 @findex @code{DIGITS} intrinsic
2009 @cindex digits, significant
2012 @item @emph{Description}:
2013 @code{DIGITS(X)} returns the number of significant digits of the internal model
2014 representation of @var{X}. For example, on a system using a 32-bit
2015 floating point representation, a default real number would likely return 24.
2017 @item @emph{Option}:
2023 @item @emph{Syntax}:
2024 @code{C = DIGITS(X)}
2026 @item @emph{Arguments}:
2027 @multitable @columnfractions .15 .80
2028 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2031 @item @emph{Return value}:
2032 The return value is of type @code{INTEGER}.
2034 @item @emph{Example}:
2037 integer :: i = 12345
2043 end program test_digits
2050 @section @code{DIM} --- Dim function
2051 @findex @code{DIM} intrinsic
2052 @findex @code{IDIM} intrinsic
2053 @findex @code{DDIM} intrinsic
2057 @item @emph{Description}:
2058 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2059 otherwise returns zero.
2061 @item @emph{Option}:
2067 @item @emph{Syntax}:
2070 @item @emph{Arguments}:
2071 @multitable @columnfractions .15 .80
2072 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2073 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2076 @item @emph{Return value}:
2077 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2079 @item @emph{Example}:
2085 x = dim(4.345_8, 2.111_8)
2088 end program test_dim
2091 @item @emph{Specific names}:
2092 @multitable @columnfractions .24 .24 .24 .24
2093 @item Name @tab Argument @tab Return type @tab Option
2094 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab gnu
2095 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab gnu
2102 @section @code{DOT_PRODUCT} --- Dot product function
2103 @findex @code{DOT_PRODUCT} intrinsic
2107 @item @emph{Description}:
2108 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2109 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2110 and must be arrays of rank one and of equal size. If the vectors are
2111 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2112 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2113 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2115 @item @emph{Option}:
2119 transformational function
2121 @item @emph{Syntax}:
2122 @code{S = DOT_PRODUCT(X,Y)}
2124 @item @emph{Arguments}:
2125 @multitable @columnfractions .15 .80
2126 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2127 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2130 @item @emph{Return value}:
2131 If the arguments are numeric, the return value is a scaler of numeric type,
2132 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2133 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2135 @item @emph{Example}:
2137 program test_dot_prod
2138 integer, dimension(3) :: a, b
2145 print *, dot_product(a,b)
2146 end program test_dot_prod
2153 @section @code{DPROD} --- Double product function
2154 @findex @code{DPROD} intrinsic
2155 @cindex Double product
2158 @item @emph{Description}:
2159 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2161 @item @emph{Option}:
2167 @item @emph{Syntax}:
2168 @code{D = DPROD(X,Y)}
2170 @item @emph{Arguments}:
2171 @multitable @columnfractions .15 .80
2172 @item @var{X} @tab The type shall be @code{REAL}.
2173 @item @var{Y} @tab The type shall be @code{REAL}.
2176 @item @emph{Return value}:
2177 The return value is of type @code{REAL(8)}.
2179 @item @emph{Example}:
2188 end program test_dprod
2195 @section @code{DREAL} --- Double real part function
2196 @findex @code{DREAL} intrinsic
2197 @cindex Double real part
2200 @item @emph{Description}:
2201 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2203 @item @emph{Option}:
2209 @item @emph{Syntax}:
2212 @item @emph{Arguments}:
2213 @multitable @columnfractions .15 .80
2214 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2217 @item @emph{Return value}:
2218 The return value is of type @code{REAL(8)}.
2220 @item @emph{Example}:
2223 complex(8) :: z = (1.3_8,7.2_8)
2225 end program test_dreal
2232 @section @code{DTIME} --- Execution time subroutine (or function)
2233 @findex @code{DTIME} intrinsic
2234 @cindex dtime subroutine
2237 @item @emph{Description}:
2238 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2239 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2240 returns the user and system components of this time in @code{TARRAY(1)} and
2241 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2244 Subsequent invocations of @code{DTIME} return values accumulated since the
2245 previous invocation.
2247 On some systems, the underlying timings are represented using types with
2248 sufficiently small limits that overflows (wraparounds) are possible, such as
2249 32-bit types. Therefore, the values returned by this intrinsic might be, or
2250 become, negative, or numerically less than previous values, during a single
2251 run of the compiled program.
2253 If @code{DTIME} is invoked as a function, it can not be invoked as a
2254 subroutine, and vice versa.
2256 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2258 @multitable @columnfractions .15 .30 .60
2259 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2260 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2261 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2264 @item @emph{Option}:
2270 @item @emph{Syntax}:
2271 @multitable @columnfractions .80
2272 @item @code{CALL DTIME(TARRAY, RESULT)}.
2273 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
2276 @item @emph{Arguments}:
2277 @multitable @columnfractions .15 .80
2278 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2279 @item @var{RESULT}@tab The type shall be @code{REAL}.
2282 @item @emph{Return value}:
2283 Elapsed time in seconds since the start of program execution.
2285 @item @emph{Example}:
2289 real, dimension(2) :: tarray
2291 call dtime(tarray, result)
2295 do i=1,100000000 ! Just a delay
2298 call dtime(tarray, result)
2302 end program test_dtime
2309 @section @code{EOSHIFT} --- End-off shift function
2310 @findex @code{EOSHIFT} intrinsic
2311 @cindex eoshift intrinsic
2314 @item @emph{Description}:
2315 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
2316 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
2317 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2318 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
2319 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
2320 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
2321 then all complete rank one sections of @var{ARRAY} along the given dimension are
2322 shifted. Elements shifted out one end of each rank one section are dropped. If
2323 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
2324 is copied back in the other end. If @var{BOUNDARY} is not present then the
2325 following are copied in depending on the type of @var{ARRAY}.
2327 @multitable @columnfractions .15 .80
2328 @item @emph{Array Type} @tab @emph{Boundary Value}
2329 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
2330 @item Logical @tab @code{.FALSE.}.
2331 @item Character(@var{len}) @tab @var{len} blanks.
2334 @item @emph{Option}:
2338 transformational function
2340 @item @emph{Syntax}:
2341 @code{A = EOSHIFT(A, SHIFT[,BOUNDARY, DIM])}
2343 @item @emph{Arguments}:
2344 @multitable @columnfractions .15 .80
2345 @item @var{ARRAY} @tab May be any type, not scaler.
2346 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2347 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
2348 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2351 @item @emph{Return value}:
2352 Returns an array of same type and rank as the @var{ARRAY} argument.
2354 @item @emph{Example}:
2356 program test_eoshift
2357 integer, dimension(3,3) :: a
2358 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2359 print '(3i3)', a(1,:)
2360 print '(3i3)', a(2,:)
2361 print '(3i3)', a(3,:)
2362 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
2364 print '(3i3)', a(1,:)
2365 print '(3i3)', a(2,:)
2366 print '(3i3)', a(3,:)
2367 end program test_eoshift
2374 @section @code{EPSILON} --- Epsilon function
2375 @findex @code{EPSILON} intrinsic
2376 @cindex epsilon, significant
2379 @item @emph{Description}:
2380 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
2382 @item @emph{Option}:
2388 @item @emph{Syntax}:
2389 @code{C = EPSILON(X)}
2391 @item @emph{Arguments}:
2392 @multitable @columnfractions .15 .80
2393 @item @var{X} @tab The type shall be @code{REAL(*)}.
2396 @item @emph{Return value}:
2397 The return value is of same type as the argument.
2399 @item @emph{Example}:
2401 program test_epsilon
2406 end program test_epsilon
2413 @section @code{ERF} --- Error function
2414 @findex @code{ERF} intrinsic
2415 @cindex error function
2418 @item @emph{Description}:
2419 @code{ERF(X)} computes the error function of @var{X}.
2421 @item @emph{Option}:
2427 @item @emph{Syntax}:
2430 @item @emph{Arguments}:
2431 @multitable @columnfractions .15 .80
2432 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
2435 @item @emph{Return value}:
2436 The return value is a scalar of type @code{REAL(*)} and it is positive
2437 (@math{ - 1 \leq erf (x) \leq 1 }.
2439 @item @emph{Example}:
2442 real(8) :: x = 0.17_8
2444 end program test_erf
2447 @item @emph{Specific names}:
2448 @multitable @columnfractions .24 .24 .24 .24
2449 @item Name @tab Argument @tab Return type @tab Option
2450 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
2457 @section @code{ERFC} --- Error function
2458 @findex @code{ERFC} intrinsic
2459 @cindex error function
2462 @item @emph{Description}:
2463 @code{ERFC(X)} computes the complementary error function of @var{X}.
2465 @item @emph{Option}:
2471 @item @emph{Syntax}:
2474 @item @emph{Arguments}:
2475 @multitable @columnfractions .15 .80
2476 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
2479 @item @emph{Return value}:
2480 The return value is a scalar of type @code{REAL(*)} and it is positive
2481 (@math{ 0 \leq erfc (x) \leq 2 }.
2483 @item @emph{Example}:
2486 real(8) :: x = 0.17_8
2488 end program test_erfc
2491 @item @emph{Specific names}:
2492 @multitable @columnfractions .24 .24 .24 .24
2493 @item Name @tab Argument @tab Return type @tab Option
2494 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
2501 @section @code{ETIME} --- Execution time subroutine (or function)
2502 @findex @code{ETIME} intrinsic
2503 @cindex ETIME subroutine
2506 @item @emph{Description}:
2507 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
2508 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2509 returns the user and system components of this time in @code{TARRAY(1)} and
2510 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
2512 On some systems, the underlying timings are represented using types with
2513 sufficiently small limits that overflows (wraparounds) are possible, such as
2514 32-bit types. Therefore, the values returned by this intrinsic might be, or
2515 become, negative, or numerically less than previous values, during a single
2516 run of the compiled program.
2518 If @code{ETIME} is invoked as a function, it can not be invoked as a
2519 subroutine, and vice versa.
2521 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2523 @multitable @columnfractions .15 .30 .60
2524 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2525 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2526 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2529 @item @emph{Option}:
2535 @item @emph{Syntax}:
2536 @multitable @columnfractions .8
2537 @item @code{CALL ETIME(TARRAY, RESULT)}.
2538 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
2541 @item @emph{Arguments}:
2542 @multitable @columnfractions .15 .80
2543 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2544 @item @var{RESULT}@tab The type shall be @code{REAL}.
2547 @item @emph{Return value}:
2548 Elapsed time in seconds since the start of program execution.
2550 @item @emph{Example}:
2554 real, dimension(2) :: tarray
2556 call ETIME(tarray, result)
2560 do i=1,100000000 ! Just a delay
2563 call ETIME(tarray, result)
2567 end program test_etime
2574 @section @code{EXIT} --- Exit the program with status.
2579 @item @emph{Description}:
2580 @code{EXIT} causes immediate termination of the program with status. If status
2581 is omitted it returns the canonical @emph{success} for the system. All Fortran
2582 I/O units are closed.
2584 @item @emph{Option}:
2588 non-elemental subroutine
2590 @item @emph{Syntax}:
2591 @code{CALL EXIT([STATUS])}
2593 @item @emph{Arguments}:
2594 @multitable @columnfractions .15 .80
2595 @item @var{STATUS} @tab The type of the argument shall be @code{INTEGER(*)}.
2598 @item @emph{Return value}:
2599 @code{STATUS} is passed to the parent process on exit.
2601 @item @emph{Example}:
2604 integer :: STATUS = 0
2605 print *, 'This program is going to exit.'
2607 end program test_exit
2614 @section @code{EXP} --- Exponential function
2615 @findex @code{EXP} intrinsic
2616 @findex @code{DEXP} intrinsic
2617 @findex @code{ZEXP} intrinsic
2618 @findex @code{CDEXP} intrinsic
2622 @item @emph{Description}:
2623 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
2625 @item @emph{Option}:
2631 @item @emph{Syntax}:
2634 @item @emph{Arguments}:
2635 @multitable @columnfractions .15 .80
2636 @item @var{X} @tab The type shall be @code{REAL(*)} or
2640 @item @emph{Return value}:
2641 The return value has same type and kind as @var{X}.
2643 @item @emph{Example}:
2648 end program test_exp
2651 @item @emph{Specific names}:
2652 @multitable @columnfractions .24 .24 .24 .24
2653 @item Name @tab Argument @tab Return type @tab Option
2654 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
2655 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
2656 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2657 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2664 @section @code{EXPONENT} --- Exponent function
2665 @findex @code{EXPONENT} intrinsic
2666 @cindex exponent function
2669 @item @emph{Description}:
2670 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
2671 is zero the value returned is zero.
2673 @item @emph{Option}:
2679 @item @emph{Syntax}:
2680 @code{I = EXPONENT(X)}
2682 @item @emph{Arguments}:
2683 @multitable @columnfractions .15 .80
2684 @item @var{X} @tab The type shall be @code{REAL(*)}.
2687 @item @emph{Return value}:
2688 The return value is of type default @code{INTEGER}.
2690 @item @emph{Example}:
2692 program test_exponent
2697 print *, exponent(0.0)
2698 end program test_exponent
2704 @section @code{FREE} --- Frees memory
2705 @findex @code{FREE} intrinsic
2709 @item @emph{Description}:
2710 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
2711 intrinsic is an extension intended to be used with Cray pointers, and is
2712 provided in @command{gfortran} to allow user to compile legacy code. For
2713 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
2716 @item @emph{Option}:
2722 @item @emph{Syntax}:
2725 @item @emph{Arguments}:
2726 @multitable @columnfractions .15 .80
2727 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
2728 location of the memory that should be de-allocated.
2731 @item @emph{Return value}:
2734 @item @emph{Example}:
2735 See @code{MALLOC} for an example.
2740 @section @code{FLOOR} --- Integer floor function
2741 @findex @code{FLOOR} intrinsic
2745 @item @emph{Description}:
2746 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
2748 @item @emph{Option}:
2754 @item @emph{Syntax}:
2755 @code{I = FLOOR(X[,KIND])}
2757 @item @emph{Arguments}:
2758 @multitable @columnfractions .15 .80
2759 @item @var{X} @tab The type shall be @code{REAL(*)}.
2760 @item @var{KIND} @tab Optional scaler integer initialization expression.
2763 @item @emph{Return value}:
2764 The return value is of type @code{INTEGER(KIND)}
2766 @item @emph{Example}:
2771 print *, floor(x) ! returns 63
2772 print *, floor(y) ! returns -64
2773 end program test_floor
2780 @section @code{FNUM} --- File number function
2781 @findex @code{FNUM} intrinsic
2785 @item @emph{Description}:
2786 @code{FNUM(UNIT)} returns the Posix file descriptor number corresponding to the
2787 open Fortran I/O unit @code{UNIT}.
2789 @item @emph{Option}:
2793 non-elemental function
2795 @item @emph{Syntax}:
2796 @code{I = FNUM(UNIT)}
2798 @item @emph{Arguments}:
2799 @multitable @columnfractions .15 .80
2800 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
2803 @item @emph{Return value}:
2804 The return value is of type @code{INTEGER}
2806 @item @emph{Example}:
2810 open (unit=10, status = "scratch")
2814 end program test_fnum
2819 @section @code{LOC} --- Returns the address of a variable
2820 @findex @code{LOC} intrinsic
2824 @item @emph{Description}:
2825 @code{LOC(X)} returns the address of @var{X} as an integer.
2827 @item @emph{Option}:
2833 @item @emph{Syntax}:
2836 @item @emph{Arguments}:
2837 @multitable @columnfractions .15 .80
2838 @item @var{X} @tab Variable of any type.
2841 @item @emph{Return value}:
2842 The return value is of type @code{INTEGER(n)}, where @code{n} is the
2843 size (in bytes) of a memory address on the target machine.
2845 @item @emph{Example}:
2852 end program test_loc
2857 @section @code{LOG} --- Logarithm function
2858 @findex @code{LOG} intrinsic
2859 @findex @code{ALOG} intrinsic
2860 @findex @code{DLOG} intrinsic
2861 @findex @code{CLOG} intrinsic
2862 @findex @code{ZLOG} intrinsic
2863 @findex @code{CDLOG} intrinsic
2867 @item @emph{Description}:
2868 @code{LOG(X)} computes the logarithm of @var{X}.
2870 @item @emph{Option}:
2876 @item @emph{Syntax}:
2879 @item @emph{Arguments}:
2880 @multitable @columnfractions .15 .80
2881 @item @var{X} @tab The type shall be @code{REAL(*)} or
2885 @item @emph{Return value}:
2886 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
2887 The kind type parameter is the same as @var{X}.
2889 @item @emph{Example}:
2892 real(8) :: x = 1.0_8
2893 complex :: z = (1.0, 2.0)
2896 end program test_log
2899 @item @emph{Specific names}:
2900 @multitable @columnfractions .24 .24 .24 .24
2901 @item Name @tab Argument @tab Return type @tab Option
2902 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
2903 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
2904 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
2905 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2906 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2913 @section @code{LOG10} --- Base 10 logarithm function
2914 @findex @code{LOG10} intrinsic
2915 @findex @code{ALOG10} intrinsic
2916 @findex @code{DLOG10} intrinsic
2920 @item @emph{Description}:
2921 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
2923 @item @emph{Option}:
2929 @item @emph{Syntax}:
2932 @item @emph{Arguments}:
2933 @multitable @columnfractions .15 .80
2934 @item @var{X} @tab The type shall be @code{REAL(*)} or
2938 @item @emph{Return value}:
2939 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
2940 The kind type parameter is the same as @var{X}.
2942 @item @emph{Example}:
2945 real(8) :: x = 10.0_8
2947 end program test_log10
2950 @item @emph{Specific names}:
2951 @multitable @columnfractions .24 .24 .24 .24
2952 @item Name @tab Argument @tab Return type @tab Option
2953 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
2954 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
2960 @section @code{MALLOC} --- Allocate dynamic memory
2961 @findex @code{MALLOC} intrinsic
2965 @item @emph{Description}:
2966 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
2967 returns the address of the allocated memory. The @code{MALLOC} intrinsic
2968 is an extension intended to be used with Cray pointers, and is provided
2969 in @command{gfortran} to allow user to compile legacy code. For new code
2970 using Fortran 95 pointers, the memory allocation intrinsic is
2973 @item @emph{Option}:
2977 non-elemental function
2979 @item @emph{Syntax}:
2980 @code{PTR = MALLOC(SIZE)}
2982 @item @emph{Arguments}:
2983 @multitable @columnfractions .15 .80
2984 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
2987 @item @emph{Return value}:
2988 The return value is of type @code{INTEGER(K)}, with @var{K} such that
2989 variables of type @code{INTEGER(K)} have the same size as
2990 C pointers (@code{sizeof(void *)}).
2992 @item @emph{Example}:
2993 The following example demonstrates the use of @code{MALLOC} and
2994 @code{FREE} with Cray pointers. This example is intended to run on
2995 32-bit systems, where the default integer kind is suitable to store
2996 pointers; on 64-bit systems, ptr_x would need to be declared as
2997 @code{integer(kind=8)}.
3006 ptr_x = malloc(20*8)
3008 x(i) = sqrt(1.0d0 / i)
3016 end program test_malloc
3022 @section @code{REAL} --- Convert to real type
3023 @findex @code{REAL} intrinsic
3024 @findex @code{REALPART} intrinsic
3028 @item @emph{Description}:
3029 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
3030 @code{REALPART(X)} function is provided for compatibility with @command{g77},
3031 and its use is strongly discouraged.
3033 @item @emph{Option}:
3037 transformational function
3039 @item @emph{Syntax}:
3040 @multitable @columnfractions .30 .80
3041 @item @code{X = REAL(X)}
3042 @item @code{X = REAL(X, KIND)}
3043 @item @code{X = REALPART(Z)}
3046 @item @emph{Arguments}:
3047 @multitable @columnfractions .15 .80
3048 @item @var{X} @tab shall be @code{INTEGER(*)}, @code{REAL(*)}, or
3050 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer.
3053 @item @emph{Return value}:
3054 These functions return the a @code{REAL(*)} variable or array under
3055 the following rules:
3059 @code{REAL(X)} is converted to a default real type if @var{X} is an
3060 integer or real variable.
3062 @code{REAL(X)} is converted to a real type with the kind type parameter
3063 of @var{X} if @var{X} is a complex variable.
3065 @code{REAL(X, KIND)} is converted to a real type with kind type
3066 parameter @var{KIND} if @var{X} is a complex, integer, or real
3070 @item @emph{Example}:
3073 complex :: x = (1.0, 2.0)
3074 print *, real(x), real(x,8), realpart(x)
3075 end program test_real
3082 @section @code{SIGNAL} --- Signal handling subroutine (or function)
3083 @findex @code{SIGNAL} intrinsic
3084 @cindex SIGNAL subroutine
3087 @item @emph{Description}:
3088 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
3089 @var{HANDLER} to be executed with a single integer argument when signal
3090 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
3091 turn off handling of signal @var{NUMBER} or revert to its default
3092 action. See @code{signal(2)}.
3094 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
3095 is supplied, it is set to the value returned by @code{signal(2)}.
3097 @item @emph{Option}:
3101 subroutine, non-elemental function
3103 @item @emph{Syntax}:
3104 @multitable @columnfractions .30 .80
3105 @item @code{CALL ALARM(NUMBER, HANDLER)}
3106 @item @code{CALL ALARM(NUMBER, HANDLER, STATUS)}
3107 @item @code{STATUS = ALARM(NUMBER, HANDLER)}
3110 @item @emph{Arguments}:
3111 @multitable @columnfractions .15 .80
3112 @item @var{NUMBER} @tab shall be a scalar integer, with @code{INTENT(IN)}
3113 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
3114 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
3115 @code{INTEGER}. It is @code{INTENT(IN)}.
3116 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
3117 integer. It has @code{INTENT(OUT)}.
3120 @item @emph{Return value}:
3121 The @code{SIGNAL} functions returns the value returned by @code{signal(2)}.
3123 @item @emph{Example}:
3127 external handler_print
3129 call signal (12, handler_print)
3133 end program test_signal
3141 @section @code{SECNDS} --- Time subroutine
3142 @findex @code{SECNDS} intrinsic
3146 @item @emph{Description}:
3147 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
3148 @var{X} is a reference time, also in seconds. If this is zero, the time in
3149 seconds from midnight is returned. This function is non-standard and its
3152 @item @emph{Option}:
3158 @item @emph{Syntax}:
3159 @code{T = SECNDS (X)}
3161 @item @emph{Arguments}:
3162 @multitable @columnfractions .15 .80
3163 @item Name @tab Type
3164 @item @var{T} @tab REAL(4)
3165 @item @var{X} @tab REAL(4)
3168 @item @emph{Return value}:
3171 @item @emph{Example}:
3175 print *, secnds (0.0) ! seconds since midnight
3176 t1 = secnds (0.0) ! reference time
3177 do i = 1, 10000000 ! do something
3179 t2 = secnds (t1) ! elapsed time
3180 print *, "Something took ", t2, " seconds."
3181 end program test_secnds
3188 @section @code{SIN} --- Sine function
3189 @findex @code{SIN} intrinsic
3190 @findex @code{DSIN} intrinsic
3191 @findex @code{ZSIN} intrinsic
3192 @findex @code{CDSIN} intrinsic
3196 @item @emph{Description}:
3197 @code{SIN(X)} computes the sine of @var{X}.
3199 @item @emph{Option}:
3205 @item @emph{Syntax}:
3208 @item @emph{Arguments}:
3209 @multitable @columnfractions .15 .80
3210 @item @var{X} @tab The type shall be @code{REAL(*)} or
3214 @item @emph{Return value}:
3215 The return value has same type and king than @var{X}.
3217 @item @emph{Example}:
3222 end program test_sin
3225 @item @emph{Specific names}:
3226 @multitable @columnfractions .24 .24 .24 .24
3227 @item Name @tab Argument @tab Return type @tab Option
3228 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3229 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
3230 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3231 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3238 @section @code{SINH} --- Hyperbolic sine function
3239 @findex @code{SINH} intrinsic
3240 @findex @code{DSINH} intrinsic
3241 @cindex hyperbolic sine
3244 @item @emph{Description}:
3245 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
3247 @item @emph{Option}:
3253 @item @emph{Syntax}:
3256 @item @emph{Arguments}:
3257 @multitable @columnfractions .15 .80
3258 @item @var{X} @tab The type shall be @code{REAL(*)}.
3261 @item @emph{Return value}:
3262 The return value is of type @code{REAL(*)}.
3264 @item @emph{Example}:
3267 real(8) :: x = - 1.0_8
3269 end program test_sinh
3272 @item @emph{Specific names}:
3273 @multitable @columnfractions .24 .24 .24 .24
3274 @item Name @tab Argument @tab Return type @tab Option
3275 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3282 @section @code{SQRT} --- Square-root function
3283 @findex @code{SQRT} intrinsic
3284 @findex @code{DSQRT} intrinsic
3285 @findex @code{CSQRT} intrinsic
3286 @findex @code{ZSQRT} intrinsic
3287 @findex @code{CDSQRT} intrinsic
3291 @item @emph{Description}:
3292 @code{SQRT(X)} computes the square root of @var{X}.
3294 @item @emph{Option}:
3300 @item @emph{Syntax}:
3303 @item @emph{Arguments}:
3304 @multitable @columnfractions .15 .80
3305 @item @var{X} @tab The type shall be @code{REAL(*)} or
3309 @item @emph{Return value}:
3310 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
3311 The kind type parameter is the same as @var{X}.
3313 @item @emph{Example}:
3316 real(8) :: x = 2.0_8
3317 complex :: z = (1.0, 2.0)
3320 end program test_sqrt
3323 @item @emph{Specific names}:
3324 @multitable @columnfractions .24 .24 .24 .24
3325 @item Name @tab Argument @tab Return type @tab Option
3326 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3327 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
3328 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3329 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3336 @section @code{TAN} --- Tangent function
3337 @findex @code{TAN} intrinsic
3338 @findex @code{DTAN} intrinsic
3342 @item @emph{Description}:
3343 @code{TAN(X)} computes the tangent of @var{X}.
3345 @item @emph{Option}:
3351 @item @emph{Syntax}:
3354 @item @emph{Arguments}:
3355 @multitable @columnfractions .15 .80
3356 @item @var{X} @tab The type shall be @code{REAL(*)}.
3359 @item @emph{Return value}:
3360 The return value is of type @code{REAL(*)}. The kind type parameter is
3361 the same as @var{X}.
3363 @item @emph{Example}:
3366 real(8) :: x = 0.165_8
3368 end program test_tan
3371 @item @emph{Specific names}:
3372 @multitable @columnfractions .24 .24 .24 .24
3373 @item Name @tab Argument @tab Return type @tab Option
3374 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3381 @section @code{TANH} --- Hyperbolic tangent function
3382 @findex @code{TANH} intrinsic
3383 @findex @code{DTANH} intrinsic
3384 @cindex hyperbolic tangent
3387 @item @emph{Description}:
3388 @code{TANH(X)} computes the hyperbolic tangent 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(*)} and lies in the range
3406 @math{ - 1 \leq tanh(x) \leq 1 }.
3408 @item @emph{Example}:
3411 real(8) :: x = 2.1_8
3413 end program test_tanh
3416 @item @emph{Specific names}:
3417 @multitable @columnfractions .24 .24 .24 .24
3418 @item Name @tab Argument @tab Return type @tab Option
3419 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3427 @comment gen fraction
3445 @comment sub get_command
3447 @comment sub get_command_argument
3449 @comment sub get_environment_variable
3489 @comment gen len_trim
3499 @comment gen logical
3510 @comment gen maxexponent
3525 @comment gen minexponent
3539 @comment gen nearest
3550 @comment gen precision
3552 @comment gen present
3554 @comment gen product
3561 @comment sub random_number
3563 @comment sub random_seed
3573 @comment gen reshape
3575 @comment gen rrspacing
3584 @comment gen selected_int_kind
3586 @comment gen selected_real_kind
3588 @comment gen set_exponent
3598 @comment gen spacing
3612 @comment sub system_clock
3616 @comment gen transfer
3618 @comment gen transpose