Skip to content

Fix undefined allreduce min/max/sum results in non-MPI builds - #1971

Closed
sbryngelson wants to merge 1 commit into
MFlowCode:masterfrom
sbryngelson:fix-allreduce-nompi
Closed

sbryngelson wants to merge 1 commit into
MFlowCode:masterfrom
sbryngelson:fix-allreduce-nompi

Conversation

@sbryngelson

@sbryngelson sbryngelson commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Contribution Policy

We do not accept pull requests generated primarily by AI without genuine understanding or real-world usage context.

All contributions are expected to demonstrate:

  • A clear understanding of the codebase
  • Alignment with product direction
  • Thoughtful reasoning behind changes
  • Evidence of real-world usage or hands-on experience with the problem

If these expectations are not met, we would prefer to implement the changes ourselves rather than spend time reviewing low-effort submissions.


Acknowledgement

  • I confirm this PR meets the above expectations and reflects my own understanding and real-world context.

Fixes #1966

Change

In non-MPI builds, s_mpi_allreduce_min and s_mpi_allreduce_max in src/common/m_mpi_common.fpp left their intent(out) var_glb undefined. Added #else var_glb = var_loc.

  • s_mpi_allreduce_sum had the same gap. It is also fixed in the unmerged Keep species mass fractions in [0, 1] by construction instead of clipping #1963; repeated here so this PR stands alone (trivial overlap, same one-line branch).
  • Audit of the rest of the file found one more: s_mpi_gather_data left its allocatable gathered_vector unallocated without MPI. Added #else gathered_vector = my_vector (single process: the gathered vector is the local one).
  • Already correct: s_mpi_allreduce_min_vec, s_mpi_allreduce_vectors_sum, s_mpi_allreduce_integer_sum(_vec), s_mpi_reduce_int_sum, s_mpi_reduce_stability_criteria_extrema. s_mpi_reduce_min and s_mpi_reduce_maxloc are intent(inout), so the local value is already the result.

Affected callers on single-process builds: s_mpi_allreduce_min in m_boundary_common.fpp (global bounds), and s_mpi_allreduce_max/sum and s_mpi_gather_data in post_process m_data_output.fpp (probe/integral output). These now receive the local value instead of garbage.

Evidence

./mfc.sh test --no-mpi --no-gpu -j 24 --only IBM on Tuolumne (login node): 61 passed, 0 failed, 708 skipped. ./mfc.sh format and ./mfc.sh precheck pass.

Not verified: no dedicated test exercises these routines in a no-MPI build (the garbage read is not caught by the golden-file tests); the claim that callers now get the local value is from reading the code. MPI builds are unaffected (the change is inside #else), but I did not run MPI tests.


Consolidated into draft PR #2024. This change is retained as a separate commit, and this original description is reproduced in full there. Original discussion remains available here.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/common/m_mpi_common.fpp 1502 +8
Directory Lines Diff
common 10456 +8
total 47434 +8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

s_mpi_allreduce_min/max leave var_glb undefined in non-MPI builds

1 participant