File: gen_mergemsg.c

package info (click to toggle)
hdf5 1.10.0-patch1+docs-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 143,572 kB
  • ctags: 38,562
  • sloc: ansic: 472,614; f90: 28,734; java: 27,116; xml: 17,791; sh: 16,757; cpp: 14,937; makefile: 1,769; perl: 1,339; yacc: 338; lex: 184; ruby: 24
file content (332 lines) | stat: -rw-r--r-- 8,394 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the files COPYING and Copyright.html.  COPYING can be found at the root   *
 * of the source code distribution tree; Copyright.html can be found at the  *
 * root level of an installed copy of the electronic HDF5 document set and   *
 * is linked from the top-level documents page.  It can also be found at     *
 * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
 * access to either file, you may request a copy from help@hdfgroup.org.     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
 * Programmer:  Quincey Koziol <koziol@ncsa.uiuc.edu>
 *              Friday, June 30, 2006
 *
 *  This program creates an object with fragmented object header messages
 *  that will be merged when the object is read from the file.  This program
 *  needs to be compiled against the 1.6.5 or earlier version of the library
 *  in order to generate the file as desired.
 */

#include <assert.h>
#include <stdio.h>
#include "hdf5.h"

#define FILENAME        "mergemsg.h5"
#define GROUP1          "grp1"
#define GROUP2          "grp2"
#define GROUP3          "grp3"
#define ATTR1           "__111111111111__"
#define ATTR1_LEN       11
#define ATTR2           "__222222222__"
#define ATTR2_LEN       11
#define ATTR3           "__333333333__"
#define ATTR3_LEN       1

