[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++ and record variables
- Subject: Re: C++ and record variables
- Date: Tue, 06 Sep 1994 13:05:05 -0600
> Organization: NOAA/ERL
> Keywords: 199409011356.AA29525 C++ record variables bug
Tom,
> I tried your suggestion on the C++ record variables and I still get the
> same results. Here is my short test program:
> ------------------------------------------------------------------------------
> #include <stdio.h>
> #include "netcdf.hh"
>
> int main()
> {
> float data[3][50];
> int i,j,k;
> long start[3];
> long rec=0;
> long nrec=1;
> long number=0;
>
>
> for(j=0;j<3;j++)
> for(i=0;i<50;i++)
> data[j][i]=((float)i*.5)+(float)number;
>
> NcOldFile file ("scr.nc",NcOldFile::Write);
>
> NcDim* TIME=file.get_dim("time");
> NcDim* HEIGHTS=file.get_dim("heights");
> NcDim* BEAM=file.get_dim("beam");
>
> NcVar* velId=file.get_var("vel");
>
> velId->put((float *)&data,nrec,BEAM->size(),HEIGHTS->size());
>
> velId->set_cur(++rec);
>
> velId->put((float *)&data,nrec,BEAM->size(),HEIGHTS->size());
>
> return(0);
> }
> --------------------------------------------------------------------------------
> Here is the test cdl file that I'm using:
>
> --------------------------------------------------------------------------------
> netcdf scr
> {
>
> // Santa Cruz profiler site NetCDF file.
>
> dimensions:
>
> time = UNLIMITED;
> namelen = 30;
> heights = 50;
> beam = 3;
> az = 3;
> el = 3;
>
> variables:
>
> // Actual data variables:
>
> // Radial Velocity
>
> float
> vel(time, beam, heights);
> vel:long_name = "Radial Velocity, all beams";
> vel:units = "meters/second";
> vel:valid_range = -100.f, 100.f;
>
> }
>
> --------------------------------------------------------------------------------
>
> What I am doing wrong? Is the fact that I'm using a cdl file causing the
> problem?
Your test program demonstrates a bug in the NcVar::set_cur() member
function. I've appended a two-line patch that I think fixes the bug.
Thanks for reporting the problem. Please let me know if this doesn't fix it
for you.
--
Russ Rew UCAR Unidata Program
address@hidden P.O. Box 3000
http://www.unidata.ucar.edu/ Boulder, CO 80307-3000
RCS file: /upc/new/CVS/netcdf/c++/netcdf.cc,v
retrieving revision 1.46
diff -r1.46 netcdf.cc
672c672
< if (t[i] >= get_dim(i)->size())
---
> if (t[i] >= get_dim(i)->size() && ! get_dim(i)->is_unlimited())
687c687
< if (cur[i] >= get_dim(i)->size())
---
> if (cur[i] >= get_dim(i)->size() && ! get_dim(i)->is_unlimited())