@@ -7,6 +7,8 @@ program main
7
7
integer , parameter :: n = 3
8
8
integer , parameter :: m = 4
9
9
10
+ logical :: error_printed= .false.
11
+
10
12
! Allocatable coarrays
11
13
call one(- 5 , 1 )
12
14
call one(0 , 0 )
@@ -16,7 +18,11 @@ program main
16
18
! Static coarrays
17
19
call two()
18
20
call three()
19
- write (* ,* ) ' Test passed'
21
+
22
+ if (error_printed) error stop
23
+ sync all
24
+
25
+ if (this_image()==1 ) print * ,' Test passed.'
20
26
contains
21
27
subroutine one (lb1 , lb2 )
22
28
integer , value :: lb1, lb2
@@ -42,7 +48,7 @@ subroutine one(lb1, lb2)
42
48
end if
43
49
sync all
44
50
if (this_image()==1 ) then
45
- if (any (a /= c)) error stop " ARRAY = SCALAR failed in get_array_test"
51
+ if (any (a /= c)) call print_and_register( " ARRAY = SCALAR failed in get_array_test" )
46
52
endif
47
53
48
54
! Whole array: ARRAY = ARRAY
@@ -59,7 +65,7 @@ subroutine one(lb1, lb2)
59
65
print * , a
60
66
print * , c
61
67
! FIXME: Without the print lines above, it always fails. Why?
62
- error stop " ARRAY = ARRAY failed in get_array_test"
68
+ call print_and_register( " ARRAY = ARRAY failed in get_array_test" )
63
69
end if
64
70
endif
65
71
@@ -98,7 +104,7 @@ subroutine one(lb1, lb2)
98
104
print * , this_image(), ' : ' , a
99
105
print * , this_image(), ' : ' , c
100
106
! FIXME: Without the print lines above, it always fails. Why?
101
- error stop " scalar assignment failed in get_array_test"
107
+ call print_and_register( " scalar assignment failed in get_array_test" )
102
108
end if
103
109
endif
104
110
! Array sections with different ranges and pos/neg strides
@@ -130,7 +136,7 @@ subroutine one(lb1, lb2)
130
136
print * , a
131
137
print * , c
132
138
print * , a- c
133
- error stop " array sections with ranges and strides failed in get_array_test"
139
+ call print_and_register( " array sections with ranges and strides failed in get_array_test" )
134
140
endif
135
141
end if
136
142
! ARRAY = ARRAY
@@ -155,7 +161,7 @@ subroutine one(lb1, lb2)
155
161
print * , a
156
162
print * , c
157
163
print * , a- c
158
- error stop " array sections with ranges and strides failed in get_array_test"
164
+ call print_and_register( " array sections with ranges and strides failed in get_array_test" )
159
165
endif
160
166
end if
161
167
end do
@@ -189,7 +195,7 @@ subroutine two()
189
195
sync all
190
196
if (this_image() == num_images()) then
191
197
if (any (a /= caf)) &
192
- error stop " Array = scalar failed in subroutine two get_array_test"
198
+ call print_and_register( " Array = scalar failed in subroutine two get_array_test" )
193
199
end if
194
200
195
201
! Whole array: ARRAY = ARRAY
@@ -203,7 +209,7 @@ subroutine two()
203
209
sync all
204
210
if (this_image() == num_images()) then
205
211
if (any (a /= caf)) &
206
- error stop " Array = array failed in subroutine two get_array_test"
212
+ call print_and_register( " Array = array failed in subroutine two get_array_test" )
207
213
end if
208
214
209
215
! Scalar assignment
@@ -235,7 +241,7 @@ subroutine two()
235
241
sync all
236
242
if (this_image() == num_images()) then
237
243
if (any (a /= caf)) &
238
- error stop " scalar assignment failed in subroutine two get_array_test"
244
+ call print_and_register( " scalar assignment failed in subroutine two get_array_test" )
239
245
end if
240
246
241
247
! Array sections with different ranges and pos/neg strides
@@ -280,7 +286,7 @@ subroutine two()
280
286
print * , a
281
287
print * , caf
282
288
print * , a- caf
283
- error stop " arrays with ranges and strides failed sub. two get_array_test failed"
289
+ call print_and_register( " arrays with ranges and strides failed sub. two get_array_test failed" )
284
290
endif
285
291
end if
286
292
end do
@@ -314,7 +320,7 @@ subroutine three()
314
320
sync all
315
321
if (this_image() == num_images()) then
316
322
if (any (a /= caf)) &
317
- error stop " Array = scalar subroutine three get_array_test failed"
323
+ call print_and_register( " Array = scalar subroutine three get_array_test failed" )
318
324
end if
319
325
320
326
! Whole array: ARRAY = ARRAY
@@ -328,7 +334,7 @@ subroutine three()
328
334
sync all
329
335
if (this_image() == num_images()) then
330
336
if (any (a /= caf)) &
331
- error stop " Array = array subroutine three get_array_test failed"
337
+ call print_and_register( " Array = array subroutine three get_array_test failed" )
332
338
end if
333
339
334
340
! Scalar assignment
@@ -360,7 +366,7 @@ subroutine three()
360
366
sync all
361
367
if (this_image() == num_images()) then
362
368
if (any (a /= caf)) &
363
- error stop " scalar assignment subroutine three get_array_test failed"
369
+ call print_and_register( " scalar assignment subroutine three get_array_test failed" )
364
370
end if
365
371
366
372
! Array sections with different ranges and pos/neg strides
@@ -405,7 +411,7 @@ subroutine three()
405
411
print * , a
406
412
print * , caf
407
413
print * , a- caf
408
- error stop " range stride in subroutine three get_array_test failed"
414
+ call print_and_register( " range stride in subroutine three get_array_test failed" )
409
415
endif
410
416
end if
411
417
end do
@@ -417,4 +423,12 @@ subroutine three()
417
423
end do
418
424
end do
419
425
end subroutine three
426
+
427
+ subroutine print_and_register (error_message )
428
+ use iso_fortran_env, only : error_unit
429
+ character (len=* ), intent (in ) :: error_message
430
+ write (error_unit,* ) error_message
431
+ error_printed= .true.
432
+ end subroutine
433
+
420
434
end program main
0 commit comments