Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran 90 Programmer's Reference: HP Series 700/800 Computers > Chapter 11 Intrinsic procedures

Intrinsic procedure specifications

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

This section contains detailed specifications of HP Fortran 90 intrinsic procedures, which are listed in alphabetical order.

For a summary of all generic as well as specific intrinsic procedures, see Table 11-6 “ Generic and specific intrinsic procedures”.

All of the intrinsic procedures in this section are generic. This means that each intrinsic procedure may be called with more than one argument type/kind/rank pattern.

In many cases, the kind and type of intrinsic function results are the same as that of the "principal" argument. For example, the SIN function may be called with any kind of real argument or any kind of complex argument, and the result has the type and kind of the argument.

Intrinsic procedure references may use keywords, in which case the actual argument expression is preceded by the dummy argument name (the argument keyword) and an "=" symbol. These argument keywords are shown in the following descriptions of the procedures.

Some intrinsic procedure's arguments are optional. Optional arguments are noted as such in the following descriptions.

ABORT()

Description. Close all files, terminate the program, and cause an exception to create a core file.

Class. Nonstandard subroutine.

Example.

The following program aborts before the second PRINT statement.

PROGRAM testabort
PRINT *, "Program prints this line."
CALL ABORT()
PRINT *, "Program aborts before this point."
END

This program produces the following output, followed by core dump information.

Program prints this line.
Fortran abort routine called

ABS(A)

Description. Absolute value.

Class. Elemental function.

Argument. A must be of type integer, real, or complex.

Result Type and Type Parameter. The same as A except that if A is complex, the result is real.

Result Value.

If A is of type integer or real, the value of the result is |A|.

If A is complex with value (x, y), the result is equal to a processor-dependent approximation to the square root of (x² + y²).

Examples.

ABS(-1) has the value 1.

ABS(-1.5) has the value 1.5.

ABS((3.0, 4.0)) has the value 5.0.

ACHAR(I)

Description. Returns the character in a specified position of the ASCII collating sequence. It is the inverse of the IACHAR function.

Class. Elemental function.

Argument. I must be of type integer.

Result Type and Type Parameter. Character of length one with kind type parameter value KIND('A').

Result Value.

If I has a value in the range 0 <= I <= 127, the result is the character in position I of the ASCII collating sequence, provided the processor is capable of representing that character; otherwise, the result is processor-dependent.

If the processor is not capable of representing both uppercase and lowercase letters and I corresponds to a letter in a case that the processor is not capable of representing, the result is the letter in the case that the processor is capable of representing.

ACHAR(IACHAR(C)) must have the value C for any character C capable of representation in the processor.

Examples.

ACHAR(88) is 'X'.

ACHAR(42) is '*'.

ACOS(X)

Description. Arccosine (inverse cosine) function in radians.

Class. Elemental function.

Argument. X must be of type real with a value that satisfies the inequality |X| <= 1.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to arccos(X), expressed in radians. It lies in the range 0 <= ACOS(X) <= Pi.

Examples.

ACOS(0.54030231) has the value 1.0.

ACOS(.1_HIGH) has the value 1.4706289056333 with kind HIGH.

ACOSD(X)

Description. Arccosine (inverse cosine) function in degrees.

Class. Elemental nonstandard function.

Argument. X must be of type real with a value that satisfies the inequality |X| <= 1.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to arccos(X), expressed in degrees. It lies in the range 0 <= ACOSD(X) <= 180.

Examples.

ACOSD(0.0000001) has the value 89.99999.

ACOSD(0.5) has the value 60.0.

ACOSD(-1.0) has the value 180.0.

ACOSH(X)

Description. Hyperbolic arccosine of radians.

Class. Elemental nonstandard function.

Argument. X must be of type real with a value X >= 1.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to the hyperbolic arccosine of X. It lies in the range 0 <= ACOSH(X).

Examples.

ACOSH(1.0) has the value 0.0.

ACOSH(180.0) has the value 5.8861.

ACOSH(0.0) has the value NaN (not a number).

ADJUSTL(STRING)

Description. Adjust to the left, removing leading blanks and inserting trailing blanks.

Class. Elemental function.

Argument. STRING must be of type character.

Result Type. Character of the same length and kind type parameter as STRING.

Result Value. The value of the result is the same as STRING except that any leading blanks have been deleted and the same number of trailing blanks have been inserted.

Example.

ADJUSTL('bbWORD') is 'WORDbb'.

ADJUSTR(STRING)

Description. Adjust to the right, removing trailing blanks and inserting leading blanks.

Class. Elemental function.

Argument. STRING must be of type character.

Result Type. Character of the same length and kind type parameter as STRING.

Result Value. The value of the result is the same as STRING except that any trailing blanks have been deleted and the same number of leading blanks have been inserted.

Examples.

ADJUSTR('WORDbb') has the value 'bbWORD'.

AIMAG(Z)

Description. Imaginary part of a complex number.

Class. Elemental function.

Argument. Z must be of type complex.

Result Type and Type Parameter. Real with the same kind type parameter as Z.

Result Value. If Z has the value (x, y), the result has value y.

Examples.

AIMAG((2.0, 3.0)) has the value 3.0.

AIMAG((2.0_HIGH, 3.0)) has the value 3.0 with kind HIGH; the parts of a complex literal constant have the same precision, which is that of the part with the greatest precision.

AINT(A, KIND)

Optional Argument. KIND

Description. Truncation to a whole number.

Class. Elemental function.

Arguments.

A

must be of type real.

KIND (optional)

must be a scalar integer initialization expression.

Result Type and Type Parameter. The result is of type real. If KIND is present, the kind type parameter is that specified by KIND; otherwise, the kind type parameter is that of A.

Result Value. If |A| < 1, AINT(A) has the value 0; if A >= 1, AINT(A) has a value equal to the integer whose magnitude is the largest integer that does not exceed the magnitude of A and whose sign is the same as the sign of A.

Examples.

AINT(2.783) has the value 2.0.

AINT(-2.783) has the value -2.0.

AINT(2.1111111111111_HIGH) and AINT(2.1111111111111, HIGH) have the value 2.0 with kind HIGH.

ALL(MASK, DIM)

Optional Argument. DIM

Description. Determine whether all values are .TRUE. in MASK along dimension DIM.

Class. Transformational function.

Arguments.

MASK

must be of type logical. It must not be scalar.

DIM (optional)

must be scalar and of type integer with value in the range 1 <= DIM <= n where n is the rank of MASK. The corresponding actual argument must not be an optional dummy argument.

Result Type, Type Parameter, and Shape. The result is of type logical with the same kind type parameter as MASK. It is scalar if DIM is absent or MASK has rank one; otherwise, the result is an array of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn) where (d1, d2, ..., dn) is the shape of MASK.

Result Value.

Case 1

The result of ALL(MASK) has the value .TRUE. if all elements of MASK are .TRUE. or if MASK has size zero, and the result has value .FALSE. if any element of MASK is .FALSE..

Case 2

If MASK has rank one, ALL(MASK, DIM) has a value equal to that of ALL(MASK). Otherwise, the value of element (s1, s2, ..., sDIM-1, sDIM+1, ..., sn) of ALL(MASK, DIM) is equal to ALL(MASK (s1, s2, ..., sDIM-1, :, sDIM+1, ..., sn)).

Examples.

Case 1

The value of ALL((/ .TRUE., .FALSE., .TRUE. /)) is .FALSE..

ALL((/ .TRUE._BIT, .TRUE._BIT, .TRUE._BIT /)) is the value .TRUE._BIT.

Case 2

If B is the array

      1  3  5
      2  4  6

and C is the array

      0  3  5
      7  4  8

then ALL(B .NE. C, DIM = 1) is [.TRUE., .FALSE., .FALSE.] and ALL(B .NE. C, DIM = 2) is [.FALSE., .FALSE.].

ALLOCATED(ARRAY)

Description. Indicate whether or not an allocatable array is currently allocated.

Class. Inquiry function.

Argument. ARRAY must be an allocatable array.

Result Type, Type Parameter, and Shape. Default logical scalar.

Result Value. The result has the value .TRUE. if ARRAY is currently allocated and has the value .FALSE. if ARRAY is not currently allocated. The result is undefined if the allocation status of the array is undefined.

Example. If the following statements are processed

REAL, ALLOCATABLE :: A(:,:)
ALLOCATE (A(10,10))
PRINT *, ALLOCATED (A) 

then T is printed.

AND(I, J)

Description. Logical AND.

Class. Elemental nonstandard function.

Arguments.

I

must be of type integer.

J

must be of type integer with the same kind type parameter as I.

Result Type and Type Parameter. Same as I.

Result Value. The result has the value obtained by performing a logical AND on I and J bit-by-bit according to the following truth table:

Table 11-7 Title not available (AND(I, J))

I

J

AND(I, J)

1

1

1

1

0

0

0

1

0

0

0

1

 

The model for interpreting an integer value as a sequence of bits is in “The bit model”.

Example.

The following program produces the output " 11 5 1".

K is assigned the binary value 0001, which is 1 in decimal.

PROGRAM andtest
INTEGER I, J, K
I = B'1011'
J = B'0101'
K = AND(I, J)
PRINT *, I, J, K
END

ANINT(A, KIND)

Optional Argument. KIND

Description. Nearest whole number.

Class. Elemental function.

Arguments.

A

must be of type real.

KIND (optional)

must be a scalar integer initialization expression.

Result Type and Type Parameter. The result is of type real. If KIND is present, the kind type parameter is that specified by KIND; otherwise, the kind type parameter is that of A.

Result Value. If A>0, ANINT(A) has the value AINT(A+0.5); if A <= 0, ANINT(A) has the value AINT(A-0.5).

Examples.

ANINT(2.783) has the value 3.0.

ANINT(-2.783) has the value -3.0.

ANINT(2.7837837837837_HIGH) and ANINT(2.7837837837837,HIGH) have the value 3.0 with kind HIGH.

ANY(MASK, DIM)

Optional Argument. DIM

Description. Determine whether any value is .TRUE. in MASK along dimension DIM.

Class. Transformational function.

Arguments.

MASK

must be of type logical. It must not be scalar.

DIM (optional)

must be scalar and of type integer with a value in the range 1 <= DIM <= n, where n is the rank of MASK. The corresponding actual argument must not be an optional dummy argument.

Result Type, Type Parameter, and Shape. The result is of type logical with the same kind type parameter as MASK. It is scalar if DIM is absent or MASK has rank one; otherwise, the result is an array of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn) where (d1, d2, ..., dn) is the shape of MASK.

Result Value.

Case 1

The result of ANY(MASK) has the value .TRUE. if any element of MASK is .TRUE. and has the value .FALSE. if no elements are .TRUE. or if MASK has size zero.

Case 2

If MASK has rank one, ANY(MASK,DIM) has a value equal to that of ANY(MASK). Otherwise, the value of element (s1, s2, ..., sDIM-1, sDIM+1, ..., sn) of ANY(MASK, DIM) is equal to ANY(MASK(s1, s2, ..., sDIM-1, :, sDIM+1, ..., sn)).

Examples.

Case 1

The value of ANY((/ .TRUE., .FALSE., .TRUE. /)) is .TRUE..

ANY((/ .FALSE._BIT, .FALSE._BIT, .FALSE._BIT /)) is .FALSE._BIT.

Case 2

If B is the array

      1  3  5
      2  4  6

and C is the array

      0  3  5
      7  4  8

then ANY(B .NE. C, DIM = 1) is [.TRUE., .FALSE., .TRUE.] and ANY(B .NE. C, DIM = 2) is [.TRUE., .TRUE.].

ASIN(X)

Description. Arcsine (inverse sine) function in radians.

Class. Elemental function.

Argument. X must be of type real. Its value must satisfy the inequality |X| >= 1.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to arcsin(X), expressed in radians. It lies in the range -Pi/2 <= ASIN(X) <= Pi/2.

Examples.

ASIN(0.84147098) has the value 1.0.

ASIN(1.0_HIGH) has the value 1.5707963267949 with kind HIGH.

ASIND(X)

Description. Arcsine (inverse sine) function in degrees.

Class. Elemental nonstandard function.

Argument. X must be of type real. Its value must satisfy the inequality |X| <= 1.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to arcsin(X), expressed in degrees. It lies in the range -90 <= ASIN(X) <= 90.

Examples.

ASIND(-1.0) has the value -90.0.

ASIND(0.5) has the value 30.0.

ASINH(X)

Description. Hyperbolic arcsine of radians.

Class. Elemental nonstandard function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to the hyperbolic arcsine of X.

Examples.

ASINH(-1.0) has the value -0.88137.

ASINH(180.0) has the value 5.88611.

ASSOCIATED(POINTER, TARGET)

Optional Argument. TARGET

Description. Returns the association status of its pointer argument or indicates the pointer is associated with the target.

Class. Inquiry function.

Arguments.

POINTER

must be a pointer and may be of any type. Its pointer association status must not be undefined.

TARGET (optional)

must be a pointer or target. If it is a pointer, its pointer association status must not be undefined.

Result Type. The result is scalar of type default logical.

Result Value.

Case 1

If TARGET is absent, the result is .TRUE. if POINTER is currently associated with a target and .FALSE. if it is not.

Case 2

If TARGET is present and is a target, the result is .TRUE. if POINTER is currently associated with TARGET and .FALSE. if it is not.

Case 3

If TARGET is present and is a pointer, the result is .TRUE. if both POINTER and TARGET are currently associated with the same target, and is .FALSE. otherwise. If either POINTER or TARGET is disassociated, the result is .FALSE..

Examples.

Case 1

ASSOCIATED(PTR) is .TRUE. if PTR is currently associated with a target.

Case 2

ASSOCIATED(PTR, TAR) is .TRUE. if the following statements have been processed:

REAL, TARGET  :: TAR (0:100)
REAL, POINTER :: PTR(:) 
PTR => TAR 

The subscript range for both TAR and PTR is 0:100.

If the pointer assignment statement is either

PTR => TAR(:)

or

PTR => TAR(0:100) 

then ASSOCIATED(PTR, TAR) is still .TRUE., but in both cases the subscript range for PTR is 1:101.

However, if the pointer assignment statement is

PTR => TAR(0:99) 

then ASSOCIATED(PTR, TAR) is .FALSE., because TAR(0:99) is not the same as TAR.

Case 3

ASSOCIATED(PTR1, PTR2) is .TRUE. if the following statements have been processed.

REAL, POINTER :: PTR1(:), PTR2(:) 
ALLOCATE(PTR1(0:10))
PTR2 => PTR1

After the execution of either

NULLIFY(PTR1) 

or

NULLIFY(PTR2) 

the statement ASSOCIATED(PTR1, PTR2) evaluates to .FALSE..

ATAN(X)

Description. Arctangent (inverse tangent) function in radians.

Class. Elemental function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to arctan(X), expressed in radians, that lies in the range -Pi/2 <= ATAN(X) <= Pi/2.

Examples.

ATAN(1.5574077) has the value 1.0.

ATAN(2.0_HIGH/3.0) has the value 0.58800260354757 with kind HIGH.

ATAN2(Y, X)

Description. Arctangent (inverse tangent) function in radians. The result is the principal value of the argument of the nonzero complex number (X, Y).

Class. Elemental function.

Arguments.

Y

must be of type real.

X

must be of the same type and kind type parameter as Y. If Y has the value zero, X must not have the value zero.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to the principal value of the argument of the complex number (X, Y), expressed in radians.

The result lies in the range -Pi <= ATAN2(Y, X) <= Pi and is equal to a processor-dependent approximation to a value of arctan(Y/X) if X is not 0.

If Y>0, the result is positive. If Y=0, the result is zero if X>0 and the result is Pi if X<0. If Y<0, the result is negative. If X=0, the absolute value of the result is Pi/2.

Examples.

ATAN2(1.5574077, 1.0) has the value 1.0.

If Y has the value

      1   1
     -1  -1

and X has the value

     -1  1
     -1  1

then the value of ATAN2(Y, X) is

   3Pi   Pi
   ---   ---
    4     4
  -3Pi   -Pi
  ----   ----
   4      4

ATAN2D(Y, X)

Description. Arctangent (inverse tangent) function in degrees.

Class. Elemental nonstandard function.

Arguments.

Y

must be of type real.

X

