UNPACK(3f)

DESCRIPTION
Store the elements of VECTOR in an array of higher rank.

STANDARD
Fortran 95 and later

CLASS
Transformational function

SYNTAX
RESULT = UNPACK(VECTOR, MASK, FIELD)

ARGUMENTS

VECTOR Shall be an array of any type and rank one. It shall have at least as many elements as MASK has TRUE values. MASK Shall be an array of type LOGICAL. FIELD Shall be of the same type as VECTOR and have the same shape as MASK.

RETURN VALUE
The resulting array corresponds to FIELD with TRUE elements of MASK replaced by values from VECTOR in array element order.

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

AUTHOR

This information was taken from the GFortran documentation (https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gfortran/) and converted to a manpage by AstroFloyd (http://astrofloyd.org).