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

Re: 950830: netCDF error



>From: Bill Roberts <address@hidden>
>Organization: NCAR/HAO
>Keywords: 199508302136.AA03514 netCDF error

Hi Bill,

> Can you tell me what the following "error msg" is indicating:
> 
>   ncendef: xdr_NC_fill

Yes, it's a symptom of a bug with calling ncrecput() in a file that has just
been opened.  I've fixed the bug in the next netCDF release, but for now, a
workaround is indicated in the appended message.

--Russ

To: address@hidden (Dave Osburn)
Subject: Re: ncrecput bug 
--------
> Organization: NOAA/FSL
> Keywords: 199405191510.AA22596

Hi Dave,

> Found a bug concerning ncrecput.  One must go into and exit define mode before
> using ncrecput, or the record write won't work.  Shouldn't we be in data mode 
> by default?  I used ncgen to create the (empty) netcdf file 'aaa'.

You are in data mode by default when you open an existing netCDF file, so
there should never be a need to enter and then exit define mode to get into
data mode.  But I have verified the bug you sent in (on a SPARCstation 10
under SunOS 5.3).  Apparently we never saw this because our test program,
nctest, uses a file that has already been in and out of define mode before
it uses it to test ncrecput().

> The following is the test program I worked with.  Take out the calls to 
> ncredef
> and ncendef, and no worky.

Yup, it produces the error messages:

    ncrecput: xdr_NC_fill
    ncrecput: NCfillrec, rec 0

when the presumably redundant calls to ncredef() folowed immediately by
ncendef() are removed.

> P.S.  I had only pulled out half of my hair by the time I figured this one 
> out!

I'm surprised you found a workaround at all.  The one you found is not
obvious.

> #include <netcdf.h>
>  
> static struct
>     {
>     long a;
>     float b;
>     } rec = {12345, 1234.5};
>  
> int ncid;
> int varid;
> int status;
> long recnum = 0;
> void *datap[2];
> static long mindex[5] = {0, 0, 0, 0, 0};
>  
> main()
> {
> datap[0] = &rec.a;
> datap[1] = &rec.b;
>  
> ncopts = NC_VERBOSE;ncid = ncopen("aaa", NC_WRITE);
>  
> status = ncredef(ncid);
> printf("redef stat = %d\n", status);
> status = ncendef(ncid);
> printf("endef stat = %d\n", status);
>  
> ncrecput(ncid, recnum, datap);
>  
> ncclose(ncid);
> exit(0);
> }
> 
>   * * * * *
>   
> netcdf test
> {
> dimensions:
>  
>     recNum    = UNLIMITED;
>  
> variables:
>  
>     long    a(recNum);
>     float   b(recNum);
> }

Thanks for reporting the problem and constructing an example that
demonstrates it.  I have verified that this bug is still in the current
development version, so we'll have to find a fix for it before the next
release.

__________________________________________________________________________
                      
Russ Rew                                              UCAR Unidata Program
address@hidden                                        P.O. Box 3000
(303)497-8645                                 Boulder, Colorado 80307-3000