Visible to Intel only — GUID: GUID-F210DE6F-AC89-4F37-9930-7B732550031F
Visible to Intel only — GUID: GUID-F210DE6F-AC89-4F37-9930-7B732550031F
UNPACK
Transformational Intrinsic Function (Generic): Takes elements from a rank-one array and unpacks them into another (possibly larger) array under the control of a mask.
result = UNPACK (vector,mask,field)
vector |
(Input) Must be a rank-one array. It may be of any data type. Its size must be at least t, where t is the number of true elements in mask. |
mask |
(Input) Must be a logical array. It determines where elements of vector are placed when they are unpacked. |
field |
(Input) Must be of the same type and type parameters as vector and conformable with mask. Elements in field are inserted into the result array when the corresponding mask element has the value false. |
The result is an array with the same shape as mask, and the same type and type parameters as vector.
Elements in the result array are filled in array element order. If element i of mask is true, the corresponding element of the result is filled by the next element in vector. Otherwise, it is filled by field (if field is scalar) or the ith element of field (if field is an array).
N is the array
[ 0 0 1 ] [ 1 0 1 ] [ 1 0 0 ],
P is the array (2, 3, 4, 5), and Q is the array
[ T F F ] [ F T F ] [ T T F ].
UNPACK (P, MASK=Q, FIELD=N) produces the result
[ 2 0 1 ] [ 1 4 1 ] [ 3 5 0 ].
UNPACK (P, MASK=Q, FIELD=1) produces the result
[ 2 1 1 ] [ 1 4 1 ] [ 3 5 1 ].
The following shows another example:
LOGICAL mask (2, 3)
INTEGER vector(3) /1, 2, 3/, AR1(2, 3)
mask = RESHAPE((/.TRUE.,.FALSE.,.FALSE.,.TRUE.,&
.TRUE.,.FALSE./), (/2, 3/))
! vector = [1 2 3] and mask = T F T
! F T F
AR1 = UNPACK(vector, mask, 8) ! returns 1 8 3
! 8 2 8
END