-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.c
82 lines (79 loc) · 3.01 KB
/
main.c
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <stdlib.h>
#include <assert.h>
#include "z5wrapper.h"
int main() {
size_t shape[] = {20, 20, 20};
size_t count[] = {10, 10, 10};
size_t start[] = {0, 0, 0};
size_t start2[] = {10, 10, 10};
float data1[10][10][10];
float data2[10][10][10];
float rdata[10][10][10];
long long int idata1[10][10][10];
long long int idata2[10][10][10];
long long int irdata[10][10][10];
unsigned int ndim = 3;
for (int i = 0; i < count[0]; i++){
for (int j = 0; j < count[1]; j++){
for (int k = 0; k<count[2]; k++){
data1[i][j][k]=rand()%1000+1;
idata1[i][j][k]=rand()%1000+1;
}
}
}
for (int i = 0; i < count[0]; i++){
for (int j = 0; j < count[1]; j++){
for (int k = 0; k<count[2]; k++){
data2[i][j][k]=rand()%1000+1;
idata2[i][j][k]=rand()%1000+1;
}
}
}
char* arrayName = "test_c.z5";
int cusezlib = 1;
int level = 1;
z5CreateFloat32Dataset(arrayName, ndim, shape, count, cusezlib, level);
z5WriteFloat32Subarray(arrayName, data1, ndim, count, start);
z5ReadFloat32Subarray(arrayName, rdata, ndim, count, start);
for (int i = 0; i < count[0]; i++){
for (int j = 0; j < count[1]; j++)
for (int k = 0; k<count[2]; k++)
assert(data1[i][j][k] == rdata[i][j][k]);
printf("data1 = %f\n",data1[i][0][0]);
}
z5WriteFloat32Subarray("test_c.z5", data2, ndim, count, start2);
z5ReadFloat32Subarray("test_c.z5", rdata, ndim, count, start2);
printf("after read float\n");
for (int i = 0; i < count[0]; i++){
for (int j = 0; j < count[1]; j++)
for (int k = 0; k<count[2]; k++)
assert(data2[i][j][k] == rdata[i][j][k]);
printf("data2 = %f\n",data2[i][0][0]);
}
printf("after assert\n");
char* iarrayName = "test_c_int64.z5";
z5CreateInt64Dataset(iarrayName, ndim, shape, count, cusezlib, level);
z5WriteInt64Subarray(iarrayName, idata1, ndim, count, start);
z5ReadInt64Subarray(iarrayName, irdata, ndim, count, start);
for (int i = 0; i < count[0]; i++){
for (int j = 0; j < count[1]; j++)
for (int k = 0; k<count[2]; k++)
assert(idata1[i][j][k] == irdata[i][j][k]);
printf("idata1 = %lu\n",idata1[i][0][0]);
}
z5WriteInt64Subarray(iarrayName, idata2, ndim, count, start2);
z5ReadInt64Subarray(iarrayName, irdata, ndim, count, start2);
printf("after read float\n");
for (int i = 0; i < count[0]; i++){
for (int j = 0; j < count[1]; j++)
for (int k = 0; k<count[2]; k++)
assert(idata2[i][j][k] == irdata[i][j][k]);
printf("idata2 = %lu\n",idata2[i][0][0]);
}
printf("after assert\n");
size_t countize0=z5GetFileSize("test_c_int64.z5/0.0.0");
size_t countize1=z5GetFileSize("test_c_int64.z5/1.1.1");
printf("size = %lu, %lu\n",countize0,countize1);
z5Delete("test_c_int64.z5");
return 0;
}