Skip to content

fix(io)!: name local_save files by rank on a single process too - #786

Merged
gouarin merged 1 commit into
mainfrom
fix/local-save-single-rank
Oct 28, 2026
Merged

gouarin merged 1 commit into
mainfrom
fix/local-save-single-rank

Conversation

@gouarin

@gouarin gouarin commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Description

In an MPI build, local_save names its files <filename>_rank<rank>.h5 and .xdmf, but only when more than one process runs. On one process it wrote <filename>.h5 and .xdmf. The suffix came from the check that save applies to a single-process communicator (comm.size() == 1 && world.size() > 1), and local_save went through save(..., MPI_COMM_SELF, ...). On main, mpiexec -n 1 ./test_local_save fails all 8 cases. CTest only ran it on 2 to 4 processes, so CI never saw it.

local_save now always appends the rank in an MPI build, so scripts that read the output need no special case for one process. save, with or without a communicator, keeps its naming. Builds without MPI are unchanged: local_save writes <filename>.h5, as save does. howto/save.md and api/io.md now say this.

Breaking changes

In an MPI build running on one process, local_save("out", mesh, u) now writes out_rank0.h5 and out_rank0.xdmf instead of out.h5 and out.xdmf. Scripts that open these files from a one-process run must add _rank0.

Related issue

Follow-up to #775, which added test_local_save.

How has this been tested?

add_mpi_gtest takes a new SINGLE_PROCESS flag, which also registers the test on 1 process. test_local_save and test_save_options use it.

main this PR
test_local_save at -n 1 8 of 8 fail pass
test_local_save, test_save_options at -n 1 to 4 (np 1 not run) pass

test_save_options no longer special-cases one process.

Under MPI, local_save wrote <filename>_rank<rank>.h5 and .xdmf on several
processes but <filename>.h5 and .xdmf on one, because the rank suffix came
from the size check that save applies to a single-process communicator.
Post-processing scripts had to special-case runs on one process, and
test_local_save failed at -n 1, which CTest never ran.

local_save now always appends the rank under MPI. save keeps its naming.
Builds without MPI are unchanged. test_local_save and test_save_options
also run on 1 process.

BREAKING CHANGE: an MPI build running on one process now writes
local_save output as <filename>_rank0.h5 and <filename>_rank0.xdmf
instead of <filename>.h5 and <filename>.xdmf.
@gouarin
gouarin force-pushed the fix/local-save-single-rank branch from e16badc to 49670f9 Compare October 28, 2026 07:02
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.70%. Comparing base (8a508ba) to head (49670f9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #786   +/-   ##
=======================================
  Coverage   82.70%   82.70%           
=======================================
  Files         161      161           
  Lines       10200    10200           
  Branches     3926     3926           
=======================================
  Hits         8436     8436           
  Misses       1150     1150           
  Partials      614      614           
Flag Coverage Δ
cpp 83.20% <ø> (ø)
python 73.53% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
include/samurai/io/hdf5.hpp 75.80% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gouarin
gouarin merged commit 15c659e into main Oct 28, 2026
26 checks passed
@gouarin
gouarin deleted the fix/local-save-single-rank branch October 28, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant