diff --git a/Makefile.am b/Makefile.am index 190ee19da2..57cdbc0358 100644 --- a/Makefile.am +++ b/Makefile.am @@ -40,8 +40,12 @@ endif # Is the user building netCDF-4? if USE_NETCDF4 -H5_TEST_DIR = h5_test LIBSRC4_DIR = libsrc4 +endif + +# Is the user building with HDF5? +if USE_HDF5 +H5_TEST_DIR = h5_test LIBHDF5 = libhdf5 NC_TEST4 = nc_test4 endif diff --git a/configure.ac b/configure.ac index 18e91b82a7..b3de7bc304 100644 --- a/configure.ac +++ b/configure.ac @@ -193,10 +193,6 @@ AC_ARG_ENABLE([netcdf-4], [AS_HELP_STRING([--disable-netcdf-4], [do not build with netcdf-4 (else HDF5 and zlib required)])]) test "x$enable_netcdf_4" = xno || enable_netcdf_4=yes -enable_hdf5=$enable_netcdf_4 -AC_MSG_CHECKING([whether we should build with HDF5]) -AC_MSG_RESULT([$enable_hdf5]) - # Synonym AC_ARG_ENABLE([netcdf4], [AS_HELP_STRING([--disable-netcdf4], [(just a synonym for --disable-netcdf-4)])]) @@ -206,6 +202,17 @@ enable_netcdf_4=no fi AC_MSG_RESULT([$enable_netcdf_4]) +# Does the user want to use HDF5? +AC_MSG_CHECKING([whether we should build with HDF5]) +#enable_hdf5=$enable_netcdf_4 +AC_ARG_ENABLE([hdf5], [AS_HELP_STRING([--disable-hdf5], + [do not build with HDF5])]) +test "x$enable_hdf5" = xno || enable_hdf5=yes +if test "x$enable_netcdf_4" = xno ; then +enable_hdf5=no +fi +AC_MSG_RESULT([$enable_hdf5]) + # Does the user require dynamic loading? # This is only for those hdf5 installs that support it. AC_MSG_CHECKING([do we require hdf5 dynamic-loading support]) @@ -852,7 +859,8 @@ AC_CHECK_FUNCS([strlcat snprintf \ getrlimit gettimeofday fsync MPI_Comm_f2c MPI_Info_f2c]) # disable dap4 if netcdf-4 is disabled -if test "x$enable_netcdf_4" = "xno" ; then +#if test "x$enable_netcdf_4" = "xno" ; then +if test "x$enable_hdf5" = "xno" ; then AC_MSG_WARN([netcdf-4 not enabled; disabling DAP4]) enable_dap4=no fi @@ -1006,9 +1014,13 @@ AC_CHECK_LIB([m], [floor], [], [AC_MSG_ERROR([Can't find or link to the math library.])]) if test "x$enable_netcdf_4" = xyes; then + AC_DEFINE([USE_NETCDF4], [1], [if true, build netCDF-4]) +fi + +hdf5_parallel=no +if test "x$enable_hdf5" = xyes; then AC_DEFINE([USE_HDF5], [1], [if true, use HDF5]) - AC_DEFINE([USE_NETCDF4], [1], [if true, build netCDF-4]) AC_DEFINE([H5_USE_16_API], [1], [use HDF5 1.6 API]) # Check for the main hdf5 and hdf5_hl library. @@ -1020,20 +1032,10 @@ if test "x$enable_netcdf_4" = xyes; then AC_CHECK_HEADERS([hdf5.h], [], [AC_MSG_ERROR([Compiling a test with HDF5 failed. Either hdf5.h cannot be found, or config.log should be checked for other reason.])]) AC_CHECK_FUNCS([H5Z_SZIP]) - hdf5_parallel=no # H5Pset_fapl_mpiposix and H5Pget_fapl_mpiposix have been removed since HDF5 1.8.12. # Use H5Pset_fapl_mpio and H5Pget_fapl_mpio, instead. AC_CHECK_FUNCS([H5Pget_fapl_mpio H5Pset_deflate H5Z_SZIP H5free_memory H5Pset_libver_bounds H5Pset_all_coll_metadata_ops]) - # The user may have parallel HDF5 based on MPI POSIX. - # if test "x$ac_cv_func_H5Pget_fapl_mpiposix" = xyes; then - # AC_DEFINE([USE_PARALLEL_POSIX], [1], [if true, compile in parallel netCDF-4 based on MPI/POSIX]) - # fi - - # The user may have parallel HDF5 based on MPI mumble mumble. - # if test "x$ac_cv_func_H5Pget_fapl_mpio" = xyes; then - # AC_DEFINE([USE_PARALLEL_MPIO], [1], [if true, compile in parallel netCDF-4 based on MPI/IO]) - # fi # Check to see if HDF5 library has collective metadata APIs, (HDF5 >= 1.10.0) if test "x$ac_cv_func_H5Pset_all_coll_metadata_ops" = xyes; then @@ -1041,7 +1043,6 @@ if test "x$enable_netcdf_4" = xyes; then fi # If parallel is available in hdf5, enable it in the C code. Also add some stuff to netcdf.h. - hdf5_parallel=no if test "x$ac_cv_func_H5Pget_fapl_mpio" = xyes -o "x$ac_cv_func_H5Pget_fapl_mpiposix" = xyes; then hdf5_parallel=yes fi @@ -1072,21 +1073,22 @@ if test "x$enable_netcdf_4" = xyes; then AC_DEFINE([HDF5_HAS_LIBVER_BOUNDS], [1], [if true, netcdf4 file properties will be set using H5Pset_libver_bounds]) fi - # If the user wants hdf4 built in, check it out. - if test "x$enable_hdf4" = xyes; then - AC_CHECK_LIB([jpeg], [jpeg_CreateCompress], [], - [AC_MSG_ERROR([Jpeg library required for --enable-hdf4 builds.])]) - AC_CHECK_HEADERS([mfhdf.h], [], [nc_mfhdf_h_missing=yes]) - if test "x$nc_mfhdf_h_missing" = xyes; then - AC_MSG_ERROR([Cannot find mfhdf.h, yet --enable-hdf4 was used.]) - fi - AC_CHECK_LIB([df], [Hclose], [], [AC_MSG_ERROR([Can't find or link to the hdf4 df library. See config.log for errors.])]) - AC_CHECK_LIB([mfhdf], [NC_arrayfill], [AC_MSG_ERROR([HDF4 library must be built with --disable-netcdf.])], []) - AC_CHECK_LIB([mfhdf], [SDcreate], [], [AC_MSG_ERROR([Can't find or link to the hdf4 mfhdf library. See config.log for errors.])]) +fi - AC_CHECK_LIB([jpeg], [jpeg_set_quality], [], [AC_MSG_ERROR([Can't find or link to the jpeg library (required by hdf4). See config.log for errors.])]) - AC_DEFINE([USE_HDF4], [1], [if true, use HDF4 too]) +# If the user wants hdf4 built in, check it out. +if test "x$enable_hdf4" = xyes; then + AC_CHECK_LIB([jpeg], [jpeg_CreateCompress], [], + [AC_MSG_ERROR([Jpeg library required for --enable-hdf4 builds.])]) + AC_CHECK_HEADERS([mfhdf.h], [], [nc_mfhdf_h_missing=yes]) + if test "x$nc_mfhdf_h_missing" = xyes; then + AC_MSG_ERROR([Cannot find mfhdf.h, yet --enable-hdf4 was used.]) fi + AC_CHECK_LIB([df], [Hclose], [], [AC_MSG_ERROR([Can't find or link to the hdf4 df library. See config.log for errors.])]) + AC_CHECK_LIB([mfhdf], [NC_arrayfill], [AC_MSG_ERROR([HDF4 library must be built with --disable-netcdf.])], []) + AC_CHECK_LIB([mfhdf], [SDcreate], [], [AC_MSG_ERROR([Can't find or link to the hdf4 mfhdf library. See config.log for errors.])]) + + AC_CHECK_LIB([jpeg], [jpeg_set_quality], [], [AC_MSG_ERROR([Can't find or link to the jpeg library (required by hdf4). See config.log for errors.])]) + AC_DEFINE([USE_HDF4], [1], [if true, use HDF4 too]) fi # There are several cases for parallelism: @@ -1096,7 +1098,7 @@ fi # b. do want to use it for netcdf4 # Should we provide parallel io for netcdf-4? -if test "x$enable_netcdf_4" = xyes ; then +if test "x$enable_hdf5" = xyes ; then AC_ARG_ENABLE([parallel4], [AS_HELP_STRING([--disable-parallel4], [disable parallel I/O for netcdf-4, even if it's enabled in libhdf5])], diff --git a/examples/C/Makefile.am b/examples/C/Makefile.am index c4996e5e8e..7400f6a43a 100644 --- a/examples/C/Makefile.am +++ b/examples/C/Makefile.am @@ -20,7 +20,7 @@ sfc_pres_temp_rd pres_temp_4D_wr pres_temp_4D_rd TESTS = run_examples.sh # To build netcdf-4, or not to build netcdf-4, that is the question... -if USE_NETCDF4 +if USE_HDF5 # These are the extra netCDF-4 examples. check_PROGRAMS += simple_nc4_wr simple_nc4_rd simple_xy_nc4_wr \ simple_xy_nc4_rd @@ -31,7 +31,7 @@ check_PROGRAMS += filter_example TESTS += run_filter.sh endif -endif #USE_NETCDF4 +endif #USE_HDF5 if USE_PNETCDF # These are the extra netCDF-4 examples. @@ -42,9 +42,9 @@ endif #USE_PNETCDF AM_CPPFLAGS += -I$(top_builddir)/liblib AM_LDFLAGS += ${top_builddir}/liblib/libnetcdf.la -if USE_NETCDF4 +if USE_HDF5 TESTS += run_examples4.sh -endif #USE_NETCDF4 +endif #USE_HDF5 # These files are created by the tests. CLEANFILES = *.nc diff --git a/include/hdf5dispatch.h b/include/hdf5dispatch.h index 4bd41f3a7b..e8a6359de8 100644 --- a/include/hdf5dispatch.h +++ b/include/hdf5dispatch.h @@ -49,6 +49,10 @@ extern "C" { int *no_fill, void *fill_valuep, int *endiannessp, unsigned int *idp, size_t *nparamsp, unsigned int *params); + EXTERNL int + NC4_HDF5_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems, + float preemption); + #if defined(__cplusplus) } #endif diff --git a/include/hdf5internal.h b/include/hdf5internal.h index 851138c410..4ed7db828d 100644 --- a/include/hdf5internal.h +++ b/include/hdf5internal.h @@ -142,7 +142,7 @@ int nc4_get_fill_value(NC_FILE_INFO_T *h5, NC_VAR_INFO_T *var, void **fillp); /* Find file, group, var, and att info, doing lazy reads if needed. */ int nc4_hdf5_find_grp_var_att(int ncid, int varid, const char *name, int attnum, - int use_name, NC_FILE_INFO_T **h5, + int use_name, char *norm_name, NC_FILE_INFO_T **h5, NC_GRP_INFO_T **grp, NC_VAR_INFO_T **var, NC_ATT_INFO_T **att); diff --git a/include/nc4dispatch.h b/include/nc4dispatch.h index 7641360578..7cfeca13c6 100644 --- a/include/nc4dispatch.h +++ b/include/nc4dispatch.h @@ -253,9 +253,6 @@ extern "C" { EXTERNL int NC4_def_var_filter(int, int, unsigned int, size_t, const unsigned int*); - EXTERNL int - NC4_set_var_chunk_cache(int, int, size_t, size_t, float); - EXTERNL int NC4_get_var_chunk_cache(int, int, size_t *, size_t *, float *); diff --git a/include/nc_provenance.h b/include/nc_provenance.h index ef9825a3dc..18708a6322 100644 --- a/include/nc_provenance.h +++ b/include/nc_provenance.h @@ -1,14 +1,12 @@ /* Copyright 2005-2018 University Corporation for Atmospheric Research/Unidata. */ -/** /** * @file * @internal Contains information for creating provenance * info and/or displaying provenance info. * * @author Dennis Heimbigner, Ward Fisher - -/**************************************************/ + */ /** It has come to pass that we can't guarantee that this information is diff --git a/libdispatch/dfile.c b/libdispatch/dfile.c index 0447cc110b..9e16842412 100644 --- a/libdispatch/dfile.c +++ b/libdispatch/dfile.c @@ -2358,7 +2358,7 @@ NC_open(const char *path0, int omode, int basepe, size_t *chunksizehintp, dispatcher = NCP_dispatch_table; break; #endif -#if defined(USE_NETCDF4) +#if defined(USE_HDF5) case NC_FORMATX_NC4: dispatcher = HDF5_dispatch_table; break; diff --git a/libdispatch/nc.c b/libdispatch/nc.c index 9683c79257..4a16524806 100644 --- a/libdispatch/nc.c +++ b/libdispatch/nc.c @@ -91,7 +91,7 @@ nc_set_default_format(int format, int *old_formatp) if (format == NC_FORMAT_CDF5) return NC_ENOTBUILT; #endif -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT_OFFSET && format != NC_FORMAT_NETCDF4 && format != NC_FORMAT_NETCDF4_CLASSIC && format != NC_FORMAT_CDF5) diff --git a/libhdf5/hdf5attr.c b/libhdf5/hdf5attr.c index b190585123..8c585df5ae 100644 --- a/libhdf5/hdf5attr.c +++ b/libhdf5/hdf5attr.c @@ -59,6 +59,77 @@ getattlist(NC_GRP_INFO_T *grp, int varid, NC_VAR_INFO_T **varp, return NC_NOERR; } +/** + * @internal Get one of three special attributes, NCPROPS, + * ISNETCDF4ATT, and SUPERBLOCKATT. These atts are not all really in + * the file, they are constructed on the fly. + * + * @param h5 Pointer to HDF5 file info struct. + * @param name Name of attribute. + * @param filetypep Pointer that gets type of the attribute data in + * file. + * @param mem_type Type of attribute data in memory. + * @param lenp Pointer that gets length of attribute array. + * @param attnump Pointer that gets the attribute number. + * @param data Attribute data. + * + * @return ::NC_NOERR No error. + * @return ::NC_EBADID Bad ncid. + * @return ::NC_ERANGE Data conversion out of range. + * @author Dennis Heimbigner + */ +int +nc4_get_att_special(NC_FILE_INFO_T* h5, const char* name, + nc_type* filetypep, nc_type mem_type, size_t* lenp, + int* attnump, void* data) +{ + /* Fail if asking for att id */ + if(attnump) + return NC_EATTMETA; + + if(strcmp(name,NCPROPS)==0) { + char* propdata = NULL; + int stat = NC_NOERR; + int len; + if(h5->provenance->propattr.version == 0) + return NC_ENOTATT; + if(mem_type == NC_NAT) mem_type = NC_CHAR; + if(mem_type != NC_CHAR) + return NC_ECHAR; + if(filetypep) *filetypep = NC_CHAR; + stat = NC4_buildpropinfo(&h5->provenance->propattr, &propdata); + if(stat != NC_NOERR) return stat; + len = strlen(propdata); + if(lenp) *lenp = len; + if(data) strncpy((char*)data,propdata,len+1); + free(propdata); + } else if(strcmp(name,ISNETCDF4ATT)==0 + || strcmp(name,SUPERBLOCKATT)==0) { + unsigned long long iv = 0; + if(filetypep) *filetypep = NC_INT; + if(lenp) *lenp = 1; + if(strcmp(name,SUPERBLOCKATT)==0) + iv = (unsigned long long)h5->provenance->superblockversion; + else /* strcmp(name,ISNETCDF4ATT)==0 */ + iv = NC4_isnetcdf4(h5); + if(mem_type == NC_NAT) mem_type = NC_INT; + if(data) + switch (mem_type) { + case NC_BYTE: *((char*)data) = (char)iv; break; + case NC_SHORT: *((short*)data) = (short)iv; break; + case NC_INT: *((int*)data) = (int)iv; break; + case NC_UBYTE: *((unsigned char*)data) = (unsigned char)iv; break; + case NC_USHORT: *((unsigned short*)data) = (unsigned short)iv; break; + case NC_UINT: *((unsigned int*)data) = (unsigned int)iv; break; + case NC_INT64: *((long long*)data) = (long long)iv; break; + case NC_UINT64: *((unsigned long long*)data) = (unsigned long long)iv; break; + default: + return NC_ERANGE; + } + } + return NC_NOERR; +} + /** * @internal I think all atts should be named the exact same thing, to * avoid confusion! @@ -727,17 +798,28 @@ NC4_HDF5_inq_att(int ncid, int varid, const char *name, nc_type *xtypep, NC_FILE_INFO_T *h5; NC_GRP_INFO_T *grp; NC_VAR_INFO_T *var = NULL; + char norm_name[NC_MAX_NAME + 1]; int retval; LOG((2, "%s: ncid 0x%x varid %d", __func__, ncid, varid)); /* Find the file, group, and var info, and do lazy att read if * needed. */ - if ((retval = nc4_hdf5_find_grp_var_att(ncid, varid, name, 0, 1, &h5, - &grp, &var, NULL))) + if ((retval = nc4_hdf5_find_grp_var_att(ncid, varid, name, 0, 1, norm_name, + &h5, &grp, &var, NULL))) return retval; - return nc4_get_att_ptrs(h5, grp, var, name, xtypep, NC_NAT, lenp, NULL, NULL); + /* If this is one of the reserved atts, use nc_get_att_special. */ + if (!var) + { + const NC_reservedatt *ra = NC_findreserved(norm_name); + if (ra && ra->flags & NAMEONLYFLAG) + return nc4_get_att_special(h5, norm_name, xtypep, NC_NAT, lenp, NULL, + NULL); + } + + return nc4_get_att_ptrs(h5, grp, var, norm_name, xtypep, NC_NAT, + lenp, NULL, NULL); } /** @@ -757,17 +839,28 @@ NC4_HDF5_inq_attid(int ncid, int varid, const char *name, int *attnump) NC_FILE_INFO_T *h5; NC_GRP_INFO_T *grp; NC_VAR_INFO_T *var = NULL; + char norm_name[NC_MAX_NAME + 1]; int retval; LOG((2, "%s: ncid 0x%x varid %d", __func__, ncid, varid)); /* Find the file, group, and var info, and do lazy att read if * needed. */ - if ((retval = nc4_hdf5_find_grp_var_att(ncid, varid, name, 0, 1, &h5, - &grp, &var, NULL))) + if ((retval = nc4_hdf5_find_grp_var_att(ncid, varid, name, 0, 1, norm_name, + &h5, &grp, &var, NULL))) return retval; - return nc4_get_att_ptrs(h5, grp, var, name, NULL, NC_NAT, NULL, attnump, NULL); + /* If this is one of the reserved atts, use nc_get_att_special. */ + if (!var) + { + const NC_reservedatt *ra = NC_findreserved(norm_name); + if (ra && ra->flags & NAMEONLYFLAG) + return nc4_get_att_special(h5, norm_name, NULL, NC_NAT, NULL, attnump, + NULL); + } + + return nc4_get_att_ptrs(h5, grp, var, norm_name, NULL, NC_NAT, + NULL, attnump, NULL); } /** @@ -793,7 +886,7 @@ NC4_HDF5_inq_attname(int ncid, int varid, int attnum, char *name) /* Find the file, group, and var info, and do lazy att read if * needed. */ if ((retval = nc4_hdf5_find_grp_var_att(ncid, varid, NULL, attnum, 0, NULL, - NULL, NULL, &att))) + NULL, NULL, NULL, &att))) return retval; assert(att); @@ -811,27 +904,41 @@ NC4_HDF5_inq_attname(int ncid, int varid, int attnum, char *name) * @param varid Variable ID. * @param name Name of attribute. * @param value Pointer that gets attribute data. - * @param memtype The type the data should be converted to as it is read. + * @param memtype The type the data should be converted to as it is + * read. * * @return ::NC_NOERR No error. * @return ::NC_EBADID Bad ncid. * @author Ed Hartnett */ int -NC4_HDF5_get_att(int ncid, int varid, const char *name, void *value, nc_type memtype) +NC4_HDF5_get_att(int ncid, int varid, const char *name, void *value, + nc_type memtype) { NC_FILE_INFO_T *h5; NC_GRP_INFO_T *grp; NC_VAR_INFO_T *var = NULL; + char norm_name[NC_MAX_NAME + 1]; int retval; LOG((2, "%s: ncid 0x%x varid %d", __func__, ncid, varid)); /* Find the file, group, and var info, and do lazy att read if * needed. */ - if ((retval = nc4_hdf5_find_grp_var_att(ncid, varid, name, 0, 1, &h5, - &grp, &var, NULL))) + if ((retval = nc4_hdf5_find_grp_var_att(ncid, varid, name, 0, 1, norm_name, + &h5, &grp, &var, NULL))) return retval; - return nc4_get_att_ptrs(h5, grp, var, name, NULL, memtype, NULL, NULL, value); + /* If this is one of the reserved atts, use nc_get_att_special. */ + if (!var) + { + const NC_reservedatt *ra = NC_findreserved(norm_name); + if (ra && ra->flags & NAMEONLYFLAG) + return nc4_get_att_special(h5, norm_name, NULL, NC_NAT, NULL, NULL, + value); + } + + return nc4_get_att_ptrs(h5, grp, var, norm_name, NULL, memtype, + NULL, NULL, value); } + diff --git a/libhdf5/hdf5cache.c b/libhdf5/hdf5cache.c index 5ae4a5ccc8..fcefa7456c 100644 --- a/libhdf5/hdf5cache.c +++ b/libhdf5/hdf5cache.c @@ -12,10 +12,11 @@ #include "config.h" #include "hdf5internal.h" -/* These hold the file caching settings for the library. */ -size_t nc4_chunk_cache_size = CHUNK_CACHE_SIZE; /**< Default chunk cache size. */ -size_t nc4_chunk_cache_nelems = CHUNK_CACHE_NELEMS; /**< Default chunk cache number of elements. */ -float nc4_chunk_cache_preemption = CHUNK_CACHE_PREEMPTION; /**< Default chunk cache preemption. */ +/* These are the default chunk cache sizes for HDF5 files created or + * opened with netCDF-4. */ +extern size_t nc4_chunk_cache_size; +extern size_t nc4_chunk_cache_nelems; +extern float nc4_chunk_cache_preemption; /** * Set chunk cache size. Only affects files opened/created *after* it diff --git a/libhdf5/hdf5dispatch.c b/libhdf5/hdf5dispatch.c index ec5e6a4b7f..7fcf723f91 100644 --- a/libhdf5/hdf5dispatch.c +++ b/libhdf5/hdf5dispatch.c @@ -98,7 +98,7 @@ NC4_def_var_fletcher32, NC4_def_var_chunking, NC4_def_var_endian, NC4_def_var_filter, -NC4_set_var_chunk_cache, +NC4_HDF5_set_var_chunk_cache, NC4_get_var_chunk_cache, #endif diff --git a/libhdf5/hdf5internal.c b/libhdf5/hdf5internal.c index f661c8a958..5752e9ea92 100644 --- a/libhdf5/hdf5internal.c +++ b/libhdf5/hdf5internal.c @@ -661,6 +661,9 @@ nc4_rec_grp_HDF5_del(NC_GRP_INFO_T *grp) * @param attnum Number of attribute. * @param use_name If true, use the name to get the * attribute. Otherwise use the attnum. + * @param norm_name Pointer to storage of size NC_MAX_NAME + 1, + * which will get the normalized name, if use_name is true. Ignored if + * NULL. * @param h5 Pointer to pointer that gets file info struct. Ignored if * NULL. * @param grp Pointer to pointer that gets group info struct. Ignored @@ -678,7 +681,7 @@ nc4_rec_grp_HDF5_del(NC_GRP_INFO_T *grp) */ int nc4_hdf5_find_grp_var_att(int ncid, int varid, const char *name, int attnum, - int use_name, NC_FILE_INFO_T **h5, + int use_name, char *norm_name, NC_FILE_INFO_T **h5, NC_GRP_INFO_T **grp, NC_VAR_INFO_T **var, NC_ATT_INFO_T **att) { @@ -686,12 +689,17 @@ nc4_hdf5_find_grp_var_att(int ncid, int varid, const char *name, int attnum, NC_GRP_INFO_T *my_grp; NC_VAR_INFO_T *my_var = NULL; NC_ATT_INFO_T *my_att; + char my_norm_name[NC_MAX_NAME + 1] = ""; NCindex *attlist = NULL; int retval; LOG((4, "%s: ncid %d varid %d attnum %d use_name %d", __func__, ncid, varid, attnum, use_name)); + /* Don't need to provide name unless getting att pointer and using + * use_name. */ + assert(!att || ((use_name && name) || !use_name)); + /* Find info for this file, group, and h5 info. */ if ((retval = nc4_find_nc_grp_h5(ncid, NULL, &my_grp, &my_h5))) return retval; @@ -721,16 +729,27 @@ nc4_hdf5_find_grp_var_att(int ncid, int varid, const char *name, int attnum, } assert(attlist); + /* Need a name if use_name is true. */ + if (use_name && !name) + return NC_EBADNAME; + + /* Normalize the name. */ + if (use_name) + if ((retval = nc4_normalize_name(name, my_norm_name))) + return retval; + /* Now find the attribute by name or number. */ if (att) { - my_att = use_name ? (NC_ATT_INFO_T *)ncindexlookup(attlist, name) : + my_att = use_name ? (NC_ATT_INFO_T *)ncindexlookup(attlist, my_norm_name) : (NC_ATT_INFO_T *)ncindexith(attlist, attnum); if (!my_att) return NC_ENOTATT; } /* Give the people what they want. */ + if (norm_name) + strncpy(norm_name, my_norm_name, NC_MAX_NAME); if (h5) *h5 = my_h5; if (grp) diff --git a/libhdf5/hdf5var.c b/libhdf5/hdf5var.c index c074d9f3b5..57333739ac 100644 --- a/libhdf5/hdf5var.c +++ b/libhdf5/hdf5var.c @@ -106,7 +106,7 @@ check_chunksizes(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, const size_t *chunksize * @returns ::NC_NOERR for success * @returns ::NC_EBADID Bad ncid. * @returns ::NC_ENOTVAR Invalid variable ID. - * @author Ed Hartnett + * @author Ed Hartnett, Dennis Heimbigner */ static int nc4_find_default_chunksizes2(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) @@ -570,11 +570,9 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *deflate, const size_t *chunksizes, int *no_fill, const void *fill_value, int *endianness) { - NC *nc; NC_GRP_INFO_T *grp; NC_FILE_INFO_T *h5; NC_VAR_INFO_T *var; - NC_FILE_INFO_T *nc4_info=NULL; int d; int retval; @@ -585,26 +583,23 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *deflate, LOG((2, "%s: ncid 0x%x varid %d", __func__, ncid, varid)); /* Find info for this file and group, and set pointer to each. */ - if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5))) + if ((retval = nc4_find_nc_grp_h5(ncid, NULL, &grp, &h5))) return retval; - assert(nc && grp && h5); + assert(grp && h5); /* Trying to write to a read-only file? No way, Jose! */ if (h5->no_write) return NC_EPERM; /* Find the var. */ - var = (NC_VAR_INFO_T*)ncindexith(grp->vars,varid); - if(!var) + if (!(var = (NC_VAR_INFO_T *)ncindexith(grp->vars, varid))) return NC_ENOTVAR; assert(var && var->hdr.id == varid); /* Can't turn on parallel and deflate/fletcher32/szip/shuffle. */ - nc4_info = NC4_DATA(nc); - if (nc4_info->parallel == NC_TRUE) { + if (h5->parallel == NC_TRUE) if (deflate || fletcher32 || shuffle) return NC_EINVAL; - } /* If the HDF5 dataset has already been created, then it is too * late to set all the extra stuff. */ @@ -734,7 +729,8 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *deflate, return retval; /* Create a _FillValue attribute. */ - if ((retval = nc_put_att(ncid, varid, _FillValue, var->type_info->hdr.id, 1, fill_value))) + if ((retval = nc_put_att(ncid, varid, _FillValue, var->type_info->hdr.id, + 1, fill_value))) return retval; } @@ -2072,8 +2068,8 @@ NC4_HDF5_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep, /* Find the file, group, and var info, and do lazy att read if * needed. */ - if ((retval = nc4_hdf5_find_grp_var_att(ncid, varid, name, 0, 1, &h5, - &grp, &var, NULL))) + if ((retval = nc4_hdf5_find_grp_var_att(ncid, varid, NULL, 0, 0, NULL, + &h5, &grp, &var, NULL))) return retval; assert(grp && h5); @@ -2084,3 +2080,89 @@ NC4_HDF5_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep, contiguousp, chunksizesp, no_fill, fill_valuep, endiannessp, idp, nparamsp, params); } + +/** + * @internal Set chunk cache size for a variable. This is the internal + * function called by nc_set_var_chunk_cache(). + * + * @param ncid File ID. + * @param varid Variable ID. + * @param size Size in bytes to set cache. + * @param nelems Number of elements in cache. + * @param preemption Controls cache swapping. + * + * @returns ::NC_NOERR No error. + * @returns ::NC_EBADID Bad ncid. + * @returns ::NC_ENOTVAR Invalid variable ID. + * @returns ::NC_ESTRICTNC3 Attempting netcdf-4 operation on strict nc3 netcdf-4 file. + * @returns ::NC_EINVAL Invalid input. + * @returns ::NC_EHDFERR HDF5 error. + * @author Ed Hartnett + */ +int +NC4_HDF5_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems, + float preemption) +{ + NC_GRP_INFO_T *grp; + NC_FILE_INFO_T *h5; + NC_VAR_INFO_T *var; + int retval; + + /* Check input for validity. */ + if (preemption < 0 || preemption > 1) + return NC_EINVAL; + + /* Find info for this file and group, and set pointer to each. */ + if ((retval = nc4_find_nc_grp_h5(ncid, NULL, &grp, &h5))) + return retval; + assert(grp && h5); + + /* Find the var. */ + if (!(var = (NC_VAR_INFO_T *)ncindexith(grp->vars, varid))) + return NC_ENOTVAR; + assert(var && var->hdr.id == varid); + + /* Set the values. */ + var->chunk_cache_size = size; + var->chunk_cache_nelems = nelems; + var->chunk_cache_preemption = preemption; + + /* Reopen the dataset to bring new settings into effect. */ + if ((retval = nc4_reopen_dataset(grp, var))) + return retval; + return NC_NOERR; +} + +/** + * @internal A wrapper for NC4_set_var_chunk_cache(), we need this + * version for fortran. Negative values leave settings as they are. + * + * @param ncid File ID. + * @param varid Variable ID. + * @param size Size in bytes to set cache. + * @param nelems Number of elements in cache. + * @param preemption Controls cache swapping. + * + * @returns ::NC_NOERR for success + * @author Ed Hartnett + */ +int +nc_set_var_chunk_cache_ints(int ncid, int varid, int size, int nelems, + int preemption) +{ + size_t real_size = H5D_CHUNK_CACHE_NBYTES_DEFAULT; + size_t real_nelems = H5D_CHUNK_CACHE_NSLOTS_DEFAULT; + float real_preemption = CHUNK_CACHE_PREEMPTION; + + if (size >= 0) + real_size = ((size_t) size) * MEGABYTE; + + if (nelems >= 0) + real_nelems = nelems; + + if (preemption >= 0) + real_preemption = preemption / 100.; + + return NC4_HDF5_set_var_chunk_cache(ncid, varid, real_size, real_nelems, + real_preemption); +} diff --git a/libhdf5/nc4hdf.c b/libhdf5/nc4hdf.c index a565e7e4c0..b61b6f8d2a 100644 --- a/libhdf5/nc4hdf.c +++ b/libhdf5/nc4hdf.c @@ -2318,72 +2318,6 @@ nc4_rec_match_dimscales(NC_GRP_INFO_T *grp) return retval; } -/** - * @internal Get the length, in bytes, of one element of a type in - * memory. - * - * @param h5 Pointer to HDF5 file info struct. - * @param xtype NetCDF type ID. - * @param len Pointer that gets length in bytes. - * - * @returns NC_NOERR No error. - * @returns NC_EBADTYPE Type not found. - * @author Ed Hartnett - */ -int -nc4_get_typelen_mem(NC_FILE_INFO_T *h5, nc_type xtype, size_t *len) -{ - NC_TYPE_INFO_T *type; - int retval; - - LOG((4, "%s xtype: %d", __func__, xtype)); - assert(len); - - /* If this is an atomic type, the answer is easy. */ - switch (xtype) - { - case NC_BYTE: - case NC_CHAR: - case NC_UBYTE: - *len = sizeof(char); - return NC_NOERR; - case NC_SHORT: - case NC_USHORT: - *len = sizeof(short); - return NC_NOERR; - case NC_INT: - case NC_UINT: - *len = sizeof(int); - return NC_NOERR; - case NC_FLOAT: - *len = sizeof(float); - return NC_NOERR; - case NC_DOUBLE: - *len = sizeof(double); - return NC_NOERR; - case NC_INT64: - case NC_UINT64: - *len = sizeof(long long); - return NC_NOERR; - case NC_STRING: - *len = sizeof(char *); - return NC_NOERR; - } - - /* See if var is compound type. */ - if ((retval = nc4_find_type(h5, xtype, &type))) - return retval; - - if (!type) - return NC_EBADTYPE; - - *len = type->size; - - LOG((5, "type->size: %d", type->size)); - - return NC_NOERR; -} - /** * @internal Get the class of a type * diff --git a/liblib/Makefile.am b/liblib/Makefile.am index 02c0599fea..da3cfe622c 100644 --- a/liblib/Makefile.am +++ b/liblib/Makefile.am @@ -41,7 +41,7 @@ libnetcdf_la_LIBADD += ${top_builddir}/libsrcp/libnetcdfp.la endif # USE_PNETCDF # + hdf5 -if USE_NETCDF4 +if USE_HDF5 AM_CPPFLAGS += -I${top_srcdir}/libhdf5 libnetcdf_la_LIBADD += ${top_builddir}/libhdf5/libnchdf5.la endif # USE_NETCDF4 @@ -66,10 +66,8 @@ endif # ENABLE_DAP4 # NetCDF-4 ... if USE_NETCDF4 - AM_CPPFLAGS += -I${top_srcdir}/libsrc4 libnetcdf_la_LIBADD += ${top_builddir}/libsrc4/libnetcdf4.la - endif #USE_NETCDF4 if ISCYGWIN diff --git a/liblib/nc_initialize.c b/liblib/nc_initialize.c index 04d336798b..8ca0b079eb 100644 --- a/liblib/nc_initialize.c +++ b/liblib/nc_initialize.c @@ -91,10 +91,10 @@ nc_initialize() #endif #ifdef USE_NETCDF4 if((stat = NC4_initialize())) goto done; - stat = NC4_provenance_init(); #endif /* USE_NETCDF4 */ #ifdef USE_HDF5 if((stat = NC_HDF5_initialize())) goto done; + stat = NC4_provenance_init(); #endif #ifdef USE_HDF4 if((stat = NC_HDF4_initialize())) goto done; diff --git a/libnetcdf.settings.in b/libnetcdf.settings.in index 29f734e9bc..56f552d892 100644 --- a/libnetcdf.settings.in +++ b/libnetcdf.settings.in @@ -26,6 +26,7 @@ Extra libraries: @LIBS@ -------- NetCDF-2 API: @HAS_NC2@ HDF4 Support: @HAS_HDF4@ +HDF5 Support: @HAS_HDF5@ NetCDF-4 API: @HAS_NC4@ NC-4 Parallel Support: @HAS_PARALLEL4@ PnetCDF Support: @HAS_PNETCDF@ diff --git a/libsrc4/error4.c b/libsrc4/error4.c index bdd2345a55..9ee7865073 100644 --- a/libsrc4/error4.c +++ b/libsrc4/error4.c @@ -17,7 +17,9 @@ redistribution conditions. */ #include #include #include "assert.h" +#ifdef USE_HDF5 #include +#endif /* USE_HDF5 */ /* This contents of this file get skipped if LOGGING is not defined * during compile. */ @@ -64,10 +66,12 @@ nc_log(int severity, const char *fmt, ...) fflush(stderr); } -void +void nc_log_hdf5(void) { +#ifdef USE_HDF5 H5Eprint(NULL); +#endif /* USE_HDF5 */ } #endif /* ifdef LOGGING */ diff --git a/libsrc4/nc4attr.c b/libsrc4/nc4attr.c index 3e86df54eb..651014d9c7 100644 --- a/libsrc4/nc4attr.c +++ b/libsrc4/nc4attr.c @@ -18,79 +18,9 @@ #include "nc.h" #include "nc4internal.h" -#include "hdf5internal.h" #include "nc4dispatch.h" #include "ncdispatch.h" -/** - * @internal Get special informatation about the attribute. - * - * @param h5 Pointer to HDF5 file info struct. - * @param name Name of attribute. - * @param filetypep Pointer that gets type of the attribute data in - * file. - * @param mem_type Type of attribute data in memory. - * @param lenp Pointer that gets length of attribute array. - * @param attnump Pointer that gets the attribute number. - * @param data Attribute data. - * - * @return ::NC_NOERR No error. - * @return ::NC_EBADID Bad ncid. - * @return ::NC_ERANGE Data conversion out of range. - * @author Dennis Heimbigner - */ -static int -nc4_get_att_special(NC_FILE_INFO_T* h5, const char* name, - nc_type* filetypep, nc_type mem_type, size_t* lenp, - int* attnump, void* data) -{ - /* Fail if asking for att id */ - if(attnump) - return NC_EATTMETA; - - if(strcmp(name,NCPROPS)==0) { - char* propdata = NULL; - int stat = NC_NOERR; - int len; - if(h5->provenance->propattr.version == 0) - return NC_ENOTATT; - if(mem_type == NC_NAT) mem_type = NC_CHAR; - if(mem_type != NC_CHAR) - return NC_ECHAR; - if(filetypep) *filetypep = NC_CHAR; - stat = NC4_buildpropinfo(&h5->provenance->propattr, &propdata); - if(stat != NC_NOERR) return stat; - len = strlen(propdata); - if(lenp) *lenp = len; - if(data) strncpy((char*)data,propdata,len+1); - free(propdata); - } else if(strcmp(name,ISNETCDF4ATT)==0 - || strcmp(name,SUPERBLOCKATT)==0) { - unsigned long long iv = 0; - if(filetypep) *filetypep = NC_INT; - if(lenp) *lenp = 1; - if(strcmp(name,SUPERBLOCKATT)==0) - iv = (unsigned long long)h5->provenance->superblockversion; - else /* strcmp(name,ISNETCDF4ATT)==0 */ - iv = NC4_isnetcdf4(h5); - if(mem_type == NC_NAT) mem_type = NC_INT; - if(data) - switch (mem_type) { - case NC_BYTE: *((char*)data) = (char)iv; break; - case NC_SHORT: *((short*)data) = (short)iv; break; - case NC_INT: *((int*)data) = (int)iv; break; - case NC_UBYTE: *((unsigned char*)data) = (unsigned char)iv; break; - case NC_USHORT: *((unsigned short*)data) = (unsigned short)iv; break; - case NC_UINT: *((unsigned int*)data) = (unsigned int)iv; break; - case NC_INT64: *((long long*)data) = (long long)iv; break; - case NC_UINT64: *((unsigned long long*)data) = (unsigned long long)iv; break; - default: - return NC_ERANGE; - } - } - return NC_NOERR; -} - /** * @internal Get or put attribute metadata from our linked list of * file info. Always locate the attribute by name, never by attnum. @@ -98,7 +28,7 @@ nc4_get_att_special(NC_FILE_INFO_T* h5, const char* name, * * @param ncid File and group ID. * @param varid Variable ID. - * @param name Name of attribute. + * @param name Name of attribute. Must already be normalized. * @param xtype Pointer that gets (file) type of attribute. Ignored if * NULL. * @param mem_type The type of attribute data in memory. @@ -123,7 +53,6 @@ nc4_get_att_ptrs(NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, int range_error = NC_NOERR; void *bufr = NULL; size_t type_size; - char norm_name[NC_MAX_NAME + 1]; int varid; int i; int retval; @@ -139,20 +68,8 @@ nc4_get_att_ptrs(NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, if (name == NULL) BAIL(NC_EBADNAME); - /* Normalize name. */ - if ((retval = nc4_normalize_name(name, norm_name))) - BAIL(retval); - - /* If this is one of the reserved atts, use nc_get_att_special. */ - if (!var) - { - const NC_reservedatt* ra = NC_findreserved(norm_name); - if(ra != NULL && (ra->flags & NAMEONLYFLAG)) - return nc4_get_att_special(h5, norm_name, xtype, mem_type, lenp, attnum, data); - } - /* Find the attribute, if it exists. */ - if ((retval = nc4_find_grp_att(grp, varid, norm_name, my_attnum, &att))) + if ((retval = nc4_find_grp_att(grp, varid, name, my_attnum, &att))) return retval; /* If mem_type is NC_NAT, it means we want to use the attribute's @@ -299,6 +216,7 @@ nc4_get_att(int ncid, int varid, const char *name, nc_type *xtype, NC_FILE_INFO_T *h5; NC_GRP_INFO_T *grp; NC_VAR_INFO_T *var = NULL; + char norm_name[NC_MAX_NAME + 1]; int retval; LOG((3, "%s: ncid 0x%x varid %d mem_type %d", __func__, ncid, @@ -321,7 +239,11 @@ nc4_get_att(int ncid, int varid, const char *name, nc_type *xtype, if (!name) return NC_EBADNAME; - return nc4_get_att_ptrs(h5, grp, var, name, xtype, mem_type, lenp, + /* Normalize name. */ + if ((retval = nc4_normalize_name(name, norm_name))) + return retval; + + return nc4_get_att_ptrs(h5, grp, var, norm_name, xtype, mem_type, lenp, attnum, data); } diff --git a/libsrc4/nc4dispatch.c b/libsrc4/nc4dispatch.c index 110b0144ac..95cb1f8867 100644 --- a/libsrc4/nc4dispatch.c +++ b/libsrc4/nc4dispatch.c @@ -78,6 +78,5 @@ NC4_initialize(void) int NC4_finalize(void) { - nc4_hdf5_finalize(); return NC_NOERR; } diff --git a/libsrc4/nc4internal.c b/libsrc4/nc4internal.c index 567af43853..bb510da6b9 100644 --- a/libsrc4/nc4internal.c +++ b/libsrc4/nc4internal.c @@ -21,11 +21,10 @@ #include "ncdispatch.h" /* from libdispatch */ #include "ncutf8.h" -/* These are the default chunk cache sizes for HDF5 files created or - * opened with netCDF-4. */ -extern size_t nc4_chunk_cache_size; -extern size_t nc4_chunk_cache_nelems; -extern float nc4_chunk_cache_preemption; +/* These hold the file caching settings for the library. */ +size_t nc4_chunk_cache_size = CHUNK_CACHE_SIZE; /**< Default chunk cache size. */ +size_t nc4_chunk_cache_nelems = CHUNK_CACHE_NELEMS; /**< Default chunk cache number of elements. */ +float nc4_chunk_cache_preemption = CHUNK_CACHE_PREEMPTION; /**< Default chunk cache preemption. */ #ifdef LOGGING /* This is the severity level of messages which will be logged. Use @@ -1413,10 +1412,7 @@ int nc_set_log_level(int new_level) { #ifdef LOGGING - if(!nc4_hdf5_initialized) - nc4_hdf5_initialize(); - - /* Now remember the new level. */ + /* Remember the new level. */ nc_log_level = new_level; LOG((4, "log_level changed to %d", nc_log_level)); #endif /*LOGGING */ diff --git a/libsrc4/nc4var.c b/libsrc4/nc4var.c index 6d242c4443..c314aba237 100644 --- a/libsrc4/nc4var.c +++ b/libsrc4/nc4var.c @@ -16,94 +16,6 @@ #include "hdf5internal.h" #include -/** - * @internal Set chunk cache size for a variable. This is the internal - * function called by nc_set_var_chunk_cache(). - * - * @param ncid File ID. - * @param varid Variable ID. - * @param size Size in bytes to set cache. - * @param nelems Number of elements in cache. - * @param preemption Controls cache swapping. - * - * @returns ::NC_NOERR No error. - * @returns ::NC_EBADID Bad ncid. - * @returns ::NC_ENOTVAR Invalid variable ID. - * @returns ::NC_ESTRICTNC3 Attempting netcdf-4 operation on strict nc3 netcdf-4 file. - * @returns ::NC_EINVAL Invalid input. - * @returns ::NC_EHDFERR HDF5 error. - * @author Ed Hartnett - */ -int -NC4_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems, - float preemption) -{ - NC *nc; - NC_GRP_INFO_T *grp; - NC_FILE_INFO_T *h5; - NC_VAR_INFO_T *var; - int retval; - - /* Check input for validity. */ - if (preemption < 0 || preemption > 1) - return NC_EINVAL; - - /* Find info for this file and group, and set pointer to each. */ - if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5))) - return retval; - assert(nc && grp && h5); - - /* Find the var. */ - var = (NC_VAR_INFO_T*)ncindexith(grp->vars,varid); - if(!var) - return NC_ENOTVAR; - assert(var && var->hdr.id == varid); - - /* Set the values. */ - var->chunk_cache_size = size; - var->chunk_cache_nelems = nelems; - var->chunk_cache_preemption = preemption; - - if ((retval = nc4_reopen_dataset(grp, var))) - return retval; - - return NC_NOERR; -} - -/** - * @internal A wrapper for NC4_set_var_chunk_cache(), we need this - * version for fortran. Negative values leave settings as they are. - * - * @param ncid File ID. - * @param varid Variable ID. - * @param size Size in bytes to set cache. - * @param nelems Number of elements in cache. - * @param preemption Controls cache swapping. - * - * @returns ::NC_NOERR for success - * @author Ed Hartnett - */ -int -nc_set_var_chunk_cache_ints(int ncid, int varid, int size, int nelems, - int preemption) -{ - size_t real_size = H5D_CHUNK_CACHE_NBYTES_DEFAULT; - size_t real_nelems = H5D_CHUNK_CACHE_NSLOTS_DEFAULT; - float real_preemption = CHUNK_CACHE_PREEMPTION; - - if (size >= 0) - real_size = ((size_t) size) * MEGABYTE; - - if (nelems >= 0) - real_nelems = nelems; - - if (preemption >= 0) - real_preemption = preemption / 100.; - - return NC4_set_var_chunk_cache(ncid, varid, real_size, real_nelems, - real_preemption); -} - /** * @internal This is called by nc_get_var_chunk_cache(). Get chunk * cache size for a variable. @@ -1395,3 +1307,69 @@ nc4_get_default_fill_value(const NC_TYPE_INFO_T *type_info, void *fill_value) return NC_NOERR; } + +/** + * @internal Get the length, in bytes, of one element of a type in + * memory. + * + * @param h5 Pointer to HDF5 file info struct. + * @param xtype NetCDF type ID. + * @param len Pointer that gets length in bytes. + * + * @returns NC_NOERR No error. + * @returns NC_EBADTYPE Type not found. + * @author Ed Hartnett + */ +int +nc4_get_typelen_mem(NC_FILE_INFO_T *h5, nc_type xtype, size_t *len) +{ + NC_TYPE_INFO_T *type; + int retval; + + LOG((4, "%s xtype: %d", __func__, xtype)); + assert(len); + + /* If this is an atomic type, the answer is easy. */ + switch (xtype) + { + case NC_BYTE: + case NC_CHAR: + case NC_UBYTE: + *len = sizeof(char); + return NC_NOERR; + case NC_SHORT: + case NC_USHORT: + *len = sizeof(short); + return NC_NOERR; + case NC_INT: + case NC_UINT: + *len = sizeof(int); + return NC_NOERR; + case NC_FLOAT: + *len = sizeof(float); + return NC_NOERR; + case NC_DOUBLE: + *len = sizeof(double); + return NC_NOERR; + case NC_INT64: + case NC_UINT64: + *len = sizeof(long long); + return NC_NOERR; + case NC_STRING: + *len = sizeof(char *); + return NC_NOERR; + } + + /* See if var is compound type. */ + if ((retval = nc4_find_type(h5, xtype, &type))) + return retval; + + if (!type) + return NC_EBADTYPE; + + *len = type->size; + + LOG((5, "type->size: %d", type->size)); + + return NC_NOERR; +} diff --git a/nc_test/Makefile.am b/nc_test/Makefile.am index 23e16db048..4ea7b399e6 100644 --- a/nc_test/Makefile.am +++ b/nc_test/Makefile.am @@ -51,7 +51,7 @@ TESTPROGRAMS += testnc3perf testnc3perf_SOURCES = testnc3perf.c endif -if USE_NETCDF4 +if USE_HDF5 TESTPROGRAMS += tst_diskless6 tst_diskless6_SOURCES = tst_diskless6.c endif @@ -62,7 +62,7 @@ check_PROGRAMS = $(TESTPROGRAMS) # Build Diskless test helpers check_PROGRAMS += tst_diskless tst_diskless3 tst_diskless4 \ tst_diskless5 tst_inmemory tst_open_mem -if USE_NETCDF4 +if USE_HDF5 check_PROGRAMS += tst_diskless2 endif diff --git a/nc_test/nc_test.c b/nc_test/nc_test.c index 9e5490e82f..1a5c910884 100644 --- a/nc_test/nc_test.c +++ b/nc_test/nc_test.c @@ -153,7 +153,7 @@ main(int argc, char *argv[]) case NC_FORMAT_NETCDF4_CLASSIC: -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 nc_set_default_format(NC_FORMAT_NETCDF4_CLASSIC, NULL); strcpy(testfile, "nc_test_netcdf4.nc"); fprintf(stderr, "\n\nSwitching to netCDF-4 format (with NC_CLASSIC_MODEL).\n"); diff --git a/nc_test/run_diskless.sh b/nc_test/run_diskless.sh index f7e87fdc35..30d27fa5df 100755 --- a/nc_test/run_diskless.sh +++ b/nc_test/run_diskless.sh @@ -17,18 +17,18 @@ FILE3=tst_diskless3.nc echo "" echo "*** Testing in-memory (diskless) files with and without persistence" -HASNC4=`${top_builddir}/nc-config --has-nc4` +HASHDF5=`${top_builddir}/nc-config --has-hdf5` echo "**** Test diskless netCDF classic file without persistence" ${execdir}/tst_diskless echo "PASS: diskless netCDF classic file without persistence" -if test "x$HASNC4" = "xyes" ; then +if test "x$HASHDF5" = "xyes" ; then echo "" echo "**** Test diskless netCDF enhanced file without persistence" ${execdir}/tst_diskless netcdf4 echo "PASS: diskless netCDF enhanced file without persistence" -fi #HASNC4 +fi #HASHDF5 echo "" echo "**** Test diskless netCDF classic file with persistence" @@ -43,7 +43,7 @@ echo "#### $FILE1 not created" echo "FAIL: diskless netCDF classic file with persistence" fi -if test "x$HASNC4" = "xyes" ; then +if test "x$HASHDF5" = "xyes" ; then echo "" echo "**** Test diskless netCDF enhanced file with persistence" rm -f $FILE1 @@ -57,10 +57,10 @@ echo "$FILE1 not created" echo "FAIL: diskless netCDF enhanced file with persistence" fi -fi #HASNC4 +fi #HASHDF5 # Do extended netcdf enhanced test -if test "x$HASNC4" = "xyes" ; then +if test "x$HASHDF5" = "xyes" ; then ok="" echo "" @@ -90,7 +90,7 @@ else echo "FAIL: extended enhanced diskless netCDF with persistence" fi -fi #HASNC4 +fi #HASHDF5 echo "" echo "**** Testing nc_open in-memory (diskless) files" diff --git a/nc_test/run_inmemory.sh b/nc_test/run_inmemory.sh index b4515c5d1b..e9f90eb6c6 100755 --- a/nc_test/run_inmemory.sh +++ b/nc_test/run_inmemory.sh @@ -22,7 +22,7 @@ OMEMFILE=f03tst_open_mem.nc echo "" echo "*** Testing in-memory operations" -HASNC4=`${top_builddir}/nc-config --has-nc4` +HASHDF5=`${top_builddir}/nc-config --has-hdf5` # Execute the core of the inmemory tests ${execdir}/tst_inmemory @@ -34,7 +34,7 @@ ${NCDUMP} -n "${FILE3}" ${FILE3}.nc > ${FILE3}.cdl ${NCDUMP} -n "${FILE3}" ${CREATE3}.nc > ${CREATE3}.cdl diff -wb ${FILE3}.cdl ${CREATE3}.cdl -if test "x$HASNC4" = "xyes" ; then +if test "x$HASHDF5" = "xyes" ; then ${NCDUMP} ${FILE4}.nc > ${FILE4}.cdl ${NCDUMP} ${CREATE4}.nc > ${CREATE4}.cdl diff -wb ${FILE4}.cdl ${CREATE4}.cdl diff --git a/nc_test/tst_default_format.c b/nc_test/tst_default_format.c index f1f4e06838..886cc7d191 100644 --- a/nc_test/tst_default_format.c +++ b/nc_test/tst_default_format.c @@ -37,7 +37,7 @@ create_check(char *fname, int cmode, int exp_format) default: break; } -#ifndef USE_NETCDF4 +#ifndef USE_HDF5 if (cmode & NC_NETCDF4) exp_err = NC_ENOTBUILT; #endif @@ -160,7 +160,7 @@ int main(int argc, char *argv[]) nerrs += create_check(fname, cmode, NC_FORMAT_64BIT_OFFSET); #endif -#ifndef USE_NETCDF4 +#ifndef USE_HDF5 err = nc_set_default_format(NC_FORMAT_NETCDF4, NULL); EXP_ERR(NC_ENOTBUILT) err = nc_set_default_format(NC_FORMAT_NETCDF4_CLASSIC, NULL); EXP_ERR(NC_ENOTBUILT) nerrs += create_check(fname, NC_NETCDF4, NC_FORMAT_NETCDF4); diff --git a/nc_test/tst_formats.c b/nc_test/tst_formats.c index 814904a5a6..6033138e98 100644 --- a/nc_test/tst_formats.c +++ b/nc_test/tst_formats.c @@ -36,11 +36,11 @@ determine_test_formats(int *num_formats, int *format) format[ind++] = NC_FORMAT_64BIT_OFFSET; /* Do we have netCDF-4 and netCDF-4 classic? */ -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 num += 2; format[ind++] = NC_FORMAT_NETCDF4; format[ind++] = NC_FORMAT_NETCDF4_CLASSIC; -#endif /* USE_NETCDF4 */ +#endif /* USE_HDF5 */ /* Do we have CDF5? */ #ifdef ENABLE_CDF5 diff --git a/nc_test/tst_global_fillval.c b/nc_test/tst_global_fillval.c index 4812d3f72a..92060bee71 100644 --- a/nc_test/tst_global_fillval.c +++ b/nc_test/tst_global_fillval.c @@ -33,7 +33,7 @@ main(int argc, char **argv) int *formats = NULL; /* Determine how many formats are in use. */ -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 num_formats += 2; #endif @@ -49,7 +49,7 @@ main(int argc, char **argv) #ifdef ENABLE_CDF5 formats[n++] = NC_64BIT_DATA; #endif -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 formats[n++] = NC_NETCDF4; formats[n++] = NC_CLASSIC_MODEL | NC_NETCDF4; #endif diff --git a/nc_test/tst_inmemory.c b/nc_test/tst_inmemory.c index af3f1b6e10..5aba2f6eaf 100644 --- a/nc_test/tst_inmemory.c +++ b/nc_test/tst_inmemory.c @@ -20,7 +20,7 @@ redistribution conditions. #include "nc_tests.h" #include "err_macros.h" -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 #include extern int H5Eprint1(FILE * stream); #endif @@ -408,7 +408,7 @@ verify_file(int ncid, int modified, int extra) int milesdata_in[MAXDIMLEN]; int expenses_in[MAXDIMLEN]; int dimprod = DIM0_LEN * DIM1_LEN; -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 int tmp; #endif @@ -417,7 +417,7 @@ verify_file(int ncid, int modified, int extra) CHECK(NC_EINVAL); /* Get all the dimids */ -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 tmp = 0; CHECK((nc_inq_dimids(ncid,&tmp,dimid,1))); if(tmp != NDIMS0+extra) CHECK(NC_EINVAL); @@ -709,7 +709,7 @@ main(int argc, char **argv) int stat = NC_NOERR; NC_memio filedata3; void* original = NULL; -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 NC_memio filedata4; #endif @@ -721,7 +721,7 @@ main(int argc, char **argv) CHECK(test_xfail(FILE3, NC_NETCDF3, &filedata3)); memiofree(&filedata3,&original); -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 fprintf(stderr,"\n*** Testing the inmemory API: netcdf-4.\n"); CHECK(create_reference_file(FILE4,NC_NETCDF4,&filedata4)); CHECK(test_open(FILE4,&filedata4,NC_NETCDF4)); diff --git a/nc_test/tst_inq_type.c b/nc_test/tst_inq_type.c index 8bd0233013..0164cdc959 100644 --- a/nc_test/tst_inq_type.c +++ b/nc_test/tst_inq_type.c @@ -113,7 +113,7 @@ int main(int argc, char **argv) { SUMMARIZE_ERR; #endif /* ENABLE_CDF5 */ -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 printf("\n* Testing nc_inq_type with netcdf-4 + Classic Model\n"); { if(nc_create(FILE_NAME,NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL,&ncid)) ERR; @@ -178,7 +178,7 @@ int main(int argc, char **argv) { } SUMMARIZE_ERR; -#endif // USE_NETCDF4 +#endif // USE_HDF5 printf("* Finished.\n"); diff --git a/nc_test/tst_names.c b/nc_test/tst_names.c index 878ae32d90..d12522c5df 100644 --- a/nc_test/tst_names.c +++ b/nc_test/tst_names.c @@ -229,7 +229,7 @@ main(int argc, char **argv) , NC_FORMAT_CDF5 #endif -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 , NC_FORMAT_NETCDF4 , diff --git a/nc_test/tst_small.c b/nc_test/tst_small.c index 040f7e2164..cca6340fd9 100644 --- a/nc_test/tst_small.c +++ b/nc_test/tst_small.c @@ -533,7 +533,7 @@ main(int argc, char **argv) case NC_FORMAT_CDF5: continue; #endif -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 case NC_FORMAT_NETCDF4_CLASSIC: nc_set_default_format(NC_FORMAT_NETCDF4_CLASSIC, NULL); strcpy(testfile, "tst_small_netcdf4_classic.nc"); diff --git a/ncdump/Makefile.am b/ncdump/Makefile.am index 0b9e5648b9..3ea5a92ad6 100644 --- a/ncdump/Makefile.am +++ b/ncdump/Makefile.am @@ -30,7 +30,7 @@ nccopy_SOURCES = nccopy.c nciter.c nciter.h chunkspec.h chunkspec.c \ utils.h utils.c dimmap.h dimmap.c list.c list.h # A simple netcdf-4 metadata -> xml printer. Do not install. -if USE_NETCDF4 +if USE_HDF5 noinst_PROGRAMS += nc4print nc4print_SOURCES = nc4print.c endif @@ -70,7 +70,7 @@ if LARGE_FILE_TESTS TESTS += tst_iter.sh endif -if USE_NETCDF4 +if USE_HDF5 # NetCDF-4 has some extra C programs to build. These will be run by # the shell script tests. check_PROGRAMS += tst_fileinfo tst_create_files tst_h_rdc0 \ @@ -91,10 +91,10 @@ tst_ncgen4.sh tst_nccopy4.log: run_ncgen_tests.log tst_output.log tst_ncgen4.log \ tst_fillbug.log tst_netcdf4_4.log tst_h_scalar.log tst_nccopy5.log: tst_nccopy4.log -endif #!USE_NETCDF4 +endif #!USE_HDF5 TESTS += tst_inmemory_nc3.sh -if USE_NETCDF4 +if USE_HDF5 TESTS += tst_inmemory_nc4.sh endif diff --git a/ncgen/util.c b/ncgen/util.c index dde9d35e24..e0ec19064c 100644 --- a/ncgen/util.c +++ b/ncgen/util.c @@ -577,7 +577,7 @@ prefixarraylength(Dimset* dimset, int last) -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 extern int H5Eprint1(FILE * stream); #endif @@ -594,7 +594,7 @@ void check_err2(const int stat, const int cdlline, const int line, const char* f else fprintf(stderr, "ncgen: %s\n", nc_strerror(stat)); fprintf(stderr, "\t(%s:%d)\n", file,line); -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 H5Eprint1(stderr); #endif fflush(stderr); diff --git a/ncgen3/Makefile.am b/ncgen3/Makefile.am index e20f326ecc..39c58576c1 100644 --- a/ncgen3/Makefile.am +++ b/ncgen3/Makefile.am @@ -25,9 +25,9 @@ run_nc4_tests.sh XGetopt.c $(man_MANS) # them for DLL builds. #if !BUILD_DLL TESTS = run_tests.sh -if USE_NETCDF4 +if USE_HDF5 TESTS += run_nc4_tests.sh -endif # USE_NETCDF4 +endif # USE_HDF5 #endif # !BUILD_DLL CLEANFILES = c0.nc c0_64.nc c0_4.nc c0_4c.nc diff --git a/nctest/driver.c b/nctest/driver.c index 9d0c3c1571..e2b8277688 100644 --- a/nctest/driver.c +++ b/nctest/driver.c @@ -35,11 +35,11 @@ determine_test_formats(int *num_formats, int *format) format[ind++] = NC_FORMAT_64BIT_OFFSET; /* Do we have netCDF-4 and netCDF-4 classic? */ -#ifdef USE_NETCDF4 +#ifdef USE_HDF5 num += 2; format[ind++] = NC_FORMAT_NETCDF4_CLASSIC; format[ind++] = NC_FORMAT_NETCDF4; -#endif /* USE_NETCDF4 */ +#endif /* USE_HDF5 */ /* Do we have CDF5? */ #ifdef ENABLE_CDF5