mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
Merge branch 'ejh_fast_var_prep_2' of https://github.com/NetCDF-World-Domination-Council/netcdf-c into pr-aggregation.wif
This commit is contained in:
commit
9e94e3298d
@ -550,13 +550,12 @@ if test "x$enable_large_file_tests" = xyes; then
|
||||
fi
|
||||
|
||||
# Does the user want to run benchmarks?
|
||||
AC_MSG_CHECKING([whether benchmarks should be run (experimental)])
|
||||
AC_MSG_CHECKING([whether benchmarks should be run])
|
||||
AC_ARG_ENABLE([benchmarks],
|
||||
[AS_HELP_STRING([--enable-benchmarks],
|
||||
[Run benchmarks. This is an experimental feature. You must fetch
|
||||
sample data files from the Unidata ftp site to use these benchmarks.
|
||||
The benchmarks are a bunch of extra tests, which are timed. We use these
|
||||
tests to check netCDF performance.])])
|
||||
[Run benchmarks. This will cause sample data files from the Unidata ftp
|
||||
site to be fetched. The benchmarks are a bunch of extra tests, which
|
||||
are timed. We use these tests to check netCDF performance.])])
|
||||
test "x$enable_benchmarks" = xyes || enable_benchmarks=no
|
||||
AC_MSG_RESULT($enable_benchmarks)
|
||||
AM_CONDITIONAL(BUILD_BENCHMARKS, [test x$enable_benchmarks = xyes])
|
||||
|
@ -141,10 +141,10 @@ typedef struct NC_VAR_INFO
|
||||
{
|
||||
NC_OBJ hdr;
|
||||
char *hdf5_name; /* used if different from name */
|
||||
struct NC_GRP_INFO* container; /* containing group */
|
||||
struct NC_GRP_INFO *container; /* containing group */
|
||||
size_t ndims;
|
||||
int *dimids;
|
||||
NC_DIM_INFO_T** dim;
|
||||
NC_DIM_INFO_T **dim;
|
||||
nc_bool_t is_new_var; /* True if variable is newly created */
|
||||
nc_bool_t was_coord_var; /* True if variable was a coordinate var, but either the dim or var has been renamed */
|
||||
nc_bool_t became_coord_var; /* True if variable _became_ a coordinate var, because either the dim or var has been renamed */
|
||||
@ -154,7 +154,7 @@ typedef struct NC_VAR_INFO
|
||||
nc_bool_t written_to; /* True if variable has data written to it */
|
||||
struct NC_TYPE_INFO *type_info;
|
||||
int atts_not_read; /* If true, the atts have not yet been read. */
|
||||
NCindex* att; /* NCindex<NC_ATT_INFO_T*> */
|
||||
NCindex *att; /* NCindex<NC_ATT_INFO_T*> */
|
||||
nc_bool_t no_fill; /* True if no fill value is defined for var */
|
||||
void *fill_value;
|
||||
size_t *chunksizes;
|
||||
@ -172,7 +172,7 @@ typedef struct NC_VAR_INFO
|
||||
/* Stuff for arbitrary filters */
|
||||
unsigned int filterid;
|
||||
size_t nparams;
|
||||
unsigned int* params;
|
||||
unsigned int *params;
|
||||
} NC_VAR_INFO_T;
|
||||
|
||||
typedef struct NC_FIELD_INFO
|
||||
|
@ -1112,6 +1112,79 @@ get_scale_info(NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim, NC_VAR_INFO_T *var,
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Get the metadata for a variable.
|
||||
*
|
||||
* @param var Pointer to var info struct.
|
||||
*
|
||||
* @return ::NC_NOERR No error.
|
||||
* @return ::NC_EBADID Bad ncid.
|
||||
* @return ::NC_ENOMEM Out of memory.
|
||||
* @return ::NC_EHDFERR HDF5 returned error.
|
||||
* @return ::NC_EVARMETA Error with var metadata.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
static int
|
||||
get_var_meta(NC_VAR_INFO_T *var)
|
||||
{
|
||||
NC_HDF5_VAR_INFO_T *hdf5_var;
|
||||
hid_t access_pid = 0;
|
||||
hid_t propid = 0;
|
||||
double rdcc_w0;
|
||||
int retval = NC_NOERR;
|
||||
|
||||
assert(var && var->format_var_info);
|
||||
|
||||
/* Get pointer to the HDF5-specific var info struct. */
|
||||
hdf5_var = (NC_HDF5_VAR_INFO_T *)var->format_var_info;
|
||||
|
||||
/* Get the current chunk cache settings. */
|
||||
if ((access_pid = H5Dget_access_plist(hdf5_var->hdf_datasetid)) < 0)
|
||||
BAIL(NC_EVARMETA);
|
||||
|
||||
/* Learn about current chunk cache settings. */
|
||||
if ((H5Pget_chunk_cache(access_pid, &(var->chunk_cache_nelems),
|
||||
&(var->chunk_cache_size), &rdcc_w0)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
var->chunk_cache_preemption = rdcc_w0;
|
||||
|
||||
/* Get the dataset creation properties. */
|
||||
if ((propid = H5Dget_create_plist(hdf5_var->hdf_datasetid)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
||||
/* Get var chunking info. */
|
||||
if ((retval = get_chunking_info(propid, var)))
|
||||
BAIL(retval);
|
||||
|
||||
/* Get filter info for a var. */
|
||||
if ((retval = get_filter_info(propid, var)))
|
||||
BAIL(retval);
|
||||
|
||||
/* Learn all about the type of this variable. */
|
||||
if ((retval = get_type_info2(var->container->nc4_info, hdf5_var->hdf_datasetid,
|
||||
&var->type_info)))
|
||||
BAIL(retval);
|
||||
|
||||
/* Indicate that the variable has a pointer to the type */
|
||||
var->type_info->rc++;
|
||||
|
||||
/* Get fill value, if defined. */
|
||||
if ((retval = get_fill_info(propid, var)))
|
||||
BAIL(retval);
|
||||
|
||||
/* Is this a deflated variable with a chunksize greater than the
|
||||
* current cache size? */
|
||||
if ((retval = nc4_adjust_var_cache(var->container, var)))
|
||||
BAIL(retval);
|
||||
|
||||
exit:
|
||||
if (access_pid && H5Pclose(access_pid) < 0)
|
||||
BAIL2(NC_EHDFERR);
|
||||
if (propid > 0 && H5Pclose(propid) < 0)
|
||||
BAIL2(NC_EHDFERR);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal This function is called by read_dataset(), (which is
|
||||
* called by rec_read_metadata()) when a netCDF variable is found in
|
||||
@ -1139,12 +1212,9 @@ read_var(NC_GRP_INFO_T *grp, hid_t datasetid, const char *obj_name,
|
||||
{
|
||||
NC_VAR_INFO_T *var = NULL;
|
||||
NC_HDF5_VAR_INFO_T *hdf5_var;
|
||||
hid_t access_pid = 0;
|
||||
int incr_id_rc = 0; /* Whether dataset ID's ref count has been incremented */
|
||||
hid_t propid = 0;
|
||||
int retval = NC_NOERR;
|
||||
double rdcc_w0;
|
||||
char *finalname = NULL;
|
||||
int retval = NC_NOERR;
|
||||
|
||||
assert(obj_name && grp);
|
||||
LOG((4, "%s: obj_name %s", __func__, obj_name));
|
||||
@ -1177,57 +1247,21 @@ read_var(NC_GRP_INFO_T *grp, hid_t datasetid, const char *obj_name,
|
||||
H5Iinc_ref(hdf5_var->hdf_datasetid); /* Increment number of objects using ID */
|
||||
incr_id_rc++; /* Indicate that we've incremented the ref. count (for errors) */
|
||||
var->created = NC_TRUE;
|
||||
|
||||
/* Get the current chunk cache settings. */
|
||||
if ((access_pid = H5Dget_access_plist(datasetid)) < 0)
|
||||
BAIL(NC_EVARMETA);
|
||||
|
||||
/* Learn about current chunk cache settings. */
|
||||
if ((H5Pget_chunk_cache(access_pid, &(var->chunk_cache_nelems),
|
||||
&(var->chunk_cache_size), &rdcc_w0)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
var->chunk_cache_preemption = rdcc_w0;
|
||||
|
||||
/* Get the dataset creation properties. */
|
||||
if ((propid = H5Dget_create_plist(datasetid)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
||||
/* Get var chunking info. */
|
||||
if ((retval = get_chunking_info(propid, var)))
|
||||
BAIL(retval);
|
||||
|
||||
/* Get filter info for a var. */
|
||||
if ((retval = get_filter_info(propid, var)))
|
||||
BAIL(retval);
|
||||
|
||||
/* Learn all about the type of this variable. */
|
||||
if ((retval = get_type_info2(grp->nc4_info, datasetid, &var->type_info)))
|
||||
BAIL(retval);
|
||||
|
||||
/* Indicate that the variable has a pointer to the type */
|
||||
var->type_info->rc++;
|
||||
|
||||
/* Get fill value, if defined. */
|
||||
if ((retval = get_fill_info(propid, var)))
|
||||
BAIL(retval);
|
||||
var->atts_not_read = 1; /* Don't read var atts until user asks for one. */
|
||||
|
||||
/* Try and read the dimids from the COORDINATES attribute. If it's
|
||||
* not present, we will have to do dimsscale matching to locate the
|
||||
* dims for this var. */
|
||||
retval = read_coord_dimids(grp, var);
|
||||
if (retval && retval != NC_ENOTATT)
|
||||
return retval;
|
||||
BAIL(retval);
|
||||
|
||||
/* Handle scale info. */
|
||||
if ((retval = get_scale_info(grp, dim, var, hdf5_var, ndims, datasetid)))
|
||||
BAIL(retval);
|
||||
|
||||
/* Don't read variable attributes until user asks for one. */
|
||||
var->atts_not_read = 1;
|
||||
|
||||
/* Is this a deflated variable with a chunksize greater than the
|
||||
* current cache size? */
|
||||
if ((retval = nc4_adjust_var_cache(grp, var)))
|
||||
/* Get the rest of the metadata for this variable. */
|
||||
if ((retval = get_var_meta(var)))
|
||||
BAIL(retval);
|
||||
|
||||
exit:
|
||||
@ -1241,10 +1275,7 @@ exit:
|
||||
nc4_var_list_del(grp,var);
|
||||
}
|
||||
}
|
||||
if (access_pid && H5Pclose(access_pid) < 0)
|
||||
BAIL2(NC_EHDFERR);
|
||||
if (propid > 0 && H5Pclose(propid) < 0)
|
||||
BAIL2(NC_EHDFERR);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -510,6 +510,7 @@ nc4_var_list_add2(NC_GRP_INFO_T *grp, const char *name, NC_VAR_INFO_T **var)
|
||||
if (!(new_var = calloc(1, sizeof(NC_VAR_INFO_T))))
|
||||
return NC_ENOMEM;
|
||||
new_var->hdr.sort = NCVAR;
|
||||
new_var->container = grp;
|
||||
|
||||
/* These are the HDF5-1.8.4 defaults. */
|
||||
new_var->chunk_cache_size = nc4_chunk_cache_size;
|
||||
|
@ -160,9 +160,7 @@ NC4_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
return retval;
|
||||
assert(grp && h5);
|
||||
|
||||
/* Walk through the list of vars, and return the info about the one
|
||||
with a matching varid. If the varid is -1, find the global
|
||||
atts and call it a day. */
|
||||
/* If the varid is -1, find the global atts and call it a day. */
|
||||
if (varid == NC_GLOBAL && nattsp)
|
||||
{
|
||||
*nattsp = ncindexcount(grp->att);
|
||||
|
@ -74,7 +74,8 @@ endif # BUILD_V2
|
||||
if BUILD_BENCHMARKS
|
||||
check_PROGRAMS += tst_create_files bm_file tst_chunks3 tst_ar4 \
|
||||
tst_ar4_3d tst_ar4_4d bm_many_objs tst_h_many_atts bm_many_atts \
|
||||
tst_files2 tst_files3 tst_mem tst_knmi bm_netcdf4_recs tst_wrf_reads
|
||||
tst_files2 tst_files3 tst_mem tst_knmi bm_netcdf4_recs tst_wrf_reads \
|
||||
tst_attsperf
|
||||
|
||||
bm_netcdf4_recs_SOURCES = bm_netcdf4_recs.c tst_utils.c
|
||||
bm_many_atts_SOURCES = bm_many_atts.c tst_utils.c
|
||||
@ -90,7 +91,7 @@ tst_wrf_reads_SOURCES = tst_wrf_reads.c tst_utils.c
|
||||
|
||||
TESTS += tst_ar4_3d tst_create_files run_bm_test1.sh run_bm_elena.sh \
|
||||
run_bm_test2.sh run_tst_chunks.sh tst_files2 tst_files3 tst_mem \
|
||||
run_knmi_bm.sh tst_wrf_reads
|
||||
run_knmi_bm.sh tst_wrf_reads tst_attsperf
|
||||
|
||||
# tst_create_files creates files for other tests.
|
||||
run_bm_test1.log: tst_create_files.log
|
||||
@ -131,8 +132,8 @@ TESTS += run_par_test.sh
|
||||
endif
|
||||
|
||||
if ENABLE_METADATA_PERF
|
||||
check_PROGRAMS += bigmeta openbigmeta tst_attsperf
|
||||
TESTS += tst_attsperf perftest.sh
|
||||
check_PROGRAMS += bigmeta openbigmeta
|
||||
TESTS += perftest.sh
|
||||
endif
|
||||
|
||||
EXTRA_DIST = run_par_test.sh.in run_par_bm_test.sh.in run_bm_test1.sh \
|
||||
|
@ -17,142 +17,142 @@
|
||||
#define VAR_NAME Y_NAME
|
||||
#define XDIM_LEN 2
|
||||
#define YDIM_LEN 5
|
||||
#define CLAIR "Clair"
|
||||
#define JAMIE "Jamie"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
printf("\n*** Testing netcdf-4 variable functions, even more.\n");
|
||||
/* printf("**** testing Jeff's dimension problem..."); */
|
||||
/* { */
|
||||
/* int varid, ncid, dims[NDIMS2], dims_in[NDIMS2]; */
|
||||
/* int ndims, nvars, ngatts, unlimdimid, natts; */
|
||||
/* char name_in[NC_MAX_NAME + 1]; */
|
||||
/* nc_type type_in; */
|
||||
/* size_t len_in; */
|
||||
printf("**** testing Jeff's dimension problem...");
|
||||
{
|
||||
int varid, ncid, dims[NDIMS2], dims_in[NDIMS2];
|
||||
int ndims, nvars, ngatts, unlimdimid, natts;
|
||||
char name_in[NC_MAX_NAME + 1];
|
||||
nc_type type_in;
|
||||
size_t len_in;
|
||||
|
||||
/* if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR; */
|
||||
/* if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR; */
|
||||
/* if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR; */
|
||||
/* if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR; */
|
||||
/* if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR; */
|
||||
/* if (nvars != NUM_VARS || ndims != NDIMS2 || ngatts != 0 || unlimdimid != -1) ERR; */
|
||||
/* if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims, dims_in, &natts)) ERR; */
|
||||
/* if (strcmp(name_in, VAR_NAME) || type_in != NC_FLOAT || ndims != NDIMS2 || */
|
||||
/* dims_in[0] != dims[0] || dims_in[1] != dims[1] || natts != 0) ERR; */
|
||||
/* if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR; */
|
||||
/* if (strcmp(name_in, X_NAME) || len_in != XDIM_LEN) ERR; */
|
||||
/* if (nc_inq_dim(ncid, 1, name_in, &len_in)) ERR; */
|
||||
/* if (strcmp(name_in, Y_NAME)) ERR; */
|
||||
/* if (len_in != YDIM_LEN) ERR; */
|
||||
/* if (nc_close(ncid)) ERR; */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR;
|
||||
if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR;
|
||||
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
|
||||
if (nvars != NUM_VARS || ndims != NDIMS2 || ngatts != 0 || unlimdimid != -1) ERR;
|
||||
if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims, dims_in, &natts)) ERR;
|
||||
if (strcmp(name_in, VAR_NAME) || type_in != NC_FLOAT || ndims != NDIMS2 ||
|
||||
dims_in[0] != dims[0] || dims_in[1] != dims[1] || natts != 0) ERR;
|
||||
if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR;
|
||||
if (strcmp(name_in, X_NAME) || len_in != XDIM_LEN) ERR;
|
||||
if (nc_inq_dim(ncid, 1, name_in, &len_in)) ERR;
|
||||
if (strcmp(name_in, Y_NAME)) ERR;
|
||||
if (len_in != YDIM_LEN) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* /\* Open the file and check. *\/ */
|
||||
/* if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; */
|
||||
/* if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR; */
|
||||
/* if (nvars != NUM_VARS || ndims != NDIMS2 || ngatts != 0 || unlimdimid != -1) ERR; */
|
||||
/* if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims, dims_in, &natts)) ERR; */
|
||||
/* if (strcmp(name_in, VAR_NAME) || type_in != NC_FLOAT || ndims != NDIMS2 || */
|
||||
/* dims_in[0] != dims[0] || dims_in[1] != dims[1] || natts != 0) ERR; */
|
||||
/* if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR; */
|
||||
/* if (strcmp(name_in, X_NAME) || len_in != XDIM_LEN) ERR; */
|
||||
/* if (nc_inq_dim(ncid, 1, name_in, &len_in)) ERR; */
|
||||
/* if (strcmp(name_in, Y_NAME)) ERR; */
|
||||
/* if (len_in != YDIM_LEN) ERR; */
|
||||
/* if (nc_close(ncid)) ERR; */
|
||||
/* } */
|
||||
/* SUMMARIZE_ERR; */
|
||||
/* printf("**** testing chunking turned on by fletcher..."); */
|
||||
/* { */
|
||||
/* int varid, ncid, dims[NDIMS2]; */
|
||||
/* int storage_in; */
|
||||
/* size_t chunksizes_in[NDIMS2]; */
|
||||
/* Open the file and check. */
|
||||
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
|
||||
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
|
||||
if (nvars != NUM_VARS || ndims != NDIMS2 || ngatts != 0 || unlimdimid != -1) ERR;
|
||||
if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims, dims_in, &natts)) ERR;
|
||||
if (strcmp(name_in, VAR_NAME) || type_in != NC_FLOAT || ndims != NDIMS2 ||
|
||||
dims_in[0] != dims[0] || dims_in[1] != dims[1] || natts != 0) ERR;
|
||||
if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR;
|
||||
if (strcmp(name_in, X_NAME) || len_in != XDIM_LEN) ERR;
|
||||
if (nc_inq_dim(ncid, 1, name_in, &len_in)) ERR;
|
||||
if (strcmp(name_in, Y_NAME)) ERR;
|
||||
if (len_in != YDIM_LEN) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("**** testing chunking turned on by fletcher...");
|
||||
{
|
||||
int varid, ncid, dims[NDIMS2];
|
||||
int storage_in;
|
||||
size_t chunksizes_in[NDIMS2];
|
||||
|
||||
/* if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR; */
|
||||
/* if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR; */
|
||||
/* if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR; */
|
||||
/* if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR; */
|
||||
/* if (nc_def_var_fletcher32(ncid, varid, NC_FLETCHER32)) ERR; */
|
||||
/* if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR; */
|
||||
/* if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR; */
|
||||
/* if (nc_close(ncid)) ERR; */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR;
|
||||
if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR;
|
||||
if (nc_def_var_fletcher32(ncid, varid, NC_FLETCHER32)) ERR;
|
||||
if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR;
|
||||
if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* /\* Open the file and check. *\/ */
|
||||
/* if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; */
|
||||
/* if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR; */
|
||||
/* if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR; */
|
||||
/* if (nc_close(ncid)) ERR; */
|
||||
/* } */
|
||||
/* SUMMARIZE_ERR; */
|
||||
/* printf("**** testing chunking turned on by shuffle..."); */
|
||||
/* { */
|
||||
/* int varid, ncid, dims[NDIMS2]; */
|
||||
/* int storage_in; */
|
||||
/* size_t chunksizes_in[NDIMS2]; */
|
||||
/* Open the file and check. */
|
||||
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
|
||||
if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR;
|
||||
if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("**** testing chunking turned on by shuffle...");
|
||||
{
|
||||
int varid, ncid, dims[NDIMS2];
|
||||
int storage_in;
|
||||
size_t chunksizes_in[NDIMS2];
|
||||
|
||||
/* if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR; */
|
||||
/* if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR; */
|
||||
/* if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR; */
|
||||
/* if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR; */
|
||||
/* if (nc_def_var_deflate(ncid, varid, NC_SHUFFLE, 0, 0)) ERR; */
|
||||
/* if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR; */
|
||||
/* if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR; */
|
||||
/* if (nc_close(ncid)) ERR; */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR;
|
||||
if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR;
|
||||
if (nc_def_var_deflate(ncid, varid, NC_SHUFFLE, 0, 0)) ERR;
|
||||
if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR;
|
||||
if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* /\* Open the file and check. *\/ */
|
||||
/* if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; */
|
||||
/* if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR; */
|
||||
/* if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR; */
|
||||
/* if (nc_close(ncid)) ERR; */
|
||||
/* } */
|
||||
/* SUMMARIZE_ERR; */
|
||||
/* #define DIM_NAME "Distance_from_Mayo" */
|
||||
/* #define VAR_NAME_2 "Rocky_Road_to_Dublin" */
|
||||
/* #define NDIMS1 1 */
|
||||
/* #define NUM_RECORDS 3 */
|
||||
/* printf("**** testing extending var along unlimited dim with no coord var..."); */
|
||||
/* { */
|
||||
/* int varid, ncid, dimid; */
|
||||
/* int ndims, nvars, natts, unlimdimid; */
|
||||
/* size_t dim_len_in, index; */
|
||||
/* int data = TEST_VAL_42; */
|
||||
/* Open the file and check. */
|
||||
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
|
||||
if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR;
|
||||
if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
#define DIM_NAME "Distance_from_Mayo"
|
||||
#define VAR_NAME_2 "Rocky_Road_to_Dublin"
|
||||
#define NDIMS1 1
|
||||
#define NUM_RECORDS 3
|
||||
printf("**** testing extending var along unlimited dim with no coord var...");
|
||||
{
|
||||
int varid, ncid, dimid;
|
||||
int ndims, nvars, natts, unlimdimid;
|
||||
size_t dim_len_in, index;
|
||||
int data = TEST_VAL_42;
|
||||
|
||||
/* /\* Create the test file with one var, one unlimited dim. *\/ */
|
||||
/* if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR; */
|
||||
/* if (nc_def_dim(ncid, DIM_NAME, NC_UNLIMITED, &dimid)) ERR; */
|
||||
/* if (nc_def_var(ncid, VAR_NAME_2, NC_INT, NDIMS1, &dimid, &varid)) ERR; */
|
||||
/* Create the test file with one var, one unlimited dim. */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, DIM_NAME, NC_UNLIMITED, &dimid)) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME_2, NC_INT, NDIMS1, &dimid, &varid)) ERR;
|
||||
|
||||
/* /\* Write some records. *\/ */
|
||||
/* for (index = 0; index < NUM_RECORDS; index++) */
|
||||
/* if (nc_put_var1_int(ncid, varid, &index, &data)) ERR; */
|
||||
/* if (nc_close(ncid)) ERR; */
|
||||
/* Write some records. */
|
||||
for (index = 0; index < NUM_RECORDS; index++)
|
||||
if (nc_put_var1_int(ncid, varid, &index, &data)) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* /\* Open the file and check. *\/ */
|
||||
/* if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; */
|
||||
/* if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR; */
|
||||
/* if (ndims != 1 || nvars != 1 || natts != 0 || unlimdimid != 0) ERR; */
|
||||
/* if (nc_inq_dim(ncid, dimid, NULL, &dim_len_in)) ERR; */
|
||||
/* if (dim_len_in != NUM_RECORDS) ERR; */
|
||||
/* Open the file and check. */
|
||||
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
|
||||
if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
|
||||
if (ndims != 1 || nvars != 1 || natts != 0 || unlimdimid != 0) ERR;
|
||||
if (nc_inq_dim(ncid, dimid, NULL, &dim_len_in)) ERR;
|
||||
if (dim_len_in != NUM_RECORDS) ERR;
|
||||
|
||||
/* /\* Now add more records. *\/ */
|
||||
/* for (index = 3; index < NUM_RECORDS * 2; index++) */
|
||||
/* if (nc_put_var1_int(ncid, varid, &index, &data)) ERR; */
|
||||
/* if (nc_inq_dim(ncid, dimid, NULL, &dim_len_in)) ERR; */
|
||||
/* Now add more records. */
|
||||
for (index = 3; index < NUM_RECORDS * 2; index++)
|
||||
if (nc_put_var1_int(ncid, varid, &index, &data)) ERR;
|
||||
if (nc_inq_dim(ncid, dimid, NULL, &dim_len_in)) ERR;
|
||||
|
||||
/* if (dim_len_in != NUM_RECORDS * 2) ERR; */
|
||||
if (dim_len_in != NUM_RECORDS * 2) ERR;
|
||||
|
||||
/* /\* Close the file. *\/ */
|
||||
/* if (nc_close(ncid)) ERR; */
|
||||
/* } */
|
||||
/* SUMMARIZE_ERR; */
|
||||
#define CLAIR "Clair"
|
||||
#define JAMIE "Jamie"
|
||||
/* Close the file. */
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("**** testing type creation and destruction for atomic types...");
|
||||
{
|
||||
int varid1, varid2, ncid;
|
||||
int ndims, nvars, natts, unlimdimid;
|
||||
|
||||
/* Create the test file with two scalar vars. */
|
||||
nc_set_log_level(4);
|
||||
/* nc_set_log_level(4); */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
|
||||
if (nc_def_var(ncid, CLAIR, NC_INT, 0, NULL, &varid1)) ERR;
|
||||
if (nc_def_var(ncid, JAMIE, NC_INT, 0, NULL, &varid2)) ERR;
|
||||
@ -165,5 +165,36 @@ main(int argc, char **argv)
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("**** testing scalar big endian vars...");
|
||||
{
|
||||
int varid1, varid2, ncid;
|
||||
int ndims, nvars, natts, unlimdimid;
|
||||
int test_val = TEST_VAL_42;
|
||||
int test_val2 = TEST_VAL_42 * 2;
|
||||
int data_in;
|
||||
|
||||
/* Create the test file with two scalar vars. */
|
||||
nc_set_log_level(4);
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
|
||||
if (nc_def_var(ncid, CLAIR, NC_INT, 0, NULL, &varid1)) ERR;
|
||||
if (nc_def_var_endian(ncid, varid1, NC_ENDIAN_BIG)) ERR;
|
||||
if (nc_def_var(ncid, JAMIE, NC_INT, 0, NULL, &varid2)) ERR;
|
||||
if (nc_def_var_endian(ncid, varid2, NC_ENDIAN_BIG)) ERR;
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
if (nc_put_var(ncid, varid1, &test_val)) ERR;
|
||||
if (nc_put_var(ncid, varid2, &test_val2)) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Open the file and check. */
|
||||
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
|
||||
if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
|
||||
if (ndims != 0 || nvars != 2 || natts != 0 || unlimdimid != -1) ERR;
|
||||
if (nc_get_var(ncid, varid1, &data_in)) ERR;
|
||||
if (data_in != TEST_VAL_42) ERR;
|
||||
if (nc_get_var(ncid, varid2, &data_in)) ERR;
|
||||
if (data_in != TEST_VAL_42 * 2) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
FINAL_RESULTS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user