1 ! Program to test the eoshift intrinsic
2 program intrinsic_eoshift
3 integer, dimension(3, 3) :: a
4 integer, dimension(3, 3, 2) :: b
5 integer, dimension(3) :: bo
, sh
7 ! Scalar shift and scalar bound.
8 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
9 a
= eoshift (a
, 1, 99, 1)
10 if (any (a
.ne
. reshape ((/2, 3, 99, 5, 6, 99, 8, 9, 99/), (/3, 3/)))) &
13 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
14 a
= eoshift (a
, 9999, 99, 1)
15 if (any (a
.ne
. 99)) STOP 2
17 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
18 a
= eoshift (a
, -2, dim
= 2)
19 if (any (a
.ne
. reshape ((/0, 0, 0, 0, 0, 0, 1, 2, 3/), (/3, 3/)))) &
22 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
23 a
= eoshift (a
, -9999, 99, 1)
24 if (any (a
.ne
. 99)) STOP 4
26 ! Array shift and scalar bound.
27 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
28 a
= eoshift (a
, (/1, 0, -1/), 99, 1)
29 if (any (a
.ne
. reshape ((/2, 3, 99, 4, 5, 6, 99, 7, 8/), (/3, 3/)))) &
32 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
33 a
= eoshift (a
, (/9999, 0, -9999/), 99, 1)
34 if (any (a
.ne
. reshape ((/99, 99, 99, 4, 5, 6, 99, 99, 99/), (/3, 3/)))) &
37 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
38 a
= eoshift (a
, (/2, -2, 0/), dim
= 2)
39 if (any (a
.ne
. reshape ((/7, 0, 3, 0, 0, 6, 0, 2, 9/), (/3, 3/)))) &
42 ! Scalar shift and array bound.
43 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
44 a
= eoshift (a
, 1, (/99, -1, 42/), 1)
45 if (any (a
.ne
. reshape ((/2, 3, 99, 5, 6, -1, 8, 9, 42/), (/3, 3/)))) &
48 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
49 a
= eoshift (a
, 9999, (/99, -1, 42/), 1)
50 if (any (a
.ne
. reshape ((/99, 99, 99, -1, -1, -1, 42, 42, 42/), &
53 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
54 a
= eoshift (a
, -9999, (/99, -1, 42/), 1)
55 if (any (a
.ne
. reshape ((/99, 99, 99, -1, -1, -1, 42, 42, 42/), &
58 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
59 a
= eoshift (a
, -2, (/99, -1, 42/), 2)
60 if (any (a
.ne
. reshape ((/99, -1, 42, 99, -1, 42, 1, 2, 3/), (/3, 3/)))) &
63 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
65 a
= eoshift (a
, -2, bo
, 2)
66 if (any (a
.ne
. reshape ((/99, -1, 42, 99, -1, 42, 1, 2, 3/), (/3, 3/)))) &
69 ! Array shift and array bound.
70 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
71 a
= eoshift (a
, (/1, 0, -1/), (/99, -1, 42/), 1)
72 if (any (a
.ne
. reshape ((/2, 3, 99, 4, 5, 6, 42, 7, 8/), (/3, 3/)))) &
75 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
76 a
= eoshift (a
, (/2, -2, 0/), (/99, -1, 42/), 2)
77 if (any (a
.ne
. reshape ((/7, -1, 3, 99, -1, 6, 99, 2, 9/), (/3, 3/)))) &
80 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
82 bo
= (/-999, -99, -9 /)
83 a
= eoshift(a
, shift
=sh
, boundary
=bo
)
84 if (any (a
.ne
. reshape ((/ -999, -999, -999, -99, 4, 5, -9, -9, -9 /), &
87 a
= reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
88 a
= eoshift (a
, (/9999, -9999, 0/), (/99, -1, 42/), 2)
89 if (any (a
.ne
. reshape ((/99, -1, 3, 99, -1, 6, 99, -1, 9/), (/3, 3/)))) &
92 ! Test arrays > rank 2
93 b(:, :, 1) = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
94 b(:, :, 2) = 10 + reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
95 b
= eoshift (b
, 1, 99, 1)
96 if (any (b(:, :, 1) .ne
. reshape ((/2, 3, 99, 5, 6, 99, 8, 9, 99/), (/3, 3/)))) &
98 if (any (b(:, :, 2) .ne
. reshape ((/12, 13, 99, 15, 16, 99, 18, 19, 99/), (/3, 3/)))) &
101 ! TODO: Test array sections