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

[netCDF #OEB-334875]: Problem when retrieving dimensions of x



Hi Christian,

I'm not sure, but I think you are not distinguishing between the netCDF
dimension named "x" and the netCDF variable named "x".  The dimension
named "x" has a dimension id that may be different from the variable id
of the variable named "x", because these are different objects.

In your program, you use "xid" to hold the dimension ID:

  istat = nc_inq_dimid(ncid, "x", &xid);  /* get ID for x dimension */

but later use xid as if it were a variable ID:

  istat = nc_get_vara_int(ncid,xid,start,count,x);

To get the variable ID of the variable named "x", you would need to call

  istat = nc_inq_varid(ncid, "x", &xvarid)

Since the variable IDs are used more than the dimension IDs, in our
examples we usually use "xid" for the ID of the variable "x" and
"xdimid" for the dimension ID of the dimension named "x".

Using the same name for a dimension and variable to indicate a coordinate
variable can be useful, but it can also cause confusion, unless you are
careful to distinguish between the two objects named "x".

If this is not the problem, please let us know.  Thanks.

--Russ

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



Ticket Details
===================
Ticket ID: OEB-334875
Department: Support netCDF
Priority: Normal
Status: Closed