diff --git a/HDF5Examples/C/H5FLT/CMakeLists.txt b/HDF5Examples/C/H5FLT/CMakeLists.txt index 1f1231f43c8..70bde1701f1 100644 --- a/HDF5Examples/C/H5FLT/CMakeLists.txt +++ b/HDF5Examples/C/H5FLT/CMakeLists.txt @@ -40,6 +40,14 @@ else () set (BITGROOM_AVAILABLE 0) endif () +option (ENABLE_BITROUND "Enable Library Building for bitround plugin" ON) +if (ENABLE_BITROUND) + set (BITROUND_AVAILABLE 1) + set (dyn_examples ${dyn_examples} h5ex_d_granularbr) +else () + set (BITROUND_AVAILABLE 0) +endif () + option (ENABLE_BSHUF "Enable Library Building for bshuf plugin" ON) if (ENABLE_BSHUF) if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") diff --git a/HDF5Examples/C/H5FLT/h5ex_d_bitgroom.c b/HDF5Examples/C/H5FLT/h5ex_d_bitgroom.c index 506049e8a10..64dd238ff46 100644 --- a/HDF5Examples/C/H5FLT/h5ex_d_bitgroom.c +++ b/HDF5Examples/C/H5FLT/h5ex_d_bitgroom.c @@ -1,29 +1,18 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of the HDF5 BitGroom filter plugin source. The full * - * copyright notice, including terms governing use, modification, and * - * terms governing use, modification, and redistribution, is contained in * - * the file COPYING, which can be found at the root of the BITGROOM source code * - * distribution tree. If you do not have access to this file, you may * - * request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /************************************************************ This example shows how to write data and read it from a dataset using BitGroom quantization. - The BitGroom filter is not available by default in HDF5. + The BitGroom filter is not available in HDF5. The example uses a new feature available in HDF5 version 1.8.11 to discover, load and register filters at run time. ************************************************************/ + #include "hdf5.h" #include #include -#define FILE "h5ex_d_bitgroom.h5" +#define FILENAME "h5ex_d_bitgroom.h5" #define DATASET "DS1" #define DIM0 32 #define DIM1 64 @@ -34,40 +23,39 @@ int main(void) { - hid_t file_id = -1; /* Handles */ - hid_t space_id = -1; /* Handles */ - hid_t dset_id = -1; /* Handles */ - hid_t dcpl_id = -1; /* Handles */ - herr_t status; - htri_t avail; - H5Z_filter_t filter_id = 0; - char filter_name[80]; - hsize_t dims[2] = {DIM0, DIM1}, chunk[2] = {CHUNK0, CHUNK1}; - size_t nelmts = 5; - /* number of elements in cd_values */ /* NB: Must equal H5Zbitgroom.c: CCR_FLT_PRM_NBR */ + hid_t file_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + herr_t status; + htri_t avail; + H5Z_filter_t filter_id = 0; + char filter_name[80]; + hsize_t dims[2] = {DIM0, DIM1}, chunk[2] = {CHUNK0, CHUNK1}; + size_t nelmts = 5; /* number of elements in cd_values */ unsigned int flags; unsigned filter_config; const unsigned int cd_values[5] = { 3, 4, 0, 0, 0}; /* BitGroom argument ordering is NSD,sizeof(data),has_mss_val,mss_val_byt_1to4[,mss_val_byt_5to8] */ unsigned int values_out[5] = {99, 99, 99, 99, 99}; - float wdata[DIM0][DIM1], /* Write buffer */ - rdata[DIM0][DIM1], /* Read buffer */ - max; - hsize_t i, j; - int ret_value = 1; + float wdata[DIM0][DIM1]; /* Write buffer */ + float rdata[DIM0][DIM1]; /* Read buffer */ + float max; + hsize_t i, j; + int ret_value = 1; /* * Initialize data. */ for (i = 0; i < DIM0; i++) for (j = 0; j < DIM1; j++) - wdata[i][j] = i * j - j; + wdata[i][j] = (float)(i * j) - (float)(j); /* * Create a new file using the default properties. */ - file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (file_id < 0) goto done; @@ -156,7 +144,7 @@ main(void) /* * Open file and dataset using the default properties. */ - file_id = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT); + file_id = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); if (file_id < 0) goto done; @@ -205,7 +193,7 @@ main(void) max = rdata[0][0]; for (i = 0; i < DIM0; i++) for (j = 0; j < DIM1; j++) { - /*printf("%d \n", rdata[i][j]); */ + /*printf("%f \n", rdata[i][j]); */ if (max < rdata[i][j]) max = rdata[i][j]; } diff --git a/HDF5Examples/C/H5FLT/h5ex_d_blosc.c b/HDF5Examples/C/H5FLT/h5ex_d_blosc.c index c8535ccdd9e..7cb1036679c 100644 --- a/HDF5Examples/C/H5FLT/h5ex_d_blosc.c +++ b/HDF5Examples/C/H5FLT/h5ex_d_blosc.c @@ -1,15 +1,3 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of the HDF5 BLOSC filter plugin source. The full * - * copyright notice, including terms governing use, modification, and * - * terms governing use, modification, and redistribution, is contained in * - * the file LICENSE, which can be found at the root of the BLOSC source code * - * distribution tree. If you do not have access to this file, you may * - * request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /************************************************************ This example shows how to write data and read it from a dataset @@ -35,10 +23,10 @@ int main(void) { - hid_t file_id = H5I_INVALID_HID; /* Handles */ - hid_t space_id = H5I_INVALID_HID; /* Handles */ - hid_t dset_id = H5I_INVALID_HID; /* Handles */ - hid_t dcpl_id = H5I_INVALID_HID; /* Handles */ + hid_t file_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; herr_t status; htri_t avail; H5Z_filter_t filter_id = 0; @@ -49,11 +37,11 @@ main(void) unsigned filter_config; const unsigned int cd_values[7] = {0, 0, 0, 0, 4, 1, 2}; /* blosc parameters */ unsigned int values_out[7] = {99, 99, 99, 99, 99, 99, 99}; - int wdata[DIM0][DIM1], /* Write buffer */ - rdata[DIM0][DIM1], /* Read buffer */ - max; - hsize_t i, j; - int ret_value = 1; + int wdata[DIM0][DIM1]; /* Write buffer */ + int rdata[DIM0][DIM1]; /* Read buffer */ + int max; + hsize_t i, j; + int ret_value = 1; /* * Initialize data. diff --git a/HDF5Examples/C/H5FLT/h5ex_d_blosc2.c b/HDF5Examples/C/H5FLT/h5ex_d_blosc2.c index 3f091fbd086..7451bbb244b 100644 --- a/HDF5Examples/C/H5FLT/h5ex_d_blosc2.c +++ b/HDF5Examples/C/H5FLT/h5ex_d_blosc2.c @@ -1,15 +1,3 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of the HDF5 BLOSC2 filter plugin source. The full * - * copyright notice, including terms governing use, modification, and * - * terms governing use, modification, and redistribution, is contained in * - * the file LICENSE, which can be found at the root of the BLOSC2 source code * - * distribution tree. If you do not have access to this file, you may * - * request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /************************************************************ This example shows how to write data and read it from a dataset @@ -35,10 +23,10 @@ int main(void) { - hid_t file_id = H5I_INVALID_HID; /* Handles */ - hid_t space_id = H5I_INVALID_HID; /* Handles */ - hid_t dset_id = H5I_INVALID_HID; /* Handles */ - hid_t dcpl_id = H5I_INVALID_HID; /* Handles */ + hid_t file_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; herr_t status; htri_t avail; H5Z_filter_t filter_id = 0; @@ -49,11 +37,11 @@ main(void) unsigned filter_config; const unsigned int cd_values[10] = {0, 0, 0, 0, 4, 1, 2, 2, 4, 8}; /* blosc parameters */ unsigned int values_out[10] = {99, 99, 99, 99, 99, 99, 99, 99, 99, 99}; - int wdata[DIM0][DIM1], /* Write buffer */ - rdata[DIM0][DIM1], /* Read buffer */ - max; - hsize_t i, j; - int ret_value = 1; + int wdata[DIM0][DIM1]; /* Write buffer */ + int rdata[DIM0][DIM1]; /* Read buffer */ + int max; + hsize_t i, j; + int ret_value = 1; /* * Initialize data. diff --git a/HDF5Examples/C/H5FLT/h5ex_d_bshuf.c b/HDF5Examples/C/H5FLT/h5ex_d_bshuf.c index 46a9d0277c0..7e6d944b82d 100644 --- a/HDF5Examples/C/H5FLT/h5ex_d_bshuf.c +++ b/HDF5Examples/C/H5FLT/h5ex_d_bshuf.c @@ -1,15 +1,3 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of the HDF5 BSHUF filter plugin source. The full * - * copyright notice, including terms governing use, modification, and * - * terms governing use, modification, and redistribution, is contained in * - * the file LICENSE, which can be found at the root of the BSHUF source code * - * distribution tree. If you do not have access to this file, you may * - * request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /************************************************************ This example shows how to write data and read it from a dataset @@ -35,10 +23,10 @@ int main(void) { - hid_t file_id = H5I_INVALID_HID; /* Handles */ - hid_t space_id = H5I_INVALID_HID; /* Handles */ - hid_t dset_id = H5I_INVALID_HID; /* Handles */ - hid_t dcpl_id = H5I_INVALID_HID; /* Handles */ + hid_t file_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; herr_t status; htri_t avail; H5Z_filter_t filter_id = 0; @@ -49,11 +37,11 @@ main(void) unsigned filter_config; const unsigned int cd_values[3] = {0, 0, 0}; unsigned int values_out[3] = {99, 99, 99}; - int wdata[DIM0][DIM1], /* Write buffer */ - rdata[DIM0][DIM1], /* Read buffer */ - max; - hsize_t i, j; - int ret_value = 1; + int wdata[DIM0][DIM1]; /* Write buffer */ + int rdata[DIM0][DIM1]; /* Read buffer */ + int max; + hsize_t i, j; + int ret_value = 1; /* * Initialize data. diff --git a/HDF5Examples/C/H5FLT/h5ex_d_bzip2.c b/HDF5Examples/C/H5FLT/h5ex_d_bzip2.c index 6ad52bcdd4a..71f3be027b0 100644 --- a/HDF5Examples/C/H5FLT/h5ex_d_bzip2.c +++ b/HDF5Examples/C/H5FLT/h5ex_d_bzip2.c @@ -1,15 +1,3 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of the HDF5 BZIP2 filter plugin source. The full * - * copyright notice, including terms governing use, modification, and * - * terms governing use, modification, and redistribution, is contained in * - * the file LICENSE, which can be found at the root of the BZIP2 source code * - * distribution tree. If you do not have access to this file, you may * - * request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /************************************************************ This example shows how to write data and read it from a dataset @@ -35,10 +23,10 @@ int main(void) { - hid_t file_id = H5I_INVALID_HID; /* Handles */ - hid_t space_id = H5I_INVALID_HID; /* Handles */ - hid_t dset_id = H5I_INVALID_HID; /* Handles */ - hid_t dcpl_id = H5I_INVALID_HID; /* Handles */ + hid_t file_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; herr_t status; htri_t avail; H5Z_filter_t filter_id = 0; @@ -49,11 +37,11 @@ main(void) unsigned filter_config; const unsigned int cd_values[1] = {2}; /* bzip2 default level is 2 */ unsigned int values_out[1] = {99}; - int wdata[DIM0][DIM1], /* Write buffer */ - rdata[DIM0][DIM1], /* Read buffer */ - max; - hsize_t i, j; - int ret_value = 1; + int wdata[DIM0][DIM1]; /* Write buffer */ + int rdata[DIM0][DIM1]; /* Read buffer */ + int max; + hsize_t i, j; + int ret_value = 1; /* * Initialize data. diff --git a/HDF5Examples/C/H5FLT/h5ex_d_mafisc.c b/HDF5Examples/C/H5FLT/h5ex_d_granularbr.c similarity index 54% rename from HDF5Examples/C/H5FLT/h5ex_d_mafisc.c rename to HDF5Examples/C/H5FLT/h5ex_d_granularbr.c index 22255d2bb28..7b433a08c0f 100644 --- a/HDF5Examples/C/H5FLT/h5ex_d_mafisc.c +++ b/HDF5Examples/C/H5FLT/h5ex_d_granularbr.c @@ -1,20 +1,8 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of the HDF5 MAFISC filter plugin source. The full * - * copyright notice, including terms governing use, modification, and * - * terms governing use, modification, and redistribution, is contained in * - * the file LICENSE, which can be found at the root of the MAFISC source code * - * distribution tree. If you do not have access to this file, you may * - * request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /************************************************************ This example shows how to write data and read it from a dataset - using mafisc compression. - mafisc filter is not available in HDF5. + using Granular BitRound quantization. + The Granular BitRound filter is not available in HDF5. The example uses a new feature available in HDF5 version 1.8.11 to discover, load and register filters at run time. @@ -24,36 +12,38 @@ #include #include -#define FILENAME "h5ex_d_mafisc.h5" -#define DATASET "DS1" -#define DIM0 32 -#define DIM1 64 -#define CHUNK0 4 -#define CHUNK1 8 -#define H5Z_FILTER_MAFISC 32002 +#define FILENAME "h5ex_d_granularbr.h5" +#define DATASET "DS1" +#define DIM0 32 +#define DIM1 64 +#define CHUNK0 4 +#define CHUNK1 8 +#define H5Z_FILTER_GRANULARBR 32023 int main(void) { - hid_t file_id = H5I_INVALID_HID; /* Handles */ - hid_t space_id = H5I_INVALID_HID; /* Handles */ - hid_t dset_id = H5I_INVALID_HID; /* Handles */ - hid_t dcpl_id = H5I_INVALID_HID; /* Handles */ + hid_t file_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; herr_t status; htri_t avail; H5Z_filter_t filter_id = 0; - char filter_name[128]; + char filter_name[80]; hsize_t dims[2] = {DIM0, DIM1}, chunk[2] = {CHUNK0, CHUNK1}; - size_t nelmts = 8; /* number of elements in cd_values */ + size_t nelmts = 5; /* number of elements in cd_values */ unsigned int flags; unsigned filter_config; - const unsigned int cd_values[8]; /* mafisc default is 6 + rank */ - unsigned int values_out[8] = {99, 99, 99, 99, 99, 99, 99, 99}; - int wdata[DIM0][DIM1], /* Write buffer */ - rdata[DIM0][DIM1], /* Read buffer */ - max; - hsize_t i, j; - int ret_value = 1; + const unsigned int cd_values[5] = { + 3, 4, 0, 0, 0}; /* Granular BitRound argument ordering is + NSD,sizeof(data),has_mss_val,mss_val_byt_1to4[,mss_val_byt_5to8] */ + unsigned int values_out[5] = {99, 99, 99, 99, 99}; + float wdata[DIM0][DIM1]; /* Write buffer */ + float rdata[DIM0][DIM1]; /* Read buffer */ + float max; + hsize_t i, j; + int ret_value = 1; /* * Initialize data. @@ -78,14 +68,16 @@ main(void) goto done; /* - * Create the dataset creation property list, add the gzip - * compression filter and set the chunk size. + * Create the dataset creation property list, add the Granular BitRound + * quantization filter and set the chunk size. */ dcpl_id = H5Pcreate(H5P_DATASET_CREATE); if (dcpl_id < 0) goto done; - status = H5Pset_filter(dcpl_id, H5Z_FILTER_MAFISC, H5Z_FLAG_MANDATORY, nelmts, cd_values); + /* 20200929: csz change this to H5Z_FLAG_OPTIONAL, so that can_apply() can reject filter for + integers without causing program to exit()? */ + status = H5Pset_filter(dcpl_id, H5Z_FILTER_GRANULARBR, H5Z_FLAG_MANDATORY, nelmts, cd_values); if (status < 0) goto done; @@ -93,12 +85,12 @@ main(void) * Check that filter is registered with the library now. * If it is registered, retrieve filter's configuration. */ - avail = H5Zfilter_avail(H5Z_FILTER_MAFISC); + avail = H5Zfilter_avail(H5Z_FILTER_GRANULARBR); if (avail) { - status = H5Zget_filter_info(H5Z_FILTER_MAFISC, &filter_config); + status = H5Zget_filter_info(H5Z_FILTER_GRANULARBR, &filter_config); if ((filter_config & H5Z_FILTER_CONFIG_ENCODE_ENABLED) && (filter_config & H5Z_FILTER_CONFIG_DECODE_ENABLED)) - printf("mafisc filter is available for encoding and decoding.\n"); + printf("Granular BitRound filter is available for quantization and decoding.\n"); } else { printf("H5Zfilter_avail - not found.\n"); @@ -112,7 +104,7 @@ main(void) * Create the dataset. */ printf("....Create dataset ................\n"); - dset_id = H5Dcreate(file_id, DATASET, H5T_STD_I32LE, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + dset_id = H5Dcreate(file_id, DATASET, H5T_IEEE_F32LE, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); if (dset_id < 0) { printf("failed to create dataset.\n"); goto done; @@ -121,8 +113,8 @@ main(void) /* * Write the data to the dataset. */ - printf("....Writing mafisc compressed data ................\n"); - status = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata[0]); + printf("....Writing Granular BitRound-quantized data ................\n"); + status = H5Dwrite(dset_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)wdata); if (status < 0) printf("failed to write data.\n"); @@ -167,27 +159,17 @@ main(void) goto done; /* - * Retrieve and print the filter id, compression level and filter's name for mafisc. + * Retrieve and print the filter id, quantization level and filter's name for Granular BitRound. */ - /* Format of the cd_values array: - cd_values[0] = version = 0; - cd_values[1] = datasetId (created randomly); - cd_values[2] = dataTypeSize (in bytes); - cd_values[3] = isFloat (true, if the datatype is a float type); - cd_values[4] = byteOrder (same as H5T_order_t); - cd_values[5] = rank (# of dimension of a chunk); - cd_values[6] = Size of first dimension (the size of the chunk!); - ... - cd_values[6+rank-1] = Size of last dimension; */ filter_id = H5Pget_filter2(dcpl_id, (unsigned)0, &flags, &nelmts, values_out, sizeof(filter_name), filter_name, NULL); printf("Filter info is available from the dataset creation property \n "); printf(" Filter identifier is "); switch (filter_id) { - case H5Z_FILTER_MAFISC: + case H5Z_FILTER_GRANULARBR: printf("%d\n", filter_id); - printf(" Number of parameters is %d with rank %u values %u %u\n", nelmts, values_out[5], - values_out[6], values_out[7]); + printf(" Number of parameters is %lu with the values %u, %u, %u, %u, %u\n", nelmts, + values_out[0], values_out[1], values_out[2], values_out[3], values_out[4]); printf(" To find more about the filter check %s\n", filter_name); break; default: @@ -198,8 +180,8 @@ main(void) /* * Read the data using the default properties. */ - printf("....Reading mafisc compressed data ................\n"); - status = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata[0]); + printf("....Reading Granular BitRound-quantized data ................\n"); + status = H5Dread(dset_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata[0]); if (status < 0) printf("failed to read data.\n"); @@ -217,13 +199,13 @@ main(void) /* * Print the maximum value. */ - printf("Maximum value in %s is %d\n", DATASET, max); + printf("Maximum value in %s is %g\n", DATASET, max); /* * Check that filter is registered with the library now. */ - avail = H5Zfilter_avail(H5Z_FILTER_MAFISC); + avail = H5Zfilter_avail(H5Z_FILTER_GRANULARBR); if (avail) - printf("mafisc filter is available now since H5Dread triggered loading of the filter.\n"); + printf("Granular BitRound filter is available now since H5Dread triggered loading of the filter.\n"); ret_value = 0; diff --git a/HDF5Examples/C/H5FLT/h5ex_d_jpeg.c b/HDF5Examples/C/H5FLT/h5ex_d_jpeg.c index 7c6c66023e7..07f43dae421 100644 --- a/HDF5Examples/C/H5FLT/h5ex_d_jpeg.c +++ b/HDF5Examples/C/H5FLT/h5ex_d_jpeg.c @@ -1,15 +1,3 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of the HDF5 JPEG filter plugin source. The full * - * copyright notice, including terms governing use, modification, and * - * terms governing use, modification, and redistribution, is contained in * - * the file LICENSE, which can be found at the root of the JPEG source code * - * distribution tree. If you do not have access to this file, you may * - * request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /************************************************************ This example shows how to write data and read it from a dataset @@ -38,10 +26,10 @@ int main(void) { - hid_t file_id = H5I_INVALID_HID; /* Handles */ - hid_t space_id = H5I_INVALID_HID; /* Handles */ - hid_t dset_id = H5I_INVALID_HID; /* Handles */ - hid_t dcpl_id = H5I_INVALID_HID; /* Handles */ + hid_t file_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; herr_t status; htri_t avail; H5Z_filter_t filter_id = 0; @@ -59,11 +47,11 @@ main(void) /* Color mode (0=Mono, 1=RGB) */ const unsigned int cd_values[4] = {JPEG_QUALITY, DIM1, DIM0, 0}; /* jpeg default level is 2 */ unsigned int values_out[4] = {99, 99, 99, 99}; - unsigned char *wdata, /* Write buffer */ - *rdata; /* Read buffer */ - int num_diff = 0; - hsize_t i; - int ret_value = 1; + unsigned char *wdata; /* Write buffer */ + unsigned char *rdata; /* Read buffer */ + int num_diff = 0; + hsize_t i; + int ret_value = 1; wdata = (unsigned char *)malloc(sizeof(unsigned char) * data_size); rdata = (unsigned char *)malloc(sizeof(unsigned char) * data_size); @@ -108,35 +96,33 @@ main(void) status = H5Zget_filter_info(H5Z_FILTER_JPEG, &filter_config); if ((filter_config & H5Z_FILTER_CONFIG_ENCODE_ENABLED) && (filter_config & H5Z_FILTER_CONFIG_DECODE_ENABLED)) - fprintf(stdout, "jpeg filter is available for encoding and decoding.\n"); + printf("jpeg filter is available for encoding and decoding.\n"); } else { - fprintf(stdout, "H5Zfilter_avail - not found.\n"); + printf("H5Zfilter_avail - not found.\n"); goto done; } status = H5Pset_chunk(dcpl_id, 3, chunk); if (status < 0) - fprintf(stdout, "failed to set chunk.\n"); + printf("failed to set chunk.\n"); /* * Create the dataset. */ - fprintf(stdout, "....Create dataset ................\n"); + printf("....Create dataset ................\n"); dset_id = H5Dcreate(file_id, DATASET, H5T_NATIVE_UINT8, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); if (dset_id < 0) { - fprintf(stdout, "failed to create dataset.\n"); + printf("failed to create dataset.\n"); goto done; } - fflush(stdout); /* * Write the data to the dataset. */ - fprintf(stdout, "....Writing jpeg compressed data ................\n"); + printf("....Writing jpeg compressed data ................\n"); status = H5Dwrite(dset_id, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); if (status < 0) - fprintf(stdout, "failed to write data.\n"); - fflush(stdout); + printf("failed to write data.\n"); /* * Close and release resources. @@ -151,11 +137,11 @@ main(void) file_id = -1; status = H5close(); if (status < 0) { - fprintf(stdout, "\nFAILED to close library\n"); + printf("\nFAILED to close library\n"); goto done; } - fprintf(stdout, "....Close the file and reopen for reading ........\n"); + printf("....Close the file and reopen for reading ........\n"); /* * Now we begin the read section of this example. */ @@ -183,28 +169,26 @@ main(void) */ filter_id = H5Pget_filter2(dcpl_id, (unsigned)0, &flags, &nelmts, values_out, sizeof(filter_name), filter_name, NULL); - fprintf(stdout, "Filter info is available from the dataset creation property \n "); - fprintf(stdout, " Filter identifier is "); + printf("Filter info is available from the dataset creation property \n "); + printf(" Filter identifier is "); switch (filter_id) { case H5Z_FILTER_JPEG: - fprintf(stdout, "%d\n", filter_id); - fprintf(stdout, " Number of parameters is %d with the value %u\n", nelmts, values_out[0]); - fprintf(stdout, " To find more about the filter check %s\n", filter_name); + printf("%d\n", filter_id); + printf(" Number of parameters is %d with the value %u\n", nelmts, values_out[0]); + printf(" To find more about the filter check %s\n", filter_name); break; default: - fprintf(stdout, "Not expected filter\n"); + printf("Not expected filter\n"); break; } - fflush(stdout); /* * Read the data using the default properties. */ - fprintf(stdout, "....Reading jpeg compressed data ................\n"); + printf("....Reading jpeg compressed data ................\n"); status = H5Dread(dset_id, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); if (status < 0) - fprintf(stdout, "failed to read data.\n"); - fflush(stdout); + printf("failed to read data.\n"); /* * Find the maximum value in the dataset, to verify that it was @@ -218,19 +202,18 @@ main(void) /* * Print the number of differences. */ - fprintf(stdout, "JPEG quality=%d, percent of differing array elements=%f\n", JPEG_QUALITY, - 100. * (double)num_diff / data_size); + printf("JPEG quality=%d, percent of differing array elements=%f\n", JPEG_QUALITY, + 100. * (double)num_diff / data_size); /* * Check that filter is registered with the library now. */ avail = H5Zfilter_avail(H5Z_FILTER_JPEG); if (avail) - fprintf(stdout, "jpeg filter is available now since H5Dread triggered loading of the filter.\n"); + printf("jpeg filter is available now since H5Dread triggered loading of the filter.\n"); ret_value = 0; done: - fflush(stdout); free(rdata); free(wdata); /* diff --git a/HDF5Examples/C/H5FLT/h5ex_d_lz4.c b/HDF5Examples/C/H5FLT/h5ex_d_lz4.c index e1cd5bb0bbb..8b5c80968ba 100644 --- a/HDF5Examples/C/H5FLT/h5ex_d_lz4.c +++ b/HDF5Examples/C/H5FLT/h5ex_d_lz4.c @@ -1,15 +1,3 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of the HDF5 LZ4 filter plugin source. The full * - * copyright notice, including terms governing use, modification, and * - * terms governing use, modification, and redistribution, is contained in * - * the file LICENSE, which can be found at the root of the LZ4 source code * - * distribution tree. If you do not have access to this file, you may * - * request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /************************************************************ This example shows how to write data and read it from a dataset @@ -35,10 +23,10 @@ int main(void) { - hid_t file_id = H5I_INVALID_HID; /* Handles */ - hid_t space_id = H5I_INVALID_HID; /* Handles */ - hid_t dset_id = H5I_INVALID_HID; /* Handles */ - hid_t dcpl_id = H5I_INVALID_HID; /* Handles */ + hid_t file_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; herr_t status; htri_t avail; H5Z_filter_t filter_id = 0; @@ -49,11 +37,11 @@ main(void) unsigned filter_config; const unsigned int cd_values[1] = {3}; /* lz4 default is 3 */ unsigned int values_out[1] = {99}; - int wdata[DIM0][DIM1], /* Write buffer */ - rdata[DIM0][DIM1], /* Read buffer */ - max; - hsize_t i, j; - int ret_value = 1; + int wdata[DIM0][DIM1]; /* Write buffer */ + int rdata[DIM0][DIM1]; /* Read buffer */ + int max; + hsize_t i, j; + int ret_value = 1; /* * Initialize data. diff --git a/HDF5Examples/C/H5FLT/h5ex_d_lzf.c b/HDF5Examples/C/H5FLT/h5ex_d_lzf.c index 41f5776494a..3a038fd594a 100644 --- a/HDF5Examples/C/H5FLT/h5ex_d_lzf.c +++ b/HDF5Examples/C/H5FLT/h5ex_d_lzf.c @@ -1,15 +1,3 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of the HDF5 LZF filter plugin source. The full * - * copyright notice, including terms governing use, modification, and * - * terms governing use, modification, and redistribution, is contained in * - * the file LICENSE, which can be found at the root of the LZF source code * - * distribution tree. If you do not have access to this file, you may * - * request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /************************************************************ This example shows how to write data and read it from a dataset @@ -35,10 +23,10 @@ int main(void) { - hid_t file_id = H5I_INVALID_HID; /* Handles */ - hid_t space_id = H5I_INVALID_HID; /* Handles */ - hid_t dset_id = H5I_INVALID_HID; /* Handles */ - hid_t dcpl_id = H5I_INVALID_HID; /* Handles */ + hid_t file_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; herr_t status; htri_t avail; H5Z_filter_t filter_id = 0; @@ -49,11 +37,11 @@ main(void) unsigned filter_config; const unsigned int cd_values[3] = {0, 0, 0}; unsigned int values_out[3] = {99, 99, 99}; - int wdata[DIM0][DIM1], /* Write buffer */ - rdata[DIM0][DIM1], /* Read buffer */ - max; - hsize_t i, j; - int ret_value = 1; + int wdata[DIM0][DIM1]; /* Write buffer */ + int rdata[DIM0][DIM1]; /* Read buffer */ + int max; + hsize_t i, j; + int ret_value = 1; /* * Initialize data. diff --git a/HDF5Examples/C/H5FLT/h5ex_d_zfp.c b/HDF5Examples/C/H5FLT/h5ex_d_zfp.c index f4bb6a97694..3ba29c50a57 100644 --- a/HDF5Examples/C/H5FLT/h5ex_d_zfp.c +++ b/HDF5Examples/C/H5FLT/h5ex_d_zfp.c @@ -1,15 +1,3 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of the HDF5 ZFP filter plugin source. The full * - * copyright notice, including terms governing use, modification, and * - * terms governing use, modification, and redistribution, is contained in * - * the file LICENSE, which can be found at the root of the ZFP source code * - * distribution tree. If you do not have access to this file, you may * - * request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /************************************************************ This example shows how to write data and read it from a dataset @@ -35,10 +23,10 @@ int main(void) { - hid_t file_id = H5I_INVALID_HID; /* Handles */ - hid_t space_id = H5I_INVALID_HID; /* Handles */ - hid_t dset_id = H5I_INVALID_HID; /* Handles */ - hid_t dcpl_id = H5I_INVALID_HID; /* Handles */ + hid_t file_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; herr_t status; htri_t avail; H5Z_filter_t filter_id = 0; @@ -49,11 +37,11 @@ main(void) unsigned filter_config; const unsigned int cd_values[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned int values_out[10] = {99, 99, 99, 99, 99, 99, 99, 99, 99, 99}; - float wdata[DIM0][DIM1], /* Write buffer */ - rdata[DIM0][DIM1]; /* Read buffer */ - float max; - hsize_t i, j; - int ret_value = 1; + float wdata[DIM0][DIM1]; /* Write buffer */ + float rdata[DIM0][DIM1]; /* Read buffer */ + float max; + hsize_t i, j; + int ret_value = 1; /* * Initialize data. diff --git a/HDF5Examples/C/H5FLT/h5ex_d_zstd.c b/HDF5Examples/C/H5FLT/h5ex_d_zstd.c index 183686fafa4..48f1d2f42bd 100644 --- a/HDF5Examples/C/H5FLT/h5ex_d_zstd.c +++ b/HDF5Examples/C/H5FLT/h5ex_d_zstd.c @@ -1,15 +1,3 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of the HDF5 ZSTD filter plugin source. The full * - * copyright notice, including terms governing use, modification, and * - * terms governing use, modification, and redistribution, is contained in * - * the file LICENSE, which can be found at the root of the ZSTD source code * - * distribution tree. If you do not have access to this file, you may * - * request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /************************************************************ This example shows how to write data and read it from a dataset @@ -37,10 +25,10 @@ int main(void) { - hid_t file_id = H5I_INVALID_HID; /* Handles */ - hid_t space_id = H5I_INVALID_HID; /* Handles */ - hid_t dset_id = H5I_INVALID_HID; /* Handles */ - hid_t dcpl_id = H5I_INVALID_HID; /* Handles */ + hid_t file_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; herr_t status; htri_t avail; H5Z_filter_t filter_id = 0; diff --git a/HDF5Examples/C/H5FLT/tfiles/h5ex_d_bitgroom.tst b/HDF5Examples/C/H5FLT/tfiles/h5ex_d_bitgroom.tst index bf368d5abdf..44b6b701270 100644 --- a/HDF5Examples/C/H5FLT/tfiles/h5ex_d_bitgroom.tst +++ b/HDF5Examples/C/H5FLT/tfiles/h5ex_d_bitgroom.tst @@ -2,7 +2,7 @@ BitGroom filter is available for quantization and decoding. ....Create dataset ................ ....Writing BitGroom-quantized data ................ ....Close the file and reopen for reading ........ -Filter info is available from the dataset creation property +Filter info is available from the dataset creation property Filter identifier is 32022 Number of parameters is 5 with the values 3, 4, 0, 0, 0 To find more about the filter check BitGroom filter (Zender, 2016 GMD: http://www.geosci-model-dev.net/9/3199/2016) diff --git a/HDF5Examples/C/H5FLT/tfiles/h5ex_d_granularbr.ddl b/HDF5Examples/C/H5FLT/tfiles/h5ex_d_granularbr.ddl new file mode 100644 index 00000000000..2e111e26f64 --- /dev/null +++ b/HDF5Examples/C/H5FLT/tfiles/h5ex_d_granularbr.ddl @@ -0,0 +1,26 @@ +HDF5 "h5ex_d_granularbr.h5" { +GROUP "/" { + DATASET "DS1" { + DATATYPE H5T_IEEE_F32LE + DATASPACE SIMPLE { ( 32, 64 ) / ( 32, 64 ) } + STORAGE_LAYOUT { + CHUNKED ( 4, 8 ) + SIZE 8192 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 32023 + COMMENT Granular BitRound filter + PARAMS { 3 4 0 0 0 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } +} +} diff --git a/HDF5Examples/C/H5FLT/tfiles/h5ex_d_granularbr.h5 b/HDF5Examples/C/H5FLT/tfiles/h5ex_d_granularbr.h5 new file mode 100644 index 00000000000..4082d082032 Binary files /dev/null and b/HDF5Examples/C/H5FLT/tfiles/h5ex_d_granularbr.h5 differ diff --git a/HDF5Examples/C/H5FLT/tfiles/h5ex_d_granularbr.tst b/HDF5Examples/C/H5FLT/tfiles/h5ex_d_granularbr.tst new file mode 100644 index 00000000000..d934eb1651c --- /dev/null +++ b/HDF5Examples/C/H5FLT/tfiles/h5ex_d_granularbr.tst @@ -0,0 +1,11 @@ +Granular BitRound filter is available for quantization and decoding. +....Create dataset ................ +....Writing Granular BitRound-quantized data ................ +....Close the file and reopen for reading ........ +Filter info is available from the dataset creation property + Filter identifier is 32023 + Number of parameters is 5 with the values 3, 4, 0, 0, 0 + To find more about the filter check Granular BitRound filter +....Reading Granular BitRound-quantized data ................ +Maximum value in DS1 is 1.84467e+19 +Granular BitRound filter is available now since H5Dread triggered loading of the filter. diff --git a/config/cmake/HDF5PluginCache.cmake b/config/cmake/HDF5PluginCache.cmake index a1089dcb089..4aedbbca509 100644 --- a/config/cmake/HDF5PluginCache.cmake +++ b/config/cmake/HDF5PluginCache.cmake @@ -24,6 +24,7 @@ endif () if (H5PL_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT") set (ENABLE_BITGROOM OFF CACHE BOOL "" FORCE) + set (ENABLE_BITROUND OFF CACHE BOOL "" FORCE) set (ENABLE_JPEG OFF CACHE BOOL "" FORCE) set (ENABLE_LZF OFF CACHE BOOL "" FORCE) endif ()