Skip to content

Commit 2a58100

Browse files
committed
Merge branch 'issue-422-implement-by-refs' of github.com:sourceryinstitute/OpenCoarrays into issue-422-implement-by-refs
2 parents fa6a9fb + 633f251 commit 2a58100

File tree

9 files changed

+483
-272
lines changed

9 files changed

+483
-272
lines changed

prerequisites/acceptable_compiler.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@
3535
program main
3636
use iso_fortran_env, only : compiler_version
3737
implicit none
38-
print *,(compiler_version() >= "GCC version 6.1.0 ") .and. (compiler_version() < "GCC version 7.0.0 ")
38+
print *,(compiler_version() >= "GCC version 6.1.0 ")
3939
end program

prerequisites/install-functions/find_or_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ find_or_install()
173173

174174
else
175175

176-
info "$this_script: Checking whether $executable in PATH wraps gfortran version >= $(./build.sh -V gcc) and < 7.0.0 ... "
176+
info "$this_script: Checking whether $executable in PATH wraps gfortran version >= $(./build.sh -V gcc)... "
177177
$executable acceptable_compiler.f90 -o acceptable_compiler || true;
178178
$executable print_true.f90 -o print_true || true;
179179
if [[ -f ./acceptable_compiler && -f ./print_true ]]; then

src/tests/unit/send-get/get_array_test.f90

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ program main
77
integer, parameter :: n = 3
88
integer, parameter :: m = 4
99

10+
logical :: error_printed=.false.
11+
1012
! Allocatable coarrays
1113
call one(-5, 1)
1214
call one(0, 0)
@@ -16,7 +18,11 @@ program main
1618
! Static coarrays
1719
call two()
1820
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.'
2026
contains
2127
subroutine one(lb1, lb2)
2228
integer, value :: lb1, lb2
@@ -42,7 +48,7 @@ subroutine one(lb1, lb2)
4248
end if
4349
sync all
4450
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")
4652
endif
4753

4854
! Whole array: ARRAY = ARRAY
@@ -59,7 +65,7 @@ subroutine one(lb1, lb2)
5965
print *, a
6066
print *, c
6167
! 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")
6369
end if
6470
endif
6571

@@ -98,7 +104,7 @@ subroutine one(lb1, lb2)
98104
print *, this_image(), ': ', a
99105
print *, this_image(), ': ', c
100106
! 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")
102108
end if
103109
endif
104110
! Array sections with different ranges and pos/neg strides
@@ -130,7 +136,7 @@ subroutine one(lb1, lb2)
130136
print *, a
131137
print *, c
132138
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")
134140
endif
135141
end if
136142
! ARRAY = ARRAY
@@ -155,7 +161,7 @@ subroutine one(lb1, lb2)
155161
print *, a
156162
print *, c
157163
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")
159165
endif
160166
end if
161167
end do
@@ -189,7 +195,7 @@ subroutine two()
189195
sync all
190196
if (this_image() == num_images()) then
191197
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")
193199
end if
194200

195201
! Whole array: ARRAY = ARRAY
@@ -203,7 +209,7 @@ subroutine two()
203209
sync all
204210
if (this_image() == num_images()) then
205211
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")
207213
end if
208214

209215
! Scalar assignment
@@ -235,7 +241,7 @@ subroutine two()
235241
sync all
236242
if (this_image() == num_images()) then
237243
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")
239245
end if
240246

241247
! Array sections with different ranges and pos/neg strides
@@ -280,7 +286,7 @@ subroutine two()
280286
print *, a
281287
print *, caf
282288
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")
284290
endif
285291
end if
286292
end do
@@ -314,7 +320,7 @@ subroutine three()
314320
sync all
315321
if (this_image() == num_images()) then
316322
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")
318324
end if
319325

320326
! Whole array: ARRAY = ARRAY
@@ -328,7 +334,7 @@ subroutine three()
328334
sync all
329335
if (this_image() == num_images()) then
330336
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")
332338
end if
333339

334340
! Scalar assignment
@@ -360,7 +366,7 @@ subroutine three()
360366
sync all
361367
if (this_image() == num_images()) then
362368
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")
364370
end if
365371

366372
! Array sections with different ranges and pos/neg strides
@@ -405,7 +411,7 @@ subroutine three()
405411
print *, a
406412
print *, caf
407413
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")
409415
endif
410416
end if
411417
end do
@@ -417,4 +423,12 @@ subroutine three()
417423
end do
418424
end do
419425
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+
420434
end program main

