PACK intrinsic function
Standard: F77 F90 F95 F2003
  Example Program

ARRAY : array of any type
MASK : Logical, conformable with ARRAY
VECTOR : vector with same type as ARRAY
The result of PACK(ARRAY,MASK) is a vector containing all the masked elements of ARRAY. The size of this result will be COUNT(MASK) if MASK is an array, SIZE(ARRAY) if MASK is scalar true and zero if MASK is scalar false.

If VECTOR is present it must be at least as big as SIZE(PACK(ARRAY,MASK)). The size of PACK(ARRAY,MASK,VECTOR) is SIZE(VECTOR); if this is bigger than SIZE(PACK(ARRAY,MASK)), the remaining elements of the result are the corresponding elements of VECTOR.
UNPACK intrinsic function