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

Re: 971119: inconsistency in netCDF-3.3.1



> >From: Joseph VanAndel <address@hidden>
> >Subject: inconsistency in netCDF-3.3.1
> >Organization: NCAR/ATD
> >Keywords: 199711191649.JAA27108 netCDF 3.3.1
> 
> I'm trying to write a program using netCDF in C++ and have discovered 
> an inconsistency between the C++ and the C interfaces.
> 
> nc.c/nc_cktype() doesn't accept NC_LONG as a valid type.

Well actually it should, because in netcdf.h you will find the following:

    /*
     * If and when 64 integer types become ubiquitous,
     * we would like to use NC_LONG for that. 
     * For now, define for backward compatibility.
     */
    #define NC_LONG NC_INT

> However, the enumeration NcType in cxx/ncvalues.hh does contain 
> NC_LONG, but doesn't contain NC_INT.
> 
> Which is preferred?  NC_LONG or NC_INT?

NC_LONG is deprecated but still supported for backward compatibility.
The NetCDF-2 C Transition Guide (available from
    
<http://www.unidata.ucar.edu/packages/netcdf/guidec/guidec-20.html#HEADING20-0>)
 
says: 

    Where the netCDF-2 interface used NC_LONG to identify an external
    data type corresponding to 32-bit integers, the new interface uses
    NC_INT instead. NC_LONG is defined to have the same value as NC_INT
    for backward compatibility, but it should not be used in new
    code. With new 64-bit platforms using long for 64-bit integers, we
    would like to reduce the confusion caused by this name clash. Note
    that there is still no netCDF external data type corresponding to
    64-bit integers.

The C++ interface still supports the netCDF-2.4 typedef "nclong", which
was defined to be an int on most platforms but a long on a few.

We deprecated the use of "nclong" with the netCDF-3 release, but
unfortunately never updated the C++ interface to use NC_INT instead of
NC_LONG and "int" instead of "nclong".

I thought I had fixed this in a way that would keep backward
compatibility for our next release (3.4), but in researching your
question, I discovered some additional changes that need to be made.
The goal is to have interfaces overloaded for both int and long instead
of nclong.

For now, I'm afraid you'll have to use NC_LONG and cast (ugh) to nclong
to use the existing C++ interface for putting ints.  If you can wait a
week or two, we may have a beta test version with the necessary changes
incorporated.

--Russ