|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.
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
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.
N is the array
PACK (N, MASK=N .NE. 0, VECTOR=(/1, 3, 5, 9, 11, 13/)) produces the result (7, 8, 5, 9, 11, 13).
[ 0 8 0 ] [ 0 0 0 ] [ 7 0 0 ].
PACK (N, MASK=N .NE. 0) produces the result (7, 8).