2 ! Test CSHIFT with array argument for shift
7 integer, intent(out
), dimension(:,:) :: a
8 integer, intent(in
) :: n
9 real, dimension(size(a
,1),size(a
,2)) :: r
18 subroutine emul_cshift(a
,sh_in
,dim
, c
)
19 integer, dimension(:,:,:), intent(in
) :: a
20 integer, dimension(:,:,:), intent(out
) :: c
21 integer, dimension(:,:), intent(in
) :: sh_in
22 integer, intent(in
) :: dim
24 integer :: s1
, s2
, s3
, n
, i
33 sh
= modulo(sh_in(s2
,s3
), n
)
36 c(i
,s2
,s3
) = a(i
+sh
,s2
,s3
)
39 c(i
,s2
,s3
) = a(i
-rsh
,s2
,s3
)
43 else if (dim
== 2) then
47 sh
= modulo(sh_in(s1
,s3
),n
)
50 c(s1
,i
,s3
) = a(s1
,i
+sh
,s3
)
53 c(s1
,i
,s3
) = a(s1
,i
-rsh
,s3
)
58 else if (dim
== 3) then
62 sh
= modulo(sh_in(s1
,s2
),n
)
65 c(s1
,s2
,i
) = a(s1
,s2
,i
+sh
)
68 c(s1
,s2
,i
) = a(s1
,s2
,i
-rsh
)
75 end subroutine emul_cshift
81 integer, parameter :: n1
=30,n2
=40,n3
=50
82 integer, dimension(n1
,n2
,n3
) :: a
, b
,c
85 integer, dimension(:,:), allocatable
:: sh1
, sh2
, sh3
86 integer, dimension(:), allocatable
:: sh_shift
92 type(t
), dimension(n1
,n2
,n3
) :: ta
, tb
116 call emul_cshift(a
,sh1
,1,c
)
117 if (any(b
/= c
)) then
122 tb
= cshift(ta
,sh1
,1)
123 if (any(tb
%i1
/= c
)) call abort
126 call emul_cshift(a
,sh2
,2,c
)
127 if (any(b
/= c
)) call abort
128 tb
= cshift(ta
,sh2
,2)
129 if (any (tb
%i2
/= c
*2)) call abort
132 call emul_cshift(a
,sh3
,3,c
)
133 if (any(b
/= c
)) call abort
134 tb
= cshift(ta
,sh3
,3)
135 if (any(tb
%i3
/= c
*3)) call abort
139 b(1:n1
:2,:,:) = cshift(a(1:n1
/2,:,:),sh1
,1)
140 call emul_cshift(a(1:n1
/2,:,:), sh1
, 1, c(1:n1
:2,:,:))
141 if (any(b
/= c
)) call abort
146 tb(1:n1
:2,:,:) = cshift(ta(1:n1
/2,:,:),sh1
,1)
147 if (any(tb
%i1
/= b
)) call abort
148 if (any(tb
%i2
/= 2*b
)) call abort
149 if (any(tb
%i3
/= 3*b
)) call abort
151 9000 format (99(3(I3
,1X
),2X
))