[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP Fortran for OpenVMS
Language Reference Manual


Previous Contents Index

Table 9-4 lists the specific functions that have no generic function associated with them.

Table 9-4 Specific Functions with No Generic Association
Specific Function Class Value Returned
DPROD (X, Y) E The higher precision product of two real arguments
DREAL (A) E The corresponding double-precision value of the real part of a double-complex argument
EOF (A) I .TRUE. or .FALSE. depending on whether a file is beyond the end-of-file record
MALLOC (I) E The starting address for the block of memory allocated
MULT_HIGH (I, J) E The upper (leftmost) 64 bits of the 128-bit unsigned result.
NUMBER_OF_PROCESSORS
([DIM])
I The total number of processors (peers) available to the program
MY_PROCESSOR
( )
I The identifying number of the calling process
NWORKERS ( ) 1 I The number of executing processes
PROCESSORS_SHAPE ( ) I The shape of an implementation-dependent hardware processor array
QREAL (A) E The corresponding REAL(16) value of the real part of a COMPLEX(16) argument
RAN (I) N The next number from a sequence of pseudorandom numbers (uniformly distributed in the range 0 to 1)
SECNDS (X) E The system time of day (or elapsed time) as a floating-point value in seconds
SIZEOF (X) I The bytes of storage used by the argument

1Included for compatibility with older versions of Compaq Fortran 77.

Key to Classes
E--Elemental
I--Inquiry
N--Nonelemental

9.3.2 Intrinsic Subroutines

Table 9-5 lists the intrinsic subroutines. All these subroutines are nonelemental except for MVBITS.

Table 9-5 Intrinsic Subroutines
Subroutine Value Returned or Result
CPU_TIME (TIME) The processor time in seconds
DATE (BUF) The ASCII representation of the current date (in dd-mmm-yy form)
DATE_AND_TIME ([DATE] [,TIME]
[,ZONE] [,VALUES])
Date and time information from the real-time clock
ERRSNS ([IO_ERR] [,SYS_ERR] [,STAT]
[,UNIT] [,COND])
Information about the most recently detected error condition
EXIT ([STATUS]) Optionally returns image exit status; terminates the program, closes all files, and returns control to the operating system
FREE (A) Frees memory that is currently allocated
IDATE (I, J, K) Three integer values representing the current month, day, and year
MVBITS (FROM, FROMPOS, LEN,
TO, TOPOS) 1
Copies a sequence of bits (bit field) from one location to another
RANDOM_NUMBER (HARVEST) A pseudorandom number taken from a sequence of pseudorandom numbers uniformly distributed within the range 0 <= x < 1
RANDOM_SEED ([SIZE] [,PUT] [,GET]) Initializes or retrieves the pseudorandom number generator seed value
RANDU (I1, I2, X) A pseudorandom number as a single-precision value (within the range 0.0 to 1.0)
SYSTEM_CLOCK ([COUNT]
[,COUNT_RATE] [,COUNT_MAX])
Data from the processors real-time clock
TIME (BUF) The ASCII representation of the current time (in hh:mm:ss form)

1An elemental subroutine.

9.3.3 Bit Functions

Integer data types are represented internally in binary twos complement notation. Bit positions in the binary representation are numbered from right (least significant bit) to left (most significant bit); the rightmost bit position is numbered 0.

The intrinsic functions IAND, IOR, IEOR, and NOT operate on all of the bits of their argument (or arguments). Bit 0 of the result comes from applying the specified logical operation to bit 0 of the argument. Bit 1 of the result comes from applying the specified logical operation to bit 1 of the argument, and so on for all of the bits of the result.

The functions ISHFT and ISHFTC shift binary patterns.

The functions IBSET, IBCLR, BTEST, and IBITS and the subroutine MVBITS operate on bit fields.

A bit field is a contiguous group of bits within a binary pattern. Bit fields are specified by a starting bit position and a length. A bit field must be entirely contained in its source operand.

For example, the integer 47 is represented by the following:

Binary pattern: 0...0101111
Bit position: n...6543210
  Where n is the number of bit positions
in the numeric storage unit.

You can refer to the bit field contained in bits 3 through 6 by specifying a starting position of 3 and a length of 4.

Negative integers are represented in twos complement notation. For example, the integer --47 is represented by the following:

Binary pattern: 1...1010001
Bit position: n...6543210
  Where n is the number of bit positions
in the numeric storage unit.

The value of bit position n is as follows:

1 for a negative number
0 for a non-negative number

All the high-order bits in the pattern from the last significant bit of the value up to bit n are the same as bit n.

IBITS and MVBITS operate on general bit fields. Both the starting position of a bit field and its length are arguments to these intrinsics. IBSET, IBCLR, and BTEST operate on 1-bit fields. They do not require a length argument.

For IBSET, IBCLR, and BTEST, the bit position range is as follows:

  • 0 to 63 for INTEGER(8) and LOGICAL(8)
  • 0 to 31 for INTEGER(4) and LOGICAL(4)
  • 0 to 15 for INTEGER(2) and LOGICAL(2)
  • 0 to 7 for BYTE, INTEGER(1), and LOGICAL(1)

For IBITS, the bit position can be any number. The length range is 0 to 63.

The following example demonstrates IBSET, IBCLR, and BTEST:


I = 4
J = IBSET (I,5)
PRINT *, 'J = ',J
K = IBCLR (J,2)
PRINT *, 'K = ',K
PRINT *, 'Bit 2 of K is ',BTEST(K,2)
END

The results are: J = 36, K = 32, and Bit 2 of K is F.

For optimum selection of performance and memory requirements, HP Fortran provides the following integer data types:

Data Type Storage Required (in bytes)
INTEGER(1) 1
INTEGER(2) 2
INTEGER(4) 4
INTEGER(8) 8

The bit manipulation functions each have a generic form that operates on all of these integer types and a specific form for each type.

When you specify the intrinsic functions that refer to bit positions or that shift binary patterns within a storage unit, be careful that you do not create a value that is outside the range of integers representable by the data type. If you shift by an amount greater than or equal to the size of the object you're shifting, the result is 0.

Consider the following:


INTEGER(2) I,J
I = 1
J = 17
I = ISHFT(I,J)

The variables I and J have INTEGER(2) type. Therefore, the generic function ISHFT maps to the specific function IISHFT, which returns an INTEGER(2) result. INTEGER(2) results must be in the range --32768 to 32767, but the value 1, shifted left 17 positions, yields the binary pattern 1 followed by 17 zeros, which represents the integer 131072. In this case, the result in I is 0.

The previous example would be valid if I was INTEGER(4), because ISHFT would then map to the specific function JISHFT, which returns an INTEGER(4) value.

If ISHFT is called with a constant first argument, the result will either be the default integer size or the smallest integer size that can contain the first argument, whichever is larger.

9.4 Descriptions of Intrinsic Procedures

This section contains detailed information on all the generic and specific intrinsic procedures. These procedures are described in alphabetical order by generic name (if there is one). In headings, square brackets denote optional arguments; in text, these optional arguments are labeled "(opt)".

9.4.1 ABS (A)

Description: Computes an absolute value.
Class: Elemental function; Generic
Arguments: A must be of type integer, real, or complex.
Results: If A is an integer or real value, the value of the result is |A|; if A is a complex value (X, Y), the result is the real value SQRT (X**2 + Y**2).
Specific Name Argument Type Result Type
  INTEGER(1) INTEGER(1)
IIABS INTEGER(2) INTEGER(2)
IABS 1 INTEGER(4) INTEGER(4)
KIABS INTEGER(8) INTEGER(8)
ABS REAL(4) REAL(4)
DABS REAL(8) REAL(8)
QABS REAL(16) REAL(16)
CABS 2 COMPLEX(4) REAL(4)
CDABS 3 COMPLEX(8) REAL(8)
CQABS COMPLEX(16) REAL(16)

1Or JIABS. For compatibility with older versions of Fortran, IABS can also be specified as a generic function.
2The setting of compiler options specifying real size can affect CABS.
3This function can also be specified as ZABS.

Examples

ABS (--7.4) has the value 7.4.

ABS ((6.0, 8.0)) has the value 10.0.

9.4.2 ACHAR (I)

Description: Returns the character in a specified position of the ASCII character set, even if the processor's default character set is different. It is the inverse of the IACHAR function. In HP Fortran, ACHAR is equivalent to the CHAR function.
Class: Elemental function; Generic
Arguments: I must be of type integer.
Results: The result is of type character with length 1; it has the kind parameter value of KIND ( ' A ' ).

If I has a value within the range 0 to 127, the result is the character in position I of the ASCII character set. ACHAR (IACHAR(C)) has the value C for any character C capable of representation in the processor.

Examples

ACHAR (71) has the value ' G ' .

ACHAR (63) has the value ' ? ' .

9.4.3 ACOS (X)

Description: Produces the arccosine of X.
Class: Elemental function; Generic
Arguments: X must be of type real. The |X| must be less than or equal to 1.
Results: The result type is the same as X and is expressed in radians. The value lies in the range 0 to Pi sign.
Specific Name Argument Type Result Type
ACOS REAL(4) REAL(4)
DACOS REAL(8) REAL(8)
QACOS REAL(16) REAL(16)

Examples

ACOS (0.68032123) has the value .8225955.

9.4.4 ACOSD (X)

Description: Produces the arccosine of X.
Class: Elemental function; Generic
Arguments: X must be of type real and must be greater than or equal to zero. The |X| must be less than or equal to 1.
Results: The result type is the same as X and is expressed in degrees.
Specific Name Argument Type Result Type
ACOSD REAL(4) REAL(4)
DACOSD REAL(8) REAL(8)
QACOSD REAL(16) REAL(16)

Examples

ACOSD (0.886579) has the value 27.55354.

9.4.5 ADJUSTL (STRING)

Description: Adjusts a character string to the left, removing leading blanks and inserting trailing blanks.
Class: Elemental function; Generic
Arguments: STRING must be of type character.
Results: The result is of type character with the same length and kind parameter as STRING.

The value of the result is the same as STRING, except that any leading blanks have been removed and inserted as trailing blanks.

Examples

ADJUSTL ( ' ----SUMMERTIME ' ) has the value ' SUMMERTIME---- ' .

9.4.6 ADJUSTR (STRING)

Description: Adjusts a character string to the right, removing trailing blanks and inserting leading blanks.
Class: Elemental function; Generic
Arguments: STRING must be of type character.
Results: The result is of type character with the same length and kind parameter as STRING.

The value of the result is the same as STRING, except that any trailing blanks have been removed and inserted as leading blanks.

Examples

ADJUSTR ( ' SUMMERTIME---- ' ) has the value ' ----SUMMERTIME ' .


Previous Next Contents Index