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.
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:
ICHAR(CHAR(I)) = I, for 0≤I≤N-1
CHAR(ICHAR(C)) = C, for any character C capable of representation in the processor
(6) COMPLEX
A COMPLEX value is expressed as an ordered pair of reals, (ar, ai), where ar is the real part, and ai is the imaginary part.
(7) Radians
All angles are expressed in radians, unless the “Intrinsic Function” column includes the “(degrees)” remark.
(8) COMPLEX Function
The result of a function of type COMPLEX is the principal value.
(8’) CBRT
If a is of COMPLEX type, CBRT results in COMPLEX RT1=(A, B), where:A ≥ 0.0, and -60 degrees≤ arctan (B/A) < + 60 degrees.
Other two possible results can be evaluated as follows:
RT2 = RT1 * (-0.5, square_root (0.75))
RT3 = RT1 * (-0.5, square_root (0.75))
(9) Argument types
All arguments in an intrinsic function reference must be of the same type.
(10) INDEX
INDEX(X,Y) is the place in X where Y starts. That is, it is the starting position within character string X of the first occurrence of character string Y.
If Y does not occur in X, then INDEX(X,Y) is 0.
If LEN(X) < LEN(Y), then INDEX(X,Y) is 0.
INDEX returns default INTEGER*4 data. If compiling for a 64-bit environment, the compiler will issue a warning if the result overflows the INTEGER*4 data range. To use INDEX in a 64-bit environment with character strings larger than the INTEGER*4 limit (2 Gbytes), the INDEX function and the variables receiving the result must be declared INTEGER*8.
(11) LEN
LEN returns the declared length of the CHARACTER argument variable. The actual value of the argument is of no importance.
LEN returns default INTEGER*4 data. If compiling for a 64-bit environment, the compiler will issue a warning if the result overflows the INTEGER*4 data range. To use LEN in a 64-bit environment with character variables larger than the INTEGER*4 limit (2 Gbytes), the LEN function and the variables receiving the result must be declared INTEGER*8.
(12) Lexical Compare
LGE( X, Y ) is true if X=Y, or if X follows Y in the collating sequence; otherwise, it is false.
LGT( X, Y ) is true if X follows Y in the collating sequence; otherwise, it is false.
LLE( X, Y ) is true if X=Y, or if X precedes Y in the collating sequence; otherwise, it is false.
LLT( X, Y ) is true if X precedes Y in the collating sequence; otherwise, it is false.
If the operands for LGE, LGT, LLE, and LLT are of unequal length, the shorter operand is considered as if it were extended on the right with blanks.
(13) Bit Functions
There are other bitwise operations in VMS Fortran, but these are not implemented.
(14) Shift
LSHIFT shifts a1 logically left by a2 bits (inline code).
LRSHFT shifts a1 logically right by a2 bits (inline code).
RSHIFT shifts a1 arithmetically right by a2 bits.
ISHFT shifts a1 logically left if a2 > 0 and right if a2 < 0.
The LSHIFT and RSHIFT functions are the Fortran analogs of the C << and >> operators. As in C, the semantics depend on the hardware.
The behavior of the shift functions with an out of range shift count is hardware dependent and generally unpredictable. In this release, shift counts larger than 31 result in hardware dependent behavior.
(15) Environmental inquiries
Only the type of the argument is significant.
(16) Epsilon
Epsilon is the least e, such that 1.0 + e ≠ 1.0.
(17) LOC, MALLOC, and FREE
The LOC function returns the address of a variable or of an external procedure. The function call MALLOC( n ) allocates a block of at least n bytes, and returns the address of that block.
LOC returns default INTEGER*4 in 32-bit environments, INTEGER*8 in 64-bit environments.
MALLOC is a library function and not an intrinsic in FORTRAN 77. It too returns default INTEGER*4 in 32-bit environments, INTEGER*8 in 64-bit environments. However, MALLOC must be explicitly declared INTEGER*8 when compiling for 64-bit environments.
The value returned by LOC or MALLOC should be stored in variables typed POINTER, INTEGER*4, or INTEGER*8 in 64-bit environments. The argument to FREE must be the value returned by a previous call to MALLOC and hence should have data type POINTER, INTEGER*4, or INTEGER*8.
MALLOC64 always takes an INTEGER*8 argument (size of memory request in bytes) and always returns an INTEGER*8 value. Use this routine rather than MALLOC when compiling programs that must run in both 32-bit and 64-bit environments. The receiving variable must be declared either POINTER or INTEGER*8.
(18) SIZEOF
The SIZEOF intrinsic cannot be applied to arrays of an assumed size, characters of a length that is passed, or subroutine calls or names. SIZEOF returns default INTEGER*4 data. If compiling for a 64-bit environment, the compiler will issue a warning if the result overflows the INTEGER*4 data range. To use SIZEOF in a 64-bit environment with arrays larger than the INTEGER*4 limit (2 Gbytes), the SIZEOF function and the variables receiving the result must be declared INTEGER*8.