2 ! Check that eoshift works for three-dimensional arrays.
6 subroutine eoshift_2 (array
, shift
, boundary
, dim
, res
)
7 real, dimension(:,:,:), intent(in
) :: array
8 real, dimension(:,:,:), intent(out
) :: res
9 integer, value
:: shift
10 real, optional
, dimension(:,:), intent(in
) :: boundary
11 integer, optional
, intent(in
) :: dim
18 if (present(dim
)) then
31 shift
= min(shift
, n1
)
36 res(s1
,s2
,s3
) = array(s1
+shift
,s2
,s3
)
38 do s1
= n1
- shift
+ 1,n1
45 shift
= max(shift
, -n1
)
53 res(s1
,s2
,s3
) = array(s1
+shift
,s2
,s3
)
61 shift
= min(shift
, n2
)
65 res(s1
,s2
,s3
) = array(s1
,s2
+shift
,s3
)
68 do s2
=n2
- shift
+ 1, n2
76 shift
= max(shift
, -n2
)
86 res(s1
,s2
,s3
) = array(s1
,s2
+shift
,s3
)
94 shift
= min(shift
, n3
)
98 res(s1
,s2
,s3
) = array(s1
,s2
,s3
+shift
)
102 do s3
=n3
- shift
+ 1, n3
111 shift
= max(shift
, -n3
)
123 res(s1
,s2
,s3
) = array(s1
,s2
,s3
+shift
)
132 end subroutine eoshift_2
138 integer, parameter :: n1
=20,n2
=30,n3
=40
139 real, dimension(n1
,n2
,n3
) :: a
,b
,c
140 real, dimension(2*n1
,n2
,n3
) :: a2
,c2
141 integer :: dim
, shift
, shift_lim
142 real, dimension(n2
,n3
), target
:: b1
143 real, dimension(n1
,n3
), target
:: b2
144 real, dimension(n1
,n2
), target
:: b3
145 real, dimension(:,:), pointer :: bp
147 call random_number(a
)
148 call random_number (b1
)
149 call random_number (b2
)
150 call random_number (b3
)
155 else if (dim
== 2) then
162 do shift
=-shift_lim
, shift_lim
163 b
= eoshift(a
,shift
,dim
=dim
, boundary
=bp
)
164 call eoshift_2 (a
, shift
=shift
, dim
=dim
, boundary
=bp
, res
=c
)
165 if (any (b
/= c
)) then
166 print *,"dim = ", dim
, "shift = ", shift
173 b
= eoshift(a2(1:2*n1
:2,:,:), shift
, dim
=dim
, boundary
=bp
)
174 if (any (b
/= c
)) then
178 c2(1:2*n1
:2,:,:) = eoshift(a
,shift
,dim
=dim
, boundary
=bp
)
179 if (any(c2(1:2*n1
:2,:,:) /= c
)) then
182 if (any(c2(2:2*n1
:2,:,:) /= 43)) then