Repository: Unidata/netcdf-c
Pull request #1406 (2019-05-22 19:24:24)

Modified how libsz is being detected in automake-based builds.
Observed an issue on systems using `libsz` as provided by the `libaec` package instead of being built from scratch.  Discovered after a CI bug report by @edhartnett, and was able to recreate.  The libaec-provided libsz does not contain the symbol `SZ_Compress`, and so the netcdf-c `configure` script returned a false negative.  

Fix was to modify `libsz` detection to mirror how `libhdf5` is detecting it.  


Patch:
diff --git a/configure.ac b/configure.ac
index 6780273cc..e54268216 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1047,7 +1047,7 @@ if test "x$enable_hdf5" = xyes; then
 
    # Check to see if we need to search for and link against szlib.
    if test "x$ac_cv_func_H5Z_SZIP" = xyes; then
-      AC_SEARCH_LIBS([SZ_Compress], [szip sz], [],
+      AC_SEARCH_LIBS([SZ_BufftoBuffCompress], [szip sz], [],
       [AC_MSG_ERROR([libhdf5 installed with szip support, but cannot find or link to the szip library.])])
    fi
 
@@ -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/libhdf5/hdf5var.c b/libhdf5/hdf5var.c
index 6a0941682..388852642 100644
--- a/libhdf5/hdf5var.c
+++ b/libhdf5/hdf5var.c
@@ -9,9 +9,7 @@
  */
 
 #include "config.h"
-#ifdef USE_HDF5
 #include <hdf5internal.h>
-#endif
 #include <math.h> /* For pow() used below. */
 
 /** @internal Default size for unlimited dim chunksize. */
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..f10ceeb8e 100644
--- a/nc_perf/Makefile.am
+++ b/nc_perf/Makefile.am
@@ -58,7 +58,7 @@ EXTRA_DIST = run_par_bm_test.sh.in run_knmi_bm.sh CMakeLists.txt	\
 perftest.sh run_bm_test1.sh run_bm_test2.sh \
 CMakeLists.txt
 
-CLEANFILES = tst_*.nc bigmeta.nc bigvars.nc floats*.nc	\
+CLEANFILES = tst_*.nc *.txt bigmeta.nc bigvars.nc floats*.nc	\
 floats*.cdl shorts*.nc shorts*.cdl ints*.nc ints*.cdl tst_*.cdl
 
 DISTCLEANFILES = run_par_bm_test.sh MSGCPP_CWP_NC*.nc


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/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;
 }