update ungrib to handle files larger than 2GB - #3
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to enable ungrib to process GRIB2 files larger than 2GB by widening seek/skip offsets to 64-bit and updating the underlying BACIO C/Fortran interface to support large file offsets.
Changes:
- Switch GRIB2 reader seek/skip variables (
lskip,iseek) to 64-bit integers. - Update BACIO Fortran and C interfaces to pass 64-bit start/newpos offsets and use 64-bit file offsets in
lseek. - Update GRIB message scanning (
SKGB) to use 64-bit seek/skip arithmetic.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
ungrib/src/rd_grib2.F |
Uses 64-bit lskip/iseek to avoid overflow when scanning large GRIB2 files. |
ungrib/src/g2print.F |
Mirrors the 64-bit lskip/iseek changes for the GRIB2 printing utility. |
ungrib/src/ngl/w3/baciof.f |
Changes BACIO Fortran wrappers (e.g., BAREAD/BAWRITE) to use 64-bit offsets when calling into C. |
ungrib/src/ngl/w3/bacio.v1.3.c |
Updates ba_cio/banio to accept 64-bit offsets and uses 64-bit off_t/lseek. |
ungrib/src/ngl/g2/skgb.f |
Updates GRIB scan routine to use 64-bit ISEEK/LSKIP and avoids 32-bit offset overflow. |
Comments suppressed due to low confidence (1)
ungrib/src/ngl/g2/skgb.f:46
- SKGB now declares dummy args ISEEK and LSKIP as INTEGER(KIND=8). Several existing callers in this repo (e.g., ungrib/src/ngl/w3/getgir.f and ungrib/src/ngl/g2/getg2ir.f) pass implicitly-typed variables (ISEEK default INTEGER, LSKIP implicit REAL), so this changes the calling ABI and will cause incorrect argument interpretation at runtime. Please update all SKGB call sites (and their declarations) to use consistent INTEGER(KIND=8) types for ISEEK/LSKIP, or provide a separate SKGB64 wrapper / explicit interface (module or INTERFACE block) so mismatches are caught at compile time.
INTEGER(KIND=8) :: ISEEK, LSKIP, KS, KS2
C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LGRIB=0
KS=ISEEK
KN=MIN(LSEEK,MSEEK)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
17 tasks
EricJames-NOAA
approved these changes
Apr 7, 2026
EricJames-NOAA
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me! Thanks for your work on this.
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.
long longC type to match Fortran'sINTEGER(KIND=8)seekretfrominttooff_t(matcheslseek()return type)Tested both situations with files smaller than or larger than 2GB and the new ungrib.x generates identical intermediate binary files.