I’ve received feedback from several people that my GRIB_GET_RECORD routine was causing a nasty hard crash of IDL on 64-bit Linux and Mac OS X. Corinne James of Oregon State University emailed me recently with the problem both identified and solved (thank you, Corinne!): on 64-bit systems, the handle returned from GRIB_NEW_FROM_FILE is a 64-bit signed integer. I had incorrectly assumed a 32-bit integer. To see this, get a handle for the first record of the NCEP HiResWindow GRIB2 file I used in the previous GRIB helper routines post on a 32-bit system:
IDL> print, !version { x86 linux unix linux 8.2 Apr 10 2012 32 64} IDL> f = '/home/mpiper/data/grib/HiResWindow/ak.t18z.pgrb.mean.f06.grib2' IDL> fid = grib_open(f) IDL> h = grib_new_from_file(fid) IDL> help, h H LONG = 149085464
and then do the same on a 64-bit system:
IDL> print, !version { x86_64 linux unix linux 8.2 Apr 10 2012 64 64} IDL> f = '/home/mpiper/data/grib/HiResWindow/ak.t18z.pgrb.mean.f06.grib2' IDL> fid = grib_open(f) IDL> h = grib_new_from_file(fid) IDL> help, h H LONG64 = 140301847196112
Note the handle is of type LONG64 on the 64-bit system. Unfortunately, this isn’t documented in the IDL Help. I now have both 32- and 64-bit Linux machines for development and testing, so hopefully I won’t make this mistake again.
Please get the latest version of the GRIB helper routines from the VIS Code Library, and, as before, let me know if you find GRIB files on which they fail.
Reblogged this on Gigable – Tech Blog.
Thanks for these great GRIB routines! In response to your request above for sample cases, I’ve encountered an issue reading the GEFS ensemble GRIB2 files found on the TOC ftp site (e.g., ftp://tgftp.nws.noaa.gov/SL.us008001/ST.opnl/MT.ensg_CY.00/RD.20121210/PT.grid_DF.gr2_RE.high/fh.0000_pa.membrp03_tl.press_gr.onedeg). (You might need to refresh the date 20121210 [YYYYMMDD])
The call grib_get(h, key) within GRIB_GET_RECORD appears to generate an error of “Invalid type” when key = “EPS information”. For now, I’ve just added “EPS information” to the excluded keywords… although I’m not entirely sure that’s the most appropriate workaround.
Thanks, Ken. I’m thinking GRIB_GET just can’t handle spaces in a key. I’ve updated GRIB_GET_RECORD on the Code Library with your suggestion. This should be a temporary workaround, since we’re planning to restart work on IDL’s GRIB library in January.
Mark, by any chance do you have an example of writing a GRIB2 file? We are trying to work with the Weather Service on producing files to go into their AWIPS system, and apparently it will only accept GRIB. I see that IDL 8.2 how a routine to write GRIB, so just looking for an example on how to use it.
I don’t have much experience writing GRIB files, but please try this bare-bones example: grib_write_grib2_ex.pro. I hope it’ll give you a start. I tried to comment the code heavily to explain what I was doing in each step.