PACK(3I) Last changed: 1-6-98
NAMEPACK - Packs an array into an array of rank one under control of a
mask
SYNOPSISPACK ([ARRAY=]array, [MASK=]mask [,[VECTOR=]vector])
IMPLEMENTATION
UNICOS, UNICOS/mk, and IRIX systems
STANDARDS
Fortran 90
DESCRIPTION
The PACK intrinsic function packs an array into an array of rank one
under control of a mask. It can be used for array construction. It
accepts the following arguments:
array Can be of any type. It must not be scalar.
mask Must be of type logical and must be conformable with array.
vector Must be of the same type as array and must have rank one.
vector must have at least as many elements as there are true
elements in mask. If mask is scalar with the value true,
vector must have at least as many elements as there are in
array.
PACK is a transformational function. The name of this intrinsic
cannot be passed as an argument.
RETURN VALUES
The result is an array of rank one of the same type as array. If
vector is present, the result size is that of vector; otherwise, the
result size is the number t of true elements in mask unless mask is
scalar with the value true in which case the result size is the size
of array.
Element i of the result is the element of array that corresponds to
the ith true element of mask, taking elements in array element order,
for i=1, 2, ..., t. If vector is present and has size n>t, element i
of the result has the value vector(i), for i=t+1, ..., n.
EXAMPLES
Example 1: If N = (/ 1, -1, 3 /), the following are true:
PACK( N, MASK=N.LT.0) is [-1].
PACK( N, MASK=.TRUE.) is [1, -1, 3].
Example 2: Array M is as follows:
| 0 0 0 |
| 9 0 0 |
| 0 0 7 |
The nonzero elements of array M can be gathered by the PACK function.
The following are the results:
PACK(M, MASK=M.NE.0) is [9, 7].
PACK(M, MASK=M.NE.0, VECTOR=(/2, 4, 6, 8, 10, 12/)) is [9, 7, 6,
8, 10 12].
SEE ALSO
Intrinsic Procedures Reference Manual, publication SR-2138, for the
printed version of this man page.