Skip to content

Make single and double precision restarts compatible with either version of the code - #2889

Merged
pcarruscag merged 3 commits into
developfrom
pedro/restart_compatible
Sep 8, 2026
Merged

Make single and double precision restarts compatible with either version of the code#2889
pcarruscag merged 3 commits into
developfrom
pedro/restart_compatible

Conversation

@pcarruscag

Copy link
Copy Markdown
Member

Proposed Changes

The 4th int of the header was written as 0 and never read, it now holds the size in bytes of the floating point data, so single and double precision builds can read each other's restart files. Files written before this field existed have a 0 there and were always double.

The MPI-IO read paths were hardcoded to MPI_DOUBLE, which is redefined to MPI_FLOAT in single precision builds and was therefore consistent within a build but not across builds. They now describe the payload as blocks of bytes of the size given by the header, and convert to the precision of the build when the two differ.

PR Checklist

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

The 4th int of the header was written as 0 and never read, it now holds
the size in bytes of the floating point data, so single and double
precision builds can read each other's restart files. Files written
before this field existed have a 0 there and were always double.

The MPI-IO read paths were hardcoded to MPI_DOUBLE, which is redefined
to MPI_FLOAT in single precision builds and was therefore consistent
within a build but not across builds. They now describe the payload as
blocks of bytes of the size given by the header, and convert to the
precision of the build when the two differ.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pcarruscag and others added 2 commits September 8, 2026 12:12
The 4th and 5th ints of the header were not spare after all, they used
to be the number of ints and of doubles of a metadata trailer appended
after the data (1 and 5, later 1 and 8). No reader ever looked at them,
the trailer layout was hardcoded, but old files in circulation (several
in the regression test data) still carry a 1 in the precision slot and
were rejected as an invalid precision.

Treat 1 there as double precision, like 0, and document what the two
ints held so they are not reused for something else.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
SetSensitivity read the trailer unconditionally, seeking a fixed 68
bytes back from the end of the file. The trailer has not been written
for a long time, so for current files those bytes are the tail of the
solution data, reinterpreted as the iteration number and the metadata.
That is where AoA_Sens comes from, which is the gradient of an
ANGLE_OF_ATTACK or FFD_ANGLE_OF_ATTACK design variable in SU2_DOT, so
those gradients were being taken from arbitrary solution values.

The header says whether there is a trailer and how many scalars it
holds, use it, and leave the iteration and metadata at the zeros they
are initialized with when there is none.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@pcarruscag
pcarruscag merged commit 710ce76 into develop Sep 8, 2026
37 of 38 checks passed
@pcarruscag
pcarruscag deleted the pedro/restart_compatible branch September 8, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant