-
Notifications
You must be signed in to change notification settings - Fork 32
SIP338 Remove schema version from restart.c #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Alomir
merged 2 commits into
PecanProject:master
from
re2zero:sip338-remove-schema-version
Jun 1, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,15 +15,13 @@ | |
| #include "version.h" | ||
|
|
||
| #define RESTART_MAGIC "SIPNET_RESTART" | ||
| #define RESTART_SCHEMA_VERSION "1.0" | ||
| #define RESTART_FLOAT_EPSILON 1e-8 | ||
|
|
||
| /* | ||
| * When the serialized restart contract changes, update: | ||
| * - Number of elements of changed payload struct (#defs immediately below) | ||
| * - RESTART_SCHEMA_LAYOUT_* constants and related runtime checks | ||
| * - restart read/write logic, docs, and restart tests | ||
| * - RESTART_SCHEMA_VERSION | ||
| */ | ||
|
|
||
| #define MODEL_VERSION_BUFFER_SIZE 32 | ||
|
|
@@ -49,19 +47,19 @@ | |
| (8 * NUM_EVENT_TRACKERS_FIELDS) | ||
|
|
||
| _Static_assert(sizeof(Envi) == RESTART_SCHEMA_LAYOUT_ENVI_SIZE, | ||
| "Restart schema 1.0 drift: Envi changed; bump restart schema " | ||
| "version and update schema_layout.* checks"); | ||
| "Restart schema drift: Envi changed; update schema_layout.* " | ||
| "checks"); | ||
| _Static_assert(sizeof(Trackers) == RESTART_SCHEMA_LAYOUT_TRACKERS_SIZE, | ||
| "Restart schema 1.0 drift: serialized trackers payload changed; " | ||
| "bump restart schema version and update schema_layout.* checks"); | ||
| _Static_assert( | ||
| sizeof(PhenologyTrackers) == RESTART_SCHEMA_LAYOUT_PHENOLOGY_TRACKERS_SIZE, | ||
| "Restart schema 1.0 drift: PhenologyTrackers changed; bump restart " | ||
| "schema version and update schema_layout.* checks"); | ||
| "Restart schema drift: serialized trackers payload changed; " | ||
| "update schema_layout.* checks"); | ||
| _Static_assert(sizeof(PhenologyTrackers) == | ||
| RESTART_SCHEMA_LAYOUT_PHENOLOGY_TRACKERS_SIZE, | ||
| "Restart schema drift: PhenologyTrackers changed; update " | ||
| "schema_layout.* checks"); | ||
| _Static_assert(sizeof(EventTrackers) == | ||
| RESTART_SCHEMA_LAYOUT_EVENT_TRACKERS_SIZE, | ||
| "Restart schema 1.0 drift: EventTrackers changed; bump restart " | ||
| "schema version and update schema_layout.* checks"); | ||
| "Restart schema drift: EventTrackers changed; update " | ||
| "schema_layout.* checks"); | ||
|
|
||
| #define NUM_CLIMATE_SIGNATURE_FIELDS 4 | ||
| typedef struct RestartClimateSignature { | ||
|
|
@@ -91,8 +89,8 @@ typedef struct RestartContextModelFlags { | |
| static RestartContextModelFlags modelFlags; | ||
|
|
||
| _Static_assert(sizeof(RestartContextModelFlags) == NUM_CONTEXT_MODEL_FLAGS * 4, | ||
| "Restart schema 1.0 drift: Model flags changed; bump restart " | ||
| "schema version and update schema_layout.* checks"); | ||
| "Restart schema drift: Model flags changed; update " | ||
| "schema_layout.* checks"); | ||
|
|
||
| typedef enum StateFieldType { | ||
| FT_LONGLONG = 0, | ||
|
|
@@ -387,10 +385,9 @@ static void validateSchemaLayoutValue(const char *restartIn, const char *key, | |
| const char *value, long long expected) { | ||
| long long parsed = parseIntStrict(restartIn, key, value); | ||
| if (parsed != expected) { | ||
| logError( | ||
| "Restart schema layout mismatch in %s: key=%s found=%lld expected=%lld " | ||
| "(schema %s)\n", | ||
| restartIn, key, parsed, expected, RESTART_SCHEMA_VERSION); | ||
| logError("Restart schema layout mismatch in %s: key=%s found=%lld " | ||
| "expected=%lld\n", | ||
| restartIn, key, parsed, expected); | ||
| exit(EXIT_CODE_BAD_RESTART_PARAMETER); | ||
| } | ||
| } | ||
|
|
@@ -542,21 +539,13 @@ static void readRestartState(const char *restartIn, RestartState *state, | |
| } | ||
| checkLineLength(firstLine, strlen(firstLine), restartIn, in); | ||
|
|
||
| char magic[64]; | ||
| char schemaVersion[16]; | ||
| if (sscanf(firstLine, "%63s %15s", magic, schemaVersion) != 2) { | ||
| parseError(restartIn, "invalid header line", NULL); | ||
| } | ||
| // Strip trailing newline/carriage return for exact comparison | ||
| firstLine[strcspn(firstLine, "\r\n")] = '\0'; | ||
|
Comment on lines
+542
to
+543
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch |
||
|
|
||
| if (strcmp(magic, RESTART_MAGIC) != 0) { | ||
| if (strcmp(firstLine, RESTART_MAGIC) != 0) { | ||
| logError("Restart file %s has invalid magic header\n", restartIn); | ||
| exit(EXIT_CODE_BAD_RESTART_PARAMETER); | ||
| } | ||
| if (strcmp(schemaVersion, RESTART_SCHEMA_VERSION) != 0) { | ||
| logError("Restart schema mismatch in %s: found %s expected %s\n", restartIn, | ||
| schemaVersion, RESTART_SCHEMA_VERSION); | ||
| exit(EXIT_CODE_BAD_RESTART_PARAMETER); | ||
| } | ||
|
|
||
| int meanLength = meanNPP->length; | ||
| int *seenMeanValues = (int *)calloc((size_t)meanLength, sizeof(int)); | ||
|
|
@@ -727,7 +716,7 @@ static void writeRestartState(const char *restartOut, const RestartState *state, | |
| FILE *out = openFile(restartOut, "w"); | ||
|
|
||
| // Magic header | ||
| fprintf(out, "%s %s\n", RESTART_MAGIC, RESTART_SCHEMA_VERSION); | ||
| fprintf(out, "%s\n", RESTART_MAGIC); | ||
|
|
||
| // Schema batches | ||
| writeKeysBatch(out, state->metaPF, NUM_META_FIELDS); | ||
|
|
||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.