GRIB1 data length overflow
When GRIB1 data length > 2^23-1, apparently this is the way it is encoded:
sizeSection4 = (read the 3 bytes of section 4)
If (sizeSection4 < 120) {
// computed using total length – length of all other sections
sizeTotal = (sizeTotal – 7FFFFF ) * 120 – sizeSection4 + 4
sizeSection4 = sizeTotal – 8 –sizeSection1 – sizeSection2 – sizeSection3 – 4;
}
May be ECMWF specific, not sure (sent note to ask).
ECMWF redefines the GRIB format without (AFAIK) documenting it. Now we all run around and adjust. Can we lodge a protest with the United Nations?
OTOH, maybe they did get official permission, and we dont know it. OTOH, why reward bad behavior? OTOH, this is just the way it is in GRIBlandia, so stop your whining, its not a bad solution to data size too big. OTOH, it messes with my pretty code. OTOH, grow up and get over it.
OTOH, it's non-standard GRIB, so the best course of action is to burn it!

But more seriously, it's non-standard GRIB. GRIB is a pain as it is, no need to further complicate it with non-standard stuff. I'd rather try to get users to put pressure on the organization to get them to do the right thing. That said, it's ECMWF, so I have zero idea how they respond to things like this.
Ok, im going to transfer ownership to you. if you do decide to do it, note that Grib1RecordScanner has to get more complex because can no longer count on the message length being correct.
Do you have any updates on the status of this issue? We have users that have been requesting access to this dataset through TDS/OPeNDAP. Thx.
Greetings @DCSCHUS - do you have an example file I could play with (I may have asked before, but I've misplaced the file if I have it).
Hi Sean,
Example files for ds113.1 can be downloaded from the following, after you agree to the terms of usage in your RDA profile: https://rda.ucar.edu/datasets/ds113.1/#!description
If you have detailed questions regarding the ECMWF GRIB1 "length of data section" hack, Dave Stepaniak, cc'd on this email might be able to help.
Finally, if it would be of help, we could add a login for you on the VM that John Caron previously used for testing. This has direct access to all DSS/RDA data on disk, and has his current version of the RDA#THREDDS version 5.0 data server installed.
Thanks in advance for your help, Doug
On Fri, May 26, 2017 at 10:00 AM, Sean Arms [email protected] wrote:
Greetings @DCSCHUS https://github.com/dcschus - do you have an example file I could play with (I may have asked before, but I've misplaced the file if I have it).
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Unidata/thredds/issues/445#issuecomment-304320698, or mute the thread https://github.com/notifications/unsubscribe-auth/AGL5avVRaC_9fVnwBJrCHaJk53-uXlzBks5r9vcMgaJpZM4Hhz6A .
-- Doug Schuster [email protected] 303-497-1216 NCAR/CISL Research Data Archive http://rda.ucar.edu
Great - thanks Doug! I just grabbed a file and will try to take a look here soon. A login to the VM might be extreamly helpful once I have netCDF-Java able to read the files locally.
Cheers!
On Fri, May 26, 2017 at 1:06 PM, Doug Schuster [email protected] wrote:
Hi Sean,
Example files for ds113.1 can be downloaded from the following, after you agree to the terms of usage in your RDA profile: https://rda.ucar.edu/datasets/ds113.1/#!description
If you have detailed questions regarding the ECMWF GRIB1 "length of data section" hack, Dave Stepaniak, cc'd on this email might be able to help.
Finally, if it would be of help, we could add a login for you on the VM that John Caron previously used for testing. This has direct access to all DSS/RDA data on disk, and has his current version of the RDA#THREDDS version 5.0 data server installed.
Thanks in advance for your help, Doug
On Fri, May 26, 2017 at 10:00 AM, Sean Arms [email protected] wrote:
Greetings @DCSCHUS https://github.com/dcschus - do you have an example file I could play with (I may have asked before, but I've misplaced the file if I have it).
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Unidata/thredds/issues/445#issuecomment-304320698, or mute the thread <https://github.com/notifications/unsubscribe-auth/AGL5avVRaC_ 9fVnwBJrCHaJk53-uXlzBks5r9vcMgaJpZM4Hhz6A> .
-- Doug Schuster [email protected] 303-497-1216 <(303)%20497-1216> NCAR/CISL Research Data Archive http://rda.ucar.edu
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/Unidata/thredds/issues/445#issuecomment-304364386, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEGGFyghjFkIkRXWKWCIF-gUYMbRomcks5r9yLKgaJpZM4Hhz6A .
Sounds good. Thanks Sean. Let me know when you get to the point where a VM login is needed.
Doug
On Wed, Jun 7, 2017 at 10:21 AM, Sean Arms [email protected] wrote:
Great - thanks Doug! I just grabbed a file and will try to take a look here soon. A login to the VM might be extreamly helpful once I have netCDF-Java able to read the files locally.
Cheers!
On Fri, May 26, 2017 at 1:06 PM, Doug Schuster [email protected] wrote:
Hi Sean,
Example files for ds113.1 can be downloaded from the following, after you agree to the terms of usage in your RDA profile: https://rda.ucar.edu/datasets/ds113.1/#!description
If you have detailed questions regarding the ECMWF GRIB1 "length of data section" hack, Dave Stepaniak, cc'd on this email might be able to help.
Finally, if it would be of help, we could add a login for you on the VM that John Caron previously used for testing. This has direct access to all DSS/RDA data on disk, and has his current version of the RDA#THREDDS version 5.0 data server installed.
Thanks in advance for your help, Doug
On Fri, May 26, 2017 at 10:00 AM, Sean Arms [email protected] wrote:
Greetings @DCSCHUS https://github.com/dcschus - do you have an example file I could play with (I may have asked before, but I've misplaced the file if I have it).
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/Unidata/thredds/issues/445#issuecomment-304320698 , or mute the thread <https://github.com/notifications/unsubscribe-auth/AGL5avVRaC_ 9fVnwBJrCHaJk53-uXlzBks5r9vcMgaJpZM4Hhz6A> .
-- Doug Schuster [email protected] 303-497-1216 <(303)%20497-1216> <(303)%20497-1216> NCAR/CISL Research Data Archive http://rda.ucar.edu
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/Unidata/thredds/issues/445#issuecomment-304364386, or mute the thread <https://github.com/notifications/unsubscribe- auth/AAEGGFyghjFkIkRXWKWCIF-gUYMbRomcks5r9yLKgaJpZM4Hhz6A>
.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Unidata/thredds/issues/445#issuecomment-306847698, or mute the thread https://github.com/notifications/unsubscribe-auth/AGL5ai7rj5Ee8hLESxZ06ROZYh67yH--ks5sBs4YgaJpZM4Hhz6A .
-- Doug Schuster [email protected] 303-497-1216 NCAR/CISL Research Data Archive http://rda.ucar.edu
Hi, we have emailed with Sean about netCdf java support of ECMWF grib1 files at 27/12/2017.
These files can be read with grib-api, an ECMWF grib library which can be found here
I provide here a sample file and its grib-api dump. Sample file grib-api dump
Basically, what is wrong with these files is the "totalLength" section at bytes 5-7 of each message. Netcdf Java tries to validate these files by looking at "totalLength" area and checks whether the end of section 5 message is "7777". Due to wrong length value, it gives "not a valid cdm file" exception.
In my opinion, these files have a fixed length sections for each message. So, grib-api can read them without referring to "totalLength" section. But this information needs to be approved.
I need to be able to open these files with netcdf java. Let me know if I can contribute the open source development process.
Thank you.
@sefadolunay,
you can use that files setting 2 properties at Grib1RecordScanner class:
ucar.nc2.grib.grib1.Grib1RecordScanner.setAllowBadDsLength(true);
ucar.nc2.grib.grib1.Grib1RecordScanner.setAllowBadIsLength(true);
NetcdfFile nc = NetcdfFile.open(filename);
System.out.println(nc);
Regards