diff --git a/install.sh b/install.sh index 169ab23b..86afc0e4 100755 --- a/install.sh +++ b/install.sh @@ -344,13 +344,15 @@ echo "Version: 0.1.0" >> $CAFFEINE_P exit_if_pkg_config_pc_file_missing "caffeine" RUN_FPM_SH="build/run-fpm.sh" -echo "#!/bin/sh" > $RUN_FPM_SH -echo "#-- DO NOT EDIT -- created by caffeine/install.sh" >> $RUN_FPM_SH -echo "\"${FPM}\" \"\$@\" \\" >> $RUN_FPM_SH -echo "--compiler \"`$PKG_CONFIG caffeine --variable=CAFFEINE_FPM_FC`\" \\" >> $RUN_FPM_SH -echo "--c-compiler \"`$PKG_CONFIG caffeine --variable=CAFFEINE_FPM_CC`\" \\" >> $RUN_FPM_SH -echo "--c-flag \"`$PKG_CONFIG caffeine --variable=CAFFEINE_FPM_CFLAGS`\" \\" >> $RUN_FPM_SH -echo "--link-flag \"`$PKG_CONFIG caffeine --variable=CAFFEINE_FPM_LDFLAGS`\"" >> $RUN_FPM_SH +echo "#!/bin/sh" > $RUN_FPM_SH +echo "#-- DO NOT EDIT -- created by caffeine/install.sh" >> $RUN_FPM_SH +echo "fpm_sub_cmd=\$1; shift" >> $RUN_FPM_SH +echo "\"${FPM}\" \"\$fpm_sub_cmd\" \\" >> $RUN_FPM_SH +echo "--compiler \"`$PKG_CONFIG caffeine --variable=CAFFEINE_FPM_FC`\" \\" >> $RUN_FPM_SH +echo "--c-compiler \"`$PKG_CONFIG caffeine --variable=CAFFEINE_FPM_CC`\" \\" >> $RUN_FPM_SH +echo "--c-flag \"`$PKG_CONFIG caffeine --variable=CAFFEINE_FPM_CFLAGS`\" \\" >> $RUN_FPM_SH +echo "--link-flag \"`$PKG_CONFIG caffeine --variable=CAFFEINE_FPM_LDFLAGS`\" \\" >> $RUN_FPM_SH +echo "\"\$@\"" >> $RUN_FPM_SH chmod u+x $RUN_FPM_SH ./$RUN_FPM_SH build diff --git a/manifest/fpm.toml.template b/manifest/fpm.toml.template index ea6736ad..be629a6c 100644 --- a/manifest/fpm.toml.template +++ b/manifest/fpm.toml.template @@ -6,7 +6,7 @@ maintainer = "rouson@lbl.gov" copyright = "2021-2022 UC Regents" [dev-dependencies] -veggies = {git = "https://gitlab.com/everythingfunctional/veggies", tag = "v1.0.5"} +veggies = {git = "https://gitlab.com/everythingfunctional/veggies", tag = "v1.1.0"} iso_varying_string = {git = "https://gitlab.com/everythingfunctional/iso_varying_string.git", tag = "v3.0.4"} [build] diff --git a/test/caf_co_broadcast_test.f90 b/test/caf_co_broadcast_test.f90 index ab7465d5..1097af34 100644 --- a/test/caf_co_broadcast_test.f90 +++ b/test/caf_co_broadcast_test.f90 @@ -15,7 +15,12 @@ module caf_co_broadcast_test interface operator(==) module procedure equals + module procedure equals_with_allocatable end interface + + type with_allocatable + integer, allocatable :: i + end type contains @@ -26,6 +31,7 @@ function test_prif_co_broadcast() result(tests) "The prif_co_broadcast subroutine", & [ it("broadcasts a default integer scalar with no optional arguments present", broadcast_default_integer_scalar) & ,it("broadcasts a derived type scalar with no allocatable components", broadcast_derived_type) & + , it("broadcasts a derived type with an allocatable component", broadcast_with_allocatable) & ]) end function @@ -38,6 +44,19 @@ logical pure function equals(lhs, rhs) ,lhs%issues == rhs%issues & ]) end function + + logical pure function equals_with_allocatable(lhs, rhs) + type(with_allocatable), intent(in) :: lhs, rhs + if (allocated(lhs%i)) then + if (allocated(rhs%i)) then + equals_with_allocatable = lhs%i == rhs%i + else + equals_with_allocatable = .false. + end if + else + equals_with_allocatable = .not.allocated(rhs%i) + end if + end function function broadcast_default_integer_scalar() result(result_) type(result_t) result_ @@ -64,5 +83,19 @@ function broadcast_derived_type() result(result_) end associate end function + + function broadcast_with_allocatable() result(result_) + type(result_t) :: result_ + + integer, parameter :: expected_val = 42 + integer :: me + type(with_allocatable) :: obj, expected + + expected%i = expected_val + call prif_this_image(image_index=me) + if (me == 1) obj%i = expected_val + call prif_co_broadcast(obj, source_image=1) + result_ = assert_that(expected == obj, "co_broadcast with allocatable component") + end function end module caf_co_broadcast_test diff --git a/test/caf_co_reduce_test.f90 b/test/caf_co_reduce_test.f90 index 31909d5f..e58c50de 100644 --- a/test/caf_co_reduce_test.f90 +++ b/test/caf_co_reduce_test.f90 @@ -8,6 +8,9 @@ module caf_co_reduce_test private public :: test_prif_co_reduce + type my_int + integer :: val + end type contains function test_prif_co_reduce() result(tests) @@ -24,6 +27,7 @@ function test_prif_co_reduce() result(tests) ,it("sums default complex scalars with a stat-variable present", sum_default_complex_scalars) & ,it("sums complex(c_double) scalars with a stat-variable present", sum_complex_c_double_scalars) & ,it("sums default integer elements of a 2D array across images", sum_integer_array_elements) & + ,it("can reduce derived types", sum_derived_types) & ]) end function @@ -247,4 +251,23 @@ pure function multiply(lhs, rhs) result(product_) end function end function + + pure function add_my_ints(lhs, rhs) result(sum_) + type(my_int), intent(in) :: lhs, rhs + type(my_int) :: sum_ + + sum_%val = lhs%val + rhs%val + end function + + function sum_derived_types() result(result_) + type(result_t) :: result_ + + type(my_int) :: var + integer :: num_imgs, i + + call prif_this_image(image_index=var%val) + call prif_num_images(image_count=num_imgs) + call prif_co_reduce(var, c_funloc(add_my_ints)) + result_ = assert_equals(sum([(i, i = 1, num_imgs)]), var%val) + end function end module caf_co_reduce_test