must be of the same type and kind type parameter as Y.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to the principal value of the argument of the complex number (X, Y), expressed in degrees, that lies in the range -90 < ATAN2D(Y,X) < 90.

Examples.

ATAN2D(1.0, 1.0) has the value 45.0.

ATAN2D(1.0, 0.0) has the value 90.0.

ATAN2D(8735.0, 1.0) has the value 89.99344.

ATAND(X)

Description. Arctangent (inverse tangent) function in degrees.

Class. Elemental nonstandard function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to arctan(X), expressed in degrees, that lies in the range -90 < ATAND(X) < 90.

Examples.

ATAND(1.0) has the value 45.0.

ATAND(0.0) has the value 0.0.

ATAND(-94373.0) has the value -89.9994.

ATANH(X)

Description. Hyperbolic arctangent of radians.

Class. Elemental nonstandard function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to the hyperbolic arctangent of X.

Examples.

ATANH(0.0) has the value 0.0.

ATANH(-0.77) has the value -1.02033.

ATANH(0.5) has the value 0.549306.

BADDRESS(X)

Description. Return the address of X.

Class. Inquiry nonstandard function.

Argument. X may be of any type.

Result Type. The result is of type default integer.

Example.

The following program:

PROGRAM batest
INTEGER X(5), I
DO I=1, 5
PRINT *, BADDRESS(X(I))
END DO
END

Could produce this output:

2063835808
2063835812
2063835816
2063835820
2063835824

BIT_SIZE(I)

Description. Returns the number of bits n, defined by the model in “The bit model”, for integers with the kind parameter of the argument.

Class. Inquiry function.

Argument. I must be of type integer.

Result Type, Type Parameter, and Shape. Scalar integer with the same kind type parameter as I.

Result Value. The result has the value of the number of bits n in the model integer, defined for bit manipulation contexts in “The bit model”, for integers with the kind parameter of the argument.

Examples. BIT_SIZE(1) has the value 32 if n in the model is 32.

BTEST(I, POS)

Description. Tests a bit of an integer value.

Class. Elemental function.

Arguments.

I

must be of type integer.

POS

must be of type integer. It must be nonnegative and be less than BIT_SIZE(I).

Result Type. The result is of type default logical.

Result Value. The result has the value .TRUE. if bit POS of I has the value 1 and has the value .FALSE. if bit POS of I has the value 0. The model for the interpretation of an integer value as a sequence of bits is in “The bit model”.

Examples.

BTEST(8, 3) has the value .TRUE..

BTEST(8_SHORT, 3) has the value .TRUE..

If A has the value [1, 2, 3, 4] then the value of BTEST(A, 2) is [.FALSE., .FALSE., .FALSE., .TRUE.] and the value of BTEST(2, A) is [.TRUE., .FALSE., .FALSE., .FALSE.].

CEILING(A)

Description. Returns the least integer greater than or equal to its argument.

Class. Elemental function.

Argument. A must be of type real.

Result Type and Type Parameter. Default integer.

Result Value. The result has a value equal to the least integer greater than or equal to A. The result is undefined if the processor cannot represent this value in the default integer type.

Examples.

CEILING(3.7) has the value 4.

CEILING(-3.7) has the value -3.

CEILING(20.0_HIGH/3) has the value 7.

CHAR(I, KIND)

Optional Argument. KIND

Description. Returns the character in a given position of the processor collating sequence associated with the specified kind type parameter. It is the inverse of the function ICHAR.

Class. Elemental function.

Arguments.

I

must be of type integer with a value in the range 0 <= I <= n-1, where n is the number of characters in the collating sequence associated with the specified kind type parameter.

KIND (optional)

must be a scalar integer initialization expression.

Result Type and Type Parameters. Character of length one. If KIND is present, the kind type parameter is that specified by KIND; otherwise, the kind type parameter is that of default character type.

Result Value. The result is the character in position I of the collating sequence associated with the specified kind type parameter.

ICHAR(CHAR(I, KIND(C))) must have the value I for 0 <= I <= n-1 and CHAR(ICHAR(C), KIND(C)) must have the value C for any character C capable of representation in the processor.

Example.

CHAR(88) is 'X' on a processor using the ASCII collating sequence.

CMPLX(X, Y, KIND)

Optional Arguments. Y, KIND

Description. Convert to complex type.

Class. Elemental function.

Arguments.

X

must be of type integer, real, or complex.

Y (optional)

must be of type integer or real. It must not be present if X is of type complex.

KIND (optional)

must be a scalar integer initialization expression.

Result Type and Type Parameter. The result is of type complex. If KIND is present, the kind type parameter is that specified by KIND; otherwise, the kind type parameter is that of default real type.

Result Value.

If Y is absent and X is not complex, it is as if Y were present with the value zero.

If Y is absent and X is complex, it is as if Y were present with the value AIMAG(X).

CMPLX(X,Y,KIND) has the complex value whose real part is REAL(X,KIND) and whose imaginary part is REAL(Y,KIND).

Examples.

CMPLX(-3) is -3.0 + 0i.

CMPLX((4.1,0.0), KIND=HIGH), CMPLX((4.1,0), KIND=HIGH), and CMPLX(4.1, KIND=HIGH) are each 4.1 + 0.0i with kind HIGH.

CONJG(Z)

Description. Conjugate of a complex number.

Class. Elemental function.

Argument. Z must be of type complex.

Result Type and Type Parameter. Same as Z.

Result Value. If Z has the value (x, y), the result has the value (x, -y).

Examples.

CONJG((2.0, 3.0) is (2.0, - 3.0).

CONJG((0., -4.1_HIGH)) is 0 + 4.1i with kind HIGH.

COS(X)

Description. Cosine function in radians.

Class. Elemental function.

Argument. X must be of type real or complex.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to cos(X). If X is of type real, it is regarded as a value in radians. If X is of type complex, its real part is regarded as a value in radians.

Examples.

COS(1.0) has the value 0.54030231.

COS((1.0_HIGH, 1.0)) has the value 0.83373002513115 - 0.98889770576287i with kind HIGH.

COSD(X)

Description. Cosine function in degrees.

Class. Elemental nonstandard function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to cos(X).

Examples.

COSD(0.0) has the value 1.0.

COSD(60.0) has the value 0.5.

COSH(X)

Description. Hyperbolic cosine function.

Class. Elemental function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to cosh(X).

Examples.

COSH(1.0) has the value 1.5430806.

COSH(0.1_HIGH) has the value 1.0050041680558 with kind HIGH.

COUNT(MASK, DIM)

Optional Argument. DIM

Description. Count the number of .TRUE. elements of MASK along dimension DIM.

Class. Transformational function.

Arguments.

MASK

must be of type logical. It must not be scalar.

DIM (optional)

must be scalar and of type integer with a value in the range

1 <= DIM <= n, where n is the rank of MASK. The corresponding actual argument must not be an optional dummy argument.

Result Type, Type Parameter, and Shape. The result is of type default integer. It is scalar if DIM is absent or MASK has rank one; otherwise, the result is an array of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn) where (d1, d2, ..., dn) is the shape of MASK.

Result Value.

Case 1

The result of COUNT(MASK) has a value equal to the number of .TRUE. elements of MASK or has the value zero if MASK has size zero.

Case 2

If MASK has rank one, COUNT(MASK, DIM) has a value equal to that of COUNT(MASK). Otherwise, the value of element (s1, s2, ..., sDIM-1, sDIM+1, ..., sn) of COUNT(MASK, DIM) is equal to COUNT(MASK(s1, s2, ..., sDIM-1, :, sDIM+1, ..., sn)).

Examples.

Case 1

The value of COUNT((/ .TRUE., .FALSE., .TRUE. /)) is 2.

Case 2

If B is the array

      1  3  5
      2  4  6

and C is the array

      0  3  5
      7  4  8

then COUNT(B .NE. C, DIM = 1) is [2, 0, 1] and COUNT(B .NE. C, DIM = 2) is [1, 2].

CSHIFT(ARRAY, SHIFT, DIM)

Optional Argument. DIM

Description. Perform a circular shift on an array expression of rank one, or perform circular shifts on all the complete rank one sections along a given dimension of an array expression of rank two or greater.

Elements shifted out at one end of a section are shifted in at the other end. Different sections may be shifted by different amounts and in different directions (positive for left shifts, negative for right shifts).

Class. Transformational function.

Arguments.

ARRAY

may be of any type. It must not be scalar.

SHIFT

must be of type integer and must be scalar if ARRAY has rank one; otherwise, it must be scalar or of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn) where (d1, d2, ..., dn) is the shape of ARRAY.

DIM (optional)

must be a scalar and of type integer with a value in the range 1 <= DIM <= n, where n is the rank of ARRAY. If DIM is omitted, it is as if it were present with the value 1.

Result Type, Type Parameter, and Shape. The result is of the type and type parameters of ARRAY, and has the shape of ARRAY.

Result Value.

Case 1

If ARRAY has rank one, element i of the result is ARRAY(1 + MODULO(i + SHIFT - 1, SIZE(ARRAY))).

Case 2

If ARRAY has rank greater than one, section (s1, s2, ..., sDIM-1, :, sDIM+1, ...., sn) of the result has a value equal to CSHIFT(ARRAY(s1, s2, ..., sDIM-1, :, sDIM+1, ...., sn), sh, 1), where sh is SHIFT or SHIFT(s1, s2, ..., sDIM-1, sDIM+1, ..., sn).

Examples.

Case 1

If V is the array [1, 2, 3, 4, 5, 6], the effect of shifting V circularly to the left by two positions is achieved by CSHIFT(V, SHIFT = 2) which has the value [3, 4, 5, 6, 1, 2].

CSHIFT(V, SHIFT = -2) achieves a circular shift to the right by two positions and has the value [5, 6, 1, 2, 3, 4].

Case 2

The rows of an array of rank two may all be shifted by the same amount or by different amounts. If M is the array

      1  2  3
      4  5  6
      7  8  9

then the value of CSHIFT(M, SHIFT = -1, DIM = 2) is

      3  1  2
      6  4  5
      9  7  8

and the value of CSHIFT(M, SHIFT = (/ -1, 1, 0 /), DIM = 2) is

      3  1  2
      5  6  4
      7  8  9

DATE(DATESTR)

Description. Return current system date.

Class. Nonstandard subroutine.

Argument. DATESTR must be of type character. It must be a character string of length 9 or more.

Example.

The following program gets and prints the current system date. Its output could be, for example, "12-Jul-96" (without the quotes).

PROGRAM datetest
CHARACTER(9) :: today
INTRINSIC DATE
CALL DATE(today)
PRINT *, today
END

DATE_AND_TIME(DATE, TIME, ZONE, VALUES)

Optional Arguments. DATE, TIME, ZONE, VALUES

Description. Returns data on the real-time clock and date in a form compatible with the representations defined in ISO 8601:1988 ("Data elements and interchange formats — Information interchange — Representation of dates and times").

Class. Subroutine.

Arguments.

DATE (optional)

must be scalar and of type default character, and must be of length at least 8 in order to contain the complete value. It is an INTENT(OUT) argument. Its leftmost 8 characters are set to a value of the form CCYYMMDD, where CC is the century, YY the year within the century, MM the month within the year, and DD the day within the month. If there is no date available, they are set to blank.

TIME (optional)

must be scalar and of type default character, and must be of length at least 10 in order to contain the complete value. It is an INTENT(OUT) argument. Its leftmost 10 characters are set to a value of the form hhmmss.sss, where hh is the hour of the day, mm is the minutes of the hour, and ss.sss is the seconds and milliseconds of the minute. If there is no clock available, they are set to blank.

ZONE (optional)

must be scalar and of type default character, and must be of length at least 5 in order to contain the complete value. It is an INTENT(OUT) argument. Its leftmost 5 characters are set to a value of the form (+/-)hhmm, where hh and mm are the time difference with respect to Coordinated Universal Time (UTC) in hours and parts of an hour expressed in minutes, respectively. If there is no clock available, they are set to blank.

VALUES (optional)

must be of type default integer and of rank one. It is an INTENT(OUT) argument. Its size must be at least 8. The values returned in VALUES are as follows:

VALUES(1)

the year (for example, 1990), or -HUGE(0) if there is no date available;

VALUES(2)

the month of the year, or -HUGE(0) if there is no date available;

VALUES(3)

the day of the month, or -HUGE(0) if there is no date available;

VALUES(4)

the time difference with respect to Coordinated Universal Time (UTC) in minutes, or -HUGE(0) if this information is not available;

VALUES(5)

the hour of the day, in the range of 0 to 23, or -HUGE(0) if there is no clock;

VALUES(6)

the minutes of the hour, in the range 0 to 59, or -HUGE(0) if there is no clock;

VALUES(7)

the seconds of the minute, in the range 0 to 60, or -HUGE(0) if there is no clock;

VALUES(8)

the milliseconds of the second, in the range 0 to 999, or -HUGE(0) if there is no clock.

The HUGE intrinsic function is described in “HUGE(X) ”.

Example.

INTEGER DATE_TIME (8)
CHARACTER (LEN = 10) BIG_BEN (3)
CALL DATE_AND_TIME (BIG_BEN (1), BIG_BEN (2), &
BIG_BEN (3), DATE_TIME)

if called in Geneva, Switzerland on 1985 April 12 at 15:27:35.5 would have assigned the value "19850412bb" to BIG_BEN(1), the value "152735.500" to BIG_BEN(2), and the value "+0100bbbbb" to BIG_BEN(3), and the following values to DATE_TIME: 1985, 4, 12, 60, 15, 27, 35, 500.

Note that UTC is defined by CCIR Recommendation 460-2 (and is also known as Greenwich Mean Time).

DBLE(A)

Description. Convert to double precision real type.

Class. Elemental function.

Argument. A must be of type integer, real, or complex.

Result Type and Type Parameter. Double precision real.

Result Value.

Case 1

If A is of type double precision real, DBLE(A) = A.

Case 2

If A is of type integer or real, the result is as much precision of the significant part of A as a double precision real datum can contain.

Case 3

If A is of type complex, the result is as much precision of the significant part of the real part of A as a double precision real datum can contain.

Examples.

DBLE(-.3) is -0.3 of type double precision real.

DBLE(1.0_HIGH/3) is 0.33333333333333 of type double precision real.

DCMPLX(X,Y)

Optional Argument. Y

Description. Convert to double precision complex type.

Class. Elemental nonstandard function.

Arguments.

X

must be of type integer, real, or complex.

Y

must not be supplied if X is of type complex; otherwise is optional and must be of the same type and kind type parameter as X.

Result Type and Type Parameter. Double precision complex.

Examples.

DCMPLX(56) is (56.0, 0.0) of type double precision complex.

The following code:

PROGRAM dcmplxtst
INTEGER(2) x, y
DOUBLE COMPLEX dc
x = 452
y = 2
dc = DCMPLX(x, y)
PRINT *, dc
END

Produces this output:

(452.0,2.0)

DFLOAT(A)

Description. Convert to double precision type.

Class. Elemental nonstandard function.

Argument. A must be of type integer.

Result Type and Type Parameter. Double precision.

Example.

DFLOAT(56) is 56.0 of type double precision.

DIGITS(X)

Description. Returns the number of significant digits in the model representing numbers of the same type and kind type parameter as the argument.

Class. Inquiry function.

Argument. X must be of type integer or real. It may be scalar or array valued.

Result Type, Type Parameter, and Shape. Default integer scalar.

Result Value. The result has the value q if X is of type integer and p if X is of type real, where q and p are as defined in “Data representation models” for the model representing numbers of the same type and kind type parameter as X.

Example. DIGITS(X) has the value 24 for real X whose model is described in “The real number system model”.

DIM(X, Y)

Description. The difference X-Y if it is positive; otherwise zero.

Class. Elemental function.

Arguments.

X

must be of type integer or real.

Y

must be of the same type and kind type parameter as X.

Result Type and Type Parameter. Same as X.

Result Value. The value of the result is X-Y if X > Y and zero otherwise.

Examples. DIM(5, 3) has the value 2. DIM(-3.0, 2.0) has the value 0.0.

DNUM(I)

Description. Convert to double precision.

Class. Elemental nonstandard function.

Argument. I must be of type character.

Result Type. Double precision.

Examples.

