Skip to content

Commit f9a08e3

Browse files
committed
src: broadcast BC type codes with MPI_INTEGER in pre_process; pin residue broadcasts
pre_process sent the integer bc_x/y/z%beg/%end with mpi_p (an 8-byte real transfer over 4-byte integers - undefined behavior that happened to work by adjacency); simulation and post_process already used MPI_INTEGER. Also adds a test pinning the hand-written vb/ve and BC-code residue in pre/post so a merge conflict cannot silently drop them. Both from review.
1 parent 913f8f2 commit f9a08e3

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/pre_process/m_mpi_proxy.fpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,20 @@ contains
3939
call MPI_BCAST(${VAR}$, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)
4040
#:endfor
4141

42-
! manual: bc_x/y/z and domain bounds (registered as struct members, not in NAMELIST_VARS)
42+
! manual: domain bounds and wall temperatures (REAL struct members, not in NAMELIST_VARS)
4343
#:for VAR in [ 'x_domain%beg', 'x_domain%end', 'y_domain%beg', &
4444
& 'y_domain%end', 'z_domain%beg', 'z_domain%end', &
45-
& 'bc_x%beg', 'bc_x%end', 'bc_y%beg', 'bc_y%end', &
46-
& 'bc_z%beg', 'bc_z%end', 'bc_x%Twall_in', 'bc_x%Twall_out', &
45+
& 'bc_x%Twall_in', 'bc_x%Twall_out', &
4746
& 'bc_y%Twall_in', 'bc_y%Twall_out', 'bc_z%Twall_in', &
4847
& 'bc_z%Twall_out']
4948
call MPI_BCAST(${VAR}$, 1, mpi_p, 0, MPI_COMM_WORLD, ierr)
5049
#:endfor
5150

51+
! manual: BC type codes (INTEGER struct members)
52+
#:for VAR in [ 'bc_x%beg', 'bc_x%end', 'bc_y%beg', 'bc_y%end', 'bc_z%beg', 'bc_z%end']
53+
call MPI_BCAST(${VAR}$, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
54+
#:endfor
55+
5256
! wall-velocity members consumed by s_slip_wall/s_no_slip_wall on all ranks
5357
#:for DIM in ['x', 'y', 'z']
5458
#:for DIR in [1, 2, 3]

toolchain/mfc/params_tests/test_fortran_gen.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,3 +605,19 @@ def test_generate_bcast_fpp_lag_params_registry_walk():
605605
# Dead members must not appear
606606
for dead in ("T0", "Thost", "c0", "rho0", "x0"):
607607
assert f"lag_params%{dead}" not in sim, f"dead member lag_params%{dead} present in sim"
608+
609+
610+
def test_mpi_proxy_residue_pins_wall_velocity_and_bc_datatypes():
611+
"""The vb/ve wall-velocity broadcasts and integer BC datatypes live in
612+
hand-written residue (not codegen); pin them so an edit or merge conflict
613+
that drops them fails loudly."""
614+
import pathlib
615+
616+
root = pathlib.Path(__file__).resolve().parents[3]
617+
for target in ("pre_process", "post_process"):
618+
src = (root / "src" / target / "m_mpi_proxy.fpp").read_text()
619+
assert "bc_${DIM}$%vb${DIR}$" in src, f"{target}: vb broadcasts missing"
620+
assert "bc_${DIM}$%ve${DIR}$" in src, f"{target}: ve broadcasts missing"
621+
assert "'bc_x%beg', 'bc_x%end', 'bc_y%beg', 'bc_y%end', 'bc_z%beg', 'bc_z%end']" in src
622+
seg = src.split("'bc_z%beg', 'bc_z%end']", 1)[1]
623+
assert "MPI_INTEGER" in seg.split("#:endfor")[0], f"{target}: BC codes not MPI_INTEGER"

0 commit comments

Comments
 (0)