[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.147 SIZEOF (X)

Description: Returns the number of bytes of storage used by the argument. 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: X is a scalar or array (of any data type). It must not be an assumed-size array.
Results: The result is of type INTEGER(8). The result value is the number of bytes of storage used by X.

Examples

SIZEOF (3.44) has the value 4.

SIZEOF ( ' SIZE ' ) has the value 4.

9.4.148 SPACING (X)

Description: Returns the absolute 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 b e-p. Parameters b, e, and p are defined in Section D.2. If the result value is outside of the real model range, the result is TINY(X). (For information on TINY, see Section 9.4.157.)

Examples

If 3.0 is a REAL(4) value, SPACING (3.0) has the value 2-22.

9.4.149 SPREAD (SOURCE, DIM, NCOPIES)

Description: Creates a replicated array with an added dimension by making copies of existing elements along a specified dimension.
Class: Transformational function; Generic
Arguments: SOURCE Must be a scalar or array (of any data type). The rank must be less than 7.
  DIM Must be scalar and of type integer. It must have a value in the range 1 to n + 1 (inclusive), where n is the rank of SOURCE.
  NCOPIES Must be scalar and of type integer. It becomes the extent of the additional dimension in the result.
Results: The result is an array of the same type as SOURCE and of rank that is one greater than SOURCE.

If SOURCE is an array, each array element in dimension DIM of the result is equal to the corresponding array element in SOURCE.

If SOURCE is a scalar, the result is a rank-one array with NCOPIES elements, each with the value SOURCE.

If NCOPIES <= zero, the result is an array of size zero.

Examples

SPREAD ("B", 1, 4) is the character array (/"B", "B", "B", "B"/).

B is the array (3, 4, 5) and NC has the value 4.

SPREAD (B, DIM=1, NCOPIES=NC) produces the array <left[ symbol><matrix symbol> 3&4&5<cr symbol> 3&4&5<cr symbol> 3&4&5<cr symbol> 3&4&5<cr symbol> <right] symbol> .

SPREAD (B, DIM=2, NCOPIES=NC) produces the array <left[ symbol><matrix symbol> 3&3&3&3<cr symbol> 4&4&4&4<cr symbol> 5&5&5&5<cr symbol> <right] symbol> .

9.4.150 SQRT (X)

Description: Derives the square root of the argument.
Class: Elemental function; Generic
Arguments: X must be of type real or complex. If X is type real, its value must be greater than or equal to zero.
Results: The result type is the same as X. The result has a value equal to the square root of X. A result of type complex is the principal value, with the real part greater than or equal to zero. When the real part of the result is zero, the imaginary part is greater than or equal to zero.
Specific Name Argument Type Result Type
SQRT REAL(4) REAL(4)
DSQRT REAL(8) REAL(8)
QSQRT REAL(16) REAL(16)
CSQRT 1 COMPLEX(4) COMPLEX(4)
CDSQRT 2 COMPLEX(8) COMPLEX(8)
CQSQRT COMPLEX(16) COMPLEX(16)

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

Examples

SQRT (16.0) has the value 4.0.

SQRT (3.0) has the value 1.732051.

9.4.151 SUM (ARRAY [,DIM] [,MASK])

Description: Returns the sum of all the elements in an entire array or in a specified dimension of an array.
Class: Transformational function; Generic
Arguments: ARRAY Must be an array of type integer, real, or complex.
  DIM (opt) Must be a scalar integer with a value in the range 1 to n, where n is the rank of ARRAY.
  MASK (opt) Must be of type logical and conformable with ARRAY.
Results: The result is an array or a scalar of the same data type as ARRAY.

The result is a scalar if DIM is omitted or ARRAY has rank one.

The following rules apply if DIM is omitted:

  • If SUM (ARRAY) is specified, the result is the sum of all elements of ARRAY. If ARRAY has size zero, the result is zero.
  • If SUM (ARRAY, MASK=MASK) is specified, the result is the sum of all elements of ARRAY corresponding to true elements of MASK. If ARRAY has size zero, or every element of MASK has the value .FALSE., the result is zero.

The following rules apply if DIM is specified:

  • If ARRAY has rank one, the value is the same as SUM (ARRAY [,MASK=MASK]).
  • An array result has 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.
  • The value of element (s 1, s 2, ..., s DIM-1, s DIM+1, ..., s n) of SUM (ARRAY, DIM [,MASK]) is equal to SUM (ARRAY (s 1, s 2, ..., s DIM-1, :, s DIM+1, ..., s n)) [,MASK=MASK (s 1, s 2, ..., s DIM-1, :, s DIM+1, ..., s n)].

Examples

SUM ((/2, 3, 4/)) returns the value 9 (sum of 2 + 3 + 4). SUM ((/2, 3, 4/), DIM=1) returns the same result.

SUM (B, MASK=B .LT. 0.0) returns the arithmetic sum of the negative elements of B.

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

SUM (C, DIM=1) returns the value (5, 7, 9), which is the sum of all elements in each column. 5 is the sum of 1 + 4 in column 1. 7 is the sum of 2 + 5 in column 2, and so forth.

SUM (C, DIM=2) returns the value (6, 15), which is the sum of all elements in each row. 6 is the sum of 1 + 2 + 3 in row 1. 15 is the sum of 4 + 5 + 6 in row 2.

9.4.152 SYSTEM_CLOCK ([COUNT] [,COUNT_RATE] [,COUNT_MAX])

Description: Returns integer data from a real-time clock. 1
Class: Subroutine
Arguments: There are three optional arguments 2:
COUNT (opt) Must be scalar and of type default integer. It is set to a value based on the current value of the processor clock. The value is increased by one for each clock count until the value COUNT_MAX is reached, and is reset to zero at the next count. (COUNT lies in the range 0 to COUNT_MAX.)
COUNT_
RATE (opt)
Must be scalar and of type default integer. It is set to the number of processor clock counts per second modified by the kind of COUNT_RATE.

If default integer is INTEGER(2), COUNT_RATE is 1000. If default integer is INTEGER(4), COUNT_RATE is 10000. If default integer is INTEGER(8), COUNT_RATE is 1000000.

COUNT_MAX
(opt)
Must be scalar and of type default integer. It is set to the maximum value that COUNT can have, HUGE(0) 3.

1SYSTEM_CLOCK returns the number of seconds from 00:00 Coordinated Universal Time (CUT) on 1 JAN 1970. The number is returned with no bias. To get the elapsed time, you must call SYSTEM_CLOCK twice, and subtract the starting time value from the ending time value.
2All are INTENT(OUT) arguments. (See Section 5.10.)
3For more information on HUGE, see Section 9.4.56.

Examples

Consider the following:


  INTEGER(2) :: IC2, CRATE2, CMAX2
  INTEGER(4) :: IC4, CRATE4, CMAX4
  CALL SYSTEM_CLOCK(COUNT=IC2, COUNT_RATE=CRATE2, COUNT_MAX=CMAX2)
  CALL SYSTEM_CLOCK(COUNT=IC4, COUNT_RATE=CRATE4, COUNT_MAX=CMAX4)
  PRINT *, IC2, CRATE2, CMAX2
  PRINT *, IC4, CRATE4, CMAX4
  end

This program was run on Thursday Dec 11, 1997 at 14:23:55 EST and produced the following output:


  13880   1000  32767
  1129498807       10000  2147483647

9.4.153 TAN (X)

Description: Produces the tangent of X.
Class: Elemental function; Generic
Arguments: X must be of type real. It must be in radians and is treated as modulo 2 * Pi sign.
Results: The result type is the same as X.
Specific Name Argument Type Result Type
TAN REAL(4) REAL(4)
DTAN REAL(8) REAL(8)
QTAN REAL(16) REAL(16)

Examples

TAN (2.0) has the value --2.185040.

TAN (0.8) has the value 1.029639.

9.4.154 TAND (X)

Description: Produces the tangent 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
TAND REAL(4) REAL(4)
DTAND REAL(8) REAL(8)
QTAND REAL(16) REAL(16)

Examples

TAND (2.0) has the value 3.4920771E--02.

TAND (0.8) has the value 1.3963542E--02.

9.4.155 TANH (X)

Description: Produces a hyperbolic tangent.
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
TANH REAL(4) REAL(4)
DTANH REAL(8) REAL(8)
QTANH REAL(16) REAL(16)

Examples

TANH (2.0) has the value 0.9640276.

TANH (0.8) has the value 0.6640368.

9.4.156 TIME (BUF)

Description: Returns the current time as set within the system.
Class: Subroutine
Arguments: BUF is an 8-byte variable, array, array element, or character substring.

The date is returned as an 8-byte ASCII character string taking the form hh:mm:ss, where:

hh is the 2-digit hour
mm is the 2-digit minute
ss is the 2-digit second

If BUF is of numeric type and smaller than 8 bytes, data corruption can occur.

If BUF is of character type, its associated length is passed to the subroutine. If BUF is smaller than 8 bytes, the subroutine truncates the date to fit in the specified length. If a CHARACTER array is passed, the subroutine stores the date in the first array element, using the element length, not the length of the entire array.

Examples

An example of a value returned from a call to TIME is 13:45:23 (a 24-hour clock is used).

Consider the following:


CHARACTER*1 HOUR(8)
...
CALL TIME (HOUR)

The length of the first array element in CHARACTER array HOUR is passed to the TIME subroutine. The subroutine then truncates the time to fit into the 1-character element, producing an incorrect result.

9.4.157 TINY (X)

Description: Returns the smallest number in the model representing the same type and kind parameters as the argument.
Class: Inquiry function; Generic
Arguments: X must be of type real; it can be scalar or array valued.
Results: The result is a scalar with the same type and kind parameters as X. The result has the value b e_min-1 . Parameters b and e min are defined in Section D.2.

Examples

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

9.4.158 TRAILZ (I)

Description: Returns the number of trailing zero bits in an integer.
Class: Elemental function; Generic
Arguments: I must be of type integer.
Results: The result type is the same as I. The result value is the number of trailing zeros in the binary representation of the integer I.

The model for the interpretation of an integer value as a sequence of bits is shown in Section D.3.

Examples

Consider the following:


  INTEGER*8 J, TWO
  PARAMETER (TWO=2)
  DO J= -1, 40
    TYPE *, TRAILZ(TWO**J)  ! Prints 64, then 0 up to
  ENDDO                     !   40 (trailing zeros)
  END

9.4.159 TRANSFER (SOURCE, MOLD [,SIZE])

Description: Copies the bit pattern of SOURCE and interprets it according to the type and kind parameters of MOLD.
Class: Transformational function; Generic
Arguments: SOURCE Must be a scalar or array (of any data type).
  MOLD Must be a scalar or array (of any data type). It provides the type characteristics (not a value) for the result.
  SIZE (opt) Must be scalar and of type integer. It provides the number of elements for the output result.
Results: The result has the same type and type parameters as MOLD.

If MOLD is a scalar and SIZE is omitted, the result is a scalar.

If MOLD is an array and SIZE is omitted, the result is a rank-one array. Its size is the smallest that is possible to hold all of SOURCE.

If SIZE is present, the result is a rank-one array of size SIZE.

If the physical representation of the result is larger than SOURCE, the result contains SOURCE's bit pattern in its right-most bits; the left-most bits of the result are undefined.

If the physical representation of the result is smaller than SOURCE, the result contains the right-most bits of SOURCE's bit pattern.

Examples

TRANSFER (1082130432, 0.0) has the value 4.0 (on processors that represent the values 4.0 and 1082130432 as the string of binary digits 0100 0000 1000 0000 0000 0000 0000 0000).

TRANSFER ((/2.2, 3.3, 4.4/), ((0.0, 0.0))) results in a scalar whose value is (2.2, 3.3).

TRANSFER ((/2.2, 3.3, 4.4/), (/(0.0, 0.0)/)) results in a complex rank-one array of length 2. Its first element is (2.2,3.3) and its second element has a real part with the value 4.4 and an undefined imaginary part.

TRANSFER ((/2.2, 3.3, 4.4/), (/(0.0, 0.0)/), 1) results in a complex rank-one array having one element with the value (2.2, 3.3).


Previous Next Contents Index