DNUM("3.14159") is 3.14159 of type double precision.

The following code sets x to 311.0:

  CHARACTER(3) i
DOUBLE PRECISION x
i = "311"
x = DNUM(I)

DOT_PRODUCT(VECTOR_A, VECTOR_B)

Description. Performs dot-product multiplication of numeric or logical vectors.

Class. Transformational function.

Arguments.

VECTOR_A

must be of numeric type (integer, real, or complex) or of logical type. It must be array valued and of rank one.

VECTOR_B

must be of numeric type if VECTOR_A is of numeric type or of type logical if VECTOR_A is of type logical. It must be array valued and of rank one. It must be of the same size as VECTOR_A.

Result Type, Type Parameter, and Shape. The result is scalar.

If the arguments are of numeric type, the type and kind type parameter of the result are those of the expression VECTOR_A * VECTOR_B determined by the types of the arguments.

If the arguments are of type logical, the result is of type logical with the kind type parameter of the expression VECTOR_A .AND. VECTOR_B.

Result Value.

Case 1

If VECTOR_A is of type integer or real, the result has the value SUM(VECTOR_A*VECTOR_B). If the vectors have size zero, the result has the value zero.

Case 2

If VECTOR_A is of type complex, the result has the value SUM(CONJG(VECTOR_A)*VECTOR_B). If the vectors have size zero, the result has the value zero.

Case 3

If VECTOR_A is of type logical, the result has the value ANY(VECTOR_A .AND. VECTOR_B). If the vectors have size zero, the result has the value .FALSE..

Examples.

Case 1

DOT_PRODUCT( (/ 1, 2, 3 /), (/ 2, 3, 4 /) ) has the value 20.

Case 2

DOT_PRODUCT( (/ (1.0, 2.0), (2.0, 3.0) /), (/ (1.0, 1.0), (1.0, 4.0) /) ) has the value 17 + 4i.

Case 3

DOT_PRODUCT( (/ .TRUE., .FALSE. /), (/ .TRUE., .TRUE. /) ) has the value .TRUE..

DPROD(X, Y)

Description. Double precision real product.

Class. Elemental function.

Arguments.

X

must be of type default real.

Y

must be of type default real.

Result Type and Type Parameters. Double precision real.

Result Value. The result has a value equal to a processor-dependent approximation to the product of X and Y.

Example. DPROD(-3.0, 2.0) has the value -6.0 of type double precision real.

DREAL(A)

Description. Convert to double precision.

Class. Elemental nonstandard function.

Argument. A must be of type integer, real, or complex.

Result. Double precision.

Examples.

DREAL(91) is 91.0 of type double precision.

The following code sets x to 45.34:

  COMPLEX p
DOUBLE PRECISION x
p = (45.34, 1.0)
x = DREAL(p)

EOSHIFT(ARRAY, SHIFT, BOUNDARY, DIM)

Optional Arguments. BOUNDARY, DIM

Description. Perform an end-off shift on an array expression of rank one or perform end-off shifts on all the complete rank-one sections along a given dimension of an array expression of rank two or greater.

Elements are shifted off at one end of a section and copies of a boundary value are shifted in at the other end.

Different sections may have different boundary values and may be shifted by different amounts and in different directions (positive for left shifts, negative for right shifts).

Class. Transformational function.

Arguments.

ARRAY

may be of any type. It must not be scalar.

SHIFT

must be of type integer and must be scalar if ARRAY has rank one; otherwise, it must be scalar or of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn) where (d1, d2, ..., dn) is the shape of ARRAY.

BOUNDARY (optional)

must be of the same type and type parameters as ARRAY and must be scalar if ARRAY has rank one; otherwise, it must be either scalar or of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn). BOUNDARY may be omitted for the data types in the following table and, in this case, it is as if it were present with the scalar value shown.

Table 11-8 Title not available (EOSHIFT(ARRAY, SHIFT, BOUNDARY, DIM) )

Type of ARRAY

Value of BOUNDARY

Integer

0

Real

0.0

Complex

(0.0, 0.0)

Logical

.FALSE.

Character (len)

len blanks

 

DIM (optional)

must be scalar and of type integer with a value in the range 1 <= DIM <= n, where n is the rank of ARRAY. If DIM is omitted, it is as if it were present with the value 1.

Result Type, Type Parameter, and Shape. The result has the type, type parameters, and shape of ARRAY.

Result Value. Element (s1, s1, ..., sn) of the result has the value ARRAY (s1, s2, ..., sDIM-1, sDIM + sh, sDIM+1, ..., sn) where sh is SHIFT or SHIFT(s1, s2, ..., sDIM-1, sDIM+1, ..., sn) provided the inequality LBOUND(ARRAY, DIM) <= sDIM + sh <= UBOUND(ARRAY, DIM) holds and is otherwise BOUNDARY or BOUNDARY(s1, s2, ..., sDIM-1, sDIM+1, ..., sn).

Examples.

Case 1

If V is the array [1, 2, 3, 4, 5, 6], the effect of shifting V end-off to the left by 3 positions is achieved by EOSHIFT(V, SHIFT = 3) which has the value [4, 5, 6, 0, 0, 0].

EOSHIFT(V, SHIFT = -2, BOUNDARY = 99) achieves an end-off shift to the right by 2 positions with the boundary value of 99 and has the value [99, 99, 1, 2, 3, 4].

Case 2

The rows of an array of rank two may all be shifted by the same amount or by different amounts and the boundary elements can be the same or different. If M is the array

      A  B  C
      D  E  F
      G  H  I

then the value of EOSHIFT(M, SHIFT = -1, BOUNDARY = '*', DIM = 2) is

      *  A  B
      *  D  E
      *  G  H

and the value of EOSHIFT(M, SHIFT = (/ -1, 1, 0 /), BOUNDARY = (/ '*', '/', '?' /), DIM = 2) is

      *  A  B
      E  F  /
      G  H  I

EPSILON(X)

Description. Returns a positive model number that is almost negligible compared to unity in the model representing numbers of the same type and kind type parameter as the argument.

Class. Inquiry function.

Argument. X must be of type real. It may be scalar or array valued.

Result Type, Type Parameter, and Shape. Scalar of the same type and kind type parameter as X.

Result Value. The result has the value b1-p where b and p are as defined in “The real number system model” for the model representing numbers of the same type and kind type parameter as X.

Examples.

EPSILON(X) has the value 2-23 for real X whose model is described in “The real number system model”.

EPSILON(Y), where Y has kind parameter HIGH, would be 2-47 if p is 48 for the model of kind HIGH.

EXIT(STATUS)

Optional Argument. STATUS

Description. Close all files and terminate the program.

Class. Nonstandard subroutine.

Argument. STATUS must be of type integer.

If STATUS is supplied, the calling program exits with a return code status of STATUS. Otherwise the return code status is indeterminate.

In csh the $status environment variable holds the return code for the last executed command. In ksh, the $? environment variable holds the return code

Example.

The following program exits before the second PRINT statement.

PROGRAM testexit
INTRINSIC EXIT
INTEGER stat
PRINT *, "Program prints this line."
stat = 3
CALL EXIT(stat)
PRINT *, "Program exits before this line."
END

This program produces the following output:

Program prints this line.

The return code is saved in the $status or $? environment variable; it is not printed.

EXP(X)

Description. Exponential.

Class. Elemental function.

Argument. X must be of type real or complex.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to ex. If X is of type complex, its imaginary part is regarded as a value in radians.

Examples.

EXP(1.0) has the value 2.7182818.

EXP(2.0_HIGH/3.0) has the value 1.9477340410547 with kind HIGH.

EXPONENT(X)

Description. Returns the exponent part of the argument when represented as a model number.

Class. Elemental function.

Argument. X must be of type real.

Result Type. Default integer.

Result Value. The result has a value equal to the exponent e of the model representation (see “The real number system model”) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.

Examples.

EXPONENT(1.0) has the value 1 and EXPONENT(4.1) has the value 3 for reals, whose model is described in “The real number system model”.

FLOOR(A)

Description. Returns the greatest integer less than or equal to its argument.

Class. Elemental function.

Argument. A must be of type real.

Result Type and Type Parameter. Default integer.

Result Value. The result has a value equal to the greatest integer less than or equal to A. The result is undefined if the processor cannot represent this value in the default integer type.

Examples.

FLOOR(3.7) has the value 3.

FLOOR(-3.7) has the value -4.

FLOOR(10.0_HIGH/3) has the value 3.

FLUSH(LUNIT)

Description. Flush pending I/O on a logical unit.

Class. Nonstandard subroutine.

For details see FLUSH in Table 11-6 “ Generic and specific intrinsic procedures”.

FNUM(UNIT)

Description. Get an operating system file descriptor.

Class. Inquiry nonstandard function.

For details see FNUM in Table 11-6 “ Generic and specific intrinsic procedures”.

FRACTION(X)

Description. Returns the fractional part of the model representation of the argument value.

Class. Elemental function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. The result has the value X * b-e, where b and e are as defined in “The real number system model”. If X has the value zero, the result has the value zero.

Example. FRACTION(3.0) has the value 0.75 for reals, whose model is described in “The real number system model”.

FREE(P)

Description. Free a block of memory.

Class. Nonstandard subroutine.

For details see FREE in Table 11-6 “ Generic and specific intrinsic procedures”.

FSET(UNIT, NEWFD, OLDFD)

Description. Attach a system file descriptor to a logical unit.

Class. Nonstandard subroutine.

For details see FSET in Table 11-6 “ Generic and specific intrinsic procedures”.

FSTREAM(UNIT)

Description. Retrieve a C language FILE stream pointer.

Class. Inquiry nonstandard function.

For details see FSTREAM in Table 11-6 “ Generic and specific intrinsic procedures”.

GETARG(N, STRING)

Description. Get the arguments passed to the program.

Class. Nonstandard subroutine.

Arguments.

N

must be of type integer. N specifies which command-line argument is requested. When N=1, it returns the program name. When N=0, it returns all blanks.

STRING

must be a character variable. It is assigned the requested command-line argument, padded with blanks on the end. If the requested argument is longer than STRING, a truncated version is assigned to STRING.

Example.

The following code assigns arg the value of the first argument passed to the program.

  CHARACTER(10) arg
CALL GETARG(2, arg)

GETENV(VAR, VALUE)

Description. Return the value of a system environment variable.

Class. Nonstandard subroutine.

Arguments. VAR and VALUE are of type character. VAR specifies the environment variable name. The character variable VALUE is assigned the environment variable's value. VALUE must be declared large enough to hold the value. If the environment variable is not defined VALUE is set to all blanks.

Example.

The following code assigns val the value of the TERM environment variable.

CHARACTER(10) val
CALL GETENV("TERM", val)

GRAN()

Description. Generate Gaussian normal random numbers.

Class. Elemental nonstandard function.

Result. REAL(4). The numbers generated by GRAN have a mean of 0.0, a standard deviation of 1.0, and a range of approximately -5.0 through +5.0.

Examples.

y=GRAN() assigns the REAL(4) scalar y a random value.

For a REAL(4) array x, x=GRAN() sets all elements of x to the same random value; a separate call to GRAN to assign each element would provide different values.

HFIX(A)

Description. Convert to INTEGER(2) type.

Class. Elemental nonstandard function.

Argument. A must be of type integer, real, double precision, or complex.

Result. INTEGER(2) type.

Examples.

HFIX(9.897) is 9 of type INTEGER(2).

HFIX(9.125) is 9 of type INTEGER(2).

The following code sets b to 34:

  INTEGER(2) b
COMPLEX p
p = (34.5, 1.0)
b = HFIX(p)

HUGE(X)

Description. Returns the largest number in the model representing numbers of the same type and kind type parameter as the argument.

Class. Inquiry function.

Argument. X must be of type integer or real. It may be scalar or array valued.

Result Type, Type Parameter, and Shape. Scalar of the same type and kind type parameter as X.

Result Value. The result has the value rq - 1 if X is of type integer and

(1 - b-p) b ** emax

if X is of type real, where r, q, b, p, and emax are as defined in “The real number system model”.

Example. HUGE(X) has the value (1 - 2-24) * 2127 for real X, whose model is described in “The real number system model”.

IACHAR(C)

Description. Returns the position of a character in the ASCII collating sequence.

Class. Elemental function.

Argument. C must be of type default character and of length one.

Result Type and Type Parameter. Default integer.

Result Value. If C is in the collating sequence defined by the codes specified in ISO 646:1983 ("Information technology — ISO 7-bit coded character set for information interchange"), the result is the position of C in that sequence and satisfies the inequality (0 <= IACHAR(C) <= 127).

A processor-dependent value is returned if C is not in the ASCII collating sequence. The results are consistent with the LGE, LGT, LLE, and LLT lexical comparison functions. For example, if LLE(C, D) is .TRUE., IACHAR(C) .LE. IACHAR(D) is .TRUE. where C and D are any two characters representable by the processor.

Examples.

IACHAR('X') has the value 88.

IACHAR('*') has the value 42.

IADDR(X)

Description. Return the address of X.

Class. Inquiry nonstandard function.

Argument. X may be of any type.

Result Type. The result is of type default integer.

See “BADDRESS(X)” for examples.

IAND(I, J)

Description. Performs a bitwise logical AND.

Class. Elemental function.

Arguments.

I

must be of type integer.

J

must be of type integer with the same kind type parameter as I.

Result Type and Type Parameter. Same as I.

Result Value. The result has the value obtained by combining I and J bit-by-bit according to the following truth table:

Table 11-9 Title not available (IAND(I, J) )

I

J

IAND(I, J)

1

1

1

1

0

0

0

1

0

0

0

0

 

The model for the interpretation of an integer value as a sequence of bits is in “The bit model”.

Examples.

IAND(1, 3) has the value 1.

IAND(2_SHORT, 10_SHORT) is 2 with kind SHORT.

IARGC()

Description. Get the number of arguments passed to the program.

Class. Elemental nonstandard function.

Result Type. Integer.

Result Value. If no arguments are passed to the program, IARGC returns zero. Otherwise IARGC returns a count of the arguments that follow the program name on the command line.

Example.

The statement PRINT *,IARGC() prints a count of the arguments passed to the program.

IBCLR(I, POS)

Description. Clears a bit to zero.

Class. Elemental function.

Arguments.

I

must be of type integer.

POS

must be of type integer. It must be nonnegative and less than BIT_SIZE(I).

Result Type and Type Parameter. Same as I.

Result Value. The result has the value of the sequence of bits of I, except that bit POS of I is set to zero. The model for the interpretation of an integer value as a sequence of bits is in “The bit model”.

Examples.

IBCLR(14, 1) has the result 12.

If V has the value (1, 2, 3, 4), the value of IBCLR(POS = V, I = 31) is [29, 27, 23, 15].

The value of IBCLR((/ 15_SHORT, 31_SHORT, 7_SHORT /), 3) is [7, 23, 7] with kind SHORT.

IBITS(I, POS, LEN)

Description. Extracts a sequence of bits.

Class. Elemental function.

Arguments.

I

must be of type integer.

POS

must be of type integer. It must be nonnegative and POS + LEN must be less than or equal to BIT_SIZE(I).

LEN

must be of type integer and nonnegative.

Result Type and Type Parameter. Same as I.

Result Value. The result has the value of the sequence of LEN bits in I beginning at bit POS, right-adjusted and with all other bits zero. The model for the interpretation of an integer value as a sequence of bits is in “The bit model”.

Examples.

IBITS(14, 1, 3) has the value 7.

The value of IBITS((/ 15_SHORT, 31_SHORT, 7_SHORT /), 2_SHORT, 3_SHORT) is [3, 7, 1] with kind SHORT.

IBSET(I, POS)

Description. Sets a bit to one.

Class. Elemental function.

Arguments.

I

must be of type integer.

POS

must be of type integer. It must be nonnegative and less than BIT_SIZE(I).

Result Type and Type Parameter. Same as I.

Result Value. The result has the value of the sequence of bits of I, except that bit POS of I is set to one. The model for the interpretation of an integer value as a sequence of bits is in “The bit model”.

Examples.

IBSET(12, 1) has the value 14.

If V has the value [1, 2, 3, 4], the value of IBSET(POS = V, I = 0) is [2, 4, 8, 16].

