NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: [netcdfgroup] need to id netcdf files

Hi, Jim,

We can add two new functions in pnetcdf library:

int ncmpi_inq_format      (int   ncid,     int *formatp);
int ncmpi_inq_file_format (char *filename, int *formatp);

The return argument "formatp" will be a constant defined in pnetcdf.h.
Currently we have
#define NC_FORMAT_CLASSIC    1
#define NC_FORMAT_64BIT      2
#define NC_FORMAT_64BIT_DATA 5

Since netcdf4 is in HDF5 format, as Russ pointed out, it may not
be as simple to report and return NC_FORMAT_NETCDF4 and
NC_FORMAT_NETCDF4_CLASSIC.

But, we can add
#define NC_FORMAT_UNKNOWN -1
for formats other than the above already-defined three.

Wei-keng

On Feb 2, 2010, at 11:17 AM, Jim Edwards wrote:

Hi Russ,


Maybe I can distill the essence of this function since my goal is to use it before I call the netcdf open function.


I think that 64-bit-offset is the pnetcdf format that I was referring to.

Thanks for the hint about hdf5 files.


- Jim


On Tue, Feb 2, 2010 at 9:58 AM, Russ Rew <russ@xxxxxxxxxxxxxxxx> wrote:
Jim,

> I am in need of a function that can identify a file as netcdf3, netcdf4, or
> pnetcdf 64-bit.
> Preferably I would like this function to work without having linked any of
> the mentioned netcdf libraries.
>
> Does anyone have or know of one?

Although it doesn't match your preference for independence from netCDF
libraries, the nc_inq_format() function documented here:

 
http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c.html#nc_005finq-Family

distinguishes among the 4 netCDF format variants:

 http://www.unidata.ucar.edu/software/netcdf/docs/faq.html#fv1

in the netCDF-4 library or between classic and 64-bit-offset formats in
a netCDF-3 library.  It doesn't recognize the pnetcdf 64-bit variant.

By the way, an HDF5 file can't necessarily be distinguished by its first
4 bytes, because HDF5 files may begin with a "user-block" of size 512,
1024, 2048, ... bytes, before the 4-byte file-type signature.

--Russ




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