s_mpi_allreduce_min/max leave var_glb undefined in non-MPI builds #1966
Copy link
Copy link
Open
Labels
pr-to-doFix already written in a closed PR; reopen when review capacity allowsFix already written in a closed PR; reopen when review capacity allows
Description
Summary
In builds without MPI, s_mpi_allreduce_min and s_mpi_allreduce_max (src/common/m_mpi_common.fpp) leave their intent(out) result var_glb undefined. The MPI_ALLREDUCE call is wrapped in #ifdef MFC_MPI and has no #else var_glb = var_loc. Callers on a single-process build then read garbage.
s_mpi_allreduce_sum had the same gap; #1963 adds the #else branch for it. s_mpi_allreduce_min_vec and s_mpi_reduce_int_sum already have the fallback.
Fix
Add the same branch to s_mpi_allreduce_min and s_mpi_allreduce_max:
#ifdef MFC_MPI
...
call MPI_ALLREDUCE(var_loc, var_glb, 1, mpi_p, MPI_MIN, MPI_COMM_WORLD, ierr)
#else
var_glb = var_loc
#endifThen check whether any other scalar reduction helper is missing the same branch.
Found with Claude Code (a cleanup report that used s_mpi_allreduce_sum never printed in --no-mpi test builds).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
pr-to-doFix already written in a closed PR; reopen when review capacity allowsFix already written in a closed PR; reopen when review capacity allows
Activity