The value of IBSET((/ 15_SHORT, 31_SHORT, 7_SHORT /), 3) is [15, 31, 15] with kind SHORT.

ICHAR(C)

Description. Returns the position of a character in the processor collating sequence associated with the kind type parameter of the character.

Class. Elemental function.

Argument. C must be of type character and of length one. Its value must be that of a character capable of representation in the processor.

Result Type and Type Parameter. Default integer.

Result Value. The result is the position of C in the processor collating sequence associated with the kind type parameter of C and is in the range 0 <= IACHAR(C) <n-1, where n is the number of characters in the collating sequence.

For any characters C and D capable of representation in the processor, C.LE.D is .TRUE. if and only if ICHAR(C) .LE. ICHAR(D) is .TRUE., and C.EQ.D is .TRUE. if and only if ICHAR(C).EQ. ICHAR(D) is .TRUE..

Examples.

ICHAR('X') has the value 88 on a processor using the ASCII collating sequence for the default character type.

ICHAR('*') has the value 42 on such a processor.

IDATE(MONTH, DAY, YEAR)

Description. Return the month, day, and year of current system.

Class. Nonstandard subroutine.

Arguments. MONTH, DAY, and YEAR must be of type integer.

Example.

The statement CALL IDATE(mon,da,yr) sets mon to the month number, da to the day of the month, and yr to the two-digit year representation (for example, 69 for the year 1969).

IDIM(X, Y)

Description. Integer positive difference.

Class. Nonstandard function.

Arguments.

X

must be of type integer.

Y

must be of type integer with the same kind type parameter as X.

Result Type and Type Parameter. Integer of same kind type parameter as X.

Result Value. If X > Y, IDIM(X, Y) is X-Y. If X <= Y, IDIM(X, Y) is zero.

Examples.

IDIM(89, 12) is 77.

IDIM(56, 59) is 0.

IEOR(I, J)

Description. Performs a bitwise exclusive OR.

Class. Elemental function.

Arguments.

I

must be of type integer.

J

must be of type integer with the same kind type parameter as I.

Result Type and Type Parameter. Same as I.

Result Value. The result has the value obtained by combining I and J bit-by-bit according to the following truth table:

Table 11-10 Title not available (IEOR(I, J) )

I

J

IEOR(I, J)

1

1

0

1

0

1

0

1

1

0

0

0

 

The model for the interpretation of an integer value as a sequence of bits is in “The bit model”.

Examples.

IEOR(1, 3) has the value 2.

IEOR( (/ 3_SHORT, 10_SHORT /), 2_SHORT) is [1, 8] with kind SHORT.

IGETARG(N, STR, STRLEN)

Description. Get command-line argument.

Class. Inquiry nonstandard function.

Arguments.

N

must be of type integer. N specifies which command-line argument is requested. When N=0, it returns the program name.

STR

must be a character variable. It is assigned first STRLEN characters of the requested command-line argument, padded with blanks on the end. If the requested argument is longer than STR, a truncated version is assigned to STR.

STRLEN

must be of type integer. STRLEN specifies the number of characters of argument N to assign to STR.

Result Value. IGETARG returns an integer value, either -1 if the requested argument was not found, or a positive integer that indicates the number of characters copied from the command line to STR.

Example.

The following code copies the first six characters of the second command-line argument to the character variable str.

  INTEGER n
CHARACTER(10) str
n = IGETARG(2, str, 6)

IJINT(A)

Description. Convert to INTEGER(2) type.

Class. Elemental nonstandard function.

Argument. A must be of type INTEGER(4).

Result. INTEGER(2) type.

Example. IJINT(32) is 32 of type INTEGER(2).

IMAG(A)

Description. Imaginary part of complex number.

Class. Elemental nonstandard function.

Argument. A must be of type complex or double complex.

Result. Real if A is complex. Double precision if A is double complex.

Example.

The following code sets x to 2.0:

  COMPLEX p
REAL x
p = (39.61, 2.0)
x = IMAG(p)

INDEX(STRING, SUBSTRING, BACK)

Optional Argument. BACK

Description. Returns the starting position of a substring within a string.

Class. Elemental function.

Arguments.

STRING

must be of type character.

SUBSTRING

must be of type character with the same kind type parameter as STRING.

BACK (optional)

must be of type logical.

Result Type and Type Parameter. Default integer.

Result Value.

Case 1

If BACK is absent or present with the value .FALSE., the result is the minimum positive value of I such that STRING(I : I + LEN(SUBSTRING) - 1) = SUBSTRING or zero if there is no such value.

Zero is returned if LEN(STRING) < LEN(SUBSTRING) and one is returned if LEN(SUBSTRING) = 0.

Case 2

If BACK is present with the value .TRUE., the result is the maximum value of I less than or equal to LEN(STRING) - LEN(SUBSTRING) + 1 such that STRING(I : I + LEN(SUBSTRING) - 1) = SUBSTRING or zero if there is no such value.

Zero is returned if LEN(STRING) < LEN(SUBSTRING) and LEN(STRING) + 1 is returned if LEN(SUBSTRING) = 0.

Examples.

INDEX('FORTRAN', 'R') has the value 3.

INDEX('FORTRAN', 'R', BACK = .TRUE.) has the value 5.

INDEX("XXX", "") has the value 1.

INDEX("XXX", "", BACK=.TRUE.) has the value 4.

INT(A, KIND)

Optional Argument. KIND

Description. Convert to integer type.

Class. Elemental function.

Arguments.

A

must be of type integer, real, or complex.

KIND (optional)

must be a scalar integer initialization expression.

Result Type and Type Parameter. Integer. If KIND is present, the kind type parameter is that specified by KIND; otherwise, the kind type parameter is that of default integer type.

Result Value.

Case 1

If A is of type integer, INT(A) = A.

Case 2

If A is of type real, there are two cases: if |A| < 1, INT(A) has the value 0; if |A| >= 1, INT(A) is the integer whose magnitude is the largest integer that does not exceed the magnitude of A and whose sign is the same as the sign of A.

Case 3

If A is of type complex, INT(A) is the value obtained by applying the above rules (for reals) to the real part of A. The result is undefined if the processor cannot represent the result in the specified integer type.

Examples.

INT(-3.7) has the value -3.

INT(9.1_HIGH/4.0_HIGH, SHORT) is 2 with kind SHORT.

INT1(A)

Description. Convert to INTEGER(1) type.

Class. Elemental nonstandard function.

Argument. A must be of type integer, real, or complex.

Result. INTEGER(1) type. If A is complex, INT1(A) is equal to the truncated real portion of A.

Example. INT1(6.23) is 6 of type INTEGER(1).

INT2(A)

Description. Convert to INTEGER(2) type.

Class. Elemental nonstandard function.

Argument. A must be of type integer, real, or complex.

Result. INTEGER(2) type. If A is complex, INT2(A) is equal to the truncated real portion of A.

Example. INT2(212.4545) is 212 of type INTEGER(2).

INT4(A)

Description. Convert to INTEGER(4) type.

Class. Elemental nonstandard function.

Argument. A must be of type integer, real, or complex.

Result. INTEGER(4) type. If A is complex, INT4(A) is equal to the truncated real portion of A.

Example. INT4(1988.74) is 1988 of type INTEGER(4).

INT8(A)

Description. Convert to INTEGER(8) type.

Class. Elemental nonstandard function.

Argument. A must be of type integer, real, or complex.

Result. INTEGER(8) type. If A is complex, INT8(A) is equal to the truncated real portion of A.

Example. INT8(14.14) is 14 of type INTEGER(8).

INUM(I)

Description. Convert character to INTEGER(2) type.

Class. Elemental nonstandard function.

Argument. I must be of type character.

Result. INTEGER(2) type.

Example. INUM("451.92") is 451 of type INTEGER(2).

IOMSG(N, MSG)

Description. Print the text for an I/O message.

Class. Nonstandard subroutine.

For details see IOMSG in Table 11-6 “ Generic and specific intrinsic procedures”.

IOR(I, J)

Description. Performs a bitwise inclusive OR.

Class. Elemental function.

Arguments.

I

must be of type integer.

J

must be of type integer with the same kind type parameter as I.

Result Type and Type Parameter. Same as I.

Result Value. The result has the value obtained by combining I and J bit-by-bit according to the following truth table:

Table 11-11 Title not available (IOR(I, J) )

I

J

IOR(I, J)

1

1

1

1

0

1

0

1

1

0

0

0

 

The model for the interpretation of an integer value as a sequence of bits is in “The bit model”.

Examples.

IOR(1, 3) has the value 3.

IOR( (/ 3_SHORT, 2_SHORT /),(/ 1_SHORT, 10_SHORT /) ) is [3_SHORT, 10_SHORT].

IQINT(A)

Description. Convert to integer type.

Class. Elemental nonstandard function.

Argument. A must be of type REAL(16).

Result. Integer type.

Examples. IQINT(9416.39) is 9416.

IRAND()

Description. Generate pseudorandom numbers.

Class. Elemental nonstandard function.

Result Type and Type Parameter. INTEGER(4) type.

Result Value. IRAND generates numbers in the range 0 through 215-1.

Example.

INTEGER(4) rn
rn = IRAND()

Notes.

For details about restarting the pseudorandom number generator used by IRAND and RAND, see “SRAND(ISEED)”.

IRANP(X)

Description. Generate Poisson-distributed random numbers.

Class. Elemental nonstandard function.

Argument. X must be of REAL(4) type and must be in the range 0.0 through 87.33. For better performance, it is recommended that X be less than 50.0 (see "Result Value" below).

Result Type and Type Parameter. INTEGER(4) type.

Result Value.

IRANP returns an error code of -1 if X <= 0.0.

IRANP returns an error code of -2 if X > 87.33.

IRANP calculates exponentially distributed random numbers until the product is less than exp(-X). The random number returned by IRANP is the number of exponentials needed, minus 1. IRANP makes an average of X+1 calls to RAND, so it is recommended that X be less than 50.

Example.

INTEGER(4) irn
irn = IRANP(29.11)

ISHFT(I, SHIFT)

Description. Performs a logical shift.

Class. Elemental function.

Arguments.

I

must be of type integer.

SHIFT

must be of type integer. The absolute value of SHIFT must be less than or equal to BIT_SIZE(I).

Result Type and Type Parameter. Same as I.

Result Value. The result has the value obtained by shifting the bits of I by SHIFT positions.

If SHIFT is positive, the shift is to the left; if SHIFT is negative, the shift is to the right; and if SHIFT is zero, no shift is performed. Bits shifted out from the left or from the right, as appropriate, are lost. Zeros are shifted in from the opposite end.

The model for the interpretation of an integer value as a sequence of bits is in “The bit model”.

Examples.

ISHFT(3, 1) has the value 6.

ISHFT(3, -1) has the value 1.

ISHFTC(I, SHIFT, SIZE)

Optional Argument. SIZE

Description. Performs a circular shift of the rightmost bits.

Class. Elemental function.

Arguments.

I

must be of type integer.

SHIFT

must be of type integer. The absolute value of SHIFT must be less than or equal to SIZE.

SIZE (optional)

must be of type integer. The value of SIZE must be positive and must not exceed BIT_SIZE(I). If SIZE is absent, it is as if it were present with the value of BIT_SIZE(I).

Result Type and Type Parameter. Same as I.

Result Value. The result has the value obtained by shifting the SIZE rightmost bits of I circularly by SHIFT positions.

If SHIFT is positive, the shift is to the left; if SHIFT is negative, the shift is to the right; and if SHIFT is zero, no shift is performed. No bits are lost. The unshifted bits are unaltered.

The model for the interpretation of an integer value as a sequence of bits is in “The bit model”.

Example. ISHFTC(3, 2, 3) has the value 5.

ISIGN(A, B)

Description. Absolute value of A times the sign of B.

Class. Elemental nonstandard function.

Arguments.

A

must be of type integer.

B

must be of type integer with the same kind type parameter as A.

Result Type and Type Parameter. Same as A.

Result Value. The value of the result is |A| if B>= 0 and -|A| if B < 0.

Examples.

ISIGN(-3, 0) is 3.

ISIGN(12, -9) is -12.

ISNAN(X)

Description. Determine if a value is NaN (not a number).

Class. Elemental nonstandard function.

Argument. X must be of type real.

Result Type. Logical.

Examples.

ISNAN(45.4) is .FALSE..

ISNAN(ACOSH(0.0)) is .TRUE..

IXOR(I, J)

Description. Exclusive OR.

Class. Elemental nonstandard function.

Arguments.

I

must be of type integer.

J

must be of type integer with the same kind type parameter as I.

Result Type and Type Parameter. Same as I.

Result Value. The result has the value obtained by performing an exclusive OR on I and J bit-by-bit according to the truth table that follows.

Table 11-12 Title not available (IXOR(I, J))

I

J

IXOR(I, J)

1

1

0

1

0

1

0

1

1

0

0

0

 

The model for interpreting an integer value as a sequence of bits is in “The bit model”.

Example. IXOR(12, 7) is 11. (Binary 1100 exclusive OR with binary 0111 is binary 1011.)

IZEXT(A)

Description. Zero extend.

Class. Generic elemental nonstandard function.

Argument.

A

must be of type INTEGER(1), INTEGER(2), LOGICAL(1), or LOGICAL(2).

Result Type and Type Parameter. The result is of type INTEGER(2).

Result. IZEXT converts A to INTEGER(2) by sign-extending zeroes instead of the actual sign bit.

JNUM(I)

Description. Convert character to integer type.

Class. Elemental nonstandard function.

Argument. I must be of type character.

Result. Integer type.

Example. JNUM("46616.725") is 46616.

JZEXT(A)

Description. Zero extend.

Class. Generic elemental nonstandard function.

Argument.

A

must be of type INTEGER(1), INTEGER(2), INTEGER(4), LOGICAL(1), LOGICAL(2), or LOGICAL(4).

Result Type and Type Parameter. The result is of type INTEGER(4).

Result. IZEXT converts A to INTEGER(4) by sign-extending zeroes instead of the actual sign bit.

KIND(X)

Description. Returns the value of the kind type parameter of X.

Class. Inquiry function.

Argument. X may be of any intrinsic type.

Result Type, Type Parameter, and Shape. Default integer scalar.

Result Value. The result has a value equal to the kind type parameter value of X.

Examples.

KIND(0.0) has the kind type parameter value of default real.

KIND(1.0_HIGH) has the value of the named constant HIGH.

KZEXT(A)

Description. Zero extend.

Class. Generic elemental nonstandard function.

Argument.

A

must be of type INTEGER(1), INTEGER(2), INTEGER(4), INTEGER(8), LOGICAL(1), LOGICAL(2), LOGICAL(4), or LOGICAL(8).

Result Type and Type Parameter. The result is of type INTEGER(8).

Result. IZEXT converts A to INTEGER(8) by sign-extending zeroes instead of the actual sign bit.

LBOUND(ARRAY, DIM)

Optional Argument. DIM

Description. Returns all the lower bounds or a specified lower bound of an array.

Class. Inquiry function.

Arguments.

ARRAY

may be of any type. It must not be scalar. It must not be a pointer that is disassociated or an allocatable array that is not allocated.

DIM (optional)

must be scalar and of type integer with a value in the range 1 <= DIM <= n, where n is the rank of ARRAY. The corresponding actual argument must not be an optional dummy argument.

Result Type, Type Parameter, and Shape. The result is of type default integer. It is scalar if DIM is present; otherwise, the result is an array of rank one and size n, where n is the rank of ARRAY.

Result Value.

Case 1

For an array section or for an array expression other than a whole array or array structure component, LBOUND(ARRAY, DIM) has the value 1. For a whole array or array structure component, LBOUND(ARRAY, DIM) has the value:

  • equal to the lower bound for subscript DIM of ARRAY if dimension DIM of ARRAY does not have extent zero or if ARRAY is an assumed-size array of rank DIM

    or

  • one (1), otherwise.

Case 2

LBOUND(ARRAY) has a value whose ith component is equal to LBOUND(ARRAY, i), for i= 1, 2, ..., n, where n is the rank of ARRAY.

Examples. If the following statements are processed

REAL, TARGET :: A (2:3, 7:10)
REAL, POINTER, DIMENSION (:,:) :: B, C, D
B => A
C => A(:,:)
ALLOCATE ( D(-3:3,-7:7) )

