/************************************************************ This example shows how to read and write data to a dataset using the shuffle filter with gzip compression. The program first checks if the shuffle and gzip filters are available, then if they are it writes integers to a dataset using shuffle+gzip, then closes the file. Next, it reopens the file, reads back the data, and outputs the types of filters and the maximum value in the dataset to the screen. This file is intended for use with HDF5 Library version 1.8 ************************************************************/ #include "hdf5.h" #include #include #define FILE "h5ex_d_shuffle.h5" #define DATASET "DS1" #define DIM0 32 #define DIM1 64 #define CHUNK0 4 #define CHUNK1 8 int main (void) { hid_t file, space, dset, dcpl; /* Handles */ herr_t status; htri_t avail; H5Z_filter_t filter_type; hsize_t dims[2] = {DIM0, DIM1}, chunk[2] = {CHUNK0, CHUNK1}; size_t nelmts; unsigned int flags, filter_info; int wdata[DIM0][DIM1], /* Write buffer */ rdata[DIM0][DIM1], /* Read buffer */ max, nfilters, i, j; /* * Check if gzip compression is available and can be used for both * compression and decompression. Normally we do not perform error * checking in these examples for the sake of clarity, but in this * case we will make an exception because this filter is an * optional part of the hdf5 library. */ avail = H5Zfilter_avail(H5Z_FILTER_DEFLATE); if (!avail) { printf ("gzip filter not available.\n"); return 1; } status = H5Zget_filter_info (H5Z_FILTER_DEFLATE, &filter_info); if ( !(filter_info & H5Z_FILTER_CONFIG_ENCODE_ENABLED) || !(filter_info & H5Z_FILTER_CONFIG_DECODE_ENABLED) ) { printf ("gzip filter not available for encoding and decoding.\n"); return 1; } /* * Similarly, check for availability of the shuffle filter. */ avail = H5Zfilter_avail(H5Z_FILTER_SHUFFLE); if (!avail) { printf ("Shuffle filter not available.\n"); return 1; } status = H5Zget_filter_info (H5Z_FILTER_SHUFFLE, &filter_info); if ( !(filter_info & H5Z_FILTER_CONFIG_ENCODE_ENABLED) || !(filter_info & H5Z_FILTER_CONFIG_DECODE_ENABLED) ) { printf ("Shuffle filter not available for encoding and decoding.\n"); return 1; } /* * Initialize data. */ for (i=0; i