3 ! This program does a correctness check for
4 ! ARRAY[idx] = SCALAR, ARRAY[idx] = ARRAY and SCALAR[idx] = SCALAR
8 integer, parameter :: n
= 3
9 integer, parameter :: m
= 4
11 ! Allocatable coarrays
21 subroutine one(lb1
, lb2
)
22 integer, value
:: lb1
, lb2
24 integer :: i_sgn1
, i_sgn2
, i
, i_e
, i_s
, j
, j_e
, j_s
25 integer, allocatable
:: caf(:,:)[:]
26 integer, allocatable
:: a(:,:), b(:,:)
28 allocate(caf(lb1
:n
+lb1
-1, lb2
:m
+lb2
-1)[*], &
29 a(lb1
:n
+lb1
-1, lb2
:m
+lb2
-1), &
30 b(lb1
:n
+lb1
-1, lb2
:m
+lb2
-1))
32 b
= reshape([(i
*33, i
= 1, size(b
))], shape(b
))
34 ! Whole array: ARRAY = SCALAR
39 if (this_image() == 1) then
40 caf(:,:)[num_images()] = b(lb1
, lb2
)
43 if (this_image() == num_images()) then
49 ! Whole array: ARRAY = ARRAY
54 if (this_image() == 1) then
55 caf(:,:)[num_images()] = b(:, :)
58 if (this_image() == num_images()) then
78 if (this_image() == 1) then
81 caf(i
,j
)[num_images()] = b(i
, j
)
86 caf(i
,j
)[num_images()] = b(i
, j
)
91 if (this_image() == num_images()) then
97 ! Array sections with different ranges and pos/neg strides
109 a(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
) = b(lb1
, lb2
)
111 if (this_image() == 1) then
112 caf(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
)[num_images()] &
120 a(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
) &
121 = b(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
)
123 if (this_image() == 1) then
124 caf(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
)[num_images()] &
125 = b(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
)
129 if (this_image() == num_images()) then
130 if (any (a
/= caf
)) then
131 print '(*(g0))', "bounds: ", lb1
,":",n
+lb1
-1,", ", &
133 print '(*(g0))', "section: ", i
,":",i_e
,":",i_s
*i_sgn1
, &
134 ", ", j
,":",j_e
,":",j_s
*i_sgn2
154 integer, parameter :: lb1
= -5, lb2
= 1
156 integer :: i_sgn1
, i_sgn2
, i
, i_e
, i_s
, j
, j_e
, j_s
157 integer, save :: caf(lb1
:n
+lb1
-1, lb2
:m
+lb2
-1)[*]
158 integer, save :: a(lb1
:n
+lb1
-1, lb2
:m
+lb2
-1)
159 integer, save :: b(lb1
:n
+lb1
-1, lb2
:m
+lb2
-1)
161 b
= reshape([(i
*33, i
= 1, size(b
))], shape(b
))
163 ! Whole array: ARRAY = SCALAR
168 if (this_image() == 1) then
169 caf(:,:)[num_images()] = b(lb1
, lb2
)
172 if (this_image() == num_images()) then
173 if (any (a
/= caf
)) &
177 ! Whole array: ARRAY = ARRAY
182 if (this_image() == 1) then
183 caf(:,:)[num_images()] = b(:, :)
186 if (this_image() == num_images()) then
187 if (any (a
/= caf
)) &
196 do i
= n
+lb1
-1, 1, -2
206 if (this_image() == 1) then
208 do i
= n
+lb1
-1, 1, -2
209 caf(i
,j
)[num_images()] = b(i
, j
)
214 caf(i
,j
)[num_images()] = b(i
, j
)
219 if (this_image() == num_images()) then
220 if (any (a
/= caf
)) &
225 ! Array sections with different ranges and pos/neg strides
237 a(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
) = b(lb1
, lb2
)
239 if (this_image() == 1) then
240 caf(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
)[num_images()] &
248 a(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
) &
249 = b(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
)
251 if (this_image() == 1) then
252 caf(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
)[num_images()] &
253 = b(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
)
257 if (this_image() == num_images()) then
258 if (any (a
/= caf
)) then
259 print '(*(g0))', "bounds: ", lb1
,":",n
+lb1
-1,", ", &
261 print '(*(g0))', "section: ", i
,":",i_e
,":",i_s
*i_sgn1
, &
262 ", ", j
,":",j_e
,":",j_s
*i_sgn2
282 integer, parameter :: lb1
= 0, lb2
= 0
284 integer :: i_sgn1
, i_sgn2
, i
, i_e
, i_s
, j
, j_e
, j_s
285 integer, save :: caf(lb1
:n
+lb1
-1, lb2
:m
+lb2
-1)[*]
286 integer, save :: a(lb1
:n
+lb1
-1, lb2
:m
+lb2
-1)
287 integer, save :: b(lb1
:n
+lb1
-1, lb2
:m
+lb2
-1)
289 b
= reshape([(i
*33, i
= 1, size(b
))], shape(b
))
291 ! Whole array: ARRAY = SCALAR
296 if (this_image() == 1) then
297 caf(:,:)[num_images()] = b(lb1
, lb2
)
300 if (this_image() == num_images()) then
301 if (any (a
/= caf
)) &
305 ! Whole array: ARRAY = ARRAY
310 if (this_image() == 1) then
311 caf(:,:)[num_images()] = b(:, :)
314 if (this_image() == num_images()) then
315 if (any (a
/= caf
)) &
324 do i
= n
+lb1
-1, 1, -2
334 if (this_image() == 1) then
336 do i
= n
+lb1
-1, 1, -2
337 caf(i
,j
)[num_images()] = b(i
, j
)
342 caf(i
,j
)[num_images()] = b(i
, j
)
347 if (this_image() == num_images()) then
348 if (any (a
/= caf
)) &
352 ! Array sections with different ranges and pos/neg strides
364 a(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
) = b(lb1
, lb2
)
366 if (this_image() == 1) then
367 caf(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
)[num_images()] &
375 a(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
) &
376 = b(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
)
378 if (this_image() == 1) then
379 caf(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
)[num_images()] &
380 = b(i
:i_e
:i_s
*i_sgn1
, j
:j_e
:j_s
*i_sgn2
)
384 if (this_image() == num_images()) then
385 if (any (a
/= caf
)) then
386 print '(*(g0))', "bounds: ", lb1
,":",n
+lb1
-1,", ", &
388 print '(*(g0))', "section: ", i
,":",i_e
,":",i_s
*i_sgn1
, &
389 ", ", j
,":",j_e
,":",j_s
*i_sgn2