📄 intrinsic.texi
字号:
@ignoreCopyright (C) 2005Free Software Foundation, Inc.This is part of the GFORTRAN manual. For copying conditions, see the file gfortran.texi.Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.2 orany later version published by the Free Software Foundation; with theInvariant Sections being ``GNU General Public License'' and ``FundingFree Software'', the Front-Cover texts being (a) (see below), and withthe Back-Cover Texts being (b) (see below). A copy of the license isincluded in the gfdl(7) man page.Some basic guidelines for editing this document: (1) The intrinsic procedures are to be listed in alphabetical order. (2) The generic name is to be use. (3) The specific names are included in the function index and in a table at the end of the node (See ABS entry). (4) Try to maintain the same style for each entry.@end ignore@node Intrinsic Procedures@chapter Intrinsic Procedures@cindex Intrinsic ProceduresThis portion of the document is incomplete and undergoing massive expansion and editing. All contributions and corrections are strongly encouraged. @menu* Introduction: Introduction* @code{ABORT}: ABORT, Abort the program * @code{ABS}: ABS, Absolute value * @code{ACHAR}: ACHAR, Character in @acronym{ASCII} collating sequence* @code{ACOS}: ACOS, Arc cosine function* @code{ADJUSTL}: ADJUSTL, Left adjust a string* @code{ADJUSTR}: ADJUSTR, Right adjust a string* @code{AIMAG}: AIMAG, Imaginary part of complex number* @code{AINT}: AINT, Truncate to a whole number* @code{ALARM}: ALARM, Set an alarm clock* @code{ALL}: ALL, Determine if all values are true* @code{ALLOCATED}: ALLOCATED, Status of allocatable entity* @code{ANINT}: ANINT, Nearest whole number* @code{ANY}: ANY, Determine if any values are true* @code{ASIN}: ASIN, Arcsine function* @code{ASSOCIATED}: ASSOCIATED, Status of a pointer or pointer/target pair* @code{ATAN}: ATAN, Arctangent function* @code{ATAN2}: ATAN2, Arctangent function* @code{BESJ0}: BESJ0, Bessel function of the first kind of order 0* @code{BESJ1}: BESJ1, Bessel function of the first kind of order 1* @code{BESJN}: BESJN, Bessel function of the first kind* @code{BESY0}: BESY0, Bessel function of the second kind of order 0* @code{BESY1}: BESY1, Bessel function of the second kind of order 1* @code{BESYN}: BESYN, Bessel function of the second kind* @code{BIT_SIZE}: BIT_SIZE, Bit size inquiry function* @code{BTEST}: BTEST, Bit test function* @code{CEILING}: CEILING, Integer ceiling function* @code{CHAR}: CHAR, Character conversion function* @code{CMPLX}: CMPLX, Complex conversion function* @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Command line argument count* @code{CONJG}: CONJG, Complex conjugate function* @code{COS}: COS, Cosine function* @code{COSH}: COSH, Hyperbolic cosine function* @code{COUNT}: COUNT, Count occurrences of .TRUE. in an array* @code{CPU_TIME}: CPU_TIME, CPU time subroutine* @code{CSHIFT}: CSHIFT, Circular array shift function* @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string* @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine* @code{DBLE}: DBLE, Double precision conversion function* @code{DCMPLX}: DCMPLX, Double complex conversion function* @code{DFLOAT}: DFLOAT, Double precision conversion function* @code{DIGITS}: DIGITS, Significant digits function* @code{DIM}: DIM, Dim function* @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function* @code{DPROD}: DPROD, Double product function* @code{DREAL}: DREAL, Double real part function* @code{DTIME}: DTIME, Execution time subroutine (or function)* @code{EOSHIFT}: EOSHIFT, End-off shift function* @code{EPSILON}: EPSILON, Epsilon function* @code{ERF}: ERF, Error function* @code{ERFC}: ERFC, Complementary error function* @code{ETIME}: ETIME, Execution time subroutine (or function)* @code{EXIT}: EXIT, Exit the program with status.* @code{EXP}: EXP, Exponential function* @code{EXPONENT}: EXPONENT, Exponent function* @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string* @code{FLOOR}: FLOOR, Integer floor function* @code{FNUM}: FNUM, File number function* @code{FREE}: FREE, Memory de-allocation subroutine* @code{LOC}: LOC, Returns the address of a variable* @code{LOG}: LOG, Logarithm function* @code{LOG10}: LOG10, Base 10 logarithm function * @code{MALLOC}: MALLOC, Dynamic memory allocation function* @code{REAL}: REAL, Convert to real type * @code{SECNDS}: SECNDS, Time function* @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)* @code{SIN}: SIN, Sine function* @code{SINH}: SINH, Hyperbolic sine function* @code{SQRT}: SQRT, Square-root function* @code{TAN}: TAN, Tangent function* @code{TANH}: TANH, Hyperbolic tangent function@end menu@node Introduction@section Introduction to intrinsic proceduresGfortran provides a rich set of intrinsic procedures that includes allthe intrinsic procedures required by the Fortran 95 standard, a set ofintrinsic procedures for backwards compatibility with Gnu Fortran 77(i.e., @command{g77}), and a small selection of intrinsic proceduresfrom the Fortran 2003 standard. Any description here, which conflicts with a description in either the Fortran 95 standard or the Fortran 2003 standard,is unintentional and the standard(s) should be considered authoritative.The enumeration of the @code{KIND} type parameter is processor defined inthe Fortran 95 standard. Gfortran defines the default integer type anddefault real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},respectively. The standard mandates that both data types shall haveanother kind, which have more precision. On typical target architecturessupported by @command{gfortran}, this kind type parameter is @code{KIND=8}.Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.In the description of generic intrinsic procedures, the kind type parameterwill be specified by @code{KIND=*}, and in the description of specificnames for an intrinsic procedure the kind type parameter will be explicitlygiven (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, forbrevity the optional @code{KIND=} syntax will be omitted.Many of the intrinsics procedures take one or more optional arguments.This document follows the convention used in the Fortran 95 standard,and denotes such arguments by square brackets.@command{Gfortran} offers the @option{-std=f95} and @option{-std=gnu} options,which can be used to restrict the set of intrinsic procedures to a given standard. By default, @command{gfortran} sets the @option{-std=gnu}option, and so all intrinsic procedures described here are accepted. Thereis one caveat. For a select group of intrinsic procedures, @command{g77}implemented both a function and a subroutine. Both classes have been implemented in @command{gfortran} for backwards compatibilitywith @command{g77}. It is noted here that these functions and subroutinescannot be intermixed in a given subprogram. In the descriptions that follow,the applicable option(s) is noted.@node ABORT@section @code{ABORT} --- Abort the program @findex @code{ABORT}@cindex abort@table @asis@item @emph{Description}:@code{ABORT} causes immediate termination of the program. On operatingsystems that support a core dump, @code{ABORT} will produce a core dump,which is suitable for debugging purposes.@item @emph{Option}:gnu@item @emph{Class}:non-elemental subroutine@item @emph{Syntax}:@code{CALL ABORT}@item @emph{Return value}:Does not return.@item @emph{Example}:@smallexampleprogram test_abort integer :: i = 1, j = 2 if (i /= j) call abortend program test_abort@end smallexample@end table@node ABS@section @code{ABS} --- Absolute value @findex @code{ABS} intrinsic@findex @code{CABS} intrinsic@findex @code{DABS} intrinsic@findex @code{IABS} intrinsic@findex @code{ZABS} intrinsic@findex @code{CDABS} intrinsic@cindex absolute value@table @asis@item @emph{Description}:@code{ABS(X)} computes the absolute value of @code{X}.@item @emph{Option}:f95, gnu@item @emph{Class}:elemental function@item @emph{Syntax}:@code{X = ABS(X)}@item @emph{Arguments}:@multitable @columnfractions .15 .80@item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},@code{REAL(*)}, or @code{COMPLEX(*)}.@end multitable@item @emph{Return value}:The return value is of the same type andkind as the argument except the return value is @code{REAL(*)} for a@code{COMPLEX(*)} argument.@item @emph{Example}:@smallexampleprogram test_abs integer :: i = -1 real :: x = -1.e0 complex :: z = (-1.e0,0.e0) i = abs(i) x = abs(x) x = abs(z)end program test_abs@end smallexample@item @emph{Specific names}:@multitable @columnfractions .24 .24 .24 .24@item Name @tab Argument @tab Return type @tab Option@item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab f95, gnu@item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu@item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab f95, gnu@item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu@item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab gnu@end multitable@end table@node ACHAR@section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence @findex @code{ACHAR} intrinsic@cindex @acronym{ASCII} collating sequence@table @asis@item @emph{Description}:@code{ACHAR(I)} returns the character located at position @code{I}in the @acronym{ASCII} collating sequence.@item @emph{Option}:f95, gnu@item @emph{Class}:elemental function@item @emph{Syntax}:@code{C = ACHAR(I)}@item @emph{Arguments}:@multitable @columnfractions .15 .80@item @var{I} @tab The type shall be @code{INTEGER(*)}.@end multitable@item @emph{Return value}:The return value is of type @code{CHARACTER} with a length of one. Thekind type parameter is the same as @code{KIND('A')}.@item @emph{Example}:@smallexampleprogram test_achar character c c = achar(32)end program test_achar@end smallexample@end table@node ACOS@section @code{ACOS} --- Arc cosine function @findex @code{ACOS} intrinsic@findex @code{DACOS} intrinsic@cindex arc cosine@table @asis@item @emph{Description}:@code{ACOS(X)} computes the arc cosine of @var{X}.@item @emph{Option}:f95, gnu@item @emph{Class}:elemental function@item @emph{Syntax}:@code{X = ACOS(X)}@item @emph{Arguments}:@multitable @columnfractions .15 .80@item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that isless than one.@end multitable@item @emph{Return value}:The return value is of type @code{REAL(*)} and it lies in therange @math{ 0 \leq \arccos (x) \leq \pi}. The kind typeparameter is the same as @var{X}.@item @emph{Example}:@smallexampleprogram test_acos real(8) :: x = 0.866_8 x = achar(x)end program test_acos@end smallexample@item @emph{Specific names}:@multitable @columnfractions .24 .24 .24 .24@item Name @tab Argument @tab Return type @tab Option@item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu@end multitable@end table@node ADJUSTL@section @code{ADJUSTL} --- Left adjust a string @findex @code{ADJUSTL} intrinsic@cindex adjust string@table @asis@item @emph{Description}:@code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.Spaces are inserted at the end of the string as needed.@item @emph{Option}:f95, gnu@item @emph{Class}:elemental function@item @emph{Syntax}:@code{STR = ADJUSTL(STR)}@item @emph{Arguments}:@multitable @columnfractions .15 .80@item @var{STR} @tab The type shall be @code{CHARACTER}.@end multitable@item @emph{Return value}:The return value is of type @code{CHARACTER} where leading spaces are removed and the same number of spaces are inserted on the endof @var{STR}.@item @emph{Example}:@smallexampleprogram test_adjustl character(len=20) :: str = ' gfortran' str = adjustl(str) print *, strend program test_adjustl@end smallexample@end table@node ADJUSTR@section @code{ADJUSTR} --- Right adjust a string @findex @code{ADJUSTR} intrinsic@cindex adjust string@table @asis@item @emph{Description}:@code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.Spaces are inserted at the start of the string as needed.@item @emph{Option}:f95, gnu@item @emph{Class}:elemental function@item @emph{Syntax}:@code{STR = ADJUSTR(STR)}@item @emph{Arguments}:@multitable @columnfractions .15 .80@item @var{STR} @tab The type shall be @code{CHARACTER}.@end multitable@item @emph{Return value}:The return value is of type @code{CHARACTER} where trailing spaces are removed and the same number of spaces are inserted at the startof @var{STR}.@item @emph{Example}:@smallexampleprogram test_adjustr character(len=20) :: str = 'gfortran' str = adjustr(str) print *, strend program test_adjustr@end smallexample@end table@node AIMAG@section @code{AIMAG} --- Imaginary part of complex number @findex @code{AIMAG} intrinsic@findex @code{DIMAG} intrinsic@findex @code{IMAG} intrinsic@findex @code{IMAGPART} intrinsic@cindex Imaginary part@table @asis@item @emph{Description}:@code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are providedfor compatibility with @command{g77}, and their use in new code is strongly discouraged.@item @emph{Option}:f95, gnu@item @emph{Class}:elemental function@item @emph{Syntax}:@code{X = AIMAG(Z)}@item @emph{Arguments}:@multitable @columnfractions .15 .80@item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.@end multitable@item @emph{Return value}:The return value is of type real with thekind type parameter of the argument.@item @emph{Example}:@smallexampleprogram test_aimag complex(4) z4 complex(8) z8 z4 = cmplx(1.e0_4, 0.e0_4) z8 = cmplx(0.e0_8, 1.e0_8) print *, aimag(z4), dimag(z8)end program test_aimag@end smallexample@item @emph{Specific names}:@multitable @columnfractions .24 .24 .24 .24@item Name @tab Argument @tab Return type @tab Option@item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab f95, gnu@item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab gnu@item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab gnu@end multitable@end table@node AINT@section @code{AINT} --- Imaginary part of complex number @findex @code{AINT} intrinsic@findex @code{DINT} intrinsic@cindex whole number@table @asis@item @emph{Description}:@code{AINT(X [, KIND])} truncates its argument to a whole number.@item @emph{Option}:f95, gnu
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -