Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

[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
russ@xxxxxxxxxxxxxxxx                     http://www.unidata.ucar.edu



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


 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Office of Programs University Corporation for Atmospheric Research (UCAR)   Unidata is a member of the UCAR Office of Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690