[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP Fortran for OpenVMS
Language Reference Manual


Previous Contents Index

9.4.40 DIGITS (X)

Description: Returns the number of significant binary digits for numbers of the same type and kind parameters as the argument.
Class: Inquiry function; Generic
Arguments: X must be of type integer or real; it can be scalar or array valued.
Results: The result is a scalar of type default integer.

The result has the value q if X is of type integer; it has the value p if X is of type real. Integer parameter q is defined in Section D.1; real parameter p is defined in Section D.2.

Examples

If X is of type REAL(4), DIGITS (X) has the value 24.

9.4.41 DIM (X, Y)

Description: Returns the difference between two numbers (if the difference is positive).
Class: Elemental function; Generic
Arguments: X Must be of type integer or real.
  Y Must have the same type and kind parameters as X.
Results: The result type is the same as X. The value of the result is X - Y if X is greater than Y; otherwise, the value of the result is zero.
Specific Name Argument Type Result Type
  INTEGER(1) INTEGER(1)
IIDIM INTEGER(2) INTEGER(2)
IDIM 1 INTEGER(4) INTEGER(4)
KIDIM INTEGER(8) INTEGER(8)
DIM REAL(4) REAL(4)
DDIM REAL(8) REAL(8)
QDIM REAL(16) REAL(16)

1Or JIDIM.

Examples

DIM (6, 2) has the value 4.

DIM (--4.0, 3.0) has the value 0.0.

9.4.42 DOT_PRODUCT (VECTOR_A, VECTOR_B)

Description: Performs dot-product multiplication of numeric or logical vectors (rank-one arrays).
Class: Transformational function; Generic
Arguments: VECTOR_A Must be a rank-one array of numeric (integer, real, or complex) or logical type.
  VECTOR_B Must be a rank-one array of numeric type if VECTOR_A is of numeric type, or of logical type if VECTOR_A is of logical type. It must be the same size as VECTOR_A.
Results: The result is a scalar whose type depends on the types of VECTOR_A and VECTOR_B.

If VECTOR_A is of type integer or real, the result value is SUM (VECTOR_A*VECTOR_B).

If VECTOR_A is of type complex, the result value is SUM (CONJG (VECTOR_A)*VECTOR_B).

If VECTOR_A is of type logical, the result has the value ANY (VECTOR_A .AND. VECTOR_B).

If either rank-one array has size zero, the result is zero if the array is of numeric type, and false if the array is of logical type. (For more information on expressions, see Section 4.1.)

Examples

DOT_PRODUCT ((/1, 2, 3/), (/3, 4, 5/)) has the value 26 (calculated as follows: ( (1 x 3) + (2 x 4) + (3 x 5)) = 26 ).

DOT_PRODUCT ((/ (1.0, 2.0), (2.0, 3.0) /), (/ (1.0, 1.0), (1.0, 4.0) /)) has the value (17.0, 4.0).

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

9.4.43 DPROD (X, Y)

Description: Produces a higher precision product. This is a specific function that has no generic function associated with it. It must not be passed as an actual argument.
Class: Elemental function; Specific
Arguments: X Must be of type REAL(4) or REAL(8).
  Y Must be the same type and kind parameter as X.
Results: If X and Y are of type REAL(4), the result is of type double-precision real. If X and Y are of type REAL(8), the result is of type REAL(16). The result value is equal to X*Y.

Examples

DPROD (2.0, --4.0) has the value --8.00D0.

DPROD (5.0D0, 3.0D0) has the value 15.00Q0.

The following shows another example:


  REAL(4) e
  REAL(8) d
  e = 123456.7
  d = 123456.7D0
  ! DPROD (e,e) returns 15241557546.4944

  ! DPROD (d,d) returns 15241556774.8899992813874268904328

9.4.44 DREAL (A)

Description: Converts the real part of a double-complex argument to double-precision type. This is a specific function that has no generic function associated with it. It must not be passed as an actual argument.
Class: Elemental function; Specific
Arguments: A must be of type double complex (COMPLEX(8) or COMPLEX*16).
Results: The result is of type double-precision real (REAL(8) or REAL*8).

Examples

DREAL ((2.0d0, 3.0d0)) has the value 2.0d0.

9.4.45 EOF (A)

Description: Checks whether a file is at or beyond the end-of-file record. This is a specific function that has no generic function associated with it. It must not be passed as an actual argument.
Class: Inquiry function; Specific
Arguments: A must be of type integer. It represents a unit specifier corresponding to an open file. It cannot be zero unless you have reconnected unit zero to a unit other than the screen or keyboard.
Results: The result is of type logical. The value of the result is .TRUE. if the file connected to A is at or beyond the end-of-file record; otherwise, .FALSE..

Examples

Consider the following:


!  Creates a file of random numbers, reads them back
      REAL x, total
      INTEGER count
      OPEN (1, FILE = 'TEST.DAT')
      DO I = 1, 20
        CALL RANDOM_NUMBER(x)
        WRITE (1, '(F6.3)') x * 100.0
      END DO
      CLOSE(1)
      OPEN (1, FILE = 'TEST.DAT')
      DO WHILE (.NOT. EOF(1))
        count = count + 1
        READ (1, *) value
        total = total + value
      END DO
100   IF ( count .GT. 0) THEN
        WRITE (*,*) 'Average is: ', total / count
      ELSE
        WRITE (*,*) 'Input file is empty '
      END IF
 STOP
      END

9.4.46 EOSHIFT (ARRAY, SHIFT [,BOUNDARY] [,DIM])

Description: Performs an end-off shift on a rank-one array, or performs end-off shifts on all the complete rank-one sections along a given dimension of an array of rank two or greater.

Elements are shifted off at one end of a section and copies of a boundary value are filled in at the other end. Different sections can have different boundary values and can be shifted by different amounts and in different directions.

Class: Transformational function; Generic
Arguments: ARRAY Must be an array (of any data type).
  SHIFT Must be a scalar integer or an array with a rank that is one less than ARRAY, and shape (d 1, d 2, ..., d DIM-1, d DIM+1, ..., d n), where (d 1, d 2,..., d n) is the shape of ARRAY.
  BOUNDARY
(opt)
Must have the same type and kind parameters as ARRAY. It must be a scalar or an array with a rank that is one less than ARRAY, and shape (d 1, d 2, ..., d DIM-1, d DIM+1, ..., d n). If BOUNDARY is not specified, it is assumed to have the following default values (depending on the data type of ARRAY):
    ARRAY Type BOUNDARY Value
    Integer 0
    Real 0.0
    Complex (0.0, 0.0)
    Logical false
    Character ( len) len blanks
  DIM (opt) Must be a scalar integer with a value in the range 1 to n, where n is the rank of ARRAY. If DIM is omitted, it is assumed to be 1.
Results: The result is an array with the same type and kind parameters, and shape as ARRAY.

If ARRAY has rank one, the same shift is applied to each element. If an element is shifted off one end of the array, the BOUNDARY value is placed at the other end the array.

If ARRAY has rank greater than one, each section (s 1, s 2, ..., s DIM-1, :, s DIM+1, ..., s n) of the result is shifted as follows:

  • By the value of SHIFT, if SHIFT is scalar
  • According to the corresponding value in SHIFT(s 1, s 2,..., s DIM-1, s DIM+1,..., s n), if SHIFT is an array

If an element is shifted off one end of a section, the BOUNDARY value is placed at the other end of the section.

The value of SHIFT determines the amount and direction of the end-off shift. A positive SHIFT value causes a shift to the left (in rows) or up (in columns). A negative SHIFT value causes a shift to the right (in rows) or down (in columns).

Examples

V is the array (1, 2, 3, 4, 5, 6).

EOSHIFT (V, SHIFT=2) shifts the elements in V to the left by two positions, producing the value (3, 4, 5, 6, 0, 0). 1 and 2 are shifted off the beginning and two elements with the default BOUNDARY value are placed at the end.

EOSHIFT (V, SHIFT= --3, BOUNDARY= 99) shifts the elements in V to the right by 3 positions, producing the value (99, 99, 99, 1, 2, 3). 4, 5, and 6 are shifted off the end and three elements with BOUNDARY value 99 are placed at the beginning.

M is the array <left[ symbol><matrix symbol> 1&2&3<cr symbol> 4&5&6<cr symbol> 7&8&9<cr symbol> <right] symbol> .

EOSHIFT (M, SHIFT = 1, BOUNDARY = ' * ' , DIM = 2) produces the result <left[ symbol><matrix symbol> 2&3&*<cr symbol> 5&6&*<cr symbol> 8&9&*<cr symbol> <right] symbol> .

Each element in rows 1, 2, and 3 is shifted to the left by one position. This causes the first element in each row to be shifted off the beginning, and the BOUNDARY value to be placed at the end.

EOSHIFT (M, SHIFT = --1, DIM = 1) produces the result <left[ symbol><matrix symbol> 0&0&0<cr symbol> 1&2&3<cr symbol> 4&5&6<cr symbol> <right] symbol> .

Each element in columns 1, 2, and 3 is shifted down by 1 position. This causes the last element in each column to be shifted off the end and the BOUNDARY value to be placed at the beginning.

EOSHIFT (M, SHIFT = (/1, --1, 0/), BOUNDARY = (/ ' * ' , ' ? ' , ' / ' /), DIM = 2) produces the result <left[ symbol><matrix symbol> 2&3&*<cr symbol> ?&4&5<cr symbol> 7&8&9<cr symbol> <right] symbol> .

Each element in row 1 is shifted to the left by one position, causing the first element to be shifted off the beginning and the BOUNDARY value * to be placed at the end. Each element in row 2 is shifted to the right by 1 position, causing the last element to be shifted off the end and the BOUNDARY value ? to be placed at the beginning. No element in row 3 is shifted at all, so the specified BOUNDARY value is not used.

9.4.47 EPSILON (X)

Description: Returns the difference (for scalars of the same type and kind parameters) between 1.0 and the next larger model number. EPSILON is a guide to the precision with which values near unity can be represented.

EPSILON(1.0) is about 1.19E-7, EPSILON(1.0_8) is about 2.22E-16, and EPSILON(1.0_16) is about 1.93E-34.

Class: Inquiry function; Generic
Arguments: X must be of type real; it can be scalar or array valued.
Results: The result is a scalar of the same type and kind parameters as X. The result has the value b 1-p. Parameters b and p are defined in Section D.2.

Examples

If X is of type REAL(4), EPSILON (X) has the value 2-23 .

9.4.48 ERRSNS ([IO_ERR] [,SYS_ERR] [,STAT] [,UNIT] [,COND])

Description: Returns information about the most recently detected I/O system error condition.
Class: Subroutine
Arguments: There are five optional arguments:
IO_ERR (opt) Is an integer variable or array element that stores the most recent HP Fortran RTL error number that occurred during program execution. (For a listing of error numbers, see the HP Fortran for OpenVMS User Manual.)

A zero indicates no error has occurred since the last call to ERRSNS or since the start of program execution.

SYS_ERR
(opt)
Is an integer variable or array element that stores the most recent system error number associated with IO_ERR. This code is an RMS STS value.
STAT (opt) Is an integer variable or array element that stores a status value that occurred during program execution. This value is an RMS STV value.
UNIT (opt) Is an integer variable or array element that stores the logical unit number, if the last error was an I/O error.
COND (opt) Is an integer variable or array element that stores the actual processor value. This value is always zero.
  If you specify INTEGER(2) arguments, only the low-order 16 bits of information are returned or adjacent data can be overwritten. Because of this, it is best to use INTEGER(4) arguments.

The saved error information is set to zero after each call to ERRSNS.

Examples

Any of the arguments can be omitted. For example, the following is valid:


CALL ERRSNS (SYS_ERR, STAT, , UNIT)

9.4.49 EXIT ([STATUS])

Description: Terminates program execution, closes all files, and returns control to the operating system.
Class: Subroutine
Arguments: STATUS is an optional integer argument you can use to specify the image exit-status value.

Examples

CALL EXIT (100)

9.4.50 EXP (X)

Description: Computes an exponential value.
Class: Elemental function; Generic
Arguments: X must be of type real or complex.
Results: The result type is the same as X. The value of the result is e x. If X is of type complex, its imaginary part is regarded as a value in radians.
Specific Name Argument Type Result Type
EXP REAL(4) REAL(4)
DEXP REAL(8) REAL(8)
QEXP REAL(16) REAL(16)
CEXP 1 COMPLEX(4) COMPLEX(4)
CDEXP 2 COMPLEX(8) COMPLEX(8)
CQEXP COMPLEX(16) COMPLEX(16)

1The setting of compiler options specifying real size can affect CEXP.
2This function can also be specified as ZEXP.

Examples

EXP (2.0) has the value 7.389056.

EXP (1.3) has the value 3.669297.


Previous Next Contents Index