2 ! Check that eoshift works for three-dimensional arrays.
6 subroutine eoshift_1 (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
, intent(in
) :: boundary
11 integer, optional
, intent(in
) :: dim
18 if (present(boundary
)) then
24 if (present(dim
)) then
42 res(s1
,s2
,s3
) = array(s1
+sh
,s2
,s3
)
44 do s1
= n1
- sh
+ 1,n1
53 res(s1
,s2
,s3
) = array(s1
+sh
,s2
,s3
)
65 res(s1
,s2
,s3
) = array(s1
,s2
+sh
,s3
)
76 res(s1
,s2
,s3
) = array(s1
,s2
+sh
,s3
)
89 res(s1
,s2
,s3
) = array(s1
,s2
,s3
+sh
)
100 res(s1
,s2
,s3
) = array(s1
,s2
,s3
+sh
)
109 end subroutine eoshift_1
110 subroutine fill_shift(x
, n
)
111 integer, intent(out
), dimension(:,:) :: x
112 integer, intent(in
) :: n
113 integer :: n1
, n2
, s1
, s2
122 if (v
> n
+ 1) v
= -n
- 1
125 end subroutine fill_shift
131 integer, parameter :: n1
=20,n2
=30,n3
=40
132 real, dimension(n1
,n2
,n3
) :: a
,b
,c
133 real, dimension(2*n1
,n2
,n3
) :: a2
, c2
135 integer, dimension(n2
,n3
), target
:: sh1
136 integer, dimension(n1
,n3
), target
:: sh2
137 integer, dimension(n1
,n2
), target
:: sh3
138 real, dimension(n2
,n3
), target
:: b1
139 real, dimension(n1
,n3
), target
:: b2
140 real, dimension(n1
,n2
), target
:: b3
142 integer, dimension(:,:), pointer :: sp
143 real, dimension(:,:), pointer :: bp
145 call random_number(a
)
146 call fill_shift(sh1
, n1
)
147 call fill_shift(sh2
, n2
)
148 call fill_shift(sh3
, n3
)
153 else if (dim
== 2) then
158 b
= eoshift(a
,shift
=sp
,dim
=dim
,boundary
=-0.5)
159 call eoshift_1 (a
, shift
=sp
, dim
=dim
, boundary
=-0.5,res
=c
)
160 if (any (b
/= c
)) then
161 print *,"dim = ", dim
169 b
= eoshift(a2(1:2*n1
:2,:,:), shift
=sp
, dim
=dim
, boundary
=-0.5)
170 if (any(b
/= c
)) then
174 c2(1:2*n1
:2,:,:) = eoshift(a
, shift
=sp
, dim
=dim
, boundary
=-0.5)
175 if (any(c2(1:2*n1
:2,:,:) /= c
)) then
178 if (any(c2(2:2*n1
:2,:,:) /= 43.)) then