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

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



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


NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.