Repository: Unidata/netcdf-c
Pull request #1409 (2019-05-24 20:43:30)

Nccopy was overriding default chunking when it should not.
* Fixes https://github.com/Unidata/netcdf-c/issues/1398
re: esupport NDY-294972

The new chunking code added to nccopy missed one case.
In the event that there are no chunking specifications
of any kind, and the input is not netcdf-4, and the output
is netcdf-4 and must be chunked, then use the default chunking
that the library computes as part of the nc_def_var() function.

Misc. changes:
1. add some chunking debug code to hdf5var.c



Patch:
diff --git a/configure.ac b/configure.ac
index 6780273cc..4b57f6cf9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1386,11 +1386,6 @@ AC_MSG_WARN([netCDF-4 disabled => --disable-filter-testing])
 enable_filter_testing=no
 fi
 
-if test "x$enable_hdf5" = xno ; then
-AC_MSG_WARN([HDF5 disabled => --disable-filter-testing])
-enable_filter_testing=no
-fi
-
 if test "x$enable_shared" = xno ; then
 AC_MSG_WARN([Shared libraries are disabled => --disable-filter-testing])
 enable_filter_testing=no
diff --git a/include/ncdimscale.h b/include/ncdimscale.h
index c34b3ffd3..9a5d15333 100644
--- a/include/ncdimscale.h
+++ b/include/ncdimscale.h
@@ -11,7 +11,6 @@
 #ifndef _NCDIMSCALE_H_
 #define _NCDIMSCALE_H_
 
-#ifdef USE_HDF5
 #include <hdf5.h>
 
 /* This is used to uniquely identify datasets, so we can keep track of
@@ -21,6 +20,5 @@ typedef struct hdf5_objid
     unsigned long fileno[2]; /* file number */
     haddr_t objno[2]; /* object number */
 } HDF5_OBJID_T;
-#endif /* USE_HDF5 */
 
 #endif
diff --git a/libdispatch/dfilter.c b/libdispatch/dfilter.c
index ed541333e..26b2903bf 100644
--- a/libdispatch/dfilter.c
+++ b/libdispatch/dfilter.c
@@ -14,7 +14,7 @@
 #include "netcdf.h"
 #include "netcdf_filter.h"
 
-#ifdef USE_HDF5
+#ifdef USE_NETCDF4
 #include "hdf5internal.h"
 #endif
 
@@ -278,7 +278,7 @@ nc_filter_register(NC_FILTER_INFO* filter)
 	return NC_EINVAL;
     switch (filter->format) {
     case NC_FILTER_FORMAT_HDF5:
-#ifdef USE_HDF5
+#ifdef USE_NETCDF4
 	stat = nc4_filter_action(FILTER_REG, filter->format, filter->id, filter);
 #else
         stat = NC_ENOTBUILT;
@@ -296,7 +296,7 @@ nc_filter_unregister(int fformat, int id)
     int stat = NC_NOERR;
     switch (fformat) {
     case NC_FILTER_FORMAT_HDF5:
-#ifdef USE_HDF5
+#ifdef USE_NETCDF4
 	stat = nc4_filter_action(FILTER_UNREG, fformat, id, NULL);
 #else
         stat = NC_ENOTBUILT;
@@ -314,7 +314,7 @@ nc_filter_inq(int fformat, int id, NC_FILTER_INFO* filter_info)
     int stat = NC_NOERR;
     switch (fformat) {
     case NC_FILTER_FORMAT_HDF5:
-#ifdef USE_HDF5
+#ifdef USE_NETCDF4
 	stat = nc4_filter_action(FILTER_INQ, fformat, id, filter_info);
 #else
         stat = NC_ENOTBUILT;
diff --git a/libdispatch/dvarinq.c b/libdispatch/dvarinq.c
index b9dde5bce..a571bcbdc 100644
--- a/libdispatch/dvarinq.c
+++ b/libdispatch/dvarinq.c
@@ -618,13 +618,13 @@ nc_inq_ncid().
 
 \param varid Variable ID
 
-\param idp Storage which will get the filter id.
+\param idp Storage which will get the filter id; a return value of zero means no filter
 
 \param nparamsp Storage which will get the number of parameters to the
 filter
 
-\param params Storage which will get associated parameters. Note
-the caller must allocate and free.
+\param params Storage which will get associated parameters.
+Note: the caller must allocate and free.
 
 \returns ::NC_NOERR No error.
 \returns ::NC_ENOTNC4 Not a netCDF-4 file.
diff --git a/libhdf5/hdf5var.c b/libhdf5/hdf5var.c
index 6a0941682..bf571c1a7 100644
--- a/libhdf5/hdf5var.c
+++ b/libhdf5/hdf5var.c
@@ -1,3 +1,4 @@
+
 /* Copyright 2003-2019, University Corporation for Atmospheric
  * Research. See COPYRIGHT file for copying and redistribution
  * conditions.*/
@@ -9,11 +10,31 @@
  */
 
 #include "config.h"
-#ifdef USE_HDF5
 #include <hdf5internal.h>
-#endif
 #include <math.h> /* For pow() used below. */
 
+#ifdef LOGGING
+static void
+reportchunking(const char* title, NC_VAR_INFO_T* var)
+{
+    int i;
+    char buf[8192];
+
+    buf[0] = '\0'; /* for strlcat */
+    strlcat(buf,title,sizeof(buf));
+    strlcat(buf,"chunksizes for var ",sizeof(buf));
+    strlcat(buf,var->hdr.name,sizeof(buf));
+    strlcat(buf,"sizes=",sizeof(buf));
+    for(i=0;i<var->ndims;i++) {
+        char digits[64];
+        if(i > 0) strlcat(buf,",",sizeof(buf));
+        snprintf(digits,sizeof(digits),"%ld",(unsigned long)var->chunksizes[i]);
+	strlcat(buf,digits,sizeof(buf));
+    }
+    LOG((1,"%s",buf));
+}    
+#endif
+
 /** @internal Default size for unlimited dim chunksize. */
 #define DEFAULT_1D_UNLIM_SIZE (4096)
 
@@ -223,6 +244,9 @@ nc4_find_default_chunksizes2(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var)
         }
     }
 
+#ifdef LOGGING
+reportchunking("find_default: ",var);
+#endif
     return NC_NOERR;
 }
 
