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

[netCDF #MSV-188900]: C++ API for NETCDF version 4.0



Hi Lynton,

> I am currently implementing an interface to NETCDF-4 for my C++ code. I
> am intending to use the NETCDF C++ API, however, an initial examination
> of it suggests to me that it requires some modifications. I would like
> to know whether you would agree to me making any modifications to the
> API. I would of course be very happy for anything I do to be
> incorporated into the NETCDF unidata library.  Please let me know if you
> know of anyone else doing this same work, as I would prefer not to be
> repeating work done by others.

Yes, the netCDF C++ API was developed in the mid 90's before
exceptions, namespaces, or templates were standardized, and it's been
somewhat neglected since we have concentrated on the Java, C, and
Fortran interfaces.

We had a student work on bringing the netCDF-4 C++ API up to date, but
the work was not completed.  However, the result is in the "cxx4/"
directory of the netCDF-4 release, so you can see what namespaces were
used and how exception handling was added.  Since then, we have made
some small updates to the released source in the cxx/ directory to add
API support for some of the netCDF-4 features, but that is not
complete yet either.

> For information, the issues I have observed so far are as follows:
> (1) the C++ API defines chunking on file opening (using nc__open).
> This seems to be unnecessary. I propose to replace the call to nc__open
> with nc_open.

Unfortunately, the "chunksize" referred to as the parameter name for nc__open
has absolutely nothing to do with the chunking (multidimensional tiling) of
HDF5 and netCDF-4.  That's because the nc__open parameters were named and
documented before HDF5 and netCDF-4.  However, we should change the name and
documentation to avoid the confusion this causes.

Chunking is a per-variable property rather than per-file or per session,
so it's actually not appropriate for specifying in an open call.  Instead,
it should be an optional parameter in the NcVar constructor.

> (2) The definition of the enum variables FileMode and FileFormat
> should be placed outside the NcFile object class.

That seems reasonable if there is a namespace for netCDF.

> (3) The C++ API should be enclosed within a namespace.

Yes, that's one of the things we had the student do on her summer project
of updating the C++ API.

> (4) Exception handling should be using try/throw/catch.

Yes, using exceptions is superior to the current interface, and I think
that's correctly implemented in the cxx4 sources.

If you wanted to take on updating the C++ interface, I think it would be
best to start with cxx4 and finish that implementation.  We would certainly
be inclined to include any changes in a future release.  We have in our
plans to finish the netCDF-4 update, but if you have to wait for us to
identify resources and finish the work, it may be a few years.

I had also heard of a graduate student in India who wanted to update the
C++ interface as a Master's thesis project, but I haven't heard about any
results from this, and suspect the project may have bee abandoned.

--Russ

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



Ticket Details
===================
Ticket ID: MSV-188900
Department: Support netCDF
Priority: Normal
Status: Closed