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

Re: netCDF 2.32 patch 2; C++ Interface netCDF



> Organization: Institut fuer Flugmechanik
> Keywords: 199408031103.AA26413 netCDF 2.32 patch 2 C++
> From: address@hidden (Frank Dzaak)

Hi Frank,

> While compiling the test in the directory c++, I must change the
> c++ source of the netCDF interface to get it compiled.
> 
> netCDF Version: 2.3patch2
> Compiler      : gcc 2.5.8
> 
> Required Changes:
> 1.) ncvalues.hh, line 20: "typedef unsigned char ncbyte" redefines
> ncbyte, already defined as "typedef char ncbytes"-> remove definition in
> ncvalues.hh

Actually the definition in ncvalues.h should be removed instead.  See the
appended patch, available via anonymous FTP as pub/netcdf/2.3.2-patch3 on
ftp.unidata.ucar.edu, which has other patches for the experimental C++
interface as well.

> 2.) netcdf.cc, line 209: instead of:
> enum NcFile::FillMode NcFile::get_file/void)
> gcc requires
> NcFile::FillMode NcFile::get_file/void)
> (does not seem logically to me, c++ is sometimes strange)

This is also fixed in the appended patch.  I will soon be changing the
distribution to incorporate these patches.  Thanks for reporting the
problems.

--
Russ Rew                                                   UCAR Unidata Program
address@hidden                                             P.O. Box 3000
http://www.unidata.ucar.edu/                             Boulder, CO 80307-3000

-------------------------------------------------------------------------
This is a patch for the experimental C++ interface to netCDF in version
2.3.2pl2 (April 1994).

This patch accomplishes the following:

BUG FIXES

    A bug in netcdf.h that prevented correct compilation of the experimental
    C++ interface is fixed by removing typedefs for ncchar, ncbyte, ncshort,
    ncfloat, and ncdouble.

    Fixed off-by-one problem with strings reported by Tom Lefebvre.

    Minor changes to work with g++.

    Added put and get functions for ncbyte arrays.

    Fixed a bug in NcVar::get_att(NcToken) member, to make it return 0 for
    attributes that don't exist.    

    NcAtt::is_valid() had been returning FALSE for global attributes, but this
    fix makes it return TRUE when appropriate.

This patch-file is designed to be applied from the top-level netcdf source
directory via Larry Wall's patch(1) utility, e.g.

        $ cd /usr/local/src/netcdf-2.3.2
        $ patch < this_file

===================================================================
diff -c1 -r libsrc/netcdf.h.in
*** oldlibsrc/netcdf.h.in       Tue Jun  8 13:20:36 1993
--- libsrc/netcdf.h.in  Wed Jul 21 12:36:23 1993
***************
*** 16,18 ****
   */
! /* "$Id: netcdf.h.in,v 1.3 1993/06/08 19:22:22 steve Exp $" */
  
--- 16,18 ----
   */
! /* "$Id: netcdf.h.in,v 1.4 1993/07/21 18:36:23 steve Exp $" */
  
***************
*** 278,282 ****
   */
- typedef char  ncchar;
- typedef char  ncbyte;
- typedef short ncshort;
  #ifdef __alpha
--- 278,279 ----
***************
*** 291,294 ****
  #undef        NCLONG_DEFINED
- typedef float ncfloat;
- typedef double        ncdouble;
  
--- 288,289 ----
diff -c1 -r c++/ncvalues.cc
*** oldc++/ncvalues.cc  Thu Apr 15 15:41:03 1993
--- c++/ncvalues.cc     Fri Aug  6 11:13:55 1993
***************
*** 6,8 ****
   *
!  *   $Header: /a/zero/home/russ/src/netcdf/c++/RCS/ncvalues.cc,v 1.9 
1993/04/15 21:41:40 russ Exp $
   *********************************************************************/
--- 6,8 ----
   *
!  *   $Header: /upc/new/CVS/netcdf/c++/ncvalues.cc,v 1.10 1993/08/06 17:13:55 
russ Exp $
   *********************************************************************/
***************
*** 156,158 ****
  {
!     return strdup((char*)the_values + n);
  }
--- 156,161 ----
  {
!     char *s = new char[the_number + 1];
!     s[the_number] = '\0';
!     strncpy(s, (const char *)the_values + n, (int)the_number);
!     return s;
  }
