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

[netCDF #RUY-124668]: problem in writing nc4 variable using nc_put_var



Marston,

> I managed to get CDL and ncgen going when I added groups to my code. The
> problem was understanding how to write the 1D (that's actually a 3D
> array) arrays with nc_put_var when the variable is defined as a 3D
> variable, plus  how to add attributes after I had created the file.
> I have a really good example of CDL text with groups that I'm might help
> novices like me. If you guys want to improve you NC4 docs for C, I can
> send my example.

Yes, please send it.  We can always use better examples.

> I really like NC4 but getting it to compile with HDF5 is not a trivial
> thing.

We're hoping the upcoming 4.1.2 release will be somewhat easier to build.
Thanks for your feedback.

--Russ

> /M
> 
> On 2011-03-09 21:32, Unidata netCDF Support wrote:
> > Hi Marston,
> >
> >> I'm using netcdf4.1.1 and hdf51.8.4 patch 1.
> > We now recommend using HDF5 version 1.8.5-patch1 with netCDF-4.1.1,
> > although I don't think all our online documentation has been updated
> > with that recommendation.  But that is probably *not* the source of
> > the problem you're seeing.
> >
> >> I'm trying to write an array that short *array(sizeof(short)*NX*NY*NZ).
> >> It is in fact a 3D array in a 1D array. I defined an array in NETCDF
> >> with nc_def_var as a 3D with NDIM=3.
> > Without seeing your code I'm just guessing, but did you supply an array
> > of the dimensions sizes (NX, NY, and NZ) rather than the dimension IDs
> > returned from defining 3 netCDF dimensions named NX, NY, and NZ?
> >
> > Just for reference, here's an example of a program fragment defining 3
> > netCDF dimensions and defining a 3D netCDF variable in terms of them:
> >
> > #define NDIM 3
> > #define NX   10
> > #define NY   20
> > #define NZ   30
> >     int nx_dimid, ny_dimid, nz_dimid;
> >     int dimids[NDIM];
> >     int varid;
> > ...
> >     /* Define the dimensions. */
> >     if ((retval = nc_def_dim(ncid, "nx", NX,&nx_dimid)))
> >        ERR(retval);
> >     if ((retval = nc_def_dim(ncid, "ny", NY,&ny_dimid)))
> >        ERR(retval);
> >     if ((retval = nc_def_dim(ncid, "nz", NZ,&nz_dimid)))
> >        ERR(retval);
> >
> >     /* The dimids array is used to pass the dimids of the dimensions of
> >        the netCDF variables. */
> >     dimids[0] = ny_dimid;
> >     dimids[1] = ny_dimid;
> >     dimids[2] = nz_dimid;
> >
> >     /* Define the netCDF variable */
> >     if ((retval = nc_def_var(ncid, "varname", NC_FLOAT, NDIMS, 
> > dimids,&varid)))
> >
> >> When I try to write it I get the error:
> >>
> >> HDF error.
> >>
> >> I follwed the example in the manual but it doesn't work. Can I get some
> >> help with this issue?
> > If it's not the problem described above, do you have a small example
> > that fails that you could send, so we can reproduce the problem here?
> >
> > --Russ
> >
> > Russ Rew                                         UCAR Unidata Program
> > address@hidden                      http://www.unidata.ucar.edu
> >
> >
> >
> > Ticket Details
> > ===================
> > Ticket ID: RUY-124668
> > Department: Support netCDF
> > Priority: Normal
> > Status: Closed
> >
> 
> 

Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: RUY-124668
Department: Support netCDF
Priority: Normal
Status: Closed