From 89d2babd0580937ff8952c321fb478705236d8c0 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Tue, 17 Dec 2024 16:35:09 -0600 Subject: [PATCH] fix: collective tests --- test/caf_co_max_test.f90 | 7 +++---- test/caf_co_min_test.f90 | 5 ++--- test/caf_co_reduce_test.f90 | 17 ++++++----------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/test/caf_co_max_test.f90 b/test/caf_co_max_test.f90 index cd43ef8e..506eac27 100644 --- a/test/caf_co_max_test.f90 +++ b/test/caf_co_max_test.f90 @@ -124,8 +124,8 @@ function max_elements_in_2D_string_arrays() result(result_) function reverse_alphabetize_default_character_scalars() result(result_) type(result_t) result_ integer, parameter :: length = len("loddy") - character(len=length), parameter :: words(*) = [character(len=length):: "loddy","doddy","we","like","to","party"] - character(len=:), allocatable :: my_word, expected_word + character(len=*), parameter :: words(*) = [character(len=length):: "loddy","doddy","we","like","to","party"] + character(len=len(words)) :: my_word, expected_word integer :: me, num_imgs call prif_this_image_no_coarray(this_image=me) @@ -135,8 +135,7 @@ function reverse_alphabetize_default_character_scalars() result(result_) end associate call prif_num_images(num_imgs) - !expected_word = maxval(words(1:min(num_imgs, size(words)))) ! this line crashes flang - expected_word = "we" + expected_word = maxval(words(1:min(num_imgs, size(words))), dim=1) result_ = assert_equals(expected_word, my_word) end function diff --git a/test/caf_co_min_test.f90 b/test/caf_co_min_test.f90 index 6784eed2..99753064 100644 --- a/test/caf_co_min_test.f90 +++ b/test/caf_co_min_test.f90 @@ -127,7 +127,7 @@ function alphabetically_1st_scalar_string() result(result_) type(result_t) result_ integer, parameter :: length = len("to party!") character(len=length), parameter :: words(*) = [character(len=length):: "Loddy","doddy","we","like","to party!"] - character(len=:), allocatable :: my_word, expected_word + character(len=length) :: my_word, expected_word integer :: me, num_imgs call prif_this_image_no_coarray(this_image=me) @@ -137,8 +137,7 @@ function alphabetically_1st_scalar_string() result(result_) end associate call prif_num_images(num_images=num_imgs) - ! expected_word = minval(words(1:min(num_imgs, size(words)))) ! this line exposes a flang bug - expected_word = "Loddy" + expected_word = minval(words(1:min(num_imgs, size(words))), dim=1) result_ = assert_equals(expected_word, my_word) end function diff --git a/test/caf_co_reduce_test.f90 b/test/caf_co_reduce_test.f90 index 4f04ed91..96e66969 100644 --- a/test/caf_co_reduce_test.f90 +++ b/test/caf_co_reduce_test.f90 @@ -29,31 +29,26 @@ function test_prif_co_reduce() result(tests) function alphabetically_1st_size1_string_array() result(result_) type(result_t) result_ character(len=*, kind=c_char), parameter :: names(*) = ["larry","harry","carey","betty","tommy","billy"] - character(len=:, kind=c_char), allocatable :: my_name(:) - character(len=:), allocatable :: expected_name + character(len=len(names), kind=c_char) :: my_name(1) + character(len=len(names)) :: expected_name integer :: me, num_imgs call prif_this_image_no_coarray(this_image=me) associate(periodic_index => 1 + mod(me-1,size(names))) - my_name = [names(periodic_index)] + my_name(1) = names(periodic_index) call prif_co_reduce(my_name, c_funloc(alphabetize)) end associate call prif_num_images(num_images=num_imgs) - !expected_name = minval(names(1:min(num_imgs, size(names)))) ! this exposes a flang bug - expected_name = "betty" + expected_name = minval(names(1:min(num_imgs, size(names))), dim=1) result_ = assert_that(all(expected_name == my_name)) contains function alphabetize(lhs, rhs) result(first_alphabetically) - character(len=*), intent(in) :: lhs, rhs - character(len=:), allocatable :: first_alphabetically + character(len=len(names)), intent(in) :: lhs, rhs + character(len=len(names)) :: first_alphabetically - if (len(lhs).ne.len(rhs)) then - call prif_error_stop(quiet=.false._c_bool, & - stop_code_char="co_reduce_s alphabetize: LHS(" // lhs // ")/RHS(" // rhs // ") length don't match") - end if first_alphabetically = min(lhs,rhs) end function