***************
*** 161,163 ****
  {
!     return strdup(the_values + n);
  }
--- 164,169 ----
  {
!     char *s = new char[the_number + 1];
!     s[the_number] = '\0';
!     strncpy(s, (const char *)the_values + n, (int)the_number);
!     return s;
  }
diff -c1 -r c++/netcdf.cc
*** oldc++/netcdf.cc    Sun Apr 25 10:23:53 1993
--- c++/netcdf.cc       Tue Feb 22 11:09:42 1994
***************
*** 6,8 ****
   *
!  *   $Header: /a/zero/home/russ/src/netcdf/c++/RCS/netcdf.cc,v 1.42 
1993/04/25 16:24:28 russ Exp $
   *********************************************************************/
--- 6,8 ----
   *
!  *   $Header: /upc/new/CVS/netcdf/c++/netcdf.cc,v 1.46 1994/02/22 18:09:42 
russ Exp $
   *********************************************************************/
***************
*** 208,210 ****
  
! enum NcFile::FillMode NcFile::get_fill( void )
  {
--- 208,210 ----
  
! NcFile::FillMode NcFile::get_fill( void )
  {
***************
*** 493,494 ****
--- 493,498 ----
      NcAtt* att = new NcAtt(the_file, this, aname);
+     if (! att->is_valid()) {
+       delete att;
+       return 0;
+     }
      return att;
***************
*** 562,563 ****
--- 566,568 ----
  
+ NcVar_put_array(ncbyte)
  NcVar_put_array(char)
***************
*** 582,583 ****
--- 587,589 ----
  
+ NcVar_put_nd_array(ncbyte)
  NcVar_put_nd_array(char)
***************
*** 621,622 ****
--- 627,629 ----
  
+ NcVar_get_array(ncbyte)
  NcVar_get_array(char)
***************
*** 641,642 ****
--- 648,650 ----
  
+ NcVar_get_nd_array(ncbyte)
  NcVar_get_nd_array(char)
***************
*** 672,673 ****
--- 680,682 ----
      }
+     return TRUE;
  }
***************
*** 849,851 ****
      return the_file->is_valid() &&
!       the_variable->is_valid() &&
        ncattinq(the_file->id(), the_variable->id(), the_name, 0, 0) != ncBad;
--- 858,860 ----
      return the_file->is_valid() &&
!       (the_variable->id() == NC_GLOBAL || the_variable->is_valid()) &&
        ncattinq(the_file->id(), the_variable->id(), the_name, 0, 0) != ncBad;
diff -c1 -r c++/netcdf.hh
*** oldc++/netcdf.hh    Sun Apr 25 10:23:11 1993
--- c++/netcdf.hh       Tue Dec  7 09:17:48 1993
***************
*** 6,8 ****
   *
!  *   $Header: /a/zero/home/russ/src/netcdf/c++/RCS/netcdf.hh,v 1.39 
1993/04/25 16:23:51 russ Exp $
   *********************************************************************/
--- 6,8 ----
   *
!  *   $Header: /upc/new/CVS/netcdf/c++/netcdf.hh,v 1.40 1993/12/07 16:17:48 
russ Exp $
   *********************************************************************/
***************
*** 243,244 ****
--- 243,246 ----
      // returned if type of values does not match type for variable.
+     NcBool put( const ncbyte* vals,
+                 long c0=0, long c1=0, long c2=0, long c3=0, long c4=0 );
      NcBool put( const char* vals,
***************
*** 258,259 ****
--- 260,262 ----
      // may be reset with set_cur().
+     NcBool put( const ncbyte* vals, const long* counts );
      NcBool put( const char* vals, const long* counts );
***************
*** 269,270 ****
--- 272,275 ----
      // default, but may be reset using the set_cur() member.
+     NcBool get( ncbyte* vals, long c0=0, long c1=0,
+                 long c2=0, long c3=0, long c4=0 ) const;
      NcBool get( char* vals, long c0=0, long c1=0,
***************
*** 284,285 ****
--- 289,291 ----
      // may be reset with set_cur().
+     NcBool get( ncbyte* vals, const long* counts ) const;
      NcBool get( char* vals, const long* counts ) const;