Skip to content

s_mpi_allreduce_min/max leave var_glb undefined in non-MPI builds #1966

Description

@sbryngelson

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
#endif

Then 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).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions