Merged
Conversation
Root cause The multifile code path in ushow.c only checked for Zarr, then fell through to NetCDF — never checking for GRIB files. And file_grib.c had no fileset functions. src/file_grib.h — Added fileset function declarations - grib_open_fileset(), grib_open_glob(), grib_fileset_map_time(), grib_read_slice_fileset(), grib_fileset_total_times(), grib_get_dim_info_fileset(), grib_close_fileset(), grib_read_timeseries_fileset() src/file_grib.c — Implemented fileset functions - grib_open_fileset: Opens multiple GRIB files, sorts by name, counts unique time values in each file to build time_offsets - grib_open_glob: Expands glob pattern, delegates to grib_open_fileset - grib_read_slice_fileset: Maps virtual time to (file_idx, local_time), lazily scans variables for non-first files, then reads the correct slice - grib_get_dim_info_fileset: Returns concatenated time values across all files - grib_read_timeseries_fileset: Reads and concatenates time series across files - Uses a lazy variable scanning pattern — variables for non-first files are scanned on first access using the shared mesh src/ushow.c — Updated dispatch in 7 locations 1. File opening: Added GRIB detection for both glob patterns and explicit multiple files (checks grib_is_grib_file() on first matched file) 2. Dim info dispatch (2 places): GRIB fileset → grib_get_dim_info_fileset() 3. Timeseries dispatch: GRIB fileset → grib_read_timeseries_fileset() 4. Error cleanup (2 places): Added GRIB fileset handling 5. Final cleanup: grib_close_fileset() for GRIB filesets 6. Fixed pre-existing bug: FILE_TYPE_GRIB used outside #ifdef HAVE_GRIB guards src/view.c — Updated read dispatch - Added GRIB fileset check before single-file GRIB check in view_update()
Collaborator
|
Collaborator
|
Thanks a lot, Sebastian, merging! |
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.
Add support for reading grib files. Requires eccodes as additional dependency.
I hope I got it correct with mapping the variables/levels etc. to depth, but the destine data that I used for testing works.
This is the ampcode thread where the work was done:
https://ampcode.com/threads/T-019c39ce-9bad-76bb-806b-42a4701c39de