nc_inq_varndims
Chad Saxon, Contractor
csaxon.ctr at navo.hpc.mil
Wed Aug 9 09:32:55 MDT 2006
Hi all I am trying to getting the number of dimensions per variable and
I
seem to have run into a wall.. in my netcdf code I have the following:
nc_inq_ndims(ncid, &ndims); //# of dimensions
nc_inq_nvars(ncid, &nvars); //# of variables
nc_inq_natts(ncid, &natts); //# of attributes
//for loop to print out all the dimension names
for(int i = 0; i < ndims; i++)
{
nc_inq_dimname(ncid, i, dim_name);
std::cout << "dimname[" << i << "] " << dim_name << endl;
}
//print out all the variable names
for(int i = 0; i < nvars; i++)
{
nc_inq_varname(ncid, i, var_name);
std::cout << "varname[" << i << "] " << var_name << endl;
}
//print out all the dimensions per variable
for(int i = 0; i < nvars; i++)
{std::cout << "test" << endl;
**** nc_inq_varndims(ncid, i, ndimsp); <-- I get a seg fault here
std::cout << "test" << endl;
std::cout << "varname[" << i << "] " << ndimsp << endl;
}
why does my nc_inq_varndims give me a seg fault? All my declarations are
correct and the loop above it worked just fine. Can someone tell me then
how
to get the number of dimensions per variable and how to access those
dimensions?
Thanks for your time..
****************
Chad
More information about the netcdfgroup
mailing list