LBOUND(A) is [2, 7], LBOUND(A, DIM=2) is 7, LBOUND(B) is [2,7], LBOUND(C) is [1,1], and LBOUND(D) is [-3,-7].

LEN(STRING)

Description. Returns the length of a character entity.

Class. Inquiry function.

Argument. STRING must be of type character. It may be scalar or array valued.

Result Type, Type Parameter, and Shape. Default integer scalar.

Result Value. The result has a value equal to the number of characters in STRING if it is scalar or in an element of STRING if it is array valued.

Example. If C and D are declared by the statements

CHARACTER (11) C(100) 
CHARACTER (LEN=31) D

LEN(C) has the value 11, and LEN(D) has the value 31.

LEN_TRIM(STRING)

Description. Returns the length of the character argument without counting trailing blank characters.

Class. Elemental function.

Argument. STRING must be of type character.

Result Type and Type Parameter. Default integer.

Result Value. The result has a value equal to the number of characters remaining after any trailing blanks in STRING are removed. If the argument contains no nonblank characters, the result is zero.

Examples.

LEN_TRIM('bAbBbb') has the value 4.

LEN_TRIM('bbb') has the value 0.

LGE(STRING_A, STRING_B)

Description. Tests whether a string is lexically greater than or equal to another string, based on the ASCII collating sequence.

Class. Elemental function.

Arguments.

STRING_A

must be of type default character.

STRING_B

must be of type default character.

Result Type and Type Parameters. Default logical.

Result Value. If the strings are of unequal length, the comparison is made as if the shorter string were extended on the right with blanks to the length of the longer string.

If either string contains a character not in the ASCII character set, the result is processor dependent.

The result is .TRUE. if the strings are equal or if STRING_A follows STRING_B in the ASCII collating sequence; otherwise, the result is .FALSE.. Note that the result is .TRUE. if both STRING_A and STRING_B are of zero length.

Examples.

LGE('apple', 'beans') has the value .FALSE..

LGE('apple', 'applesauce') has the value .FALSE..

LGE('Zebra', 'Yak') has the value .TRUE..

LGT(STRING_A, STRING_B)

Description. Tests whether a string is lexically greater than another string, based on the ASCII collating sequence.

Class. Elemental function.

Arguments.

STRING_A

must be of type default character.

STRING_B

must be of type default character.

Result Type and Type Parameters. Default logical.

Result Value. If the strings are of unequal length, the comparison is made as if the shorter string were extended on the right with blanks to the length of the longer string.

If either string contains a character not in the ASCII character set, the result is processor-dependent.

The result is .TRUE. if STRING_A follows STRING_B in the ASCII collating sequence; otherwise, the result is .FALSE.. Note that the result is .FALSE. if both STRING_A and STRING_B are of zero length.

Examples.

LGT('apple', 'beans') has the value .FALSE..

LGT('apple', 'applesauce') has the value .FALSE..

LGT('Zebra', 'Yak') has the value .TRUE..

LLE(STRING_A, STRING_B)

Description. Tests whether a string is lexically less than or equal to another string, based on the ASCII collating sequence.

Class. Elemental function.

Arguments.

STRING_A

must be of type default character.

STRING_B

must be of type default character.

Result Type and Type Parameters. Default logical.

Result Value. If the strings are of unequal length, the comparison is made as if the shorter string were extended on the right with blanks to the length of the longer string.

If either string contains a character not in the ASCII character set, the result is processor dependent.

The result is .TRUE. if the strings are equal or if STRING_A precedes STRING_B in the ASCII collating sequence; otherwise, the result is .FALSE.. Note that the result is .TRUE. if both STRING_A and STRING_B are of zero length.

Examples.

LLE('apple', 'beans') has the value .TRUE..

LLE('apple', 'applesauce') has the value .TRUE..

LLE('Zebra', 'Yak') has the value .FALSE..

LLT(STRING_A, STRING_B)

Description. Tests whether a string is lexically less than another string, based on the ASCII collating sequence.

Class. Elemental function.

Arguments.

STRING_A

must be of type default character.

STRING_B

must be of type default character.

Result Type and Type Parameters. Default logical.

Result Value. If the strings are of unequal length, the comparison is made as if the shorter string were extended on the right with blanks to the length of the longer string.

If either string contains a character not in the ASCII character set, the result is processor-dependent.

The result is .TRUE. if STRING_A precedes STRING_B in the ASCII collating sequence; otherwise, the result is .FALSE.. Note that the result is .FALSE. if both STRING_A and STRING_B are of zero length.

Examples.

LLT('apple', 'beans') has the value .TRUE..

LLT('apple', 'applesauce') has the value .TRUE..

LLT('Zebra', 'Yak') has the value .FALSE..

LOC(X)

Description. Return the address of the argument.

Class. Inquiry nonstandard function.

For details see LOC in Table 11-6 “ Generic and specific intrinsic procedures”.

LOG(X)

Description. Natural logarithm.

Class. Elemental function.

Argument. X must be of type real or complex. If X is real, its value must be greater than zero. If X is complex, its value must not be zero.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to logex. A result of type complex is the principal value with imaginary part w in the range -Pi < w <= Pi. The imaginary part of the result is Pi only when the real part of the argument is less than zero and the imaginary part of the argument is zero.

Examples.

LOG(10.0) has the value 2.3025851.

LOG((-0.5_HIGH,0)) has the value -0.69314718055994 + 3.1415926535898i with kind HIGH.

LOG10(X)

Description. Common logarithm.

Class. Elemental function.

Argument. X must be of type real. The value of X must be greater than zero.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to log10X.

Examples.

LOG10(10.0) has the value 1.0.

LOG10(10.0E1000_HIGH) has the value 1001.0 with kind HIGH.

LOGICAL(L, KIND)

Optional Argument. KIND

Description. Converts between kinds of logical.

Class. Elemental function.

Arguments.

L

must be of type logical.

KIND (optional)

must be a scalar integer initialization expression.

Result Type and Type Parameter. Logical. If KIND is present, the kind type parameter is that specified by KIND; otherwise, the kind type parameter is that of default logical.

Result Value. The value is that of L.

Examples.

LOGICAL(L .OR. .NOT. L) has the value .TRUE. and is of type default logical, regardless of the kind type parameter of the logical variable L.

LOGICAL(L, BIT) has kind parameter BIT and has the same value as L.

LSHFT(I, SHIFT)

Description. Left shift.

Class. Elemental nonstandard function.

For details see LSHFT in Table 11-6 “ Generic and specific intrinsic procedures”.

LSHIFT(I, SHIFT)

Description. Left shift.

Class. Elemental nonstandard function.

For details see LSHIFT in Table 11-6 “ Generic and specific intrinsic procedures”.

MALLOC(SIZE)

Description. Allocate a block of memory.

Class. Transformational nonstandard function.

For details see MALLOC in Table 11-6 “ Generic and specific intrinsic procedures”.

MATMUL(MATRIX_A, MATRIX_B)

Description. Performs matrix multiplication of numeric or logical matrices.

Class. Transformational function.

Arguments.

MATRIX_A

must be of numeric type (integer, real, or complex) or of logical type. It must be array valued and of rank one or two.

MATRIX_B

must be of numeric type if MATRIX_A is of numeric type and of logical type if MATRIX_A is of logical type. It must be array valued and of rank one or two.

If MATRIX_A has rank one, MATRIX_B must have rank two. If MATRIX_B has rank one, MATRIX_A must have rank two. The size of the first (or only) dimension of MATRIX_B must equal the size of the last (or only) dimension of MATRIX_A.

Result Type, Type Parameter, and Shape. If the arguments are of numeric type, the type and kind type parameter of the result are determined by the types of MATRIX_A and MATRIX_B.

If the arguments are of type logical, the result is of type logical with the kind type parameter of the arguments.

The shape of the result depends on the shapes of the arguments as follows:

Case 1

If MATRIX_A has shape [n, m] and MATRIX_B has shape [m, k], the result has shape [n, k].

Case 2

If MATRIX_A has shape [m] and MATRIX_B has shape [m, k], the result has shape [k].

Case 3

If MATRIX_A has shape [n, m] and MATRIX_B has shape [m], the result has shape [n].

Result Value.

Case 1

Element (i, j) of the result has the value SUM(MATRIX_A(i,:) * MATRIX_B(:, j)) if the arguments are of numeric type and has the value ANY(MATRIX_A(i, :) .AND. MATRIX_B(:, j)) if the arguments are of logical type.

Case 2

Element (j) of the result has the value SUM(MATRIX_A(:) * MATRIX_B(:, j)) if the arguments are of numeric type and has the value ANY(MATRIX_A(:) .AND. MATRIX_B(:, j)) if the arguments are of logical type.

Case 3

Element (i) of the result has the value SUM(MATRIX_A(i, :) * MATRIX_B(:)) if the arguments are of numeric type and has the value ANY(MATRIX_A(i, :) .AND. MATRIX_B(:)) if the arguments are of logical type.

Examples. If A is the matrix

      1  2  3
      2  3  4

and B is the matrix

      1  2
      2  3
      3  4

and X is the vector [1, 2] and Y is the vector [1, 2, 3].

Case 1

The result of MATMUL(A, B) is the matrix-matrix product AB with the value

      14  20
      20  29
Case 2

The result of MATMUL(X, A) is the vector-matrix product XA with the value [5, 8, 11].

Case 3

The result of MATMUL(A, Y) is the matrix-vector product AY with the value [14, 20].

MAX(A1, A2, A3, ...)

Optional Arguments. A3, ...

Description. Maximum value.

Class. Elemental function.

Arguments. The arguments must all have the same type which must be integer or real, and they must all have the same kind type parameter.

Result Type and Type Parameter. Same as the arguments.

Result Value. The value of the result is that of the largest argument.

Examples.

MAX(-9.0, 7.0, 2.0) has the value 7.0.

MAX(-1.0_HIGH/3, -0.1_HIGH) is -0.1_HIGH.

MAXEXPONENT(X)

Description. Returns the maximum exponent in the model representing numbers of the same type and kind type parameter as the argument.

Class. Inquiry function.

Argument. X must be of type real. It may be scalar or array valued.

Result Type, Type Parameter, and Shape. Default integer scalar.

Result Value. The result has the value emax, as defined in “The real number system model”.

Example. MAXEXPONENT(X) has the value 128 for real X, whose model is described in “The real number system model”.

MAXLOC(ARRAY, MASK)

Optional Argument. MASK

Description. Returns the location of the first element of ARRAY having the maximum value of the elements identified by MASK.

Class. Transformational function.

Arguments.

ARRAY

must be of type integer or real. It must not be scalar.

MASK (optional)

must be of type logical and must be conformable with ARRAY.

Result Type, Type Parameter, and Shape. The result is of type default integer; it is an array of rank one and of size equal to the rank of ARRAY.

Result Value.

Case 1

If MASK is absent, the result is a rank-one array whose element values are the values of the subscripts of an element of ARRAY whose value equals the maximum value of all of the elements of ARRAY.

The ith subscript returned lies in the range 1 to ei, where ei is the extent of the ith dimension of ARRAY.

If more than one element has the maximum value, the element whose subscripts are returned is the first such element, taken in array element order. If ARRAY has size zero, the value of the result is processor-dependent.

Case 2

If MASK is present, the result is a rank-one array whose element values are the values of the subscripts of an element of ARRAY, corresponding to a .TRUE. element of MASK, whose value equals the maximum value of all such elements of ARRAY.

The ith subscript returned lies in the range 1 to ei, where ei is the extent of the ith dimension of ARRAY.

If more than one such element has the maximum value, the element whose subscripts are returned is the first such element taken in array element order.

If there are no such elements (that is, if ARRAY has size zero or every element of MASK has the value .FALSE.), the value of the result is processor-dependent.

In both cases, an element of the result is undefined if the processor cannot represent the value as a default integer.

Examples.

Case 1

The value of MAXLOC((/ 2, 6, 4, 6 /)) is [2].

If the array B is declared

INTEGER, DIMENSION(4:7) :: B = (/ 8, 6, 3, 1 /)

the value of MAXLOC(B) is [1].

Case 2

If A has the value

      0 -5  8 -3
      3  4 -1  2
      1  5  6 -4

then MAXLOC(A, MASK = A .LT. 6) has the value [3, 2]. Note that this is true even if A has a declared lower bound other than 1.

MAXVAL(ARRAY, DIM, MASK)

Optional Arguments. DIM, MASK

Description. Maximum value of the elements of ARRAY along dimension DIM that correspond to the .TRUE. elements of MASK.

Class. Transformational function.

Arguments.

ARRAY

must be of type integer or real. It must not be scalar.

DIM (optional)

must be scalar and of type integer with a value in the range 1 <= DIM <= n where n is the rank of ARRAY. The corresponding actual argument must not be an optional dummy argument.

MASK (optional)

must be of type logical and must be conformable with ARRAY.

Result Type, Type Parameter, and Shape. The result is of the same type and kind type parameter as ARRAY.

It is scalar if DIM is absent or ARRAY has rank one; otherwise, the result is an array of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn) where (d1, d2, ..., dn) is the shape of ARRAY.

Result Value.

Case 1

The result of MAXVAL(ARRAY) has a value equal to the maximum value of all the elements of ARRAY or has the value of the negative number of the largest magnitude supported by the processor for numbers of the type and kind type parameter of ARRAY if ARRAY has size zero.

Case 2

The result of MAXVAL(ARRAY, MASK = MASK) has a value equal to the maximum value of the elements of ARRAY corresponding to .TRUE. elements of MASK or has the value of the negative number of the largest magnitude supported by the processor for numbers of the same type and kind type parameter as ARRAY if there are no .TRUE. elements.

Case 3

If ARRAY has rank one, MAXVAL(ARRAY, DIM [,MASK]) has a value equal to that of MAXVAL(ARRAY [,MASK = MASK]). Otherwise, the value of element (s1, s2, ..., sDIM-1, sDIM+1, ..., sn) of MAXVAL(ARRAY, DIM [,MASK]) is equal to the following:

MAXVAL(ARRAY(s1, s2, ..., sDIM-1, :, sDIM+1, ..., sn) [, MASK = MASK(s1, s2, ..., sDIM-1, :, sDIM+1, ..., sn) ] )

Examples.

Case 1

The value of MAXVAL((/ 1, 2, 3 /)) is 3.

Case 2

MAXVAL(C, MASK = C .LT. 0.0) finds the maximum of the negative elements of C.

Case 3

If B is the array

      1  3  5
      2  4  6

then MAXVAL(B, DIM = 1) is [2, 4, 6] and MAXVAL(B, DIM = 2) is [5, 6].

MCLOCK()

Description. Return time accounting for a program.

Class. Inquiry nonstandard function.

Result Type. Integer.

Result Value. The value returned, in units of microseconds, is the sum of the current process's user time and the user and system time of all its child processes.

MERGE(TSOURCE, FSOURCE, MASK)

Description. Choose alternative value according to the value of a mask.

Class. Elemental function.

Arguments.

TSOURCE

may be of any type.

FSOURCE

must be of the same type and type parameters as TSOURCE.

MASK

must be of type logical.

Result Type and Type Parameters. Same as TSOURCE.

Result Value. The result is TSOURCE if MASK is .TRUE. and FSOURCE otherwise.

Examples.

If TSOURCE is the array

      1  6  5
      2  4  6

and FSOURCE is the array

      0  3  2
      7  4  8

and MASK is the array

      T  .  T
      .  .  T

then where "T" represents .TRUE. and "." represents .FALSE., then MERGE(TSOURCE, FSOURCE, MASK) is

      1  3  5
      7  4  6

The value of MERGE(1.0, 0.0, K > 0) is 1.0 for K = 5 and 0.0 for K = -2.

MIN(A1, A2, A3, ...)

Optional Arguments. A3, ...

Description. Minimum value.

Class. Elemental function.

Arguments. The arguments must all be of the same type, which must be integer or real, and they must all have the same kind type parameter.

Result Type and Type Parameter. Same as the arguments.

Result Value. The value of the result is that of the smallest argument.

Examples.

MIN(-9.0, 7.0, 2.0) has the value -9.0.

MIN(-0.4_HIGH, -1.0_HIGH/3) is -0.4_HIGH.

MINEXPONENT(X)

