This is a patch number 4 for netCDF version 2.3.2. It updates the software to version 2.3.2pl4. Before applying this patch, you should first apply patch 3, available from ftp://ftp.unidata.ucar.edu/pub/netcdf/2.3.2-patch3 Patches 3 and 4 only correct problems in the experimental netCDF C++ interface; they are not needed if you are not using the C++ interface. Note that after applying patch3, you *must* remake the netCDF library from scratch (from the `configure' step), because the libsrc/netcdf.h file is regenerated by the `configure' script from one of the files changed by this patch. This patch accomplishes the following: BUG FIXES Fixed bug reported by Tom Glaess (and others) with NcVar::set_cur() not incrementing the record dimension properly. Minor changes to make the software compile with g++. Made virtual destructor for NcFile protected instead of =0 since it's not really pure. Revised the Makefile to create a library, not just an object file. Changed the type of the last argument in the interface of NcFile::add_var(), so an array of dimensions could be used when a variable has more than five dimensions. Fixed a memory leak in the NcFile::sync() member function. Changed NcVar::edges() to return a non-const, since it's sometimes useful to be able to modify the returned array for later use. This patch-file is designed to be applied from the top-level netcdf source directory via Larry Wall's patch(1) utility. So, after you have applied patch 3, for example, use something like the following: $ cd /usr/local/src/netcdf-2.3.2 $ patch < this_file =================================================================== diff -c1 -r oldc++/Makefile c++/Makefile *** oldc++/Makefile Sun Apr 25 10:17:39 1993 --- c++/Makefile Tue Jan 31 16:23:38 1995 *************** *** 1,2 **** ! # $Id: Makefile,v 1.10 1993/04/25 16:18:17 russ Exp $ # --- 1,2 ---- ! # $Id: Makefile,v 1.15 1995/01/31 21:16:50 russ Exp $ # *************** *** 5,13 **** ! INCDIR = ../libsrc ! LIBDIR = ../libsrc ! CCC = CC ! INCLUDES = -I$(INCDIR) ! CCFLAGS=-g MANIFEST = Makefile README example.c example.cc example.cdl \ --- 5,13 ---- ! INCDIR = ../libsrc ! LIBDIR = ../libsrc ! CCC = CC ! INCLUDES = -I$(INCDIR) ! CCFLAGS = -g MANIFEST = Makefile README example.c example.cc example.cdl \ *************** *** 15,32 **** expected nc.txn nc.info ! DEFINES = ! CPPFLAGS = $(INCLUDES) $(DEFINES) ! LIBS = -L$(LIBDIR) -lnetcdf ! PURIFY = purify ! PRINTER = hpnp # a test program that uses some of the draft C++ interface PROG = nctst ! PROG_SRCS = netcdf.cc nctst.cc ncvalues.cc ! PROG_OBJS = netcdf.o nctst.o ncvalues.o ! all: $(PROG) ! $(PROG) : $(PROG_OBJS) ! $(LINK.cc) $(PROG_OBJS) $(LIBS) -o $@ test: expected $(PROG) --- 15,51 ---- expected nc.txn nc.info ! DEFINES = ! CPPFLAGS = $(INCLUDES) $(DEFINES) ! LIBRARY = netcdf_c++ ! LIBS = -L$(LIBDIR) -lnetcdf -L. -l$(LIBRARY) ! LIB_A = lib$(LIBRARY).a ! PURIFY = purify + LIB_SRCS = netcdf.cc ncvalues.cc + LIB_OBJS = netcdf.o ncvalues.o + + .SUFFIXES: + .SUFFIXES: .o .cc + + # Compile C++ code. + # + .cc.o: + $(CCC) -c $(CCFLAGS) $(CPPFLAGS) $< + # a test program that uses some of the draft C++ interface PROG = nctst ! PROG_SRCS = nctst.cc ! PROG_OBJS = nctst.o ! ! all: library $(PROG) ! library: $(LIB_A) ! $(PROG) : $(PROG_OBJS) $(LIB_A) ! $(CCC) $(PROG_OBJS) $(LIB_A) $(LIBS) -o $@ + $(LIB_A): $(LIB_OBJS) + $(AR) rcuv $@ $(LIB_OBJS) + # If ranlib isn't found, that's OK + -ranlib $@ + test: expected $(PROG) *************** *** 37,39 **** nctst.pure: $(PROG_OBJS) ! $(PURIFY) $(LINK.cc) $(PROG_OBJS) $(LIBS) -o $@ ./$@ --- 56,58 ---- nctst.pure: $(PROG_OBJS) ! $(PURIFY) $(LINK.cc) $(PROG_OBJS) $(LIB_A) $(LIBS) -o $@ ./$@ *************** *** 41,43 **** clean: ! rm -f $(PROG_OBJS) $(PROG) example.cdf *~ --- 60,62 ---- clean: ! -rm -f $(PROG_OBJS) $(PROG) $(LIB_OBJS) $(LIB_A) example.nc test.out *************** *** 50,54 **** nctst_src: nctst.cc netcdf.cc ncvalues.cc ! #load nctst.cc ! #load netcdf.cc ! #load ncvalues.cc #load -L../../lib ../../lib/libnetcdf.a --- 69,71 ---- nctst_src: nctst.cc netcdf.cc ncvalues.cc ! #load -I../libsrc nctst.cc netcdf.cc ncvalues.cc #load -L../../lib ../../lib/libnetcdf.a *************** *** 56,72 **** - nvtst: nvtst.o ncvalues.o - $(LINK.cc) -g -o $@ nvtst.cc ncvalues.o - - - nvtst_src: nvtst.cc ncvalues.cc - #load nvtst.cc - #load ncvalues.cc - #link - print: nctst.cc netcdf.hh netcdf.cc ncvalues.hh ncvalues.cc vgrind -s11 -lC++ -t nctst.cc netcdf.hh netcdf.cc ncvalues.hh \ ! ncvalues.cc | lpr -Phpnp nc.hc: nc.ps ! lpr -P$(PRINTER) nc.ps --- 73,80 ---- print: nctst.cc netcdf.hh netcdf.cc ncvalues.hh ncvalues.cc vgrind -s11 -lC++ -t nctst.cc netcdf.hh netcdf.cc ncvalues.hh \ ! ncvalues.cc | lpr nc.hc: nc.ps ! lpr nc.ps diff -c1 -r oldc++/netcdf.cc c++/netcdf.cc *** oldc++/netcdf.cc Tue Jan 31 14:08:35 1995 --- c++/netcdf.cc Tue Jan 31 12:48:59 1995 *************** *** 6,8 **** * ! * $Header: /upc/new/CVS/netcdf/c++/netcdf.cc,v 1.46 1994/02/22 18:09:42 russ Exp $ *********************************************************************/ --- 6,8 ---- * ! * $Header: /upc/new/CVS/netcdf/c++/netcdf.cc,v 1.50 1995/01/31 17:10:58 russ Exp $ *********************************************************************/ *************** *** 162,164 **** ! NcVar* NcFile::add_var(NcToken name, NcType type, int ndims, const NcDim* dims) { --- 162,164 ---- ! NcVar* NcFile::add_var(NcToken name, NcType type, int ndims, const NcDim** dims) { *************** *** 168,170 **** for (int i=0; i < ndims; i++) ! dimids[i] = dims[i].id(); int n = num_vars(); --- 168,170 ---- for (int i=0; i < ndims; i++) ! dimids[i] = dims[i]->id(); int n = num_vars(); *************** *** 220,229 **** ! NcBool NcFile::sync( void ) { if (ncsync(the_id) == ncBad) return 0; - for (int i = 0; i < num_dims(); i++) - dimensions[i] = new NcDim(this, i); - for (i = 0; i < num_vars(); i++) - variables[i] = new NcVar(this, i); return 1; --- 220,227 ---- ! NcBool NcFile::sync( void ) // Flushes writes to disk. { + if (! data_mode()) + return 0; if (ncsync(the_id) == ncBad) return 0; return 1; *************** *** 471,473 **** ! const long* NcVar::edges( void ) const // edge lengths (dimension sizes) { --- 469,471 ---- ! long* NcVar::edges( void ) const // edge lengths (dimension sizes) { *************** *** 575,577 **** #define NcVar_put_nd_array(TYPE) \ ! NcBool NcVar::put( const TYPE* vals, const long* count ) \ { \ --- 573,575 ---- #define NcVar_put_nd_array(TYPE) \ ! NcBool NcVar::put( const TYPE* vals, const long* count ) \ { \ *************** *** 636,638 **** #define NcVar_get_nd_array(TYPE) \ ! NcBool NcVar::get( TYPE* vals, const long* count ) const \ { \ --- 634,636 ---- #define NcVar_get_nd_array(TYPE) \ ! NcBool NcVar::get( TYPE* vals, const long* count ) const \ { \ *************** *** 671,673 **** for (int i = 0; i < j; i++) { ! if (t[i] >= get_dim(i)->size()) return FALSE; // too big for dimension --- 669,671 ---- for (int i = 0; i < j; i++) { ! if (t[i] >= get_dim(i)->size() && ! get_dim(i)->is_unlimited()) return FALSE; // too big for dimension *************** *** 686,688 **** for(int i = 0; i < num_dims(); i++) { ! if (cur[i] >= get_dim(i)->size()) return FALSE; --- 684,686 ---- for(int i = 0; i < num_dims(); i++) { ! if (cur[i] >= get_dim(i)->size() && ! get_dim(i)->is_unlimited()) return FALSE; diff -c1 -r oldc++/netcdf.hh c++/netcdf.hh *** oldc++/netcdf.hh Tue Jan 31 14:08:35 1995 --- c++/netcdf.hh Tue Jan 31 12:48:59 1995 *************** *** 6,8 **** * ! * $Header: /upc/new/CVS/netcdf/c++/netcdf.hh,v 1.40 1993/12/07 16:17:48 russ Exp $ *********************************************************************/ --- 6,8 ---- * ! * $Header: /upc/new/CVS/netcdf/c++/netcdf.hh,v 1.43 1995/01/31 17:10:59 russ Exp $ *********************************************************************/ *************** *** 12,14 **** --- 12,16 ---- + extern "C" { #include "netcdf.h" // the C interface + } #include "ncvalues.hh" // arrays that know their element type *************** *** 33,37 **** - // Pure destructor used to make this an abstract base class. - virtual ~NcFile( void )=0; - NcBool is_valid( void ) const; // opened OK in ctr, still valid --- 35,36 ---- *************** *** 63,65 **** NcVar* add_var( NcToken varname, NcType type, // n-dim ! int ndims, const NcDim* dims ); --- 62,64 ---- NcVar* add_var( NcToken varname, NcType type, // n-dim ! int ndims, const NcDim** dims ); *************** *** 98,99 **** --- 97,102 ---- protected: + + // Protected destructor used to make this an abstract base class. + virtual ~NcFile( void ); + int the_id; *************** *** 231,233 **** NcDim* get_dim( int ) const; // n-th dimension ! const long* edges( void ) const; // dimension sizes int num_atts( void ) const; // number of attributes --- 234,236 ---- NcDim* get_dim( int ) const; // n-th dimension ! long* edges( void ) const; // dimension sizes int num_atts( void ) const; // number of attributes *************** *** 334,337 **** // to make variables, since constructor is private ! friend NcOldFile::NcOldFile( const char *, OpenMode ); ! friend NcNewFile::NcNewFile( const char *, CreateMode ); friend NcBool NcFile::sync( void ); --- 337,340 ---- // to make variables, since constructor is private ! friend NcOldFile::NcOldFile( const char *, NcOldFile::OpenMode ); ! friend NcNewFile::NcNewFile( const char *, NcNewFile::CreateMode ); friend NcBool NcFile::sync( void ); *************** *** 344,346 **** friend NcVar* NcFile::add_var( NcToken, NcType, int, ! const NcDim* ); }; --- 347,349 ---- friend NcVar* NcFile::add_var( NcToken, NcType, int, ! const NcDim** ); }; *************** *** 375,378 **** // To make attributes, since constructor is private ! friend NcOldFile::NcOldFile( const char *, OpenMode ); ! friend NcNewFile::NcNewFile( const char *, CreateMode ); friend NcAtt* NcVar::get_att( NcToken ) const; --- 378,381 ---- // To make attributes, since constructor is private ! friend NcOldFile::NcOldFile( const char *, NcOldFile::OpenMode ); ! friend NcNewFile::NcNewFile( const char *, NcNewFile::CreateMode ); friend NcAtt* NcVar::get_att( NcToken ) const;