Chapter 3 FORTRAN 77 and VMS Intrinsic Functions
This chapter lists the set of FORTRAN 77 intrinsic functions
accepted by f95 and is provided to aid migration of
programs from legacy FORTRAN 77 to Fortran 95.
f95 recognizes as intrinsic functions all the
FORTRAN 77 and VMS functions listed in this chapter, along with all the Fortran
95 functions listed in the previous chapter. As an aid to migrating legacy
FORTRAN 77 programs to f95, compiling with -f77=intrinsics causes the compiler to recognize only FORTRAN 77 and VMS functions
as intrinsics, and not the Fortran 95 intrinsics.
Intrinsic functions that are Sun extensions of the ANSI FORTRAN 77 standard
are marked with ¤. Programs using non-standard intrinsics and library
functions may not be portable to other platforms.
Intrinsic functions have generic and specific names when they accept arguments of more than one data type. In
general, the generic name returns a value with the same
data type as its argument. However, there are exceptions such as the type
conversion functions (Table 3–2) and
the inquiry functions (Table 3–7).
The function may also be called by one of its specific names
to handle a specific argument data type.
With functions that work on more than one data item (for example, sign(a1,a2) ), all the data arguments must be the same type.
In the following tables, the FORTRAN 77 intrinsic functions are listed
by:
-
Intrinsic Function– description of what the function
does
-
Definition– a mathematical definition
-
No. of Args.– number of arguments the function accepts
-
Generic Name– the function’s generic name
-
Specific Names– the function’s specific names
-
Argument Type– data type associated with each specific
name
-
Function Type– data type returned for specific argument
data type
Note –
Compiler option -xtypemap changes the
default sizes of variables and has an affect on intrinsic references. See 3.4 Remarks , and the discussion of
default sizes and alignment in the Fortran User’s Guide.
3.1 Arithmetic and Mathematical Functions
This section details arithmetic, type
conversion, trigonometric, and other functions. “a” stands for
a function’s single argument, “a1” and “a2”
for the first and second arguments of a two argument function, and “ar”
and “ai” for the real and imaginary parts of a function’s
complex argument.
3.1.1 Arithmetic Functions
Table 3–1 Fortran 77 Arithmetic Functions
|
Intrinsic Function
|
Definition
|
No. of
Args.
|
Generic
Name
|
Specific
Names
|
Argument
Type
|
Function Type
|
|
Absolute value
See Note (6).
|
|a| =
(ar2+ai2)1/2
|
1
|
ABS
|
IABS
ABS
DABS
CABS
QABS ¤
ZABS ¤
CDABS ¤
CQABS ¤
|
INTEGER
REAL
DOUBLE
COMPLEX
REAL*16
DOUBLE COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
INTEGER
REAL
DOUBLE
REAL
REAL*16
DOUBLE
DOUBLE
REAL*16
|
|
Truncation
See Note (1).
|
int(a)
|
1
|
AINT
|
AINT
DINT
QINT ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Nearest whole number
|
int(a+.5) if a ≥ 0
int(a-.5) if a < 0
|
1
|
ANINT
|
ANINT
DNINT
QNINT ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Nearest integer
|
int(a+.5) if a ≥ 0
int(a-.5) if a < 0
|
1
|
NINT
|
NINT
IDNINT
IQNINT ¤
|
REAL
DOUBLE
REAL*16
|
INTEGER
INTEGER
INTEGER
|
|
Remainder
See Note (1).
|
a1-int(a1/a2)*a2
|
2
|
MOD
|
MOD
AMOD
DMOD
QMOD ¤
|
INTEGER
REAL
DOUBLE
REAL*16
|
INTEGER
REAL
DOUBLE
REAL*16
|
|
Transfer of sign
|
|a1| if a2 ≥ 0
-|a1| if a2 < 0
|
2
|
SIGN
|
ISIGN
SIGN
DSIGN
QSIGN ¤
|
INTEGER
REAL
DOUBLE
REAL*16
|
INTEGER
REAL
DOUBLE
REAL*16
|
|
Positive difference
|
a1-a2 if a1 > a2
0 if a1≤ a2
|
2
|
DIM
|
IDIM
DIM
DDIM
QDIM ¤
|
INTEGER
REAL
DOUBLE
REAL*16
|
INTEGER
REAL
DOUBLE
REAL*16
|
|
Double and quad products
|
a1 * a2
|
2
|
-
|
DPROD
QPROD ¤
|
REAL
DOUBLE
|
DOUBLE
REAL*16
|
|
Choosing largest value
|
max(a1, a2, …)
|
≥2
|
MAX
|
MAX0
AMAX1
DMAX1
QMAX1 ¤
|
INTEGER
REAL
DOUBLE
REAL*16
|
INTEGER
REAL
DOUBLE
REAL*16
|
|
AMAX0
|
AMAX0
|
INTEGER
|
REAL
|
|
MAX1
|
MAX1
|
REAL
|
INTEGER
|
|
Choosing smallest value
|
min(a1, a2, …)
|
≥2
|
MIN
|
MIN0
AMIN1
DMIN1
QMIN1 ¤
|
INTEGER
REAL
DOUBLE
REAL*16
|
INTEGER
REAL
DOUBLE
REAL*16
|
|
AMIN0
|
AMIN0
|
INTEGER
|
REAL
|
|
MIN1
|
MIN1
|
REAL
|
INTEGER
|
3.1.2 Type Conversion Functions
Table 3–2 Fortran 77 Type Conversion Functions
|
Conversion to
|
No. of Args
|
Generic Name
|
Specific
Names
|
Argument Type
|
Function Type
|
|
INTEGER
|
1
|
INT
|
-
INT
IFIX
IDINT
-
-
-
IQINT ¤
|
INTEGER
REAL
REAL
DOUBLE
COMPLEX
COMPLEX*16
COMPLEX*32
REAL*16
|
INTEGER
INTEGER
INTEGER
INTEGER
INTEGER
INTEGER
INTEGER
INTEGER
|
|
REAL
|
1
|
REAL
|
REAL
FLOAT
-
SNGL
SNGLQ ¤
-
-
-
FLOATK
|
INTEGER
INTEGER
REAL
DOUBLE
REAL*16
COMPLEX
COMPLEX*16
COMPLEX*32
INTEGER*8
|
REAL
REAL
REAL
REAL
REAL
REAL
REAL
REAL
REAL*4
|
|
DOUBLE
|
1
|
DBLE
|
DBLE
DFLOAT
DFLOATK
DREAL ¤
-
-
-
-
-
DBLEQ ¤-
|
INTEGER
INTEGER
INTEGER*8
REAL
DOUBLE
COMPLEX
COMPLEX*16
REAL*16
COMPLEX*32REAL*16COMPLEX*32
|
DOUBLE PRECISION
DOUBLE PRECISION
DOUBLE PRECISION
DOUBLE PRECISION
DOUBLE PRECISION
DOUBLE PRECISION
DOUBLE PRECISION
DOUBLE PRECISION
DOUBLE PRECISIONDOUBLE PRECISION
DOUBLE PRECISION
|
|
|
1
|
QREAL¤
QEXT ¤
|
QREAL ¤
QFLOAT ¤
-
QEXT ¤
QEXTD ¤
-
-
-
-
|
INTEGER
INTEGER
REAL
INTEGER
DOUBLE
REAL*16
COMPLEX
COMPLEX*16
COMPLEX*32
|
REAL*16
REAL*16
REAL*16
REAL*16
REAL*16
REAL*16
REAL*16
REAL*16
REAL*16
|
COMPLEX
See Notes (4) and (8).
|
|
1 or 2
|
|
-
-
-
-
-
-
-
|
INTEGER
REAL
DOUBLE
REAL*16
COMPLEX
COMPLEX*16
COMPLEX*32
|
COMPLEX
COMPLEX
COMPLEX
COMPLEX
COMPLEX
COMPLEX
COMPLEX
|
DOUBLE COMPLEX
See Note (8).
|
|
1 or 2
|
|
-
-
-
-
-
-
-
|
INTEGER
REAL
DOUBLE
REAL*16
COMPLEX
COMPLEX*16
COMPLEX*32
|
DOUBLE COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
|
|
|
1 or 2
|
|
-
-
-
-
-
-
-
|
INTEGER
REAL
DOUBLE
REAL*16
COMPLEX
COMPLEX*16
COMPLEX*32
|
COMPLEX*32
COMPLEX*32
COMPLEX*32
COMPLEX*32
COMPLEX*32
COMPLEX*32
COMPLEX*32
|
|
|
1
|
|
ICHAR
IACHAR ¤
|
CHARACTER
|
INTEGER
|
|
|
1
|
|
CHAR
ACHAR ¤
|
INTEGER
|
CHARACTER
|
On an ASCII platform, including Sun systems:
On a non-ASCII platform, ACHAR and IACHAR were intended to provide a way to deal directly with ASCII.
3.1.3 Trigonometric Functions
Table 3–3 Fortran 77 Trigonometric Functions
|
Intrinsic Function
|
Definition
|
Args
|
Generic Name
|
Specific
Names
|
Argument Type
|
Function Type
|
|
Sine
See Note (7).
|
sin(a)
|
1
|
SIN
|
SIN
DSIN
QSIN ¤
CSIN
ZSIN ¤
CDSIN ¤
CQSIN ¤
|
REAL
DOUBLE
REAL*16
COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
REAL
DOUBLE
REAL*16
COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
|
Sine (degrees)
See Note (7).
|
sin(a)
|
1
|
SIND ¤
|
SIND ¤
DSIND ¤
QSIND ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Cosine
See Note (7).
|
cos(a)
|
1
|
COS
|
COS
DCOS
QCOS ¤
CCOS
ZCOS ¤
CDCOS ¤
CQCOS ¤
|
REAL
DOUBLE
REAL*16
COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
REAL
DOUBLE
REAL*16
COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
|
Cosine (degrees)
See Note (7).
|
cos(a)
|
1
|
COSD ¤
|
COSD ¤
DCOSD ¤
QCOSD ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Tangent
See Note (7).
|
tan(a)
|
1
|
TAN
|
TAN
DTAN
QTAN ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Tangent (degrees)
See Note (7).
|
tan(a)
|
1
|
TAND ¤
|
TAND ¤
DTAND ¤
QTAND ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Arcsine
See Note (7).
|
arcsin(a)
|
1
|
ASIN
|
ASIN
DASIN
QASIN ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Arcsine (degrees)
See Note (7).
|
arcsin(a)
|
1
|
ASIND ¤
|
ASIND ¤
DASIND ¤
QASIND ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Arccosine
See Note (7).
|
arccos(a)
|
1
|
ACOS
|
ACOS
DACOS
QACOS ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Arccosine (degrees)
See Note (7).
|
arccos(a)
|
1
|
ACOSD ¤
|
ACOSD ¤
DACOSD ¤
QACOSD ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Arctangent
See Note (7).
|
arctan(a)
|
1
|
ATAN
|
ATAN
DATAN
QATAN ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
arctan
(a1/a2)
|
2
|
ATAN2
|
ATAN2
DATAN2
QATAN2 ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Arctangent (degrees)
See Note (7).
|
arctan(a)
|
1
|
ATAND ¤
|
ATAND ¤
DATAND ¤
QATAND ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
arctan
(a1/a2)
|
2
|
ATAN2D¤
|
ATAN2D ¤
DATAN2D ¤
QATAN2D ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Hyperbolic Sine
See Note (7).
|
sinh(a)
|
1
|
SINH
|
SINH
DSINH
QSINH ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Hyperbolic Cosine
See Note (7).
|
cosh(a)
|
1
|
COSH
|
COSH
DCOSH
QCOSH ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Hyperbolic Tangent
See Note (7).
|
tanh(a)
|
1
|
TANH
|
TANH
DTANH
QTANH ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
3.1.4 Other Mathematical Functions
Table 3–4 Other Fortran 77 Mathematical Functions
|
Intrinsic Function
|
Definition
|
No. of Args.
|
Generic Name
|
Specific Names
|
Argument Type
|
Function Type
|
|
Imaginary part of a complex number
See Note (6).
|
ai
|
1
|
IMAG
|
AIMAG
DIMAG ¤
QIMAG ¤
|
COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
REAL
DOUBLE
REAL*16
|
|
Conjugate of a complex number
See Note (6).
|
(ar, -ai)
|
1
|
CONJG
|
CONJG
DCONJG ¤
QCONJG ¤
|
COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
|
Square root
|
a**(1/2)
|
1
|
SQRT
|
SQRT
DSQRT
QSQRT ¤
CSQRT
ZSQRT ¤
CDSQRT ¤
CQSQRT ¤
|
REAL
DOUBLE
REAL*16
COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
REAL
DOUBLE
REAL*16
COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
|
Cube root
See Note(8’).
|
a**(1/3)
|
1
|
CBRT
|
CBRT ¤
DCBRT ¤
QCBRT ¤
CCBRT ¤
ZCBRT ¤
CDCBRT ¤
CQCBRT ¤
|
REAL
DOUBLE
REAL*16
COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
REAL
DOUBLE
REAL*16
COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
|
Exponential
|
e**a
|
1
|
EXP
|
EXP
DEXP
QEXP ¤
CEXP
ZEXP ¤
CDEXP ¤
CQEXP ¤
|
REAL
DOUBLE
REAL*16
COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
REAL
DOUBLE
REAL*16
COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
|
Natural logarithm
|
log(a)
|
1
|
LOG
|
ALOG
DLOG
QLOG ¤
CLOG
ZLOG ¤
CDLOG ¤
CQLOG ¤
|
REAL
DOUBLE
REAL*16
COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
REAL
DOUBLE
REAL*16
COMPLEX
DOUBLE COMPLEX
DOUBLE COMPLEX
COMPLEX*32
|
|
Common logarithm
|
log10(a)
|
1
|
LOG10
|
ALOG10
DLOG10
QLOG10 ¤
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Error function(See note below)
|
erf(a)
|
1
|
ERF
|
ERF ¤
DERF ¤
|
REAL
DOUBLE
|
REAL
DOUBLE
|
|
Error function
|
1.0 - erf(a)
|
1
|
ERFC
|
ERFC ¤
DERFC ¤
|
REAL
DOUBLE
|
REAL
DOUBLE
|
3.2 Character Functions
Table 3–5 Fortran 77 Character Functions
|
Intrinsic Function
|
Definition
|
No. of Args.
|
Specific
Names
|
Argument Type
|
Function Type
|
|
Conversion See Note (5).
|
Conversion to character
Conversion to integer
See also:
Table 3–2.
|
1
1
|
CHAR
ACHAR ¤
ICHAR
IACHAR ¤
|
INTEGER
CHARACTER
|
CHARACTER
INTEGER
|
|
Index of a substring
|
Location of substring a2 in string a1
See Note (10).
|
2
|
INDEX
|
CHARACTER
|
INTEGER
|
|
Length
|
Length of character entity
See Note (11).
|
1
|
LEN
|
CHARACTER
|
INTEGER
|
|
Lexically greater than or equal
|
a1 ≥ a2
See Note (12).
|
2
|
LGE
|
CHARACTER
|
LOGICAL
|
|
Lexically greater than
|
a1 > a2
See Note (12).
|
2
|
LGT
|
CHARACTER
|
LOGICAL
|
|
Lexically less than or equal
|
a1≤ a2
See Note (12).
|
2
|
LLE
|
CHARACTER
|
LOGICAL
|
|
Lexically less than
|
a1 < a2
See Note (12).
|
2
|
LLT
|
CHARACTER
|
LOGICAL
|
On an ASCII platform (including Sun systems):
On a non-ASCII platform, ACHAR and IACHAR were intended to provide a way to deal directly with ASCII.
3.3 Miscellaneous Functions
Other miscellaneous functions include bitwise functions, environmental
inquiry functions, and memory allocation and deallocation functions.
3.3.1 Bit Manipulation ¤
None of these functions are part of the FORTRAN 77 Standard.
Table 3–6 Fortran 77 Bitwise Functions
|
Bitwise Operations
|
No. of Args.
|
Specific Name
|
Argument Type
|
Function Type
|
|
Complement
|
1
|
NOT
|
INTEGER
|
INTEGER
|
|
And
|
22
|
AND IAND
|
INTEGER
|
INTEGER
|
|
Inclusive or
|
22
|
OR IOR
|
INTEGER
|
INTEGER
|
|
Exclusive or
|
22
|
XOR IEOR
|
INTEGER
|
INTEGER
|
|
Shift See Note (14).
|
2
|
ISHFT
|
INTEGER
|
INTEGER
|
|
Left shift See Note (14).
|
2
|
LSHIFT
|
INTEGER
|
INTEGER
|
|
Right shift See Note (14).
|
2
|
RSHIFT
|
INTEGER
|
INTEGER
|
|
Logical right shift See Note (14).
|
2
|
LRSHFT
|
INTEGER
|
INTEGER
|
|
Circular shift
|
3
|
ISHFTC
|
INTEGER
|
INTEGER
|
|
Bit extraction
|
3
|
IBITS
|
INTEGER
|
INTEGER
|
|
Bit set
|
2
|
IBSET
|
INTEGER
|
INTEGER
|
|
Bit test
|
2
|
BTEST
|
INTEGER
|
LOGICAL
|
|
Bit clear
|
2
|
IBCLR
|
INTEGER
|
INTEGER
|
The above functions are available as intrinsic or extrinsic functions.
See also the discussion of the library bit manipulation routines in the Fortran Library Reference manual.
3.3.2 Environmental Inquiry Functions ¤
None of these functions are part of the FORTRAN 77 Standard.
Table 3–7 Fortran 77 Environmental Inquiry Functions
|
Definition
|
No. of Args.
|
Generic Name
|
Argument Type
|
Function Type
|
|
Base of Number System
|
1
|
EPBASE
|
INTEGER
REAL
DOUBLE
REAL*16
|
INTEGER
INTEGER
INTEGER
INTEGER
|
|
Number of Significant Bits
|
1
|
EPPREC
|
INTEGER
REAL
DOUBLE
REAL*16
|
INTEGER
INTEGER
INTEGER
INTEGER
|
|
Minimum Exponent
|
1
|
EPEMIN
|
REAL
DOUBLE
REAL*16
|
INTEGER
INTEGER
INTEGER
|
|
Maximum Exponent
|
1
|
EPEMAX
|
REAL
DOUBLE
REAL*16
|
INTEGER
INTEGER
INTEGER
|
|
Least Nonzero Number
|
1
|
EPTINY
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
|
Largest Number Representable
|
1
|
EPHUGE
|
INTEGER
REAL
DOUBLE
REAL*16
|
INTEGER
REAL
DOUBLE
REAL*16
|
|
Epsilon See Note (16).
|
1
|
EPMRSP
|
REAL
DOUBLE
REAL*16
|
REAL
DOUBLE
REAL*16
|
3.3.3 Memory ¤
None of these functions are part of the FORTRAN 77 Standard.
Table 3–8 Fortran 77 Memory Functions
|
Intrinsic Function
|
Definition
|
No. of Args
|
Specific Name
|
Argument Type
|
Function Type
|
|
Location
|
Address of
See Note (17).
|
1
|
LOC
|
Any
|
INTEGER*4INTEGER*8
|
|
Allocate
|
Allocate memory and return address.
See Note (17).
|
1
|
MALLOC
MALLOC64
|
INTEGER*4
INTEGER*8
|
INTEGER
INTEGER*8
|
|
Deallocate
|
Deallocate memory allocated by MALLOC.
See Note (17).
|
1
|
FREE
|
Any
|
-
|
|
Size
|
Return the size of the argument in bytes.
See Note (18).
|
1
|
SIZEOF
|
Any expression
|
INTEGER
|
3.4 Remarks
The following remarks apply to all of the intrinsic function tables
in this chapter.
-
The abbreviation DOUBLE stands for DOUBLE PRECISION.
-
An intrinsic that takes INTEGER arguments
accepts INTEGER*2, INTEGER*4,
or INTEGER*8.
-
INTEGER intrinsics that take INTEGER arguments return values of INTEGER type
determined as follows. Note that the -xtypemap option
may alter the default sizes of actual arguments:
-
mod sign dim max min and iand or ior xor ieor—
size of the value returned is the largest of the sizes of the
arguments.
-
abs ishft lshift rshift lrshft ibset ibclr ishftc
ibits— size of the value returned is the size of the first
argument.
-
int epbase epprec— size of the
value returned is the size of default INTEGER.
-
ephuge— size of the value returned
is the size of the default INTEGER, or the size of
the argument, whichever is largest.
Options that change the default data sizes also change the way some
intrinsics are used. For example, with -dbl in effect,
a call to ZCOS with a DOUBLE COMPLEX argument
will automatically become a call to CQCOS because the
argument has been promoted to COMPLEX*32. The following
functions have this capability:
aimag alog amod cabs
ccbrt ccos cdabs cdcbrt cdcos cdexp cdlog cdsin cdsqrt cexp clog csin csqrt
dabs dacos dacosd dasin dasind datan datand dcbrt dconjg dcos dcosd dcosh
ddim derf derfc dexp dimag dint dlog dmod dnint dprod dsign dsin dsind dsinh
dsqrt dtan dtand dtanh idnint iidnnt jidnnt zabs zcbrt zcos zexp zlog zsin
zsqrt
-
The following functions permit arguments of an integer or
logical type of any size:
and iand ieor iiand iieor
iior inot ior jiand jieor jior jnot lrshft lshift not or rshift xor
-
An intrinsic that is shown to return a default REAL, DOUBLE PRECISION, COMPLEX, or DOUBLE COMPLEX value
will return the prevailing type depending on certain compilation options.
For example, if compiled with- xtypemap=real:64,double:64:
-
A call to a REAL function returns REAL*8
-
A call to a DOUBLE PRECISION function
returns REAL*8
-
A call to a COMPLEX function returns COMPLEX*16
-
A call to a DOUBLE COMPLEX function
returns COMPLEX*16
Other options that alter
the data sizes of default data types are– r8 and– dbl, which also promote DOUBLE to QUAD. The– xtypemap= option provides
more flexibility than these older compiler options and is preferred.
A function with a generic name returns a value with the same type as
the argument—except for type conversion functions, the nearest integer
function, the absolute value of a complex argument, and others. If there is
more than one argument, they must all be of the same type.
-
If a function name is used as an actual argument, then it
must be a specific name.
-
If a function name is used as a dummy argument, then it does
not identify an intrinsic function in the subprogram, and it has a data type
according to the same rules as for variables and arrays.
3.4.1 Notes on Functions
Tables and notes 1 through 12 are based on the “Table of Intrinsic
Functions,” from ANSI X3.9-1978 Programming Language FORTRAN,
with the Fortran extensions added.
(1) INT
If A is type integer, then INT(A) is A.
If A is type real or double precision, then:
if |A| < 1, then INT(A)
is 0if |A| ≥ 1, then INT(A) is the greatest integer that does not exceed the magnitude
of A, and whose sign is the same as the sign of A. (Such a mathematical integer value may be too large to fit
in the computer integer type.)
If A is type complex or double complex, then
apply the above rule to the real part of A.
If A is type real, then IFIX(A) is
the same as INT(A).
(2) REAL
If A is type real, then REAL(A) is A.
If A is type integer or double precision, then REAL(A) is as much precision of the significant part of A as
a real datum can contain.
If A is type complex, then REAL(A) is
the real part of A.
If A is type double complex, then REAL(A) is as much precision of the significant part of the real part
of A as a real datum can contain.
(3) DBLE
If A is type double precision, then DBLE(A) is A.
If A is type integer or real, then DBLE(A) is as much precision of the significant part of A as
a double precision datum can contain.
If A is type complex, then DBLE(A) is
as much precision of the significant part of the real part of A as
a double precision datum can contain.
If A is type COMPLEX*16,
then DBLE(A) is the real part of A.
(3’) QREAL
If A is type REAL*16,
then QREAL(A) is A.
If A is type integer, real, or double precision,
then QREAL(A) is as much precision of the significant
part of A as a REAL*16 datum
can contain.
If A is type complex or double complex, then QREAL(A) is as much precision of the significant part of the real
part of A as a REAL*16 datum
can contain.
If A is type COMPLEX*16 or COMPLEX*32, then QREAL(A) is the real part
of A.
(4) CMPLX
If A is type complex, then CMPLX(A) is A.
If A is type integer, real, or double precision,
then CMPLX(A) is REAL(A) + 0i.
If A1 and A2 are
type integer, real, or double precision, then CMPLX(A1,A2) is REAL(A1) + REAL(A2)*i.
If A is type double complex, then CMPLX(A) is REAL( DBLE(A) ) + i*REAL( DIMAG(A) ).
If CMPLX has two arguments, then they must be
of the same type, and they may be one of integer, real, or double precision.
If CMPLX has one argument, then it may be one
of integer, real, double precision, complex, COMPLEX*16,
or COMPLEX*32.
(4’) DCMPLX
If A is type COMPLEX*16,
then DCMPLX(A) is A.
If A is type integer, real, or double precision,
then DCMPLX(A) is DBLE(A) + 0i.
If A1 and A2 are type
integer, real, or double precision, then DCMPLX(A1,A2) is DBLE(A1) + DBLE(A2)*i.
If DCMPLX has two arguments, then they must be
of the same type, and they may be one of integer, real, or double precision.
If DCMPLX has one argument, then it may be one
of integer, real, double precision, complex, COMPLEX*16,
or COMPLEX*32.
(5) ICHAR
ICHAR(A) is the position of A in
the collating sequence.
The first position is 0, the last is N-1, 0≤ICHAR(A)≤N-1, where N is
the number of characters in the collating sequence, and A is
of type character of length one.
CHAR and ICHAR are inverses
in the following sense:
3.5 VMS Intrinsic Functions
This section lists VMS FORTRAN intrinsic routines recognized by f95. They are, of course, nonstandard. ¤
3.5.1 VMS Double-Precision Complex
Table 3–9 VMS Double-Precision Complex Functions
|
Generic Name
|
Specific Names
|
Function
|
Argument Type
|
Result Type
|
|
|
CDABS
CDEXP
CDLOG
CDSQRT
|
Absolute value
Exponential, e**a
Natural log
Square root
|
COMPLEX*16
COMPLEX*16
COMPLEX*16
COMPLEX*16
|
REAL*8
COMPLEX*16
COMPLEX*16
COMPLEX*16
|
|
|
CDSIN
CDCOS
|
Sine
Cosine
|
COMPLEX*16
COMPLEX*16
|
COMPLEX*16
COMPLEX*16
|
|
DCMPLX
|
DCONJG
DIMAG
DREAL
|
Convert to DOUBLE COMPLEX
Complex conjugate
Imaginary part of complex
Real part of complex
|
Any numeric
COMPLEX*16
COMPLEX*16
COMPLEX*16
|
COMPLEX*16
COMPLEX*16
REAL*8
REAL*8
|
3.5.2 VMS Degree-Based Trigonometric
Table 3–10 VMS Degree-Based Trigonometric Functions
|
Generic Name
|
Specific Names
|
Function
|
Argument Type
|
Result Type
|
|
SIND
|
SIND
DSIND
QSIND
|
Sine
|
-
REAL*4
REAL*8
REAL*16
|
-
REAL*4
REAL*8
REAL*16
|
|
COSD
|
COSD
DCOSD
QCOSD
|
Cosine
|
-
REAL*4
REAL*8
REAL*16
|
-
REAL*4
REAL*8
REAL*16
|
|
TAND
|
TAND
DTAND
QTAND
|
Tangent
|
-
REAL*4
REAL*8
REAL*16
|
-
REAL*4
REAL*8
REAL*16
|
|
ASIND
|
ASIND
DASIND
QASIND
|
Arc sine
|
-
REAL*4
REAL*8
REAL*16
|
-
REAL*4
REAL*8
REAL*16
|
|
ACOSD
|
ACOSD
DACOSD
QACOSD
|
Arc cosine
|
-
REAL*4
REAL*8
REAL*16
|
-
REAL*4
REAL*8
REAL*16
|
|
ATAND
|
ATAND
DATAND
QATAND
|
Arc tangent
|
-
REAL*4
REAL*8
REAL*16
|
-
REAL*4
REAL*8
REAL*16
|
|
ATAN2D
|
ATAN2D
DATAN2D
QATAN2D
|
Arc tangent of a1/a2
|
-
REAL*4
REAL*8
REAL*16
|
-
REAL*4
REAL*8
REAL*16
|
3.5.3 VMS Bit-Manipulation
Table 3–11 VMS Bit-Manipulation Functions
|
Generic Name
|
Specific Names
|
Function
|
Argument Type
|
Result Type
|
|
IBITS
|
IIBITS
JIBITS
KIBITS
|
From a1, initial bit a2,
extract a3 bits
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
|
ISHFT
|
IISHFT
JISHFT
KISHFT
|
Shift a1 logically by a2 bits;
if a2 positive shift left, if a2 negative
shift right
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
|
ISHFTC
|
IISHFTC
JISHFTC
|
In a1, circular shift by a2 places,
of right a3 bits
|
-
INTEGER*2
INTEGER*4
|
-
INTEGER*2
INTEGER*4
|
|
IAND
|
IIAND
JIAND
|
Bitwise AND of a1, a2
|
-
INTEGER*2
INTEGER*4
|
-
INTEGER*2
INTEGER*4
|
|
IOR
|
IIOR
JIOR
KIOR
|
Bitwise OR of a1, a2
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
|
IEOR
|
IIEOR
JIEOR
KIEOR
|
Bitwise exclusive OR of a1, a2
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
|
NOT
|
INOT
JNOT
KNOT
|
Bitwise complement
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
|
IBSET
|
IIBSET
JIBSET
KIBSET
|
In a1, set bit a2 to 1; return new a1
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
|
BTEST
|
BITEST
BJTEST
BKTEST
|
If bit a2 of a1 is 1, return .TRUE.
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
-
LOGICAL
LOGICAL
LOGICAL
|
|
IBCLR
|
IIBCLR
JIBCLR
KIBCLR
|
In a1, set bit a2 to 0; return new a1
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
-
INTEGER*2
INTEGER*4
INTEGER*8
|
3.5.4 VMS Multiple Integer Types
The possibility of multiple integer types is not addressed by the Fortran Standard.
The compiler copes with their existence by treating a specific INTEGER-to-INTEGER function name (IABS,
and so forth) as a special sort of generic. The argument type is used to select
the appropriate runtime routine name, which is not accessible to the programmer.
VMS Fortran takes a similar approach, but makes the specific names
available.
Table 3–12 VMS Integer Functions
|
Specific Names
|
Function
|
Argument Type
|
Result Type
|
|
IIABS
JIABS
KIABS
|
Absolute value
|
INTEGER*2
INTEGER*4
INTEGER*8
|
INTEGER*2
INTEGER*4
INTEGER*8
|
|
IMAX0
JMAX0
|
Maximum
|
INTEGER*2
INTEGER*4
|
INTEGER*2
INTEGER*4
|
|
IMIN0
JMIN0
|
Minimum
|
INTEGER*2
INTEGER*4
|
INTEGER*2
INTEGER*4
|
|
IIDIM
JIDIM
KIDIM
|
Positive difference
|
INTEGER*2
INTEGER*4
INTEGER*8
|
INTEGER*2
INTEGER*4
INTEGER*8
|
|
IMOD
JMOD
|
Remainder of a1/a2
|
INTEGER*2
INTEGER*4
|
INTEGER*2
INTEGER*4
|
|
IISIGN
JISIGN
KISIGN
|
Transfer of sign, |a1|* sign(a2)
|
INTEGER*2
INTEGER*4
INTEGER*8
|
INTEGER*2
INTEGER*4
INTEGER*8
|