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{FLOOR}: FLOOR, Integer floor function
92 * @code{FNUM}: FNUM, File number function
93 * @code{FREE}: FREE, Memory de-allocation subroutine
94 * @code{LOC}: LOC, Returns the address of a variable
95 * @code{LOG}: LOG, Logarithm function
96 * @code{LOG10}: LOG10, Base 10 logarithm function
97 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
98 * @code{REAL}: REAL, Convert to real type
99 * @code{SECNDS}: SECNDS, Time function
100 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
101 * @code{SIN}: SIN, Sine function
102 * @code{SINH}: SINH, Hyperbolic sine function
103 * @code{SQRT}: SQRT, Square-root function
104 * @code{TAN}: TAN, Tangent function
105 * @code{TANH}: TANH, Hyperbolic tangent function
109 @section Introduction to intrinsic procedures
111 Gfortran provides a rich set of intrinsic procedures that includes all
112 the intrinsic procedures required by the Fortran 95 standard, a set of
113 intrinsic procedures for backwards compatibility with Gnu Fortran 77
114 (i.e., @command{g77}), and a small selection of intrinsic procedures
115 from the Fortran 2003 standard. Any description here, which conflicts with a
116 description in either the Fortran 95 standard or the Fortran 2003 standard,
117 is unintentional and the standard(s) should be considered authoritative.
119 The enumeration of the @code{KIND} type parameter is processor defined in
120 the Fortran 95 standard. Gfortran defines the default integer type and
121 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
122 respectively. The standard mandates that both data types shall have
123 another kind, which have more precision. On typical target architectures
124 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
125 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
126 In the description of generic intrinsic procedures, the kind type parameter
127 will be specified by @code{KIND=*}, and in the description of specific
128 names for an intrinsic procedure the kind type parameter will be explicitly
129 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
130 brevity the optional @code{KIND=} syntax will be omitted.
132 Many of the intrinsics procedures take one or more optional arguments.
133 This document follows the convention used in the Fortran 95 standard,
134 and denotes such arguments by square brackets.
136 @command{Gfortran} offers the @option{-std=f95} and @option{-std=gnu} options,
137 which can be used to restrict the set of intrinsic procedures to a
138 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
139 option, and so all intrinsic procedures described here are accepted. There
140 is one caveat. For a select group of intrinsic procedures, @command{g77}
141 implemented both a function and a subroutine. Both classes
142 have been implemented in @command{gfortran} for backwards compatibility
143 with @command{g77}. It is noted here that these functions and subroutines
144 cannot be intermixed in a given subprogram. In the descriptions that follow,
145 the applicable option(s) is noted.
150 @section @code{ABORT} --- Abort the program
155 @item @emph{Description}:
156 @code{ABORT} causes immediate termination of the program. On operating
157 systems that support a core dump, @code{ABORT} will produce a core dump,
158 which is suitable for debugging purposes.
164 non-elemental subroutine
169 @item @emph{Return value}:
172 @item @emph{Example}:
175 integer :: i = 1, j = 2
176 if (i /= j) call abort
177 end program test_abort
184 @section @code{ABS} --- Absolute value
185 @findex @code{ABS} intrinsic
186 @findex @code{CABS} intrinsic
187 @findex @code{DABS} intrinsic
188 @findex @code{IABS} intrinsic
189 @findex @code{ZABS} intrinsic
190 @findex @code{CDABS} intrinsic
191 @cindex absolute value
194 @item @emph{Description}:
195 @code{ABS(X)} computes the absolute value of @code{X}.
206 @item @emph{Arguments}:
207 @multitable @columnfractions .15 .80
208 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
209 @code{REAL(*)}, or @code{COMPLEX(*)}.
212 @item @emph{Return value}:
213 The return value is of the same type and
214 kind as the argument except the return value is @code{REAL(*)} for a
215 @code{COMPLEX(*)} argument.
217 @item @emph{Example}:
222 complex :: z = (-1.e0,0.e0)
229 @item @emph{Specific names}:
230 @multitable @columnfractions .24 .24 .24 .24
231 @item Name @tab Argument @tab Return type @tab Option
232 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab f95, gnu
233 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
234 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab f95, gnu
235 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
236 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
243 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
244 @findex @code{ACHAR} intrinsic
245 @cindex @acronym{ASCII} collating sequence
248 @item @emph{Description}:
249 @code{ACHAR(I)} returns the character located at position @code{I}
250 in the @acronym{ASCII} collating sequence.
261 @item @emph{Arguments}:
262 @multitable @columnfractions .15 .80
263 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
266 @item @emph{Return value}:
267 The return value is of type @code{CHARACTER} with a length of one. The
268 kind type parameter is the same as @code{KIND('A')}.
270 @item @emph{Example}:
275 end program test_achar
282 @section @code{ACOS} --- Arc cosine function
283 @findex @code{ACOS} intrinsic
284 @findex @code{DACOS} intrinsic
288 @item @emph{Description}:
289 @code{ACOS(X)} computes the arc cosine of @var{X}.
300 @item @emph{Arguments}:
301 @multitable @columnfractions .15 .80
302 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
306 @item @emph{Return value}:
307 The return value is of type @code{REAL(*)} and it lies in the
308 range @math{ 0 \leq \arccos (x) \leq \pi}. The kind type
309 parameter is the same as @var{X}.
311 @item @emph{Example}:
314 real(8) :: x = 0.866_8
316 end program test_acos
319 @item @emph{Specific names}:
320 @multitable @columnfractions .24 .24 .24 .24
321 @item Name @tab Argument @tab Return type @tab Option
322 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
329 @section @code{ADJUSTL} --- Left adjust a string
330 @findex @code{ADJUSTL} intrinsic
331 @cindex adjust string
334 @item @emph{Description}:
335 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
336 Spaces are inserted at the end of the string as needed.
345 @code{STR = ADJUSTL(STR)}
347 @item @emph{Arguments}:
348 @multitable @columnfractions .15 .80
349 @item @var{STR} @tab The type shall be @code{CHARACTER}.
352 @item @emph{Return value}:
353 The return value is of type @code{CHARACTER} where leading spaces
354 are removed and the same number of spaces are inserted on the end
357 @item @emph{Example}:
360 character(len=20) :: str = ' gfortran'
363 end program test_adjustl
370 @section @code{ADJUSTR} --- Right adjust a string
371 @findex @code{ADJUSTR} intrinsic
372 @cindex adjust string
375 @item @emph{Description}:
376 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
377 Spaces are inserted at the start of the string as needed.
386 @code{STR = ADJUSTR(STR)}
388 @item @emph{Arguments}:
389 @multitable @columnfractions .15 .80
390 @item @var{STR} @tab The type shall be @code{CHARACTER}.
393 @item @emph{Return value}:
394 The return value is of type @code{CHARACTER} where trailing spaces
395 are removed and the same number of spaces are inserted at the start
398 @item @emph{Example}:
401 character(len=20) :: str = 'gfortran'
404 end program test_adjustr
411 @section @code{AIMAG} --- Imaginary part of complex number
412 @findex @code{AIMAG} intrinsic
413 @findex @code{DIMAG} intrinsic
414 @findex @code{IMAG} intrinsic
415 @findex @code{IMAGPART} intrinsic
416 @cindex Imaginary part
419 @item @emph{Description}:
420 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
421 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
422 for compatibility with @command{g77}, and their use in new code is
423 strongly discouraged.
434 @item @emph{Arguments}:
435 @multitable @columnfractions .15 .80
436 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
439 @item @emph{Return value}:
440 The return value is of type real with the
441 kind type parameter of the argument.
443 @item @emph{Example}:
448 z4 = cmplx(1.e0_4, 0.e0_4)
449 z8 = cmplx(0.e0_8, 1.e0_8)
450 print *, aimag(z4), dimag(z8)
451 end program test_aimag
454 @item @emph{Specific names}:
455 @multitable @columnfractions .24 .24 .24 .24
456 @item Name @tab Argument @tab Return type @tab Option
457 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab f95, gnu
458 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab gnu
459 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab gnu
466 @section @code{AINT} --- Imaginary part of complex number
467 @findex @code{AINT} intrinsic
468 @findex @code{DINT} intrinsic
472 @item @emph{Description}:
473 @code{AINT(X [, KIND])} truncates its argument to a whole number.
483 @code{X = AINT(X, KIND)}
485 @item @emph{Arguments}:
486 @multitable @columnfractions .15 .80
487 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
488 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
489 initialization expression.
492 @item @emph{Return value}:
493 The return value is of type real with the kind type parameter of the
494 argument if the optional @var{KIND} is absent; otherwise, the kind
495 type parameter will be given by @var{KIND}. If the magnitude of
496 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
497 magnitude is equal to or greater than one, then it returns the largest
498 whole number that does not exceed its magnitude. The sign is the same
499 as the sign of @var{X}.
501 @item @emph{Example}:
508 print *, aint(x4), dint(x8)
510 end program test_aint
513 @item @emph{Specific names}:
514 @multitable @columnfractions .24 .24 .24 .24
515 @item Name @tab Argument @tab Return type @tab Option
516 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
523 @section @code{ALARM} --- Execute a routine after a given delay
524 @findex @code{ALARM} intrinsic
527 @item @emph{Description}:
528 @code{ALARM(SECONDS [, STATUS])} causes external subroutine @var{HANDLER}
529 to be executed after a delay of @var{SECONDS} by using @code{alarm(1)} to
530 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
531 supplied, it will be returned with the number of seconds remaining until
532 any previously scheduled alarm was due to be delivered, or zero if there
533 was no previously scheduled alarm.
542 @code{CALL ALARM(SECONDS, HANDLER)}
543 @code{CALL ALARM(SECONDS, HANDLER, STATUS)}
545 @item @emph{Arguments}:
546 @multitable @columnfractions .15 .80
547 @item @var{SECONDS} @tab The type of the argument shall be a scalar
548 @code{INTEGER}. It is @code{INTENT(IN)}.
549 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
550 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
551 @code{INTEGER}. It is @code{INTENT(IN)}.
552 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
553 @code{INTEGER} variable. It is @code{INTENT(OUT)}.
556 @item @emph{Example}:
559 external handler_print
561 call alarm (3, handler_print, i)
564 end program test_alarm
566 This will cause the external routine @var{handler_print} to be called
573 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
574 @findex @code{ALL} intrinsic
578 @item @emph{Description}:
579 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
580 in the array along dimension @var{DIM}.
586 transformational function
590 @code{L = ALL(MASK, DIM)}
592 @item @emph{Arguments}:
593 @multitable @columnfractions .15 .80
594 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
595 it shall not be scalar.
596 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
597 with a value that lies between one and the rank of @var{MASK}.
600 @item @emph{Return value}:
601 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
602 the kind type parameter is the same as the kind type parameter of
603 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
604 an array with the rank of @var{MASK} minus 1. The shape is determined from
605 the shape of @var{MASK} where the @var{DIM} dimension is elided.
609 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
610 It also is true if @var{MASK} has zero size; otherwise, it is false.
612 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
613 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
614 is determined by applying @code{ALL} to the array sections.
617 @item @emph{Example}:
621 l = all((/.true., .true., .true./))
626 integer a(2,3), b(2,3)
630 print *, all(a .eq. b, 1)
631 print *, all(a .eq. b, 2)
632 end subroutine section
640 @section @code{ALLOCATED} --- Status of an allocatable entity
641 @findex @code{ALLOCATED} intrinsic
642 @cindex allocation status
645 @item @emph{Description}:
646 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
655 @code{L = ALLOCATED(X)}
657 @item @emph{Arguments}:
658 @multitable @columnfractions .15 .80
659 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
662 @item @emph{Return value}:
663 The return value is a scalar @code{LOGICAL} with the default logical
664 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
665 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
667 @item @emph{Example}:
669 program test_allocated
671 real(4), allocatable :: x(:)
672 if (allocated(x) .eqv. .false.) allocate(x(i)
673 end program test_allocated
680 @section @code{ANINT} --- Imaginary part of complex number
681 @findex @code{ANINT} intrinsic
682 @findex @code{DNINT} intrinsic
686 @item @emph{Description}:
687 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
697 @code{X = ANINT(X, KIND)}
699 @item @emph{Arguments}:
700 @multitable @columnfractions .15 .80
701 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
702 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
703 initialization expression.
706 @item @emph{Return value}:
707 The return value is of type real with the kind type parameter of the
708 argument if the optional @var{KIND} is absent; otherwise, the kind
709 type parameter will be given by @var{KIND}. If @var{X} is greater than
710 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
711 less than or equal to zero, then return @code{AINT(X-0.5)}.
713 @item @emph{Example}:
720 print *, anint(x4), dnint(x8)
722 end program test_anint
725 @item @emph{Specific names}:
726 @multitable @columnfractions .24 .24 .24 .24
727 @item Name @tab Argument @tab Return type @tab Option
728 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
735 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
736 @findex @code{ANY} intrinsic
740 @item @emph{Description}:
741 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
742 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
748 transformational function
752 @code{L = ANY(MASK, DIM)}
754 @item @emph{Arguments}:
755 @multitable @columnfractions .15 .80
756 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
757 it shall not be scalar.
758 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
759 with a value that lies between one and the rank of @var{MASK}.
762 @item @emph{Return value}:
763 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
764 the kind type parameter is the same as the kind type parameter of
765 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
766 an array with the rank of @var{MASK} minus 1. The shape is determined from
767 the shape of @var{MASK} where the @var{DIM} dimension is elided.
771 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
772 otherwise, it is false. It also is false if @var{MASK} has zero size.
774 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
775 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
776 is determined by applying @code{ANY} to the array sections.
779 @item @emph{Example}:
783 l = any((/.true., .true., .true./))
788 integer a(2,3), b(2,3)
792 print *, any(a .eq. b, 1)
793 print *, any(a .eq. b, 2)
794 end subroutine section
802 @section @code{ASIN} --- Arcsine function
803 @findex @code{ASIN} intrinsic
804 @findex @code{DASIN} intrinsic
808 @item @emph{Description}:
809 @code{ASIN(X)} computes the arcsine of its @var{X}.
820 @item @emph{Arguments}:
821 @multitable @columnfractions .15 .80
822 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
826 @item @emph{Return value}:
827 The return value is of type @code{REAL(*)} and it lies in the
828 range @math{-\pi / 2 \leq \arccos (x) \leq \pi / 2}. The kind type
829 parameter is the same as @var{X}.
831 @item @emph{Example}:
834 real(8) :: x = 0.866_8
836 end program test_asin
839 @item @emph{Specific names}:
840 @multitable @columnfractions .24 .24 .24 .24
841 @item Name @tab Argument @tab Return type @tab Option
842 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
849 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
850 @findex @code{ASSOCIATED} intrinsic
851 @cindex pointer status
854 @item @emph{Description}:
855 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
856 or if @var{PTR} is associated with the target @var{TGT}.
865 @code{L = ASSOCIATED(PTR)}
866 @code{L = ASSOCIATED(PTR [, TGT])}
868 @item @emph{Arguments}:
869 @multitable @columnfractions .15 .80
870 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
871 it can be of any type.
872 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
873 a @code{TARGET}. It must have the same type, kind type parameter, and
874 array rank as @var{PTR}.
876 The status of neither @var{PTR} nor @var{TGT} can be undefined.
878 @item @emph{Return value}:
879 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
880 There are several cases:
882 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
883 is true if @var{PTR} is associated with a target; otherwise, it returns false.
884 @item (B) If @var{TGT} is present and a scalar target, the result is true if
886 is not a 0 sized storage sequence and the target associated with @var{PTR}
887 occupies the same storage units. If @var{PTR} is disassociated, then the
889 @item (C) If @var{TGT} is present and an array target, the result is true if
890 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
891 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
892 @var{PTR} occupy the same storage units in array element order.
893 As in case(B), the result is false, if @var{PTR} is disassociated.
894 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
895 target associated with @var{PTR} and the target associated with @var{TGT}
896 are not 0 sized storage sequences and occupy the same storage units.
897 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
898 @item (E) If @var{TGT} is present and an array pointer, the result is true if
899 target associated with @var{PTR} and the target associated with @var{TGT}
900 have the same shape, are not 0 sized arrays, are arrays whose elements are
901 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
902 storage units in array element order.
903 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
906 @item @emph{Example}:
908 program test_associated
910 real, target :: tgt(2) = (/1., 2./)
911 real, pointer :: ptr(:)
913 if (associated(ptr) .eqv. .false.) call abort
914 if (associated(ptr,tgt) .eqv. .false.) call abort
915 end program test_associated
922 @section @code{ATAN} --- Arctangent function
923 @findex @code{ATAN} intrinsic
924 @findex @code{DATAN} intrinsic
928 @item @emph{Description}:
929 @code{ATAN(X)} computes the arctangent of @var{X}.
940 @item @emph{Arguments}:
941 @multitable @columnfractions .15 .80
942 @item @var{X} @tab The type shall be @code{REAL(*)}.
945 @item @emph{Return value}:
946 The return value is of type @code{REAL(*)} and it lies in the
947 range @math{ - \pi / 2 \leq \arcsin (x) \leq \pi / 2}.
949 @item @emph{Example}:
952 real(8) :: x = 2.866_8
954 end program test_atan
957 @item @emph{Specific names}:
958 @multitable @columnfractions .24 .24 .24 .24
959 @item Name @tab Argument @tab Return type @tab Option
960 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
967 @section @code{ATAN2} --- Arctangent function
968 @findex @code{ATAN2} intrinsic
969 @findex @code{DATAN2} intrinsic
973 @item @emph{Description}:
974 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
983 @code{X = ATAN2(Y,X)}
985 @item @emph{Arguments}:
986 @multitable @columnfractions .15 .80
987 @item @var{Y} @tab The type shall be @code{REAL(*)}.
988 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
989 If @var{Y} is zero, then @var{X} must be nonzero.
992 @item @emph{Return value}:
993 The return value has the same type and kind type parameter as @var{Y}.
994 It is the principle value of the complex number @math{X + i Y}. If
995 @var{X} is nonzero, then it lies in the range @math{-\pi \le \arccos (x) \leq \pi}.
996 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
997 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
998 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1001 @item @emph{Example}:
1004 real(4) :: x = 1.e0_4, y = 0.5e0_4
1006 end program test_atan2
1009 @item @emph{Specific names}:
1010 @multitable @columnfractions .24 .24 .24 .24
1011 @item Name @tab Argument @tab Return type @tab Option
1012 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
1019 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1020 @findex @code{BESJ0} intrinsic
1021 @findex @code{DBESJ0} intrinsic
1025 @item @emph{Description}:
1026 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1029 @item @emph{Option}:
1035 @item @emph{Syntax}:
1038 @item @emph{Arguments}:
1039 @multitable @columnfractions .15 .80
1040 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1043 @item @emph{Return value}:
1044 The return value is of type @code{REAL(*)} and it lies in the
1045 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1047 @item @emph{Example}:
1050 real(8) :: x = 0.0_8
1052 end program test_besj0
1055 @item @emph{Specific names}:
1056 @multitable @columnfractions .24 .24 .24 .24
1057 @item Name @tab Argument @tab Return type @tab Option
1058 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1065 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1066 @findex @code{BESJ1} intrinsic
1067 @findex @code{DBESJ1} intrinsic
1071 @item @emph{Description}:
1072 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1075 @item @emph{Option}:
1081 @item @emph{Syntax}:
1084 @item @emph{Arguments}:
1085 @multitable @columnfractions .15 .80
1086 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1089 @item @emph{Return value}:
1090 The return value is of type @code{REAL(*)} and it lies in the
1091 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1093 @item @emph{Example}:
1096 real(8) :: x = 1.0_8
1098 end program test_besj1
1101 @item @emph{Specific names}:
1102 @multitable @columnfractions .24 .24 .24 .24
1103 @item Name @tab Argument @tab Return type @tab Option
1104 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1111 @section @code{BESJN} --- Bessel function of the first kind
1112 @findex @code{BESJN} intrinsic
1113 @findex @code{DBESJN} intrinsic
1117 @item @emph{Description}:
1118 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1121 @item @emph{Option}:
1127 @item @emph{Syntax}:
1128 @code{Y = BESJN(N, X)}
1130 @item @emph{Arguments}:
1131 @multitable @columnfractions .15 .80
1132 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1133 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1136 @item @emph{Return value}:
1137 The return value is a scalar of type @code{REAL(*)}.
1139 @item @emph{Example}:
1142 real(8) :: x = 1.0_8
1144 end program test_besjn
1147 @item @emph{Specific names}:
1148 @multitable @columnfractions .24 .24 .24 .24
1149 @item Name @tab Argument @tab Return type @tab Option
1150 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab gnu
1151 @item @tab @code{REAL(8) X} @tab @tab
1158 @section @code{BESY0} --- Bessel function of the second kind of order 0
1159 @findex @code{BESY0} intrinsic
1160 @findex @code{DBESY0} intrinsic
1164 @item @emph{Description}:
1165 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1168 @item @emph{Option}:
1174 @item @emph{Syntax}:
1177 @item @emph{Arguments}:
1178 @multitable @columnfractions .15 .80
1179 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1182 @item @emph{Return value}:
1183 The return value is a scalar of type @code{REAL(*)}.
1185 @item @emph{Example}:
1188 real(8) :: x = 0.0_8
1190 end program test_besy0
1193 @item @emph{Specific names}:
1194 @multitable @columnfractions .24 .24 .24 .24
1195 @item Name @tab Argument @tab Return type @tab Option
1196 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1203 @section @code{BESY1} --- Bessel function of the second kind of order 1
1204 @findex @code{BESY1} intrinsic
1205 @findex @code{DBESY1} intrinsic
1209 @item @emph{Description}:
1210 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1213 @item @emph{Option}:
1219 @item @emph{Syntax}:
1222 @item @emph{Arguments}:
1223 @multitable @columnfractions .15 .80
1224 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1227 @item @emph{Return value}:
1228 The return value is a scalar of type @code{REAL(*)}.
1230 @item @emph{Example}:
1233 real(8) :: x = 1.0_8
1235 end program test_besy1
1238 @item @emph{Specific names}:
1239 @multitable @columnfractions .24 .24 .24 .24
1240 @item Name @tab Argument @tab Return type @tab Option
1241 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
1248 @section @code{BESYN} --- Bessel function of the second kind
1249 @findex @code{BESYN} intrinsic
1250 @findex @code{DBESYN} intrinsic
1254 @item @emph{Description}:
1255 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1258 @item @emph{Option}:
1264 @item @emph{Syntax}:
1265 @code{Y = BESYN(N, X)}
1267 @item @emph{Arguments}:
1268 @multitable @columnfractions .15 .80
1269 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1270 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1273 @item @emph{Return value}:
1274 The return value is a scalar of type @code{REAL(*)}.
1276 @item @emph{Example}:
1279 real(8) :: x = 1.0_8
1281 end program test_besyn
1284 @item @emph{Specific names}:
1285 @multitable @columnfractions .24 .24 .24 .24
1286 @item Name @tab Argument @tab Return type @tab Option
1287 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab gnu
1288 @item @tab @code{REAL(8) X} @tab @tab
1295 @section @code{BIT_SIZE} --- Bit size inquiry function
1296 @findex @code{BIT_SIZE} intrinsic
1300 @item @emph{Description}:
1301 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1302 represented by the type of @var{I}.
1304 @item @emph{Option}:
1310 @item @emph{Syntax}:
1311 @code{I = BIT_SIZE(I)}
1313 @item @emph{Arguments}:
1314 @multitable @columnfractions .15 .80
1315 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1318 @item @emph{Return value}:
1319 The return value is of type @code{INTEGER(*)}
1321 @item @emph{Example}:
1323 program test_bit_size
1328 end program test_bit_size
1335 @section @code{BTEST} --- Bit test function
1336 @findex @code{BTEST} intrinsic
1340 @item @emph{Description}:
1341 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1344 @item @emph{Option}:
1350 @item @emph{Syntax}:
1351 @code{I = BTEST(I,POS)}
1353 @item @emph{Arguments}:
1354 @multitable @columnfractions .15 .80
1355 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1356 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1359 @item @emph{Return value}:
1360 The return value is of type @code{LOGICAL}
1362 @item @emph{Example}:
1365 integer :: i = 32768 + 1024 + 64
1369 bool = btest(i, pos)
1372 end program test_btest
1379 @section @code{CEILING} --- Integer ceiling function
1380 @findex @code{CEILING} intrinsic
1384 @item @emph{Description}:
1385 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1387 @item @emph{Option}:
1393 @item @emph{Syntax}:
1394 @code{I = CEILING(X[,KIND])}
1396 @item @emph{Arguments}:
1397 @multitable @columnfractions .15 .80
1398 @item @var{X} @tab The type shall be @code{REAL(*)}.
1399 @item @var{KIND} @tab Optional scaler integer initialization expression.
1402 @item @emph{Return value}:
1403 The return value is of type @code{INTEGER(KIND)}
1405 @item @emph{Example}:
1407 program test_ceiling
1410 print *, ceiling(x) ! returns 64
1411 print *, ceiling(y) ! returns -63
1412 end program test_ceiling
1419 @section @code{CHAR} --- Character conversion function
1420 @findex @code{CHAR} intrinsic
1424 @item @emph{Description}:
1425 @code{CHAR(I,[KIND])} returns the character represented by the integer @var{I}.
1427 @item @emph{Option}:
1433 @item @emph{Syntax}:
1434 @code{C = CHAR(I[,KIND])}
1436 @item @emph{Arguments}:
1437 @multitable @columnfractions .15 .80
1438 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1439 @item @var{KIND} @tab Optional scaler integer initialization expression.
1442 @item @emph{Return value}:
1443 The return value is of type @code{CHARACTER(1)}
1445 @item @emph{Example}:
1451 print *, i, c ! returns 'J'
1452 end program test_char
1459 @section @code{CMPLX} --- Complex conversion function
1460 @findex @code{CMPLX} intrinsic
1464 @item @emph{Description}:
1465 @code{CMPLX(X,[Y,KIND])} returns a complex number where @var{X} is converted to
1466 the real component. If @var{Y} is present it is converted to the imaginary
1467 component. If @var{Y} is not present then the imaginary component is set to
1468 0.0. If @var{X} is complex then @var{Y} must not be present.
1470 @item @emph{Option}:
1476 @item @emph{Syntax}:
1477 @code{C = CMPLX(X[,Y,KIND])}
1479 @item @emph{Arguments}:
1480 @multitable @columnfractions .15 .80
1481 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
1482 @item @var{Y} @tab Optional, allowed if @var{X} is not @code{COMPLEX(*)}. May be @code{INTEGER(*)} or @code{REAL(*)}.
1483 @item @var{KIND} @tab Optional scaler integer initialization expression.
1486 @item @emph{Return value}:
1487 The return value is of type @code{COMPLEX(*)}
1489 @item @emph{Example}:
1496 print *, z, cmplx(x)
1497 end program test_cmplx
1503 @node COMMAND_ARGUMENT_COUNT
1504 @section @code{COMMAND_ARGUMENT_COUNT} --- Argument count function
1505 @findex @code{COMMAND_ARGUMENT_COUNT} intrinsic
1506 @cindex command argument count
1509 @item @emph{Description}:
1510 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
1511 command line when the containing program was invoked.
1513 @item @emph{Option}:
1517 non-elemental function
1519 @item @emph{Syntax}:
1520 @code{I = COMMAND_ARGUMENT_COUNT()}
1522 @item @emph{Arguments}:
1523 @multitable @columnfractions .15 .80
1527 @item @emph{Return value}:
1528 The return value is of type @code{INTEGER(4)}
1530 @item @emph{Example}:
1532 program test_command_argument_count
1534 count = command_argument_count()
1536 end program test_command_argument_count
1543 @section @code{CONJG} --- Complex conjugate function
1544 @findex @code{CONJG} intrinsic
1545 @findex @code{DCONJG} intrinsic
1546 @cindex complex conjugate
1548 @item @emph{Description}:
1549 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
1550 then the result is @code{(x, -y)}
1552 @item @emph{Option}:
1558 @item @emph{Syntax}:
1561 @item @emph{Arguments}:
1562 @multitable @columnfractions .15 .80
1563 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
1566 @item @emph{Return value}:
1567 The return value is of type @code{COMPLEX(*)}.
1569 @item @emph{Example}:
1572 complex :: z = (2.0, 3.0)
1573 complex(8) :: dz = (2.71_8, -3.14_8)
1578 end program test_conjg
1581 @item @emph{Specific names}:
1582 @multitable @columnfractions .24 .24 .24 .24
1583 @item Name @tab Argument @tab Return type @tab Option
1584 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
1591 @section @code{COS} --- Cosine function
1592 @findex @code{COS} intrinsic
1593 @findex @code{DCOS} intrinsic
1594 @findex @code{ZCOS} intrinsic
1595 @findex @code{CDCOS} intrinsic
1599 @item @emph{Description}:
1600 @code{COS(X)} computes the cosine of @var{X}.
1602 @item @emph{Option}:
1608 @item @emph{Syntax}:
1611 @item @emph{Arguments}:
1612 @multitable @columnfractions .15 .80
1613 @item @var{X} @tab The type shall be @code{REAL(*)} or
1617 @item @emph{Return value}:
1618 The return value has the same type and kind as @var{X}.
1620 @item @emph{Example}:
1625 end program test_cos
1628 @item @emph{Specific names}:
1629 @multitable @columnfractions .24 .24 .24 .24
1630 @item Name @tab Argument @tab Return type @tab Option
1631 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
1632 @item @code{CCOS(X)}@tab @code{COMPLEX(4) X}@tab @code{COMPLEX(4)}@tab f95, gnu
1633 @item @code{ZCOS(X)}@tab @code{COMPLEX(8) X}@tab @code{COMPLEX(8)}@tab f95, gnu
1634 @item @code{CDCOS(X)}@tab @code{COMPLEX(8) X}@tab @code{COMPLEX(8)}@tab f95, gnu
1641 @section @code{COSH} --- Hyperbolic cosine function
1642 @findex @code{COSH} intrinsic
1643 @findex @code{DCOSH} intrinsic
1644 @cindex hyperbolic cosine
1647 @item @emph{Description}:
1648 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
1650 @item @emph{Option}:
1656 @item @emph{Syntax}:
1659 @item @emph{Arguments}:
1660 @multitable @columnfractions .15 .80
1661 @item @var{X} @tab The type shall be @code{REAL(*)}.
1664 @item @emph{Return value}:
1665 The return value is of type @code{REAL(*)} and it is positive
1666 (@math{ \cosh (x) \geq 0 }.
1668 @item @emph{Example}:
1671 real(8) :: x = 1.0_8
1673 end program test_cosh
1676 @item @emph{Specific names}:
1677 @multitable @columnfractions .24 .24 .24 .24
1678 @item Name @tab Argument @tab Return type @tab Option
1679 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
1686 @section @code{COUNT} --- Count function
1687 @findex @code{COUNT} intrinsic
1691 @item @emph{Description}:
1692 @code{COUNT(MASK[,DIM])} counts the number of @code{.TRUE.} elements of
1693 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
1694 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
1695 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
1697 @item @emph{Option}:
1701 transformational function
1703 @item @emph{Syntax}:
1704 @code{I = COUNT(MASK[,DIM])}
1706 @item @emph{Arguments}:
1707 @multitable @columnfractions .15 .80
1708 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
1709 @item @var{DIM} @tab The type shall be @code{INTEGER}.
1712 @item @emph{Return value}:
1713 The return value is of type @code{INTEGER} with rank equal to that of
1716 @item @emph{Example}:
1719 integer, dimension(2,3) :: a, b
1720 logical, dimension(2,3) :: mask
1721 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
1722 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
1723 print '(3i3)', a(1,:)
1724 print '(3i3)', a(2,:)
1726 print '(3i3)', b(1,:)
1727 print '(3i3)', b(2,:)
1730 print '(3l3)', mask(1,:)
1731 print '(3l3)', mask(2,:)
1733 print '(3i3)', count(mask)
1735 print '(3i3)', count(mask, 1)
1737 print '(3i3)', count(mask, 2)
1738 end program test_count
1745 @section @code{CPU_TIME} --- CPU elapsed time in seconds
1746 @findex @code{CPU_TIME} intrinsic
1750 @item @emph{Description}:
1751 Returns a @code{REAL} value representing the elapsed CPU time in seconds. This
1752 is useful for testing segments of code to determine execution time.
1754 @item @emph{Option}:
1760 @item @emph{Syntax}:
1763 @item @emph{Arguments}:
1764 @multitable @columnfractions .15 .80
1765 @item @var{X} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
1768 @item @emph{Return value}:
1771 @item @emph{Example}:
1773 program test_cpu_time
1774 real :: start, finish
1775 call cpu_time(start)
1776 ! put code to test here
1777 call cpu_time(finish)
1778 print '("Time = ",f6.3," seconds.")',finish-start
1779 end program test_cpu_time
1786 @section @code{CSHIFT} --- Circular shift function
1787 @findex @code{CSHIFT} intrinsic
1788 @cindex cshift intrinsic
1791 @item @emph{Description}:
1792 @code{CSHIFT(ARRAY, SHIFT[,DIM])} performs a circular shift on elements of
1793 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
1794 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
1795 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
1796 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
1797 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
1798 sections of @var{ARRAY} along the given dimension are shifted. Elements
1799 shifted out one end of each rank one section are shifted back in the other end.
1801 @item @emph{Option}:
1805 transformational function
1807 @item @emph{Syntax}:
1808 @code{A = CSHIFT(A, SHIFT[,DIM])}
1810 @item @emph{Arguments}:
1811 @multitable @columnfractions .15 .80
1812 @item @var{ARRAY} @tab May be any type, not scaler.
1813 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
1814 @item @var{DIM} @tab The type shall be @code{INTEGER}.
1817 @item @emph{Return value}:
1818 Returns an array of same type and rank as the @var{ARRAY} argument.
1820 @item @emph{Example}:
1823 integer, dimension(3,3) :: a
1824 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
1825 print '(3i3)', a(1,:)
1826 print '(3i3)', a(2,:)
1827 print '(3i3)', a(3,:)
1828 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
1830 print '(3i3)', a(1,:)
1831 print '(3i3)', a(2,:)
1832 print '(3i3)', a(3,:)
1833 end program test_cshift
1839 @section @code{CTIME} --- Convert a time into a string
1840 @findex @code{CTIME} intrinsic
1841 @cindex ctime subroutine
1844 @item @emph{Description}:
1845 @code{CTIME(T,S)} converts @var{T}, a system time value, such as returned
1846 by @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14
1847 1995}, and returns that string into @var{S}.
1849 If @code{CTIME} is invoked as a function, it can not be invoked as a
1850 subroutine, and vice versa.
1852 @var{T} is an @code{INTENT(IN)} @code{INTEGER(KIND=8)} variable.
1853 @var{S} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
1855 @item @emph{Option}:
1861 @item @emph{Syntax}:
1862 @multitable @columnfractions .80
1863 @item @code{CALL CTIME(T,S)}.
1864 @item @code{S = CTIME(T)}, (not recommended).
1867 @item @emph{Arguments}:
1868 @multitable @columnfractions .15 .80
1869 @item @var{S}@tab The type shall be of type @code{CHARACTER}.
1870 @item @var{T}@tab The type shall be of type @code{INTEGER(KIND=8)}.
1873 @item @emph{Return value}:
1874 The converted date and time as a string.
1876 @item @emph{Example}:
1880 character(len=30) :: date
1883 ! Do something, main part of the program
1886 print *, 'Program was started on ', date
1887 end program test_ctime
1892 @section @code{DATE_AND_TIME} --- Date and time subroutine
1893 @findex @code{DATE_AND_TIME} intrinsic
1894 @cindex DATE_AND_TIME
1897 @item @emph{Description}:
1898 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
1899 time information from the real-time system clock. @var{DATE} is
1900 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
1901 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
1902 representing the difference with respect to Coordinated Universal Time (UTC).
1903 Unavailable time and date parameters return blanks.
1905 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
1907 @multitable @columnfractions .15 .30 .60
1908 @item @tab @code{VALUE(1)}: @tab The year
1909 @item @tab @code{VALUE(2)}: @tab The month
1910 @item @tab @code{VALUE(3)}: @tab The day of the month
1911 @item @tab @code{VAlUE(4)}: @tab Time difference with UTC in minutes
1912 @item @tab @code{VALUE(5)}: @tab The hour of the day
1913 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
1914 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
1915 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
1918 @item @emph{Option}:
1924 @item @emph{Syntax}:
1925 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
1927 @item @emph{Arguments}:
1928 @multitable @columnfractions .15 .80
1929 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
1930 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
1931 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
1932 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
1935 @item @emph{Return value}:
1938 @item @emph{Example}:
1940 program test_time_and_date
1941 character(8) :: date
1942 character(10) :: time
1943 character(5) :: zone
1944 integer,dimension(8) :: values
1945 ! using keyword arguments
1946 call date_and_time(date,time,zone,values)
1947 call date_and_time(DATE=date,ZONE=zone)
1948 call date_and_time(TIME=time)
1949 call date_and_time(VALUES=values)
1950 print '(a,2x,a,2x,a)', date, time, zone
1951 print '(8i5))', values
1952 end program test_time_and_date
1959 @section @code{DBLE} --- Double conversion function
1960 @findex @code{DBLE} intrinsic
1961 @cindex double conversion
1964 @item @emph{Description}:
1965 @code{DBLE(X)} Converts @var{X} to double precision real type.
1966 @code{DFLOAT} is an alias for @code{DBLE}
1968 @item @emph{Option}:
1974 @item @emph{Syntax}:
1976 @code{X = DFLOAT(X)}
1978 @item @emph{Arguments}:
1979 @multitable @columnfractions .15 .80
1980 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
1983 @item @emph{Return value}:
1984 The return value is of type double precision real.
1986 @item @emph{Example}:
1991 complex :: z = (2.3,1.14)
1992 print *, dble(x), dble(i), dfloat(z)
1993 end program test_dble
2000 @section @code{DCMPLX} --- Double complex conversion function
2001 @findex @code{DCMPLX} intrinsic
2005 @item @emph{Description}:
2006 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2007 converted to the real component. If @var{Y} is present it is converted to the
2008 imaginary component. If @var{Y} is not present then the imaginary component is
2009 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2011 @item @emph{Option}:
2017 @item @emph{Syntax}:
2018 @code{C = DCMPLX(X)}
2019 @code{C = DCMPLX(X,Y)}
2021 @item @emph{Arguments}:
2022 @multitable @columnfractions .15 .80
2023 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
2024 @item @var{Y} @tab Optional if @var{X} is not @code{COMPLEX(*)}. May be @code{INTEGER(*)} or @code{REAL(*)}.
2027 @item @emph{Return value}:
2028 The return value is of type @code{COMPLEX(8)}
2030 @item @emph{Example}:
2040 print *, dcmplx(x,i)
2041 end program test_dcmplx
2048 @section @code{DFLOAT} --- Double conversion function
2049 @findex @code{DFLOAT} intrinsic
2050 @cindex double float conversion
2053 @item @emph{Description}:
2054 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2055 @code{DFLOAT} is an alias for @code{DBLE}. See @code{DBLE}.
2061 @section @code{DIGITS} --- Significant digits function
2062 @findex @code{DIGITS} intrinsic
2063 @cindex digits, significant
2066 @item @emph{Description}:
2067 @code{DIGITS(X)} returns the number of significant digits of the internal model
2068 representation of @var{X}. For example, on a system using a 32-bit
2069 floating point representation, a default real number would likely return 24.
2071 @item @emph{Option}:
2077 @item @emph{Syntax}:
2078 @code{C = DIGITS(X)}
2080 @item @emph{Arguments}:
2081 @multitable @columnfractions .15 .80
2082 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2085 @item @emph{Return value}:
2086 The return value is of type @code{INTEGER}.
2088 @item @emph{Example}:
2091 integer :: i = 12345
2097 end program test_digits
2104 @section @code{DIM} --- Dim function
2105 @findex @code{DIM} intrinsic
2106 @findex @code{IDIM} intrinsic
2107 @findex @code{DDIM} intrinsic
2111 @item @emph{Description}:
2112 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2113 otherwise returns zero.
2115 @item @emph{Option}:
2121 @item @emph{Syntax}:
2124 @item @emph{Arguments}:
2125 @multitable @columnfractions .15 .80
2126 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2127 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2130 @item @emph{Return value}:
2131 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2133 @item @emph{Example}:
2139 x = dim(4.345_8, 2.111_8)
2142 end program test_dim
2145 @item @emph{Specific names}:
2146 @multitable @columnfractions .24 .24 .24 .24
2147 @item Name @tab Argument @tab Return type @tab Option
2148 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab gnu
2149 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab gnu
2156 @section @code{DOT_PRODUCT} --- Dot product function
2157 @findex @code{DOT_PRODUCT} intrinsic
2161 @item @emph{Description}:
2162 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2163 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2164 and must be arrays of rank one and of equal size. If the vectors are
2165 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2166 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2167 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2169 @item @emph{Option}:
2173 transformational function
2175 @item @emph{Syntax}:
2176 @code{S = DOT_PRODUCT(X,Y)}
2178 @item @emph{Arguments}:
2179 @multitable @columnfractions .15 .80
2180 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2181 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2184 @item @emph{Return value}:
2185 If the arguments are numeric, the return value is a scaler of numeric type,
2186 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2187 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2189 @item @emph{Example}:
2191 program test_dot_prod
2192 integer, dimension(3) :: a, b
2199 print *, dot_product(a,b)
2200 end program test_dot_prod
2207 @section @code{DPROD} --- Double product function
2208 @findex @code{DPROD} intrinsic
2209 @cindex Double product
2212 @item @emph{Description}:
2213 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2215 @item @emph{Option}:
2221 @item @emph{Syntax}:
2222 @code{D = DPROD(X,Y)}
2224 @item @emph{Arguments}:
2225 @multitable @columnfractions .15 .80
2226 @item @var{X} @tab The type shall be @code{REAL}.
2227 @item @var{Y} @tab The type shall be @code{REAL}.
2230 @item @emph{Return value}:
2231 The return value is of type @code{REAL(8)}.
2233 @item @emph{Example}:
2242 end program test_dprod
2249 @section @code{DREAL} --- Double real part function
2250 @findex @code{DREAL} intrinsic
2251 @cindex Double real part
2254 @item @emph{Description}:
2255 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2257 @item @emph{Option}:
2263 @item @emph{Syntax}:
2266 @item @emph{Arguments}:
2267 @multitable @columnfractions .15 .80
2268 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2271 @item @emph{Return value}:
2272 The return value is of type @code{REAL(8)}.
2274 @item @emph{Example}:
2277 complex(8) :: z = (1.3_8,7.2_8)
2279 end program test_dreal
2286 @section @code{DTIME} --- Execution time subroutine (or function)
2287 @findex @code{DTIME} intrinsic
2288 @cindex dtime subroutine
2291 @item @emph{Description}:
2292 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2293 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2294 returns the user and system components of this time in @code{TARRAY(1)} and
2295 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2298 Subsequent invocations of @code{DTIME} return values accumulated since the
2299 previous invocation.
2301 On some systems, the underlying timings are represented using types with
2302 sufficiently small limits that overflows (wraparounds) are possible, such as
2303 32-bit types. Therefore, the values returned by this intrinsic might be, or
2304 become, negative, or numerically less than previous values, during a single
2305 run of the compiled program.
2307 If @code{DTIME} is invoked as a function, it can not be invoked as a
2308 subroutine, and vice versa.
2310 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2312 @multitable @columnfractions .15 .30 .60
2313 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2314 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2315 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2318 @item @emph{Option}:
2324 @item @emph{Syntax}:
2325 @multitable @columnfractions .80
2326 @item @code{CALL DTIME(TARRAY, RESULT)}.
2327 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
2330 @item @emph{Arguments}:
2331 @multitable @columnfractions .15 .80
2332 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2333 @item @var{RESULT}@tab The type shall be @code{REAL}.
2336 @item @emph{Return value}:
2337 Elapsed time in seconds since the start of program execution.
2339 @item @emph{Example}:
2343 real, dimension(2) :: tarray
2345 call dtime(tarray, result)
2349 do i=1,100000000 ! Just a delay
2352 call dtime(tarray, result)
2356 end program test_dtime
2363 @section @code{EOSHIFT} --- End-off shift function
2364 @findex @code{EOSHIFT} intrinsic
2365 @cindex eoshift intrinsic
2368 @item @emph{Description}:
2369 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
2370 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
2371 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2372 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
2373 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
2374 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
2375 then all complete rank one sections of @var{ARRAY} along the given dimension are
2376 shifted. Elements shifted out one end of each rank one section are dropped. If
2377 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
2378 is copied back in the other end. If @var{BOUNDARY} is not present then the
2379 following are copied in depending on the type of @var{ARRAY}.
2381 @multitable @columnfractions .15 .80
2382 @item @emph{Array Type} @tab @emph{Boundary Value}
2383 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
2384 @item Logical @tab @code{.FALSE.}.
2385 @item Character(@var{len}) @tab @var{len} blanks.
2388 @item @emph{Option}:
2392 transformational function
2394 @item @emph{Syntax}:
2395 @code{A = EOSHIFT(A, SHIFT[,BOUNDARY, DIM])}
2397 @item @emph{Arguments}:
2398 @multitable @columnfractions .15 .80
2399 @item @var{ARRAY} @tab May be any type, not scaler.
2400 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2401 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
2402 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2405 @item @emph{Return value}:
2406 Returns an array of same type and rank as the @var{ARRAY} argument.
2408 @item @emph{Example}:
2410 program test_eoshift
2411 integer, dimension(3,3) :: a
2412 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2413 print '(3i3)', a(1,:)
2414 print '(3i3)', a(2,:)
2415 print '(3i3)', a(3,:)
2416 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
2418 print '(3i3)', a(1,:)
2419 print '(3i3)', a(2,:)
2420 print '(3i3)', a(3,:)
2421 end program test_eoshift
2428 @section @code{EPSILON} --- Epsilon function
2429 @findex @code{EPSILON} intrinsic
2430 @cindex epsilon, significant
2433 @item @emph{Description}:
2434 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
2436 @item @emph{Option}:
2442 @item @emph{Syntax}:
2443 @code{C = EPSILON(X)}
2445 @item @emph{Arguments}:
2446 @multitable @columnfractions .15 .80
2447 @item @var{X} @tab The type shall be @code{REAL(*)}.
2450 @item @emph{Return value}:
2451 The return value is of same type as the argument.
2453 @item @emph{Example}:
2455 program test_epsilon
2460 end program test_epsilon
2467 @section @code{ERF} --- Error function
2468 @findex @code{ERF} intrinsic
2469 @cindex error function
2472 @item @emph{Description}:
2473 @code{ERF(X)} computes the error function of @var{X}.
2475 @item @emph{Option}:
2481 @item @emph{Syntax}:
2484 @item @emph{Arguments}:
2485 @multitable @columnfractions .15 .80
2486 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
2489 @item @emph{Return value}:
2490 The return value is a scalar of type @code{REAL(*)} and it is positive
2491 (@math{ - 1 \leq erf (x) \leq 1 }.
2493 @item @emph{Example}:
2496 real(8) :: x = 0.17_8
2498 end program test_erf
2501 @item @emph{Specific names}:
2502 @multitable @columnfractions .24 .24 .24 .24
2503 @item Name @tab Argument @tab Return type @tab Option
2504 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
2511 @section @code{ERFC} --- Error function
2512 @findex @code{ERFC} intrinsic
2513 @cindex error function
2516 @item @emph{Description}:
2517 @code{ERFC(X)} computes the complementary error function of @var{X}.
2519 @item @emph{Option}:
2525 @item @emph{Syntax}:
2528 @item @emph{Arguments}:
2529 @multitable @columnfractions .15 .80
2530 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
2533 @item @emph{Return value}:
2534 The return value is a scalar of type @code{REAL(*)} and it is positive
2535 (@math{ 0 \leq erfc (x) \leq 2 }.
2537 @item @emph{Example}:
2540 real(8) :: x = 0.17_8
2542 end program test_erfc
2545 @item @emph{Specific names}:
2546 @multitable @columnfractions .24 .24 .24 .24
2547 @item Name @tab Argument @tab Return type @tab Option
2548 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab gnu
2555 @section @code{ETIME} --- Execution time subroutine (or function)
2556 @findex @code{ETIME} intrinsic
2557 @cindex ETIME subroutine
2560 @item @emph{Description}:
2561 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
2562 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2563 returns the user and system components of this time in @code{TARRAY(1)} and
2564 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
2566 On some systems, the underlying timings are represented using types with
2567 sufficiently small limits that overflows (wraparounds) are possible, such as
2568 32-bit types. Therefore, the values returned by this intrinsic might be, or
2569 become, negative, or numerically less than previous values, during a single
2570 run of the compiled program.
2572 If @code{ETIME} is invoked as a function, it can not be invoked as a
2573 subroutine, and vice versa.
2575 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2577 @multitable @columnfractions .15 .30 .60
2578 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2579 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2580 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2583 @item @emph{Option}:
2589 @item @emph{Syntax}:
2590 @multitable @columnfractions .8
2591 @item @code{CALL ETIME(TARRAY, RESULT)}.
2592 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
2595 @item @emph{Arguments}:
2596 @multitable @columnfractions .15 .80
2597 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2598 @item @var{RESULT}@tab The type shall be @code{REAL}.
2601 @item @emph{Return value}:
2602 Elapsed time in seconds since the start of program execution.
2604 @item @emph{Example}:
2608 real, dimension(2) :: tarray
2610 call ETIME(tarray, result)
2614 do i=1,100000000 ! Just a delay
2617 call ETIME(tarray, result)
2621 end program test_etime
2628 @section @code{EXIT} --- Exit the program with status.
2633 @item @emph{Description}:
2634 @code{EXIT} causes immediate termination of the program with status. If status
2635 is omitted it returns the canonical @emph{success} for the system. All Fortran
2636 I/O units are closed.
2638 @item @emph{Option}:
2642 non-elemental subroutine
2644 @item @emph{Syntax}:
2645 @code{CALL EXIT([STATUS])}
2647 @item @emph{Arguments}:
2648 @multitable @columnfractions .15 .80
2649 @item @var{STATUS} @tab The type of the argument shall be @code{INTEGER(*)}.
2652 @item @emph{Return value}:
2653 @code{STATUS} is passed to the parent process on exit.
2655 @item @emph{Example}:
2658 integer :: STATUS = 0
2659 print *, 'This program is going to exit.'
2661 end program test_exit
2668 @section @code{EXP} --- Exponential function
2669 @findex @code{EXP} intrinsic
2670 @findex @code{DEXP} intrinsic
2671 @findex @code{ZEXP} intrinsic
2672 @findex @code{CDEXP} intrinsic
2676 @item @emph{Description}:
2677 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
2679 @item @emph{Option}:
2685 @item @emph{Syntax}:
2688 @item @emph{Arguments}:
2689 @multitable @columnfractions .15 .80
2690 @item @var{X} @tab The type shall be @code{REAL(*)} or
2694 @item @emph{Return value}:
2695 The return value has same type and kind as @var{X}.
2697 @item @emph{Example}:
2702 end program test_exp
2705 @item @emph{Specific names}:
2706 @multitable @columnfractions .24 .24 .24 .24
2707 @item Name @tab Argument @tab Return type @tab Option
2708 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
2709 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
2710 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2711 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
2718 @section @code{EXPONENT} --- Exponent function
2719 @findex @code{EXPONENT} intrinsic
2720 @cindex exponent function
2723 @item @emph{Description}:
2724 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
2725 is zero the value returned is zero.
2727 @item @emph{Option}:
2733 @item @emph{Syntax}:
2734 @code{I = EXPONENT(X)}
2736 @item @emph{Arguments}:
2737 @multitable @columnfractions .15 .80
2738 @item @var{X} @tab The type shall be @code{REAL(*)}.
2741 @item @emph{Return value}:
2742 The return value is of type default @code{INTEGER}.
2744 @item @emph{Example}:
2746 program test_exponent
2751 print *, exponent(0.0)
2752 end program test_exponent
2758 @section @code{FREE} --- Frees memory
2759 @findex @code{FREE} intrinsic
2763 @item @emph{Description}:
2764 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
2765 intrinsic is an extension intended to be used with Cray pointers, and is
2766 provided in @command{gfortran} to allow user to compile legacy code. For
2767 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
2770 @item @emph{Option}:
2776 @item @emph{Syntax}:
2779 @item @emph{Arguments}:
2780 @multitable @columnfractions .15 .80
2781 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
2782 location of the memory that should be de-allocated.
2785 @item @emph{Return value}:
2788 @item @emph{Example}:
2789 See @code{MALLOC} for an example.
2794 @section @code{FDATE} --- Get the current time as a string
2795 @findex @code{FDATE} intrinsic
2796 @cindex fdate subroutine
2799 @item @emph{Description}:
2800 @code{FDATE(DATE)} returns the current date (using the same format as
2801 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
2804 If @code{FDATE} is invoked as a function, it can not be invoked as a
2805 subroutine, and vice versa.
2807 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
2809 @item @emph{Option}:
2815 @item @emph{Syntax}:
2816 @multitable @columnfractions .80
2817 @item @code{CALL FDATE(DATE)}.
2818 @item @code{DATE = FDATE()}, (not recommended).
2821 @item @emph{Arguments}:
2822 @multitable @columnfractions .15 .80
2823 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
2826 @item @emph{Return value}:
2827 The current date and time as a string.
2829 @item @emph{Example}:
2833 character(len=30) :: date
2835 print *, 'Program started on ', date
2836 do i = 1, 100000000 ! Just a delay
2840 print *, 'Program ended on ', date
2841 end program test_fdate
2847 @section @code{FLOOR} --- Integer floor function
2848 @findex @code{FLOOR} intrinsic
2852 @item @emph{Description}:
2853 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
2855 @item @emph{Option}:
2861 @item @emph{Syntax}:
2862 @code{I = FLOOR(X[,KIND])}
2864 @item @emph{Arguments}:
2865 @multitable @columnfractions .15 .80
2866 @item @var{X} @tab The type shall be @code{REAL(*)}.
2867 @item @var{KIND} @tab Optional scaler integer initialization expression.
2870 @item @emph{Return value}:
2871 The return value is of type @code{INTEGER(KIND)}
2873 @item @emph{Example}:
2878 print *, floor(x) ! returns 63
2879 print *, floor(y) ! returns -64
2880 end program test_floor
2887 @section @code{FNUM} --- File number function
2888 @findex @code{FNUM} intrinsic
2892 @item @emph{Description}:
2893 @code{FNUM(UNIT)} returns the Posix file descriptor number corresponding to the
2894 open Fortran I/O unit @code{UNIT}.
2896 @item @emph{Option}:
2900 non-elemental function
2902 @item @emph{Syntax}:
2903 @code{I = FNUM(UNIT)}
2905 @item @emph{Arguments}:
2906 @multitable @columnfractions .15 .80
2907 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
2910 @item @emph{Return value}:
2911 The return value is of type @code{INTEGER}
2913 @item @emph{Example}:
2917 open (unit=10, status = "scratch")
2921 end program test_fnum
2926 @section @code{LOC} --- Returns the address of a variable
2927 @findex @code{LOC} intrinsic
2931 @item @emph{Description}:
2932 @code{LOC(X)} returns the address of @var{X} as an integer.
2934 @item @emph{Option}:
2940 @item @emph{Syntax}:
2943 @item @emph{Arguments}:
2944 @multitable @columnfractions .15 .80
2945 @item @var{X} @tab Variable of any type.
2948 @item @emph{Return value}:
2949 The return value is of type @code{INTEGER(n)}, where @code{n} is the
2950 size (in bytes) of a memory address on the target machine.
2952 @item @emph{Example}:
2959 end program test_loc
2964 @section @code{LOG} --- Logarithm function
2965 @findex @code{LOG} intrinsic
2966 @findex @code{ALOG} intrinsic
2967 @findex @code{DLOG} intrinsic
2968 @findex @code{CLOG} intrinsic
2969 @findex @code{ZLOG} intrinsic
2970 @findex @code{CDLOG} intrinsic
2974 @item @emph{Description}:
2975 @code{LOG(X)} computes the logarithm of @var{X}.
2977 @item @emph{Option}:
2983 @item @emph{Syntax}:
2986 @item @emph{Arguments}:
2987 @multitable @columnfractions .15 .80
2988 @item @var{X} @tab The type shall be @code{REAL(*)} or
2992 @item @emph{Return value}:
2993 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
2994 The kind type parameter is the same as @var{X}.
2996 @item @emph{Example}:
2999 real(8) :: x = 1.0_8
3000 complex :: z = (1.0, 2.0)
3003 end program test_log
3006 @item @emph{Specific names}:
3007 @multitable @columnfractions .24 .24 .24 .24
3008 @item Name @tab Argument @tab Return type @tab Option
3009 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
3010 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3011 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
3012 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3013 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3020 @section @code{LOG10} --- Base 10 logarithm function
3021 @findex @code{LOG10} intrinsic
3022 @findex @code{ALOG10} intrinsic
3023 @findex @code{DLOG10} intrinsic
3027 @item @emph{Description}:
3028 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
3030 @item @emph{Option}:
3036 @item @emph{Syntax}:
3039 @item @emph{Arguments}:
3040 @multitable @columnfractions .15 .80
3041 @item @var{X} @tab The type shall be @code{REAL(*)} or
3045 @item @emph{Return value}:
3046 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
3047 The kind type parameter is the same as @var{X}.
3049 @item @emph{Example}:
3052 real(8) :: x = 10.0_8
3054 end program test_log10
3057 @item @emph{Specific names}:
3058 @multitable @columnfractions .24 .24 .24 .24
3059 @item Name @tab Argument @tab Return type @tab Option
3060 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
3061 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3067 @section @code{MALLOC} --- Allocate dynamic memory
3068 @findex @code{MALLOC} intrinsic
3072 @item @emph{Description}:
3073 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
3074 returns the address of the allocated memory. The @code{MALLOC} intrinsic
3075 is an extension intended to be used with Cray pointers, and is provided
3076 in @command{gfortran} to allow user to compile legacy code. For new code
3077 using Fortran 95 pointers, the memory allocation intrinsic is
3080 @item @emph{Option}:
3084 non-elemental function
3086 @item @emph{Syntax}:
3087 @code{PTR = MALLOC(SIZE)}
3089 @item @emph{Arguments}:
3090 @multitable @columnfractions .15 .80
3091 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
3094 @item @emph{Return value}:
3095 The return value is of type @code{INTEGER(K)}, with @var{K} such that
3096 variables of type @code{INTEGER(K)} have the same size as
3097 C pointers (@code{sizeof(void *)}).
3099 @item @emph{Example}:
3100 The following example demonstrates the use of @code{MALLOC} and
3101 @code{FREE} with Cray pointers. This example is intended to run on
3102 32-bit systems, where the default integer kind is suitable to store
3103 pointers; on 64-bit systems, ptr_x would need to be declared as
3104 @code{integer(kind=8)}.
3113 ptr_x = malloc(20*8)
3115 x(i) = sqrt(1.0d0 / i)
3123 end program test_malloc
3129 @section @code{REAL} --- Convert to real type
3130 @findex @code{REAL} intrinsic
3131 @findex @code{REALPART} intrinsic
3135 @item @emph{Description}:
3136 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
3137 @code{REALPART(X)} function is provided for compatibility with @command{g77},
3138 and its use is strongly discouraged.
3140 @item @emph{Option}:
3144 transformational function
3146 @item @emph{Syntax}:
3147 @multitable @columnfractions .30 .80
3148 @item @code{X = REAL(X)}
3149 @item @code{X = REAL(X, KIND)}
3150 @item @code{X = REALPART(Z)}
3153 @item @emph{Arguments}:
3154 @multitable @columnfractions .15 .80
3155 @item @var{X} @tab shall be @code{INTEGER(*)}, @code{REAL(*)}, or
3157 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer.
3160 @item @emph{Return value}:
3161 These functions return the a @code{REAL(*)} variable or array under
3162 the following rules:
3166 @code{REAL(X)} is converted to a default real type if @var{X} is an
3167 integer or real variable.
3169 @code{REAL(X)} is converted to a real type with the kind type parameter
3170 of @var{X} if @var{X} is a complex variable.
3172 @code{REAL(X, KIND)} is converted to a real type with kind type
3173 parameter @var{KIND} if @var{X} is a complex, integer, or real
3177 @item @emph{Example}:
3180 complex :: x = (1.0, 2.0)
3181 print *, real(x), real(x,8), realpart(x)
3182 end program test_real
3189 @section @code{SIGNAL} --- Signal handling subroutine (or function)
3190 @findex @code{SIGNAL} intrinsic
3191 @cindex SIGNAL subroutine
3194 @item @emph{Description}:
3195 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
3196 @var{HANDLER} to be executed with a single integer argument when signal
3197 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
3198 turn off handling of signal @var{NUMBER} or revert to its default
3199 action. See @code{signal(2)}.
3201 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
3202 is supplied, it is set to the value returned by @code{signal(2)}.
3204 @item @emph{Option}:
3208 subroutine, non-elemental function
3210 @item @emph{Syntax}:
3211 @multitable @columnfractions .30 .80
3212 @item @code{CALL ALARM(NUMBER, HANDLER)}
3213 @item @code{CALL ALARM(NUMBER, HANDLER, STATUS)}
3214 @item @code{STATUS = ALARM(NUMBER, HANDLER)}
3217 @item @emph{Arguments}:
3218 @multitable @columnfractions .15 .80
3219 @item @var{NUMBER} @tab shall be a scalar integer, with @code{INTENT(IN)}
3220 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
3221 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
3222 @code{INTEGER}. It is @code{INTENT(IN)}.
3223 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
3224 integer. It has @code{INTENT(OUT)}.
3227 @item @emph{Return value}:
3228 The @code{SIGNAL} functions returns the value returned by @code{signal(2)}.
3230 @item @emph{Example}:
3234 external handler_print
3236 call signal (12, handler_print)
3240 end program test_signal
3248 @section @code{SECNDS} --- Time subroutine
3249 @findex @code{SECNDS} intrinsic
3253 @item @emph{Description}:
3254 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
3255 @var{X} is a reference time, also in seconds. If this is zero, the time in
3256 seconds from midnight is returned. This function is non-standard and its
3259 @item @emph{Option}:
3265 @item @emph{Syntax}:
3266 @code{T = SECNDS (X)}
3268 @item @emph{Arguments}:
3269 @multitable @columnfractions .15 .80
3270 @item Name @tab Type
3271 @item @var{T} @tab REAL(4)
3272 @item @var{X} @tab REAL(4)
3275 @item @emph{Return value}:
3278 @item @emph{Example}:
3282 print *, secnds (0.0) ! seconds since midnight
3283 t1 = secnds (0.0) ! reference time
3284 do i = 1, 10000000 ! do something
3286 t2 = secnds (t1) ! elapsed time
3287 print *, "Something took ", t2, " seconds."
3288 end program test_secnds
3295 @section @code{SIN} --- Sine function
3296 @findex @code{SIN} intrinsic
3297 @findex @code{DSIN} intrinsic
3298 @findex @code{ZSIN} intrinsic
3299 @findex @code{CDSIN} intrinsic
3303 @item @emph{Description}:
3304 @code{SIN(X)} computes the sine of @var{X}.
3306 @item @emph{Option}:
3312 @item @emph{Syntax}:
3315 @item @emph{Arguments}:
3316 @multitable @columnfractions .15 .80
3317 @item @var{X} @tab The type shall be @code{REAL(*)} or
3321 @item @emph{Return value}:
3322 The return value has same type and king than @var{X}.
3324 @item @emph{Example}:
3329 end program test_sin
3332 @item @emph{Specific names}:
3333 @multitable @columnfractions .24 .24 .24 .24
3334 @item Name @tab Argument @tab Return type @tab Option
3335 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3336 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
3337 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3338 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3345 @section @code{SINH} --- Hyperbolic sine function
3346 @findex @code{SINH} intrinsic
3347 @findex @code{DSINH} intrinsic
3348 @cindex hyperbolic sine
3351 @item @emph{Description}:
3352 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
3354 @item @emph{Option}:
3360 @item @emph{Syntax}:
3363 @item @emph{Arguments}:
3364 @multitable @columnfractions .15 .80
3365 @item @var{X} @tab The type shall be @code{REAL(*)}.
3368 @item @emph{Return value}:
3369 The return value is of type @code{REAL(*)}.
3371 @item @emph{Example}:
3374 real(8) :: x = - 1.0_8
3376 end program test_sinh
3379 @item @emph{Specific names}:
3380 @multitable @columnfractions .24 .24 .24 .24
3381 @item Name @tab Argument @tab Return type @tab Option
3382 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3389 @section @code{SQRT} --- Square-root function
3390 @findex @code{SQRT} intrinsic
3391 @findex @code{DSQRT} intrinsic
3392 @findex @code{CSQRT} intrinsic
3393 @findex @code{ZSQRT} intrinsic
3394 @findex @code{CDSQRT} intrinsic
3398 @item @emph{Description}:
3399 @code{SQRT(X)} computes the square root of @var{X}.
3401 @item @emph{Option}:
3407 @item @emph{Syntax}:
3410 @item @emph{Arguments}:
3411 @multitable @columnfractions .15 .80
3412 @item @var{X} @tab The type shall be @code{REAL(*)} or
3416 @item @emph{Return value}:
3417 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
3418 The kind type parameter is the same as @var{X}.
3420 @item @emph{Example}:
3423 real(8) :: x = 2.0_8
3424 complex :: z = (1.0, 2.0)
3427 end program test_sqrt
3430 @item @emph{Specific names}:
3431 @multitable @columnfractions .24 .24 .24 .24
3432 @item Name @tab Argument @tab Return type @tab Option
3433 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3434 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
3435 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3436 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
3443 @section @code{TAN} --- Tangent function
3444 @findex @code{TAN} intrinsic
3445 @findex @code{DTAN} intrinsic
3449 @item @emph{Description}:
3450 @code{TAN(X)} computes the tangent of @var{X}.
3452 @item @emph{Option}:
3458 @item @emph{Syntax}:
3461 @item @emph{Arguments}:
3462 @multitable @columnfractions .15 .80
3463 @item @var{X} @tab The type shall be @code{REAL(*)}.
3466 @item @emph{Return value}:
3467 The return value is of type @code{REAL(*)}. The kind type parameter is
3468 the same as @var{X}.
3470 @item @emph{Example}:
3473 real(8) :: x = 0.165_8
3475 end program test_tan
3478 @item @emph{Specific names}:
3479 @multitable @columnfractions .24 .24 .24 .24
3480 @item Name @tab Argument @tab Return type @tab Option
3481 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3488 @section @code{TANH} --- Hyperbolic tangent function
3489 @findex @code{TANH} intrinsic
3490 @findex @code{DTANH} intrinsic
3491 @cindex hyperbolic tangent
3494 @item @emph{Description}:
3495 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
3497 @item @emph{Option}:
3503 @item @emph{Syntax}:
3506 @item @emph{Arguments}:
3507 @multitable @columnfractions .15 .80
3508 @item @var{X} @tab The type shall be @code{REAL(*)}.
3511 @item @emph{Return value}:
3512 The return value is of type @code{REAL(*)} and lies in the range
3513 @math{ - 1 \leq tanh(x) \leq 1 }.
3515 @item @emph{Example}:
3518 real(8) :: x = 2.1_8
3520 end program test_tanh
3523 @item @emph{Specific names}:
3524 @multitable @columnfractions .24 .24 .24 .24
3525 @item Name @tab Argument @tab Return type @tab Option
3526 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
3534 @comment gen fraction
3552 @comment sub get_command
3554 @comment sub get_command_argument
3556 @comment sub get_environment_variable
3596 @comment gen len_trim
3606 @comment gen logical
3617 @comment gen maxexponent
3632 @comment gen minexponent
3646 @comment gen nearest
3657 @comment gen precision
3659 @comment gen present
3661 @comment gen product
3668 @comment sub random_number
3670 @comment sub random_seed
3680 @comment gen reshape
3682 @comment gen rrspacing
3691 @comment gen selected_int_kind
3693 @comment gen selected_real_kind
3695 @comment gen set_exponent
3705 @comment gen spacing
3719 @comment sub system_clock
3723 @comment gen transfer
3725 @comment gen transpose