int main()
{
    hid_t fid;          /* File ID */
    hid_t gid, gid2, gid3;      /* Group IDs */
    hid_t aid;          /* Attribute ID */
    hid_t sid;          /* Dataspace ID */
    hid_t tid;          /* Datatype ID */
    herr_t ret;         /* Generic return value */

    /* Create file */
    fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    assert(fid > 0);

    /* Create first group */
    gid = H5Gcreate2(fid, GROUP1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    assert(gid > 0);

    /* Close first group */
    ret = H5Gclose(gid);
    assert(ret >= 0);

    /* Create second group */
    gid2 = H5Gcreate2(fid, GROUP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    assert(gid2 > 0);

    /* Close second group */
    ret = H5Gclose(gid2);
    assert(ret >= 0);

    /* Close file */
    ret = H5Fclose(fid);
    assert(ret >= 0);


    /* Re-open file */
    fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
    assert(fid > 0);

    /* Re-open first group */
    gid = H5Gopen2(fid, GROUP1, H5P_DEFAULT);
    assert(gid > 0);

    /* Create dataspace for attribute */
    sid = H5Screate(H5S_SCALAR);
    assert(sid > 0);

    /* Create dataype for attribute */
    tid = H5Tcopy(H5T_C_S1);
    assert(tid > 0);
    ret = H5Tset_size(tid, ATTR1_LEN);
    assert(ret >= 0);

    /* Add 1st attribute on first group */
    aid = H5Acreate2(gid, ATTR1, tid, sid, H5P_DEFAULT, H5P_DEFAULT);
    assert(aid > 0);

    /* Close dataspace */
    ret = H5Sclose(sid);
    assert(ret >= 0);

    /* Close datatype */
    ret = H5Tclose(tid);
    assert(ret >= 0);

    /* Close attribute */
    ret = H5Aclose(aid);
    assert(ret >= 0);

    /* Create dataspace for 2nd attribute */
    sid = H5Screate(H5S_SCALAR);
    assert(sid > 0);

    /* Create dataype for attribute */
    tid = H5Tcopy(H5T_C_S1);
    assert(tid > 0);
    ret = H5Tset_size(tid, ATTR2_LEN);
    assert(ret >= 0);

    /* Add 2nd attribute on first group */
    aid = H5Acreate2(gid, ATTR2, tid, sid, H5P_DEFAULT, H5P_DEFAULT);
    assert(aid > 0);

    /* Close dataspace */
    ret = H5Sclose(sid);
    assert(ret >= 0);

    /* Close datatype */
    ret = H5Tclose(tid);
    assert(ret >= 0);

    /* Close 2nd attribute */
    ret = H5Aclose(aid);
    assert(ret >= 0);

    /* Close first group */
    ret = H5Gclose(gid);
    assert(ret >= 0);

    /* Close file */
    ret = H5Fclose(fid);
    assert(ret >= 0);


    /* Re-open file */
    fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
    assert(fid > 0);

    /* Create third group */
    gid3 = H5Gcreate2(fid, GROUP3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    assert(gid3 > 0);

    /* Close third group */
    ret = H5Gclose(gid3);
    assert(ret >= 0);

    /* Re-open first group */
    gid = H5Gopen2(fid, GROUP1, H5P_DEFAULT);
    assert(gid > 0);

    /* Delete 2nd attribute */
    ret = H5Adelete(gid, ATTR2);
    assert(ret >= 0);

    /* Close first group */
    ret = H5Gclose(gid);
    assert(ret >= 0);

    /* Close file */
    ret = H5Fclose(fid);
    assert(ret >= 0);




    /* Re-open file */
    fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
    assert(fid > 0);

    /* Re-open first group */
    gid = H5Gopen2(fid, GROUP1, H5P_DEFAULT);
    assert(gid > 0);

    /* Create dataspace for 3rd attribute */
    sid = H5Screate(H5S_SCALAR);
    assert(sid > 0);

    /* Create dataype for attribute */
    tid = H5Tcopy(H5T_C_S1);
    assert(tid > 0);
    ret = H5Tset_size(tid, ATTR3_LEN);
    assert(ret >= 0);

    /* Add 3rd attribute on first group (smaller than 2nd attribute) */
    aid = H5Acreate2(gid, ATTR3, tid, sid, H5P_DEFAULT, H5P_DEFAULT);
    assert(aid > 0);

    /* Close dataspace */
    ret = H5Sclose(sid);
    assert(ret >= 0);

    /* Close datatype */
    ret = H5Tclose(tid);
    assert(ret >= 0);

    /* Close 3rd attribute */
    ret = H5Aclose(aid);
    assert(ret >= 0);

    /* Close first group */
    ret = H5Gclose(gid);
    assert(ret >= 0);

    /* Close file */
    ret = H5Fclose(fid);
    assert(ret >= 0);



    /* Re-open file */
    fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
    assert(fid > 0);

    /* Re-open first group */
    gid = H5Gopen2(fid, GROUP1, H5P_DEFAULT);
    assert(gid > 0);

    /* Delete 3rd attribute */
    ret = H5Adelete(gid, ATTR3);
    assert(ret >= 0);

    /* Create dataspace for 3rd attribute */
    sid = H5Screate(H5S_SCALAR);
    assert(sid > 0);

    /* Create dataype for attribute */
    tid = H5Tcopy(H5T_C_S1);
    assert(tid > 0);
    ret = H5Tset_size(tid, ATTR2_LEN);
    assert(ret >= 0);

    /* Re-create 2nd attribute on first group */
    aid = H5Acreate2(gid, ATTR2, tid, sid, H5P_DEFAULT, H5P_DEFAULT);
    assert(aid > 0);

    /* Close dataspace */
    ret = H5Sclose(sid);
    assert(ret >= 0);

    /* Close datatype */
    ret = H5Tclose(tid);
    assert(ret >= 0);

    /* Close 2nd attribute */
    ret = H5Aclose(aid);
    assert(ret >= 0);

    /* Close first group */
    ret = H5Gclose(gid);
    assert(ret >= 0);

    /* Close file */
    ret = H5Fclose(fid);
    assert(ret >= 0);


    /* Re-open file */
    fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
    assert(fid > 0);

    /* Re-open first group */
    gid = H5Gopen2(fid, GROUP1, H5P_DEFAULT);
    assert(gid > 0);

    /* Delete 2nd attribute */
    ret = H5Adelete(gid, ATTR2);
    assert(ret >= 0);

    /* Close first group */
    ret = H5Gclose(gid);
    assert(ret >= 0);

    /* Close file */
    ret = H5Fclose(fid);
    assert(ret >= 0);


    /* Re-open file */
    fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
    assert(fid > 0);

    /* Re-open first group */
    gid = H5Gopen2(fid, GROUP1, H5P_DEFAULT);
    assert(gid > 0);

    /* Create dataspace for 3rd attribute */
    sid = H5Screate(H5S_SCALAR);
    assert(sid > 0);

    /* Create dataype for attribute */
    tid = H5Tcopy(H5T_C_S1);
    assert(tid > 0);
    ret = H5Tset_size(tid, ATTR2_LEN);
    assert(ret >= 0);

    /* Re-create 2nd attribute on first group */
    aid = H5Acreate2(gid, ATTR2, tid, sid, H5P_DEFAULT, H5P_DEFAULT);
    assert(aid > 0);

    /* Close dataspace */
    ret = H5Sclose(sid);
    assert(ret >= 0);

    /* Close datatype */
    ret = H5Tclose(tid);
    assert(ret >= 0);

    /* Close 2nd attribute */
    ret = H5Aclose(aid);
    assert(ret >= 0);

    /* Close first group */
    ret = H5Gclose(gid);
    assert(ret >= 0);

    /* Close file */
    ret = H5Fclose(fid);
    assert(ret >= 0);

    return(0);
}