From: Arlindo da S. <da...@al...> - 2008-02-03 15:36:49
|
On Feb 3, 2008 9:57 AM, Brian Doty <do...@co...> wrote: > lengths in a GRIB msg are defined by the GRIB specification and are > independent of systems definitions like g2int. It is appropriate to > hardcode the length. Or to use a typedef that is dependent on the > GRIB definitions (ie, hardcoded). It probably doesn't matter how > long hdr is (as long as it is at least 4 bytes ) but you want to read > exactly 4 bytes no more no less.. Brian > You and Jennifer are right. Do you think grib2c is robust enough to work on machines where sizeof(int)!=4? If not, it may pay to add something to configure.ac to detect such cases and stop with an error. Pat: do you know how to do this? Arlindo > > On Feb 3, 2008, at 12:09 AM, Arlindo da Silva wrote: > > > On Feb 2, 2008 7:21 PM, Jennifer Adams <jm...@co...> wrote: > > > > > > Arlindo -- > > There is a bug in seekgb.c of the g2clib that causes it to fail to > > detect the end of a grib2 record if sizeof(g2int) != 4 (i.e. on 64- > > bit systems). I guess we should put the patch in the subblib src > > files we are redistributing (on your site and COLA's). This bug > > causes gribmap to fail to find any records -- pretty bad. > > > > # diff ./seekgb.c ~/Desktop/seekgb.c > > 39a40 > > > int hdr; > > 68,69c69,70 > > < k4=fread(&end,sizeof(g2int),1,lugb); > > < if (k4 == 1 && end == 926365495) { //GRIB > > message found > > --- > > > k4=fread(&hdr,4,1,lugb); > > > if (k4 == 1 && hdr == 926365495) { //GRIB > > message found > > > > > > If it is OK with you I'll replace int with g2int for consistency > > with rest of grib2c. They do assume that g2int = int are 32 bits, > > but keeping everything in terms of g2int will make it easier to > > update the code if we ran into ints that are > 32 bits. > > > > g2int hdr; > > ... > > k4=fread(&hdr,sizeof(hdr),1,lugb); > > if (k4 == 1 && hdr == 926365495) { //GRIB message > > found > > > > > > > > -- > > Arlindo da Silva > > da...@al... > > -- Arlindo da Silva da...@al... |