UNPACK intrinsic function
Standard: F77 F90 F95 F2003
  Example Program

VECTOR : array of any type and rank 1
MASK : Logical array
FIELD : same type as VECTOR, conformable with MASK
Returns an array with the same type as VECTOR and the same shape as MASK. The size of VECTOR shall be at least the number of true elements in MASK.

Elements of the result that correspond to true elements of MASK are taken from VECTOR (this process occurs in array element order); other elements are set to the corresponding element of FIELD.
PACK intrinsic function