Multiplies together all elements in an entire array, or selected elements from all vectors along a dimension.

**ARRAY**- is an array with a numeric data type.
**DIM (optional)**- is an integer scalar in the range 1 <= DIM <= rank(ARRAY).
**MASK (optional)**- is a logical expression that conforms with ARRAY in shape. If MASK is a scalar, the scalar value applies to all elements in ARRAY.

**Class**

Transformational function

**Result Value**

If DIM is present, the result is an array of rank rank(ARRAY)-1 and the same data type as ARRAY. If DIM is missing, or if MASK has a rank of one, the result is a scalar.

The result is calculated by one of the following methods:

**Method 1:**- If only ARRAY is specified, the result is the product of all its array elements. If ARRAY is a zero-sized array, the result is equal to one.
**Method 2:**- If ARRAY and MASK are both specified, the result is the product of those array elements of ARRAY that have a corresponding true array element in MASK. If MASK has no elements with a value of .TRUE., the result is equal to one.
**Method 3:**- If DIM is also specified, the result value equals the product of the array elements of ARRAY along dimension DIM that have a corresponding true array element in MASK.

+---------------------------------Fortran 95---------------------------------+

Because both DIM and MASK are optional, various combinations of
arguments are possible. When the **-qintlog** option is specified
with two arguments, the second argument refers to one of the following:

- MASK if it is an array of type integer, logical, byte or typeless
- DIM if it is a scalar of type integer, byte or typeless
- MASK if it is a scalar of type logical

+-----------------------------End of Fortran 95------------------------------+

**Examples**

- Method 1:
`! Multiply all elements in an array. RES = PRODUCT( (/2, 3, 4/) ) ! The result is 24 because (2 * 3 * 4) = 24. ! Do the same for a two-dimensional array. RES = PRODUCT( (/2, 3, 4/), (/4, 5, 6/) ) ! The result is 2880. All elements are multiplied.`

- Method 2:
`! A is the array (/ -3, -7, -5, 2, 3 /) ! Multiply all elements of the array that are > -5. RES = PRODUCT(A, MASK = A .GT. -5) ! The result is -18 because (-3 * 2 * 3) = -18.`

- Method 3:
`! A is the array | -2 5 7 | ! | 3 -4 3 | ! Find the product of each column in A. RES = PRODUCT(A, DIM = 1) ! The result is | -6 -20 21 | because (-2 * 3) = -6 ! ( 5 * -4 ) = -20 ! ( 7 * 3 ) = 21 ! Find the product of each row in A. RES = PRODUCT(A, DIM = 2) ! The result is | -70 -36 | ! because (-2 * 5 * 7) = -70 ! (3 * -4 * 3) = -36 ! Find the product of each row in A, considering ! only those elements greater than zero. RES = PRODUCT(A, DIM = 2, MASK = A .GT. 0) ! The result is | 35 9 | because ( 5 * 7) = 35 ! (3 * 3) = 9`