Takes some or all elements from a one-dimensional array and rearranges them into another, possibly larger, array.
The result is an array with the same shape as MASK and the same data type as VECTOR.
The elements of the result are filled in array-element order: if the corresponding element in MASK is .TRUE., the result element is filled by the next element of VECTOR; otherwise, it is filled by the corresponding element of FIELD.
! VECTOR is the array (/ 5, 6, 7, 8 /), ! MASK is | F T T |, FIELD is | -1 -4 -7 | ! | T F F | | -2 -5 -8 | ! | F F T | | -3 -6 -9 | ! Turn the one-dimensional vector into a two-dimensional ! array. The elements of VECTOR are placed into the .TRUE. ! positions in MASK, and the remaining elements are ! made up of negative values from FIELD. RES = UNPACK( VECTOR, MASK, FIELD ) ! The result is | -1 6 7 | ! | 5 -5 -8 | ! | -3 -6 8 | ! Do the same transformation, but using all zeros for the ! replacement values of FIELD. RES = UNPACK( VECTOR, MASK, FIELD = 0 ) ! The result is | 0 6 7 | ! | 5 0 0 | ! | 0 0 8 |