HP Fortran for OpenVMS
Language Reference Manual


Previous Contents Index

9.4.107 MY_PROCESSOR ( )

Description: Returns the identifying number of the calling process. 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
Results: The result is a scalar of type default integer. The result value is the identifying number of the physical processor from which the call is made.

The value is in the range 0 to n-1, where n is the value returned by NUMBER_OF_PROCESSORS.

This function can only be called from within an EXTRINSIC (HPF_LOCAL) procedure.

9.4.108 NEAREST (X, S)

Description: Returns the nearest different number (representable on the processor) in a given direction.
Class: Elemental function; Generic
Arguments: X Must be of type real.
  S Must be of type real and nonzero.
Results: The result type is the same as X. A positive S returns the nearest number in the direction of positive infinity. A negative S goes in the direction of negative infinity.

Examples

If 3.0 and 2.0 are REAL(4) values, NEAREST (3.0, 2.0) has the value 3 + 2-22 , which approximately equals 3.0000002, while NEAREST (3.0, -2.0) has the value 3 - 2-22 , which approximately equals 2.9999998. (For more information on the model for REAL(4), see Section D.2.)

9.4.109 NINT (A [,KIND])

Description: Returns the nearest integer to the argument.
Class: Elemental function; Generic
Arguments: A Must be of type real.
  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 shown in the following table. If the processor cannot represent the result value in the kind of the result, the result is undefined.

If A is greater than zero, NINT (A) has the value INT (A + 0.5); if A is less than or equal to zero, NINT (A) has the value INT (A - 0.5).

Specific Name Argument Type Result Type
ININT REAL(4) INTEGER(2)
NINT 1,2 REAL(4) INTEGER(4)
KNINT REAL(4) INTEGER(8)
IIDNNT REAL(8) INTEGER(2)
IDNINT 2,3 REAL(8) INTEGER(4)
KIDNNT REAL(8) INTEGER(8)
IIQNNT REAL(16) INTEGER(2)
IQNINT 2,4 REAL(16) INTEGER(4)
KIQNNT 5 REAL(16) INTEGER(8)

1Or JNINT.
2The setting of compiler options specifying integer size can affect NINT, IDNINT, and IQNINT.
3Or JIDNNT. For compatibility with older versions of Fortran, IDNINT can also be specified as a generic function.
4Or JIQNNT. For compatibility with older versions of Fortran, IQNINT can also be specified as a generic function.
5This specific function cannot be passed as an actual argument.

Examples

NINT (3.879) has the value 4.

NINT (--2.789) has the value --3.

9.4.110 NOT (I)

Description: Returns the logical complement of the argument.
Class: Elemental function; Generic
Arguments: I must be of type integer.
Results: The result type is the same as I. The result value is obtained by complementing I bit-by-bit according to the following truth table:
I
NOT (I)

1 0
0 1

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

Specific Name Argument Type Result Type
  INTEGER(1) INTEGER(1)
INOT INTEGER(2) INTEGER(2)
JNOT INTEGER(4) INTEGER(4)
KNOT INTEGER(8) INTEGER(8)

Examples

If I has a value equal to 10101010 (base 2), NOT (I) has the value 01010101 (base 2).

9.4.111 NULL ([MOLD])

Description: Initializes a pointer as disassociated when it is declared. This is a new intrinsic procedure in Fortran 95.
Class: Transformational function; Generic
Arguments: MOLD is optional. If used, it must be a pointer; it can be of any type. Its pointer association status can be associated, disassociated, or undefined. If its status is associated, the target does not have to be defined with a value.
Results: The result type is the same as MOLD (if present); otherwise, it is determined as follows:
If NULL () Appears...
Type is Determined From...

On the right side of
pointer assignment The pointer on the left side
As initialization for an
object in a declaration The object
As default initialization
for a component The component
In a structure constructor The corresponding component
As an actual argument The corresponding dummy argument
In a DATA statement The corresponding pointer object

The result is a pointer with disassociated association status.

Examples

Consider the following:


   INTEGER, POINTER :: POINT1 => NULL() 

This statement defines the initial association status of POINT1 to be disassociated.

9.4.112 NUMBER_OF_PROCESSORS ([DIM])

Description: Returns the total number of processors (peers) available to the program. 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
Results: The result is a scalar of type default integer. The result value is the total number of processors (peers) available to the program.

For a single-processor workstation, the result value is 1.

9.4.113 NWORKERS ( )

Description: Returns the number of processes executing a routine.

This is a specific function that has no generic function associated with it. It must not be passed as an actual argument. It is provided for compatibility with Compaq Fortran 77 for OpenVMS VAX systems.

Class: Inquiry function; Specific
Arguments: None.
Results: The result is always 1.

9.4.114 PACK (ARRAY, MASK [,VECTOR])

Description: Takes elements from an array and packs them into a rank-one array under the control of a mask.
Class: Transformational function; Generic
Arguments: ARRAY Must be an array (of any data type).
  MASK Must be of type logical and conformable with ARRAY. It determines which elements are taken from ARRAY.
  VECTOR (opt) Must be a rank-one array with the same type and type parameters as ARRAY. Its size must be at least t, where t is the number of true elements in MASK. If MASK is a scalar with value true, VECTOR must have at least as many elements as there are in ARRAY.

