Re: nc_inq_varndims


On Wed, 9 Aug 2006, Chad Saxon, Contractor wrote:

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

I think it should be nc_inq_varndims(ncid, i, &ndimsp);


   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





==============================================================================
To unsubscribe netcdfgroup, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================