UNPACK — Unpack an array of rank one into an array¶
- UNPACK()¶
Store the elements of
VECTORin an array of higher rank.- Parameters
VECTOR – Shall be an array of any type and rank one. It shall have at least as many elements as
MASKhasTRUEvalues.MASK – Shall be an array of type
LOGICAL.FIELD – Shall be of the same type as
VECTORand have the same shape asMASK.
- Returns
The resulting array corresponds to
FIELDwithTRUEelements ofMASKreplaced by values fromVECTORin array element order.
Standard:Fortran 90 and later
Class:Transformational function
Syntax:RESULT = UNPACK(VECTOR, MASK, FIELD)
Example:PROGRAM test_unpack integer :: vector(2) = (/1,1/) logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /) integer :: field(2,2) = 0, unity(2,2) ! result: unity matrix unity = unpack(vector, reshape(mask, (/2,2/)), field) END PROGRAM
See also:PACK, SPREAD