src/tests/unit/send-get/get_convert_char_array.f90

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
!!
55
!! FOO = BAR [N]
66
!!
7-
!! where
7+
!! where
88
!!
99
!! FOO BAR images
1010
!! character(len=20) character(len=10) N == me
@@ -41,6 +41,7 @@ program get_convert_char_array
4141
character(kind=1, len=5) :: str_k1_arr(1:4)
4242
character(kind=4, len=5), codimension[*] :: co_str_k4_arr(1:4)
4343
character(kind=4, len=5) :: str_k4_arr(1:4)
44+
logical :: error_printed=.false.
4445

4546
associate(me => this_image(), np => num_images())
4647
if (np < 2) error stop 'Can not run with less than 2 images.'
@@ -55,80 +56,103 @@ program get_convert_char_array
5556
if (me == 1) then
5657
str_k1_scal = co_str_k1_scal[1]
5758
print *, '#' // str_k1_scal // '#, len:', len(str_k1_scal)
58-
if (co_str_k1_scal /= str_k1_scal // ' ') error stop 'get scalar kind=1 to kind=1 self failed.'
59+
if (co_str_k1_scal /= str_k1_scal // ' ') call print_and_register( 'get scalar kind=1 to kind=1 self failed.')
5960

6061
str_k4_scal = co_str_k4_scal[1]
6162
print *, 4_'#' // str_k4_scal // 4_'#, len:', len(str_k4_scal)
62-
if (co_str_k4_scal /= str_k4_scal // 4_' ') error stop 'get scalar kind=4 to kind=4 self failed.'
63+
if (co_str_k4_scal /= str_k4_scal // 4_' ') call print_and_register( 'get scalar kind=4 to kind=4 self failed.')
6364

6465
str_k4_scal = co_str_k1_scal[1]
6566
print *, 4_'#' // str_k4_scal // 4_'#, len:', len(str_k4_scal)
66-
if (co_str_k4_scal /= str_k4_scal // 4_' ') error stop 'get scalar kind=1 to kind=4 self failed.'
67+
if (co_str_k4_scal /= str_k4_scal // 4_' ') call print_and_register( 'get scalar kind=1 to kind=4 self failed.')
6768

6869
str_k1_scal = co_str_k4_scal[1]
6970
print *, '#' // str_k1_scal // '#, len:', len(str_k1_scal)
70-
if (co_str_k1_scal /= str_k1_scal // ' ') error stop 'get scalar kind=4 to kind=1 self failed.'
71+
if (co_str_k1_scal /= str_k1_scal // ' ') call print_and_register( 'get scalar kind=4 to kind=1 self failed.')
7172
end if
7273

7374
! Do the same for arrays but on image 2
7475
if (me == 2) then
7576
str_k1_arr(:) = co_str_k1_arr(:)[2]
7677
print *, '#' // str_k1_arr(:) // '#, len:', len(str_k1_arr(1))
77-
if (any(str_k1_arr /= ['abc ', 'EFG ', 'klm ', 'NOP '])) error stop 'get array kind=1 to kind=1 self failed.'
78-
79-
print *, str_k4_arr
78+
if (any(str_k1_arr /= ['abc ', 'EFG ', 'klm ', 'NOP '])) &
79+
call print_and_register( 'get array kind=1 to kind=1 self failed.')
80+
81+
print *, str_k4_arr
8082
str_k4_arr(:) = co_str_k4_arr(:)[2]
8183
print *, 4_'#' // str_k4_arr(:) // 4_'#, len:', len(str_k4_arr(1))
82-
if (any(str_k4_arr /= [4_'abc ', 4_'EFG ', 4_'klm ', 4_'NOP '])) error stop 'get array kind=4 to kind=4 self failed.'
84+
if (any(str_k4_arr /= [4_'abc ', 4_'EFG ', 4_'klm ', 4_'NOP '])) &
85+
call print_and_register( 'get array kind=4 to kind=4 self failed.')
8386

8487
str_k4_arr(:) = co_str_k1_arr(:)[2]
8588
print *, 4_'#' // str_k4_arr(:) // 4_'#, len:', len(str_k4_arr(1))
86-
if (any(str_k4_arr /= [ 4_'abc ', 4_'EFG ', 4_'klm ', 4_'NOP '])) error stop 'get array kind=1 to kind=4 self failed.'
89+
if (any(str_k4_arr /= [ 4_'abc ', 4_'EFG ', 4_'klm ', 4_'NOP '])) &
90+
call print_and_register( 'get array kind=1 to kind=4 self failed.')
8791

8892
str_k1_arr(:) = co_str_k4_arr(:)[2]
8993
print *, '#' // str_k1_arr(:) // '#, len:', len(str_k1_arr(1))
90-
if (any(str_k1_arr /= ['abc ', 'EFG ', 'klm ', 'NOP '])) error stop 'get array kind=4 to kind=1 self failed.'
94+
if (any(str_k1_arr /= ['abc ', 'EFG ', 'klm ', 'NOP '])) &
95+
call print_and_register( 'get array kind=4 to kind=1 self failed.')
9196
end if
9297

9398
sync all
9499
if (me == 1) then
95100
str_k1_scal = co_str_k1_scal[2]
96101
print *, '#' // str_k1_scal // '#, len:', len(str_k1_scal)
97-
if (co_str_k1_scal /= str_k1_scal // ' ') error stop 'get kind=1 to kind=1 image 2 failed.'
102+
if (co_str_k1_scal /= str_k1_scal // ' ') call print_and_register( 'get kind=1 to kind=1 image 2 failed.')
98103

99104
str_k4_scal = co_str_k4_scal[2]
100105
print *, 4_'#' // str_k4_scal // 4_'#, len:', len(str_k4_scal)
101-
if (co_str_k4_scal /= str_k4_scal // 4_' ') error stop 'get kind=4 to kind=4 image 2 failed.'
106+
if (co_str_k4_scal /= str_k4_scal // 4_' ') call print_and_register( 'get kind=4 to kind=4 image 2 failed.')
102107
else if (me == 2) then
103108
str_k4_scal = co_str_k1_scal[1]
104109
print *, 4_'#' // str_k4_scal // 4_'#, len:', len(str_k4_scal)
105-
if (co_str_k4_scal /= str_k4_scal // 4_' ') error stop 'get kind=1 to kind=4 from image 1 failed.'
110+
if (co_str_k4_scal /= str_k4_scal // 4_' ') call print_and_register( 'get kind=1 to kind=4 from image 1 failed.')
106111

107112
str_k1_scal = co_str_k4_scal[1]
108113
print *, '#' // str_k1_scal // '#, len:', len(str_k1_scal)
109-
if (co_str_k1_scal /= str_k1_scal // ' ') error stop 'get kind=4 to kind=1 from image 1 failed.'
114+
if (co_str_k1_scal /= str_k1_scal // ' ') call print_and_register( 'get kind=4 to kind=1 from image 1 failed.')
110115
end if
111116

112117
str_k1_arr(:) = '#####'
113118
str_k4_arr(:) = 4_'#####'
114-
119+
115120
sync all
116121

117122
if (me == 1) then
118123
str_k1_arr(1:2) = co_str_k1_arr(::2)[2]
119124
print *, str_k1_arr
120125
if (any(str_k1_arr /= ['abc ', 'klm ', '#####', '#####'])) &
121-
& error stop "strided get char arr kind 1 to kind 1 failed."
126+
& call print_and_register( "strided get char arr kind 1 to kind 1 failed.")
122127

123128
str_k4_arr(1:2) = co_str_k4_arr(::2)[2]
124129
print *, str_k4_arr
125130
if (any(str_k4_arr /= [4_'abc ', 4_'klm ', 4_'#####', 4_'#####'] )) &
126-
& error stop "strided get char arr kind 4 to kind 4 failed."
131+
& call print_and_register( "strided get char arr kind 4 to kind 4 failed.")
127132
end if
128133

129-
sync all
130-
if (me == 1) print *, 'Test passed.'
134+
select case(me)
135+
case(1)
136+
if (error_printed) error stop
137+
sync images(2)
138+
print *, 'Test passed.'
139+
case(2)
140+
if (error_printed) error stop
141+
sync images(1)
142+
end select
143+
131144
end associate
145+
146+
contains
147+
148+
subroutine print_and_register(error_message)
149+
use iso_fortran_env, only : error_unit
150+
character(len=*), intent(in) :: error_message
151+
write(error_unit,*) error_message
152+
error_printed=.true.
153+
end subroutine
154+
132155
end program get_convert_char_array
133156

134157
! vim:ts=2:sts=2:sw=2:
158+

0 commit comments

Comments
 (0)