From 0ac8ec40a1b23ef5371a0fb425222319a279ccc6 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Thu, 2 Nov 2017 11:40:13 -0600 Subject: [PATCH 01/11] removed archaic code to check memory use --- libsrc4/nc4file.c | 80 +----------------------- libsrc4/nc4hdf.c | 139 ------------------------------------------ libsrc4/nc4internal.c | 13 +--- libsrc4/nc4var.c | 12 ---- 4 files changed, 2 insertions(+), 242 deletions(-) diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index 6f07146a8c..af63e045d9 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -32,13 +32,6 @@ extern int nc4_vararray_add(NC_GRP_INFO_T *grp, */ #define LOGOPEN 1 -/* This is to track opened HDF5 objects to make sure they are - * closed. */ -#ifdef EXTRA_TESTS -extern int num_plists; -extern int num_spaces; -#endif /* EXTRA_TESTS */ - #define MIN_DEFLATE_LEVEL 0 #define MAX_DEFLATE_LEVEL 9 @@ -417,9 +410,6 @@ 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 - num_plists++; -#endif #ifdef EXTRA_TESTS if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI)) BAIL(NC_EHDFERR); @@ -492,9 +482,6 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info, /* Create the property list. */ if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists++; -#endif /* RJ: this suppose to be FALSE that is defined in H5 private.h as 0 */ if (H5Pset_obj_track_times(fcpl_id,0)<0) @@ -529,10 +516,6 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info, /* Release the property lists. */ if (H5Pclose(fapl_id) < 0 || H5Pclose(fcpl_id) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists--; - num_plists--; -#endif /* Define mode gets turned on automatically on create. */ nc4_info->flags |= NC_INDEF; @@ -546,9 +529,6 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info, #ifdef USE_PARALLEL4 if (comm_duped) MPI_Comm_free(&nc4_info->comm); if (info_duped) MPI_Info_free(&nc4_info->info); -#endif -#ifdef EXTRA_TESTS - num_plists--; #endif if (fapl_id != H5P_DEFAULT) H5Pclose(fapl_id); if(!nc4_info) return retval; @@ -768,9 +748,6 @@ read_coord_dimids(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) /* How many dimensions are there? */ if (!ret && (spaceid = H5Aget_space(coord_attid)) < 0) ret++; -#ifdef EXTRA_TESTS - num_spaces++; -#endif if (!ret && (npoints = H5Sget_simple_extent_npoints(spaceid)) < 0) ret++; /* Check that the number of points is the same as the number of dimensions @@ -788,9 +765,6 @@ read_coord_dimids(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) /* Set my HDF5 IDs free! */ if (spaceid >= 0 && H5Sclose(spaceid) < 0) ret++; -#ifdef EXTRA_TESTS - num_spaces--; -#endif if (coord_att_typeid >= 0 && H5Tclose(coord_att_typeid) < 0) ret++; if (coord_attid >= 0 && H5Aclose(coord_attid) < 0) ret++; return ret ? NC_EATTMETA : NC_NOERR; @@ -1105,9 +1079,6 @@ read_hdf5_att(NC_GRP_INFO_T *grp, hid_t attid, NC_ATT_INFO_T *att) /* Get len. */ if ((spaceid = H5Aget_space(attid)) < 0) BAIL(NC_EATTMETA); -#ifdef EXTRA_TESTS - num_spaces++; -#endif if ((att_ndims = H5Sget_simple_extent_ndims(spaceid)) < 0) BAIL(NC_EATTMETA); if ((att_npoints = H5Sget_simple_extent_npoints(spaceid)) < 0) @@ -1246,9 +1217,6 @@ read_hdf5_att(NC_GRP_INFO_T *grp, hid_t attid, NC_ATT_INFO_T *att) BAIL(NC_EHDFERR); if (H5Sclose(spaceid) < 0) return NC_EHDFERR; -#ifdef EXTRA_TESTS - num_spaces--; -#endif return NC_NOERR; @@ -1257,9 +1225,6 @@ read_hdf5_att(NC_GRP_INFO_T *grp, hid_t attid, NC_ATT_INFO_T *att) BAIL2(NC_EHDFERR); if (spaceid > 0 && H5Sclose(spaceid) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces--; -#endif return retval; } @@ -1556,13 +1521,8 @@ read_var(NC_GRP_INFO_T *grp, hid_t datasetid, const char *obj_name, NC_VAR_INFO_T *var = NULL; hid_t access_pid = 0; int incr_id_rc = 0; /* Whether the dataset ID's ref count has been incremented */ - int natts, a, d; - const char** reserved; - - NC_ATT_INFO_T *att; + int d; att_iter_info att_info; /* Custom iteration information */ - char att_name[NC_MAX_HDF5_NAME + 1]; - #define CD_NELEMS_ZLIB 1 #define CD_NELEMS_SZIP 4 H5Z_filter_t filter; @@ -1605,9 +1565,6 @@ read_var(NC_GRP_INFO_T *grp, hid_t datasetid, const char *obj_name, /* Get the current chunk cache settings. */ if ((access_pid = H5Dget_access_plist(datasetid)) < 0) BAIL(NC_EVARMETA); -#ifdef EXTRA_TESTS - num_plists++; -#endif /* Learn about current chunk cache settings. */ if ((H5Pget_chunk_cache(access_pid, &(var->chunk_cache_nelems), @@ -1648,9 +1605,6 @@ read_var(NC_GRP_INFO_T *grp, hid_t datasetid, const char *obj_name, * ignored. */ if ((propid = H5Dget_create_plist(datasetid)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists++; -#endif /* EXTRA_TESTS */ /* Get the chunking info for non-scalar vars. */ if ((layout = H5Pget_layout(propid)) < -1) @@ -1832,14 +1786,8 @@ read_var(NC_GRP_INFO_T *grp, hid_t datasetid, const char *obj_name, } if (access_pid && H5Pclose(access_pid) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists--; -#endif if (propid > 0 && H5Pclose(propid) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists--; -#endif return retval; } @@ -1936,9 +1884,6 @@ read_dataset(NC_GRP_INFO_T *grp, hid_t datasetid, const char *obj_name, /* Get the dimension information for this dataset. */ if ((spaceid = H5Dget_space(datasetid)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces++; -#endif if ((ndims = H5Sget_simple_extent_ndims(spaceid)) < 0) BAIL(NC_EHDFERR); @@ -1970,9 +1915,6 @@ read_dataset(NC_GRP_INFO_T *grp, hid_t datasetid, const char *obj_name, exit: if (spaceid && H5Sclose(spaceid) <0) BAIL2(retval); -#ifdef EXTRA_TESTS - num_spaces--; -#endif return retval; } @@ -2252,9 +2194,6 @@ 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 - num_plists++; -#endif #ifdef EXTRA_TESTS if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI)) BAIL(NC_EHDFERR); @@ -2355,9 +2294,6 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc) /* Close the property list. */ if (H5Pclose(fapl_id) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists--; -#endif NC4_get_fileinfo(nc4_info,NULL); @@ -2367,9 +2303,6 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc) #ifdef USE_PARALLEL4 if (comm_duped) MPI_Comm_free(&nc4_info->comm); if (info_duped) MPI_Info_free(&nc4_info->info); -#endif -#ifdef EXTRA_TESTS - num_plists--; #endif if (fapl_id != H5P_DEFAULT) H5Pclose(fapl_id); if (!nc4_info) return retval; @@ -3301,17 +3234,6 @@ nc4_enddef_netcdf4_file(NC_HDF5_FILE_INFO_T *h5) return sync_netcdf4_file(h5); } -#ifdef EXTRA_TESTS -int -nc_exit() -{ - if (num_plists || num_spaces) - return NC_EHDFERR; - - return NC_NOERR; -} -#endif /* EXTRA_TESTS */ - #ifdef USE_PARALLEL4 int nc_use_parallel_enabled() diff --git a/libsrc4/nc4hdf.c b/libsrc4/nc4hdf.c index 0b09b108e6..9878ba94d2 100644 --- a/libsrc4/nc4hdf.c +++ b/libsrc4/nc4hdf.c @@ -27,13 +27,6 @@ #define NC_HDF5_MAX_NAME 1024 -/* This is to track opened HDF5 objects to make sure they are - * closed. */ -#ifdef EXTRA_TESTS -int num_plists; -int num_spaces; -#endif /* EXTRA_TESTS */ - /*! Flag attributes in a linked list as dirty. * * Given a linked list of attributes, flag each @@ -612,9 +605,6 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp, /* Get file space of data. */ if ((file_spaceid = H5Dget_space(var->hdf_datasetid)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces++; -#endif /* Check to ensure the user selection is * valid. H5Sget_simple_extent_dims gets the sizes of all the dims @@ -654,9 +644,6 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp, { if ((mem_spaceid = H5Screate(H5S_SCALAR)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces++; -#endif } else { @@ -668,9 +655,6 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp, we want. */ if ((mem_spaceid = H5Screate_simple(var->ndims, count, NULL)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces++; -#endif } #ifndef HDF5_CONVERT @@ -715,9 +699,6 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp, /* Create the data transfer property list. */ if ((xfer_plistid = H5Pcreate(H5P_DATASET_XFER)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists++; -#endif /* Apply the callback function which will detect range * errors. Which one to call depends on the length of the @@ -806,9 +787,6 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp, BAIL2(NC_EHDFERR); if ((file_spaceid = H5Dget_space(var->hdf_datasetid)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces++; -#endif if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) BAIL(NC_EHDFERR); @@ -853,19 +831,10 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp, #endif if (file_spaceid > 0 && H5Sclose(file_spaceid) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces--; -#endif if (mem_spaceid > 0 && H5Sclose(mem_spaceid) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces--; -#endif if (xfer_plistid && (H5Pclose(xfer_plistid) < 0)) BAIL2(NC_EPARINIT); -#ifdef EXTRA_TESTS - num_plists--; -#endif #ifndef HDF5_CONVERT if (need_to_convert && bufr) free(bufr); #endif @@ -944,9 +913,6 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp, /* Get file space of data. */ if ((file_spaceid = H5Dget_space(var->hdf_datasetid)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces++; -#endif /* Check to ensure the user selection is * valid. H5Sget_simple_extent_dims gets the sizes of all the dims @@ -1038,9 +1004,6 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp, if ((mem_spaceid = H5Screate(H5S_SCALAR)) < 0) BAIL(NC_EHDFERR); scalar++; -#ifdef EXTRA_TESTS - num_spaces++; -#endif } else { @@ -1051,9 +1014,6 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp, we want. */ if ((mem_spaceid = H5Screate_simple(var->ndims, count, NULL)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces++; -#endif } /* Fix bug when reading HDF5 files with variable of type @@ -1110,9 +1070,6 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp, /* Create the data transfer property list. */ if ((xfer_plistid = H5Pcreate(H5P_DATASET_XFER)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists++; -#endif #ifdef HDF5_CONVERT /* Apply the callback function which will detect range @@ -1177,9 +1134,6 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp, /* Create the data transfer property list. */ if ((xfer_plistid = H5Pcreate(H5P_DATASET_XFER)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists++; -#endif if ((retval = set_par_access(h5, var, xfer_plistid))) BAIL(retval); @@ -1194,9 +1148,6 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp, if (H5Sselect_none(mem_spaceid)<0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces++; -#endif /* Read this hyperslab into memory. */ LOG((5, "About to H5Dread some data...")); if (H5Dread(var->hdf_datasetid, var->type_info->native_hdf_typeid, @@ -1264,25 +1215,16 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp, { if (H5Sclose(file_spaceid) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces--; -#endif } if (mem_spaceid > 0) { if (H5Sclose(mem_spaceid) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces--; -#endif } if (xfer_plistid > 0) { if (H5Pclose(xfer_plistid) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists--; -#endif } #ifndef HDF5_CONVERT if (need_to_convert && bufr != NULL) @@ -1380,17 +1322,11 @@ put_att_grpa(NC_GRP_INFO_T *grp, int varid, NC_ATT_INFO_T *att) string_size = 1; if ((spaceid = H5Screate(H5S_NULL)) < 0) BAIL(NC_EATTMETA); -#ifdef EXTRA_TESTS - num_spaces++; -#endif } else { if ((spaceid = H5Screate(H5S_SCALAR)) < 0) BAIL(NC_EATTMETA); -#ifdef EXTRA_TESTS - num_spaces++; -#endif } if (H5Tset_size(file_typeid, string_size) < 0) BAIL(NC_EATTMETA); @@ -1403,17 +1339,11 @@ put_att_grpa(NC_GRP_INFO_T *grp, int varid, NC_ATT_INFO_T *att) { if ((spaceid = H5Screate(H5S_NULL)) < 0) BAIL(NC_EATTMETA); -#ifdef EXTRA_TESTS - num_spaces++; -#endif } else { if ((spaceid = H5Screate_simple(1, dims, NULL)) < 0) BAIL(NC_EATTMETA); -#ifdef EXTRA_TESTS - num_spaces++; -#endif } } if ((attid = H5Acreate(locid, att->name, file_typeid, spaceid, @@ -1431,9 +1361,6 @@ put_att_grpa(NC_GRP_INFO_T *grp, int varid, NC_ATT_INFO_T *att) BAIL2(NC_EHDFERR); if (spaceid > 0 && H5Sclose(spaceid) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces--; -#endif return retval; } @@ -1479,18 +1406,12 @@ write_coord_dimids(NC_VAR_INFO_T *var) /* Write our attribute. */ coords_len[0] = var->ndims; if ((c_spaceid = H5Screate_simple(1, coords_len, coords_len)) < 0) ret++; -#ifdef EXTRA_TESTS - num_spaces++; -#endif if (!ret && (c_attid = H5Acreate(var->hdf_datasetid, COORDINATES, H5T_NATIVE_INT, c_spaceid, H5P_DEFAULT)) < 0) ret++; if (!ret && H5Awrite(c_attid, H5T_NATIVE_INT, var->dimids) < 0) ret++; /* Close up shop. */ if (c_spaceid > 0 && H5Sclose(c_spaceid) < 0) ret++; -#ifdef EXTRA_TESTS - num_spaces--; -#endif if (c_attid > 0 && H5Aclose(c_attid) < 0) ret++; return ret ? NC_EHDFERR : 0; } @@ -1505,9 +1426,6 @@ write_netcdf4_dimid(hid_t datasetid, int dimid) /* Create the space. */ if ((dimid_spaceid = H5Screate(H5S_SCALAR)) < 0) return NC_EHDFERR; -#ifdef EXTRA_TESTS - num_spaces++; -#endif /* Does the attribute already exist? If so, don't try to create it. */ if ((attr_exists = H5Aexists(datasetid, NC_DIMID_ATT_NAME)) < 0) @@ -1531,9 +1449,6 @@ write_netcdf4_dimid(hid_t datasetid, int dimid) /* Close stuff*/ if (H5Sclose(dimid_spaceid) < 0) return NC_EHDFERR; -#ifdef EXTRA_TESTS - num_spaces--; -#endif if (H5Aclose(dimid_attid) < 0) return NC_EHDFERR; @@ -1557,14 +1472,8 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid /* Scalar or not, we need a creation property list. */ if ((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists++; -#endif if ((access_plistid = H5Pcreate(H5P_DATASET_ACCESS)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists++; -#endif /* RJ: this suppose to be FALSE that is defined in H5 private.h as 0 */ if (H5Pset_obj_track_times(plistid,0)<0) @@ -1721,17 +1630,11 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid /* Create the dataspace. */ if ((spaceid = H5Screate_simple(var->ndims, dimsize, maxdimsize)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces++; -#endif } else { if ((spaceid = H5Screate(H5S_SCALAR)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces++; -#endif } /* Turn on creation order tracking. */ @@ -1786,19 +1689,10 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid BAIL2(NC_EHDFERR); if (plistid > 0 && H5Pclose(plistid) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists--; -#endif if (access_plistid > 0 && H5Pclose(access_plistid) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists--; -#endif if (spaceid > 0 && H5Sclose(spaceid) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces--; -#endif if (fillp) { if (var->type_info->nc_type_class == NC_VLEN) @@ -1991,9 +1885,6 @@ write_nc3_strict_att(hid_t hdf_grpid) * strict netcdf-3 rules. */ if ((spaceid = H5Screate(H5S_SCALAR)) < 0) BAIL(NC_EFILEMETA); -#ifdef EXTRA_TESTS - num_spaces++; -#endif if ((attid = H5Acreate(hdf_grpid, NC3_STRICT_ATT_NAME, H5T_NATIVE_INT, spaceid, H5P_DEFAULT)) < 0) BAIL(NC_EFILEMETA); @@ -2003,9 +1894,6 @@ write_nc3_strict_att(hid_t hdf_grpid) exit: if (spaceid > 0 && (H5Sclose(spaceid) < 0)) BAIL2(NC_EFILEMETA); -#ifdef EXTRA_TESTS - num_spaces--; -#endif if (attid > 0 && (H5Aclose(attid) < 0)) BAIL2(NC_EFILEMETA); return retval; @@ -2026,9 +1914,6 @@ create_group(NC_GRP_INFO_T *grp) * creation property list. */ if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) return NC_EHDFERR; -#ifdef EXTRA_TESTS - num_plists++; -#endif /* RJ: this suppose to be FALSE that is defined in H5 private.h as 0 */ if (H5Pset_obj_track_times(gcpl_id,0)<0) @@ -2043,9 +1928,6 @@ create_group(NC_GRP_INFO_T *grp) BAIL(NC_EHDFERR); if (H5Pclose(gcpl_id) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists--; -#endif } else { @@ -2058,9 +1940,6 @@ create_group(NC_GRP_INFO_T *grp) exit: if (gcpl_id > 0 && H5Pclose(gcpl_id) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists--; -#endif if (grp->hdf_grpid > 0 && H5Gclose(grp->hdf_grpid) < 0) BAIL2(NC_EHDFERR); return retval; @@ -2399,9 +2278,6 @@ write_dim(NC_DIM_INFO_T *dim, NC_GRP_INFO_T *grp, nc_bool_t write_dimid) * up chunking, with a chunksize of 1. */ if ((create_propid = H5Pcreate(H5P_DATASET_CREATE)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists++; -#endif /* RJ: this suppose to be FALSE that is defined in H5 private.h as 0 */ if (H5Pset_obj_track_times(create_propid,0)<0) @@ -2419,9 +2295,6 @@ write_dim(NC_DIM_INFO_T *dim, NC_GRP_INFO_T *grp, nc_bool_t write_dimid) /* Set up space. */ if ((spaceid = H5Screate_simple(1, dims, max_dims)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces++; -#endif if (H5Pset_attr_creation_order(create_propid, H5P_CRT_ORDER_TRACKED| H5P_CRT_ORDER_INDEXED) < 0) @@ -2436,14 +2309,8 @@ write_dim(NC_DIM_INFO_T *dim, NC_GRP_INFO_T *grp, nc_bool_t write_dimid) /* Close the spaceid and create_propid. */ if (H5Sclose(spaceid) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces--; -#endif if (H5Pclose(create_propid) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_plists--; -#endif /* Indicate that this is a scale. Also indicate that not * be shown to the user as a variable. It is hidden. It is @@ -3739,9 +3606,6 @@ nc4_rec_match_dimscales(NC_GRP_INFO_T *grp) /* Find the space information for this dimension. */ if ((spaceid = H5Dget_space(var->hdf_datasetid)) < 0) return NC_EHDFERR; -#ifdef EXTRA_TESTS - num_spaces++; -#endif /* Get the len of each dim in the space. */ if (var->ndims) @@ -3778,9 +3642,6 @@ nc4_rec_match_dimscales(NC_GRP_INFO_T *grp) free(h5dimlenmax); return NC_EHDFERR; } -#ifdef EXTRA_TESTS - num_spaces--; -#endif /* Create a phony dimension for each dimension in the * dataset, unless there already is one the correct diff --git a/libsrc4/nc4internal.c b/libsrc4/nc4internal.c index 89526d8408..378bdc8875 100644 --- a/libsrc4/nc4internal.c +++ b/libsrc4/nc4internal.c @@ -40,12 +40,6 @@ extern size_t nc4_chunk_cache_size; extern size_t nc4_chunk_cache_nelems; extern float nc4_chunk_cache_preemption; -/* This is to track opened HDF5 objects to make sure they are - * closed. */ -#ifdef EXTRA_TESTS -extern int num_spaces; -#endif /* EXTRA_TESTS */ - #ifdef LOGGING /* This is the severity level of messages which will be logged. Use severity 0 for errors, 1 for important log messages, 2 for less @@ -146,9 +140,7 @@ find_var_dim_max_length(NC_GRP_INFO_T *grp, int varid, int dimid, size_t *maxlen BAIL(retval); if ((spaceid = H5Dget_space(datasetid)) < 0) BAIL(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces++; -#endif + /* If it's a scalar dataset, it has length one. */ if (H5Sget_simple_extent_type(spaceid) == H5S_SCALAR) { @@ -182,9 +174,6 @@ find_var_dim_max_length(NC_GRP_INFO_T *grp, int varid, int dimid, size_t *maxlen exit: if (spaceid > 0 && H5Sclose(spaceid) < 0) BAIL2(NC_EHDFERR); -#ifdef EXTRA_TESTS - num_spaces--; -#endif if (h5dimlen) free(h5dimlen); if (h5dimlenmax) free(h5dimlenmax); return retval; diff --git a/libsrc4/nc4var.c b/libsrc4/nc4var.c index 3cb1165af6..6f342eea0f 100644 --- a/libsrc4/nc4var.c +++ b/libsrc4/nc4var.c @@ -17,12 +17,6 @@ conditions. #define MIN_DEFLATE_LEVEL 0 #define MAX_DEFLATE_LEVEL 9 -/* This is to track opened HDF5 objects to make sure they are - * closed. */ -#ifdef EXTRA_TESTS -extern int num_plists; -#endif /* EXTRA_TESTS */ - /* One meg is the minimum buffer size. */ #define ONE_MEG 1048576 @@ -45,9 +39,6 @@ nc4_reopen_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) { if ((access_pid = H5Pcreate(H5P_DATASET_ACCESS)) < 0) return NC_EHDFERR; -#ifdef EXTRA_TESTS - num_plists++; -#endif if (H5Pset_chunk_cache(access_pid, var->chunk_cache_nelems, var->chunk_cache_size, var->chunk_cache_preemption) < 0) @@ -59,9 +50,6 @@ nc4_reopen_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) return NC_EHDFERR; if (H5Pclose(access_pid) < 0) return NC_EHDFERR; -#ifdef EXTRA_TESTS - num_plists--; -#endif } return NC_NOERR; From b28aaab6d7cd6a63c83c4b9592802046f0bc98b8 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Thu, 2 Nov 2017 12:57:16 -0600 Subject: [PATCH 02/11] documentation for nc_par_var_access() and nc_open_par() --- docs/Doxyfile.in | 2 +- libdispatch/derror.c | 3 - libdispatch/dparallel.c | 137 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 134 insertions(+), 8 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 5712b5674c..b72b013e90 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -699,7 +699,7 @@ WARNINGS = YES # will automatically be disabled. # The default value is: YES. -WARN_IF_UNDOCUMENTED = NO +WARN_IF_UNDOCUMENTED = YES # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some parameters diff --git a/libdispatch/derror.c b/libdispatch/derror.c index ff31dd7f02..1be5016af3 100644 --- a/libdispatch/derror.c +++ b/libdispatch/derror.c @@ -16,9 +16,6 @@ Research/Unidata. See COPYRIGHT file for more info. static const char nc_libvers[] = PACKAGE_VERSION " of "__DATE__" "__TIME__" $"; /** -\defgroup lib_version Library Version - Functions related to querying the library version. - Return the library version. \returns short string that contains the version information for the diff --git a/libdispatch/dparallel.c b/libdispatch/dparallel.c index 652053b2de..ecbb21a0f9 100644 --- a/libdispatch/dparallel.c +++ b/libdispatch/dparallel.c @@ -33,10 +33,77 @@ int nc_create_par(const char *path, int cmode, MPI_Comm comm, #endif /* USE_PARALLEL */ } -/*! \ingroup datasets +/** \ingroup datasets +Open an existing netCDF file for parallel I/O. + +This function opens an existing netCDF dataset for parallel I/O +access. It determines the underlying file format automatically. Use +the same call to open a netCDF classic, 64-bit offset, or netCDF-4 +file. + +Parallel I/O access is only available in library build which support +parallel I/O. To support parallel I/O, netCDF must be built with +netCDF-4 enabled, and with a HDF5 library that supports parallel I/O, +or with support for the parallel-netcdf library via the +enable-pnetcdf option. + +It is not necessary to pass any information about the format of the +file being opened. The file type will be detected automatically by the +netCDF library. + +As of version 4.3.1.2, multiple calls to nc_open_par() with the same +path will return the same ncid value. + +\note When opening a netCDF-4 file HDF5 error reporting is turned off, +if it is on. This doesn't stop the HDF5 error stack from recording the +errors, it simply stops their display to the user through stderr. + +\param path File name for netCDF dataset to be opened. + +\param mode The mode flag may include NC_WRITE (for read/write +access), NC_MPIIO or NC_MPIPOSIX (not both) for parallel netCDF-4 I/O, +or NC_PNETCDF for parallel-netcdf parallel I/O access for a netCDF +classic or CDF5 file. + +\param comm the MPI communicator to be used. + +\param info MPI info or MPI_INFO_NULL. + +\param ncidp Pointer to location where returned netCDF ID is to be +stored. + +nc_open_par() returns the value NC_NOERR if no errors +occurred. Otherwise, the returned status indicates an error. Possible +causes of errors include: + +\returns ::NC_NOERR No error. + +\returns ::NC_EINVAL Invalid parameters. + +\returns ::NC_ENOTNC Not a netCDF file. + +\returns ::NC_ENOMEM Out of memory. + +\returns ::NC_EHDFERR HDF5 error. (NetCDF-4 files only.) - This function opens a file for parallel I/O. +\returns ::NC_EDIMMETA Error in netCDF-4 dimension metadata. (NetCDF-4 +files only.) +

Examples

+ +Here is an example using nc_open_par() from examples/C/parallel_vara.c. + +@code +#include +#include +#include + ... + int ncid, omode; + char filename[128]; + ... + omode = NC_PNETCDF | NC_NOWRITE; + err = nc_open_par(filename, omode, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid); FATAL_ERR +@endcode */ int nc_open_par(const char *path, int mode, MPI_Comm comm, @@ -92,8 +159,70 @@ nc_open_par_fortran(const char *path, int mode, int comm, #endif } -/* This function will change the parallel access of a variable from - * independent to collective. */ +/* */ +/**\ingroup datasets + +This function will change the parallel access of a variable from +independent to collective. + +\param ncid NetCDF or group ID, from a previous call to nc_open(), +nc_create(), nc_def_grp(), or associated inquiry functions such as +nc_inq_ncid(). + +\param varid Variable ID + +\param par_access NC_COLLECTIVE or NC_INDEPENDENT. + +\returns ::NC_NOERR No error. + +\returns ::NC_EBADID Invalid ncid passed. + +\returns ::NC_ENOTVAR Invalid varid passed. + +\returns ::NC_ENOPAR LFile was not opened with nc_open_par/nc_create_var. + +\returns ::NC_EINVAL Invalid par_access specified. + +

Example

+ +Here is an example from examples/C/parallel_vara.c which changes the +parallel access of a variable and then writes to it. + +\code +#define NY 10 +#define NX 4 + + #include + #include + #include + ... + char filename[128]; + int err, ncid, cmode, varid, dimid, dimid[2], buf[NY][NX]; + size_t global_ny, global_nx, start[2], count[2]; + ... + global_ny = NY; + global_nx = NX * nprocs; + ... + cmode = NC_CLOBBER | NC_PNETCDF; + err = nc_create_par(filename, cmode, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid); FATAL_ERR + ... + err = nc_def_dim(ncid, "Y", global_ny, &dimid[0]); ERR + err = nc_def_dim(ncid, "X", global_nx, &dimid[1]); ERR + err = nc_def_var(ncid, "var", NC_INT, 2, dimid, &varid); ERR + ... + err = nc_enddef(ncid); ERR + ... + err = nc_var_par_access(ncid, varid, NC_COLLECTIVE); ERR + ... + start[0] = 0; + start[1] = NX * rank; + count[0] = NY; + count[1] = NX; + + err = nc_put_vara_int(ncid, varid, start, count, &buf[0][0]); ERR + +\endcode + */ int nc_var_par_access(int ncid, int varid, int par_access) { From 140782c5bcfa12046169ed85d8b4c34368af1725 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Thu, 2 Nov 2017 12:58:14 -0600 Subject: [PATCH 03/11] reset doxygen setting --- docs/Doxyfile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index b72b013e90..5712b5674c 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -699,7 +699,7 @@ WARNINGS = YES # will automatically be disabled. # The default value is: YES. -WARN_IF_UNDOCUMENTED = YES +WARN_IF_UNDOCUMENTED = NO # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some parameters From 7c9a91d2d0f70daf461edf69d975f368cd022e1f Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 3 Nov 2017 07:47:02 -0600 Subject: [PATCH 04/11] added missing documentation for public functions in dvars.c --- libdispatch/dvar.c | 327 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 309 insertions(+), 18 deletions(-) diff --git a/libdispatch/dvar.c b/libdispatch/dvar.c index ec3daff934..dbc64f0203 100644 --- a/libdispatch/dvar.c +++ b/libdispatch/dvar.c @@ -520,6 +520,12 @@ NC_getshape(int ncid, int varid, int ndims, size_t* shape) #ifdef USE_NETCDF4 /** \ingroup variables +Change the cache settings for a chunked variable. This function allows +users to control the amount of memory used in the per-variable chunk +cache at the HDF5 level. Changing the chunk cache only has effect +until the file is closed. Once re-opened, the variable chunk cache +returns to its default value. + \param ncid NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). @@ -542,6 +548,34 @@ chunks. \returns ::NC_ENOTVAR Invalid variable ID. \returns ::NC_ESTRICTNC3 Attempting netcdf-4 operation on strict nc3 netcdf-4 file. \returns ::NC_EINVAL Invalid input + +\section nc_def_var_chunk_cache_example Example + +In this example from nc_test4/tst_coords.c, a variable is defined, and +the chunk cache settings are changed for that variable. + +\code + printf("**** testing setting cache values for coordinate variables..."); + { +#define RANK_1 1 +#define DIM0_NAME "d0" +#define CACHE_SIZE 1000000 +#define CACHE_NELEMS 1009 +#define CACHE_PREEMPTION .90 + + int ncid, dimid, varid; + char name_in[NC_MAX_NAME + 1]; + + if (nc_create(FILE_NAME, NC_CLASSIC_MODEL|NC_NETCDF4, &ncid)) ERR; + if (nc_def_dim(ncid, DIM0_NAME, NC_UNLIMITED, &dimid)) ERR; + if (nc_def_var(ncid, DIM0_NAME, NC_DOUBLE, 1, &dimid, &varid)) ERR; + if (nc_set_var_chunk_cache(ncid, varid, CACHE_SIZE, CACHE_NELEMS, CACHE_PREEMPTION)) ERR; + if (nc_close(ncid)) ERR; + + ... + } + SUMMARIZE_ERR; +\endcode */ int nc_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems, @@ -556,6 +590,8 @@ nc_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems, /** \ingroup variables +Get the per-variable chunk cache settings from the HDF5 layer. + \param ncid NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). @@ -578,7 +614,8 @@ chunks are always preempted before other chunks. \ref ignored_if_null. \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_ESTRICTNC3 Attempting netcdf-4 operation on strict nc3 +netcdf-4 file. \returns ::NC_EINVAL Invalid input */ int @@ -614,6 +651,81 @@ nc_free_string(size_t len, char **data) return NC_NOERR; } +/** \ingroup variables + +Set the compression settings for a netCDF-4/HDF5 variable. + +This function must be called after nc_def_var and before nc_enddef or +any functions which writes data to the file. + +\param ncid NetCDF or group ID, from a previous call to nc_open(), +nc_create(), nc_def_grp(), or associated inquiry functions such as +nc_inq_ncid(). + +\param varid Variable ID + +\param shuffle True to turn on the shuffle filter. + +\param deflate True to turn on deflation for this variable. + +\param deflate_level A number between 0 (no compression) and 9 +(maximum compression). + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. +\returns ::NC_ENOTNC4 Attempting netcdf-4 operation on file that is +not netCDF-4/HDF5. +\returns ::NC_ESTRICTNC3 Attempting netcdf-4 operation on strict nc3 +netcdf-4 file. +\returns ::NC_ELATEDEF Too late to change settings for this variable. +\returns ::NC_EINVAL Invalid input + +\section nc_def_var_deflate_example Example + +Here is an example from /examples/C/simple_xy_nc4_wr.c using +nc_def_var_deflate to create a variable and then turn on the shuffle +filter and compression. + +\code +#include +#define NDIMS 2 +#define NX 6 +#define NY 12 + + int ncid, x_dimid, y_dimid, varid; + int dimids[NDIMS]; + int shuffle, deflate, deflate_level; + int data_out[NX][NY]; + int x, y, retval; + + shuffle = NC_SHUFFLE; + deflate = 1; + deflate_level = 1; + ... + if ((retval = nc_create(FILE_NAME, NC_NETCDF4, &ncid))) + ERR(retval); + + if ((retval = nc_def_dim(ncid, "x", NX, &x_dimid))) + ERR(retval); + if ((retval = nc_def_dim(ncid, "y", NY, &y_dimid))) + ERR(retval); + + dimids[0] = x_dimid; + dimids[1] = y_dimid; + + if ((retval = nc_def_var(ncid, "data", NC_INT, NDIMS, + dimids, &varid))) + ERR(retval); + + ... + + if ((retval = nc_def_var_deflate(ncid, varid, shuffle, deflate, + deflate_level))) + ERR(retval); + ... +\endcode +*/ int nc_def_var_deflate(int ncid, int varid, int shuffle, int deflate, int deflate_level) { @@ -623,6 +735,32 @@ nc_def_var_deflate(int ncid, int varid, int shuffle, int deflate, int deflate_le return ncp->dispatch->def_var_deflate(ncid,varid,shuffle,deflate,deflate_level); } +/** \ingroup variables + +Set checksum for a var. + +This function must be called after nc_def_var and before nc_enddef or +any functions which writes data to the file. + +\param ncid NetCDF or group ID, from a previous call to nc_open(), +nc_create(), nc_def_grp(), or associated inquiry functions such as +nc_inq_ncid(). + +\param varid Variable ID + +\param fletcher32 True to turn on Fletcher32 checksums for this +variable. + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ncid. +\returns ::NC_ENOTVAR Invalid variable ID. +\returns ::NC_ENOTNC4 Attempting netcdf-4 operation on file that is +not netCDF-4/HDF5. +\returns ::NC_ESTRICTNC3 Attempting netcdf-4 operation on strict nc3 +netcdf-4 file. +\returns ::NC_ELATEDEF Too late to change settings for this variable. +\returns ::NC_EINVAL Invalid input +*/ int nc_def_var_fletcher32(int ncid, int varid, int fletcher32) { @@ -636,32 +774,59 @@ nc_def_var_fletcher32(int ncid, int varid, int fletcher32) \ingroup variables -The function nc_def_var_chunking sets the chunking parameters for a variable in a netCDF-4 file. It can set the chunk sizes to get chunked storage, or it can set the contiguous flag to get contiguous storage. +The function nc_def_var_chunking sets the chunking parameters for a +variable in a netCDF-4 file. It can set the chunk sizes to get chunked +storage, or it can set the contiguous flag to get contiguous storage. -The total size of a chunk must be less than 4 GiB. That is, the product of all chunksizes and the size of the data (or the size of nc_vlen_t for VLEN types) must be less than 4 GiB. +The total size of a chunk must be less than 4 GiB. That is, the +product of all chunksizes and the size of the data (or the size of +nc_vlen_t for VLEN types) must be less than 4 GiB. -This function may only be called after the variable is defined, but before nc_enddef is called. Once the chunking parameters are set for a variable, they cannot be changed. +This function may only be called after the variable is defined, but +before nc_enddef is called. Once the chunking parameters are set for a +variable, they cannot be changed. -Note that this does not work for scalar variables. Only non-scalar variables can have chunking. +Note that this does not work for scalar variables. Only non-scalar +variables can have chunking. +\param[in] ncid NetCDF ID, from a previous call to nc_open or +nc_create. +\param[in] varid Variable ID. -@param[in] ncid NetCDF ID, from a previous call to nc_open or nc_create. -@param[in] varid Variable ID. -@param[in] storage If ::NC_CONTIGUOUS, then contiguous storage is used for this variable. Variables with one or more unlimited dimensions cannot use contiguous storage. If contiguous storage is turned on, the chunksizes parameter is ignored. If ::NC_CHUNKED, then chunked storage is used for this variable. Chunk sizes may be specified with the chunksizes parameter or default sizes will be used if that parameter is NULL. -@param[in] chunksizesp A pointer to an array list of chunk sizes. The array must have one chunksize for each dimension of the variable. If ::NC_CONTIGUOUS storage is set, then the chunksizes parameter is ignored. +\param[in] storage If ::NC_CONTIGUOUS, then contiguous storage is used +for this variable. Variables with one or more unlimited dimensions +cannot use contiguous storage. If contiguous storage is turned on, the +chunksizes parameter is ignored. If ::NC_CHUNKED, then chunked storage +is used for this variable. Chunk sizes may be specified with the +chunksizes parameter or default sizes will be used if that parameter +is NULL. -@returns ::NC_NOERR No error. -@returns ::NC_EBADID Bad ID. -@returns ::NC_ENOTNC4 Not a netCDF-4 file. -@returns ::NC_ELATEDEF This variable has already been the subject of a nc_enddef call. In netCDF-4 files nc_enddef will be called automatically for any data read or write. Once nc_enddef has been called after the nc_def_var call for a variable, it is impossible to set the chunking for that variable. -@returns ::NC_ENOTINDEFINE Not in define mode. This is returned for netCDF classic or 64-bit offset files, or for netCDF-4 files, when they wwere created with NC_STRICT_NC3 flag. See \ref nc_create. -@returns ::NC_EPERM Attempt to create object in read-only file. -@returns ::NC_EBADCHUNK Retunrs if the chunk size specified for a variable is larger than the length of the dimensions associated with variable. +\param[in] chunksizesp A pointer to an array list of chunk sizes. The +array must have one chunksize for each dimension of the variable. If +::NC_CONTIGUOUS storage is set, then the chunksizes parameter is +ignored. + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ID. +\returns ::NC_ENOTNC4 Not a netCDF-4 file. +\returns ::NC_ELATEDEF This variable has already been the subject of a +nc_enddef call. In netCDF-4 files nc_enddef will be called +automatically for any data read or write. Once nc_enddef has been +called after the nc_def_var call for a variable, it is impossible to +set the chunking for that variable. +\returns ::NC_ENOTINDEFINE Not in define mode. This is returned for +netCDF classic or 64-bit offset files, or for netCDF-4 files, when +they wwere created with NC_STRICT_NC3 flag. See \ref nc_create. +\returns ::NC_EPERM Attempt to create object in read-only file. +\returns ::NC_EBADCHUNK Retunrs if the chunk size specified for a +variable is larger than the length of the dimensions associated with +variable. \section nc_def_var_chunking_example Example -In this example from libsrc4/tst_vars2.c, chunksizes are set with nc_var_def_chunking, and checked with nc_var_inq_chunking. +In this example from libsrc4/tst_vars2.c, chunksizes are set with +nc_var_def_chunking, and checked with nc_var_inq_chunking. \code printf("**** testing chunking..."); @@ -696,7 +861,6 @@ In this example from libsrc4/tst_vars2.c, chunksizes are set with nc_var_def_chu if (chunksize[d] != chunksize_in[d]) ERR; if (storage_in != NC_CHUNKED) ERR; \endcode - */ int nc_def_var_chunking(int ncid, int varid, int storage, @@ -709,6 +873,68 @@ nc_def_var_chunking(int ncid, int varid, int storage, chunksizesp); } +/*! Set the fill value for a netCDF4/HDF5 variable. + +\ingroup variables + +\param ncid NetCDF ID, from a previous call to nc_open or +nc_create. + +\param varid Variable ID. + +\param no_fill Set to NC_NOFILL to turn off fill mode for this +variable. Set to NC_FILL (the default) to turn on fill mode for the +variable. + +\param fill_value the fill value to be used for this variable. Must be +the same type as the variable. + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ID. +\returns ::NC_ENOTNC4 Not a netCDF-4 file. +\returns ::NC_ENOTINDEFINE Not in define mode. This is returned for +netCDF classic or 64-bit offset files, or for netCDF-4 files, when +they wwere created with NC_STRICT_NC3 flag. See \ref nc_create. +\returns ::NC_EPERM Attempt to create object in read-only file. + +\section nc_def_var_fill_example Example + +In this example from libsrc4/tst_vars.c, a variable is defined, and +the fill mode turned off. Then nc_inq_fill() is used to check that the +setting is correct. Then some data are written to the variable. Since +the data that are written do not cover the full extent of the +variable, the missing values will just be random. If fill value mode +was turned on, the missing values would get the fill value. + +\code +#define DIM7_LEN 2 +#define DIM7_NAME "dim_7_from_Indiana" +#define VAR7_NAME "var_7_from_Idaho" +#define NDIMS 1 + int dimids[NDIMS]; + size_t index[NDIMS]; + int varid; + int no_fill; + unsigned short ushort_data = 42, ushort_data_in, fill_value_in; + + if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; + if (nc_def_dim(ncid, DIM7_NAME, DIM7_LEN, &dimids[0])) ERR; + if (nc_def_var(ncid, VAR7_NAME, NC_USHORT, NDIMS, dimids, + &varid)) ERR; + if (nc_def_var_fill(ncid, varid, 1, NULL)) ERR; + + if (nc_inq_var_fill(ncid, varid, &no_fill, &fill_value_in)) ERR; + if (!no_fill) ERR; + + index[0] = 1; + if (nc_put_var1_ushort(ncid, varid, index, &ushort_data)) ERR; + + index[0] = 0; + if (nc_get_var1_ushort(ncid, varid, index, &ushort_data_in)) ERR; + + if (nc_close(ncid)) ERR; +\endcode +*/ int nc_def_var_fill(int ncid, int varid, int no_fill, const void *fill_value) { @@ -718,6 +944,71 @@ nc_def_var_fill(int ncid, int varid, int no_fill, const void *fill_value) return ncp->dispatch->def_var_fill(ncid,varid,no_fill,fill_value); } +/*! Define endianness of a variable. + +\ingroup variables + +With this function the endianness (i.e. order of bits in integers) can +be changed on a per-variable basis. By default, the endianness is the +same as the default endianness of the platform. But with +nc_def_var_endianness the endianness can be explicitly set for a +variable. + +This function may only be called after the variable is defined, but +before nc_enddef is called. + +\param[in] ncid NetCDF ID, from a previous call to nc_open or +nc_create. + +\param[in] varid Variable ID. + +\param[in] endian NC_ENDIAN_NATIVE to select the native endianness of +the platform (the default), NC_ENDIAN_LITTLE to use little-endian, +NC_ENDIAN_BIG to use big-endian. + +\returns ::NC_NOERR No error. +\returns ::NC_EBADID Bad ID. +\returns ::NC_ENOTNC4 Not a netCDF-4 file. +\returns ::NC_ELATEDEF This variable has already been the subject of a +nc_enddef call. In netCDF-4 files nc_enddef will be called +automatically for any data read or write. Once nc_enddef has been +called after the nc_def_var call for a variable, it is impossible to +set the chunking for that variable. +\returns ::NC_ENOTINDEFINE Not in define mode. This is returned for +netCDF classic or 64-bit offset files, or for netCDF-4 files, when +they wwere created with NC_STRICT_NC3 flag. See \ref nc_create. +\returns ::NC_EPERM Attempt to create object in read-only file. + +\section nc_def_var_endian_example Example + +In this example from libsrc4/tst_vars2.c, a variable is created, and +the endianness set to NC_ENDIAN_BIG. + +\code +#define NDIMS4 1 +#define DIM4_NAME "Joe" +#define VAR_NAME4 "Ed" +#define DIM4_LEN 10 + { + int dimids[NDIMS4], dimids_in[NDIMS4]; + int varid; + int ndims, nvars, natts, unlimdimid; + nc_type xtype_in; + char name_in[NC_MAX_NAME + 1]; + int data[DIM4_LEN], data_in[DIM4_LEN]; + int endian_in; + int i; + + for (i = 0; i < DIM4_LEN; i++) + data[i] = i; + + if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; + if (nc_def_dim(ncid, DIM4_NAME, DIM4_LEN, &dimids[0])) ERR; + if (dimids[0] != 0) ERR; + if (nc_def_var(ncid, VAR_NAME4, NC_INT, NDIMS4, dimids, &varid)) ERR; + if (nc_def_var_endian(ncid, varid, NC_ENDIAN_BIG)) ERR; +\endcode +*/ int nc_def_var_endian(int ncid, int varid, int endian) { From 3301c3f8dc87f3bec7159f83b44b21c92b2758b7 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Sat, 4 Nov 2017 05:34:36 -0600 Subject: [PATCH 05/11] fixed some warnings --- libdap4/d4chunk.c | 2 +- libdap4/d4data.c | 1 - libdap4/d4file.c | 1 - libdap4/d4rc.c | 2 +- libdap4/d4swap.c | 2 +- 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libdap4/d4chunk.c b/libdap4/d4chunk.c index b748879ccb..8e159b768c 100644 --- a/libdap4/d4chunk.c +++ b/libdap4/d4chunk.c @@ -65,7 +65,7 @@ NCD4_dechunk(NCD4meta* metadata) /* setup as dmr only */ metadata->serial.dmr = (char*)metadata->serial.rawdata; /* temp */ metadata->serial.dmr[metadata->serial.rawsize-1] = '\0'; - metadata->serial.dmr = strdup(q); + metadata->serial.dmr = strdup((char *)q); if(metadata->serial.dmr == NULL) return THROW(NC_ENOMEM); return THROW(NC_NOERR); diff --git a/libdap4/d4data.c b/libdap4/d4data.c index fa39d60b46..a60210be04 100644 --- a/libdap4/d4data.c +++ b/libdap4/d4data.c @@ -180,7 +180,6 @@ fillstruct(NCD4meta* meta, NCD4node* type, void** offsetp, void** dstp, NClist* #ifdef CLEARSTRUCT /* Avoid random data within aligned structs */ - d4size_t prevoffset = 0; memset(dst,0,type->meta.memsize); #endif diff --git a/libdap4/d4file.c b/libdap4/d4file.c index 058648adfe..a6667cb8e4 100644 --- a/libdap4/d4file.c +++ b/libdap4/d4file.c @@ -442,7 +442,6 @@ set_curl_properties(NCD4INFO* d4info) static void applyclientparamcontrols(NCD4INFO* info) { - NCD4meta* meta = info->substrate.metadata; const char* value; /* clear the flags */ diff --git a/libdap4/d4rc.c b/libdap4/d4rc.c index 478809918e..4449f14299 100644 --- a/libdap4/d4rc.c +++ b/libdap4/d4rc.c @@ -86,7 +86,7 @@ rctrim(char* text) static NClist* rcorder(NClist* rc) { - int i,j; + int i; int len = nclistlength(rc); NClist* newrc = nclistnew(); if(rc == NULL || len == 0) return newrc; diff --git a/libdap4/d4swap.c b/libdap4/d4swap.c index daed3752b5..2278d73c02 100644 --- a/libdap4/d4swap.c +++ b/libdap4/d4swap.c @@ -235,7 +235,7 @@ walkSeq(NCD4meta* compiler, NCD4node* topvar, NCD4node* vlentype, void** offsetp swapinline64(&recordcount); basetype = vlentype->basetype; /* This may be of any type potentially */ - assert(basetype->sort = NCD4_TYPE); + assert(basetype->sort == NCD4_TYPE); for(i=0;isubsort) { From 6ce15853d64113b02f239bbe62e69f9dcbd5d7de Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Sun, 5 Nov 2017 09:06:48 -0700 Subject: [PATCH 06/11] fixed ENABLE_CDF5 issue in some tests --- include/nc_tests.h | 1 + nc_test/tst_inq_type.c | 265 ++++++++++++++++++++++------------------ nc_test4/tst_converts.c | 50 ++++++-- nc_test4/tst_files.c | 70 +++++++---- 4 files changed, 228 insertions(+), 158 deletions(-) diff --git a/include/nc_tests.h b/include/nc_tests.h index efbc09b2aa..a51fce7668 100644 --- a/include/nc_tests.h +++ b/include/nc_tests.h @@ -24,6 +24,7 @@ for conditions of use. #define NC_TESTS_MAX_DIMS 1024 /**< NC_MAX_DIMS for tests. Allows different NC_MAX_DIMS values without breaking this test with a heap or stack overflow. */ +#define MAX_NUM_FORMATS 5 /**< Max number of available binary formats. */ /** Useful define for tests. */ /** \{ */ diff --git a/nc_test/tst_inq_type.c b/nc_test/tst_inq_type.c index c0f0ccc83b..8780fb45c1 100644 --- a/nc_test/tst_inq_type.c +++ b/nc_test/tst_inq_type.c @@ -22,144 +22,165 @@ #define FILE_NAME "tst_inq_type.nc" -void -check_err(const int stat, const int line, const char *file) { - if (stat != NC_NOERR) { - (void)fprintf(stderr,"line %d of %s: %s\n", line, file, nc_strerror(stat)); - fflush(stderr); - exit(1); - } -} - - int test_type_should_fail(int ncid, int type, char* tstring) { - printf("\t* Testing Type (Should Fail) %s:\t",tstring); - if(!nc_inq_type(ncid,type,NULL,NULL)) ERR; - else printf("expected failure.\n"); + printf("\t* Testing Type (Should Fail) %s:\t",tstring); + if(!nc_inq_type(ncid,type,NULL,NULL)) ERR; + else printf("expected failure.\n"); - return 0; + return 0; } int test_type(int ncid, int type, char* tstring) { - printf("\t* Testing Type %s:\t",tstring); - if(nc_inq_type(ncid,type,NULL,NULL)) ERR; - else printf("success.\n"); + printf("\t* Testing Type %s:\t",tstring); + if(nc_inq_type(ncid,type,NULL,NULL)) ERR; + else printf("success.\n"); - return 0; + return 0; } - - int main(int argc, char **argv) { - int ncid=0; - - { - printf("\n* Testing nc_inq_type with netcdf-3\n"); - - if(nc_create(FILE_NAME,NC_CLOBBER,&ncid)) ERR; - - test_type(ncid, NC_BYTE,"NC_BYTE"); - test_type(ncid, NC_CHAR,"NC_CHAR"); - test_type(ncid, NC_SHORT,"NC_SHORT"); - test_type(ncid, NC_INT,"NC_INT"); - test_type(ncid, NC_LONG,"NC_LONG"); - test_type(ncid, NC_FLOAT,"NC_FLOAT"); - test_type(ncid, NC_DOUBLE,"NC_DOUBLE"); - - /* Not Valid for Classic */ - /* Valid now, see https://github.com/Unidata/netcdf-c/issues/240 for more - information. The types are not valid for use in Classic, - but nc_inq_type should return valid info. */ - test_type(ncid, NC_UBYTE,"NC_UBYTE"); - test_type(ncid, NC_USHORT,"NC_USHORT"); - test_type(ncid, NC_UINT,"NC_UINT"); - test_type(ncid, NC_INT64,"NC_INT64"); - test_type(ncid, NC_UINT64,"NC_UINT64"); - test_type(ncid, NC_STRING,"NC_STRING"); - - /* Invoke a true negative */ - test_type_should_fail(ncid, 9999, "NC_GARBAGE"); - test_type_should_fail(ncid, -1, "NC_GARBAGE_NEGATIVE"); - - - if(nc_close(ncid)) ERR; - } - - { - printf("\n* Testing nc_inq_type with CDF5\n"); - - if(nc_create(FILE_NAME,NC_CLOBBER|NC_CDF5,&ncid)) ERR; - - test_type(ncid, NC_BYTE,"NC_BYTE"); - test_type(ncid, NC_CHAR,"NC_CHAR"); - test_type(ncid, NC_SHORT,"NC_SHORT"); - test_type(ncid, NC_INT,"NC_INT"); - test_type(ncid, NC_LONG,"NC_LONG"); - test_type(ncid, NC_FLOAT,"NC_FLOAT"); - test_type(ncid, NC_DOUBLE,"NC_DOUBLE"); - test_type(ncid, NC_UBYTE,"NC_UBYTE"); - test_type(ncid, NC_USHORT,"NC_USHORT"); - test_type(ncid, NC_UINT,"NC_UINT"); - test_type(ncid, NC_INT64,"NC_INT64"); - test_type(ncid, NC_UINT64,"NC_UINT64"); - test_type(ncid, NC_STRING,"NC_STRING"); - - if(nc_close(ncid)) ERR; - } + int ncid=0; + + printf("\n* Testing nc_inq_type with netcdf-3\n"); + { + if(nc_create(FILE_NAME,NC_CLOBBER,&ncid)) ERR; + + test_type(ncid, NC_BYTE,"NC_BYTE"); + test_type(ncid, NC_CHAR,"NC_CHAR"); + test_type(ncid, NC_SHORT,"NC_SHORT"); + test_type(ncid, NC_INT,"NC_INT"); + test_type(ncid, NC_LONG,"NC_LONG"); + test_type(ncid, NC_FLOAT,"NC_FLOAT"); + test_type(ncid, NC_DOUBLE,"NC_DOUBLE"); + + /* Not Valid for Classic */ + /* Valid now, see https://github.com/Unidata/netcdf-c/issues/240 for more + information. The types are not valid for use in Classic, + but nc_inq_type should return valid info. */ + test_type(ncid, NC_UBYTE,"NC_UBYTE"); + test_type(ncid, NC_USHORT,"NC_USHORT"); + test_type(ncid, NC_UINT,"NC_UINT"); + test_type(ncid, NC_INT64,"NC_INT64"); + test_type(ncid, NC_UINT64,"NC_UINT64"); + test_type(ncid, NC_STRING,"NC_STRING"); + + /* Invoke a true negative */ + test_type_should_fail(ncid, 9999, "NC_GARBAGE"); + test_type_should_fail(ncid, -1, "NC_GARBAGE_NEGATIVE"); + + if(nc_close(ncid)) ERR; + + /* Reopen file to check that we can. */ + if (nc_create(FILE_NAME, 0, &ncid)) ERR; + if (nc_close(ncid)) ERR; + if (nc_create(FILE_NAME, NC_WRITE, &ncid)) ERR; + if (nc_close(ncid)) ERR; + } + SUMMARIZE_ERR; + +#ifdef ENABLE_CDF5 + printf("\n* Testing nc_inq_type with CDF5\n"); + { + if(nc_create(FILE_NAME,NC_CLOBBER|NC_CDF5,&ncid)) ERR; + + test_type(ncid, NC_BYTE,"NC_BYTE"); + test_type(ncid, NC_CHAR,"NC_CHAR"); + test_type(ncid, NC_SHORT,"NC_SHORT"); + test_type(ncid, NC_INT,"NC_INT"); + test_type(ncid, NC_LONG,"NC_LONG"); + test_type(ncid, NC_FLOAT,"NC_FLOAT"); + test_type(ncid, NC_DOUBLE,"NC_DOUBLE"); + test_type(ncid, NC_UBYTE,"NC_UBYTE"); + test_type(ncid, NC_USHORT,"NC_USHORT"); + test_type(ncid, NC_UINT,"NC_UINT"); + test_type(ncid, NC_INT64,"NC_INT64"); + test_type(ncid, NC_UINT64,"NC_UINT64"); + test_type(ncid, NC_STRING,"NC_STRING"); + + if(nc_close(ncid)) ERR; + + /* Reopen file to check that we can. */ + if (nc_open(FILE_NAME, NC_CDF5, &ncid)) ERR; + if (nc_close(ncid)) ERR; + if (nc_open(FILE_NAME, 0, &ncid)) ERR; + if (nc_close(ncid)) ERR; + if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; + if (nc_close(ncid)) ERR; + } + SUMMARIZE_ERR; +#endif /* ENABLE_CDF5 */ #ifdef USE_NETCDF4 - - { - 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; - - test_type(ncid, NC_BYTE,"NC_BYTE"); - test_type(ncid, NC_CHAR,"NC_CHAR"); - test_type(ncid, NC_SHORT,"NC_SHORT"); - test_type(ncid, NC_INT,"NC_INT"); - test_type(ncid, NC_LONG,"NC_LONG"); - test_type(ncid, NC_FLOAT,"NC_FLOAT"); - test_type(ncid, NC_DOUBLE,"NC_DOUBLE"); - test_type(ncid, NC_UBYTE,"NC_UBYTE"); - test_type(ncid, NC_USHORT,"NC_USHORT"); - test_type(ncid, NC_UINT,"NC_UINT"); - test_type(ncid, NC_INT64,"NC_INT64"); - test_type(ncid, NC_UINT64,"NC_UINT64"); - test_type(ncid, NC_STRING,"NC_STRING"); - - - if(nc_close(ncid)) ERR; - } - - { - printf("\n* Testing nc_inq_type with netcdf-4\n"); - - if(nc_create(FILE_NAME,NC_CLOBBER|NC_NETCDF4,&ncid)) ERR; - - test_type(ncid, NC_BYTE,"NC_BYTE"); - test_type(ncid, NC_CHAR,"NC_CHAR"); - test_type(ncid, NC_SHORT,"NC_SHORT"); - test_type(ncid, NC_INT,"NC_INT"); - test_type(ncid, NC_LONG,"NC_LONG"); - test_type(ncid, NC_FLOAT,"NC_FLOAT"); - test_type(ncid, NC_DOUBLE,"NC_DOUBLE"); - test_type(ncid, NC_UBYTE,"NC_UBYTE"); - test_type(ncid, NC_USHORT,"NC_USHORT"); - test_type(ncid, NC_UINT,"NC_UINT"); - test_type(ncid, NC_INT64,"NC_INT64"); - test_type(ncid, NC_UINT64,"NC_UINT64"); - test_type(ncid, NC_STRING,"NC_STRING"); - if(nc_close(ncid)) ERR; - } + 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; + + test_type(ncid, NC_BYTE,"NC_BYTE"); + test_type(ncid, NC_CHAR,"NC_CHAR"); + test_type(ncid, NC_SHORT,"NC_SHORT"); + test_type(ncid, NC_INT,"NC_INT"); + test_type(ncid, NC_LONG,"NC_LONG"); + test_type(ncid, NC_FLOAT,"NC_FLOAT"); + test_type(ncid, NC_DOUBLE,"NC_DOUBLE"); + test_type(ncid, NC_UBYTE,"NC_UBYTE"); + test_type(ncid, NC_USHORT,"NC_USHORT"); + test_type(ncid, NC_UINT,"NC_UINT"); + test_type(ncid, NC_INT64,"NC_INT64"); + test_type(ncid, NC_UINT64,"NC_UINT64"); + test_type(ncid, NC_STRING,"NC_STRING"); + + if(nc_close(ncid)) ERR; + + /* Re-open file to be sure we can. */ + if (nc_open(FILE_NAME, NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR; + if (nc_close(ncid)) ERR; + if (nc_open(FILE_NAME, NC_NETCDF4, &ncid)) ERR; + if (nc_close(ncid)) ERR; + if (nc_open(FILE_NAME, NC_CLASSIC_MODEL, &ncid)) ERR; + if (nc_close(ncid)) ERR; + if (nc_open(FILE_NAME, 0, &ncid)) ERR; + if (nc_close(ncid)) ERR; + if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; + if (nc_close(ncid)) ERR; + } + SUMMARIZE_ERR; + + printf("\n* Testing nc_inq_type with netcdf-4\n"); + { + + if(nc_create(FILE_NAME,NC_CLOBBER|NC_NETCDF4,&ncid)) ERR; + + test_type(ncid, NC_BYTE,"NC_BYTE"); + test_type(ncid, NC_CHAR,"NC_CHAR"); + test_type(ncid, NC_SHORT,"NC_SHORT"); + test_type(ncid, NC_INT,"NC_INT"); + test_type(ncid, NC_LONG,"NC_LONG"); + test_type(ncid, NC_FLOAT,"NC_FLOAT"); + test_type(ncid, NC_DOUBLE,"NC_DOUBLE"); + test_type(ncid, NC_UBYTE,"NC_UBYTE"); + test_type(ncid, NC_USHORT,"NC_USHORT"); + test_type(ncid, NC_UINT,"NC_UINT"); + test_type(ncid, NC_INT64,"NC_INT64"); + test_type(ncid, NC_UINT64,"NC_UINT64"); + test_type(ncid, NC_STRING,"NC_STRING"); + if(nc_close(ncid)) ERR; + + /* Re-open file to be sure we can. */ + if (nc_open(FILE_NAME, NC_NETCDF4, &ncid)) ERR; + if (nc_close(ncid)) ERR; + if (nc_open(FILE_NAME, 0, &ncid)) ERR; + if (nc_close(ncid)) ERR; + if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; + if (nc_close(ncid)) ERR; + } + SUMMARIZE_ERR; #endif // USE_NETCDF4 - printf("* Finished.\n"); + printf("* Finished.\n"); - SUMMARIZE_ERR; - FINAL_RESULTS; + FINAL_RESULTS; } diff --git a/nc_test4/tst_converts.c b/nc_test4/tst_converts.c index 183da06de0..72c80c403c 100644 --- a/nc_test4/tst_converts.c +++ b/nc_test4/tst_converts.c @@ -22,25 +22,58 @@ #define VAR2_NAME "var2" /* This is handy for print statements. */ -static char *format_name[] = {"", "classic", "64-bit offset", "netCDF-4", - "netCDF-4 classic model"}; +static char *format_name[MAX_NUM_FORMATS] = {"classic", "64-bit offset", "netCDF-4", + "netCDF-4 classic model", "CDF5"}; int check_file(int format, unsigned char *uchar_out); int create_file(int format, unsigned char *uchar_out); +/* Determine how many formats are available, and what they are. */ +void +determine_test_formats(int *num_formats, int *format) +{ + int ind = 0; + int num; + + /* Check inputs. */ + assert(num_formats && format); + + /* We always have classic and 64-bit offset */ + num = 2; + format[ind++] = NC_FORMAT_CLASSIC; + format[ind++] = NC_FORMAT_64BIT_OFFSET; + + /* Do we have netCDF-4 and netCDF-4 classic? */ +#ifdef USE_NETCDF4 + num += 2; + format[ind++] = NC_FORMAT_NETCDF4_CLASSIC; + format[ind++] = NC_FORMAT_NETCDF4; +#endif /* USE_NETCDF4 */ + + /* Do we have CDF5? */ +#ifdef ENABLE_CDF5 + num++; + format[ind++] = NC_FORMAT_CDF5; +#endif /* ENABLE_CDF5 */ + + *num_formats = num; +} + int main(int argc, char **argv) { unsigned char uchar_out[DIM1_LEN] = {0, 128, 255}; - int format; + int format[MAX_NUM_FORMATS]; + int num_formats; printf("\n*** Testing netcdf data conversion.\n"); + determine_test_formats(&num_formats, format); - for (format = 1; format < 5; format++) + for (int f = 0; f < num_formats; f++) { - printf("*** Testing conversion in netCDF %s files... ", format_name[format]); - create_file(format, uchar_out); - check_file(format, uchar_out); + printf("*** Testing conversion in netCDF %s files... ", format_name[f]); + create_file(format[f], uchar_out); + check_file(format[f], uchar_out); SUMMARIZE_ERR; } @@ -72,7 +105,7 @@ create_file(int format, unsigned char *uchar_out) retval = nc_put_var_uchar(ncid, varid, uchar_out); if (format == NC_FORMAT_NETCDF4 || format == NC_FORMAT_64BIT_DATA) { - if (retval != NC_ERANGE) ERR; + if (retval != NC_ERANGE) ERR; } else if (retval != NC_NOERR) ERR; @@ -83,7 +116,6 @@ create_file(int format, unsigned char *uchar_out) int check_file(int format, unsigned char *uchar_out) { - int ncid; int ndims, natts; int dimids_var[1], var_type; diff --git a/nc_test4/tst_files.c b/nc_test4/tst_files.c index 1fe342c805..ae934f0e7e 100644 --- a/nc_test4/tst_files.c +++ b/nc_test4/tst_files.c @@ -147,7 +147,7 @@ main(int argc, char **argv) if (dim_len != DIM1_LEN || strcmp(dim_name, DIM1_NAME)) ERR; if (nc_inq_var(ncid, 0, var_name, &var_type, &ndims, dimids_var, &natts)) ERR; if (ndims != 1 || strcmp(var_name, VAR1_NAME) || var_type != NC_BYTE || - dimids_var[0] != dimids[0] || natts != 0) ERR; + dimids_var[0] != dimids[0] || natts != 0) ERR; if (nc_close(ncid)) ERR; /* Recreate the file. */ @@ -206,7 +206,7 @@ main(int argc, char **argv) if (dim_len != DIM1_LEN || strcmp(dim_name, DIM1_NAME)) ERR; if (nc_inq_var(ncid, 0, var_name, &var_type, &ndims, dimids_var, &natts)) ERR; if (ndims != 1 || strcmp(var_name, VAR1_NAME) || var_type != NC_INT || - dimids_var[0] != dimids[0] || natts != 0) ERR; + dimids_var[0] != dimids[0] || natts != 0) ERR; if (nc_close(ncid)) ERR; } SUMMARIZE_ERR; @@ -244,10 +244,10 @@ main(int argc, char **argv) if (dim_len != DIM2_LEN || strcmp(dim_name, DIM2_NAME)) ERR; if (nc_inq_var(ncid, 0, var_name, &var_type, &ndims, dimids_var, &natts)) ERR; if (ndims != 2 || strcmp(var_name, VAR1_NAME) || var_type != NC_INT || - dimids_var[0] != dimids[0] || natts != 0) ERR; + dimids_var[0] != dimids[0] || natts != 0) ERR; if (nc_inq_var(ncid, 1, var_name, &var_type, &ndims, dimids_var, &natts)) ERR; if (ndims != 2 || strcmp(var_name, VAR2_NAME) || var_type != NC_UINT || - dimids_var[1] != dimids[1] || natts != 0) ERR; + dimids_var[1] != dimids[1] || natts != 0) ERR; if (nc_get_att_float(ncid, NC_GLOBAL, ATT1_NAME, &float_in)) ERR; if (float_in != float_out) ERR; if (nc_get_att_int(ncid, NC_GLOBAL, ATT2_NAME, &int_in)) ERR; @@ -262,12 +262,22 @@ main(int argc, char **argv) printf("*** testing redef for netCDF 64-bit offset..."); test_redef(NC_FORMAT_64BIT_OFFSET); SUMMARIZE_ERR; + +#ifdef USE_NETCDF4 printf("*** testing redef for netCDF-4 ..."); test_redef(NC_FORMAT_NETCDF4); SUMMARIZE_ERR; printf("*** testing redef for netCDF-4, with strict netCDF-3 rules..."); test_redef(NC_FORMAT_NETCDF4_CLASSIC); SUMMARIZE_ERR; +#endif /* USE_NETCDF4 */ + +#ifdef ENABLE_CDF5 + printf("*** testing redef for CDF5..."); + test_redef(NC_FORMAT_CDF5); + SUMMARIZE_ERR; +#endif /* ENABLE_CDF5 */ + printf("*** testing different formats..."); { int ncid; @@ -285,11 +295,14 @@ main(int argc, char **argv) if (format != NC_FORMAT_64BIT_OFFSET) ERR; if (nc_close(ncid)) ERR; + +#ifdef USE_NETCDF4 /* Create a netcdf-4 file. */ if (nc_create(FILE_NAME, NC_NETCDF4|NC_CLOBBER, &ncid)) ERR; if (nc_inq_format(ncid, &format)) ERR; if (format != NC_FORMAT_NETCDF4) ERR; if (nc_close(ncid)) ERR; +#endif /* USE_NETCDF4 */ } SUMMARIZE_ERR; printf("*** testing CLASSIC_MODEL flag with classic formats..."); @@ -310,6 +323,7 @@ main(int argc, char **argv) if (nc_close(ncid)) ERR; } SUMMARIZE_ERR; +#ifdef USE_NETCDF4 printf("*** testing multiple open files..."); { #define VAR_NAME "Captain_Kirk" @@ -329,32 +343,34 @@ main(int argc, char **argv) /* Create a bunch of files. */ for (f = 0; f < NUM_FILES; f++) { - sprintf(file_name, "tst_files2_%d.nc", f); - if (nc_create(file_name, NC_NETCDF4, &ncid[f])) ERR; - if (nc_def_dim(ncid[f], D1_NAME, TEXT_LEN + 1, &dimid)) ERR; - if (nc_def_var(ncid[f], VAR_NAME, NC_CHAR, NDIMS, &dimid, &varid)) ERR; - if (f % 2 == 0) - if (nc_def_var_chunking(ncid[f], varid, 0, chunks)) ERR; - - /* Write one time to the coordinate variable. */ - count[0] = TEXT_LEN + 1; - if (nc_put_vara_text(ncid[f], varid, index, count, ttext)) ERR; + sprintf(file_name, "tst_files2_%d.nc", f); + if (nc_create(file_name, NC_NETCDF4, &ncid[f])) ERR; + if (nc_def_dim(ncid[f], D1_NAME, TEXT_LEN + 1, &dimid)) ERR; + if (nc_def_var(ncid[f], VAR_NAME, NC_CHAR, NDIMS, &dimid, &varid)) ERR; + if (f % 2 == 0) + if (nc_def_var_chunking(ncid[f], varid, 0, chunks)) ERR; + + /* Write one time to the coordinate variable. */ + count[0] = TEXT_LEN + 1; + if (nc_put_vara_text(ncid[f], varid, index, count, ttext)) ERR; } /* Read something from each file. */ for (f = 0; f < NUM_FILES; f++) { - if (nc_get_vara_text(ncid[f], varid, index, count, (char *)ttext_in)) ERR; - if (strcmp(ttext_in, ttext)) ERR; + if (nc_get_vara_text(ncid[f], varid, index, count, (char *)ttext_in)) ERR; + if (strcmp(ttext_in, ttext)) ERR; } /* Close all open files. */ for (f = 0; f < NUM_FILES; f++) - if (nc_close(ncid[f])) ERR; + if (nc_close(ncid[f])) ERR; } SUMMARIZE_ERR; +#endif /* USE_NETCDF4 */ FINAL_RESULTS; } + #define REDEF_ATT1_NAME "CANTERBURY" #define REDEF_ATT2_NAME "ELY" #define REDEF_ATT3_NAME "KING_HENRY_V" @@ -407,14 +423,14 @@ test_redef(int format) /* Change chunk cache. */ if (nc_set_chunk_cache(NEW_CACHE_SIZE, NEW_CACHE_NELEMS, - NEW_CACHE_PREEMPTION)) ERR; + NEW_CACHE_PREEMPTION)) ERR; /* Create a file with two dims, two vars, and two atts. */ if (nc_create(FILE_NAME, cflags|NC_CLOBBER, &ncid)) ERR; /* Retrieve the chunk cache settings, just for fun. */ if (nc_get_chunk_cache(&cache_size_in, &cache_nelems_in, - &cache_preemption_in)) ERR; + &cache_preemption_in)) ERR; if (cache_size_in != NEW_CACHE_SIZE || cache_nelems_in != NEW_CACHE_NELEMS || cache_preemption_in != NEW_CACHE_PREEMPTION) ERR; @@ -422,7 +438,7 @@ test_redef(int format) * name. */ if (format != NC_FORMAT_NETCDF4) if (nc_def_dim(ncid, REDEF_NAME_ILLEGAL, REDEF_DIM2_LEN, - &dimids[1]) != NC_EBADNAME) ERR; + &dimids[1]) != NC_EBADNAME) ERR; if (nc_def_dim(ncid, REDEF_DIM1_NAME, REDEF_DIM1_LEN, &dimids[0])) ERR; if (nc_def_dim(ncid, REDEF_DIM2_NAME, REDEF_DIM2_LEN, &dimids[1])) ERR; @@ -459,15 +475,15 @@ test_redef(int format) /* This will fail. */ ret = nc_def_var(ncid, REDEF_VAR3_NAME, NC_UBYTE, REDEF_NDIMS, - dimids, &varid); + dimids, &varid); if(format == NC_FORMAT_NETCDF4) { - if(ret != NC_EPERM) { - ERR; - } + if(ret != NC_EPERM) { + ERR; + } } else { - if(ret != NC_ENOTINDEFINE) { - ERR; - } + if(ret != NC_ENOTINDEFINE) { + ERR; + } } /* This will fail. */ if (!nc_put_att_uchar(ncid, NC_GLOBAL, REDEF_ATT3_NAME, NC_CHAR, 1, &uchar_out)) ERR; From c920f48c49db2a7759c5a208dc8328cc3572d93f Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Sun, 5 Nov 2017 09:08:39 -0700 Subject: [PATCH 07/11] fixed ENABLE_CDF5 issue in some tests --- nc_test/tst_inq_type.c | 1 + 1 file changed, 1 insertion(+) diff --git a/nc_test/tst_inq_type.c b/nc_test/tst_inq_type.c index 8780fb45c1..8bd0233013 100644 --- a/nc_test/tst_inq_type.c +++ b/nc_test/tst_inq_type.c @@ -184,3 +184,4 @@ int main(int argc, char **argv) { FINAL_RESULTS; } + From f8c77f0692d682f2ef9064a82fe25e563080555e Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Mon, 6 Nov 2017 05:35:34 -0700 Subject: [PATCH 08/11] refurbished tst_cdf5format.c --- nc_test/Makefile.am | 8 + nc_test/tst_cdf5format.c | 344 +++++++++++++++++---------------------- 2 files changed, 153 insertions(+), 199 deletions(-) diff --git a/nc_test/Makefile.am b/nc_test/Makefile.am index cef7cf4b7b..363dd19f21 100644 --- a/nc_test/Makefile.am +++ b/nc_test/Makefile.am @@ -35,6 +35,14 @@ if USE_PNETCDF TESTPROGRAMS += tst_parallel2 tst_pnetcdf tst_addvar tst_formatx_pnetcdf endif +if TEST_PARALLEL4 +if USE_PNETCDF +if USE_CDF5 +TESTPROGRAMS += tst_cdf5format +endif +endif +endif + # These are the source files for the main workhorse test program, # nc_test. If you pass nc_test, you are doing well. nc_test_SOURCES = nc_test.c error.c test_get.c test_put.c \ diff --git a/nc_test/tst_cdf5format.c b/nc_test/tst_cdf5format.c index 91a65c5e56..2648409b77 100644 --- a/nc_test/tst_cdf5format.c +++ b/nc_test/tst_cdf5format.c @@ -5,224 +5,170 @@ Test fix of bug involving creation of a file with pnetcdf APIs, then opening and modifying the file with netcdf. - Author: Wei-keng Liao. + Author: Wei-keng Liao, Ed Hartnett */ - -/* -Goal is to verify that cdf-5 code is writing data that can -be read by pnetcdf and vice-versa. -*/ - -/* - Compile: - mpicc -g -o tst_cdf5format tst_cdf5format.c -lnetcdf -lcurl -lhdf5_hl -lhdf5 -lpnetcdf -lz -lm - Run: - nc_pnc -*/ - +#include #include -#include -#include -#include -#include -#include -#include -#include +#include #define NVARS 6 -#define NX 5 -#define FILENAME "tst_pnetcdf.nc" - -static void -report(int stat, char* file, int line) -{ - fflush(stdout); /* Make sure our stdout is synced with stderr.*/ - if(stat != 0) { - fprintf(stderr, "Sorry! Unexpected result, %s, line: %d: status=%d\n", \ - __FILE__, __LINE__,stat); - } -} - -#define Error(stat) report(stat,__FILE__,__LINE__) - -/* -Given ncid, -write meta-data and data -*/ +#define NX 5 +#define NDIM2 2 +#define FILENAME "tst_cdf5format.nc" int -write(int ncid, int parallel) +write2(int ncid, int parallel) { - int i, j, rank, nprocs, cmode, varid[NVARS], dimid[2], *buf; - int err = 0; - char str[32]; - size_t start[2], count[2]; - int stat = NC_NOERR; - - /* define dimension */ - if (stat=nc_def_dim(ncid, "Y", NC_UNLIMITED, &dimid[0])) Error(stat);; - if (stat=nc_def_dim(ncid, "X", NX, &dimid[1])) Error(stat);; - - /* Odd numbers are fixed variables, even numbers are record variables */ - for (i=0; i>>>>>> 896fe992ff193edcd1a7f2ad592d144a91de3de5 - for (i=0; i>>>>>> 896fe992ff193edcd1a7f2ad592d144a91de3de5 - /* read variables and check their contents */ - for (i=0; i 1 && rank == 0) - printf("This test program is intended to run on ONE process\n"); - if (rank > 0) goto fn_exit; - - -#ifdef DISABLE_PNETCDF_ALIGNMENT - MPI_Info_create(&info); - MPI_Info_set(info, "nc_header_align_size", "1"); - MPI_Info_set(info, "nc_var_align_size", "1"); -#endif - - /* pnetcdf->cdf5 */ - printf("\nWrite using PNETCDF; Read using CDF5\n"); + int rank, nprocs, ncid, cmode; + MPI_Comm comm = MPI_COMM_SELF; + MPI_Info info = MPI_INFO_NULL; + + MPI_Init(&argc, &argv); + MPI_Comm_size(MPI_COMM_WORLD, &nprocs); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + if (rank > 0) + return 2; + + /* pnetcdf->cdf5 */ + printf("\nWrite using PNETCDF; Read using classic netCDF..."); - cmode = NC_PNETCDF | NC_CLOBBER; - if (stat=nc_create_par(FILENAME, cmode, comm, info, &ncid)) Error(stat); - if (stat=write(ncid,1)) Error(stat); - if (stat=nc_close(ncid)) Error(stat); - /* re-open the file with netCDF (parallel) and enter define mode */ - if (stat=nc_open_par(FILENAME, NC_WRITE|NC_PNETCDF, comm, info, &ncid)) Error(stat); - if(stat=extend(ncid)) Error(stat); - if (stat=nc_close(ncid)) Error(stat); - - cmode = NC_CDF5 | NC_NOCLOBBER; - if (stat=nc_open(FILENAME, cmode, &ncid)) ERR_RET; - if (stat=read(ncid)) Error(stat); - if (stat=nc_close(ncid)) Error(stat); - - unlink(FILENAME); - - /* cdf5->pnetcdf */ - printf("\nWrite using CDF-5; Read using PNETCDF\n"); - cmode = NC_CDF5 | NC_CLOBBER; - if (stat=nc_create(FILENAME, cmode, &ncid)) ERR_RET; - if (stat=write(ncid,0)) Error(stat); - if (stat=nc_close(ncid)) Error(stat); - /* re-open the file with netCDF (parallel) and enter define mode */ - if (stat=nc_open(FILENAME, NC_WRITE|NC_CDF5, &ncid)) ERR_RET; - if (stat=extend(ncid)) Error(stat); - if (stat=nc_close(ncid)) Error(stat); - - cmode = NC_PNETCDF | NC_NOCLOBBER; - if (stat=nc_open_par(FILENAME, cmode, comm, info, &ncid)) ERR_RET; - if (stat=read(ncid)) Error(stat); - if (stat=nc_close(ncid)) Error(stat); - - if (info != MPI_INFO_NULL) MPI_Info_free(&info); - -fn_exit: - MPI_Finalize(); - SUMMARIZE_ERR; - FINAL_RESULTS; - return 0; + /* Create a netCDF classic file with pnetcdf. */ + cmode = NC_PNETCDF | NC_CLOBBER; + if (nc_create_par(FILENAME, cmode, comm, info, &ncid)) ERR; + if (write2(ncid, 1)) ERR; + if (nc_close(ncid)) ERR; + + /* Re-open the file with netCDF (parallel) and add var attributes. */ + if (nc_open_par(FILENAME, NC_WRITE|NC_PNETCDF, comm, info, &ncid)) ERR; + if (extend(ncid)) ERR; + if (nc_close(ncid)) ERR; + + if (nc_open(FILENAME, 0, &ncid)) ERR; + if (read2(ncid)) ERR; + if (nc_close(ncid)) ERR; + + /* cdf5->pnetcdf */ + printf("\nWrite using CDF-5; Read using PNETCDF\n"); + cmode = NC_CDF5 | NC_CLOBBER; + if (nc_create(FILENAME, cmode, &ncid)) ERR; + if (write2(ncid, 0)) ERR; + if (nc_close(ncid)) ERR; + + /* re-open the file with netCDF (parallel) and enter define mode */ + if (nc_open(FILENAME, NC_WRITE|NC_CDF5, &ncid)) ERR; + if (extend(ncid)) ERR; + if (nc_close(ncid)) ERR; + + cmode = NC_PNETCDF | NC_NOCLOBBER; + if (nc_open_par(FILENAME, cmode, comm, info, &ncid)) ERR; + if (read2(ncid)) ERR; + if (nc_close(ncid)) ERR; + + MPI_Finalize(); + SUMMARIZE_ERR; + FINAL_RESULTS; + return 0; } From c58bc3e41c31ff497a1c35ebd475b13ac3b40df4 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Mon, 6 Nov 2017 06:06:47 -0700 Subject: [PATCH 09/11] fixed warnings --- nc_test4/tst_interops5.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/nc_test4/tst_interops5.c b/nc_test4/tst_interops5.c index 3869106d0e..44c3274e8f 100644 --- a/nc_test4/tst_interops5.c +++ b/nc_test4/tst_interops5.c @@ -194,14 +194,10 @@ main(int argc, char **argv) hid_t fileid, grpid, spaceid, datasetid; int data_out[DIM1_LEN], data_in[DIM1_LEN]; hsize_t dims[1] = {DIM1_LEN}; - H5Z_filter_t filter; - int num_filters; hid_t propid; - unsigned int flags, cd_values[NUM_CD_ELEM], filter_config; - size_t cd_nelems = NUM_CD_ELEM; - size_t namelen = MAX_NAME; - char name[MAX_NAME + 1], name_in[MAX_NAME + 1]; + char name_in[MAX_NAME + 1]; int ncid, ndims_in, nvars_in, ngatts_in, unlimdimid_in, ngrps_in; + int nc_grpid; int dimid_in[1], natts_in; nc_type xtype_in; @@ -236,19 +232,19 @@ main(int argc, char **argv) if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR; if (nc_inq(ncid, &ndims_in, &nvars_in, &ngatts_in, &unlimdimid_in)) ERR; if (ndims_in != 0 || nvars_in != 0 || ngatts_in != 0 || unlimdimid_in != -1) ERR; - if (nc_inq_grps(ncid, &ngrps_in, &grpid)) ERR; + if (nc_inq_grps(ncid, &ngrps_in, &nc_grpid)) ERR; if (ngrps_in != 1) ERR; - if (nc_inq(grpid, &ndims_in, &nvars_in, &ngatts_in, &unlimdimid_in)) ERR; + if (nc_inq(nc_grpid, &ndims_in, &nvars_in, &ngatts_in, &unlimdimid_in)) ERR; if (ndims_in != 1 || nvars_in != 1 || ngatts_in != 0 || unlimdimid_in != -1) ERR; /* Check the variable. */ - if (nc_inq_var(grpid, 0, name_in, &xtype_in, &ndims_in, dimid_in, + if (nc_inq_var(nc_grpid, 0, name_in, &xtype_in, &ndims_in, dimid_in, &natts_in)) ERR; if (strcmp(name_in, BATTLE_RECORD) || xtype_in != NC_INT || ndims_in != 1 || dimid_in[0] != 0 || natts_in != 0) ERR; /* Check the data. */ - if (nc_get_var(grpid, 0, data_in)) ERR; + if (nc_get_var(nc_grpid, 0, data_in)) ERR; for (i = 0; i < DIM1_LEN; i++) if (data_in[i] != data_out[i]) ERR; From 59217fe8ac370d6e857abd1d0c289a904a309518 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Mon, 6 Nov 2017 06:19:34 -0700 Subject: [PATCH 10/11] cleaned up, fixed comments --- nc_test/tst_cdf5format.c | 74 ++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/nc_test/tst_cdf5format.c b/nc_test/tst_cdf5format.c index 2648409b77..6e183c1f6b 100644 --- a/nc_test/tst_cdf5format.c +++ b/nc_test/tst_cdf5format.c @@ -16,6 +16,7 @@ #define NDIM2 2 #define FILENAME "tst_cdf5format.nc" +/* Write a file with 2 dims and 6 vars, including some sample data. */ int write2(int ncid, int parallel) { @@ -71,6 +72,7 @@ write2(int ncid, int parallel) return 0; } +/* Add some attributes to the vars of an open file. */ int extend(int ncid) { @@ -89,6 +91,7 @@ extend(int ncid) return NC_NOERR; } +/* Read the file and check the data. */ int read2(int ncid) { @@ -132,43 +135,48 @@ int main(int argc, char* argv[]) if (rank > 0) return 2; - /* pnetcdf->cdf5 */ printf("\nWrite using PNETCDF; Read using classic netCDF..."); - - /* Create a netCDF classic file with pnetcdf. */ - cmode = NC_PNETCDF | NC_CLOBBER; - if (nc_create_par(FILENAME, cmode, comm, info, &ncid)) ERR; - if (write2(ncid, 1)) ERR; - if (nc_close(ncid)) ERR; - - /* Re-open the file with netCDF (parallel) and add var attributes. */ - if (nc_open_par(FILENAME, NC_WRITE|NC_PNETCDF, comm, info, &ncid)) ERR; - if (extend(ncid)) ERR; - if (nc_close(ncid)) ERR; - - if (nc_open(FILENAME, 0, &ncid)) ERR; - if (read2(ncid)) ERR; - if (nc_close(ncid)) ERR; - - /* cdf5->pnetcdf */ - printf("\nWrite using CDF-5; Read using PNETCDF\n"); - cmode = NC_CDF5 | NC_CLOBBER; - if (nc_create(FILENAME, cmode, &ncid)) ERR; - if (write2(ncid, 0)) ERR; - if (nc_close(ncid)) ERR; - - /* re-open the file with netCDF (parallel) and enter define mode */ - if (nc_open(FILENAME, NC_WRITE|NC_CDF5, &ncid)) ERR; - if (extend(ncid)) ERR; - if (nc_close(ncid)) ERR; + { + /* Create a netCDF classic file with pnetcdf. */ + cmode = NC_PNETCDF | NC_CLOBBER; + if (nc_create_par(FILENAME, cmode, comm, info, &ncid)) ERR; + if (write2(ncid, 1)) ERR; + if (nc_close(ncid)) ERR; + + /* Re-open the file with pnetCDF (parallel) and add var attributes. */ + if (nc_open_par(FILENAME, NC_WRITE|NC_PNETCDF, comm, info, &ncid)) ERR; + if (extend(ncid)) ERR; + if (nc_close(ncid)) ERR; + + /* Open with classic and check. */ + if (nc_open(FILENAME, 0, &ncid)) ERR; + if (read2(ncid)) ERR; + if (nc_close(ncid)) ERR; + } + SUMMARIZE_ERR; - cmode = NC_PNETCDF | NC_NOCLOBBER; - if (nc_open_par(FILENAME, cmode, comm, info, &ncid)) ERR; - if (read2(ncid)) ERR; - if (nc_close(ncid)) ERR; + printf("\nWrite using CDF-5; Read using PNETCDF..."); + { + /* Create a file with CDF5. */ + cmode = NC_CDF5 | NC_CLOBBER; + if (nc_create(FILENAME, cmode, &ncid)) ERR; + if (write2(ncid, 0)) ERR; + if (nc_close(ncid)) ERR; + + /* Re-open the file with CDF5 and add some atts. */ + if (nc_open(FILENAME, NC_WRITE, &ncid)) ERR; + if (extend(ncid)) ERR; + if (nc_close(ncid)) ERR; + + /* Re-open with pnetcdf and check. */ + cmode = NC_PNETCDF | NC_NOCLOBBER; + if (nc_open_par(FILENAME, cmode, comm, info, &ncid)) ERR; + if (read2(ncid)) ERR; + if (nc_close(ncid)) ERR; + } + SUMMARIZE_ERR; MPI_Finalize(); - SUMMARIZE_ERR; FINAL_RESULTS; return 0; } From e7fee3ee53efad3f8a718c775b0dcfc469cd19d3 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Tue, 7 Nov 2017 15:19:07 -0700 Subject: [PATCH 11/11] Corrected an issue encountered by the default compiler on ARM. --- nc_test4/tst_converts.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nc_test4/tst_converts.c b/nc_test4/tst_converts.c index 72c80c403c..2b6b8320ff 100644 --- a/nc_test4/tst_converts.c +++ b/nc_test4/tst_converts.c @@ -65,11 +65,12 @@ main(int argc, char **argv) unsigned char uchar_out[DIM1_LEN] = {0, 128, 255}; int format[MAX_NUM_FORMATS]; int num_formats; + int f = 0; printf("\n*** Testing netcdf data conversion.\n"); determine_test_formats(&num_formats, format); - for (int f = 0; f < num_formats; f++) + for (f = 0; f < num_formats; f++) { printf("*** Testing conversion in netCDF %s files... ", format_name[f]); create_file(format[f], uchar_out);