diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2015-12-15 09:48:59 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2015-12-15 09:48:59 (GMT) |
commit | 4fe9d56f786f1f43e06655fa238ac7b11a194ba1 (patch) | |
tree | 7b1d0a0d729a2fe508efb0c46360d5204edec7b1 /tools/h5diff/h5diffgentest.c | |
parent | e9da1c3460abdb32496f9271edf2a2dbbaa4e72b (diff) | |
download | hdf5-4fe9d56f786f1f43e06655fa238ac7b11a194ba1.zip hdf5-4fe9d56f786f1f43e06655fa238ac7b11a194ba1.tar.gz hdf5-4fe9d56f786f1f43e06655fa238ac7b11a194ba1.tar.bz2 |
[svn-r28658] Manual merge of revise_chunks and alpha branch.
Tested on: Unbuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1
Autotools serial (C++ Fortran)
Autotools parallel (MPICH 3.1.4, Fortran)
CMake serial (CMake 3.3.2)
Diffstat (limited to 'tools/h5diff/h5diffgentest.c')
-rw-r--r-- | tools/h5diff/h5diffgentest.c | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index 8f92660..937bd32 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -62,6 +62,8 @@ hsize_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024); #define FILE18 "h5diff_ext2softlink_trg.h5" #define FILE19 "h5diff_dset_zero_dim_size1.h5" #define FILE20 "h5diff_dset_zero_dim_size2.h5" +#define FILE21 "h5diff_dset_idx1.h5" +#define FILE22 "h5diff_dset_idx2.h5" #define DANGLE_LINK_FILE1 "h5diff_danglelinks1.h5" #define DANGLE_LINK_FILE2 "h5diff_danglelinks2.h5" #define GRP_RECURSE_FILE1 "h5diff_grp_recurse1.h5" @@ -165,6 +167,7 @@ static void gen_datareg(hid_t fid,int make_diffs); /* utilities */ static int write_attr(hid_t loc_id,int rank,hsize_t *dims,const char *name,hid_t tid,void *buf); static int write_dset(hid_t loc_id,int rank,hsize_t *dims,const char *name,hid_t tid,void *buf); +static int gen_dataset_idx(const char *file, int format); /*------------------------------------------------------------------------- @@ -211,6 +214,15 @@ int main(void) test_special_datasets(FILE19,0); test_special_datasets(FILE20,1); + /* + * Generate 2 files: FILE21 with old format; FILE22 with new format + * Create 2 datasets in each file: + * One dataset: chunked layout, w/o filters, fixed dimension + * One dataset: chunked layout, w/ filters, fixed dimension + */ + gen_dataset_idx(FILE21, 0); + gen_dataset_idx(FILE22, 1); + test_dangle_links(DANGLE_LINK_FILE1, DANGLE_LINK_FILE2); test_group_recurse(GRP_RECURSE_FILE1, GRP_RECURSE_FILE2); @@ -2105,6 +2117,95 @@ out: } /*------------------------------------------------------------------------- +* Function: gen_dataset_idx +* +* Purpose: Create a file with either the new or old format +* Create two datasets in the file: +* one dataset: fixed dimension, chunked layout, w/o filters +* one dataset: fixed dimension, chunked layout, w/ filters +* +*------------------------------------------------------------------------- +*/ +static +int gen_dataset_idx(const char *file, int format) +{ + hid_t fid; /* file id */ + hid_t did, did2; /* dataset id */ + hid_t sid; /* space id */ + hid_t fapl; /* file access property id */ + hid_t dcpl; /* dataset creation property id */ + hsize_t dims[1] = {10}; /* dataset dimension */ + hsize_t c_dims[1] = {2}; /* chunk dimension */ + herr_t status; /* return status */ + int buf[10]; /* data buffer */ + int i; /* local index variable */ + + /* Get a copy of the file aaccess property */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + + /* Set the "use the latest format" bounds for creating objects in the file */ + if(format) { + status = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + assert(status >= 0); + } + + /* Create a file */ + if((fid = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + return -1; + + /* Create data */ + for(i = 0; i < 10; i++) + buf[i] = i; + + /* Set chunk */ + dcpl = H5Pcreate(H5P_DATASET_CREATE); + status = H5Pset_chunk(dcpl, 1, c_dims); + assert(status >= 0); + + /* Create a 1D dataset */ + sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + + /* Write to the dataset */ + status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + assert(status >= 0); + +#if defined (H5_HAVE_FILTER_DEFLATE) + /* set deflate data */ + status = H5Pset_deflate(dcpl, 9); + assert(status >= 0); + + /* Create and write the dataset */ + did2 = H5Dcreate2(fid, "dset_filter", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + status = H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + assert(status >= 0); + + /* Close the dataset */ + status = H5Dclose(did2); + assert(status >= 0); + +#endif + + /* closing: dataspace, dataset, file */ + status = H5Sclose(sid); + assert(status >= 0); + + status = H5Dclose(did); + assert(status >= 0); + + status = H5Fclose(fid); + assert(status >= 0); + + status = H5Pclose(dcpl); + assert(status >= 0); + + status = H5Pclose(fapl); + assert(status >= 0); + + return status; +} + +/*------------------------------------------------------------------------- * * Purpose: Create test files to compare dangling links in various way * |