From 406e979fb444f7622d8a2ac254461c1be798f13d Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 1 Nov 2017 04:31:12 -0600 Subject: [PATCH 1/9] fixed tst_enums memory issue --- libdispatch/dfile.c | 9 ++++++--- libsrc4/nc4file.c | 2 +- nc_test4/tst_enums.c | 5 +++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libdispatch/dfile.c b/libdispatch/dfile.c index f4c1ae3d2e..3b5b39126b 100644 --- a/libdispatch/dfile.c +++ b/libdispatch/dfile.c @@ -1234,10 +1234,13 @@ nc_close(int ncid) #endif { - stat = ncp->dispatch->close(ncid); + stat = ncp->dispatch->close(ncid); /* Remove from the nc list */ - del_from_NCList(ncp); - free_NC(ncp); + if (!stat) + { + del_from_NCList(ncp); + free_NC(ncp); + } } return stat; } diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index 6f07146a8c..3688b06796 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -3141,7 +3141,7 @@ close_netcdf4_file(NC_HDF5_FILE_INFO_T *h5, int abort) exit: /* Free the nc4_info struct; above code should have reclaimed everything else */ - if(h5 != NULL) + if(!retval && h5 != NULL) free(h5); return retval; } diff --git a/nc_test4/tst_enums.c b/nc_test4/tst_enums.c index 873800fc83..96a4e3136c 100644 --- a/nc_test4/tst_enums.c +++ b/nc_test4/tst_enums.c @@ -304,8 +304,13 @@ main(int argc, char **argv) /* Close the file. */ if (nc_close(ncid) != NC_EINVAL) ERR; + unsigned char ubyte_value = 42; + if (nc_redef(ncid)) ERR; + if (nc_insert_enum(ncid, typeid, "name", &ubyte_value)) ERR; + if (nc_close(ncid)) ERR; } SUMMARIZE_ERR; FINAL_RESULTS; } + From c71e4dde09658a543d53ca622197e35714a882a2 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 1 Nov 2017 05:09:29 -0600 Subject: [PATCH 2/9] removed historic file no longer used: nc_test/ncx.c --- nc_test/Makefile.am | 5 ----- 1 file changed, 5 deletions(-) diff --git a/nc_test/Makefile.am b/nc_test/Makefile.am index 87d074e9e1..56b0e74f45 100644 --- a/nc_test/Makefile.am +++ b/nc_test/Makefile.am @@ -109,11 +109,6 @@ EXTRA_DIST += ref_tst_diskless2.cdl tst_diskless5.cdl CMakeLists.txt # regenerate. #MAINTAINERCLEANFILES = test_get.c test_put.c -all: - cp $(top_srcdir)/libsrc/ncx.c . - -CLEANFILES += ncx.c - # This rule tells make how to turn our .m4 files into .c files. .m4.c: m4 $(AM_M4FLAGS) $(M4FLAGS) $< >$@ From 3fbbe847d87d35b3403882d31f787a0dc070ff05 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 3 Nov 2017 11:58:22 -0600 Subject: [PATCH 3/9] added v2 documentation --- libdispatch/dv2i.c | 566 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 545 insertions(+), 21 deletions(-) diff --git a/libdispatch/dv2i.c b/libdispatch/dv2i.c index 0110d35ccf..9517789906 100644 --- a/libdispatch/dv2i.c +++ b/libdispatch/dv2i.c @@ -13,6 +13,23 @@ See \ref copyright file for copying and redistribution conditions. #include #include "netcdf.h" #include "math.h" + +/** \defgroup v2_api The Version 2 API + +NetCDF's modern history began with the introduction of the V2 netCDF +API by Glenn Davis and Russ Rew in 1991. (The V1 API is lost to mists +of time.) + +The V2 API is still fully supported, but should not be used for new +development. + +All of the V2 functions have been reimplemented in terms of the V3 API +code; see the documentation for the related V3 functions to get more +documentation. + +The V2 API is tested in test directory nctest. +*/ + /* The subroutines in error.c emit no messages unless NC_VERBOSE bit * is on. They call exit() when NC_FATAL bit is on. */ int ncopts = (NC_FATAL | NC_VERBOSE) ; @@ -220,12 +237,29 @@ dimsizes(int ncid, int varid, size_t *sizes) return NC_NOERR; } - -/* - * Retrieves the number of record variables, the record variable ids, and the - * record size of each record variable. If any pointer to info to be returned - * is null, the associated information is not returned. Returns -1 on error. - */ +/** \ingroup v2_api + +Retrieves the number of record variables, the record variable ids, and the +record size of each record variable. If any pointer to info to be returned +is null, the associated information is not returned. Returns -1 on error. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 functions nc_inq_nvars(), +nc_inq_unlimdim(), nc_inq_dim(). + +\param ncid file ID +\param nrecvarsp pointer that will get the number of record variables +in the file. +\param recvarids pointer to array that will get the variable IDs of +all variables that use the record dimension. +\param recsizes pointer to array that will dimension size of the +record dimension for each variable. + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. +\returns ::NC_EINVAL Invalid input +*/ int nc_inq_rec( int ncid, @@ -273,13 +307,25 @@ nc_inq_rec( return NC_NOERR; } +/** \ingroup v2_api -/* - * Write one record's worth of data, except don't write to variables for which - * the address of the data to be written is NULL. Return -1 on error. This is - * the same as the ncrecput() in the library, except that can handle errors - * better. - */ +Write one record's worth of data, except don't write to variables for which +the address of the data to be written is NULL. Return -1 on error. This is +the same as the ncrecput() in the library, except that can handle errors +better. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_put_vara(). + +\param ncid file ID +\param recnum the record number to write. +\param datap pointer to one record's worth of data for all variables. + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. +\returns ::NC_EINVAL Invalid input +*/ int nc_put_rec( int ncid, @@ -320,12 +366,27 @@ nc_put_rec( } -/* - * Read one record's worth of data, except don't read from variables for which - * the address of the data to be read is null. Return -1 on error. This is - * the same as the ncrecget() in the library, except that can handle errors - * better. - */ +/** \ingroup v2_api + +Read one record's worth of data, except don't read from variables for which +the address of the data to be read is null. Return -1 on error. This is +the same as the ncrecget() in the library, except that can handle errors +better. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_get_vara(). + +\param ncid file ID +\param recnum the record number to read. +\param datap pointer memory to hold one record's worth of data for all +variables. + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. +\returns ::NC_EINVAL Invalid input + +*/ int nc_get_rec( int ncid, @@ -364,8 +425,18 @@ nc_get_rec( return 0; } -/* - */ +/** \ingroup v2_api + +Show an error message and exit (based on ncopts). + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_strerror() + +\param routine_name +\param err error code +\param fmt pointer to a char array containing string format + +*/ void nc_advise(const char *routine_name, int err, const char *fmt,...) { @@ -399,6 +470,18 @@ nc_advise(const char *routine_name, int err, const char *fmt,...) /* End error handling */ +/** \ingroup v2_api + +Create a netCDF file. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_create(). + +\param path path and filename of the file to be created. +\param cmode see nc_create() for full discussion of the create mode. + +\returns the ncid of the created file. +*/ int nccreate(const char* path, int cmode) { @@ -412,7 +495,18 @@ nccreate(const char* path, int cmode) return ncid; } +/** \ingroup v2_api + +Open a netCDF file. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_open(). + +\param path path and filename of the file to be created. +\param mode see nc_open() for full discussion of the open mode. +\returns the ncid of the created file. +*/ int ncopen(const char *path, int mode) { @@ -426,7 +520,17 @@ ncopen(const char *path, int mode) return ncid; } +/** \ingroup v2_api +Put file in define mode. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_redef(). + +\param ncid file ID + +\returns 0 for success, -1 for failure. +*/ int ncredef(int ncid) { @@ -439,7 +543,17 @@ ncredef(int ncid) return 0; } +/** \ingroup v2_api + +End define mode for file. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_enddef(). +\param ncid file ID + +\returns 0 for success, -1 for failure. +*/ int ncendef(int ncid) { @@ -452,7 +566,17 @@ ncendef(int ncid) return 0; } +/** \ingroup v2_api + +Close a file. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_close(). + +\param ncid file ID +\returns 0 for success, -1 for failure. +*/ int ncclose(int ncid) { @@ -466,7 +590,22 @@ ncclose(int ncid) return 0; } +/** \ingroup v2_api +Learn about a file. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_inq(). + +\param ncid file ID +\param ndims pointer that will get number of dimensions. +\param nvars pointer that will get number of variables. +\param natts pointer that will get number of global attributes. +\param recdim pointer that will get dimension ID of record dimension, +or -1 if there is no record dimension. + +\returns 0 for success, -1 for failure. +*/ int ncinquire( int ncid, @@ -498,7 +637,17 @@ ncinquire( return ncid; } +/** \ingroup v2_api + +Sync a file. +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_sync(). + +\param ncid file ID + +\returns 0 for success, -1 for failure. +*/ int ncsync(int ncid) { @@ -512,7 +661,16 @@ ncsync(int ncid) return 0; } +/** \ingroup v2_api + +Abort defining a file. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_abort(). +\param ncid file ID +\returns 0 for success, -1 for failure. +*/ int ncabort(int ncid) { @@ -525,7 +683,20 @@ ncabort(int ncid) return 0; } +/** \ingroup v2_api +Define a dimension. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_def_dim(). + +\param ncid file ID +\param name name of dimension. +\param length length of the dimension, NC_UNLIMITED for a record +dimension. + +\returns dimid or -1 for failure. +*/ int ncdimdef( int ncid, @@ -549,7 +720,18 @@ ncdimdef( return dimid; } +/** \ingroup v2_api + +Find dimension ID from name. +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_inq_dimid(). + +\param ncid file ID +\param name name of dimension. + +\returns dimid or -1 for failure. +*/ int ncdimid(int ncid, const char* name) { @@ -563,7 +745,20 @@ ncdimid(int ncid, const char* name) return dimid; } +/** \ingroup v2_api + +Learn about a dimension. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_inq_dim(). +\param ncid file ID +\param dimid the dimension ID to learn about +\param name pointer that will get name of dimension. +\param length pointer that will get length of dimension. + +\returns dimid or -1 for failure. +*/ int ncdiminq( int ncid, @@ -588,7 +783,19 @@ ncdiminq( return dimid; } +/** \ingroup v2_api + +Rename a dimension. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_rename_dim(). + +\param ncid file ID +\param dimid the dimension ID. +\param name the new name. +\returns dimid or -1 for failure. +*/ int ncdimrename( int ncid, @@ -605,7 +812,21 @@ ncdimrename( return dimid; } +/** \ingroup v2_api +Define a variable. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_def_var(). + +\param ncid file ID +\param name the name of the variable. +\param datatype the data type of the variable. +\param ndims the number of dimensions. +\param dim array of dimension IDs. + +\returns varid or -1 for failure. +*/ int ncvardef( int ncid, @@ -625,7 +846,18 @@ ncvardef( return varid; } +/** \ingroup v2_api + +Learn a variable ID from the name. +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_inq_varid(). + +\param ncid file ID +\param name the name of the variable. + +\returns varid or -1 for failure. +*/ int ncvarid( int ncid, @@ -642,7 +874,23 @@ ncvarid( return varid; } +/** \ingroup v2_api + +Learn about a variable. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_inq_var(). + +\param ncid file ID +\param varid the variable ID. +\param name pointer to array of char that will get name of variable. +\param datatype pointer that will get variable data type. +\param ndims pointer that will get number of dimensions. +\param dim pointer to array that will get dimension IDs. +\param natts pointer that will get number of variable attributes. +\returns varid or -1 for failure. +*/ int ncvarinq( int ncid, @@ -674,7 +922,20 @@ ncvarinq( return varid; } +/** \ingroup v2_api +Write 1 data value. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_put_var1(). + +\param ncid file ID +\param varid the variable ID. +\param index pointer to array of index values. +\param value pointer to data. + +\returns 0 for success or -1 for failure. +*/ int ncvarput1( int ncid, @@ -698,7 +959,20 @@ ncvarput1( return 0; } +/** \ingroup v2_api + +Read 1 data value. +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_get_var1(). + +\param ncid file ID +\param varid the variable ID. +\param index pointer to array of index values. +\param value pointer that will get data. + +\returns 0 for success or -1 for failure. +*/ int ncvarget1( int ncid, @@ -722,7 +996,21 @@ ncvarget1( return 0; } +/** \ingroup v2_api + +Write some data. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_put_vara(). +\param ncid file ID +\param varid the variable ID. +\param start pointer to array of start values. +\param count pointer to array of count values. +\param value pointer to data. + +\returns 0 for success or -1 for failure. +*/ int ncvarput( int ncid, @@ -750,7 +1038,21 @@ ncvarput( return 0; } +/** \ingroup v2_api + +Read some data. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_get_vara(). + +\param ncid file ID +\param varid the variable ID. +\param start pointer to array of start values. +\param count pointer to array of count values. +\param value pointer to data. +\returns 0 for success or -1 for failure. +*/ int ncvarget( int ncid, @@ -778,7 +1080,22 @@ ncvarget( return 0; } +/** \ingroup v2_api +Write strided data. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_put_vars(). + +\param ncid file ID +\param varid the variable ID. +\param start pointer to array of start values. +\param count pointer to array of count values. +\param stride pointer to array of stride values. +\param value pointer to data. + +\returns 0 for success or -1 for failure. +*/ int ncvarputs( int ncid, @@ -816,7 +1133,22 @@ ncvarputs( } } +/** \ingroup v2_api + +Read strided data. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_get_vars(). +\param ncid file ID +\param varid the variable ID. +\param start pointer to array of start values. +\param count pointer to array of count values. +\param stride pointer to array of stride values. +\param value pointer to data. + +\returns 0 for success or -1 for failure. +*/ int ncvargets( int ncid, @@ -853,7 +1185,23 @@ ncvargets( } } +/** \ingroup v2_api + +Write mapped data. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_get_varm(). + +\param ncid file ID +\param varid the variable ID. +\param start pointer to array of start values. +\param count pointer to array of count values. +\param stride pointer to array of stride values. +\param map pointer to array of map values. +\param value pointer to data. +\returns 0 for success or -1 for failure. +*/ int ncvarputg( int ncid, @@ -910,7 +1258,23 @@ ncvarputg( } } +/** \ingroup v2_api +Read mapped data. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_get_varm(). + +\param ncid file ID +\param varid the variable ID. +\param start pointer to array of start values. +\param count pointer to array of count values. +\param stride pointer to array of stride values. +\param map pointer to array of map values. +\param value pointer to data. + +\returns 0 for success or -1 for failure. +*/ int ncvargetg( int ncid, @@ -967,7 +1331,19 @@ ncvargetg( } } +/** \ingroup v2_api + +Rename a variable. +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_rename_var(). + +\param ncid file ID +\param varid the variable ID. +\param name the new name. + +\returns varid or -1 for failure. +*/ int ncvarrename( int ncid, @@ -984,7 +1360,22 @@ ncvarrename( return varid; } +/** \ingroup v2_api + +Write an attribute. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_put_att_int(), etc. +\param ncid file ID +\param varid the variable ID or NC_GLOBAL. +\param name the name of the attribute. +\param datatype the type of the attribute. +\param len the length of the attribute. +\param value the attribute value. + +\returns dimid or -1 for failure. +*/ int ncattput( int ncid, @@ -1004,7 +1395,22 @@ ncattput( return 0; } +/** \ingroup v2_api + +Learn about an attribute. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_inq_att(). +\param ncid file ID +\param varid the variable ID. +\param name the name of the attribute. +\param datatype pointer that will get data type. +\param len pointer that will get length. + +\returns 1 for success or -1 for failure. (That's a delightful +artifact of a by-gone era of C programming, isn't it?) +*/ int ncattinq( int ncid, @@ -1028,10 +1434,22 @@ ncattinq( *len = (int) ll; return 1; - } +/** \ingroup v2_api +Read an attribute. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_get_att_int(), etc. + +\param ncid file ID. +\param varid the variable ID or NC_GLOBAL. +\param name the name of the attribute. +\param value pointer that will get the attribute data. + +\returns 1 for success or -1 for failure. +*/ int ncattget( int ncid, @@ -1049,7 +1467,21 @@ ncattget( return 1; } +/** \ingroup v2_api + +Copy an attribute. +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_get_att_int(), etc. + +\param ncid_in file ID to copy from. +\param varid_in the variable ID or NC_GLOBAL to copy from. +\param name the name of the attribute. +\param ncid_out file ID to copy to. +\param varid_out the variable ID or NC_GLOBAL to copy to. + +\returns 0 for success or -1 for failure. +*/ int ncattcopy( int ncid_in, @@ -1068,7 +1500,20 @@ ncattcopy( return 0; } +/** \ingroup v2_api + +Learn attribute name from its number. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_inq_attname(). +\param ncid file ID +\param varid the variable ID. +\param attnum the number of the attribute. +\param name the name of the attribute. + +\returns attnum for success or -1 for failure. +*/ int ncattname( int ncid, @@ -1086,7 +1531,20 @@ ncattname( return attnum; } +/** \ingroup v2_api + +Rename an attribute. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_rename_att(). + +\param ncid file ID +\param varid the variable ID. +\param name the attribute name. +\param newname the new name. +\returns 1 for success or -1 for failure. +*/ int ncattrename( int ncid, @@ -1104,7 +1562,19 @@ ncattrename( return 1; } +/** \ingroup v2_api +Delete an attribute. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_delete_att(). + +\param ncid file ID +\param varid the variable ID. +\param name the attribute name. + +\returns 1 for success or -1 for failure. +*/ int ncattdel( int ncid, @@ -1125,6 +1595,18 @@ ncattdel( #ifndef NO_NETCDF_2 +/** \ingroup v2_api + +Set the fill mode. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_set_fill(). + +\param ncid file ID +\param fillmode NC_FILL or NC_NOFILL. + +\returns oldmode for success or -1 for failure. +*/ int ncsetfill( int ncid, @@ -1141,7 +1623,20 @@ ncsetfill( return oldmode; } +/** \ingroup v2_api + +Learn record variables and the lengths of the record dimension. +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 functions nc_inq_var()/nc_inq_dim(). + +\param ncid file ID +\param nrecvars pointer that will get number of record variables. +\param recvarids pointer that will get array of record variable IDs. +\param recsizes pointer that will get array of record dimension length. + +\returns oldmode for success or -1 for failure. +*/ int ncrecinq( int ncid, @@ -1183,7 +1678,22 @@ ncrecinq( return (int) nrv; } +/** \ingroup v2_api + +Read one record's worth of data, except don't read from variables for which +the address of the data to be read is null. Return -1 on error. This is +the same as the nc_get_rec(), with poorer error handling. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_get_vara(). +\param ncid file ID +\param recnum the record number to read. +\param datap pointer memory to hold one record's worth of data for all +variables. + +\returns 0 for success, -1 for error. +*/ int ncrecget( int ncid, @@ -1200,7 +1710,21 @@ ncrecget( return 0; } +/** \ingroup v2_api + +Write one record's worth of data, except don't write to variables for which +the address of the data to be written is NULL. Return -1 on error. This is +the same as the nc_put_rec(), but with poorer error handling. + +This is part of the legacy V2 API of netCDF. New code should be +written with the V3 API. See V3 function nc_put_vara(). + +\param ncid file ID +\param recnum the record number to write. +\param datap pointer to one record's worth of data for all variables. +\returns 0 for success, -1 for error. +*/ int ncrecput( int ncid, From 74519d550bc0d04b1de61a57250b97a9ed095698 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Sat, 4 Nov 2017 08:12:48 -0600 Subject: [PATCH 4/9] moved tests dependant on ncdump inside BUILD_UTILITIES block in Makefile.am files --- dap4_test/Makefile.am | 4 ++-- ncdap_test/Makefile.am | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dap4_test/Makefile.am b/dap4_test/Makefile.am index 7534768956..733020c0f6 100644 --- a/dap4_test/Makefile.am +++ b/dap4_test/Makefile.am @@ -25,12 +25,12 @@ test_parse_SOURCES = test_parse.c test_common.h test_meta_SOURCES = test_meta.c test_common.h test_data_SOURCES = test_data.c test_common.h TESTS += test_parse.sh -TESTS += test_meta.sh -TESTS += test_data.sh if BUILD_UTILITIES # These rely on ncdump TESTS += test_raw.sh +TESTS += test_meta.sh +TESTS += test_data.sh endif if ENABLE_DAP_REMOTE_TESTS diff --git a/ncdap_test/Makefile.am b/ncdap_test/Makefile.am index 3ed2849c3b..dad6893495 100644 --- a/ncdap_test/Makefile.am +++ b/ncdap_test/Makefile.am @@ -27,7 +27,9 @@ test_vara_SOURCES = test_vara.c t_srcdir.h if ENABLE_DAP check_PROGRAMS += t_dap3a test_cvt3 test_vara TESTS += t_dap3a test_cvt3 test_vara +if BUILD_UTILITIES TESTS += tst_ncdap3.sh +endif # remote tests are optional # because the server may be down or inaccessible @@ -37,10 +39,10 @@ check_PROGRAMS += findtestserver findtestserver_SOURCES = findtestserver.c if BUILD_UTILITIES -TESTS += tst_ber.sh tst_remote3.sh tst_formatx.sh +TESTS += tst_ber.sh tst_remote3.sh tst_formatx.sh testurl.sh endif -TESTS += test_partvar testurl.sh +TESTS += test_partvar if ENABLE_DAP_LONG_TESTS TESTS += tst_longremote3.sh From 9d187c099ac3671b2255b14f409f3a1c03cca2b0 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 8 Nov 2017 04:20:13 -0700 Subject: [PATCH 5/9] fixed file name in test --- h5_test/tst_h_dimscales1.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/h5_test/tst_h_dimscales1.c b/h5_test/tst_h_dimscales1.c index da8b12cf27..c834835ac1 100644 --- a/h5_test/tst_h_dimscales1.c +++ b/h5_test/tst_h_dimscales1.c @@ -6,13 +6,13 @@ but they use HDF5 the same way that netCDF-4 does, so if these tests don't work, than netCDF-4 won't work either. - $Id: tst_h_dimscales1.c,v 1.2 2010/06/01 15:34:51 ed Exp $ + @author Ed Hartnett */ #include "h5_err_macros.h" #include #include -#define FILE_NAME "tst_h_dimscales.h5" +#define FILE_NAME "tst_h_dimscales1.h5" int main() { @@ -42,29 +42,29 @@ main() /* Create our dimension scale. Use the built-in NAME attribute * on the dimscale. */ - if ((dimscale_spaceid = H5Screate_simple(1, dimscale_dims, - dimscale_dims)) < 0) ERR; - if ((dimscaleid = H5Dcreate(grpid, DIMSCALE_NAME, H5T_NATIVE_INT, - dimscale_spaceid, H5P_DEFAULT)) < 0) ERR; + if ((dimscale_spaceid = H5Screate_simple(1, dimscale_dims, + dimscale_dims)) < 0) ERR; + if ((dimscaleid = H5Dcreate(grpid, DIMSCALE_NAME, H5T_NATIVE_INT, + dimscale_spaceid, H5P_DEFAULT)) < 0) ERR; if (H5DSset_scale(dimscaleid, NAME_ATTRIBUTE) < 0) ERR; /* Create a 1D variable which uses the dimscale. Attach a label * to this scale. */ if ((var1_spaceid = H5Screate_simple(1, dims, dims)) < 0) ERR; - if ((var1_datasetid = H5Dcreate(grpid, VAR1_NAME, H5T_NATIVE_INT, - var1_spaceid, H5P_DEFAULT)) < 0) ERR; + if ((var1_datasetid = H5Dcreate(grpid, VAR1_NAME, H5T_NATIVE_INT, + var1_spaceid, H5P_DEFAULT)) < 0) ERR; if (H5DSattach_scale(var1_datasetid, dimscaleid, 0) < 0) ERR; if (H5DSset_label(var1_datasetid, 0, FIFTIES_SONG) < 0) ERR; /* Create a 1D variabls that doesn't use the dimension scale. */ - if ((var2_datasetid = H5Dcreate(grpid, VAR2_NAME, H5T_NATIVE_INT, - var1_spaceid, H5P_DEFAULT)) < 0) ERR; + if ((var2_datasetid = H5Dcreate(grpid, VAR2_NAME, H5T_NATIVE_INT, + var1_spaceid, H5P_DEFAULT)) < 0) ERR; /* Create a 2D dataset which uses the scale for one of its * dimensions. */ if ((var3_spaceid = H5Screate_simple(2, dims, dims)) < 0) ERR; - if ((var3_datasetid = H5Dcreate(grpid, VAR3_NAME, H5T_NATIVE_INT, - var3_spaceid, H5P_DEFAULT)) < 0) ERR; + if ((var3_datasetid = H5Dcreate(grpid, VAR3_NAME, H5T_NATIVE_INT, + var3_spaceid, H5P_DEFAULT)) < 0) ERR; if (H5DSattach_scale(var3_datasetid, dimscaleid, 0) < 0) ERR; /* Detach the scale. */ @@ -72,13 +72,13 @@ main() /* Close up the shop. */ if (H5Dclose(dimscaleid) < 0 || - H5Dclose(var1_datasetid) < 0 || - H5Dclose(var2_datasetid) < 0 || - H5Dclose(var3_datasetid) < 0 || - H5Sclose(var1_spaceid) < 0 || - H5Sclose(var3_spaceid) < 0 || - H5Sclose(dimscale_spaceid) < 0 || - H5Gclose(grpid) < 0 || + H5Dclose(var1_datasetid) < 0 || + H5Dclose(var2_datasetid) < 0 || + H5Dclose(var3_datasetid) < 0 || + H5Sclose(var1_spaceid) < 0 || + H5Sclose(var3_spaceid) < 0 || + H5Sclose(dimscale_spaceid) < 0) ERR; + if (H5Gclose(grpid) < 0 || H5Fclose(fileid) < 0) ERR; } SUMMARIZE_ERR; From d1946e4b69032bfa2cc9f9f8317c3bfc6b2866a3 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 8 Nov 2017 04:28:44 -0700 Subject: [PATCH 6/9] cleanup whitespace issues --- h5_test/tst_h_dimscales1.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/h5_test/tst_h_dimscales1.c b/h5_test/tst_h_dimscales1.c index c834835ac1..35b4f59c82 100644 --- a/h5_test/tst_h_dimscales1.c +++ b/h5_test/tst_h_dimscales1.c @@ -36,35 +36,35 @@ main() hsize_t dimscale_dims[1] = {DIM1_LEN}; /* Open file and create group. */ - if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, - H5P_DEFAULT)) < 0) ERR; + if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, + H5P_DEFAULT)) < 0) ERR; if ((grpid = H5Gcreate(fileid, GRP_NAME, 0)) < 0) ERR; - + /* Create our dimension scale. Use the built-in NAME attribute * on the dimscale. */ if ((dimscale_spaceid = H5Screate_simple(1, dimscale_dims, - dimscale_dims)) < 0) ERR; + dimscale_dims)) < 0) ERR; if ((dimscaleid = H5Dcreate(grpid, DIMSCALE_NAME, H5T_NATIVE_INT, - dimscale_spaceid, H5P_DEFAULT)) < 0) ERR; + dimscale_spaceid, H5P_DEFAULT)) < 0) ERR; if (H5DSset_scale(dimscaleid, NAME_ATTRIBUTE) < 0) ERR; /* Create a 1D variable which uses the dimscale. Attach a label * to this scale. */ if ((var1_spaceid = H5Screate_simple(1, dims, dims)) < 0) ERR; if ((var1_datasetid = H5Dcreate(grpid, VAR1_NAME, H5T_NATIVE_INT, - var1_spaceid, H5P_DEFAULT)) < 0) ERR; + var1_spaceid, H5P_DEFAULT)) < 0) ERR; if (H5DSattach_scale(var1_datasetid, dimscaleid, 0) < 0) ERR; if (H5DSset_label(var1_datasetid, 0, FIFTIES_SONG) < 0) ERR; /* Create a 1D variabls that doesn't use the dimension scale. */ if ((var2_datasetid = H5Dcreate(grpid, VAR2_NAME, H5T_NATIVE_INT, - var1_spaceid, H5P_DEFAULT)) < 0) ERR; + var1_spaceid, H5P_DEFAULT)) < 0) ERR; /* Create a 2D dataset which uses the scale for one of its * dimensions. */ if ((var3_spaceid = H5Screate_simple(2, dims, dims)) < 0) ERR; if ((var3_datasetid = H5Dcreate(grpid, VAR3_NAME, H5T_NATIVE_INT, - var3_spaceid, H5P_DEFAULT)) < 0) ERR; + var3_spaceid, H5P_DEFAULT)) < 0) ERR; if (H5DSattach_scale(var3_datasetid, dimscaleid, 0) < 0) ERR; /* Detach the scale. */ @@ -72,16 +72,15 @@ main() /* Close up the shop. */ if (H5Dclose(dimscaleid) < 0 || - H5Dclose(var1_datasetid) < 0 || - H5Dclose(var2_datasetid) < 0 || - H5Dclose(var3_datasetid) < 0 || - H5Sclose(var1_spaceid) < 0 || - H5Sclose(var3_spaceid) < 0 || - H5Sclose(dimscale_spaceid) < 0) ERR; + H5Dclose(var1_datasetid) < 0 || + H5Dclose(var2_datasetid) < 0 || + H5Dclose(var3_datasetid) < 0 || + H5Sclose(var1_spaceid) < 0 || + H5Sclose(var3_spaceid) < 0 || + H5Sclose(dimscale_spaceid) < 0) ERR; if (H5Gclose(grpid) < 0 || - H5Fclose(fileid) < 0) ERR; + H5Fclose(fileid) < 0) ERR; } SUMMARIZE_ERR; FINAL_RESULTS; } - From bd22bde4c8a5abddb5d0b662d5eeccb3392a8d59 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 8 Nov 2017 04:29:53 -0700 Subject: [PATCH 7/9] final cleanup --- h5_test/tst_h_dimscales1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/h5_test/tst_h_dimscales1.c b/h5_test/tst_h_dimscales1.c index 35b4f59c82..6bc85f2494 100644 --- a/h5_test/tst_h_dimscales1.c +++ b/h5_test/tst_h_dimscales1.c @@ -77,8 +77,8 @@ main() H5Dclose(var3_datasetid) < 0 || H5Sclose(var1_spaceid) < 0 || H5Sclose(var3_spaceid) < 0 || - H5Sclose(dimscale_spaceid) < 0) ERR; - if (H5Gclose(grpid) < 0 || + H5Sclose(dimscale_spaceid) < 0 || + H5Gclose(grpid) < 0 || H5Fclose(fileid) < 0) ERR; } SUMMARIZE_ERR; From b9911d6e6f8eb98293e6f08298dc54b8d98e3b00 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 8 Nov 2017 13:25:23 -0700 Subject: [PATCH 8/9] took out most uses of EXTRA_TESTS, returned it to disabled by default --- configure.ac | 2 +- h5_test/tst_h_atts3.c | 2 -- h5_test/tst_h_atts4.c | 2 -- h5_test/tst_h_dimscales.c | 2 -- libsrc4/nc4file.c | 10 ---------- nc_test4/tst_camrun.c | 12 ------------ nc_test4/tst_files4.c | 2 -- nc_test4/tst_interops.c | 4 ---- nc_test4/tst_xplatform2.c | 2 -- nctest/Makefile.am | 2 -- 10 files changed, 1 insertion(+), 39 deletions(-) diff --git a/configure.ac b/configure.ac index 3f00cff8fa..24cc067ffa 100644 --- a/configure.ac +++ b/configure.ac @@ -462,7 +462,7 @@ AC_MSG_CHECKING([whether netCDF extra tests should be run (developers only)]) AC_ARG_ENABLE([extra-tests], [AS_HELP_STRING([--enable-extra-tests], [enable some extra tests that may not pass because of known issues])]) -test "x$enable_extra_tests" = xno || enable_extra_tests=yes +test "x$enable_extra_tests" = xyes || enable_extra_tests=no AC_MSG_RESULT($enable_extra_tests) if test "x$enable_extra_tests" = xyes; then AC_DEFINE([EXTRA_TESTS], [1], [if true, run extra tests which may not work yet]) diff --git a/h5_test/tst_h_atts3.c b/h5_test/tst_h_atts3.c index 2a4fe9a709..d80f41e637 100644 --- a/h5_test/tst_h_atts3.c +++ b/h5_test/tst_h_atts3.c @@ -35,7 +35,6 @@ int main() { printf("\n*** Checking HDF5 attribute functions some more.\n"); -#ifdef EXTRA_TESTS printf("*** Creating tst_xplatform2_3.nc with HDF only..."); { hid_t fapl_id, fcpl_id; @@ -308,6 +307,5 @@ main() free(vc_out[i].p); } SUMMARIZE_ERR; -#endif /* EXTRA_TESTS */ FINAL_RESULTS; } diff --git a/h5_test/tst_h_atts4.c b/h5_test/tst_h_atts4.c index eca0116132..86a7b86941 100644 --- a/h5_test/tst_h_atts4.c +++ b/h5_test/tst_h_atts4.c @@ -36,7 +36,6 @@ int main() { printf("\n*** Checking HDF5 attribute functions for memory leaks.\n"); -#ifdef EXTRA_TESTS printf("*** Checking vlen of compound file..."); { #define NUM_OBJ_2 2 @@ -181,6 +180,5 @@ main() free(vc_out); } SUMMARIZE_ERR; -#endif /* EXTRA_TESTS */ FINAL_RESULTS; } diff --git a/h5_test/tst_h_dimscales.c b/h5_test/tst_h_dimscales.c index 349b1a8368..c6c4c0bf12 100644 --- a/h5_test/tst_h_dimscales.c +++ b/h5_test/tst_h_dimscales.c @@ -362,7 +362,6 @@ main() } SUMMARIZE_ERR; -#ifdef EXTRA_TESTS printf("*** Checking that unlimited dimscale file can be read..."); { @@ -780,6 +779,5 @@ main() } SUMMARIZE_ERR; -#endif FINAL_RESULTS; } diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index b9edb6ef6c..63204bbf22 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -332,13 +332,8 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info, * fail if there are any open objects in the file. */ if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI)) BAIL(NC_EHDFERR); -#else - if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_STRONG)) - BAIL(NC_EHDFERR); -#endif /* EXTRA_TESTS */ #ifdef USE_PARALLEL4 /* If this is a parallel file create, set up the file creation @@ -2116,13 +2111,8 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc) if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI)) BAIL(NC_EHDFERR); -#else - if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_STRONG)) - BAIL(NC_EHDFERR); -#endif #ifdef USE_PARALLEL4 /* If this is a parallel file create, set up the file creation diff --git a/nc_test4/tst_camrun.c b/nc_test4/tst_camrun.c index 3038aa718f..2ce9cbbb02 100644 --- a/nc_test4/tst_camrun.c +++ b/nc_test4/tst_camrun.c @@ -662,7 +662,6 @@ # define RANK_wat_a2 4 # define RANK_wat_a3 4 -#ifdef EXTRA_TESTS #define MEGABYTE 1048576 void get_mem_used2(int *mem_used) @@ -691,7 +690,6 @@ get_mem_used2(int *mem_used) *mem_used = -1; fclose(pf); } -#endif int main() @@ -2005,17 +2003,13 @@ main() int wat_a1_dims[RANK_wat_a1]; int wat_a2_dims[RANK_wat_a2]; int wat_a3_dims[RANK_wat_a3]; -#ifdef EXTRA_TESTS int memused; -#endif /* EXTRA_TESTS */ printf("\n*** Testing CAM output file in netCDF-4.\n"); printf("*** creating file..."); -#ifdef EXTRA_TESTS get_mem_used2(&memused); printf("data memory %d MB\n", memused); -#endif /* EXTRA_TESTS */ if (nc_set_chunk_cache(0, 1009, .75)) ERR; @@ -7389,26 +7383,20 @@ main() if (nc_put_att_text(ncid, wat_a3_id, "cell_methods", 10, "time: mean")) ERR; -#ifdef EXTRA_TESTS get_mem_used2(&memused); printf("before enddef data memory %d MB\n", memused); -#endif /* leave define mode */ if (nc_enddef (ncid)) ERR; -#ifdef EXTRA_TESTS get_mem_used2(&memused); printf("before close data memory %d MB\n", memused); -#endif /* assign variable data */ if (nc_close(ncid)) ERR; -#ifdef EXTRA_TESTS get_mem_used2(&memused); printf("after close data memory %d MB\n", memused); -#endif SUMMARIZE_ERR; FINAL_RESULTS; diff --git a/nc_test4/tst_files4.c b/nc_test4/tst_files4.c index 55fb289f63..a83523a30e 100644 --- a/nc_test4/tst_files4.c +++ b/nc_test4/tst_files4.c @@ -105,7 +105,6 @@ main() {/* create data.nc */ if (nc_close(ncid)) ERR; } SUMMARIZE_ERR; -#ifdef EXTRA_TESTS printf("*** testing opening of many files..."); { int i, ncid; @@ -121,6 +120,5 @@ main() {/* create data.nc */ /*printf("last ncid: %d\n", ncid);*/ } SUMMARIZE_ERR; -#endif FINAL_RESULTS; } diff --git a/nc_test4/tst_interops.c b/nc_test4/tst_interops.c index 0050bf7cc4..086336e30e 100644 --- a/nc_test4/tst_interops.c +++ b/nc_test4/tst_interops.c @@ -390,11 +390,7 @@ main(int argc, char **argv) /* Open the file with HDF5 while netcdf still has it open. */ if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR; /* Turn this off for*/ -#ifdef EXTRA_TESTS if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI)) ERR; -#else - if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_STRONG)) ERR; -#endif if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, fapl_id)) < 0) ERR; if (H5Pclose(fapl_id) < 0) ERR; if (H5Fclose(fileid) < 0) ERR; diff --git a/nc_test4/tst_xplatform2.c b/nc_test4/tst_xplatform2.c index b93c99c954..6b6e1ab249 100644 --- a/nc_test4/tst_xplatform2.c +++ b/nc_test4/tst_xplatform2.c @@ -558,7 +558,6 @@ main(int argc, char **argv) #define NUM_OBJ 3 printf("\n*** Checking HDF5 attribute functions some more.\n"); -#ifdef EXTRA_TESTS printf("*** Opening tst_xplatform2_3.nc..."); { hid_t fileid, grpid, attid; @@ -651,6 +650,5 @@ main(int argc, char **argv) H5Fclose(fileid) < 0) ERR; } SUMMARIZE_ERR; -#endif /* EXTRA_TESTS */ FINAL_RESULTS; } diff --git a/nctest/Makefile.am b/nctest/Makefile.am index 4a9257c141..c722eac8c3 100644 --- a/nctest/Makefile.am +++ b/nctest/Makefile.am @@ -30,11 +30,9 @@ TESTS = $(TESTPROGRAMS) compare_test_files.sh # This will the test program with valgrind, the memory checking # tool. (Valgrind must be present for this to work.) -if EXTRA_TESTS if USE_VALGRIND_TESTS TESTS += run_valgrind_tests.sh endif # USE_VALGRIND_TESTS -endif # EXTRA_TESTS # These are the source files for the nctest program. nctest_SOURCES = add.c add.h atttests.c cdftests.c dimtests.c driver.c \ From fde90d9e10936834af2908b9a1d33e2c5208a455 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Thu, 9 Nov 2017 12:51:05 -0700 Subject: [PATCH 9/9] Updated requirements in install.md to clarify both 1.8.x branch and 1.10.x branch minimum versions. --- docs/install.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/install.md b/docs/install.md index ad1299a24c..3a336d6ea7 100644 --- a/docs/install.md +++ b/docs/install.md @@ -73,7 +73,9 @@ full functionality. (See \ref architecture). Requirements {#netcdf_requirements} ---------------------------------- -* HDF5 1.8.9 or later (for netCDF-4 support) +* For netCDF-4 support + * HDF5 1.8.9 or later. + * HDF5 1.10.1 or later. * zlib 1.2.5 or later (for netCDF-4 compression) * curl 7.18.0 or later (for DAP remote access client support)