[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20040213: gdbm file reader program



Neil,

> To: address@hidden
> From: "Neil R. Smith" <address@hidden>
> Subject: gdbm file reader program
> Organization: TAMU
> Keywords: 200401280025.i0S0PCp2028769 LDM gdbm

The above message contained the following:

> I'm still having difficulty reading pqsurf DBFILE output from my
> LDM 6.0.14 on FreeBSD by weather compiled on Red Hat Linux.

I would be very surprised if a Linux GDBM program could read a GDBM file
produced by a FreeBSD GDBM program. As far as I know, GDBM files (unlike
netCDF files) are platform-dependent.

> (Haven't
> successfully built weather on this FreeBSD, but can build the gdbm 1.7.3
> package included in the weather [4.1.0] package.) So I
> thought I'd experiment with reading from the file with a short
> little program using the gdbm 1.7.3 library to see if I could 
> glean some further insight. The program is attached.
> 
> For program testing, I compile it on our irix host where the 
> weather program has been running successfully, reading DBFILE 
> output from an older LDM also running on irix (different host).
> The gdbm.h include line you see in the sample was changed to point
> to the full path appropriate to that irix install. The input
> file, hard coded, is a copy of a real DBFILE metar file. The
> station name, CLL, is in the file cause I can grep it. The program
> is compiled with:
> cc -o tstdb tstdb.c -L/unidata/ldm/weather/v4.10/lib/irix -lgdbm
> 
> On the irix host, this program prints out:
> -- gdbm_open stmt
> -- fetch
> -- Printing content
> (null)
> Dsize is 0

If the GDBM file was created on a different system (i.e., the FreeBSD
system you mentioned previously) then I would be surprised if you could
read it on the IRIX system.

Try testing writing-to and reading-from a GDBM file on the same system first.

> I expect content to be the metar report, and dsize to be non-zero.
> Am I coding incorrectly here?
> 
> Thanks for you help. -Neil
> -- 
> Neil R. Smith, Comp. Sys. Mngr.               address@hidden
> Dept. Atmospheric Sci., Texas A&M Univ.       979/845-6272 FAX:979/862-4466
> 
...
> /* test open/read of gdbm metar files*/
> # include "/unidata/ldm/weather.bsd/include/gdbm.h"
> # include <stdio.h>
> 
> main ()
> {=09
>       datum station, content;
>       GDBM_FILE dbf;
> =09
>       station.dptr =3D "CLL";
>       station.dsize =3D 3;
>       =09
>       printf("-- gdbm_open stmt\n");
> 
>       dbf =3D gdbm_open ("sample.METAR",0,0,0,0);
> =09
>         printf("-- fetch\n");
> =09
>       content =3D gdbm_fetch (dbf, station);
> 
>       printf ("-- Printing content\n");=20
> =09
>         printf ("%s\nDsize is %i\n",content.dptr,content.dsize);
> 
>       gdbm_close (dbf);
> =09
>       free(content.dptr);
> =09
> }

Regards,
Steve Emmerson