From ffe42ef008ff40584489fc84c8aba345069ce63e Mon Sep 17 00:00:00 2001 From: Damian Rouson Date: Fri, 17 Jul 2026 13:30:25 -0700 Subject: [PATCH 1/3] chore(fpm.toml): update to Julienne 4.1.0 --- demo/fpm.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/fpm.toml b/demo/fpm.toml index 10a9fd64d..a1484e112 100644 --- a/demo/fpm.toml +++ b/demo/fpm.toml @@ -1,6 +1,6 @@ name = "Fiats-Demonstration-Applications" [dependencies] -julienne = {git = "https://github.com/berkeleylab/julienne", tag = "3.6.1"} +julienne = {git = "https://github.com/berkeleylab/julienne", tag = "4.1.0"} fiats = {path = "../"} netcdf-interfaces = {git = "https://github.com/berkeleylab/netcdf-interfaces.git", rev = "d2bbb71ac52b4e346b62572b1ca1620134481096"} From 993ea36a9349064491eef0d6524abf7e9f65f2d2 Mon Sep 17 00:00:00 2001 From: Damian Rouson Date: Fri, 17 Jul 2026 13:33:15 -0700 Subject: [PATCH 2/3] test(occupancy_t): add passing unit test --- demo/src/phase_space_bin_m.f90 | 11 ++++ demo/test/driver.f90 | 4 +- demo/test/occupancy_test_m.f90 | 115 +++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 demo/test/occupancy_test_m.f90 diff --git a/demo/src/phase_space_bin_m.f90 b/demo/src/phase_space_bin_m.f90 index 1e164fea1..7fd8e362e 100644 --- a/demo/src/phase_space_bin_m.f90 +++ b/demo/src/phase_space_bin_m.f90 @@ -1,6 +1,14 @@ ! Copyright (c), The Regents of the University of California ! Terms of use are as specified in LICENSE.txt + +#include "julienne-assert-macros.h" + module phase_space_bin_m + use julienne_m, only : & + call_julienne_assert_ & + ,operator(.all.) & + ,operator(.greaterThan.) & + ,operator(.isAtLeast.) use tensor_map_m, only : tensor_map_t use tensor_m, only : tensor_t implicit none @@ -33,6 +41,9 @@ end module phase_space_bin_m real, parameter :: half = 0.5 + call_julienne_assert(.all. (maxima .greaterThan. minima)) + call_julienne_assert(.all. (num_bins .isAtLeast. 1)) + associate(bin_widths => (maxima - minima)/real(num_bins)) associate(tensor_values => min(tensor%values(), maxima - half*bin_widths)) phase_space_bin%loc = (tensor_values - minima)/bin_widths + 1 diff --git a/demo/test/driver.f90 b/demo/test/driver.f90 index 87f12e1a8..855c11dfb 100644 --- a/demo/test/driver.f90 +++ b/demo/test/driver.f90 @@ -6,13 +6,15 @@ program test_suite_driver use netCDF_file_test_m, only : netCDF_file_test_t use time_data_test_m, only : time_data_test_t use histogram_test_m, only : histogram_test_t + use occupancy_test_m, only : occupancy_test_t implicit none associate(test_harness => test_harness_t([ & test_fixture_t(netCDF_file_test_t()) & ,test_fixture_t(time_data_test_t()) & ,test_fixture_t(histogram_test_t()) & + ,test_fixture_t(occupancy_test_t()) & ])) call test_harness%report_results end associate -end program test_suite_driver +end program test_suite_driver \ No newline at end of file diff --git a/demo/test/occupancy_test_m.f90 b/demo/test/occupancy_test_m.f90 new file mode 100644 index 000000000..543d8501f --- /dev/null +++ b/demo/test/occupancy_test_m.f90 @@ -0,0 +1,115 @@ +! Copyright (c) 2022-2025, The Regents of the University of California and Sourcery Institute +! Terms of use are as specified in LICENSE.txt + +#include "julienne-assert-macros.h" + +module occupancy_test_m + !! Unit test for the occupancy subroutine + use iso_fortran_env, only : int64 + use julienne_m, only : & + call_julienne_assert_ & + ,operator(//) & + ,operator(.all.) & + ,operator(.also.) & + ,operator(.expect.) & + ,operator(.equalsExpected.) & + ,passing_test & + ,string_t & + ,test_t & + ,test_result_t & + ,test_description_t & + ,test_diagnosis_t + use fiats_m, only : tensor_t + use phase_space_bin_m, only : phase_space_bin_t + use occupancy_m, only : occupancy_t + implicit none + + private + public :: occupancy_test_t + + type, extends(test_t) :: occupancy_test_t + contains + procedure, nopass :: subject + procedure, nopass :: results + end type + +contains + + pure function subject() result(specimen) + character(len=:), allocatable :: specimen + specimen = "The occupancy_t type" + end function + + function results() result(test_results) + type(occupancy_test_t) occupancy_test + type(test_result_t), allocatable :: test_results(:) + + test_results = occupancy_test%run([ & + test_description_t("occupying a prescribed set of bins", check_bin_occupation) & + ]) + end function + + type(test_diagnosis_t) function check_bin_occupation() result(test_diagnosis) + + type(tensor_t), allocatable :: tensors(:) + type(occupancy_t) occupancy + real, allocatable :: components(:,:) + integer, parameter :: bins = 3 + integer(int64) i + + ! Define tensors with the depicted tensor counts in a 2D slice of a 9D bin space: +! |----|----|----| +! | | | 1 | +! |----|----|----| +! | | 3 | | +! |----|----|----| +! | 2 | | | +! |----|----|----| plus one extra tensor to extablish the ranges ofthe other components + tensors = [ & + tensor_t([ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]) & + ,tensor_t([ 1.5, 1.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]) & + + ,tensor_t([ 2.5, 2.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]) & + ,tensor_t([ 2.5, 2.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]) & + ,tensor_t([ 2.5, 2.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]) & + + ,tensor_t([ 4.0, 4.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]) & + + ,tensor_t([ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]) & + ] + + associate( & + num_tensors => size(tensors) & + ,num_components => size(tensors(1)%values()) & + ) + call_julienne_assert(.all. [( size(tensors(i)%values()), i=2,num_tensors )] .equalsExpected. num_tensors) + + allocate(components(num_tensors, num_components)) + + do concurrent(integer :: tensor = 1:num_tensors) + components(tensor,:) = tensors(tensor)%values() + end do + + associate(bin => [(phase_space_bin_t(tensors(i), minima = minval(components, dim=1), maxima = maxval(components, dim=1), num_bins = bins), i = 1, num_tensors)]) + + call occupancy%vacate(dims = [( bins, i = 1, num_components)]) + + populate_bins: & + do i = 1, size(bin) + if (occupancy%occupied(bin(i)%loc)) cycle + call occupancy%occupy(bin(i)%loc) + end do populate_bins + end associate + + test_diagnosis = passing_test() + test_diagnosis = test_diagnosis .also. ((int(occupancy%num_bins()) .equalsExpected. int(bins**num_components))) + test_diagnosis = test_diagnosis .also. ((.expect. occupancy%occupied([[1,1,1, 1,1,1, 1,1,1]]))) + test_diagnosis = test_diagnosis .also. ((.expect. occupancy%occupied([[2,2,1, 1,1,1, 1,1,1]]))) + test_diagnosis = test_diagnosis .also. ((.expect. occupancy%occupied([[3,3,1, 1,1,1, 1,1,1]]))) + test_diagnosis = test_diagnosis .also. ((.expect. occupancy%occupied([[3,3,3, 3,3,3, 3,3,3]]))) + + end associate + + end function + +end module occupancy_test_m \ No newline at end of file From 1531f073006fe91c949019c832fcf78e28d40d29 Mon Sep 17 00:00:00 2001 From: Damian Rouson Date: Fri, 17 Jul 2026 16:20:08 -0700 Subject: [PATCH 3/3] chore(preprocess): git mv occupancy_test_m.{f,F}90 --- demo/test/{occupancy_test_m.f90 => occupancy_test_m.F90} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename demo/test/{occupancy_test_m.f90 => occupancy_test_m.F90} (100%) diff --git a/demo/test/occupancy_test_m.f90 b/demo/test/occupancy_test_m.F90 similarity index 100% rename from demo/test/occupancy_test_m.f90 rename to demo/test/occupancy_test_m.F90