diff options
author | Jonathan Kim <jkm@hdfgroup.org> | 2010-09-15 19:00:44 (GMT) |
---|---|---|
committer | Jonathan Kim <jkm@hdfgroup.org> | 2010-09-15 19:00:44 (GMT) |
commit | f4af8527642179df0d8b380ae27fecd73c463dfa (patch) | |
tree | 4cf90e44fa1f0fb2241204457f4a1e65d73a26ed /tools/h5repack/h5repacktst.c | |
parent | 6ef5b395eab45a61ff944d7d9214dca32730b826 (diff) | |
download | hdf5-f4af8527642179df0d8b380ae27fecd73c463dfa.zip hdf5-f4af8527642179df0d8b380ae27fecd73c463dfa.tar.gz hdf5-f4af8527642179df0d8b380ae27fecd73c463dfa.tar.bz2 |
[svn-r19391] Purpose:
Fix for Bug1896 h5repack - changing layout to COMPACT does not work
Description:
Merged from hdf5 trunk (r19389)
Make h5repack be able to convert a layout to COMPACT for small size dataset as default. Also add verifying layout changes in our test script.
Tested:
jam, amani
Diffstat (limited to 'tools/h5repack/h5repacktst.c')
-rw-r--r-- | tools/h5repack/h5repacktst.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index 57fb1ce..8eddeca 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -76,6 +76,9 @@ #define FNAME17 "h5repack_named_dtypes.h5" #define FNAME17OUT "h5repack_named_dtypes_out.h5" +#define FNAME18 "h5repack_layout2.h5" +#define FNAME18OUT "h5repack_layout2_out.h5" + #define FNAME_UB "ublock.bin" /* obj and region references */ @@ -117,6 +120,7 @@ static int make_attributes(hid_t loc_id); static int make_hlinks(hid_t loc_id); static int make_early(void); static int make_layout(hid_t loc_id); +static int make_layout2(hid_t loc_id); #ifdef H5_HAVE_FILTER_SZIP static int make_szip(hid_t loc_id); #endif /* H5_HAVE_FILTER_SZIP */ @@ -1630,6 +1634,19 @@ int make_testfiles(void) return -1; /*------------------------------------------------------------------------- + * create a file for layout conversion test + *------------------------------------------------------------------------- + */ + if((fid = H5Fcreate(FNAME18, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + return -1; + + if(make_layout2(fid) < 0) + goto out; + + if(H5Fclose(fid) < 0) + return -1; + + /*------------------------------------------------------------------------- * create a file for the H5D_ALLOC_TIME_EARLY test *------------------------------------------------------------------------- */ @@ -2910,6 +2927,78 @@ out: } /*------------------------------------------------------------------------- + * Function: make_layout2 + * + * Purpose: create datasets with contiguous and chunked layouts: + * + * contig_small: < 1k, fixed dims datspace + * chunked_small_fixed: < 1k, fixed dims dataspace + * + *------------------------------------------------------------------------- + */ +#define S_DIM1 4 +#define S_DIM2 10 +#define CONTIG_S "contig_small" +#define CHUNKED_S_FIX "chunked_small_fixed" + +static +int make_layout2(hid_t loc_id) +{ + + hid_t contig_dcpl = -1; /* dataset creation property list */ + hid_t chunked_dcpl = -1; /* dataset creation property list */ + + int i, j, n; /* Local index variables */ + int ret_value = -1; /* Return value */ + hid_t s_sid = -1; /* dataspace ID */ + + hsize_t s_dims[RANK] = {S_DIM1,S_DIM2}; /* Dataspace (< 1 k) */ + hsize_t chunk_dims[RANK] = {S_DIM1/2, S_DIM2/2}; /* Dimension sizes for chunks */ + + int s_buf[S_DIM1][S_DIM2]; /* Temporary buffer */ + + for(i = n = 0; i < S_DIM1; i++) { + for (j = 0; j < S_DIM2; j++) { + s_buf[i][j] = n++; + } + } + + /* Create dataspaces */ + if((s_sid = H5Screate_simple(RANK, s_dims, NULL)) < 0) + goto out; + + /* Create contiguous datasets */ + if((contig_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto out; + if(H5Pset_layout(contig_dcpl, H5D_CONTIGUOUS) < 0) + goto out; + if(make_dset(loc_id, CONTIG_S, s_sid, contig_dcpl, s_buf) < 0) + goto out; + + /* Create chunked datasets */ + if((chunked_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto out; + if(H5Pset_chunk(chunked_dcpl, RANK, chunk_dims) < 0) + goto out; + if(make_dset(loc_id, CHUNKED_S_FIX, s_sid, chunked_dcpl, s_buf) < 0) + goto out; + + ret_value = 0; + +out: + H5E_BEGIN_TRY { + H5Pclose(contig_dcpl); + H5Pclose(chunked_dcpl); + + H5Sclose(s_sid); + + } H5E_END_TRY; + + return(ret_value); + +} /* make_layout2() */ + +/*------------------------------------------------------------------------- * Function: make a file with an integer dataset with a fill value * * Purpose: test copy of fill values |