Re: [netcdfgroup] Problem using nc_put_vara_...() and nc_put_vars_...() functions.

  • To: Ed Hartnett <ed@xxxxxxxxxxxxxxxx>
  • Subject: Re: [netcdfgroup] Problem using nc_put_vara_...() and nc_put_vars_...() functions.
  • From: Sergey Panov <sergey.panov@xxxxxxxxxxx>
  • Date: Thu, 16 Oct 2008 23:56:51 -0400
Thank you, it was an "operator error" - replacing 0-s with 1-s in count
array fix the problem.
 I wish man page elaborated more on this topic. The statement that to
write one element one has to set  count to {1,1,...,1} is a hint easily
mistaken for a typo.

Regards, 
        Sergey

On Thu, 2008-10-16 at 08:37 -0600, Ed Hartnett wrote:
> Sergey Panov <sergey.panov@xxxxxxxxxxx> writes:
> > I suspect it is an "operator error", but I tried all possible
> > interpretations of the API documentation and can not fill data block
> > with either nc_put_vara_double() or  nc_put_vars_double().
> > nc_put_var1_double() works as expected.
> >
...
> >
> > Here is a snapshot of non-working code:
> >
> > ...
> > double ray_data[RANGE_BINS_COUNT] = {0.0};
> > ...
> >     for (sweep_idx = 0; sweep_idx < SWEEPS_COUNT; sweep_idx++ )
> >         for(ray_idx = 0; ray_idx < RAYS_PER_SWEEP_COUNT; ray_idx++ ) {
> >             size_t start[3] = {sweep_idx, ray_idx, 0};
> >             size_t count[3] = {0, 0, RANGE_BINS_COUNT};
> >
> >             status = nc_put_vara_double(ncid, dbz_id, start, count, 
> > ray_data);
> >             if (status != NC_NOERR)
> >                 handle_error(status);
> >         }
> > ...
> >
> >

> Your problem is that you are setting some of the count array to zero.
> 
> With the vara calls, multiply all the count elements together to get
> the total number of values written. If one of the count elements is
> zero, you are asking the library to write zero elements of data, and
> it obliges by doing nothing and returning no error.
> 
> So probably you want to set count to:
>              size_t count[3] = {1, 1, RANGE_BINS_COUNT};
> 
> Good luck!
> 
> Ed




  • 2008 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: