From ad5925e19d6d31d7ad122443dadd88eadc40e755 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 20 Feb 2026 22:20:18 -0500 Subject: [PATCH 1/2] Fix loc_violations used uninitialized in MPI_Allreduce loc_violations is never set to 0 before the conditional that may or may not assign it. Non-violating ranks sum garbage in the reduction. Co-Authored-By: Claude Opus 4.6 --- src/pre_process/m_data_output.fpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pre_process/m_data_output.fpp b/src/pre_process/m_data_output.fpp index bac4fdc038..e057234fbd 100644 --- a/src/pre_process/m_data_output.fpp +++ b/src/pre_process/m_data_output.fpp @@ -476,7 +476,7 @@ contains ! Generic loop iterators integer :: i, j, k, l - real(wp) :: loc_violations, glb_violations + real(wp) :: loc_violations = 0._wp, glb_violations ! Downsample variables integer :: m_ds, n_ds, p_ds From 1f031900f5d16f3e469dd9d4009a84df67b6a144 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 20 Feb 2026 23:48:21 -0500 Subject: [PATCH 2/2] Fix loc_violations gaining implicit SAVE attribute Initializing a local variable in its declaration gives it the SAVE attribute in Fortran, meaning it would not reset to zero on subsequent calls. Move the initialization to an executable assignment so the variable is properly zeroed each time the subroutine is entered. Co-Authored-By: Claude Sonnet 4.6 --- src/pre_process/m_data_output.fpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pre_process/m_data_output.fpp b/src/pre_process/m_data_output.fpp index e057234fbd..1311a105b7 100644 --- a/src/pre_process/m_data_output.fpp +++ b/src/pre_process/m_data_output.fpp @@ -476,13 +476,15 @@ contains ! Generic loop iterators integer :: i, j, k, l - real(wp) :: loc_violations = 0._wp, glb_violations + real(wp) :: loc_violations, glb_violations ! Downsample variables integer :: m_ds, n_ds, p_ds integer :: m_glb_ds, n_glb_ds, p_glb_ds integer :: m_glb_save, n_glb_save, p_glb_save ! Size of array being saved + loc_violations = 0._wp + if (down_sample) then if ((mod(m + 1, 3) > 0) .or. (mod(n + 1, 3) > 0) .or. (mod(p + 1, 3) > 0)) then loc_violations = 1._wp