-
Notifications
You must be signed in to change notification settings - Fork 292
HDF5 format compatibility when re-opening files #2176
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
Merged
Changes from 2 commits
Commits
Show all changes
4 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
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 |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* Copyright 2022, University Corporation for Atmospheric Research. | ||
| * See COPYRIGHT file for copying and redistribution conditions. */ | ||
| /** | ||
| * @file | ||
| * @internal This function selects the best HDF5 file format options | ||
| * to create netCDF-4 files that can be read and written by older | ||
| * library versions. | ||
| * | ||
| * Format compatibility is transient, not baked in to an HDF5 file | ||
| * at creation time. Therefore the desired compatibilty options | ||
| * must be selected every time a file is opened for writing. | ||
| * | ||
| * This function should be called before every call to create a new | ||
| * netCDF-4 file, or to open an existing netCDF-4 file for writing. | ||
| * This function has no effect when opening a file for read only. | ||
| * | ||
| * This function should work correctly with all HDF5 library versions | ||
| * from 1.8.0 through 1.13.0 and beyond, with no further changes. | ||
| * This assumes that HDF5 versioning controls remain consistent | ||
| * into the future. | ||
| * | ||
| * The basic functionality is to select the traditional HDF5 v1.8 | ||
| * format compatibility, whenever possible. The less desirable | ||
| * v1.6 compatibily is selected in a few strange cases when it is | ||
| * not possible to select v1.8. | ||
| * | ||
| * Files created with v1.6 compatibility have superblock version 0. | ||
| * Files created with v1.8 compatibility have superblock version 2. | ||
| * | ||
| * The superblock version is locked in when a file is first created. | ||
| * It is then possible to get a mix of v1.6 and v1.8 internal | ||
| * object versions, when an existing netCDF-4 file is modified by | ||
| * a different software version than the one that originally | ||
| * created the file. Mixed-object files of this nature are common | ||
| * and do not suffer any serious problems. | ||
| * | ||
| * See netcdf-c github issues #250 and #951 for more details about | ||
| * the rationale and evolution of netCDF-4 format compatibility. | ||
| */ | ||
|
|
||
| #include "config.h" | ||
| #include "hdf5internal.h" | ||
|
|
||
| /** | ||
| * @internal Function to set HDF5 file access options for backward | ||
| * format compatibility. Call this before every call to H5Fcreate | ||
| * or H5Fopen. | ||
| * | ||
| * @param fapl_id Identifier for valid file access property list to | ||
| * be used in the next call to H5Fcreate or H5Fopen. | ||
| * | ||
| * @return ::NC_EHDFERR General failure in HDF5. | ||
| */ | ||
| int | ||
| hdf5set_format_compatibility(hid_t fapl_id) | ||
| { | ||
| #if H5_VERSION_GE(1,10,2) | ||
| /* lib versions 1.10.2 and higher */ | ||
| if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) | ||
|
|
||
| #else | ||
| #if H5_VERSION_GE(1,10,0) | ||
| /* lib versions 1.10.0, 1.10.1 */ | ||
| if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) | ||
|
|
||
| #else | ||
| /* all HDF5 1.8 lib versions */ | ||
| if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) | ||
| #endif | ||
| #endif | ||
| return NC_EHDFERR; /* failure exit */ | ||
|
|
||
| return NC_NOERR; /* normal exit */ | ||
| } | ||
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.