Description. Returns the minimum exponent in the model representing numbers of the same type and kind type parameter as the argument.

Class. Inquiry function.

Argument. X must be of type real. It may be scalar or array valued.

Result Type, Type Parameter, and Shape. Default integer scalar.

Result Value. The result has the value emin, as defined in “The real number system model”.

Example. MINEXPONENT(X) has the value -125 for real X, whose model is described in “The real number system model”.

MINLOC(ARRAY, MASK)

Optional Argument. MASK

Description. Returns the location of the first element of ARRAY having the minimum value of the elements identified by MASK.

Class. Transformational function.

Arguments.

ARRAY

must be of type integer or real. It must not be scalar.

MASK (optional)

must be of type logical and must be conformable with ARRAY.

Result Type, Type Parameter, and Shape. The result is of type default integer; it is an array of rank one and of size equal to the rank of ARRAY.

Result Value.

Case 1

If MASK is absent, the result is a rank-one array whose element values are the values of the subscripts of an element of ARRAY whose value equals the minimum value of all the elements of ARRAY.

The ith subscript returned lies in the range 1 to ei, where ei is the extent of the ith dimension of ARRAY.

If more than one element has the minimum value, the element whose subscripts are returned is the first such element, taken in array element order. If ARRAY has size zero, the value of the result is processor-dependent.

Case 2

If MASK is present, the result is a rank-one array whose element values are the values of the subscripts of an element of ARRAY, corresponding to a .TRUE. element of MASK, whose value equals the minimum value of all such elements of ARRAY.

The ith subscript returned lies in the range 1 to ei, where ei is the extent of the ith dimension of ARRAY. If more than one such element has the minimum value, the element whose subscripts are returned is the first such element taken in array element order.

If ARRAY has size zero or every element of MASK has the value .FALSE., the value of the result is processor-dependent.

In both cases, an element of the result is undefined if the processor cannot represent the value as a default integer.

Examples.

Case 1

The value of MINLOC((/ 4, 3, 6, 3 /)) is [2].

If the array B is declared

INTEGER, DIMENSION(4:7) :: B = (/ 8, 6, 3, 1 /)

the value of MINLOC(B) is [4]

Case 2

If A has the value

      0 -5  8 -3
      3  4 -1  2
      1  5  6 -4

then MINLOC(A, MASK = A .GT. -4) has the value [1, 4]. Note that this is true even if A has a declared lower bound other than 1.

MINVAL(ARRAY, DIM, MASK)

Optional Arguments. DIM, MASK

Description. Minimum value of all the elements of ARRAY along dimension DIM corresponding to .TRUE. elements of MASK.

Class. Transformational function.

Arguments.

ARRAY

must be of type integer or real. It must not be scalar.

DIM (optional)

must be scalar and of type integer with a value in the range 1 <= DIM <= n, where n is the rank of ARRAY. The corresponding actual argument must not be an optional dummy argument.

MASK (optional)

must be of type logical and must be conformable with ARRAY.

Result Type, Type Parameter, and Shape. The result is of the same type and kind type parameter as ARRAY. It is scalar if DIM is absent or ARRAY has rank one; otherwise, the result is an array of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn) where (d1, d2, ..., dn) is the shape of ARRAY.

Result Value.

Case 1

The result of MINVAL(ARRAY) has a value equal to the minimum value of all the elements of ARRAY or has the value of the positive number of the largest magnitude supported by the processor for numbers of the type and kind type parameter of ARRAY if ARRAY has size zero.

Case 2

The result of MINVAL(ARRAY, MASK = MASK) has a value equal to the minimum value of the elements of ARRAY corresponding to .TRUE. elements of MASK or has the value of the positive number of the largest magnitude supported by the processor for numbers of the same type and kind type parameter as ARRAY if there are no .TRUE. elements.

Case 3

If ARRAY has rank one, MINVAL(ARRAY, DIM [,MASK]) has a value equal to that of MINVAL(ARRAY [,MASK = MASK]). Otherwise, the value of element (s1, s2, ..., sDIM-1, sDIM+1, ..., sn) of MINVAL(ARRAY, DIM [,MASK]) is equal to the following:

MINVAL(ARRAY(s1, s2, ..., sDIM-1, :, sDIM+1, ..., sn) [, MASK= MASK(s1, s2, ..., sDIM-1, :, sDIM+1, ..., sn) ] )

Examples.

Case 1

The value of MINVAL((/ 1, 2, 3 /)) is 1.

Case 2

MINVAL(C, MASK = C .GT. 0.0) forms the minimum of the positive elements of C.

Case 3

If B is the array

      1  3  5
      2  4  6

then MINVAL(B, DIM = 1) is [1, 3, 5] and MINVAL(B, DIM = 2) is [1, 2].

MOD(A, P)

Description. Remainder function.

Class. Elemental function.

Arguments.

A

must be of type integer or real.

P

must be of the same type and kind type parameter as A.

Result Type and Type Parameter. Same as A.

Result Value. If P is not 0, the value of the result is A - INT(A/P) * P. If P=0, the result is processor-dependent.

Examples.

MOD(3.0, 2.0) has the value 1.0.

MOD(8, 5) has the value 3.

MOD(-8, 5) has the value -3.

MOD(8, -5) has the value 3.

MOD(-8, -5) has the value -3.

MOD(2.0_HIGH, 3.0_HIGH) has the value 2.0_HIGH.

MODULO(A, P)

Description. Modulo function.

Class. Elemental function.

Arguments.

A

must be of type integer or real.

P

must be of the same type and kind type parameter as A.

Result Type and Type Parameter. Same as A.

Result Value.

Case 1

A is of type integer. If P is not 0, MODULO(A, P) has the value R such that A = Q * P + R, where Q is an integer, the inequalities 0 <= R<P hold if P>0, and P<R <= 0 hold if P<0. If P=0, the result is processor-dependent.

Case 2

A is of type real. If P is not 0, the value of the result is A -FLOOR (A / P) * P. If P=0, the result is processor-dependent.

Examples.

MODULO(8, 5) has the value 3.

MODULO(-8, 5) has the value 2.

MODULO(8, -5) has the value -2.

MODULO(-8, -5) has the value -3.

MODULO(3.0, 2.0) has the value 1.0.

MODULO(2.0_HIGH, 3.0_HIGH) has the value 2.0_HIGH.

MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)

Description. Copies a sequence of bits from one data object to another.

Class. Elemental subroutine.

Arguments.

FROM

must be of type integer. It is an INTENT(IN) argument.

FROMPOS

must be of type integer and nonnegative. It is an INTENT(IN) argument. FROMPOS + LEN must be less than or equal to BIT_SIZE(FROM). The model for the interpretation of an integer value as a sequence of bits is in “The bit model”.

LEN

must be of type integer and nonnegative. It is an INTENT(IN) argument.

TO

must be a variable of type integer with the same kind type parameter value as FROM and may be the same variable as FROM. It is an INTENT(INOUT) argument.

TO is set by copying the sequence of bits of length LEN, starting at position FROMPOS of FROM to position TOPOS of TO. No other bits of TO are altered. On return, the LEN bits of TO starting at TOPOS are equal to the value that the LEN bits of FROM starting at FROMPOS had on entry.

The model for the interpretation of an integer value as a sequence of bits is in “The bit model”.

TOPOS

must be of type integer and nonnegative. It is an INTENT(IN) argument. TOPOS + LEN must be less than or equal to BIT_SIZE(TO).

Examples.

If TO has the initial value 6, the value of TO after the statement CALL MVBITS(7, 2, 2, TO, 0) is 5.

After the statement

CALL MVBITS (PATTERN, 0_SHORT, 1_SHORT, PATTERN, 7_SHORT) 

is executed, the integer variable PATTERN of kind SHORT has a leading bit that is identical to its terminal bit.

NEAREST(X, S)

Description. Returns the nearest different machine representable number in a given direction.

Class. Elemental function.

Arguments.

X

must be of type real.

S

must be of type real and not equal to zero.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to the machine representable number distinct from X and nearest to it in the direction of the infinity with the same sign as S.

Example. NEAREST(3.0, 2.0) has the value 3+2-22 on a machine whose representation is that of the model described in “The real number system model”.

NINT(A, KIND)

Optional Argument. KIND

Description. Nearest integer.

Class. Elemental function.

Arguments.

A

must be of type real.

KIND (optional)

must be a scalar integer initialization expression.

Result Type and Type Parameter. Integer. If KIND is present, the kind type parameter is that specified by KIND; otherwise, the kind type parameter is that of default integer type.

Result Value. If A>0, NINT(A) has the value INT(A+0.5); if A <= 0, NINT(A) has the value INT(A-0.5). The result is undefined if the processor cannot represent the result in the specified integer type.

Examples.

NINT(2.783) has the value 3.

NINT(-1.99999999999_HIGH) has the value -2.

NOT(I)

Description. Performs a bitwise logical complement.

Class. Elemental function.

Argument. I must be of type integer.

Result Type and Type Parameter. Same as I.

Result Value. The result has the value obtained by complementing I bit-by-bit according to the following truth table:

Table 11-13 Title not available (NOT(I) )

I

NOT(I)

1

0

0

1

 

The model for the interpretation of an integer value as a sequence of bits is in “The bit model”.

Example. If I is an integer of kind SHORT and has a value that is equal to 01010101 (base 2), NOT(I) has a value that is equal to 10101010 (base 2).

OR(I, J)

Description. Bitwise logical OR.

Class. Elemental nonstandard function.

Arguments.

I

must be of type integer.

J

must be of type integer with the same kind type parameter as I.

Result Type and Type Parameter. Same as I.

Result Value. The result has the value obtained by performing an OR on I and J bit-by-bit according to the following truth table:

Table 11-14 Title not available (OR(I, J))

I

J

OR(I, J)

1

1

1

1

0

1

0

1

1

0

0

0

 

The model for interpreting an integer value as a sequence of bits is in “The bit model”.

Example. OR(3, 5) is 7. (Binary 0011 OR with binary 0101 is binary 0111.)

PACK(ARRAY, MASK, VECTOR)

Optional Argument. VECTOR

Description. Pack an array into an array of rank one under the control of a mask.

Class. Transformational function.

Arguments.

ARRAY

may be of any type. It must not be scalar.

MASK

must be of type logical and must be conformable with ARRAY.

VECTOR (optional)

must be of the same type and type parameters as ARRAY and must have rank one. VECTOR must have at least as many elements as there are .TRUE. elements in MASK. If MASK is scalar with the value .TRUE., VECTOR must have at least as many elements as there are in ARRAY.

Result Type, Type Parameter, and Shape. The result is an array of rank one with the same type and type parameters as ARRAY. If VECTOR is present, the result size is that of VECTOR; otherwise, the result size is the number t of .TRUE. elements in MASK unless MASK is scalar with the value .TRUE., in which case the result size is the size of ARRAY.

Result Value. Element i of the result is the element of ARRAY that corresponds to the ith .TRUE. element of MASK, taking elements in array element order, for i= 1, 2, ..., t. If VECTOR is present and has size n>t, element i of the result has the value VECTOR (i), for i= t+1, ..., n.

Examples.

The nonzero elements of an array M with the value

      0  0  0
      9  0  0
      0  0  7

may be "gathered" by the function PACK.

The result of PACK(M, MASK = M .NE. 0) is [9, 7].

The result of PACK(M, M .NE. 0, VECTOR = (/ 2, 4, 6, 8, 10, 12 /)) is [9, 7, 6, 8, 10, 12].

PRECISION(X)

Description. Returns the decimal precision in the model representing real numbers with the same kind type parameter as the argument.

Class. Inquiry function.

Argument. X must be of type real or complex. It may be scalar or array valued.

Result Type, Type Parameter, and Shape. Default integer scalar.

Result Value. The result has the value INT((p-1) * LOG10(b))+k. The values of b and p are as defined in “The real number system model” for the model representing real numbers with the same kind type parameter as X. The value of k is 1 if b is an integral power of 10 and 0 otherwise.

Example. PRECISION(X) has the value INT(23 * LOG10(2.)) = INT(6.92...) = 6 for real X whose model is described in “The real number system model”.

PRESENT(A)

Description. Determine whether an optional argument is present.

Class. Inquiry function.

Argument. A must be the name of an optional dummy argument that is accessible in the procedure in which the PRESENT function reference appears.

Result Type and Type Parameters. Default logical scalar.

Result Value. The result has the value .TRUE. if A is present and otherwise has the value .FALSE..

Example.

SUBROUTINE SUB (A, B, EXTRA) 
REAL A, B, C
REAL, OPTIONAL :: EXTRA
. . .
IF (PRESENT (EXTRA)) THEN
C = EXTRA
ELSE
C = (A+B)/2
END IF
. . .
END

If SUB is called with the statement

CALL SUB (10.0, 20.0, 30.0) 

then C is set to 30.0. If SUB is called with the statement

CALL SUB (10.0, 20.0) 

then C is set to 15.0.

An optional argument that is not present must not be referenced or defined or supplied as a nonoptional actual argument, except as the argument of the PRESENT intrinsic function.

PRODUCT(ARRAY, DIM, MASK)

Optional Arguments. DIM, MASK

Description. Product of all the elements of ARRAY along dimension DIM corresponding to the .TRUE. elements of MASK.

Class. Transformational function.

Arguments.

ARRAY

must be of type integer, real, or complex. It must not be scalar.

DIM (optional)

must be scalar and of type integer with a value in the range 1 <= DIM <= n, where n is the rank of ARRAY. The corresponding actual argument must not be an optional dummy argument.

MASK (optional)

must be of type logical and must be conformable with ARRAY.

Result Type, Type Parameter, and Shape. The result is of the same type and kind type parameter as ARRAY. It is scalar if DIM is absent or ARRAY has rank one; otherwise, the result is an array of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn) where (d1, d2, ..., dn) is the shape of ARRAY.

Result Value.

Case 1

The result of PRODUCT(ARRAY) has a value equal to a processor-dependent approximation to the product of all the elements of ARRAY or has the value one if ARRAY has size zero.

Case 2

The result of PRODUCT(ARRAY, MASK = msk) has a value equal to a processor-dependent approximation to the product of the elements of ARRAY corresponding to the .TRUE. elements of msk or has the value one if there are no .TRUE. elements.

Case 3

If ARRAY has rank one, PRODUCT(ARRAY, DIM [,msk]) has a value equal to that of PRODUCT(ARRAY [,MASK = msk]). Otherwise, the value of element (s1, s2, ..., sDIM-1, sDIM+1, ..., sn) of PRODUCT(ARRAY, DIM [,msk]) is equal to the following:

PRODUCT(ARRAY(s1, s2, ..., sDIM-1, :, sDIM+1, ..., sn) [, MASK = msk(s1, s2, ..., sDIM-1, :, sDIM+1, ..., sn) ] )

Examples.

Case 1

The value of PRODUCT((/ 1, 2, 3 /)) and PRODUCT((/ 1, 2, 3 /), DIM=1) is 6.

Case 2

PRODUCT(C, MASK = C .GT. 0.0) forms the product of the positive elements of C.

Case 3

If B is the array

      1  3  5
      2  4  6

then PRODUCT(B, DIM = 1) is [2, 12, 30] and PRODUCT(B, DIM = 2) is [15, 48].

QEXT(A)

Description. Convert to REAL(16) type.

Class. Elemental nonstandard function.

Argument. A must be of type integer, real, double precision, or complex.

Result. REAL(16).

Examples.

QEXT(77) is 77.0 of type REAL(16).

The following code sets x to 34.4:

  COMPLEX b
REAL(16) x
b = (34.4, 1.0)
x = QEXT(b)

QFLOAT(A)

Description. Convert to REAL(16) type.

Class. Elemental nonstandard function.

Argument. A must be of type integer or REAL(4).

Result. REAL(16).

Examples.

QFLOAT(4) is 4.0 of type REAL(16).

QFLOAT(1.6723) is 1.6723 of type REAL(16).

QNUM(I)

Description. Convert character to REAL(16) type.

Class. Elemental nonstandard function.

Argument. I must be of type character.

Result. REAL(16) type.

Example. QNUM("8899.321") is 8899.321 of type REAL(16).

QPROD(X, Y)

Description. Double precision product.

Class. Elemental nonstandard function.

Arguments. X and Y must be of type double precision.

