1 ! Program to test the UNPACK intrinsic
2 program intrinsic_unpack
3 integer, dimension(3, 3) :: a
, b
4 logical, dimension(3, 3) :: mask
;
5 character(len
=50) line1
, line2
8 mask
= reshape ((/.false
.,.true
.,.false
.,.true
.,.false
.,.false
.,&
9 &.false
.,.false
.,.true
./), (/3, 3/));
10 a
= reshape ((/1, 0, 0, 0, 1, 0, 0, 0, 1/), (/3, 3/));
11 b
= unpack ((/2, 3, 4/), mask
, a
)
12 if (any (b
.ne
. reshape ((/1, 2, 0, 3, 1, 0, 0, 0, 4/), (/3, 3/)))) &
14 write (line1
,'(10I4)') b
15 write (line2
,'(10I4)') unpack((/2, 3, 4/), mask
, a
)
16 if (line1
.ne
. line2
) call abort
18 b
= unpack ((/2, 3, 4/), mask
, 0)
19 if (any (b
.ne
. reshape ((/0, 2, 0, 3, 0, 0, 0, 0, 4/), (/3, 3/)))) &