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

Re: netCDF-3 compatability issues



> To: Russ Rew <address@hidden>
> Subject: Re: netCDF-3 compatability issues

Hi Mark,

> One of our netCDF C interface users has reported a potential problem
> because of the change to NC_CLOBBER,
> 
>   $ grep NC_CLOBBER /usr/local/include/netcdf.h # v3.3.1 include file
>   #define NC_CLOBBER      0
>   $ grep NC_NOWRIT /usr/local/include/netcdf.h
>   #define NC_NOWRITE      0       /* default is read only */
> 
> cf.
> 
>   $ grep NC_CLOBBER netcdf.h # old v2.4 include file
>   #define NC_CLOBBER   (NC_INDEF | NC_CREAT | NC_RDWR)
>   $ grep NC_NOWRITE netcdf.h
>   #define NC_NOWRITE   0
> 
> i.e., both NC_CLOBBER and NC_NOWRITE have the same value. This breaks
> her code, where she hda formerly done something like,
> 
> jac>          if (x == NC_CLOBBER) { then do something }
> jac>          else if (x == NC_NOWRITE) { do something else }
> 
> since the second block now never executes.
> 
> This code can be easily changed, but I'm wondering if the change was
> intentional.

Yes, the change was intentional.  The above logic looks like a symptom
of a conceptual error or "unwarranted chumminess" with the
implementation.  

There is no reason that NC_CLOBBER and NC_NOWRITE need to be distinct,
because they are used in different contexts.  The flags NC_CLOBBER and
NC_NOCLOBBER are used to specify the creation-mode when calling
nc_create to create a new netCDF file:

  int nc_create (const char* path, int cmode, int *ncidp);

The NC_WRITE and NC_NOWRITE flags are used to specify the open-mode when
calling nc_open to open an existing netCDF file:

  int nc_open (const char *path, int omode, int *ncidp);

(See http://www.unidata.ucar.edu/packages/netcdf/guidec/guidec-10.html
for more details)

If the documentation would lead a user to believe the values of
NC_CLOBBER and NC_NOWRITE are distinct in either netCDF-2 or netCDF-3,
that's a documentation bug we should correct.  But I couldn't find any
such problem with the documentation.

--Russ
_____________________________________________________________________

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

P.S.  If you send your netCDF questions to address@hidden,
      they'll get answered by someone else even when I'm on vacation
      next week.