Result. REAL(16) type.

Example.

The following code prints the product of x and y (11392147076.9423828125).

PROGRAM testqprod
DOUBLE PRECISION x,y
REAL(16) z
x = 9485156.0
y = 1201.05
z = QPROD(x,y)
PRINT *, z
END

RADIX(X)

Description. Returns the base of the model representing numbers of the same type and kind type parameter as the argument.

Class. Inquiry function.

Argument. X must be of type integer or real. It may be scalar or array valued.

Result Type, Type Parameter, and Shape. Default integer scalar.

Result Value. The result has the value r if X is of type integer and the value b if X is of type real, where r and b are as defined in “The real number system model”.

Example. RADIX(X) has the value 2 for real X whose model is described in “The real number system model”.

RAN(ISEED)

Description. Multiplicative congruential random number generator.

Class. Elemental nonstandard function.

Argument. ISEED must be an INTEGER(4) variable or array element. RAN stores a number in ISEED to be used by the next call to RAN.

ISEED should initially be set to an odd number, preferably very large; see the following example.

Result Type and Type Parameter. REAL(4) type.

Example.

INTEGER(4) iseed
REAL(4) rnd
iseed = 425001
rnd = RAN(iseed)

Notes.

To ensure different random values for each run of a program, ISEED should be set to a different value each time the program is run. One way to implement this would be to have the user enter the seed at the start of the program. Another way would be to compute a value from the current year, day, and month (returned by IDATE) and the number of seconds since midnight (returned by SECNDS).

RAND()

Description. Generate successive pseudorandom numbers uniformly distributed in the range of 0.0 to 1.0.

Class. Elemental nonstandard function.

Result Type and Type Parameter. REAL(4) type.

Example.

REAL(4) rv
rv = RAND()

Notes.

For details about restarting the pseudorandom number generator used by IRAND and RAND, see “SRAND(ISEED)” section.

RANDOM_NUMBER(HARVEST)

Description. Returns one pseudorandom number or an array of pseudorandom numbers from the uniform distribution over the range 0 <= x < 1.

Class. Subroutine.

Argument. HARVEST must be of type real. It is an INTENT(OUT) argument. It may be a scalar or an array variable. It is set to contain pseudorandom numbers from the uniform distribution in the interval 0 <= x < 1.

Examples.

REAL X, Y (10, 10) 
! Initialize X with a pseudorandom number
CALL RANDOM_NUMBER (HARVEST = X)
CALL RANDOM_NUMBER (Y)
! X and Y contain
! uniformly distributed random numbers

RANDOM_SEED(SIZE, PUT, GET)

Optional Arguments. SIZE, PUT, GET

Description. Restarts or queries the pseudorandom number generator used by RANDOM_NUMBER.

Class. Subroutine.

Arguments. There must either be exactly one or no arguments present.

SIZE (optional)

must be scalar and of type default integer. It is an INTENT(OUT) argument. It is set to the number N of integers that the processor uses to hold the value of the seed.

PUT (optional)

must be a default integer array of rank one and size >= N. It is an INTENT(IN) argument. It is used by the processor to set the seed value.

GET (optional)

must be a default integer array of rank one and size >= N. It is an INTENT(OUT) argument. It is set by the processor to the current value of the seed. If no argument is present, the processor sets the seed to a processor-dependent value.

Examples.

CALL RANDOM_SEED                      ! Processor initialization 
CALL RANDOM_SEED (SIZE = K) ! Sets K = N
CALL RANDOM_SEED (PUT = SEED (1 : K)) ! Set user seed
CALL RANDOM_SEED (GET = OLD (1 : K)) ! Read current seed

RANGE(X)

Description. Returns the decimal exponent range in the model representing integer or real numbers with the same kind type parameter as the argument.

Class. Inquiry function.

Argument. X must be of type integer, real, or complex. It may be scalar or array valued.

Result Type, Type Parameter, and Shape. Default integer scalar.

Result Value.

Case 1

For an integer argument, the result has the value INT(LOG10(huge)), where huge is the largest positive integer in the model representing integer numbers with same kind type parameter as X (see “The integer number system model”).

Case 2

For a real or complex argument, the result has the value INT(MIN(LOG10(huge), -LOG10(tiny))), where huge and tiny are the largest and smallest positive numbers in the model representing real numbers with the same value for the kind type parameter as X (see “The real number system model”).

Example. RANGE(X) has the value 38 for real X, whose model is described in “The real number system model”, because in this case huge= (1 - 2-24) * 2127 and tiny = 2-127.

REAL(A, KIND)

Optional Argument. KIND

Description. Convert to real type.

Class. Elemental function.

Arguments.

A

must be of type integer, real, or complex.

KIND (optional)

must be a scalar integer initialization expression.

Result Type and Type Parameter. Real.

Case 1

If A is of type integer or real and KIND is present, the kind type parameter is that specified by KIND.

If A is of type integer or real and KIND is not present, the kind type parameter is the processor-dependent kind type parameter for the default real type.

Case 2

If A is of type complex and KIND is present, the kind type parameter is that specified by KIND.

If A is of type complex and KIND is not present, the kind type parameter is the kind type parameter of A.

Result Value.

Case 1

If A is of type integer or real, the result is equal to a processor-dependent approximation to A.

Case 2

If A is of type complex, the result is equal to a processor-dependent approximation to the real part of A.

Examples.

REAL(-3) has the value -3.0.

REAL(Z) has the same kind type parameter and the same value as the real part of the complex variable Z.

REAL(2.0_HIGH/3.0) is 0.66666666666666 with kind HIGH.

REPEAT(STRING, NCOPIES)

Description. Concatenate several copies of a string.

Class. Transformational function.

Arguments.

STRING

must be scalar and of type character.

NCOPIES

must be scalar and of type integer. Its value must not be negative.

Result Type, Type Parameter, and Shape. Character scalar of length NCOPIES times that of STRING, with the same kind type parameter as STRING.

Result Value. The value of the result is the concatenation of NCOPIES copies of STRING.

Examples.

REPEAT('H', 2) has the value HH.

REPEAT('XYZ', 0) has the value of a zero-length string.

RESHAPE(SOURCE, SHAPE, PAD, ORDER)

Optional Arguments. PAD, ORDER

Description. Constructs an array of a specified shape from the elements of a given array.

Class. Transformational function.

Arguments.

SOURCE

may be of any type. It must be array valued. If PAD is absent or of size zero, the size of SOURCE must be greater than or equal to PRODUCT(SHAPE). The size of the result is the product of the values of the elements of SHAPE.

SHAPE

must be of type integer, rank one, and constant size. Its size must be positive and less than 8. It must not have an element whose value is negative.

PAD (optional)

must be of the same type and type parameters as SOURCE. PAD must be array valued.

ORDER (optional)

must be of type integer, must have the same shape as SHAPE, and its value must be a permutation of [1, 2, ..., n], where n is the size of SHAPE. If absent, it is as if it were present with value [1, 2, ..., n].

Result Type, Type Parameter, and Shape. The result is an array of shape SHAPE (that is, SHAPE(RESHAPE(SOURCE, SHAPE, PAD, ORDER)) is equal to SHAPE) with the same type and type parameters as SOURCE.

Result Value. The elements of the result, taken in permuted subscript order ORDER(1), ..., ORDER(n), are those of SOURCE in normal array element order followed if necessary by those of PAD in array element order, followed if necessary by additional copies of PAD in array element order.

Examples.

RESHAPE((/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /)) has the value

      1  3  5
      2  4  6

RESHAPE((/ 1, 2, 3, 4, 5, 6 /), (/ 2, 4 /), (/ 0, 0 /), (/ 2, 1 /)) has the value

      1  2  3  4
      5  6  0  0

RNUM(I)

Description. Convert character to real type.

Class. Elemental nonstandard function.

Argument. I must be of type character.

Result. Default real type.

Example. RNUM("821.003") is 821.003 of type default real.

RRSPACING(X)

Description. Returns the reciprocal of the relative spacing of model numbers near the argument value.

Class. Elemental function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. The result has the value |X * b-e| * bp, where b, e, and p are as defined in “The real number system model”.

Example. RRSPACING(-3.0) has the value 0.75 * 224 for reals whose model is described in “The real number system model”.

RSHFT(I, SHIFT)

Description. Bitwise right shift.

Class. Elemental nonstandard function.

For details see RSHFT in Table 11-6 “ Generic and specific intrinsic procedures”.

RSHIFT(I, SHIFT)

Description. Bitwise right shift.

Class. Elemental nonstandard function.

For details see RSHIFT in Table 11-6 “ Generic and specific intrinsic procedures”.

SCALE(X, I)

Description. Returns X * b I where b is the base in the model representation of X (see “The real number system model”).

Class. Elemental function.

Arguments.

X

must be of type real.

I

must be of type integer.

Result Type and Type Parameter. Same as X.

Result Value. The result has the value X * bI, where b is defined in “The real number system model”, provided this result is within range; if not, the result is processor dependent.

Example. SCALE(3.0, 2) has the value 12.0 for reals whose model is described in “The real number system model”.

SCAN(STRING, SET, BACK)

Optional Argument. BACK

Description. Scan a string for any one of the characters in a set of characters.

Class. Elemental function.

Arguments.

STRING

must be of type character.

SET

must be of type character with the same kind type parameter as STRING.

BACK (optional)

must be of type logical.

Result Type and Type Parameter. Default integer.

Result Value.

Case 1

If BACK is absent or is present with the value .FALSE. and if STRING contains at least one character that is in SET, the value of the result is the position of the leftmost character of STRING that is in SET.

Case 2

If BACK is present with the value .TRUE. and if STRING contains at least one character that is in SET, the value of the result is the position of the rightmost character of STRING that is in SET.

Case 3

The value of the result is zero if no character of STRING is in SET or if the length of STRING or SET is zero.

Examples.

Case 1

SCAN('FORTRAN', 'TR') has the value 3.

Case 2

SCAN('FORTRAN', 'TR', BACK = .TRUE.) has the value 5.

Case 3

SCAN('FORTRAN', 'BCD') has the value 0.

SECNDS(X)

Description. Return the number of seconds that have elapsed since midnight, less the value of the argument.

Class. Elemental nonstandard function.

Argument. X must be of type REAL(4).

Result Type and Type Parameter. REAL(4).

Example.

s= SECNDS(0.0)
DO i=1,1000000
j=j+1
END DO
s = SECNDS(s)
PRINT *, "It took",s,"seconds to run."

Notes.

SECNDS is accurate to one one-hundredth of a second (0.01 second). The SECNDS routine is useful for computing elapsed time for a code's execution.

SELECTED_INT_KIND(R)

Description. Returns a value of the kind type parameter of an integer data type that represents all integer values n with -10R < n < 10R.

Class. Transformational function.

Argument. R must be scalar and of type integer.

Result Type, Type Parameter, and Shape. Default integer scalar.

Result Value. The result has a value equal to the value of the kind type parameter of an integer data type that represents all values n in the range of values n with -10R < n < 10R, or if no such kind type parameter is available on the processor, the result is -1.

If more than one kind type parameter meets the criteria, the value returned is the one with the smallest decimal exponent range, unless there are several such values, in which case the smallest of these kind values is returned.

Example.

SELECTED_INT_KIND(6) has the value KIND(0) on a machine that supports a default integer representation method with r=2 and q=31 as defined in the model for the integer number systems in “The integer number system model”.

SELECTED_REAL_KIND(P, R)

Optional Arguments. P, R

Description. Returns a value of the kind type parameter of a real data type with decimal precision of at least P digits and a decimal exponent range of at least R.

Class. Transformational function.

Arguments. At least one argument must be present.

P (optional)

must be scalar and of type integer.

R (optional)

must be scalar and of type integer.

Result Type, Type Parameter, and Shape. Default integer scalar.

Result Value. The result has a value equal to a value of the kind type parameter of a real data type with decimal precision, as returned by the function PRECISION, of at least P digits and a decimal exponent range, as returned by the function RANGE, of at least R.

If no such kind type parameter is available on the processor, the result is -1 if the precision is not available, -2 if the exponent range is not available, and -3 if neither is available.

If more than one kind type parameter value meets the criteria, the value returned is the one with the smallest decimal precision, unless there are several such values, in which case the smallest of these kind values is returned.

Example.

SELECTED_REAL_KIND(6, 70) has the value KIND(0.0) on a machine that supports a default real approximation method with p=16, p= 6, emin=-64, and emax=63 as defined in the model for the real number system in “The real number system model”.

SET_EXPONENT(X, I)

Description. Returns the model number whose fractional part is the fractional part of the model representation of X and whose exponent part is I.

Class. Elemental function.

Arguments.

X

must be of type real.

I

must be of type integer.

Result Type and Type Parameter. Same as X.

Result Value. The result has the value X * bI-e, where b and e are as defined in “The real number system model”, provided this result is within range; if not, the result is processor-dependent.

If X has value zero, the result has value zero.

Example. SET_EXPONENT(3.0, 1) has the value 1.5 for reals whose model is as described in “The real number system model”.

SHAPE(SOURCE)

Description. Returns the shape of an array or a scalar.

Class. Inquiry function.

Argument. SOURCE may be of any type. It may be array valued or scalar. It must not be a pointer that is disassociated or an allocatable array that is not allocated. It must not be an assumed-size array.

Result Type, Type Parameter, and Shape. The result is a default integer array of rank one whose size is equal to the rank of SOURCE.

Result Value. The value of the result is the shape of SOURCE.

Examples.

The value of SHAPE(A(2:5, -1:1) ) is [4, 3].

The value of SHAPE(3) is the rank-one array of size zero.

SIGN(A, B)

Description. Absolute value of A times the sign of B.

Class. Elemental function.

Arguments.

A

must be of type integer or real.

B

must be of the same type and kind type parameter as A.

Result Type and Type Parameter. Same as A.

Result Value. The value of the result is |A| if B>= 0 and -|A| if B < 0.

Example. SIGN(-3.0, 2.0) has the value 3.0.

SIN(X)

Description. Sine function in radians.

Class. Elemental function.

Argument. X must be of type real or complex.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to sin(X).

If X is of type real, it is regarded as a value in radians.

If X is of type complex, its real part is regarded as a value in radians.

Examples.

SIN(1.0) has the value 0.84147098.

SIN((0.5_HIGH, 0.5)) has the value 0.54061268571316 + 0.45730415318425i with kind HIGH.

SIND(X)

Description. Sine function in degrees.

Class. Elemental nonstandard function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to sin(X).

Examples.

SIND(0.0) has the value 0.0.

SIND(30.0) has the value 0.5.

SINH(X)

Description. Hyperbolic sine function.

Class. Elemental function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to sinh(X).

Examples.

SINH(1.0) has the value 1.1752012.

SINH(0.5_HIGH) has the value 0.52109530549375 with kind HIGH.

SIZE(ARRAY, DIM)

Optional Argument. DIM

Description. Returns the extent of an array along a specified dimension or the total number of elements in the array.

Class. Inquiry function.

Arguments.

ARRAY

may be of any type. It must not be scalar. It must not be a pointer that is disassociated or an allocatable array that is not allocated. If ARRAY is an assumed-size array, DIM must be present with a value less than the rank of ARRAY.

DIM (optional)

must be scalar and of type integer with a value in the range 1 <= DIM <= n, where n is the rank of ARRAY.

Result Type, Type Parameter, and Shape. Default integer scalar.

Result Value. The result has a value equal to the extent of dimension DIM of ARRAY or, if DIM is absent, the total number of elements of ARRAY.

Examples.

The value of SIZE(A(2:5, -1:1), DIM=2) is 3.

The value of SIZE(A(2:5, -1:1) ) is 12.

SIZEOF(A)

Description. Return the number of bytes of storage used by the argument.

Class. Inquiry nonstandard function.

Argument. A may be of any type (except assumed-size arrays or passed-length character arguments).

Result Type. Integer.

Example.

INTEGER(2) a, b(20)
REAL(16) x
PRINT *, SIZEOF(a), SIZEOF(b), SIZEOF(x)

This code produces the following output: 2 40 16.

SPACING(X)

Description. Returns the absolute spacing of model numbers near the argument value.

Class. Elemental function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. If X is not zero, the result has the value be-p, where b, e, and p are as defined in “The real number system model”, provided this result is within range; otherwise, the result is the same as that of TINY(X).

