Re: [netcdfgroup] Determining format options available in netcdf library

  • To: "Russ Rew" <russ@xxxxxxxxxxxxxxxx>
  • Subject: Re: [netcdfgroup] Determining format options available in netcdf library
  • From: "Gregory Sjaardema" <gdsjaar@xxxxxxxxxx>
  • Date: Tue, 6 Sep 2011 09:47:45 -0600
On 9/6/11 9:38 AM, Russ Rew wrote:
Is there a way for an application linked to a netcdf library to
determine whether the netcdf-4 capabilities are present in the library?
Yes, but it's not exactly elegant :-)

#include<netcdf.h>

/* Returns 1 if linked to library with netCDF-4 features enabled, otherwise 0 */
int
is_netcdf4(void) {
     int ncid;
     int stat = nc_create("/tmp/tmp.nc", NC_NETCDF4,&ncid);
     if(stat == NC_ENOTNC)
        return 0;
     return 1;
}
OK, that was the only method I had come up with; I was hoping I was missing something.
I have an application that I want to normally write a classic netcdf-3
file, but if the netcdf library was compiled with the netcdf-4 option
enabled, it should create a netcdf-4 file.  It looks like the netcdf.h
file is the same for both options and I don't see any api function that
would give the information.
We'll consider adding such a function in addition to the current
nc_inq_libvers() function that returns a string for which version of the
library source was used to build the library, but doesn't specify with
which features the library was built.

--Russ
Thanks, that sounds like a good idea...

--Greg




  • 2011 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: