The following is an alphabetical list of all generic names for intrinsic procedures.
For each procedure, several items of information are listed.
Notes:
For example, references to SINH are replaced by references to DSINH when -qrealsize=8 is in effect, and references to DSINH are replaced by references to QSINH.
Terminates the program. It truncates all open output files to the current position of the file pointer, closes all open files, and sends the SIGIOT signal to the current process.
If the SIGIOT is neither caught nor ignored, and if the current directory is writable, the system produces a core file in the current directory.
Class
Subroutine
Examples
The following is an example of a statement using the ABORT subroutine.
IF (ERROR_CONDITION) CALL ABORT
The following is the output generated by the above program:
/home/mark IOT/Abort trap(coredump)
Absolute value.
Class
Elemental function
Result Type and Attributes
The same as A except that if A is complex, the result is real.
Result Value
Examples
ABS ((3.0, 4.0)) has the value 5.0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
IABS | any integer (1) | same as argument | yes |
ABS | default real | default real | yes |
DABS | double precision real | double precision real | yes |
QABS | REAL(16) | REAL(16) | yes |
CABS | default complex | default real | yes |
CDABS | double complex | double precision real | yes |
ZABS | double complex | double precision real | yes |
CQABS | COMPLEX(16) | REAL(16) | yes |
Notes:
Returns the character in a specified position of the ASCII collating sequence. It is the inverse of the IACHAR function.
Class
Elemental function
Result Type and Attributes
Character of length one with the same kind type parameter as KIND ('A').
Result Value
Examples
Arccosine (inverse cosine) function.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
ACOS (1.0) has the value 0.0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ACOS | default real | default real | yes |
DACOS | double precision real | double precision real | yes |
QACOS | REAL(16) | REAL(16) | yes |
QARCOS | REAL(16) | REAL(16) | yes |
Arccosine (inverse cosine) function. Result in degrees.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
ACOSD (0.5) has the value 60.0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ACOSD | default real | default real | yes |
DACOSD | double precision real | double precision real | yes |
QACOSD | REAL(16) | REAL(16) | yes |
Adjust to the left, removing leading blanks and inserting trailing blanks.
Class
Elemental function
Result Type and Attributes
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.
Examples
ADJUSTL (' WORD') has the value 'WORD '.
Adjust to the right, removing trailing blanks and inserting leading blanks.
Class
Elemental function
Result Type and Attributes
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 ('WORD ') has the value ' WORD'.
Imaginary part of a complex number.
Class
Elemental function
Result Type and Attributes
Real with the same kind type parameter as Z.
Result Value
If Z has the value (x,y), the result has the value y.
Examples
AIMAG ((2.0, 3.0)) has the value 3.0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
AIMAG | default complex | default real | yes |
DIMAG | double complex | double precision real | yes |
QIMAG | COMPLEX(16) | REAL(16) | yes |
Truncates to a whole number.
Class
Elemental function
Result Type and Attributes
Result Value
Examples
AINT(3.555) = 3.0 AINT(-3.555) = -3.0
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
AINT | default real | default real | yes |
DINT | double precision real | double precision real | yes |
QINT | REAL(16) | REAL(16) | yes |
Determines if all values in an entire array, or in each vector along a single dimension, are true.
Class
Transformational function
Result Value
The result is a logical array with the same type and type parameters as MASK, and rank rank(mask)-1. If the dim is missing, or mask has a rank of one, the result is a scalar of type logical.
The shape of the result is (s1, s2, ..., s(DIM-1), s(DIM+1), ..., sn), where n is the rank of mask.
Each element in the result array is .TRUE. only if all the elements given by mask(m1, m2, ..., m(DIM-1), :, m(DIM+1), ..., mn), are true. When the result is a scalar, either because dim is not specified or because mask is of rank one, it is .TRUE. only if all elements of mask are true, or MASK has size zero.
Examples
! A is the array | 4 3 6 |, and B is the array | 3 5 2 | ! | 2 4 1 | | 7 8 4 | ! Is every element in A less than the ! corresponding one in B? RES = ALL(A .LT. B) ! result RES is false ! Are all elements in each column of A less than the ! corresponding column of B? RES = ALL(A .LT. B, DIM = 1) ! result RES is (f,t,f) ! Same question, but for each row of A and B. RES = ALL(A .LT. B, DIM = 2) ! result RES is (f,t)
R
Indicate whether or not an allocatable array is currently allocated.
Class
Inquiry function
Result Type and Attributes
Default logical scalar.
Result Value
The result corresponds to the allocation status of array: .TRUE. if it is currently allocated, .FALSE. if it is not currently allocated, or undefined if its allocation status is undefined.
Examples
INTEGER, ALLOCATABLE, DIMENSION(:) :: A PRINT *, ALLOCATED(A) ! A is not allocated yet. ALLOCATE (A(1000)) PRINT *, ALLOCATED(A) ! A is now allocated. END
Related Information
"Allocatable Arrays", ALLOCATE, "Allocation Status".
Nearest whole number.
Class
Elemental function
Result Type and Attributes
Result Value
Note: | The addition and subtraction of 0.5 are done in round-to-zero mode. |
Examples
ANINT(3.555) = 4.0 ANINT(-3.555) = -4.0
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ANINT | default real | default real | yes |
DNINT | double precision real | double precision real | yes |
QNINT | REAL(16) | REAL(16) | yes |
Determines if any of the values in an entire array, or in each vector along a single dimension, are true.
Class
Transformational function
Result Value
The result is a logical array of the same type and type parameters as MASK, and rank of rank(mask)-1. If the dim is missing, or mask has a rank of one, the result is a scalar of type logical.
The shape of the result is (s1, s2, ..., s(DIM -1), s(DIM+1), ..., sn), where n is the rank of mask.
Each element in the result array is .TRUE. if any of the elements given by mask(m1, m2, ..., m(DIM-1), :, m(DIM+1), ..., mn) are true. When the result is a scalar, either because dim is not specified or because mask is of rank one, it is .TRUE. if any of the elements of mask are true.
Examples
! A is the array | 9 -6 7 |, and B is the array | 2 7 8 | ! | 3 -1 5 | | 5 6 9 | ! Is any element in A greater than or equal to the ! corresponding element in B? RES = ANY(A .GE. B) ! result RES is true ! For each column in A, is there any element in the column ! greater than or equal to the corresponding element in B? RES = ANY(A .GE. B, DIM = 1) ! result RES is (t,f,f) ! Same question, but for each row of A and B. RES = ANY(A .GE. B, DIM = 2) ! result RES is (t,f)
Arcsine (inverse sine) function.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
ASIN (1.0) approximates PI/2.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ASIN | default real | default real | yes |
DASIN | double precision real | double precision real | yes |
QASIN | REAL(16) | REAL(16) | yes |
QARSIN | REAL(16) | REAL(16) | yes |
Arcsine (inverse sine) function. Result in degrees.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
ASIND (0.5) has the value 30.0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ASIND | default real | default real | yes |
DASIND | double precision real | double precision real | yes |
QASIND | REAL(16) | REAL(16) | yes |
Returns the association status of its pointer argument, or indicates whether the pointer is associated with the target.
Class
Inquiry function
Result Type and Attributes
Default logical scalar.
Result Value
If only the POINTER argument is specified, the result is .TRUE. if it is associated with any target and .FALSE. otherwise. If TARGET is also specified, the procedure tests whether POINTER is associated with TARGET, or with the same object that TARGET is associated with (if TARGET is also pointer).
The result is undefined if either POINTER or TARGET is associated with a zero-sized array, or if TARGET is a zero-sized array.
Objects with different types or shapes cannot be associated with each other.
Arrays with the same type and shape but different bounds can be associated with each other.
Examples
REAL, POINTER, DIMENSION(:,:) :: A REAL, TARGET, DIMENSION(5,10) :: B, C NULLIFY (A) PRINT *, ASSOCIATED (A) ! False, not associated yet A => B PRINT *, ASSOCIATED (A) ! True, because A is ! associated with B PRINT *, ASSOCIATED (A,C) ! False, A is not ! associated with C END
Arctangent (inverse tangent) function.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
ATAN (1.0) approximates PI/4.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ATAN | default real | default real | yes |
DATAN | double precision real | double precision real | yes |
QATAN | REAL(16) | REAL(16) | yes |
Arctangent (inverse tangent) function. Result in degrees.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
ATAND (1.0) has the value 45.0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ATAND | default real | default real | yes |
DATAND | double precision real | double precision real | yes |
QATAND | REAL(16) | REAL(16) | yes |
Arctangent (inverse tangent) function. The result is the principal value of the nonzero complex number (X, Y) formed by the real arguments Y and X.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
ATAN2 (1.5574077, 1.0) has the value 1.0.
Given that:
Y = | 1 1 | X = | -1 1 | | -1 -1 | | -1 1 |the value of ATAN2(Y,X) is approximately:
ATAN2 (Y, X) = | 3PI/4 PI/4 | | -3PI/4 -PI/4 |
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ATAN2 | default real | default real | yes |
DATAN2 | double precision real | double precision real | yes |
QATAN2 | REAL(16) | REAL(16) | yes |
Arctangent (inverse tangent) function. The result is the principal value of the nonzero complex number (X, Y) formed by the real arguments Y and X.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
ATAN2D (1.5574077, 1.0) has the value 57.295780181 (approximately).
Given that:
Y = | 1.0 1.0 | X = | -1.0 1.0 | | -1.0 -1.0 | | -1.0 1.0 |then the value of ATAN2D(Y,X) is:
ATAN2D(Y,X) = | 135.0000000 45.00000000 | | -135.0000000 -45.00000000 |
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ATAN2D | default real | default real | yes |
DATAN2D | double precision real | double precision real | yes |
QATAN2D | REAL(16) | REAL(16) | yes |
Returns the number of bits in an integer type. Because only the type of the argument is examined, the argument need not be defined.
Class
Inquiry function
Result Type and Attributes
Scalar integer with the same kind type parameter as I.
Result Value
The result is the number of bits in the integer data type of the argument:
type bits ----------- ------ integer(1) 08 integer(2) 16 integer(4) 32 integer(8) 64
The bits are numbered 0 to BIT_SIZE(I)-1, from right to left.
Examples
BIT_SIZE (1_4) has the value 32, because the integer type with kind 4 (that is, a four-byte integer) contains 32 bits.
Tests a bit of an integer value.
Class
Elemental function
Result Type and Attributes
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 the value .FALSE. if bit POS of I has the value 0.
The bits are numbered 0 to BIT_SIZE(I)-1, from right to left.
Examples
BTEST (8, 3) has the value .TRUE..
If A has the value | 1 2 | | 3 4 | the value of BTEST (A, 2) is | false false | | false true | and the value of BTEST (2, A) is | true false | | false false |
See "Integer Bit Model".
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
BTEST | any integer | default logical | yes |
Returns the least integer greater than or equal to its argument.
Class
Elemental function
Result Type and Attributes
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 this value cannot be represented in the default integer type.
Examples
CEILING (3.7) has the value 4. CEILING (-3.7) has the value -3.
Returns the character in the given position of the collating sequence associated with the specified kind type parameter. It is the inverse of the function ICHAR.
Class
Elemental function
Result Type and Attributes
Result Value
Examples
CHAR (88) has the value 'X'.
Notes:
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
CHAR | any integer | default character | yes (1) |
Notes:
Convert to complex type.
Class
Elemental function
Result Type and Attributes
Result Value
Examples
CMPLX (-3) has the value (-3.0, 0.0).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
CMPLX | default real | default complex | no |
Related Information
Conjugate of a complex number.
Class
Elemental function
Result Type and Attributes
Same as Z.
Result Value
Given Z has the value (x, y), the result has the value (x, -y).
Examples
CONJG ((2.0, 3.0)) has the value (2.0, -3.0).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
CONJG | default complex | default complex | yes |
DCONJG | double complex | double complex | yes |
QCONJG | COMPLEX(16) | COMPLEX(16) | yes |
Cosine function.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
COS (1.0) has the value 0.54030231 (approximately).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
COS | default real | default real | yes |
DCOS | double precision real | double precision real | yes |
QCOS | REAL(16) | REAL(16) | yes |
CCOS (1) | default complex | default complex | yes |
CDCOS (2) | double complex | double complex | yes |
ZCOS (2) | double complex | double complex | yes |
CQCOS (2) | COMPLEX(16) | COMPLEX(16) | yes |
Given that X is a complex number in the form a + bi, where i = (-1)½:
Cosine function. Argument in degrees.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
COSD (45.0) has the value 0.7071067691.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
COSD | default real | default real | yes |
DCOSD | double precision real | double precision real | yes |
QCOSD | REAL(16) | REAL(16) | yes |
Hyperbolic cosine function.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
The result value approximates cosh(X).
Examples
COSH (1.0) has the value 1.5430806 (approximately).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
COSH (1) | default real | default real | yes |
DCOSH (2) | double precision real | double precision real | yes |
QCOSH (2) | REAL(16) | REAL(16) | yes |
Notes:
Counts the number of true array elements in an entire logical array, or in each vector along a single dimension. Typically, the logical array is one that is used as a mask in another intrinsic.
Class
Transformational function
Result Value
If DIM is present, the result is an integer array of rank rank(mask)-1. If dim is missing, or mask has a rank of one, the result is a scalar of type integer.
Each element of the resulting array (R(s1, s2, ..., s(DIM-1), s(DIM+1), ..., sn)) equals the number of elements that are true in mask along the corresponding dimension (s1, s2, ..., s(DIM-1), :, s(DIM+1), ..., sn).
If mask is a zero-sized array, the result equals zero.
Examples
! A is the array | T F F |, and B is the array | F F T | ! | F T T | | T T T | ! How many corresponding elements in A and B ! are equivalent? RES = COUNT(A .EQV. B) ! result RES is 3 ! How many corresponding elements are equivalent ! in each column? RES = COUNT(A .EQV. B, DIM=1) ! result RES is (0,2,1) ! Same question, but for each row. RES = COUNT(A .EQV. B, DIM=2) ! result RES is (1,2)
Shifts the elements of all vectors along a given dimension of an array. The shift is circular; that is, elements shifted off one end are inserted again at the other end.
Class
Transformational function
Result Value
The result is an array with the same shape and the same data type as array.
If shift is a scalar, the same shift is applied to each vector. Otherwise, each vector array (s1, s2, ..., s(DIM-1), :, s(DIM+1), ..., sn) is shifted according to the corresponding value in shift (s1, s2, ..., s(DIM-1), s(DIM+1), ..., sn)
The absolute value of shift determines the amount of shift. The sign of shift determines the direction of the shift:
Examples
! A is the array | A D G | ! | B E H | ! | C F I | ! Shift the first column down one, the second column ! up one, and leave the third column unchanged. RES = CSHIFT (A, SHIFT = (/-1,1,0/), DIM = 1) ! The result is | C E G | ! | A F H | ! | B D I | ! Do the same shifts as before, but on the rows ! instead of the columns. RES = CSHIFT (A, SHIFT = (/-1,1,0/), DIM = 2) ! The result is | G A D | ! | E H B | ! | C F I |
The conditional vector merge functions ( CVMGM, CVMGN, CVMGP, CVMGT, and CVMGZ) enable you to port existing code that contains these functions.
Calling them is very similar to calling
MERGE ( TSOURCE, FSOURCE, arith_expr .op. 0 ) or MERGE ( TSOURCE, FSOURCE, logical_expr .op. .TRUE. )Because the MERGE intrinsic is part of the Fortran 90 language, we recommend that you use it instead of these functions for any new programs.
If only one of TSOURCE and FSOURCE is typeless, the typeless argument acquires the type of the other argument. If both TSOURCE and FSOURCE are typeless, both arguments acquire the type of MASK. If MASK is also typeless, both TSOURCE and FSOURCE are treated as default integers. If MASK is typeless, it is treated as a default logical for the CVMGT function and as a default integer for the other CVMGx functions.
Class
Elemental function
Result Type and Attributes
Same as TSOURCE and FSOURCE.
Result Value
The function result is the value of either the first argument or second
argument, depending on the result of the test performed on the third argument.
If the arguments are arrays, the test is performed for each element of the
MASK array and the result may contain some elements from
TSOURCE and some elements from FSOURCE.
Table 15. Result Values for CVMGx Intrinsic Procedures
Explanation | Function Return Value | Generic Name |
---|---|---|
Test for positive or zero | TSOURCE if MASK>=0 FSOURCE if MASK<0 | CVMGP |
Test for negative | TSOURCE if MASK<0 FSOURCE if MASK>=0 | CVMGM |
Test for zero | TSOURCE if MASK=0 FSOURCE if MASK<>0 | CVMGZ |
Test for nonzero | TSOURCE if MASK<>0 FSOURCE if MASK=0 | CVMGN |
Test for true | TSOURCE if MASK= .true. FSOURCE if MASK=.false. | CVMGT |
Returns data from the real-time clock and the date in a form compatible with the representations defined in ISO 8601:1988.
Class
Subroutine
Examples
The following program:
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 executed in Geneva, Switzerland on 1985 April 12 at 15:27:35.5, would have assigned the value 19850412 to BIG_BEN(1), the value 152735.500 to BIG_BEN(2), the value +0100 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 (also known as Greenwich Mean Time).
Convert to double precision real type.
Class
Elemental function
Result Type and Attributes
Double precision real.
Result Value
Examples
DBLE (-3) has the value -3.0D0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
DFLOAT | any integer | double precision real | no |
DBLE | default real | double precision real | no |
DBLEQ | REAL(16) | REAL(8) | no |
Convert to double complex type.
Class
Elemental function
Result Type and Attributes
It is of type double complex.
Result Value
Examples
DCMPLX (-3) has the value (-3.0D0, 0.0D0).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
DCMPLX | double precision real | double complex | no |
Related Information
CMPLX (X, Y, KIND), QCMPLX (X, Y).
Returns the number of significant digits for numbers whose type and kind type parameter are the same as the argument.
Class
Inquiry function
Result Type and Attributes
Default integer scalar.
Result Value
type bits ----------- ------ integer(1) 07 integer(2) 15 integer(4) 31 integer(8) 63
type bits ---------- ------ real(4) 24 real(8) 53 real(16) 106
Examples
DIGITS (X) = 63, where X is of type integer(8) (see "Data Representation Models").
The difference X-Y if it is positive; otherwise zero.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
DIM (-3.0, 2.0) has the value 0.0. DIM (-3.0, -4.0) has the value 1.0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
IDIM | any integer (1) | same as argument | yes |
DIM | default real | default real | yes |
DDIM | double precision real | double precision real | yes |
QDIM | REAL(16) | REAL(16) | yes |
Notes:
Computes the dot product on two vectors.
Class
Transformational function
Result Value
The result is a scalar whose data type depends on the data type of the two vectors, according to the rules in Table 3 and Table 4.
If either vector is a zero-sized array, the result equals zero when it has a numeric data type, and false when it is of type logical.
If vctr_a is of type integer or real, the result value equals SUM(vctr_a * vctr_b).
If vctr_a is of type complex, the result equals SUM(CONJG(vctr_a) * vctr_b).
If vctr_a is of type logical, the result equals ANY(vctr_a .AND. vctr_b).
Examples
! A is (/ 3, 1, -5 /), and B is (/ 6, 2, 7 /). RES = DOT_PRODUCT (A, B) ! calculated as ! ( (3*6) + (1*2) + (-5*7) ) ! = ( 18 + 2 + (-35) ) ! = -15
Double precision real product.
Class
Elemental function
Result Type and Attributes
Double precision real.
Result Value
The result has a value equal to the product of X and Y.
Examples
DPROD (-3.0, 2.0) has the value -6.0D0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
DPROD | default real | double precision real | yes |
QPROD | double precision real | REAL(16) | yes |
Shifts the elements of all vectors along a given dimension of an array. The shift is end-off; that is, elements shifted off one end are lost, and copies of boundary elements are shifted in at the other end.
Class
Transformational function
Result Value
The result is an array with the same shape and data type as array.
The absolute value of shift determines the amount of shift. The sign of shift determines the direction of the shift:
Result Value
If boundary is a scalar value, this value is used in all shifts.
If boundary is an array of values, the values of the array elements of boundary with subscripts (s1, s2, ..., s(DIM-1), s(DIM+1), ..., sn) are used for that dimension.
If boundary is not specified, the following default values are used, depending on the data type of array:
Examples
! A is | 1.1 4.4 7.7 |, SHIFT is S=(/0, -1, 1/), ! | 2.2 5.5 8.8 | ! | 3.3 6.6 9.9 | ! and BOUNDARY is the array B=(/-0.1, -0.2, -0.3/). ! Leave the first column alone, shift the second ! column down one, and shift the third column up one. RES = EOSHIFT (A, SHIFT = S, BOUNDARY = B, DIM = 1) ! The result is | 1.1 -0.2 8.8 | ! | 2.2 4.4 9.9 | ! | 3.3 5.5 -0.3 | ! Do the same shifts as before, but on the ! rows instead of the columns. RES = EOSHIFT (A, SHIFT = S, BOUNDARY = B, DIM = 2) ! The result is | 1.1 4.4 7.7 | ! | -0.2 2.2 5.5 | ! | 6.6 9.9 -0.3 |
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
Result Type and Attributes
Scalar of the same type and kind type parameter as X.
Result Value
The result is
2.0ei01 - DIGITS(X)where ei is the exponent indicator (E, D, or Q) depending on the type of X:
type EPSILON(X) ---- ------------------ real(4) 02E0 ** (-23) real(8) 02D0 ** (-52) real(16) 02Q0 ** (-105)
Examples
EPSILON (X) = 1.1920929E-07 for X of type real(4). See "Real Data Model".
Error function.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
ERF (1.0) has the value 0.8427007794 (approximately).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ERF | default real | default real | yes |
DERF | double precision real | double precision real | yes |
QERF | REAL(16) | REAL(16) | yes |
Complementary error function.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
ERFC (1.0) has the value 0.1572992057 (approximately).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ERFC | default real | default real | yes |
DERFC | double precision real | double precision real | yes |
QERFC | REAL(16) | REAL(16) | yes |
Exponential.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
EXP (1.0) has the value 2.7182818 (approximately).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
EXP (1) | default real | default real | yes |
DEXP (2) | double precision real | double precision real | yes |
QEXP (2) | REAL(16) | REAL(16) | yes |
CEXP (3a) | default complex | default complex | yes |
CDEXP (3b) | double complex | double complex | yes |
ZEXP (3b) | double complex | double complex | yes |
CQEXP (3b) | COMPLEX(16) | COMPLEX(16) | yes |
Notes:
Returns the exponent part of the argument when represented as a model number.
Class
Elemental function
Result Type and Attributes
Default integer.
Result Value
Examples
EXPONENT (10.2) = 4. See "Real Data Model"
Returns the greatest integer less than or equal to its argument.
Class
Elemental function
Result Type and Attributes
Default integer.
Result Value
The result has the value equal to the greatest integer less than or equal to A. The result is undefined if this value cannot be represented in the default integer type.
Examples
FLOOR (3.7) has the value 3. FLOOR (-3.7) has the value -4.
Returns the fractional part of the model representation of the argument value.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
The result is:
X * (2.0-EXPONENT(X))
Examples
FRACTION(10.2) = 2-4 * 10.2 &approx. 0.6375
Gamma function.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
The result has a value that approximates Gamma(X).
Examples
GAMMA (1.0) has the value 1.0.
GAMMA (10.0) has the value 362880.0 (approximately).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
GAMMA (1) | default real | default real | yes |
DGAMMA (2) | double precision real | double precision real | yes |
QGAMMA (3) | REAL(16) | REAL(16) | yes |
X must satisfy the inequality:
Determines the value of the specified environment variable.
Class
Subroutine
Result Value
The result is returned in the VALUE argument, not as a function result variable.
If the environment variable specified in the NAME argument does not exist, the VALUE argument contains blanks.
Examples
CHARACTER (LEN=16) ENVDATA CALL GETENV('HOME', VALUE=ENVDATA) ! Print the value. PRINT *, ENVDATA ! Show how it is blank-padded on the right. WRITE(*, '(Z32)') ENVDATA END
The following is sample output generated by the above program:
/home/mark 2F686F6D652F6D61726B202020202020
Related Information
See the getenv subroutine in the Technical Reference: Base Operating System and Extensions Volume 1 for details about the operating-system-level implementation.
Convert from REAL(4) to INTEGER(2).
This procedure is a specific function, not a generic function.
Class
Elemental function
Result Type and Attributes
An INTEGER(2) scalar or array.
Result Value
Examples
HFIX (-3.7) has the value -3.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
HFIX | REAL(4) | INTEGER(2) | no |
Returns the largest number in the model representing numbers of the same type and kind type parameter as the argument.
Class
Inquiry function
Result Type and Attributes
Scalar of the same type and kind type parameter as X.
Result Value
2DIGITS(X) - 1
(1.0 - 2.0-DIGITS(X)) * (2.0MAXEXPONENT(X))
Examples
HUGE (X) = (1D0 - 2D0**-53) * (2D0**1024) for X of type real(8).
HUGE (X) = (2**63) - 1 for X of type integer(8).
See "Data Representation Models".
Returns the position of a character in the ASCII collating sequence.
Class
Elemental function
Result Type and Attributes
Default integer.
Result Value
Examples
IACHAR ('X') has the value 88.
Performs a logical AND.
Class
Elemental function
Result Type and Attributes
Same as I.
Result Value
The result has the value obtained by combining I and J bit-by-bit according to the following table:
I J IAND (I,J) ------------------ 1 1 1 1 0 0 0 1 0 0 0 0
The bits are numbered 0 to BIT_SIZE(I)-1, from right to left.
Examples
IAND (1, 3) has the value 1. See "Integer Bit Model".
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
IAND | any integer | same as argument | yes |
AND | any integer | same as argument | yes |
Clears one bit to zero.
Class
Elemental function
Result Type and Attributes
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 bits are numbered 0 to BIT_SIZE(I)-1, from right to left.
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/).
See "Integer Bit Model".
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
IBCLR | any integer | same as argument | yes |
Extracts a sequence of bits.
Class
Elemental function
Result Type and Attributes
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 bits are numbered 0 to BIT_SIZE(I)-1, from right to left.
Examples
IBITS (14, 1, 3) has the value 7. See "Integer Bit Model".
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
IBITS | any integer | same as argument | yes |
Sets one bit to one.
Class
Elemental function
Result Type and Attributes
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 bits are numbered 0 to BIT_SIZE(I)-1, from right to left.
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/).
See .
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
IBSET | any integer | same as I | yes |
Returns the position of a character in the collating sequence associated with the kind type parameter of the character.
Class
Elemental function
Result Type and Attributes
Default integer.
Result Value
Examples
ICHAR ('X') has the value 88 in the ASCII collating sequence.
Notes:
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ICHAR | default character | default integer | yes (1) |
Notes:
Performs an exclusive OR.
Class
Elemental function
Result Type and Attributes
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:
I J IEOR (I,J) ----------------- 1 1 0 1 0 1 0 1 1 0 0 0
The bits are numbered 0 to BIT_SIZE(I)-1, from right to left.
Examples
IEOR (1, 3) has the value 2. See "Integer Bit Model".
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
IEOR | any integer | same as argument | yes |
XOR | any integer | same as argument | yes |
Returns one less than the length, in bits, of the twos complement representation of an integer.
Class
Elemental function
Result Type and Attributes
Same as I.
Result Value
Examples
I=ILEN(4) ! 3 J=ILEN(-4) ! 2
Identical to AIMAG.
Related Information
Returns the starting position of a substring within a string.
Class
Elemental function
Result Type and Attributes
Default integer.
Result Value
Examples
INDEX ('FORTRAN', 'R') has the value 3.
INDEX ('FORTRAN', 'R', BACK = .TRUE.) has the value 5.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
INDEX | default character | default integer | yes (1) |
Note: | When this specific name is passed as an argument, the procedure can only be referenced without the BACK optional argument. |
Convert to integer type.
Class
Elemental function
Result Type and Attributes
Result Value
Examples
INT (-3.7) has the value -3.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
INT | default real | default integer | no |
IDINT | double precision real | default integer | no |
IFIX | default real | default integer | no |
IQINT | REAL(16) | default integer | no |
Performs an inclusive OR.
Class
Elemental function
Result Type and Attributes
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:
I J IOR (I,J) ----------------- 1 1 1 1 0 1 0 1 1 0 0 0
The bits are numbered 0 to BIT_SIZE(I)-1, from right to left.
Examples
IOR (1, 3) has the value 3. See "Integer Bit Model".
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
IOR | any integer | same as argument | yes |
OR | any integer | same as argument | yes |
Performs a logical shift.
Class
Elemental function
Result Type and Attributes
Same as I.
Result Value
Examples
ISHFT (3, 1) has the result 6. See "Integer Bit Model".
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ISHFT | any integer | same as argument | yes |
Performs a circular shift of the right-most bits; that is, bits shifted off one end are inserted again at the other end.
Class
Elemental function
Result Type and Attributes
Same as I.
Result Value
The result has the value obtained by shifting the SIZE right-most 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 bits are numbered 0 to BIT_SIZE(I)-1, from right to left.
Examples
ISHFTC (3, 2, 3) has the value 5. See "Integer Bit Model".
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ISHFTC | any integer | same as argument | yes (1) |
Notes:
Returns the value of the kind type parameter of X.
Class
Inquiry function
Result Type and Attributes
Default integer scalar.
Result Value
The result has a value equal to the kind type parameter value of X.
Kind type parameters supported by XL Fortran are defined in "Intrinsic Types".
Examples
KIND (0.0) has the kind type parameter value of the default real type.
Returns the lower bound of each dimension in an array, or the lower bound of a specified dimension.
Class
Inquiry function
Result Type and Attributes
Default integer.
If DIM is present, the result is a scalar. If DIM is not present, the result is a one-dimensional array with one element for each dimension in array.
Result Value
Each element in the result corresponds to a dimension of array.
The only exception is for a dimension that is zero-sized and ARRAY is not an assumed-size array of rank DIM, In such a case, the corresponding element in the result is one regardless of the value declared for the lower bound.
Examples
REAL A(1:10, -4:5, 4:-5) RES=LBOUND( A ) ! The result is (/ 1, -4, 1 /). RES=LBOUND( A(:,:,:) ) RES=LBOUND( A(4:10,-4:1,:) ) ! The result in both cases is (/ 1, 1, 1 /) ! because the arguments are array sections.
Returns the number of leading zero-bits in the binary representation of an integer.
Class
Elemental function
Result Type and Attributes
Same as I.
Result Value
The result is the count of zero-bits to the left of the left-most one-bit for an integer.
Examples
I = LEADZ(0_4) ! I=32 J = LEADZ(4_4) ! J=29 K = LEADZ(-1_4) ! K=0
Returns the length of a character entity. The argument to this function need not be defined.
Class
Inquiry function
Result Type and Attributes
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.
Examples
If C is declared by the statement
CHARACTER (11) C(100)
LEN (C) has the value 11.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
LEN | default character | default integer | yes (1) |
Notes:
Returns the length of the character argument without counting trailing blank characters.
Class
Elemental function
Result Type and Attributes
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 (' A B ') has the value 4. LEN_TRIM (' ') has the value 0.
Log of gamma function.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
The result has a value equal to logeGamma(X).
Examples
LGAMMA (1.0) has the value 0.0.
LGAMMA (10.0) has the value 12.80182743 (approximately).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
LGAMMA | default real | default real | yes |
LGAMMA | double precision real | double precision real | yes |
ALGAMA (1) | default real | default real | yes |
DLGAMA (2) | double precision real | double precision real | yes |
QLGAMA (3) | REAL(16) | REAL(16) | yes |
X must satisfy the inequality:
Test whether a string is lexically greater than or equal to another string, based on the ASCII collating sequence.
Class
Elemental function
Result Type and Attributes
Default logical.
Result Value
Examples
LGE ('ONE', 'TWO') has the value .FALSE..
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
LGE | default character | default logical | yes (1) |
Notes:
Test whether a string is lexically greater than another string, based on the ASCII collating sequence.
Class
Elemental function
Result Type and Attributes
Default logical.
Result Value
Examples
LGT ('ONE', 'TWO') has the value .FALSE..
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
LGT | default character | default logical | yes (1) |
Notes:
Test whether a string is lexically less than or equal to another string, based on the ASCII collating sequence.
Class
Elemental function
Result Type and Attributes
Default logical.
Result Value
Examples
LLE ('ONE', 'TWO') has the value .TRUE..
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
LLE | default character | default logical | yes (1) |
Notes:
Test whether a string is lexically less than another string, based on the ASCII collating sequence.
Class
Elemental function
Result Type and Attributes
Default logical.
Result Value
Examples
LLT ('ONE', 'TWO') has the value .TRUE..
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
LLT | default character | default logical | yes (1) |
Notes:
Returns the address of X that can then be used to define an integer POINTER.
Class
Inquiry function
Result Type and Attributes
LOC returns INTEGER(4) in 32-bit and INTEGER(8) in 64-bit.
Result Value
The result is the address of the data object, or, if X is a pointer, the address of the associated target. The result is undefined if the argument is not valid.
Examples
INTEGER A,B POINTER (P,I) P=LOC(A) P=LOC(B) END
Natural logarithm.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
If the argument type is complex, the result is the principal value of the imaginary part &omega. in the range -PI < &omega. <= PI. If the real part of the argument is less than zero and its imaginary part is zero, the imaginary part of the result approximates PI.
Examples
LOG (10.0) has the value 2.3025851 (approximately).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ALOG | default real | default real | yes |
DLOG | double precision real | double precision real | yes |
QLOG | REAL(16) | REAL(16) | yes |
CLOG | default complex | default complex | yes |
CDLOG | double complex | double complex | yes |
ZLOG | double complex | double complex | yes |
CQLOG | COMPLEX(16) | COMPLEX(16) | yes |
Common logarithm.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
The result has a value equal to log10X.
Examples
LOG10 (10.0) has the value 1.0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
ALOG10 | default real | default real | yes |
DLOG10 | double precision real | double precision real | yes |
QLOG10 | REAL(16) | REAL(16) | yes |
Converts between objects of type logical with different kind type parameter values.
Class
Elemental function
Result Type and Attributes
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.
Performs a logical shift to the left.
Class
Elemental function
Result Type and Attributes
Same as I.
Result Value
Examples
LSHIFT (3, 1) has the result 6.
LSHIFT (3, 2) has the result 12.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
LSHIFT | any integer | same as argument | yes |
Performs a matrix multiplication.
Note: | Strassen's method is not stable for certain row or column scalings of the input matrices. Therefore, for MATRIX_A and MATRIX_B with divergent exponent values, Strassen's method may give inaccurate results. |
The significance of the value of MINDIM is:
By default, MATMUL employs the conventional O(N**3) method of matrix multiplication.
If you link the libxlf90_r.a library, a parallel implementation of matrix multiplication is employed which improves performance on SMP machines.
If you link the libxlf90.a or libxlf90_t.a library, the Winograd variation of the O(N**2.81) Strassen method is employed under these conditions:
At least one of the arguments must be of rank two. The size of the first or only dimension of matrix_b must be equal to the last or only dimension of matrix_a.
Class
Transformational function
Result Value
The result is an array. If one of the arguments is of rank one, the result has a rank of one. If both arguments are of rank two, the result has a rank of two.
The data type of the result depends on the data type of the arguments, according to the rules in Table 3 and Table 4.
If matrix_a and matrix_b have a numeric data type, the array elements of the result are:
If matrix_a and matrix_b are of type logical, the array elements of the result are:
Examples
! A is the array | 1 2 3 |, B is the array | 7 10 | ! | 4 5 6 | | 8 11 | ! | 9 12 | RES = MATMUL(A, B) ! The result is | 50 68 | ! | 122 167 |
! HUGE_ARRAY and GIGANTIC_ARRAY in this example are ! large arrays of real or complex type, so the operation ! might be faster with the Strassen algorithm. RES = MATMUL(HUGE_ARRAY, GIGANTIC_ARRAY, MINDIM=196)
Related Information
The numerical stability of Strassen's method for matrix multiplication is discussed in:
Maximum value.
Class
Elemental function
Result Type and Attributes
Same as the arguments. (Some specific functions return results of a particular type.)
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.
If you evaluate MAX (10, 3, A), where A is an optional array argument in the calling procedure, PRESENT(A) must be true in the calling procedure.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
AMAX0 | any integer (1) | default real | no |
AMAX1 | default real | default real | no |
DMAX1 | double precision real | double precision real | no |
QMAX1 | REAL(16) | REAL(16) | no |
MAX0 | any integer (1) | same as argument | no |
MAX1 | any real (2) | default integer | no |
Notes:
Returns the maximum exponent in the model representing numbers of the same type and kind type parameter as the argument.
Class
Inquiry function
Result Type and Attributes
Default integer scalar.
Result Value
The result is the following:
type MAXEXPONENT ---------- ----------- real(4) 128 real(8) 1024 real(16) 1024
Examples
MAXEXPONENT(X) = 128 for X of type real(4).
See "Real Data Model".
Locates the first element of an array along a dimension that has the maximum value of all elements corresponding to the true values of the mask. MAXLOC will return the index referable to the position of the element using a positive integer.
Class
Transformational function
Result Type and Attributes
If DIM is absent, the result is an integer array of rank one with a size equal to the rank of ARRAY. If DIM is present, the result is an integer array of rank rank(ARRAY)-1, and the shape is (s1, ..., sDIM-1, sDIM+1, ..., sn), where n is the rank of ARRAY.
If there is no maximum value, perhaps because the array is zero-sized or the mask array has all .FALSE. values or there is no DIM argument, the return value is a zero-sized one-dimensional entity. If DIM is present, the result shape depends on the rank of ARRAY.
Result Value
The result indicates the subscript of the location of the maximum masked element of array. If more than one element is equal to this maximum value, the function finds the location of the first (in array element order). If DIM is specified, the result indicates the location of the maximum masked element along each vector of the dimension.
Because both DIM and MASK are optional, various combinations of arguments are possible. When the -qintlog option is specified with two arguments, the second argument refers to one of the following:
The addition of the DIM argument modifies the behavior from XL Fortran Version 3.
Examples
! A is the array | 4 9 8 -8 | ! | 2 1 -1 5 | ! | 9 4 -1 9 | ! | -7 5 7 -3 | ! Where is the largest element of A? RES = MAXLOC(A) ! The result is | 3 1 | because 9 is located at A(3,1). ! Although there are other 9s, A(3,1) is the first in ! column-major order. ! Where is the largest element in each column of A ! that is less than 7? RES = MAXLOC(A, DIM = 1, MASK = A .LT. 7) ! The result is | 1 4 2 2 | because these are the corresponding ! row locations of the largest value in each column ! that are less than 7 (the values being 4,5,-1,5).
Regardless of the defined upper and lower bounds of the array, MAXLOC will determine the lower bound index as '1'. Both MAXLOC and MINLOC index using positive integers. To find the actual index:
INTEGER B(-100:100) ! Maxloc views the bounds as (1:201) ! If the largest element is located at index '-49' I = MAXLOC(B) ! Will return the index '52' ! To return the exact index for the largest element, insert: INDEX = LBOUND(B) - 1 + I ! Which is: INDEX = (-100) - 1 + 52 = (-49) PRINT*, B(INDEX)
Returns the maximum value of the elements in the array along a dimension corresponding to the true elements of MASK.
Class
Transformational function
Result Value
The result is an array of rank rank(ARRAY)-1, with the same data type as array. If dim is missing or if ARRAY is of rank one, the result is a scalar.
If dim is specified, each element of the result value contains the maximum value of all the elements that satisfy the condition specified by mask along each vector of the dimension dim. The array element subscripts in the result are (s1, s2, ..., s(DIM-1), s(DIM+1), ..., sn), where n is the rank of array and DIM is the dimension specified by dim.
If dim is not specified, the function returns the maximum value of all applicable elements.
If ARRAY is zero-sized or the mask array has all .FALSE. values, the result value is the negative number of the largest magnitude, of the same type and kind type as ARRAY.
Examples
! A is the array | -41 33 25 | ! | 12 -61 11 | ! What is the largest value in the entire array? RES = MAXVAL(A) ! The result is 33 ! What is the largest value in each column? RES = MAXVAL(A, DIM=1) ! The result is | 12 33 25 | ! What is the largest value in each row? RES = MAXVAL(A, DIM=2) ! The result is | 33 12 | ! What is the largest value in each row, considering only ! elements that are less than 30? RES = MAXVAL(A, DIM=2, MASK = A .LT. 30) ! The result is | 25 12 |
Selects between two values, or corresponding elements in two arrays. A logical mask determines whether to take each result element from the first or second argument.
Class
Elemental function
Result Value
The result has the same shape and data type as tsource and fsource.
For each element in the result, the value of the corresponding element in mask determines whether the value is taken from tsource (if true) or fsource (if false).
Examples
! TSOURCE is | A D G |, FSOURCE is | a d g |, ! | B E H | | b e h | ! | C F I | | c f i | ! ! and MASK is the array | T T T | ! | F F F | ! | F F F | ! Take the top row of TSOURCE, and the remaining elements ! from FSOURCE. RES = MERGE(TSOURCE, FSOURCE, MASK) ! The result is | A D G | ! | b e h | ! | c f i | ! Evaluate IF (X .GT. Y) THEN ! RES=6 ! ELSE ! RES=12 ! END IF ! in a more concise form. RES = MERGE(6, 12, X .GT. Y)
Minimum value.
Class
Elemental function
Result Type and Attributes
Same as the arguments. (Some specific functions return results of a particular type.)
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.
If you evaluate MIN (10, 3, A), where A is an optional array argument in the calling procedure, PRESENT(A) must be true in the calling procedure.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
AMIN0 | any integer | default real | no |
AMIN1 | default real | default real | no |
DMIN1 | double precision real | double precision real | no |
QMIN1 | REAL(16) | REAL(16) | no |
MIN0 | any integer | same as argument | no |
MIN1 | any real | default integer | no |
Returns the minimum (most negative) exponent in the model representing the numbers of the same type and kind type parameter as the argument.
Class
Inquiry function
Result Type and Attributes
Default integer scalar.
Result Value
The result is the following:
type MINEXPONENT ---------- ----------- real(4) - 125 real(8) -1021 real(16) -968
Examples
MINEXPONENT(X) = -125 for X of type real(4).
See "Real Data Model".
Locates the first element of an array along a dimension that has the minimum value of all elements corresponding to the true values of the mask. MINLOC will return the index referable to the position of the element using a positive integer.
Class
Transformational function
Result Type and Attributes
If DIM is absent, the result is an integer array of rank one with a size equal to the rank of ARRAY. If DIM is present, the result is an integer array of rank rank(ARRAY)-1, and the shape is (s1, ..., sDIM-1, sDIM+1, ..., sn), where n is the rank of ARRAY.
If there is no minimum value, perhaps because the array is zero-sized or the mask array has all .FALSE. values or there is no DIM argument, the return value is a zero-sized one-dimensional entity. If DIM is present, the result shape depends on the rank of ARRAY.
Result Value
The result indicates the subscript of the location of the minimum masked element of array. If more than one element is equal to this minimum value, the function finds the location of the first (in array element order). If DIM is specified, the result indicates the location of the minimum masked element along each vector of the dimension.
Because both DIM and MASK are optional, various combinations of arguments are possible. When the -qintlog option is specified with two arguments, the second argument refers to one of the following:
The addition of the DIM argument modifies the behavior from XL Fortran Version 3.
Examples
! A is the array | 4 9 8 -8 | ! | 2 1 -1 5 | ! | 9 4 -1 9 | ! | -7 5 7 -3 | ! Where is the smallest element of A? RES = MINLOC(A) ! The result is | 1 4 | because -8 is located at A(1,4). ! Where is the smallest element in each row of A that ! is not equal to -7? RES = MINLOC(A, DIM = 2, MASK = A .NE. -7) ! The result is | 4 3 3 4 | because these are the ! corresponding column locations of the smallest value ! in each row not equal ! to -7 (the values being ! -8,-1,-1,-3).
Regardless of the defined upper and lower bounds of the array, MINLOC will determine the lower bound index as '1'. Both MAXLOC and MINLOC index using positive integers. To find the actual index:
INTEGER B(-100:100) ! Minloc views the bounds as (1:201) ! If the smallest element is located at index '-49' I = MINLOC(B) ! Will return the index '52' ! To return the exact index for the smallest element, insert: INDEX = LBOUND(B) - 1 + I ! Which is: INDEX = (-100) - 1 + 52 = (-49) PRINT*, B(INDEX)
Returns the minimum value of the elements in the array along a dimension corresponding to the true elements of MASK.
Class
Transformational function
Result Value
The result is an array of rank rank(ARRAY)-1, with the same data type as array. If dim is missing or if ARRAY is of rank one, the result is a scalar.
If dim is specified, each element of the result value contains the minimum value of all the elements that satisfy the condition specified by mask along each vector of the dimension dim. The array element subscripts in the result are (s1, s2, ..., s(DIM-1), s(DIM+1), ..., sn), where n is the rank of array and DIM is the dimension specified by dim.
If dim is not specified, the function returns the minimum value of all applicable elements.
If ARRAY is zero-sized or the mask array has all .FALSE. values, the result value is the positive number of the largest magnitude, of the same type and kind type as ARRAY.
Examples
! A is the array | -41 33 25 | ! | 12 -61 11 | ! What is the smallest element in A? RES = MINVAL(A) ! The result is -61 ! What is the smallest element in each column of A? RES = MINVAL(A, DIM=1) ! The result is | -41 -61 11 | ! What is the smallest element in each row of A? RES = MINVAL(A, DIM=2) ! The result is | -41 -61 | ! What is the smallest element in each row of A, ! considering only those elements that are ! greater than zero? RES = MINVAL(A, DIM=2, MASK = A .GT.0) ! The result is | 25 11 |
Remainder function.
Class
Elemental function
Result Type and Attributes
Same as A.
Result Value
Examples
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
MOD | any integer | same as argument | yes |
AMOD | default real | default real | yes |
DMOD | double precision real | double precision real | yes |
QMOD | REAL(16) | REAL(16) | yes |
Modulo function.
Class
Elemental function
Result Type and Attributes
Same as A.
Result Value
If P > 0, the inequalities 0 <= R < P hold.
If P < 0, P < R <= 0 hold.
If P = 0, the result is undefined.
If P = 0, the result is undefined.
Examples
Copies a sequence of bits from one data object to another.
The bits are numbered 0 to BIT_SIZE(I)-1, from right to left.
Class
Elemental subroutine
Examples
If TO has the initial value 6, the value of TO is 5 after the statement
CALL MVBITS (7, 2, 2, TO, 0)
See "Integer Bit Model".
Returns the nearest different processor-representable number in the direction indicated by the sign of S (toward positive or negative infinity).
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
The result is the machine number different from and nearest to X in the direction of the infinity with the same sign as S.
Examples
NEAREST (3.0, 2.0) = 3.0 + 2.0(-22). See "Real Data Model".
Nearest integer.
Class
Elemental function
Result Type and Attributes
Result Value
Examples
NINT (2.789) has the value 3. NINT (2.123) has the value 2.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
NINT | default real | default integer | yes |
IDNINT | double precision real | default integer | yes |
IQNINT | REAL(16) | default integer | yes |
Performs a logical complement.
Class
Elemental function
Result Type and Attributes
Same as I.
Result Value
The result has the value obtained by complementing I bit-by-bit according to the following table:
I NOT (I) --------- 1 0 0 1
The bits are numbered 0 to BIT_SIZE(I)-1, from right to left.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
NOT | any integer | same as argument | yes |
Returns a scalar of type default integer whose value is always 1.
Class
System inquiry function
Result Type and Attributes
Default scalar integer which always has a value of 1 in a uniprocessor environment.
Examples
I = NUMBER_OF_PROCESSORS() ! 1 J = NUMBER_OF_PROCESSORS(DIM=1) ! 1
Returns the number of parallel Fortran threads the run time should create during execution of a program. This value is set by using the PARTHDS run-time option. If the user does not set the PARTHDS run-time option, the run time will set a default value for PARTHDS. In doing so, the run time may consider the following when setting the option:
Class
Inquiry function
Result Value
Default scalar integer
If the compiler option -qsmp has not been specified, then NUM_PARTHDS will always return a value of 1.
Examples
I = NUM_PARTHDS() IF (I == 1) THEN CALL SINGLE_THREAD_ROUTINE() ELSE CALL MULTI_THREAD_ROUTINE()
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
NUM_PARTHDS | default scalar integer | default scalar integer | no |
Related Information
See the "PARTHDS" run-time option and the "XLSMPOPTS" run-time option in the User's Guide.
Returns the number of threads that will be explicitly created by the user during execution of the program. This value is set by using the USRTHDS run-time option.
Class
Inquiry function
Result Value
Default scalar integer
If the value has not been explicitly set using the USRTHDS run-time option, the default value is 0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
NUM_USRTHDS | default scalar integer | default scalar integer | no |
Related Information
See the "USRTHDS" run-time option and the "XLSMPOPTS" run-time option in the User's Guide.
Takes some or all elements from an array and packs them into a one-dimensional array, under the control of a mask.
Class
Transformational function
Result Value
The result is always a one-dimensional array with the same data type as array.
The size of the result depends on the optional arguments:
The array elements in array are taken in array element order to form the result. If the corresponding array element in mask is .TRUE., the element from array is placed at the end of the result.
If any elements remain empty in the result (because vector is present, and has more elements than there are .TRUE. values in mask), the remaining elements in the result are set to the corresponding values from vector.
Examples
! A is the array | 0 7 0 | ! | 1 0 3 | ! | 4 0 0 | ! Take only the non-zero elements of this sparse array. ! If there are less than six, fill in -1 for the rest. RES = PACK(A, MASK= A .NE. 0, VECTOR=(/-1,-1,-1,-1,-1,-1/) ! The result is (/ 1, 4, 7, 3, -1, -1 /). ! Elements 1, 4, 7, and 3 are taken in order from A ! because the value of MASK is true only for these ! elements. The -1s are added to the result from VECTOR ! because the length (6) of VECTOR exceeds the number ! of .TRUE. values (4) in MASK.
Returns the decimal precision in the model representing real numbers with the same kind type parameter as the argument.
Class
Inquiry function
Result Type and Attributes
Default integer scalar.
Result Value
The result is:
INT( (DIGITS(X) - 1) * LOG10(2) )
Therefore,
Type Precision -------------------- --------- real(4) , complex(4) 6 real(8) , complex(8) 15 real(16) , complex(16) 31
Examples
PRECISION (X) = INT( (24 - 1) * LOG10(2.) ) = INT(6.92 ...) = 6 for X of type real(4). See "Real Data Model".
Determine whether an optional argument is present. If it is not present, you may only pass it as an optional argument to another procedure or pass it as an argument to PRESENT.
Class
Inquiry function
Result Type and Attributes
Default logical scalar.
Result Value
The result is .TRUE. if the actual argument is present (that is, if it was passed to the current procedure in the specified dummy argument), and .FALSE. otherwise.
Examples
SUBROUTINE SUB (X, Y) REAL, OPTIONAL :: Y IF (PRESENT (Y)) THEN ! In this section, we can use y like any other variable. X = X + Y PRINT *, SQRT(Y) ELSE ! In this section, we cannot define or reference y. X = X + 5 ! We can pass it to another procedure, but only if ! sub2 declares the corresponding argument as optional. CALL SUB2 (Z, Y) ENDIF END SUBROUTINE SUB
Related Information
Returns a zero-sized array.
Class
System inquiry function
Result Type and Attributes
Default integer array of rank one, whose size is equal to the rank of the processor array. In a uniprocessor environment, the result is a zero-sized vector.
Result Value
The value of the result is the shape of the processor array.
Examples
I=PROCESSORS_SHAPE() ! Zero-sized vector of type default integer
Multiplies together all elements in an entire array, or selected elements from all vectors along a dimension.
Class
Transformational function
Result Value
If DIM is present, the result is an array of rank rank(array)-1 and the same data type as array. If dim is missing, or if mask has a rank of one, the result is a scalar.
The result is calculated by one of the following methods:
Examples
! Multiply all elements in an array. RES = PRODUCT( (/2, 3, 4/) ) ! The result is 24 because (2 * 3 * 4) = 24. ! Do the same for a two-dimensional array. RES = PRODUCT( (/2, 3, 4/), (/4, 5, 6/) ) ! The result is 2880. All elements are multiplied.
! A is the array (/ -3, -7, -5, 2, 3 /) ! Multiply all elements of the array that are > -5. RES = PRODUCT(A, MASK = A .GT. -5) ! The result is -18 because (-3 * 2 * 3) = -18.
! A is the array | -2 5 7 | ! | 3 -4 3 | ! Find the product of each column in A. RES = PRODUCT(A, DIM = 1) ! The result is | -6 -20 21 | because (-2 * 3) = -6 ! ( 5 * -4 ) = -20 ! ( 7 * 3 ) = 21 ! Find the product of each row in A. RES = PRODUCT(A, DIM = 2) ! The result is | -70 -36 | ! because (-2 * 5 * 7) = -70 ! (3 * -4 * 3) = -36 ! Find the product of each row in A, considering ! only those elements greater than zero. RES = PRODUCT(A, DIM = 2, MASK = A .GT. 0) ! The result is | 35 9 | because ( 5 * 7) = 35 ! (3 * 3) = 9
Convert to extended complex type.
Class
Elemental function
Result Type and Attributes
It is of type extended complex.
Result Value
Examples
QCMPLX (-3) has the value (-3.0Q0, 0.0Q0).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
QCMPLX | REAL(16) | COMPLEX(16) | no |
Related Information
CMPLX (X, Y, KIND), DCMPLX (X, Y).
Convert to extended precision real type.
Class
Elemental function
Result Type and Attributes
Extended precision real.
Result Value
Examples
QEXT (-3) has the value -3.0Q0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
QFLOAT | any integer | REAL(16) | no |
QEXT | default real | REAL(16) | no |
QEXTD | double precision real | REAL(16) | no |
Returns the base of the model representing numbers of the same type and kind type parameter as the argument.
Class
Inquiry function
Result Type and Attributes
Default integer scalar.
Result Value
The result is the base of the model representing numbers of the same kind and type as X. The result is always 2. See the models under "Data Representation Models".
Not recommended. Generates uniform random numbers, positive real numbers greater than or equal to 0.0 and less than 1.0. Instead, use the RANDOM_NUMBER intrinsic subroutine.
Class
None (does not correspond to any of the defined categories).
Result Type and Attributes
real(4) scalar.
Related Information
SRAND (SEED) can be used to specify a seed value for the random number sequence.
If the function result is assigned to an array, all array elements receive the same value.
Examples
The following is an example of a program using the RAND function.
DO I = 1, 5 R = RAND() PRINT *, R ENDDO END
The following is sample output generated by the above program:
0.2251586914 0.8285522461 0.6456298828 0.2496948242 0.2215576172
Specific Names
This function only has a specific name.
Returns one pseudorandom number or an array of pseudorandom numbers from the uniform distribution over the range 0 <= x < 1.
Class
Subroutine
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
Restarts or queries the pseudorandom number generator used by RANDOM_NUMBER.
There must either be exactly one or no arguments present.
Random_seed allows the user to toggle between two random number generators. Generator 1 is the default. Each generator maintains a private seed and normally resumes its cycle after the last number it generated.
Generator 1 uses the multiplicative congruential method, with
S(I+1) = ( 16807.0 * S(I) ) mod (2.0**31-1)and
X(I+1) = S(I+1) / (2.0**31-1)
Generator 1 cycles after 2**31-2 (i.e., 2,147,483,646) random numbers.
Generator 2 also uses the multiplicative congruential method, with
S(I+1) = ( 44,485,709,377,909.0 * S(I) ) mod (2.0**48)and
X(I+1) = S(I+1) / (2.0**48)
Generator 2 cycles after (2**46)-1 (i.e., 70,368,744,177,663) random numbers. Although generator 1 is the default (for reasons of backwards compatibility) the use of generator 2 is recommended for new programs since it typically runs faster than generator 1 and has a longer period.
If no argument is present, the seed of the current generator is set to the default value 1d0.
Class
Subroutine
Examples
CALL RANDOM_SEED ! Current generator sets its seed to 1d0 CALL RANDOM_SEED (SIZE = K) ! Sets K = 64 / BIT_SIZE( 0 ) CALL RANDOM_SEED (PUT = SEED (1 : K)) ! Transfer seed to current generator CALL RANDOM_SEED (GET = OLD (1 : K)) ! Transfer seed from current generator
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
Result Type and Attributes
Default integer scalar.
Result Value
INT( LOG10( HUGE(X) ) )
INT( MIN( LOG10( HUGE(X) ), -LOG10( TINY(X) ) ) )
Thus:
Type RANGE ------------------------------ integer(1) 2 integer(2) 4 integer(4) 9 integer(8) 18 real(4) , complex(4) 37 real(8) , complex(8) 307 real(16) , complex(16) 291
Examples
X is of type real(4):
See "Data Representation Models".
Convert to real type.
Class
Elemental function
Result Type and Attributes
Result Value
Examples
REAL (-3) has the value -3.0. REAL ((3.2, 2.1)) has the value 3.2.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
REAL | default integer | default real | no |
FLOAT | any integer (1) | default real | no |
SNGL | double precision real | default real | no |
SNGLQ | REAL(16) | default real | no |
DREAL | double complex | double precision real | no |
QREAL | COMPLEX(16) | REAL(16) | no |
Notes:
Concatenate several copies of a string.
Class
Transformational function
Result Type and Attributes
Character scalar with a length equal to NCOPIES * LENGTH(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.
Constructs an array of a specified shape from the elements of a given array.
Class
Transformational function
Result Value
The result is an array with shape shape. It has the same data type as source.
The array elements of source are placed into the result in the order of dimensions as specified by order, or in the usual order for array elements if order is not specified.
The array elements of source are followed by the array elements of pad in array element order, and followed by additional copies of pad until all of the elements of the result are set.
Examples
! Turn a rank-1 array into a 3x4 array of the ! same size. RES= RESHAPE( (/A,B,C,D,E,F,G,H,I,J,K,L/), (/3,4/) ! The result is | A D G J | ! | B E H K | ! | C F I L | ! Turn a rank-1 array into a larger 3x5 array. ! Keep repeating -1 and -2 values for any ! elements not filled by the source array. ! Fill the rows first, then the columns. RES= RESHAPE( (/1,2,3,4,5,6/), (/3,5/), & (/-1,-2/), (/2,1/) ) ! The result is | 1 2 3 4 5 | ! | 6 -1 -2 -1 -2 | ! | -1 -2 -1 -2 -1 |
Related Information
Returns the reciprocal of the relative spacing of the model numbers near the argument value.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
The result is:
ABS(FRACTION(X)) * FLOAT(RADIX(X))DIGITS(X)
Examples
RRSPACING (-3.0) = 0.75 * 224. See "Real Data Model".
Performs a logical shift to the right.
Class
Elemental function
Result Type and Attributes
Same as I.
Result Value
Examples
RSHIFT (3, 1) has the result 1.
RSHIFT (3, 2) has the result 0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
RSHIFT | any integer | same as argument | yes |
Returns the scaled value: X * 2.0I
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
The result is determined from the following:
X * 2.0I
SCALE (X, I) = X * (2.0I)
Examples
SCALE (4.0, 3) = 4.0 * (23) = 32.0. See "Real Data Model".
Scan a string for any one of the characters in a set of characters.
Class
Elemental function
Result Type and Attributes
Default integer.
Result Value
Examples
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
Result Type and Attributes
Default integer scalar.
Result Value
Examples
SELECTED_INT_KIND (9) has the value 4, signifying that an INTEGER with kind type 4 can represent all values from 10-9 to 109.
Related Information
Kind type parameters supported by XL Fortran are defined in "Type Parameters and Specifiers".
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
Result Type and Attributes
Default integer scalar.
Result Value
Examples
SELECTED_REAL_KIND (6, 70) has the value 8.
Related Information
Kind type parameters supported by XL Fortran are defined in "Type Parameters and Specifiers".
Returns the number whose fractional part is the fractional part of the model representation of X, and whose exponent part is I.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
FRACTION(X) * 2.0I
Examples
SET_EXPONENT (10.5, 1) = 0.65625 * 2.01 = 1.3125
See "Real Data Model".
Returns the shape of an array or scalar.
Class
Inquiry function
Result Value
The result is a one-dimensional default integer array whose elements define the shape of sources. The extent of each dimension in sources is returned in the corresponding element in the result array.
Related Information
RESHAPE (SOURCE, SHAPE, PAD, ORDER).
Examples
! A is the array | 7 6 3 1 | ! | 2 4 0 9 | ! | 5 7 6 8 | ! RES = SHAPE( A ) ! The result is | 3 4 | because A is a rank-2 array ! with 3 elements in each column and 4 elements in ! each row.
Absolute value of A times the sign of B.
Class
Elemental function
Result Type and Attributes
Same as A.
Result Value
Examples
SIGN (-3.0, 2.0) has the value 3.0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
SIGN | default real | default real | yes |
ISIGN | any integer (1) | same as argument | yes |
DSIGN | double precision real | double precision real | yes |
QSIGN | REAL(16) | REAL(16) | yes |
Notes:
The SIGNAL procedure allows a program to specify a procedure to be invoked upon receipt of a specific operating-system signal.
Class
Subroutine
Examples
INCLUDE 'fexcp.h' INTEGER SIGUSR1 EXTERNAL USRINT ! Set exception handler to produce the traceback code. ! The SIGTRAP is defined in the include file fexcp.h. ! xl__trce is a procedure in the XL Fortran ! run-time library. It generates the traceback code. CALL SIGNAL(SIGTRAP, XL__TRCE) ... ! Use user-defined procedure USRINT to handle the signal ! SIGUSR1. CALL SIGNAL(SIGUSR1, USRINT) ...
Related Information
See the signal subroutine in the Technical Reference: Base Operating System and Extensions Volume 1 for details about the underlying implementation.
The "-qsigtrap Option" in the User's Guide allows you to set a handler for SIGTRAP signals through a compiler option.
Sine function.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
It approximates sin(X).
Examples
SIN (1.0) has the value 0.84147098 (approximately).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
SIN | default real | default real | yes |
DSIN | double precision real | double precision real | yes |
QSIN | REAL(16) | REAL(16) | yes |
CSIN (1) | default complex | default complex | yes |
CDSIN (2) | double complex | double complex | yes |
ZSIN (2) | double complex | double complex | yes |
CQSIN (2) | COMPLEX(16) | COMPLEX(16) | yes |
Given that X is a complex number in the form a + bi, where i = (-1)½:
Sine function. Argument in degrees.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
SIND (90.0) has the value 1.0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
SIND | default real | default real | yes |
DSIND | double precision real | double precision real | yes |
QSIND | REAL(16) | REAL(16) | yes |
Hyperbolic sine function.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
The result has a value equal to sinh(x).
Examples
SINH (1.0) has the value 1.1752012 (approximately).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
SINH (1) | default real | default real | yes |
DSINH (2) | double precision real | double precision real | yes |
QSINH (2) | REAL(16) | REAL(16) | yes |
Notes:
Returns the extent of an array along a specified dimension or the total number of elements in the array.
Class
Inquiry function
Result Type and Attributes
Default integer scalar.
Result Value
The result equals the extent of array along dimension dim; or, if dim is not specified, it is the total number of array elements in array.
Examples
! A is the array | 1 -4 7 -10 | ! | 2 5 -8 11 | ! | 3 6 9 -12 | RES = SIZE( A ) ! The result is 12 because there are 12 elements in A. RES = SIZE( A, DIM = 1) ! The result is 3 because there are 3 rows in A. RES = SIZE( A, DIM = 2) ! The result is 4 because there are 4 columns in A.
Returns the absolute spacing of the model numbers near the argument value.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
If X is not 0, the result is:
2.0EXPONENT(X) - DIGITS(X)
If X is 0, the result is the same as that of TINY(X).
Examples
SPACING (3.0) = 2.02 - 24 = 2.0(-22) See "Real Data Model".
Replicates an array in an additional dimension by making copies of existing elements along that dimension.
Class
Transformational function
Result Type and Attributes
The result is an array of rank rank(source)+1 and with the same type and type parameters as source.
Result Value
If source is a scalar, the result is a one-dimensional array with ncopies elements, each with value source.
If source is an array, the result is an array of rank rank(source) + 1. Along dimension dim, each array element of the result is equal to the corresponding array element in source.
If ncopies is less than or equal to zero, the result is a zero-sized array.
Examples
! A is the array (/ -4.7, 6.1, 0.3 /) RES = SPREAD( A, DIM = 1, NCOPIES = 3 ) ! The result is | -4.7 6.1 0.3 | ! | -4.7 6.1 0.3 | ! | -4.7 6.1 0.3 | ! DIM=1 extends each column. Each element in RES(:,1) ! becomes a copy of A(1), each element in RES(:,2) becomes ! a copy of A(2), and so on. RES = SPREAD( A, DIM = 2, NCOPIES = 3 ) ! The result is | -4.7 -4.7 -4.7 | ! | 6.1 6.1 6.1 | ! | 0.3 0.3 0.3 | ! DIM=2 extends each row. Each element in RES(1,:) ! becomes a copy of A(1), each element in RES(2,:) ! becomes a copy of A(2), and so on. RES = SPREAD( A, DIM = 2, NCOPIES = 0 ) ! The result is (/ /) (a zero-sized array).
Square root.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
SQRT (4.0) has the value 2.0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
SQRT | default real | default real | yes |
DSQRT | double precision real | double precision real | yes |
QSQRT | REAL(16) | REAL(16) | yes |
CSQRT (1) | default complex | default complex | yes |
CDSQRT (1) | double complex | double complex | yes |
ZSQRT (1) | COMPLEX(8) | COMPLEX(8) | yes |
CQSQRT (1) | COMPLEX(16) | COMPLEX(16) | yes |
Given that X is a complex number in the form a + bi, where i = (-1)½:
Provides the seed value used by the random number generator function RAND.
Class
Subroutine
Examples
The following is an example of a program using the SRAND subroutine.
CALL SRAND(0.5) DO I = 1, 5 R = RAND() PRINT *,R ENDDO END
The following is sample output generated by the above program:
0.3984375000 0.4048461914 0.1644897461 0.1281738281E-01 0.2313232422E-01
Calculates the sum of selected elements in an array.
Class
Transformational function
Result Value
If dim is present, the result is an array of rank rank(array)-1, with the same data type as array. If dim is missing, or if mask has a rank of one, the result is a scalar.
The result is calculated by one of the following methods:
Examples
Method 1:
! Sum all the elements in an array. RES = SUM( (/2, 3, 4 /) ) ! The result is 9 because (2+3+4) = 9
Method 2:
! A is the array (/ -3, -7, -5, 2, 3 /) ! Sum all elements that are greater than -5. RES = SUM( A, MASK = A .GT. -5 ) ! The result is 2 because (-3 + 2 + 3) = 2
Method 3:
! B is the array | 4 2 3 | ! | 7 8 5 | ! Sum the elements in each column. RES = SUM(B, DIM = 1) ! The result is | 11 10 8 | because (4 + 7) = 11 ! (2 + 8) = 10 ! (3 + 5) = 8 ! Sum the elements in each row. RES = SUM(B, DIM = 2) ! The result is | 9 20 | because (4 + 2 + 3) = 9 ! (7 + 8 + 5) = 20 ! Sum the elements in each row, considering only ! those elements greater than two. RES = SUM(B, DIM = 2, MASK = B .GT. 2) ! The result is | 7 20 | because (4 + 3) = 7 ! (7 + 8 + 5) = 20
Passes a command to the operating system for execution. The current process pauses until the command is completed and control is returned from the operating system. An added, optional argument to the subroutine will allow recovery of any return code information from the operating system.
Class
Subroutine
Examples
INTEGER ULIMIT CHARACTER(32) CMD ... ! Check the system ulimit. CMD = 'ulimit > ./fort.99' CALL SYSTEM(CMD) READ(99, *) ULIMIT IF (ULIMIT .LT. 2097151) THEN ...
INTEGER RC RC=99 CALL SYSTEM("/bin/test 1 -EQ 2",RC) IF (IAND(RC,'ff'z) .EQ. 0) then RC = IAND( ISHFT(RC,-8), 'ff'z ) ELSE RC = -1 ENDIF
Related Information
See the system subroutine in the Technical Reference: Base Operating System and Extensions Volume 1 for details about the underlying implementation.
Returns integer data from a real-time clock.
Class
Subroutine
Examples
! The following example shows how to interpret values ! returned by the subroutine SYSTEM_CLOCK. The processor ! clock is a 24-hour clock. After the call to SYSTEM_CLOCK, ! the COUNT contains the day time expressed in clock ticks ! per second. The number of ticks per second is available ! in the COUNT_RATE. The COUNT_RATE value is processor- ! dependent. INTEGER, DIMENSION(8) :: IV TIME_SYNC: DO CALL DATE_AND_TIME(VALUES=IV) IHR = IV(5) IMIN = IV(6) ISEC = IV(7) CALL SYSTEM_CLOCK(COUNT=IC, COUNT_RATE=IR, COUNT_MAX=IM) CALL DATE_AND_TIME(VALUES=IV) IF ((IHR == IV(5)) .AND. (IMIN == IV(6)) .AND. & (ISEC == IV(7))) EXIT TIME_SYNC END DO TIME_SYNC IDAY_SEC = 3600*IHR + IMIN*60 + ISEC IDAY_TICKS = IDAY_SEC * IR IF (IDAY_TICKS /= IC) THEN STOP 'clock error' ENDIF END
Tangent function.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
The result approximates tan(X), where X has a value in radians.
Examples
TAN (1.0) has the value 1.5574077 (approximately).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
TAN | default real | default real | yes |
DTAN | double precision real | double precision real | yes |
QTAN | REAL(16) | REAL(16) | yes |
Tangent function. Argument in degrees.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
Examples
TAND (45.0) has the value 1.0.
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
TAND | default real | default real | yes |
DTAND | double precision real | double precision real | yes |
QTAND | REAL(16) | REAL(16) | yes |
Hyperbolic tangent function.
Class
Elemental function
Result Type and Attributes
Same as X.
Result Value
The result has a value equal to tanh(X).
Examples
TANH (1.0) has the value 0.76159416 (approximately).
Specific Name | Argument Type | Result Type | Pass As Arg? |
---|---|---|---|
TANH | default real | default real | yes |
DTANH | double precision real | double precision real | yes |
QTANH | REAL(16) | REAL(16) | yes |
Returns the smallest positive number in the model representing numbers of the same type and kind type parameter as the argument.
Class
Inquiry function
Result Type and Attributes
Scalar with the same type as X.
Result Value
The result is:
2.0(MINEXPONENT(X)-1) for real X
Examples
TINY (X) = float(2)(-126) = 1.17549351e-38. See "Real Data Model".
Returns a result with a physical representation identical to that of SOURCE but interpreted with the type and type parameters of MOLD.
It performs a low-level conversion between types without any sign extension, rounding, blank padding, or other alteration that may occur using other methods of conversion.
Class
Transformational function
Result Type and Attributes
The same type and type parameters as MOLD.
If MOLD is a scalar and SIZE is absent, the result is a scalar.
If MOLD is array valued and SIZE is absent, the result is array valued and of rank one, with the smallest size that is physically large enough to hold SOURCE.
If SIZE is present, the result is array valued of rank one and size SIZE.
Result Value
The physical representation of the result is the same as SOURCE, truncated if the result is smaller or with an undefined trailing portion if the result is larger.
Because the physical representation is unchanged, it is possible to undo the results of TRANSFER as long as the result is not truncated:
REAL(4) X = 3.141 DOUBLE PRECISION I, J(6) = (/1,2,3,4,5,6/) ! Because x is transferred to a larger representation ! and then back, its value is unchanged. X = TRANSFER( TRANSFER( X, I ), X ) ! j is transferred into a real(4) array large enough to ! hold all its elements, then back into an array of ! its original size, so its value is unchanged too. J = TRANSFER( TRANSFER( J, X ), J, SIZE=SIZE(J) )
Examples
TRANSFER (1082130432, 0.0) is 4.0.
TRANSFER ((/1.1,2.2,3.3/), (/(0.0,0.0)/)) is a complex rank-one array of length two whose first element has the value (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.
TRANSFER ((/1.1,2.2,3.3/), (/(0.0,0.0)/), 1) has the value (/(1.1,2.2)/).
Transposes a two-dimensional array, turning each column into a row and each row into a column.
Class
Transformational function
Result Value
The result is a two-dimensional array of the same data type as matrix.
The shape of the result is (n,m) where the shape of matrix is (m,n). For example, if the shape of matrix is (2,3), the shape of the result is (3,2).
Each element (i,j) in the result has the value MATRIX (j,i) for i in the range 1-n and j in the range 1-m.
Examples
! A is the array | 0 -5 8 -7 | ! | 2 4 -1 1 | ! | 7 5 6 -6 | ! Transpose the columns and rows of A. RES = TRANSPOSE( A ) ! The result is | 0 2 7 | ! | -5 4 5 | ! | 8 -1 6 | ! | -7 1 -6 |
Returns the argument with trailing blank characters removed.
Class
Transformational function
Result Type and Attributes
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
Examples
TRIM (' A B ') has the value ' A B'.
Returns the upper bounds of each dimension in an array, or the upper bound of a specified dimension.
Class
Inquiry function
Result Type and Attributes
Default integer.
If DIM is present, the result is a scalar. If DIM is not present, the result is a one-dimensional array with one element for each dimension in array.
Result Value
Each element in the result corresponds to a dimension of array. If array is a whole array or array structure component, these values are equal to the upper bounds. If array is an array section or expression that is not a whole array or array structure component, the values represent the number of elements in each dimension, which may be different than the declared upper bounds of the original array. If a dimension is zero-sized, the corresponding element in the result is zero, regardless of the value of the upper bound.
Examples
! This array illustrates the way UBOUND works with ! different ranges for dimensions. REAL A(1:10, -4:5, 4:-5) RES=UBOUND( A ) ! The result is (/ 10, 5, 0 /). RES=UBOUND( A(:,:,:) ) ! The result is (/ 10, 10, 0 /) because the argument ! is an array section. RES=UBOUND( A(4:10,-4:1,:) ) ! The result is (/ 7, 6, 0 /), because for an array section, ! it is the number of elements that is significant.
Takes some or all elements from a one-dimensional array and rearranges them into another, possibly larger, array.
Class
Transformational function
Result Value
The result is an array with the same shape as mask and the same data type as vector.
The elements of the result are filled in array-element order: if the corresponding element in mask is .TRUE., the result element is filled by the next element of vector; otherwise, it is filled by the corresponding element of field.
Examples
! VECTOR is the array (/ 5, 6, 7, 8 /), ! MASK is | F T T |, FIELD is | -1 -4 -7 | ! | T F F | | -2 -5 -8 | ! | F F T | | -3 -6 -9 | ! Turn the one-dimensional vector into a two-dimensional ! array. The elements of VECTOR are placed into the .TRUE. ! positions in MASK, and the remaining elements are ! made up of negative values from FIELD. RES = UNPACK( VECTOR, MASK, FIELD ) ! The result is | -1 6 7 | ! | 5 -5 -8 | ! | -3 -6 8 | ! Do the same transformation, but using all zeros for the ! replacement values of FIELD. RES = UNPACK( VECTOR, MASK, FIELD = 0 ) ! The result is | 0 6 7 | ! | 5 0 0 | ! | 0 0 8 |
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
Result Type and Attributes
Default integer.
Result Value
Examples
(4) The value of ZONE may be incorrect if you have not set up the machine through the smit chtz fastpath, or if you are in a timezone not configurable through smit. You can manually set the TZ environment variable or use the chtz command to ensure the time zone is correctly set up. The format of the TZ variable is documented under the /etc/environment file in the Files Reference