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

Re: 20030702:nc_inq functions in C++ interface?



>To: address@hidden
>From: John Zbesko <address@hidden>
>Subject: nc_inq functions in C++ interface?
>Organization: UCAR/Unidata
>Keywords: 200306242006.h5OK6kLd022253

Hi John,

> Thank you so much for suggesting the C++ beta version
> of the NetCDF API.
> 
> Are there analogs for the nc_inq group of C functions?
> For example, I have code to open a NetCDF database and
> determine the number of variables, but how do I find
> the name of the 5th variable?

In netcdfcpp.h or the C++ documentation, you can find the
NcFile::get_var method:

      NcVar* get_var( int ) const;           // n-th variable

with which you can get the 5th variable, by using the argument 5.

Then with that variable you can get the name, using the NcVar::name()
function.  See the example in the src/cxx/nctst.cpp file, which
includes the function 

  void DumpableNcFile::dumpvars( void )

that outputs all the variable names, similar to ncdump, using just the
C++ interface.

> NcFile nc (filename,NcFile::ReadOnly);
> int number_of_variables=nc.num_vars();
> QString variable5= ??????????
> 
> Or should I be using the C nc_inq functions and use
> the "id", as in nc.id()? 

No, you should not have to use anything from the C interface.  The C++
interface is intended to be an independent interface from which you
can do anything the C interface supports.

> Thank you for your help- or perhaps this is a question
> more appropriate to the mailing list?

The question is exactly appropriate for address@hidden, and
probably not ideal for the netcdfgroup mailing list, which is intended
more for announcements and discussion than questions about use.

--Russ

_____________________________________________________________________

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