[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nc_inq_varndims
- Subject: Re: nc_inq_varndims
- Date: Wed, 09 Aug 2006 11:19:50 -0600
"Chad Saxon, Contractor" <address@hidden> writes:
> I am thinking I have use nc_inq_vardimid to get info about the variables
> dimensions or more specifically what dimensions are used by a certain
> variable?
>
For simplicity I suggest you use nc_inq, nc_inq_dim, nc_inq_var, and
nc_inq_att.
Those 4 functions tell you everything. Whatever you are not interested
in, just ignore. Any pointer parameter of those functions can be
handed a NULL if you don't care about that parameter.
To find out about a var:
EXTERNL int
nc_inq_var(int ncid, int varid, char *name, nc_type *xtypep,
int *ndimsp, int *dimidsp, int *nattsp);
Use it like this:
int nvars, ndims, ngatts, unlimdimid;
int ncid, varid, ndims, dimids[NC_MAX_DIMS], natts;
char name[NC_MAX_NAME + 1];
nc_type xtype;
int v;
if (nc_open(PATH, 0, &ncid))
return 2;
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid))
return 2;
for (v = 0; v < nvars; v++)
{
if (nc_inq_var(ncid, v, name, &xtype, &ndims, dimids, &natts))
return 2;
/* Now use dimids... */
}
Let me know if this helps!
Ed
--
Ed Hartnett -- address@hidden