Make single and double precision restarts compatible with either version of the code - #2889
Merged
Conversation
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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
pre-commit run --allto format old commits.