1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group.                                               *
3  * Copyright by the Board of Trustees of the University of Illinois.         *
4  * All rights reserved.                                                      *
5  *                                                                           *
6  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
7  * terms governing use, modification, and redistribution, is contained in    *
8  * the COPYING file, which can be found at the root of the source code       *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
10  * If you do not have access to either file, you may request a copy from     *
11  * help@hdfgroup.org.                                                        *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 #include "hdf5.h"
14 
15 /*-------------------------------------------------------------------------
16  * Function:    main
17  *
18  * Purpose:     Generates the noencoder.h5 file used to test SZIP without
19  *              an encoder present.
20  *
21  * Return:      Success:        zero
22  *
23  *              Failure:        non-zero
24  *
25  * Programmer:  James Laird and Nat Furrer
26  *              Thursday, July 1, 2004
27  *
28  * Modifications:
29  *
30  *-------------------------------------------------------------------------
31  */
32 int
main(void)33 main(void)
34 {
35     hid_t file_id;
36     hid_t dset_id;
37     hid_t dcpl_id;
38     hid_t space_id;
39     hsize_t dims, maxdims;
40     int fill = 0;
41     int write_buf[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
42 
43     file_id = H5Fcreate("noencoder.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
44 
45     dims = 10;
46     maxdims = H5S_UNLIMITED;
47     space_id = H5Screate_simple(1, &dims, &maxdims);
48 
49     dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
50     H5Pset_chunk(dcpl_id, 1, &dims);
51     H5Pset_szip(dcpl_id, H5_SZIP_NN_OPTION_MASK, 4);
52     H5Pset_fill_value(dcpl_id, H5T_NATIVE_INT, &fill);
53     H5Pset_fill_time(dcpl_id, H5D_FILL_TIME_ALLOC);
54 
55 /* Create dataset noencoder_szip_dset.h5 */
56     dset_id = H5Dcreate2(file_id, "noencoder_szip_dset.h5", H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
57 
58     H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf);
59 
60     H5Pclose(dcpl_id);
61     H5Dclose(dset_id);
62 
63     dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
64     H5Pset_chunk(dcpl_id, 1, &dims);
65     H5Pset_szip(dcpl_id, H5_SZIP_NN_OPTION_MASK, 4);
66     H5Pset_shuffle(dcpl_id);
67     H5Pset_fletcher32(dcpl_id);
68     H5Pset_fill_value(dcpl_id, H5T_NATIVE_INT, &fill);
69     H5Pset_fill_time(dcpl_id, H5D_FILL_TIME_ALLOC);
70 
71 /* Create dataset noencoder_szip_shuffle_fletcher_dset.h5 */
72     dset_id = H5Dcreate2(file_id, "noencoder_szip_shuffle_fletcher_dset.h5", H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
73 
74     H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf);
75 
76     H5Pclose(dcpl_id);
77     H5Dclose(dset_id);
78     H5Sclose(space_id);
79     H5Fclose(file_id);
80 
81     return(0);
82 }
83 
84