HP Fortran for OpenVMS
Language Reference Manual


Previous Contents Index

9.4.30 COTAN (X)

Description: Produces the cotangent of X.
Class: Elemental function; Generic
Arguments: X must be of type real; it cannot be zero. 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
COTAN REAL(4) REAL(4)
DCOTAN REAL(8) REAL(8)
QCOTAN REAL(16) REAL(16)

Examples

COTAN (2.0) has the value --4.576575E--01.

COTAN (0.6) has the value 1.461696.

9.4.31 COTAND (X)

Description: Produces the cotangent 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
COTAND REAL(4) REAL(4)
DCOTAND REAL(8) REAL(8)
QCOTAND REAL(16) REAL(16)

Examples

COTAND (2.0) has the value 0.2863625E+02.

COTAND (0.6) has the value 0.9548947E+02.

9.4.32 COUNT (MASK [,DIM] [,KIND])

Description: Counts the number of true elements in an entire array or in a specified dimension of an array.
Class: Transformational function; Generic
Arguments: MASK Must be a logical array.
  DIM (opt) Must be a scalar integer expression with a value in the range 1 to n, where n is the rank of MASK.
  KIND (opt) Must be a scalar integer initialization expression.
Results: The result is an array or 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.

The result is a scalar if DIM is omitted or MASK has rank one. A scalar result has a value equal to the number of true elements of MASK. If MASK has size zero, the result is zero.

An array result has a rank that is one less than MASK, 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 MASK.

Each element in an array result equals the number of elements that are true in the one dimensional array defined by MASK (s 1, s 2, ..., s DIM-1, :, s DIM+1, ..., s n).

Examples

COUNT ((/.TRUE., .FALSE., .TRUE./)) has the value 2 because two elements are true.

COUNT ((/.TRUE., .TRUE., .TRUE./)) has the value 3 because three elements are true.

A is the array <left[ symbol><matrix symbol> 1&5&7<cr symbol> 3&6&8<cr symbol> <right] symbol> and B is the array <left[ symbol><matrix symbol> 0&5&7<cr symbol> 2&6&9<cr symbol> <right] symbol> .

COUNT (A .NE. B, DIM=1) tests to see how many elements in each column of A are not equal to the elements in the corresponding column of B. The result has the value (2, 0, 1) because:

COUNT (A .NE. B, DIM=2) tests to see how many elements in each row of A are not equal to the elements in the corresponding row of B. The result has the value (1, 2) because:

9.4.33 CPU_TIME (TIME)

Description: Returns a processor-dependent approximation of the processor time in seconds. This is a new intrinsic procedure in Fortran 95.
Class: Subroutine
Arguments: TIME must be scalar and of type real. It is an INTENT(OUT) argument.

If a meaningful time cannot be returned, a processor-dependent negative value is returned.

Examples

Consider the following:


   REAL time_begin, time_end 
   ... 
   CALL CPU_TIME(time_begin) 
   ...                         
   CALL CPU_TIME(time_end) 
 
   PRINT (*,*) 'Time of operation was ', time_end - time_begin, ' seconds' 
 

9.4.34 CSHIFT (ARRAY, SHIFT [,DIM])

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

Elements shifted off one end are inserted at the other end. Different sections can be shifted by different amounts and in different directions.

Class: Transformational function; Generic
Arguments: ARRAY Must be an array; it can be 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.
  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, element i of the result is ARRAY (1 + MODULO (i + SHIFT - 1, SIZE (ARRAY))). (The same shift is applied to each element.)

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

The value of SHIFT determines the amount and direction of the circular 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). A zero SHIFT value causes no shift.

Examples

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

CSHIFT (V, SHIFT=2) shifts the elements in V circularly to the left by two positions, producing the value (3, 4, 5, 6, 1, 2). 1 and 2 are shifted off the beginning and inserted at the end.

CSHIFT (V, SHIFT= --2) shifts the elements in V circularly to the right by two positions, producing the value (5, 6, 1, 2, 3, 4). 5 and 6 are shifted off the end and inserted 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> .

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

Each element in rows 1, 2, and 3 is shifted to the left by two positions. The elements shifted off the beginning are inserted at the end.

