11module collective_subroutines_test
2- use Vegetables, only: Result_t, Test_Item_t, describe, it, succeed, assert_equals, assert_that, assert_not
3- use emulated_intrinsics_interface, only : co_sum, co_all
2+ use Vegetables, only: Result_t, Test_Item_t, describe, it, assert_equals, assert_that, assert_not
3+ use emulated_intrinsics_interface, only : &
4+ #ifdef COMPILER_LACKS_COLLECTIVE_SUBROUTINES
5+ co_all, co_sum
6+ #else
7+ co_all
8+ #endif
49
510 implicit none
611 private
712
8- public :: test_co_sum, test_co_all
9- contains
10- function test_co_sum () result(tests)
11- type (Test_Item_t) :: tests
13+ public :: test_co_all
14+ public :: test_co_sum
1215
13- tests = describe( &
14- " co_sum" , &
15- [it( &
16- " gives sums with result_image present" , &
17- check_co_sum_with_result_image), &
18- it( &
19- " gives sums without result_image present" , &
20- check_co_sum_without_result_image)])
21- end function
16+ contains
2217
2318 function test_co_all () result(tests)
2419 type (Test_Item_t) :: tests
@@ -33,6 +28,38 @@ function test_co_all() result(tests)
3328 check_co_all_with_one_false)])
3429 end function
3530
31+ function check_co_all_with_all_true () result(result_)
32+ type (Result_t) :: result_
33+ logical all_true
34+
35+ all_true= .true.
36+
37+ call co_all(all_true)
38+ result_ = assert_that(all_true, " co_all argument remains .true. after call with all arguments .true." )
39+ end function
40+
41+ function check_co_all_with_one_false () result(result_)
42+ type (Result_t) :: result_
43+ logical all_true
44+
45+ all_true = merge (.false. , .true. , this_image()==1 )
46+ call co_all(all_true)
47+ result_ = assert_not(all_true, " co_all argument is .false. after call with one argument .false." )
48+ end function
49+
50+ function test_co_sum () result(tests)
51+ type (Test_Item_t) :: tests
52+
53+ tests = describe( &
54+ " co_sum" , &
55+ [it( &
56+ " gives sums with result_image present" , &
57+ check_co_sum_with_result_image), &
58+ it( &
59+ " gives sums without result_image present" , &
60+ check_co_sum_without_result_image)])
61+ end function
62+
3663 function check_co_sum_with_result_image () result(result_)
3764 type (Result_t) :: result_
3865
@@ -63,23 +90,4 @@ function check_co_sum_without_result_image() result(result_)
6390 end associate
6491 end function
6592
66- function check_co_all_with_all_true () result(result_)
67- type (Result_t) :: result_
68- logical all_true
69-
70- all_true= .true.
71-
72- call co_all(all_true)
73- result_ = assert_that(all_true, " co_all argument remains .true. after call with all arguments true" )
74- end function
75-
76- function check_co_all_with_one_false () result(result_)
77- type (Result_t) :: result_
78- logical all_true
79-
80- all_true = merge (.false. , .true. , this_image()==1 )
81- call co_all(all_true)
82- result_ = assert_not(all_true, " co_all argument is .false. after call with one argument false" )
83- end function
84-
8593end module
0 commit comments