[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.134 RRSPACING (X)

Description: Returns the reciprocal of the relative spacing of model numbers near the argument value.
Class: Elemental function; Generic
Arguments: X must be of type real.
Results: The result type is the same as X. The result has the value |X * b -e| x b p. Parameters b, e, p are defined in Section D.2.

Examples

If --3.0 is a REAL(4) value, RRSPACING (--3.0) has the value 0.75 x 224 .

9.4.135 SCALE (X, I)

Description: Returns the value of the exponent part (of the model for the argument) changed by a specified value.
Class: Elemental function; Generic
Arguments: X Must be of type real.
  I Must be of type integer.
Results: The result type is the same as X. The result has the value X x b I . Parameter b is defined in Section D.2.

Examples

If 3.0 is a REAL(4) value, SCALE (3.0, 2) has the value 12.0 and SCALE (3.0, 3) has the value 24.0.

9.4.136 SCAN (STRING, SET [,BACK] [,KIND])

Description: Scans a string for any character in a set of characters.
Class: Elemental function; Generic
Arguments: STRING Must be of type character.
  SET Must be of type character with the same kind parameter as STRING.
  BACK (opt) Must be of type logical.
  KIND (opt) Must be a scalar integer initialization expression.
Results: The result is of type integer. If KIND is present, the kind parameter of the result is that specified by KIND; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the result value in the kind of the result, the result is undefined.

If BACK is omitted (or is present with the value false) and STRING has at least one character that is in SET, the value of the result is the position of the leftmost character of STRING that is in SET.

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

If no character of STRING is in SET or the length of STRING or SET is zero, the value of the result is zero.

Examples

SCAN ( ' ASTRING ' , ' ST ' ) has the value 2.

SCAN ( ' ASTRING ' , ' ST ' , BACK=.TRUE.) has the value 3.

SCAN ( ' ASTRING ' , ' CD ' ) has the value zero.

9.4.137 SECNDS (X)

Description: Provides the system time of day, or elapsed time, as a floating-point value in seconds.

This is a specific function that has no generic function associated with it. It must not be passed as an actual argument. It is not a pure function, so it cannot be referenced inside a FORALL construct.

Class: Elemental function; Specific
Arguments: X must be of type REAL(4).
Results: The result type is the same as X. The result value is the time in seconds since midnight - X. (The function also produces correct results for time intervals that span midnight.)

The value of SECNDS is accurate to 0.01 second, which is the resolution of the system clock.

The 24 bits of precision provide accuracy to the resolution of the system clock for about one day. However, loss of significance can occur if you attempt to compute very small elapsed times late in the day.

You can get more precise timing information by using the following Run-Time Library (RTL) procedures:

  • LIB$INIT_TIMER
  • LIB$SHOW_TIMER
  • LIB$STAT_TIMER

Examples

The following shows how to use SECNDS to perform elapsed-time computations:


C    START OF TIMED SEQUENCE
     T1 = SECNDS(0.0)

C    CODE TO BE TIMED
     ...
     DELTA = SECNDS(T1)      ! DELTA gives the elapsed time

9.4.138 SELECTED_INT_KIND (R)

Description: Returns the value of the kind parameter of an integer data type.
Class: Transformational function; Generic
Arguments: R must be scalar and of type integer.
Results: The result is a scalar of type default integer. The result has a value equal to the value of the kind parameter of the integer data type that represents all values n in the range of values n with --10 R < n < 10 R.

If no such kind type parameter is available on the processor, the result is --1. If more than one kind type parameter meets the criteria, the value returned is the one with the smallest decimal exponent range. (For information on the integer model, see Section D.1.)

Examples

SELECTED_INT_KIND (6) = 4

9.4.139 SELECTED_REAL_KIND ([P] [,R])

Description: Returns the value of the kind parameter of a real data type.
Class: Transformational function; Generic
Arguments: P (opt) Must be scalar and of type integer.
  R (opt) Must be scalar and of type integer.
  At least one argument must be specified.
Results: The result is a scalar of type default integer. The result has a value equal to a value of the kind parameter of a real data type with decimal precision, as returned by the function PRECISION, of at least P digits and a decimal exponent range, as returned by the function RANGE, of at least R.

If no such kind type parameter is available on the processor, the result is as follows:

--1 if the precision is not available
--2 if the exponent range is not available
--3 if neither is available

If more than one kind type parameter value meets the criteria, the value returned is the one with the smallest decimal precision. (For information on the real model, see Section D.2.)

Examples

SELECTED_REAL_KIND (6, 70) = 8

9.4.140 SET_EXPONENT (X, I)

Description: Returns the value the first argument would have if its exponent part were set to the second argument.
Class: Elemental function; Generic
Arguments: X Must be of type real.
  I Must be of type integer.
Results: The result type is the same as X. The result has the value X x b I-e . Parameters b and e are defined in Section D.2. If X has the value zero, the result is zero.

Examples

Assume the following pseudocode:


struct FLOAT {
    int exponent;
    float fraction;
}

FLOAT set_exponent( FLOAT x, int i )
{
    FLOAT y = x;
    y.exponent = i;
    return y;
}

Note that the operation is performed on the representation of the number, not on the model number. The exponent argument is adjusted for the excess-128 notation used in the exponent field of a floating-point number. The fraction field is not modified.

For example, if X is a REAL*4 variable holding 0.75, that value is represented as 0.75 * 2 ** 0. The exponent is zero. SET_EXPONENT (X, 3) returns 0.75 * 2 ** 3, which is 6.0. SET_EXPONENT (X, 4) returns 0.75 * 2 ** 4, which is 12.0.

9.4.141 SHAPE (SOURCE [,KIND])

Description: Returns the shape of an array or scalar argument.
Class: Inquiry function; Generic
Arguments: SOURCE Is a scalar or array (of any data type). It must not be an assumed-size array, a disassociated pointer, or an allocatable array that is not allocated.
  KIND (opt) Must be a scalar integer initialization expression.
Results: The result is a rank-one integer array whose size is equal to the rank of SOURCE. If KIND is present, the kind parameter of the result is that specified by KIND; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the result value in the kind of the result, the result is undefined.

The value of the result is the shape of SOURCE.

The setting of compiler options that specify integer size can affect the result of this function.

Examples

SHAPE (2) has the value of a rank-one array of size zero.

If B is declared as B(2:4, --3:1), then SHAPE (B) has the value (3, 5).

9.4.142 SIGN (A, B)

Description: Returns the absolute value of A times the sign of B.
Class: Elemental function; Generic
Arguments: A Must be of type integer or real.
  B Must have the same type and kind parameters as A.
Results: The result type is the same as A. The value of the result is |A| if B >= zero and --|A| if B < zero.

If B is of type real and zero, the value of the result is |A|. However, if the processor can distinguish between positive and negative real zero and the appropriate compiler option is specified, the following occurs:

  • If B is positive real zero, the value of the result is |A|.
  • If B is negative real zero, the value of the result is --|A|.
Specific Name Argument Type Result Type
  INTEGER(1) INTEGER(1)
IISIGN INTEGER(2) INTEGER(2)
ISIGN 1 INTEGER(4) INTEGER(4)
KISIGN INTEGER(8) INTEGER(8)
SIGN REAL(4) REAL(4)
DSIGN REAL(8) REAL(8)
QSIGN REAL(16) REAL(16)

1Or JISIGN. For compatibility with older versions of Fortran, ISIGN can also be specified as a generic function.

Examples

SIGN (4.0, --6.0) has the value --4.0.

SIGN (--5.0, 2.0) has the value 5.0.

9.4.143 SIN (X)

Description: Produces the sine of X.
Class: Elemental function; Generic
Arguments: X must be of type real or complex. It must be in radians and is treated as modulo 2*Pi sign. (If X is of type complex, its real part is regarded as a value in radians.)
Results: The result type is the same as X.
Specific Name Argument Type Result Type
SIN REAL(4) REAL(4)
DSIN REAL(8) REAL(8)
QSIN REAL(16) REAL(16)
CSIN 1 COMPLEX(4) COMPLEX(4)
CDSIN 2 COMPLEX(8) COMPLEX(8)
CQSIN COMPLEX(16) COMPLEX(16)

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

Examples

SIN (2.0) has the value 0.9092974.

SIN (0.8) has the value 0.7173561.

9.4.144 SIND (X)

Description: Produces the sine of X.
Class: Elemental function; Generic
Arguments: X must be of type real. It must be in degrees and is treated as modulo 360.
Results: The result type is the same as X.
Specific Name Argument Type Result Type
SIND REAL(4) REAL(4)
DSIND REAL(8) REAL(8)
QSIND REAL(16) REAL(16)

Examples

SIND (2.0) has the value 3.4899496E--02.

SIND (0.8) has the value 1.3962180E--02.

9.4.145 SINH (X)

Description: Produces a hyperbolic sine.
Class: Elemental function; Generic
Arguments: X must be of type real.
Results: The result type is the same as X.
Specific Name Argument Type Result Type
SINH REAL(4) REAL(4)
DSINH REAL(8) REAL(8)
QSINH REAL(16) REAL(16)

Examples

SINH (2.0) has the value 3.626860.

SINH (0.8) has the value 0.8881060.

9.4.146 SIZE (ARRAY [,DIM] [,KIND])

Description: Returns the total number of elements in an array, or the extent of an array along a specified dimension.
Class: Inquiry function; Generic
Arguments: ARRAY Must be an array (of any data type). It must not be a disassociated pointer or an allocatable array that is not allocated. It can be an assumed-size array if DIM is present with a value less than the rank of ARRAY.
  DIM (opt) Must be a scalar integer with a value in the range 1 to n, where n is the rank of ARRAY.
  KIND (opt) Must be a scalar integer initialization expression.
Results: The result is a scalar of type integer. If KIND is present, the kind parameter of the result is that specified by KIND; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the result value in the kind of the result, the result is undefined.

If DIM is present, the result is the extent of dimension DIM in ARRAY; otherwise, the result is the total number of elements in ARRAY.

The setting of compiler options that specify integer size can affect the result of this function.

Examples

If B is declared as B(2:4, --3:1), then SIZE (B, DIM=2) has the value 5 and SIZE (B) has the value 15.


Previous Next Contents Index