@@ -624,7 +648,7 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *deflate,
         return NC_ENOTVAR;
     assert(var && var->hdr.id == varid);
 
-    /* Can't turn on parallel and deflate/fletcher32/szip/shuffle. */
+    /* Can't turn on parallel and deflate/fletcher32/szip/shuffle (for now). */
     if (h5->parallel == NC_TRUE)
         if (deflate || fletcher32 || shuffle)
             return NC_EINVAL;
@@ -726,6 +750,12 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *deflate,
             return retval;
     }
 
+#ifdef LOGGING
+{int dfalt=(chunksizes == NULL);
+reportchunking(dfalt?"extra: default: ":"extra: user: ",var);
+}
+#endif
+
     /* Are we setting a fill modes? */
     if (no_fill)
     {
@@ -1008,6 +1038,10 @@ NC4_def_var_filter(int ncid, int varid, unsigned int id, size_t nparams,
     if (var->created)
         return NC_ELATEDEF;
 
+    /* Can't turn on parallel and filter (for now). */
+    if (h5->parallel == NC_TRUE)
+        return NC_EINVAL;
+
 #ifdef HAVE_H5Z_SZIP
     if(id == H5Z_FILTER_SZIP) {
         if(nparams != 2)
@@ -1038,6 +1072,17 @@ NC4_def_var_filter(int ncid, int varid, unsigned int id, size_t nparams,
         if(var->params == NULL) return NC_ENOMEM;
         memcpy(var->params,parms,sizeof(unsigned int)*var->nparams);
     }
+    /* Filter => chunking */
+    var->contiguous = NC_FALSE;
+    /* Determine default chunksizes for this variable unless already specified */
+    if(var->chunksizes && !var->chunksizes[0]) {
+        if((retval = nc4_find_default_chunksizes2(grp, var)))
+	    return retval;
+        /* Adjust the cache. */
+        if ((retval = nc4_adjust_var_cache(grp, var)))
+            return retval;
+    }
+
     return NC_NOERR;
 }
 
diff --git a/liblib/nc_initialize.c b/liblib/nc_initialize.c
index 7c708a4dd..d0cd3d89c 100644
--- a/liblib/nc_initialize.c
+++ b/liblib/nc_initialize.c
@@ -16,12 +16,12 @@ extern int NC3_finalize(void);
 
 #ifdef USE_NETCDF4
 #include "nc4internal.h"
+#include "hdf5internal.h"
 extern int NC4_initialize(void);
 extern int NC4_finalize(void);
 #endif
 
 #ifdef USE_HDF5
-#include "hdf5internal.h"
 extern int NC_HDF5_initialize(void);
 extern int NC_HDF5_finalize(void);
 #endif
diff --git a/libsrc4/nc4var.c b/libsrc4/nc4var.c
index 9aaef2e17..ff5a73ea3 100644
--- a/libsrc4/nc4var.c
+++ b/libsrc4/nc4var.c
@@ -13,9 +13,7 @@
 #include "config.h"
 #include <nc4internal.h>
 #include "nc4dispatch.h"
-#ifdef USE_HDF5
 #include "hdf5internal.h"
-#endif
 #include <math.h>
 
 /**
diff --git a/nc_perf/Makefile.am b/nc_perf/Makefile.am
index c75baa276..7186a4eb8 100644
--- a/nc_perf/Makefile.am
+++ b/nc_perf/Makefile.am
@@ -54,7 +54,7 @@ run_par_bm_test.log: tst_create_files.log
 endif # TEST_PARALLEL4
 endif # BUILD_UTILITIES
 
-EXTRA_DIST = run_par_bm_test.sh.in run_knmi_bm.sh CMakeLists.txt	\
+EXTRA_DIST = run_par_bm_test.sh.in run_knmi_bm.sh	\
 perftest.sh run_bm_test1.sh run_bm_test2.sh \
 CMakeLists.txt
 
diff --git a/ncdump/nccopy.c b/ncdump/nccopy.c
index 5a0b2e81e..b391a81d9 100644
--- a/ncdump/nccopy.c
+++ b/ncdump/nccopy.c
@@ -347,6 +347,28 @@ done:
     return stat;
 }
 
+static struct FilterSpec*
+filterspecforvar(const char* ofqn)
+{
+  int i;	 
+  struct FilterSpec* star = NULL;
+  struct FilterSpec* match = NULL;
+  /* See if any output filter spec is defined for this output variable */
+  /* Name specific overrides '*' */
+  for(i=0;i<listlength(filterspecs);i++) {
+      struct FilterSpec* spec = listget(filterspecs,i);
+      if(strcmp(spec->fqn,"*")==0)
+          star = spec; /* save */
+      if(strcmp(spec->fqn,ofqn)==0) {
+          match = spec;
+	  break;;
+      }
+  }
+  if(match) return match;
+  if(star) return star;
+  return NULL;
+}
+
 
 /* Return size of chunk in bytes for a variable varid in a group igrp, or 0 if
  * layout is contiguous */
@@ -721,7 +743,6 @@ copy_var_filter(int igrp, int varid, int ogrp, int o_varid, int inkind, int outk
     struct FilterSpec inspec;
     struct FilterSpec nospec;
     struct FilterSpec* actualspec = NULL;
-    int i;
     char* ofqn = NULL;
     int inputdefined, outputdefined, unfiltered;
     int innc4 = (inkind == NC_FORMAT_NETCDF4 || inkind == NC_FORMAT_NETCDF4_CLASSIC);
@@ -745,14 +766,9 @@ copy_var_filter(int igrp, int varid, int ogrp, int o_varid, int inkind, int outk
     /* Only bother to look if output is netcdf-4 variant */
     if(outnc4) {
       /* See if any output filter spec is defined for this output variable */
-      for(i=0;i<listlength(filterspecs);i++) {
-	  struct FilterSpec* spec = listget(filterspecs,i);
-          if(strcmp(spec->fqn,"*")==0 || strcmp(spec->fqn,ofqn)==0) {
-             ospec = spec;
-             outputdefined = 1;
-             break;
-	  }
-      }
+      ospec = filterspecforvar(ofqn);
+      if(ospec != NULL)
+          outputdefined = 1;
     }
 
     /* Is there a filter on the input variable */
@@ -762,26 +778,26 @@ copy_var_filter(int igrp, int varid, int ogrp, int o_varid, int inkind, int outk
       stat=nc_inq_var_filter(vid.grpid,vid.varid,&inspec.filterid,&inspec.nparams,NULL);
       if(stat && stat != NC_EFILTER)
 	    goto done; /* true error */
-      if(stat == NC_NOERR) {/* input has a filter */
+      if(stat == NC_NOERR && inspec.filterid > 0) {/* input has a filter */
   	    inspec.params = (unsigned int*)malloc(sizeof(unsigned int)*inspec.nparams);
 	    if((stat=nc_inq_var_filter(vid.grpid,vid.varid,&inspec.filterid,&inspec.nparams,inspec.params)))
-          goto done;
+	          goto done;
 	    inputdefined = 1;
       }
     }
 
     /* Rules for choosing output filter are as follows:
 
-	global		output		input	Actual Output
-	suppress	filter		filter	filter
-	-----------------------------------------------
-	true		undefined	NA	  unfiltered
-	true		'none'		NA	  unfiltered
-	true		defined		NA	  use output filter
-	false		undefined	defined	  use input filter
-	false		'none'		NA	  unfiltered
-	false		defined		NA	  use output filter
-	false		undefined	undefined unfiltered
+	   global	output		input	Actual Output
+	   suppress	filter		filter	filter
+	-----------------------------------------------------------
+	1  true		undefined	NA	  unfiltered
+	2  true		'none'		NA	  unfiltered
+	3  true		defined		NA	  use output filter
+	4  false	undefined	defined	  use input filter
+	5  false	'none'		NA	  unfiltered
+	6  false	defined		NA	  use output filter
+	7  false	undefined	undefined unfiltered
     */
 
     unfiltered = 0;
@@ -799,7 +815,7 @@ copy_var_filter(int igrp, int varid, int ogrp, int o_varid, int inkind, int outk
     else if(!suppressfilters && outputdefined) /* row 6 */
       actualspec = ospec;
     else if(!suppressfilters && !outputdefined && !inputdefined) /* row 7 */
-      actualspec = &nospec;
+      unfiltered = 1;
 
     /* Apply actual filter spec if any */
     if(!unfiltered) {
@@ -820,12 +836,15 @@ done:
 
 /* Propagate chunking from input to output taking -c flags into account. */
 /* Subsumes old set_var_chunked */
+/* Must make sure we do not override the default chunking when input is classic */
 static int
 copy_chunking(int igrp, int i_varid, int ogrp, int o_varid, int ndims, int inkind, int outkind)
 {
     int stat = NC_NOERR;
     int innc4 = (inkind == NC_FORMAT_NETCDF4 || inkind == NC_FORMAT_NETCDF4_CLASSIC);
     int outnc4 = (outkind == NC_FORMAT_NETCDF4 || outkind == NC_FORMAT_NETCDF4_CLASSIC);
+    VarID ovid;
+    char* ofqn = NULL;
 
     /* First, check the file kinds */
     if(!outnc4)
@@ -850,7 +869,8 @@ copy_chunking(int igrp, int i_varid, int ogrp, int o_varid, int ndims, int inkin
 	goto done;
     }
 
-    { /* Try dim-specific chunking */
+    /* See about dim-specific chunking and if any kind of filters are in place */
+    {
 	int idim;
 	/* size of a chunk: product of dimension chunksizes and size of value */
 	size_t csprod;
@@ -862,9 +882,9 @@ copy_chunking(int igrp, int i_varid, int ogrp, int o_varid, int ndims, int inkin
 	int icontig = 1;
 	int ocontig = 1; /* until proven otherwise */
 
-	/* See if chunking was suppressed */
+	/* See if dim-specific chunking was suppressed */
 	if(dimchunkspec_omit())
-	    goto done; /* do nothing */
+	    goto next2;
 
 	/* Setup for chunking */
 	typesize = val_size(ogrp, o_varid);
@@ -874,7 +894,12 @@ copy_chunking(int igrp, int i_varid, int ogrp, int o_varid, int ndims, int inkin
 	memset(&ochunkp,0,sizeof(ochunkp));
 
 	/* Get the chunking, if any, on the current input variable */
-	NC_CHECK(nc_inq_var_chunking(igrp, i_varid, &icontig, ichunkp));
+        if(innc4) {
+  	    NC_CHECK(nc_inq_var_chunking(igrp, i_varid, &icontig, ichunkp));
+	} else {
+	    icontig = 1;
+	    ichunkp[0] = 0;	    	
+	}
 	if(!icontig)
 	    ocontig = 0; /* If input is chunked, then so is output */
 
@@ -915,7 +940,7 @@ copy_chunking(int igrp, int i_varid, int ogrp, int o_varid, int ndims, int inkin
 		goto next;
 	    }
 
-            /* If input is netcdf-4 then use the input size as the chunk size;
+	    /* If input is not netcdf-4 then use the input size as the chunk size;
 		but do not force chunking.
              */
             if(!innc4) {
@@ -942,6 +967,14 @@ next:
 	    ocontig = 1; /* Force contiguous */
         }
 
+next2:
+	/* If any kind of output filter was specified, then we have to chunk */
+	ovid.grpid = ogrp;
+        ovid.varid = o_varid;
+	if((stat=computeFQN(ovid,&ofqn))) goto done;
+	if(option_deflate_level >= 0 || filterspecforvar(ofqn) != NULL)
+	    ocontig = 0;
+
 	/* Apply the chunking, if any */
 
 	if(ocontig) { /* We can use contiguous output */
@@ -949,8 +982,10 @@ next:
 	} else {
 	    NC_CHECK(nc_def_var_chunking(ogrp, o_varid, NC_CHUNKED, ochunkp));
 	}
-    }
+    } /* else no chunk spec at all, let defaults set at nc_def_var() be used */
+ 
 done:
+    if(ofqn) free(ofqn);
     return stat;
 }
 
diff --git a/ncdump/tst_nccopy5.sh b/ncdump/tst_nccopy5.sh
index e3311c327..ab9ce1a73 100755
--- a/ncdump/tst_nccopy5.sh
+++ b/ncdump/tst_nccopy5.sh
@@ -90,7 +90,6 @@ ${NCCOPY} -c ivar:7,1,2,1,5,1,9 tst_nc5.nc tmp_nc5.nc
 ${NCDUMP} -n tst_nc5 tmp_nc5.nc > tmp_nc5.cdl
 # Verify that the core cdl is the same
 diff tst_nc5.cdl tmp_nc5.cdl
-
 # Look at the output chunking of ivar
 rm -f tmp_nc5a.cdl # reuse
 ${NCDUMP} -hs -n tst_nc5 tmp_nc5.nc > tmp_nc5.cdl
@@ -99,7 +98,6 @@ TESTLINE=`sed -e '/ivar:_ChunkSizes/p' -e d <tmp_nc5.cdl`
 # track line to match
 BASELINE='ivar:_ChunkSizes = 7, 1, 2, 1, 5, 1, 9 ;'
 verifychunkline "$TESTLINE" "$BASELINE"
-
 # Make sure that fvar was not chunked
 checkfvar tmp_nc5.cdl
 
@@ -153,7 +151,7 @@ if test "x$T4" = x1 ; then
 
 echo "*** Test nccopy -c with unlimited dimension; classic ->enhanced"
 reset
-./tst_chunking tst_nc5.nc unlimited
+./tst_chunking tst_nc5.nc unlimited # should produce modified tmp_nc5.nc iwth ivar of rank 2
 ${NCDUMP} -n tst_nc5 tst_nc5.nc > tst_nc5.cdl
 ${NCCOPY} -c ivar:5,3 tst_nc5.nc tmp_nc5.nc
 ${NCDUMP} -n tst_nc5 tmp_nc5.nc > tmp_nc5.cdl


Test patch:
diff --git a/nc_test/Makefile.am b/nc_test/Makefile.am
index ceaf9ecda..736e9fa90 100644
--- a/nc_test/Makefile.am
+++ b/nc_test/Makefile.am
@@ -88,7 +88,6 @@ TESTS += test_byterange.sh
 endif
 if BUILD_MMAP
 TESTS += run_mmap.sh
-run_mmap.log: run_diskless.log
 endif
 endif
 
@@ -111,7 +110,7 @@ CMakeLists.txt
 CLEANFILES = nc_test_*.nc tst_*.nc t_nc.nc large_files.nc		\
 quick_large_files.nc tst_diskless3_file.cdl                             \
 tst_diskless4.cdl ref_tst_diskless4.cdl benchmark.nc                    \
-tst_http_nc3.cdl tst_http_nc4.cdl tmp*.cdl tmp*.nc
+tst_http_nc3.cdl tst_http_nc4.cdl
 
 EXTRA_DIST += bad_cdf5_begin.nc run_cdf5.sh
 if ENABLE_CDF5
diff --git a/nc_test4/test_filter_misc.c b/nc_test4/test_filter_misc.c
index 4eeb7bd58..0b7ff21f5 100644
--- a/nc_test4/test_filter_misc.c
+++ b/nc_test4/test_filter_misc.c
@@ -484,7 +484,7 @@ init(int argc, char** argv)
     totalproduct = 1;
     actualproduct = 1;
     chunkproduct = 1;
-    for(i=0;i<MAXDIMS;i++) {
+    for(i=0;i<NDIMS;i++) {
         if(pattern[i] == 1)
 	    chunksize[i] = 1;
         totalproduct *= dimsize[i];
diff --git a/nc_test4/test_filter_reg.c b/nc_test4/test_filter_reg.c
index a16d1989a..bbe59f107 100644
--- a/nc_test4/test_filter_reg.c
+++ b/nc_test4/test_filter_reg.c
@@ -469,7 +469,7 @@ init(int argc, char** argv)
     totalproduct = 1;
     actualproduct = 1;
     chunkproduct = 1;
-    for(i=0;i<MAXDIMS;i++) {
+    for(i=0;i<NDIMS;i++) {
 	totalproduct *= dimsize[i];
         if(i < ndims) {
             actualproduct *= dimsize[i];
diff --git a/nc_test4/tst_large2.c b/nc_test4/tst_large2.c
index 55fea5ec9..0a61e57ab 100644
--- a/nc_test4/tst_large2.c
+++ b/nc_test4/tst_large2.c
@@ -83,7 +83,7 @@ int main(int argc, char **argv)
 	       {
 		  if (data[j + LON_LEN * i] != (start[0] + i + j) % 19)
 		  {
-		     printf("error on start[0]: %ld i: %d j: %d expected %ld got %g\n",
+		     printf("error on start[0]: %ld i: %ld j: %ld expected %d got %g\n",
 			    start[0], i, j, (start[0] + i + j), data[j + LON_LEN * i]);
 		     ERR_RET;
 		  }
diff --git a/nc_test4/tst_rename2.c b/nc_test4/tst_rename2.c
index a86f7ffb1..3380263cd 100644
--- a/nc_test4/tst_rename2.c
+++ b/nc_test4/tst_rename2.c
@@ -275,8 +275,8 @@ main(int argc, char **argv)
    SUMMARIZE_ERR;
    fprintf(stderr,"*** test renaming affect on varids...");
    {
-      int ncid, varid1, varid2;
-      int varid_in;
+      int ncid, dimid1, dimid2, varid1, varid2;
+      int dimid_in, varid_in;
       char file_name[NC_MAX_NAME + 1];
 
       /* Create file with two scalar vars. */
diff --git a/nc_test4/tst_rename3.c b/nc_test4/tst_rename3.c
index 457f70f10..54f8cbb10 100644
--- a/nc_test4/tst_rename3.c
+++ b/nc_test4/tst_rename3.c
@@ -34,8 +34,8 @@ main(int argc, char **argv)
    fprintf(stderr,"Test more renaming.\n");
    fprintf(stderr,"*** test renaming affect on varids...");
    {
-      int ncid, varid1, varid2;
-      int varid_in;
+      int ncid, dimid1, dimid2, varid1, varid2;
+      int dimid_in, varid_in;
       char file_name[NC_MAX_NAME + 1];
 
       /* Create file with two scalar vars. */
@@ -60,99 +60,96 @@ main(int argc, char **argv)
       if (nc_close(ncid)) ERR;
    }
    SUMMARIZE_ERR;
-   fprintf(stderr,"*** test renaming coord var to non-coord var...");
-   {
-      int ncid, dimid1, dimid2, varid1, varid2;
-      int dimid_in, varid_in;
-      char file_name[NC_MAX_NAME + 1];
-
-      /* Create file with two dims and associated coordinate vars. */
-      sprintf(file_name, "%s_coord_to_non_coord.nc", TEST_NAME);
-      if (nc_create(file_name, NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR;
-      if (nc_def_dim(ncid, D1_NAME, DIM1_LEN, &dimid1)) ERR;
-      if (nc_def_dim(ncid, D2_NAME, DIM1_LEN, &dimid2)) ERR;
-      if (nc_def_var(ncid, D1_NAME, NC_INT, NDIM1, &dimid1, &varid1)) ERR;
-      if (nc_def_var(ncid, D2_NAME, NC_INT, NDIM1, &dimid2, &varid2)) ERR;
-      if (nc_close(ncid)) ERR;
-
-      /* Open the file and rename a var. */
-      nc_set_log_level(4);
-      if (nc_open(file_name, NC_WRITE, &ncid)) ERR;
-      if (nc_rename_var(ncid, varid1, TMP_NAME)) ERR;
-      if (nc_close(ncid)) ERR;
-
-      /* Reopen file and check, */
-      if (nc_open(file_name, NC_WRITE, &ncid)) ERR;
-      if (nc_inq_dimid(ncid, D1_NAME, &dimid_in)) ERR;
-      printf("dimid_in %d\n", dimid_in);
-      if (dimid_in != dimid1) ERR;
-      if (nc_inq_dimid(ncid, D2_NAME, &dimid_in)) ERR;
-      if (dimid_in != dimid2) ERR;
-      if (nc_inq_dimid(ncid, TMP_NAME, &dimid_in) != NC_EBADDIM) ERR;
-      if (nc_inq_varid(ncid, TMP_NAME, &varid_in)) ERR;
-      /* if (varid_in != varid1) ERR; */
-      if (nc_inq_varid(ncid, D1_NAME, &varid_in) != NC_ENOTVAR) ERR;
-      if (nc_close(ncid)) ERR;
-
-      /* This should work but does not (yet). */
-      /* if (nc_open(file_name, NC_WRITE, &ncid)) ERR; */
-      /* if (nc_rename_var(ncid, varid2, D1_NAME)) ERR; */
-      /* if (nc_close(ncid)) ERR; */
-
-      /* /\* Reopen file and check, *\/ */
-      /* if (nc_open(file_name, NC_WRITE, &ncid)) ERR; */
-      /* if (nc_inq_dimid(ncid, D1_NAME, &dimid_in)) ERR; */
-      /* if (dimid_in != dimid1) ERR; */
-      /* if (nc_inq_dimid(ncid, D2_NAME, &dimid_in)) ERR; */
-      /* if (dimid_in != dimid2) ERR; */
-      /* if (nc_inq_dimid(ncid, TMP_NAME, &dimid_in) != NC_EBADDIM) ERR; */
-      /* if (nc_inq_varid(ncid, TMP_NAME, &varid_in)) ERR; */
-      /* if (varid_in != varid1) ERR; */
-      /* if (nc_inq_varid(ncid, D1_NAME, &varid_in)) ERR; */
-      /* if (varid_in != varid2) ERR; */
-      /* if (nc_close(ncid)) ERR; */
-   }
-   SUMMARIZE_ERR;
-   fprintf(stderr,"*** test exchanging names of two coord vars, making them non-coord vars with names same as dims...");
-   {
-      int ncid, dimid1, dimid2, varid1, varid2;
-      /* int dimid_in; */
-      /* int varid_in; */
-      char file_name[NC_MAX_NAME + 1];
-
-      /* Create file with dim and associated coordinate var. */
-      sprintf(file_name, "%s_non_coord_to_dim.nc", TEST_NAME);
-      if (nc_create(file_name, NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR;
-      if (nc_def_dim(ncid, D1_NAME, DIM1_LEN, &dimid1)) ERR;
-      if (nc_def_dim(ncid, D2_NAME, DIM1_LEN, &dimid2)) ERR;
-      if (nc_def_var(ncid, D1_NAME, NC_INT, NDIM1, &dimid1, &varid1)) ERR;
-      if (nc_def_var(ncid, D2_NAME, NC_INT, NDIM1, &dimid2, &varid2)) ERR;
-      if (nc_close(ncid)) ERR;
-
-      /* Open the file and rename the vars. */
-      nc_set_log_level(4);
-      if (nc_open(file_name, NC_WRITE, &ncid)) ERR;
-      if (nc_rename_var(ncid, varid1, TMP_NAME)) ERR;
-      nc_sync(ncid);
-      /* This should work but doesn't yet. */
-      /* if (nc_rename_var(ncid, varid2, D1_NAME)) ERR; */
-      /* nc_sync(ncid); */
-      /* if (nc_rename_var(ncid, varid1, D2_NAME)) ERR; */
-      if (nc_close(ncid)) ERR;
-
-      /* Reopen file and check, this should work but doesnt yet. */
-      if (nc_open(file_name, NC_WRITE, &ncid)) ERR;
-      /* if (nc_inq_dimid(ncid, D1_NAME, &dimid_in)) ERR; */
-      /* if (dimid_in != dimid1) ERR; */
-      /* if (nc_inq_dimid(ncid, D2_NAME, &dimid_in)) ERR; */
-      /* if (dimid_in != dimid2) ERR; */
-      /* if (nc_inq_dimid(ncid, TMP_NAME, &dimid_in) != NC_EBADDIM) ERR; */
-      /* if (nc_inq_varid(ncid, TMP_NAME, &varid_in)) ERR; */
-      /* if (varid_in != varid1) ERR; */
-      /* if (nc_inq_varid(ncid, D1_NAME, &varid_in)) ERR; */
-      /* if (varid_in != varid2) ERR; */
-      if (nc_close(ncid)) ERR;
-   }
-   SUMMARIZE_ERR;
+   /* fprintf(stderr,"*** test renaming coord var to non-coord var..."); */
+   /* { */
+   /*    int ncid, dimid1, dimid2, varid1, varid2; */
+   /*    int dimid_in, varid_in; */
+   /*    char file_name[NC_MAX_NAME + 1]; */
+
+   /*    /\* Create file with two dims and associated coordinate vars. *\/ */
+   /*    sprintf(file_name, "%s_coord_to_non_coord.nc", TEST_NAME); */
+   /*    if (nc_create(file_name, NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR; */
+   /*    if (nc_def_dim(ncid, D1_NAME, DIM1_LEN, &dimid1)) ERR; */
+   /*    if (nc_def_dim(ncid, D2_NAME, DIM1_LEN, &dimid2)) ERR; */
+   /*    if (nc_def_var(ncid, D1_NAME, NC_INT, NDIM1, &dimid1, &varid1)) ERR; */
+   /*    if (nc_def_var(ncid, D2_NAME, NC_INT, NDIM1, &dimid2, &varid2)) ERR; */
+   /*    if (nc_close(ncid)) ERR; */
+
+   /*    /\* Open the file and rename a var. *\/ */
+   /*    nc_set_log_level(4); */
+   /*    if (nc_open(file_name, NC_WRITE, &ncid)) ERR; */
+   /*    if (nc_rename_var(ncid, varid1, TMP_NAME)) ERR; */
+   /*    if (nc_close(ncid)) ERR; */
+
+   /*    /\* Reopen file and check, *\/ */
+   /*    if (nc_open(file_name, NC_WRITE, &ncid)) ERR; */
+   /*    if (nc_inq_dimid(ncid, D1_NAME, &dimid_in)) ERR; */
+   /*    printf("dimid_in %d\n", dimid_in); */
+   /*    if (dimid_in != dimid1) ERR; */
+   /*    if (nc_inq_dimid(ncid, D2_NAME, &dimid_in)) ERR; */
+   /*    if (dimid_in != dimid2) ERR; */
+   /*    if (nc_inq_dimid(ncid, TMP_NAME, &dimid_in) != NC_EBADDIM) ERR; */
+   /*    if (nc_inq_varid(ncid, TMP_NAME, &varid_in)) ERR; */
+   /*    /\* if (varid_in != varid1) ERR; *\/ */
+   /*    if (nc_inq_varid(ncid, D1_NAME, &varid_in) != NC_ENOTVAR) ERR; */
+   /*    if (nc_close(ncid)) ERR; */
+
+   /*    /\* if (nc_open(file_name, NC_WRITE, &ncid)) ERR; *\/ */
+   /*    /\* if (nc_rename_var(ncid, varid2, D1_NAME)) ERR; *\/ */
+   /*    /\* if (nc_close(ncid)) ERR; *\/ */
+
+   /*    /\* /\\* Reopen file and check, *\\/ *\/ */
+   /*    /\* if (nc_open(file_name, NC_WRITE, &ncid)) ERR; *\/ */
+   /*    /\* if (nc_inq_dimid(ncid, D1_NAME, &dimid_in)) ERR; *\/ */
+   /*    /\* if (dimid_in != dimid1) ERR; *\/ */
+   /*    /\* if (nc_inq_dimid(ncid, D2_NAME, &dimid_in)) ERR; *\/ */
+   /*    /\* if (dimid_in != dimid2) ERR; *\/ */
+   /*    /\* if (nc_inq_dimid(ncid, TMP_NAME, &dimid_in) != NC_EBADDIM) ERR; *\/ */
+   /*    /\* if (nc_inq_varid(ncid, TMP_NAME, &varid_in)) ERR; *\/ */
+   /*    /\* if (varid_in != varid1) ERR; *\/ */
+   /*    /\* if (nc_inq_varid(ncid, D1_NAME, &varid_in)) ERR; *\/ */
+   /*    /\* if (varid_in != varid2) ERR; *\/ */
+   /*    /\* if (nc_close(ncid)) ERR; *\/ */
+   /* } */
+   /* SUMMARIZE_ERR; */
+   /* fprintf(stderr,"*** test exchanging names of two coord vars, making them non-coord vars with names same as dims..."); */
+   /* { */
+   /*    int ncid, dimid1, dimid2, varid1, varid2; */
+   /*    int dimid_in, varid_in; */
+   /*    char file_name[NC_MAX_NAME + 1]; */
+
+   /*    /\* Create file with dim and associated coordinate var. *\/ */
+   /*    sprintf(file_name, "%s_non_coord_to_dim.nc", TEST_NAME); */
+   /*    if (nc_create(file_name, NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR; */
+   /*    if (nc_def_dim(ncid, D1_NAME, DIM1_LEN, &dimid1)) ERR; */
+   /*    if (nc_def_dim(ncid, D2_NAME, DIM1_LEN, &dimid2)) ERR; */
+   /*    if (nc_def_var(ncid, D1_NAME, NC_INT, NDIM1, &dimid1, &varid1)) ERR; */
+   /*    if (nc_def_var(ncid, D2_NAME, NC_INT, NDIM1, &dimid2, &varid2)) ERR; */
+   /*    if (nc_close(ncid)) ERR; */
+
+   /*    /\* Open the file and rename the vars. *\/ */
+   /*    nc_set_log_level(4); */
+   /*    if (nc_open(file_name, NC_WRITE, &ncid)) ERR; */
+   /*    if (nc_rename_var(ncid, varid1, TMP_NAME)) ERR; */
+   /*    nc_sync(ncid); */
+   /*    /\* if (nc_rename_var(ncid, varid2, D1_NAME)) ERR; *\/ */
+   /*    /\* nc_sync(ncid); *\/ */
+   /*    /\* if (nc_rename_var(ncid, varid1, D2_NAME)) ERR; *\/ */
+   /*    if (nc_close(ncid)) ERR; */
+
+   /*    /\* Reopen file and check, *\/ */
+   /*    if (nc_open(file_name, NC_WRITE, &ncid)) ERR; */
+   /*    /\* if (nc_inq_dimid(ncid, D1_NAME, &dimid_in)) ERR; *\/ */
+   /*    /\* if (dimid_in != dimid1) ERR; *\/ */
+   /*    /\* if (nc_inq_dimid(ncid, D2_NAME, &dimid_in)) ERR; *\/ */
+   /*    /\* if (dimid_in != dimid2) ERR; *\/ */
+   /*    /\* if (nc_inq_dimid(ncid, TMP_NAME, &dimid_in) != NC_EBADDIM) ERR; *\/ */
+   /*    /\* if (nc_inq_varid(ncid, TMP_NAME, &varid_in)) ERR; *\/ */
+   /*    /\* if (varid_in != varid1) ERR; *\/ */
+   /*    /\* if (nc_inq_varid(ncid, D1_NAME, &varid_in)) ERR; *\/ */
+   /*    /\* if (varid_in != varid2) ERR; *\/ */
+   /*    if (nc_close(ncid)) ERR; */
+   /* } */
+   /* SUMMARIZE_ERR; */
    FINAL_RESULTS;
 }
diff --git a/nc_test4/tst_udf.c b/nc_test4/tst_udf.c
index e879bd2da..ebe543780 100644
--- a/nc_test4/tst_udf.c
+++ b/nc_test4/tst_udf.c
@@ -25,7 +25,7 @@ NC4_show_metadata(int ncid)
 
 int
 tst_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
-             void *parameters, const NC_Dispatch *dispatch, NC *nc_file)
+             void *parameters, NC_Dispatch *dispatch, NC *nc_file)
 {
    return NC_NOERR;
 }