2 ! Check that eoshift works for three-dimensional arrays.
6 subroutine eoshift_0 (array
, shift
, boundary
, dim
, res
)
7 real, dimension(:,:,:), intent(in
) :: array
8 real, dimension(:,:,:), intent(out
) :: res
9 integer, value
:: shift
10 real, optional
, intent(in
) :: boundary
11 integer, optional
, intent(in
) :: dim
17 if (present(boundary
)) then
23 if (present(dim
)) then
36 shift
= min(shift
, n1
)
40 res(s1
,s2
,s3
) = array(s1
+shift
,s2
,s3
)
42 do s1
= n1
- shift
+ 1,n1
49 shift
= max(shift
, -n1
)
56 res(s1
,s2
,s3
) = array(s1
+shift
,s2
,s3
)
64 shift
= min(shift
, n2
)
68 res(s1
,s2
,s3
) = array(s1
,s2
+shift
,s3
)
71 do s2
=n2
- shift
+ 1, n2
78 shift
= max(shift
, -n2
)
87 res(s1
,s2
,s3
) = array(s1
,s2
+shift
,s3
)
95 shift
= min(shift
, n3
)
99 res(s1
,s2
,s3
) = array(s1
,s2
,s3
+shift
)
103 do s3
=n3
- shift
+ 1, n3
111 shift
= max(shift
, -n3
)
122 res(s1
,s2
,s3
) = array(s1
,s2
,s3
+shift
)
131 end subroutine eoshift_0
137 integer, parameter :: n1
=2,n2
=4,n3
=2
138 real, dimension(n1
,n2
,n3
) :: a
,b
,c
139 integer :: dim
, shift
, shift_lim
140 call random_number(a
)
145 else if (dim
== 2) then
150 do shift
=-shift_lim
, shift_lim
151 b
= eoshift(a
,shift
,dim
=dim
)
152 call eoshift_0 (a
, shift
=shift
, dim
=dim
, res
=c
)
153 if (any (b
/= c
)) then
154 print *,"dim = ", dim
, "shift = ", shift
159 call random_number(b
)
165 else if (dim
== 2) then
171 do shift
=-shift_lim
, shift_lim
172 b(1:n1
:2,:,:) = eoshift(a(1:n1
/2,:,:),shift
,dim
=dim
)
173 call eoshift_0 (a(1:n1
/2,:,:), shift
=shift
, dim
=dim
, res
=c(1:n1
:2,:,:))
174 if (any (b
/= c
)) STOP 2