Example. SPACING(3.0) has the value 2-22 for reals whose model is described in “The real number system model”.

SPREAD(SOURCE, DIM, NCOPIES)

Description. Replicates an array by adding a dimension. Broadcasts several copies of SOURCE along a specified dimension (as in forming a book from copies of a single page) and thus forms an array of rank one greater.

Class. Transformational function.

Arguments.

SOURCE

may be of any type. It may be scalar or array valued. The rank of SOURCE must be less than 7.

DIM

must be scalar and of type integer with value in the range 1 <= DIM <= n + 1, where n is the rank of SOURCE.

NCOPIES

must be scalar and of type integer.

Result Type, Type Parameter, and Shape. The result is an array of the same type and type parameters as SOURCE and of rank n + 1, where n is the rank of SOURCE.

Case 1

If SOURCE is scalar, the shape of the result is (MAX(NCOPIES, 0)).

Case 2

If SOURCE is array valued with shape (d1, d2, ..., dn), the shape of the result is (d1, d2, ..., dDIM-1, MAX(NCOPIES, 0), dDIM, ..., dn).

Result Value.

Case 1

If SOURCE is scalar, each element of the result has a value equal to SOURCE.

Case 2

If SOURCE is array valued, the element of the result with subscripts (r1, r2, ..., rn+1) has the value SOURCE(r1, r2, ..., rDIM-1, rDIM+1, ..., rn+1).

Examples.

Case 1

SPREAD("A", 1, 3) is the character array (/ "A", "A", "A" /).

Case 2

If A is the array [2, 3, 4], SPREAD(A, DIM=1, NCOPIES=NC) is the array

      2  3  4
      2  3  4
      2  3  4

if NC has the value 3 and is a zero-sized array if NC has the value 0.

SQRT(X)

Description. Square root.

Class. Elemental function.

Argument. X must be of type real or complex. If X is real, its value must be greater than or equal to zero.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to the square root of X.

A result of type complex is the principal value with the real part greater than or equal to zero. When the real part of the result is zero, the imaginary part is greater than or equal to zero.

Examples.

SQRT(4.0) has the value 2.0.

SQRT(5.0_HIGH) has the value 2.23606774998 with kind HIGH.

SRAND(ISEED)

Description. Restart the pseudorandom number generator used by IRAND and RAND.

Class. Elemental nonstandard subroutine.

Argument. ISEED must be of INTEGER(4) type.

The same value for ISEED generates the same sequence of random numbers. To vary the sequence, call SRAND with a different ISEED value each time the program is executed. The default for ISEED is 1.

Example.

CALL SRAND(5041)

SUM(ARRAY, DIM, MASK)

Optional Arguments. DIM, MASK

Description. Sum all the elements of ARRAY along dimension DIM corresponding to the .TRUE. elements of MASK.

Class. Transformational function.

Arguments.

ARRAY

must be of type integer, real, or complex. It must not be scalar.

DIM (optional)

must be scalar and of type integer with a value in the range 1 <= DIM <= n, where n is the rank of ARRAY. The corresponding actual argument must not be an optional dummy argument.

MASK (optional)

must be of type logical and must be conformable with ARRAY.

Result Type, Type Parameter, and Shape. The result is of the same type and kind type parameter as ARRAY. It is scalar if DIM is absent of ARRAY has rank one; otherwise, the result is an array of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn) where (d1, d2, ..., dn) is the shape of ARRAY.

Result Value.

Case 1

The result of SUM(ARRAY) has a value equal to a processor-dependent approximation to the sum of all the elements of ARRAY or has the value zero if ARRAY has size zero.

Case 2

The result of SUM(ARRAY, MASK = msk) has a value equal to a processor-dependent approximation to the sum of the elements of ARRAY corresponding to the .TRUE. elements of msk or has the value zero if there are no .TRUE. elements.

Case 3

If ARRAY has rank one, SUM(ARRAY, DIM [,msk]) has a value equal to that of SUM(ARRAY [,MASK = msk]). Otherwise, the value of element (s1, s2, ..., sDIM-1, sDIM+1, ..., sn) of SUM(ARRAY, DIM [,msk]) is equal to the following:

SUM(ARRAY(s1, s2, ..., sDIM-1, :, sDIM+1, ..., sn) [, MASK=msk(s1, s2, ..., sDIM-1, :, sDIM+1, ..., sn)])

Examples.

Case 1

The value of SUM((/ 1, 2, 3 /)) and SUM((/ 1, 2, 3 /), DIM=1) is 6.

Case 2

SUM(C, MASK= C .GT. 0.0) forms the arithmetic sum of the positive elements of C.

Case 3

If B is the array

      1  3  5
      2  4  6

then SUM(B, DIM = 1) is [3, 7, 11] and SUM(B, DIM = 2) is [9, 12].

SYSTEM(STR)

Description. Issue a shell command from a Fortran 90 program.

Class. Nonstandard subroutine.

Argument. STR must be of type character. SYSTEM gives STR to the default shell (/bin/sh) as input, as if the string were entered at a terminal. When the shell has completed, the process continues.

Example.

CALL SYSTEM("pwd") prints the working directory from within a Fortran 90 program.

SYSTEM_CLOCK(COUNT, COUNT_RATE, COUNT_MAX)

Optional Arguments. COUNT, COUNT_RATE, COUNT_MAX

Description. Returns integer data from a real-time clock.

Class. Subroutine.

Arguments.

COUNT (optional)

must be scalar and of type default integer. It is an INTENT(OUT) argument. It is set to a processor-dependent value based on the current value of the processor clock or to -HUGE(0) if there is no clock. The processor-dependent value is incremented by one for each clock count until the value COUNT_MAX is reached and is reset to zero at the next count. It lies in the range 0 to COUNT_MAX if there is a clock.

COUNT_RATE (optional)

must be scalar and of type default integer. It is an INTENT(OUT) argument. It is set to the number of processor clock counts per second, or to zero if there is no clock.

COUNT_MAX (optional)

must be scalar and of type default integer. It is an INTENT(OUT) argument. It is set to the maximum value that COUNT can have, or to zero if there is no clock.

Example. If the processor clock is a 24-hour clock that registers time in 1-second intervals, at 11:30 A.M. the reference

CALL SYSTEM_CLOCK (COUNT = C, COUNT_RATE = R, COUNT_MAX = M)

sets C = 11 * 3600 + 30 * 60 = 41400, R = 1, and M = 24 * 3600 - 1 = 86399.

TAN(X)

Description. Tangent function in radians.

Class. Elemental function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to tan(X), with X regarded as a value in radians.

Examples.

TAN(1.0) has the value 1.5574077.

TAN(2.0_HIGH) has the value -2.1850398632615 with kind HIGH.

TAND(X)

Description. Tangent function in degrees.

Class. Elemental nonstandard function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to tan(X).

Examples.

TAND(0.0) has the value 0.0.

TAND(45.0) has the value 1.0.

TAND(135.0) has the value -1.0.

TANH(X)

Description. Hyperbolic tangent function.

Class. Elemental function.

Argument. X must be of type real.

Result Type and Type Parameter. Same as X.

Result Value. The result has a value equal to a processor-dependent approximation to tanh(X).

Examples.

TANH(1.0) has the value 0.76159416.

TANH(2.0_HIGH) has the value 0.96402758007582 with kind HIGH.

TIME(TIMESTR)

Description. Return the current system time.

Class. Nonstandard subroutine.

Argument. TIMESTR must be of type character and must provide at least 8 bytes of storage.

TIME fills TIMESTR with an 8-byte character string of the form hh:mm:ss (hh is the current hour, mm the current minute, ss the number of seconds past the minute).

Example.

The following code sets the character variable tstr to the current system time (for example, "16:20:07", without the quotation marks).

CHARACTER(8) tstr
CALL TIME(tstr)

TINY(X)

Description. Returns the smallest positive number in the model representing numbers of the same type and kind type parameter as the argument.

Class. Inquiry function.

Argument. X must be of type real. It may be scalar or array valued.

Result Type, Type Parameter, and Shape. Scalar with the same type and kind type parameter as X.

Result Value. The result has the value

bemin-1

where b and emin are as defined in “The real number system model”.

Example. TINY(X) has the value 2-127 for real X, whose model is described in “The real number system model”.

TRANSFER(SOURCE, MOLD, SIZE)

Optional Argument. SIZE

Description. Returns a result with a physical representation identical to that of SOURCE but interpreted with the type and type parameters of MOLD.

Class. Transformational function.

Arguments.

SOURCE

may be of any type and may be scalar or array valued.

MOLD

may be of any type and may be scalar or array valued.

SIZE (optional)

must be scalar and of type integer. The corresponding actual argument must not be an optional dummy argument.

Result Type, Type Parameter, and Shape. The result is of the same type and type parameters as MOLD.

Case 1

If MOLD is a scalar and SIZE is absent, the result is a scalar.

Case 2

If MOLD is array valued and SIZE is absent, the result is array valued and of rank one. Its size is as small as possible such that its physical representation is not shorter than that of SOURCE.

Case 3

If SIZE is present, the result is array valued of rank one and size SIZE.

Result Value. If the physical representation of the result has the same length as that of SOURCE, the physical representation of the result is that of SOURCE.

If the physical representation of the result is longer than that of SOURCE, the physical representation of the leading part is that of SOURCE and the remainder is undefined.

If the physical representation of the result is shorter than that of SOURCE, the physical representation of the result is the leading part of SOURCE. If D and E are scalar variables such that the physical representation of D is as long as or longer than that of E, the value of TRANSFER(TRANSFER(E, D), E) must be the value of E.

If D is an array and E is an array of rank one, the value of TRANSFER(TRANSFER(E, D), E, SIZE(E)) must be the value of E.

Examples.

Case 1

TRANSFER (1082130432, 0.0) has the value 4.0 on a processor that represents the values 4.0 and 1082130432 as the string of binary digits 0100 0000 1000 0000 0000 0000 0000 0000.

Case 2

TRANSFER((/ 1.1, 2.2, 3.3 /), (/ (0.0, 0.0) /)) is a complex rank-one array of length two whose first element is (1.1, 2.2) and whose second element has a real part with the value 3.3. The imaginary part of the second element is undefined.

Case 3

TRANSFER((/ 1.1, 2.2, 3.3 /), (/ (0.0, 0.0) /), 1) has the value 1.1 + 2.2i, which is a rank-one array with one complex element.

TRANSPOSE(MATRIX)

Description. Transpose an array of rank two.

Class. Transformational function.

Argument. MATRIX may be of any type and must have rank two.

Result Type,Type Parameters, and Shape. The result is an array of the same type and type parameters as MATRIX and with rank two and shape (n, m) where (m, n) is the shape of MATRIX.

Result Value. Element (i, j) of the result has the value MATRIX(j, i), i= 1, 2, ..., n; j= 1, 2, ..., m.

Example. If A is the array

      1  2  3
      4  5  6
      7  8  9

then TRANSPOSE(A) has the value

      1  4  7
      2  5  8
      3  6  9

TRIM(STRING)

Description. Returns the argument with trailing blank characters removed.

Class. Transformational function.

Argument. STRING must be of type character and must be a scalar.

Result Type and Type Parameters. Character with the same kind type parameter value as STRING and with a length that is the length of STRING less the number of trailing blanks in STRING.

Result Value. The value of the result is the same as STRING except any trailing blanks are removed. If STRING contains no nonblank characters, the result has zero length.

Example. TRIM('bAbBbb') is 'bAbB'.

UBOUND(ARRAY, DIM)

Optional Argument. DIM

Description. Returns all the upper bounds of an array or a specified upper bound.

Class. Inquiry function.

Arguments.

ARRAY

may be of any type. It must not be scalar. It must not be a pointer that is disassociated or an allocatable array that is not allocated. If ARRAY is an assumed-size array, DIM must be present with a value less than the rank of ARRAY.

DIM (optional)

must be scalar and of type integer with a value in the range 1 <= DIM <= n, where n is the rank of ARRAY. The corresponding actual argument must not be an optional dummy argument.

Result Type, Type Parameter, and Shape. The result is of type default integer. It is scalar if DIM is present; otherwise, the result is an array of rank one and size n, where n is the rank of ARRAY.

Result Value.

Case 1

For an array section or for an array expression, other than a whole array or array structure component, UBOUND(ARRAY, DIM) has a value equal to the number of elements in the given dimension; otherwise, it has a value equal to the upper bound for subscript DIM of ARRAY if dimension DIM of ARRAY does not have size zero and has the value zero if dimension DIM has size zero.

Case 2

UBOUND(ARRAY) has a value whose ith component is equal to UBOUND(ARRAY, i), for i= 1, 2, ..., n, where n is the rank of ARRAY.

Examples. If the following statements are processed

REAL, TARGET :: A (2:3, 7:10) 
REAL, POINTER, DIMENSION (:,:) :: B, C, D
B => A; C => A(:,:)
ALLOCATE (D(-3:3,-7:7))

then

  • UBOUND(A) is [3, 10]

  • UBOUND(A, DIM = 2) is 10

  • UBOUND(B) is [3, 10]

  • UBOUND(C) is [2, 4]

  • UBOUND(D) is [3, 7]

UNPACK(VECTOR, MASK, FIELD)

Description. Unpack an array of rank one into an array under the control of a mask.

Class. Transformational function.

Arguments.

VECTOR

may be of any type. It must have rank one. Its size must be at least t where t is the number of .TRUE. elements in MASK.

MASK

must be array valued and of type logical.

FIELD

must be of the same type and type parameters as VECTOR and must be conformable with MASK.

Result Type, Type Parameter, and Shape. The result is an array of the same type and type parameters as VECTOR and the same shape as MASK.

Result Value. The element of the result that corresponds to the ith .TRUE. element of MASK, in array element order, has the value VECTOR(i) for i=1, 2, ..., t, where t is the number of .TRUE. values in MASK. Each other element has a value equal to FIELD if FIELD is scalar or to the corresponding element of FIELD if it is an array.

Examples. Specific values may be "scattered" to specific positions in an array by using UNPACK. If M is the array

     1  0  0
     0  1  0
     0  0  1

then V is the array [1, 2, 3],

and Q is the logical mask

      .  T  .
      T  .  .
      .  .  T

where "T" represents .TRUE. and "." represents .FALSE., then the result of UNPACK(V, MASK = Q, FIELD = M) has the value

      1  2  0
      1  1  0
      0  0  3

and the result of UNPACK(V, MASK = Q, FIELD = 0) has the value

      0  2  0
      1  0  0
      0  0  3

VERIFY(STRING, SET, BACK)

Optional Argument. BACK

Description. Verify that a set of characters contains all the characters in a string by identifying the position of the first character in a string of characters that does not appear in a given set of characters.

Class. Elemental function.

Arguments.

STRING

must be of type character.

SET

must be of type character with the same kind type parameter as STRING.

BACK (optional)

must be of type logical.

Result Type and Type Parameter. Default integer.

Result Value.

Case 1

If BACK is absent or present with the value .FALSE. and if STRING contains at least one character that is not in SET, the value of the result is the position of the leftmost character of STRING that is not in SET.

Case 2

If BACK is present with the value .TRUE. and if STRING contains at least one character that is not in SET, the value of the result is the position of the rightmost character of STRING that is not in SET.

Case 3

The value of the result is zero if each character in STRING is in SET or if STRING has zero length.

Examples.

Case 1

VERIFY('ABBA', 'A') has the value 2.

Case 2

VERIFY('ABBA', 'A', BACK = .TRUE.) has the value 3.

Case 3

VERIFY('ABBA', 'AB') has the value 0.

XOR(I, J)

Description. Bitwise exclusive OR.

Class. Elemental nonstandard function.

Arguments.

I

must be of type integer.

J

must be of type integer with the same kind type parameter as I.

Result Type and Type Parameter. Same as I.

Notes. See “IXOR(I, J)” for result value information and examples.

ZEXT(A)

Description. Zero extend.

Class. Elemental nonstandard function.

Argument. A must be of type integer or logical.

Result. ZEXT converts a 1-, 2-, or 4-byte logical or integer to a 2- or 4-byte integer by sign-extending zeroes instead of the actual sign bit.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1996 Hewlett-Packard Development Company, L.P.