File: read_ui8_test.c

package info (click to toggle)
hdf5-filter-plugin 0.0~git20221111.49e3b65-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,848 kB
  • sloc: ansic: 14,374; sh: 11,445; cpp: 1,463; makefile: 100; python: 19; xml: 6
file content (30 lines) | stat: -rw-r--r-- 627 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <hdf5.h>
#include <stdlib.h>

#define NX 3
#define NY 4
#define NZ 5
static const char *fname="bslz4_3x4x5_testdata.h5";


int main()
{
    hid_t fid = H5Fopen(fname,H5F_ACC_RDONLY,H5P_DEFAULT);
    if(fid<0) return 1;

    hid_t dset = H5Dopen(fid,"/data_uint8",H5P_DEFAULT);
    if(dset<0) return 1;
    
    uint8_t data[NX*NY*NZ];
    hid_t mem_type = H5Tcopy(H5T_NATIVE_UINT8);
    if(H5Dread(dset,mem_type,H5S_ALL,H5S_ALL,H5P_DEFAULT,(void*)(data))<0)
        return 1;
    
    size_t index;
    for(index=0;index<NX*NY*NZ;index++)
    {
        if(data[index]!=(uint8_t)index) return 1;
    }

    return 0;
}