CSHIFT (M, SHIFT = --1, DIM = 1) produces the result <left[ symbol><matrix symbol> 7&8&9<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 one position. The elements shifted off the end are inserted at the beginning.

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

Each element in row 1 is shifted to the left by one position; each element in row 2 is shifted to the right by one position; no element in row 3 is shifted at all.

9.4.35 DATE (BUF)

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

The date is returned as a 9-byte ASCII character string taking the form dd-mmm-yy, where:

dd is the 2-digit date
mmm is the 3-letter month
yy is the last two digits of the year

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

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

Warning: The two-digit year return value may cause problems with the year 2000. Use DATE_AND_TIME instead (see Section 9.4.36).

Examples

Consider the following:


CHARACTER*1 DAY(9) 
... 
CALL DATE (DAY) 

The length of the first array element in CHARACTER array DAY is passed to the DATE subroutine. The subroutine then truncates the date to fit into the one-character element, producing an incorrect result.

9.4.36 DATE_AND_TIME ([DATE] [,TIME] [,ZONE] [,VALUES])

Description: Returns character data on the real-time clock and date in a form compatible with the representations defined in Standard ISO 8601:1988.
Class: Subroutine
Arguments: There are four optional arguments 1:
DATE (opt) Must be scalar and of type default character; its length must be at least 8 to contain the complete value. Its leftmost 8 characters are set to a value of the form CCYYMMDD, where:
CC is the century
YY is the year within the century
MM is the month within the year
DD is the day within the month
TIME (opt) Must be scalar and of type default character; its length must be at least 10 to contain the complete value. Its leftmost 10 characters are set to a value of the form hhmmss.sss, where:
hh is the hour of the day
mm is the minutes of the hour
ss.sss is the seconds and milliseconds of the minute
ZONE (opt) Must be scalar and of type default character; its length must be at least 5 to contain the complete value. Its leftmost 5 characters are set to a value of the form <pm symbol> hhmm, where hh and mm are the time difference with respect to Coordinated Universal Time (UTC) 2 in hours and parts of an hour expressed in minutes, respectively.
VALUES
(opt)
Must be of type default integer and of rank one. Its size must be at least 8. The values returned in VALUES are as follows:
VALUES (1) is the 4-digit year.
VALUES (2) is the month of the year.
VALUES (3) is the day of the month.
VALUES (4) is the time difference with respect to
Coordinated Universal Time (UTC) in minutes.
VALUES (5) is the hour of the day (range 0 to 23). 3
VALUES (6) is the minutes of the hour (range 0 to 59). 3
VALUES (7) is the seconds of the minute (range 0 to 59). 3
VALUES (8) is the milliseconds of the second (range 0 to 999). 3

1All are INTENT(OUT) arguments. (See Section 5.10.)
2UTC (also known as Greenwich Mean Time) is defined by CCIR Recommendation 460--2.
3In local time.

Note: If time zone information is not available on the system, a blank is returned for the ZONE argument and --1 is returned for the differential element of the VALUES argument.

Examples

Consider the following example executed on 2000 March 28 at 11:04:14.5:


INTEGER DATE_TIME (8) 
CHARACTER (LEN = 12) REAL_CLOCK (3) 
CALL DATE_AND_TIME (REAL_CLOCK (1), REAL_CLOCK (2), & 
                    REAL_CLOCK (3), DATE_TIME) 

This assigns the value "20000328" to REAL_CLOCK (1), the value "110414.500" to REAL_CLOCK (2), and the value "--0500" to REAL_CLOCK (3). The following values are assigned to DATE_TIME: 2000, 3, 28, -300, 11, 4, 14, and 500.

9.4.37 DBLE (A)

Description: Converts a number to double-precision real type.
Class: Elemental function; Generic
Arguments: A must be of type integer, real, or complex.
Results: The result is of type double precision real (REAL(8) or REAL*8). Functions that cause conversion of one data type to another type have the same effect as the implied conversion in assignment statements.

If A is of type double precision, the result is the value of the A with no conversion (DBLE(A) = A).

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

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

Specific Name1 Argument Type Result Type
  INTEGER(1) REAL(8)
  INTEGER(2) REAL(8)
  INTEGER(4) REAL(8)
  INTEGER(8) REAL(8)
DBLE 2 REAL(4) REAL(8)
  REAL(8) REAL(8)
DBLEQ REAL(16) REAL(8)
  COMPLEX(4) REAL(8)
  COMPLEX(8) REAL(8)
  COMPLEX(16) REAL(8)


1These specific functions cannot be passed as actual arguments.
2For compatibility with older versions of Fortran, DBLE can also be specified as a specific function.

Examples

DBLE (4) has the value 4.0.

DBLE ((3.4, 2.0)) has the value 3.4.

9.4.38 DCMPLX (X [,Y])

Description: Converts the argument to double complex type. This function must not be passed as an actual argument.
Class: Elemental function; Generic
Arguments: X Must be of type integer, real, or complex.
  Y (opt) Must be of type integer or real. It must not be present if X is of type complex.
Results: The result is of type double complex (COMPLEX(8) or COMPLEX*16).

If only one noncomplex argument appears, it is converted into the real part of the result value and zero is assigned to the imaginary part. If Y is not specified and X is complex, the result value is CMPLX (REAL(X), AIMAG(X)).

If two noncomplex arguments appear, the complex value is produced by converting the first argument into the real part of the value, and converting the second argument into the imaginary part.

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

Examples

DCMPLX (--3) has the value (--3.0, 0.0).

DCMPLX (4.1, 2.3) has the value (4.1, 2.3).

9.4.39 DFLOAT (A)

Description: Converts an integer to double-precision type.
Class: Elemental function; Generic
Arguments: A must be of type integer.
Results: The result is of type double-precision real (REAL(8) or REAL*8).

Functions that cause conversion of one data type to another type have the same affect as the implied conversion in assignment statements.

Specific Name1 Argument Type Result Type
  INTEGER(1) REAL(8)
DFLOTI INTEGER(2) REAL(8)
DFLOTJ INTEGER(4) REAL(8)
DFLOTK INTEGER(8) REAL(8)

1These specific functions cannot be passed as actual arguments.

Examples

DFLOAT (--4) has the value --4.0.


Previous Next Contents Index