summaryrefslogtreecommitdiffstats
path: root/tools/h5repack/testh5repack_make.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5repack/testh5repack_make.c')
-rw-r--r--tools/h5repack/testh5repack_make.c136
1 files changed, 136 insertions, 0 deletions
diff --git a/tools/h5repack/testh5repack_make.c b/tools/h5repack/testh5repack_make.c
index 65a1c4a..4245bec 100644
--- a/tools/h5repack/testh5repack_make.c
+++ b/tools/h5repack/testh5repack_make.c
@@ -33,6 +33,7 @@ int make_szip(hid_t loc_id);
int make_deflate(hid_t loc_id);
int make_shuffle(hid_t loc_id);
int make_fletcher32(hid_t loc_id);
+int make_nbit(hid_t loc_id);
int make_all(hid_t loc_id);
int make_fill(hid_t loc_id);
@@ -158,6 +159,15 @@ int make_testfiles(void)
return -1;
/*-------------------------------------------------------------------------
+ * create a file with the nbit filter
+ *-------------------------------------------------------------------------
+ */
+ if((loc_id = H5Fcreate(FNAME12,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
+ return -1;
+ if (make_nbit(loc_id)<0)
+ goto out;
+
+/*-------------------------------------------------------------------------
* create a file with the all filters
*-------------------------------------------------------------------------
*/
@@ -622,6 +632,106 @@ out:
}
+/*-------------------------------------------------------------------------
+ * Function: make_nbit
+ *
+ * Purpose: make a dataset with the nbit filter
+ *
+ *-------------------------------------------------------------------------
+ */
+int make_nbit(hid_t loc_id)
+{
+ hid_t dcpl; /* dataset creation property list */
+ hid_t sid; /* dataspace ID */
+ hid_t dtid;
+ hid_t dsid;
+ hsize_t dims[RANK]={DIM1,DIM2};
+ hsize_t chunk_dims[RANK]={CDIM1,CDIM2};
+ int buf[DIM1][DIM2];
+ int i, j, n;
+
+ for (i=n=0; i<DIM1; i++){
+ for (j=0; j<DIM2; j++){
+ buf[i][j]=n++;
+ }
+ }
+ /* create a space */
+ if((sid = H5Screate_simple(RANK, dims, NULL))<0)
+ return -1;
+ /* create a dataset creation property list; the same DCPL is used for all dsets */
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0)
+ goto out;
+ /* set up chunk */
+ if(H5Pset_chunk(dcpl, RANK, chunk_dims)<0)
+ goto out;
+
+ dtid = H5Tcopy(H5T_NATIVE_INT);
+ if (H5Tset_precision(dtid,(H5Tget_precision(dtid) - 1)) < 0)
+ {
+ H5Tclose(dtid);
+ goto out;
+ }
+
+#if defined (H5_HAVE_FILTER_NBIT)
+ /* remove the filters from the dcpl */
+ if (H5Premove_filter(dcpl,H5Z_FILTER_ALL)<0)
+ {
+ H5Tclose(dtid);
+ goto out;
+ }
+ if (H5Pset_nbit(dcpl)<0)
+ {
+ H5Tclose(dtid);
+ goto out;
+ }
+ if((dsid = H5Dcreate (loc_id,"dset_nbit",dtid,sid,dcpl))<0)
+ {
+ H5Tclose(dtid);
+ goto out;
+ }
+ if(H5Dwrite(dsid,dtid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
+ {
+ H5Tclose(dtid);
+ goto out;
+ }
+ H5Dclose(dsid);
+
+ if (H5Premove_filter(dcpl,H5Z_FILTER_ALL)<0)
+ {
+ H5Tclose(dtid);
+ goto out;
+ }
+ if((dsid = H5Dcreate (loc_id,"dset_int31",dtid,sid,dcpl))<0)
+ {
+ H5Tclose(dtid);
+ goto out;
+ }
+ if(H5Dwrite(dsid,dtid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
+ {
+ H5Tclose(dtid);
+ goto out;
+ }
+ H5Dclose(dsid);
+#endif
+
+/*-------------------------------------------------------------------------
+ * close space and dcpl
+ *-------------------------------------------------------------------------
+ */
+ if(H5Sclose(sid)<0)
+ goto out;
+ if(H5Pclose(dcpl)<0)
+ goto out;
+
+ return 0;
+
+out:
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl);
+ H5Sclose(sid);
+ } H5E_END_TRY;
+ return -1;
+}
/*-------------------------------------------------------------------------
@@ -635,6 +745,8 @@ int make_all(hid_t loc_id)
{
hid_t dcpl; /* dataset creation property list */
hid_t sid; /* dataspace ID */
+ hid_t dtid;
+ hid_t dsid;
#if defined (H5_HAVE_FILTER_SZIP)
unsigned szip_options_mask=H5_SZIP_ALLOW_K13_OPTION_MASK|H5_SZIP_NN_OPTION_MASK;
unsigned szip_pixels_per_block=8;
@@ -762,6 +874,30 @@ if (szip_can_encode) {
#endif
+/*-------------------------------------------------------------------------
+ * nbit
+ *-------------------------------------------------------------------------
+ */
+#if defined (H5_HAVE_FILTER_NBIT)
+ /* remove the filters from the dcpl */
+ if (H5Premove_filter(dcpl,H5Z_FILTER_ALL)<0)
+ goto out;
+ /* set the shuffle filter */
+ if (H5Pset_nbit(dcpl)<0)
+ goto out;
+ dtid = H5Tcopy(H5T_NATIVE_INT);
+ H5Tset_precision(dtid,(H5Tget_precision(dtid)-1));
+ if((dsid = H5Dcreate (loc_id,"dset_nbit",dtid,sid,dcpl))<0)
+ goto out;
+ if(H5Dwrite(dsid,dtid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
+ goto out;
+
+ /* close */
+ if(H5Tclose(dtid)<0)
+ return -1;
+ if(H5Dclose(dsid)<0)
+ return -1;
+#endif
/*-------------------------------------------------------------------------
* close space and dcpl