This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Mike, I've appended a patch file for all the small bugfs discovered so far in the netcdf C++ interface. Please let me know if you run into any more. Thanks. --Russ *** c++old/ncvalues.cc Tue Feb 22 12:29:22 1994 --- c++/ncvalues.cc Fri Aug 6 11:13:59 1993 *************** *** 4,10 **** * * Purpose: implementation of classes of typed arrays for netCDF * ! * $Header: /a/zero/home/russ/src/netcdf/c++/RCS/ncvalues.cc,v 1.9 1993/04/15 21:41:40 russ Exp $ *********************************************************************/ #include <iostream.h> // for debugging --- 4,10 ---- * * Purpose: implementation of classes of typed arrays for netCDF * ! * $Header: /home/russ/src/netcdf/c++/RCS/ncvalues.cc,v 1.10 1993/08/06 17:13:55 russ Exp $ *********************************************************************/ #include <iostream.h> // for debugging *************** *** 154,165 **** inline char* NcValues_ncbyte::as_string( int n ) const { ! return strdup((char*)the_values + n); } inline char* NcValues_char::as_string( int n ) const { ! return strdup(the_values + n); } ostream& NcValues_short::print(ostream& os) const --- 154,171 ---- inline char* NcValues_ncbyte::as_string( int n ) const { ! char *s = new char[the_number + 1]; ! s[the_number] = '\0'; ! strncpy(s, (const char *)the_values + n, (int)the_number); ! return s; } inline char* NcValues_char::as_string( int n ) const { ! char *s = new char[the_number + 1]; ! s[the_number] = '\0'; ! strncpy(s, (const char *)the_values + n, (int)the_number); ! return s; } ostream& NcValues_short::print(ostream& os) const diff -cr c++old/ncvalues.hh c++/ncvalues.hh *** c++old/ncvalues.hh Tue Feb 22 12:29:22 1994 --- c++/ncvalues.hh Fri Jul 23 14:39:32 1993 *************** *** 4,10 **** * * Purpose: interface for classes of typed arrays for netCDF * ! * $Header: /a/zero/home/russ/src/netcdf/c++/RCS/ncvalues.hh,v 1.8 1993/04/15 21:41:18 russ Exp $ *********************************************************************/ #ifndef Ncvalues_def --- 4,10 ---- * * Purpose: interface for classes of typed arrays for netCDF * ! * $Header: /home/russ/src/netcdf/c++/RCS/ncvalues.hh,v 1.8 1993/04/15 21:41:18 russ Exp russ $ *********************************************************************/ #ifndef Ncvalues_def diff -cr c++old/netcdf.cc c++/netcdf.cc *** c++old/netcdf.cc Tue Feb 22 12:29:22 1994 --- c++/netcdf.cc Tue Feb 22 11:10:32 1994 *************** *** 4,10 **** * * Purpose: Implements class interface for netCDF over C interface * ! * $Header: /a/zero/home/russ/src/netcdf/c++/RCS/netcdf.cc,v 1.42 1993/04/25 16:24:28 russ Exp $ *********************************************************************/ #include <string.h> --- 4,10 ---- * * Purpose: Implements class interface for netCDF over C interface * ! * $Header: /home/russ/src/netcdf/c++/RCS/netcdf.cc,v 1.46 1994/02/22 18:09:42 russ Exp $ *********************************************************************/ #include <string.h> *************** *** 206,212 **** return ncsetfill(the_id, a_mode) != ncBad; } ! enum NcFile::FillMode NcFile::get_fill( void ) { int mode = ncsetfill(the_id, Fill); if (mode == NC_FILL) --- 206,212 ---- return ncsetfill(the_id, a_mode) != ncBad; } ! NcFile::FillMode NcFile::get_fill( void ) { int mode = ncsetfill(the_id, Fill); if (mode == NC_FILL) *************** *** 491,496 **** --- 491,500 ---- NcAtt * NcVar::get_att( NcToken aname ) const { NcAtt* att = new NcAtt(the_file, this, aname); + if (! att->is_valid()) { + delete att; + return 0; + } return att; } *************** *** 560,565 **** --- 564,570 ---- return ncvarput(the_file->id(), the_id, start, count, vals) != ncBad; \ } + NcVar_put_array(ncbyte) NcVar_put_array(char) NcVar_put_array(short) NcVar_put_array(long) *************** *** 580,585 **** --- 585,591 ---- return ncvarput(the_file->id(), the_id, start, count, vals) != ncBad; \ } + NcVar_put_nd_array(ncbyte) NcVar_put_nd_array(char) NcVar_put_nd_array(short) NcVar_put_nd_array(long) *************** *** 619,624 **** --- 625,631 ---- return ncvarget(the_file->id(), the_id, start, count, vals) != ncBad; \ } + NcVar_get_array(ncbyte) NcVar_get_array(char) NcVar_get_array(short) NcVar_get_array(long) *************** *** 639,644 **** --- 646,652 ---- return ncvarget(the_file->id(), the_id, start, count, vals) != ncBad; \ } + NcVar_get_nd_array(ncbyte) NcVar_get_nd_array(char) NcVar_get_nd_array(short) NcVar_get_nd_array(long) *************** *** 670,675 **** --- 678,684 ---- return TRUE; } } + return TRUE; } NcBool NcVar::set_cur(long *cur) *************** *** 847,853 **** NcBool NcAtt::is_valid( void ) const { return the_file->is_valid() && ! the_variable->is_valid() && ncattinq(the_file->id(), the_variable->id(), the_name, 0, 0) != ncBad; } --- 856,862 ---- NcBool NcAtt::is_valid( void ) const { 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 -cr c++old/netcdf.hh c++/netcdf.hh *** c++old/netcdf.hh Tue Feb 22 12:29:22 1994 --- c++/netcdf.hh Tue Feb 22 11:10:47 1994 *************** *** 4,10 **** * * Purpose: C++ class interface for netCDF * ! * $Header: /a/zero/home/russ/src/netcdf/c++/RCS/netcdf.hh,v 1.39 1993/04/25 16:23:51 russ Exp $ *********************************************************************/ #ifndef NETCDF_HH --- 4,10 ---- * * Purpose: C++ class interface for netCDF * ! * $Header: /home/russ/src/netcdf/c++/RCS/netcdf.hh,v 1.40 1993/12/07 16:17:48 russ Exp $ *********************************************************************/ #ifndef NETCDF_HH *************** *** 241,246 **** --- 241,248 ---- // exceed variable\'s dimensionality. Start corner is [0,0,..., 0] by // default, but may be reset using the set_cur() member. FALSE is // 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, long c0=0, long c1=0, long c2=0, long c3=0, long c4=0 ); NcBool put( const short* vals, *************** *** 256,261 **** --- 258,264 ---- // Put n-dimensional arrays, starting at [0, 0, ..., 0] by default, // may be reset with set_cur(). + NcBool put( const ncbyte* vals, const long* counts ); NcBool put( const char* vals, const long* counts ); NcBool put( const short* vals, const long* counts ); NcBool put( const long* vals, const long* counts ); *************** *** 267,272 **** --- 270,277 ---- // arguments. Arguments are edge lengths, and their number must not // exceed variable\'s dimensionality. Start corner is [0,0,..., 0] by // 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, long c2=0, long c3=0, long c4=0 ) const; NcBool get( short* vals, long c0=0, long c1=0, *************** *** 282,287 **** --- 287,293 ---- // Get n-dimensional arrays, starting at [0, 0, ..., 0] by default, // may be reset with set_cur(). + NcBool get( ncbyte* vals, const long* counts ) const; NcBool get( char* vals, const long* counts ) const; NcBool get( short* vals, const long* counts ) const; NcBool get( long* vals, const long* counts ) const;