2 ! Check that eoshift works for three-dimensional arrays.
6 subroutine eoshift_3 (array
, shift
, boundary
, dim
, res
)
7 real, dimension(:,:,:), intent(in
) :: array
8 real, dimension(:,:,:), intent(out
) :: res
9 integer, dimension(:,:), intent(in
) :: shift
10 real, optional
, dimension(:,:), intent(in
) :: boundary
11 integer, optional
, intent(in
) :: dim
18 if (present(dim
)) then
37 res(s1
,s2
,s3
) = array(s1
+sh
,s2
,s3
)
39 do s1
= n1
- sh
+ 1,n1
48 res(s1
,s2
,s3
) = array(s1
+sh
,s2
,s3
)
61 res(s1
,s2
,s3
) = array(s1
,s2
+sh
,s3
)
72 res(s1
,s2
,s3
) = array(s1
,s2
+sh
,s3
)
86 res(s1
,s2
,s3
) = array(s1
,s2
,s3
+sh
)
97 res(s1
,s2
,s3
) = array(s1
,s2
,s3
+sh
)
106 end subroutine eoshift_3
107 subroutine fill_shift(x
, n
)
108 integer, intent(out
), dimension(:,:) :: x
109 integer, intent(in
) :: n
110 integer :: n1
, n2
, s1
, s2
119 if (v
> n
+ 1) v
= -n
- 1
122 end subroutine fill_shift
128 integer, parameter :: n1
=10,n2
=30,n3
=40
129 real, dimension(n1
,n2
,n3
) :: a
,b
,c
130 real, dimension(2*n1
,n2
,n3
) :: a2
, c2
132 integer, dimension(n2
,n3
), target
:: sh1
133 integer, dimension(n1
,n3
), target
:: sh2
134 integer, dimension(n1
,n2
), target
:: sh3
135 real, dimension(n2
,n3
), target
:: b1
136 real, dimension(n1
,n3
), target
:: b2
137 real, dimension(n1
,n2
), target
:: b3
139 integer, dimension(:,:), pointer :: sp
140 real, dimension(:,:), pointer :: bp
142 call random_number(a
)
143 call random_number(b1
)
144 call random_number(b2
)
145 call random_number(b3
)
146 call fill_shift(sh1
, n1
)
147 call fill_shift(sh2
, n2
)
148 call fill_shift(sh3
, n3
)
154 else if (dim
== 2) then
161 b
= eoshift(a
,shift
=sp
,dim
=dim
,boundary
=bp
)
162 call eoshift_3 (a
, shift
=sp
, dim
=dim
, boundary
=bp
,res
=c
)
163 if (any (b
/= c
)) then
168 b
= eoshift(a2(1:2*n1
:2,:,:), shift
=sp
, dim
=dim
, boundary
=bp
)
169 if (any(b
/= c
)) then
173 c2(1:2*n1
:2,:,:) = eoshift(a
, shift
=sp
, dim
=dim
, boundary
=bp
)
174 if (any(c2(1:2*n1
:2,:,:) /= c
)) then
177 if (any(c2(2:2*n1
:2,:,:) /= 43.)) then