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, Arccosine function
40 * @code{ADJUSTL}: ADJUSTL, Left adjust a string
41 * @code{ADJUSTR}: ADJUSTR, Right adjust a string
45 @section Introduction to intrinsic procedures
47 Gfortran provides a rich set of intrinsic procedures that includes all
48 the intrinsic procedures required by the Fortran 95 standard, a set of
49 intrinsic procedures for backwards compatibility with Gnu Fortran 77
50 (i.e., @command{g77}), and a small selection of intrinsic procedures
51 from the Fortran 2003 standard. Any description here, which conflicts with a
52 description in either the Fortran 95 standard or the Fortran 2003 standard,
53 is unintentional and the standard(s) should be considered authoritative.
55 The enumeration of the @code{KIND} type parameter is processor defined in
56 the Fortran 95 standard. Gfortran defines the default integer type and
57 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
58 respectively. The standard mandates that both data types shall have
59 another kind, which have more precision. On typical target architectures
60 supports by @command{gfortran}, this kind type parameter is @code{KIND=8}.
61 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
62 In the description of generic intrinsic procedures, the kind type parameter
63 will be specified by @code{KIND=*}, and in the description of specific
64 names for an intrinsic procedure the kind type parameter will be explicitly
65 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
66 brevity the optional @code{KIND=} syntax will be omitted.
68 Many of the intrinsics procedures take one or more optional arguments.
69 This document follows the convention used in the Fortran 95 standard,
70 and denotes such arguments by square brackets.
72 @command{Gfortran} offers the @option{-std=f95} and @option{-std=gnu} options,
73 which can be used to restrict the set of intrinsic procedures to a
74 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
75 option, and so all intrinsic procedures describe here are accepted. There
76 is one caveat. For a select group of intrinsic procedures, @command{g77}
77 implemented both a function and a subroutine. Both classes
78 have been implemented in @command{gfortran} for backwards compatibility
79 with @command{g77}. It is noted here that these functions and subroutines
80 cannot be intermixed in a given subprogram. In the descriptions that follow,
81 the applicable option(s) is noted.
86 @section @code{ABORT} --- Abort the program
91 @item @emph{Description}:
92 @code{ABORT} causes immediate termination of the program. On operating
93 systems that support a core dump, @code{ABORT} will produce a core dump,
94 which is suitable for debugging purposes.
100 non-elemental subroutine
105 @item @emph{Return value}:
108 @item @emph{Example}:
111 integer :: i = 1, j = 2
112 if (i /= j) call abort
113 end program test_abort
120 @section @code{ABS} --- Absolute value
121 @findex @code{ABS} intrinsic
122 @findex @code{CABS} intrinsic
123 @findex @code{DABS} intrinsic
124 @findex @code{IABS} intrinsic
125 @findex @code{ZABS} intrinsic
126 @findex @code{CDABS} intrinsic
127 @cindex absolute value
130 @item @emph{Description}:
131 @code{ABS(X)} computes the absolute value of @code{X}.
142 @item @emph{Arguments}:
143 @multitable @columnfractions .15 .80
144 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
145 @code{REAL(*)}, or @code{COMPLEX(*)}.
148 @item @emph{Return value}:
149 The return value is of the same type and
150 kind as the argument except the return value is @code{REAL(*)} for a
151 @code{COMPLEX(*)} argument.
153 @item @emph{Example}:
158 complex :: z = (-1.e0,0.e0)
162 end program test_abort
165 @item @emph{Specific names}:
166 @multitable @columnfractions .24 .24 .24 .24
167 @item Name @tab Argument @tab Return type @tab Option
168 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab f95, gnu
169 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
170 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab f95, gnu
171 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
172 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu
179 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
180 @findex @code{ACHAR} intrinsic
181 @cindex @acronym{ASCII} collating sequence
184 @item @emph{Description}:
185 @code{ACHAR(I)} returns the character located at position @code{I}
186 in the @acronym{ASCII} collating sequence.
197 @item @emph{Arguments}:
198 @multitable @columnfractions .15 .80
199 @item @var{I} @tab The type shall be an @code{INTEGER(*)}.
202 @item @emph{Return value}:
203 The return value is of type @code{CHARACTER} with a length of one. The
204 kind type parameter is the same as @code{KIND('A')}.
206 @item @emph{Example}:
211 end program test_abort
218 @section @code{ACOS} --- Arccosine function
219 @findex @code{ACOS} intrinsic
220 @findex @code{DACOS} intrinsic
224 @item @emph{Description}:
225 @code{ACOS(X)} computes the arccosine of its @var{X}.
236 @item @emph{Arguments}:
237 @multitable @columnfractions .15 .80
238 @item @var{X} @tab The type shall be an @code{REAL(*)}.
241 @item @emph{Return value}:
242 The return value is of type @code{REAL(*)} and it lies in the
243 range @math{ 0 \leq \arccos (x) \leq \pi}.
245 @item @emph{Example}:
248 real(8) :: x = 0.866_8
250 end program test_acos
253 @item @emph{Specific names}:
254 @multitable @columnfractions .24 .24 .24 .24
255 @item Name @tab Argument @tab Return type @tab Option
256 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
263 @section @code{ADJUSTL} --- Left adjust a string
264 @findex @code{ADJUSTL} intrinsic
265 @cindex adjust string
268 @item @emph{Description}:
269 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
270 Spaces are inserted at the end of the string as needed.
279 @code{STR = ADJUSTL(STR)}
281 @item @emph{Arguments}:
282 @multitable @columnfractions .15 .80
283 @item @var{STR} @tab The type shall be @code{CHARACTER}.
286 @item @emph{Return value}:
287 The return value is of type @code{CHARACTER} where leading spaces
288 are removed and the same number of spaces are inserted on the end
291 @item @emph{Example}:
294 character(len=20) :: str = ' gfortran'
297 end program test_adjustl
303 @section @code{ADJUSTR} --- Right adjust a string
304 @findex @code{ADJUSTR} intrinsic
305 @cindex adjust string
308 @item @emph{Description}:
309 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
310 Spaces are inserted at the start of the string as needed.
319 @code{STR = ADJUSTR(STR)}
321 @item @emph{Arguments}:
322 @multitable @columnfractions .15 .80
323 @item @var{STR} @tab The type shall be @code{CHARACTER}.
326 @item @emph{Return value}:
327 The return value is of type @code{CHARACTER} where trailing spaces
328 are removed and the same number of spaces are inserted at the start
331 @item @emph{Example}:
334 character(len=20) :: str = 'gfortran'
337 end program test_adjustr
351 @comment gen allocated
361 @comment gen associated
387 @comment gen bit_size
397 @comment gen command_argument_count
412 @comment sub cpu_time
416 @comment sub date_and_time
429 @comment gen dot_product
457 @comment gen exponent
465 @comment gen fraction
483 @comment sub get_command
485 @comment sub get_command_argument
487 @comment sub get_environment_variable
527 @comment gen len_trim
558 @comment gen maxexponent
573 @comment gen minexponent
598 @comment gen precision
609 @comment sub random_number
611 @comment sub random_seed
623 @comment gen rrspacing
632 @comment gen selected_int_kind
634 @comment gen selected_real_kind
636 @comment gen set_exponent
661 @comment zsqrt,cdsqrt
673 @comment sub system_clock
683 @comment gen transfer
685 @comment gen transpose