Elements in VECTOR are used to fill out the result array if there are not enough elements selected by MASK.

Results: The result is a rank-one array with the same type and type parameters as ARRAY. If VECTOR is present, the size of the result is that of VECTOR. Otherwise, the size of the result is the number of true elements in MASK, or the number of elements in ARRAY (if MASK is a scalar with value true).

Elements in ARRAY are processed in array element order to form the result array. Element i of the result is the element of ARRAY that corresponds to the ith true element of MASK. If VECTOR is present and has more elements than there are true values in MASK, any result elements that are empty (because they were not true according to MASK) are set to the corresponding values in VECTOR.

Examples

N is the array <left[ symbol><matrix symbol> 0&8&0<cr symbol> 0&0&0<cr symbol> 7&0&0<cr symbol> <right] symbol> .

PACK (N, MASK=N .NE. 0, VECTOR=(/1, 3, 5, 9, 11, 13/)) produces the result (7, 8, 5, 9, 11, 13).

PACK (N, MASK=N .NE. 0) produces the result (7, 8).

9.4.115 POPCNT (I)

Description: Returns the number of 1 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 1 bits 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

If the value of I is B'0...00011010110', the value of POPCNT(I) is 5.

9.4.116 POPPAR (I)

Description: Returns the parity of an integer.
Class: Elemental function; Generic
Arguments: I must be of type integer.
Results: The result type is the same as I. If there are an odd number of 1 bits in the binary representation of the integer I, the result value is 1. If there are an even number, the result value is zero.

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

Examples

If the value of I is B'0...00011010110', the value of POPPAR(I) is 1.

9.4.117 PRECISION (X)

Description: Returns the decimal precision in the model representing real numbers with the same kind parameter as the argument.
Class: Inquiry function; Generic
Arguments: X must be of type real or complex. It can be scalar or array valued.
Results: The result is a scalar of type default integer. The result has the value INT((DIGITS(X) - 1) * LOG10(RADIX(X))). If RADIX(X) is an integral power of 10, 1 is added to the result.

Examples

If X is a REAL(4) value, PRECISION (X) has the value 6. The value 6 is derived from INT ((24-1) * LOG10 (2.)) = INT (6.92...). For more information on the model for REAL(4), see Section D.2.

9.4.118 PRESENT (A)

Description: Returns whether or not an optional dummy argument is present (has an associated actual argument).
Class: Inquiry function; Generic
Arguments: A must be an optional argument of the current procedure.
Results: The result is a scalar of type default logical. The result is .TRUE. if A is present; otherwise, the result is .FALSE..

Examples

Consider the following:


SUBROUTINE CHECK (X, Y) 
  REAL X, Z 
  REAL, OPTIONAL :: Y 
  ... 
  IF (PRESENT (Y)) THEN 
    Z = Y 
  ELSE 
     Z = X * 2 
  END IF 
END         
... 
CALL CHECK (15.0, 12.0)      ! Causes B to be set to 12.0 
CALL CHECK (15.0)            ! Causes B to be set to 30.0 

For more information, including a full example, see Section 8.8.1.1.

9.4.119 PROCESSORS_SHAPE ( )

Description: Returns the shape of an implementation-dependent hardware processor array.

Alpha MPI clusters are one-dimensional processor arrays whose shape is the number of peers.

PROCESSORS_SHAPE 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: None.
Results: If a program is compiled for an Alpha MPI cluster, the result is an array of rank one containing the number of processors (peers) available to the program. Otherwise, the result is always a rank-one array of size zero.

9.4.120 PRODUCT (ARRAY [,DIM] [,MASK])

Description: Returns the product 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 or real.
  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 PRODUCT (ARRAY) is specified, the result is the product of all elements of ARRAY. If ARRAY has size zero, the result is 1.
  • If PRODUCT (ARRAY, MASK=MASK) is specified, the result is the product 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 1.

The following rules apply if DIM is specified:

  • If ARRAY has rank one, the value is the same as PRODUCT (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 PRODUCT (ARRAY, DIM [,MASK]) is equal to PRODUCT (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

PRODUCT ((/2, 3, 4/)) returns the value 24 (the product of 2 * 3 * 4). PRODUCT ((/2, 3, 4/), DIM=1) returns the same result.

PRODUCT (C, MASK=C .LT. 0.0) returns the product of the negative elements of C.

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

PRODUCT (A, DIM=1) returns the value (2, 12, 35), which is the product of all elements in each column. 2 is the product of 1 * 2 in column 1. 12 is the product of 4 * 3 in column 2, and so forth.

PRODUCT (A, DIM=2) returns the value (28, 30), which is the product of all elements in each row. 28 is the product of 1 * 4 * 7 in row 1. 30 is the product of 2 * 3 * 5 in row 2.


Previous Next Contents Index