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
14 /*
15 * Generate the binary hdf5 files for the h5format_convert tests.
16 * Usage: just execute the program without any arguments will
17 * generate all the binary hdf5 files
18 *
19 * If you regenerate the test files (e.g., changing some code,
20 * trying it on a new platform, ...), you need to verify the correctness
21 * of the expected output and update the corresponding *.ddl files.
22 */
23
24 #include "hdf5.h"
25 #include "H5private.h"
26
27 #define NON_V3_FILE "h5fc_non_v3.h5"
28 #define EDGE_V3_FILE "h5fc_edge_v3.h5"
29 #define ERR_LEVEL_FILE "h5fc_err_level.h5"
30
31 const char *FILENAME[] = {
32 "h5fc_ext1_i.h5", /* 0 */
33 "h5fc_ext1_s.h5", /* 1 */
34 "h5fc_ext1_f.h5", /* 2 */
35 "h5fc_ext2_is.h5", /* 3 */
36 "h5fc_ext2_if.h5", /* 4 */
37 "h5fc_ext2_sf.h5", /* 5 */
38 "h5fc_ext3_isf.h5", /* 6 */
39 "h5fc_ext_none.h5", /* 7 */
40 NULL
41 };
42
43 #define GROUP "GROUP"
44
45 #define DSET_COMPACT "DSET_COMPACT"
46 #define DSET_CONTIGUOUS "DSET_CONTIGUOUS"
47
48 #define DSET_EA "DSET_EA"
49 #define DSET_NDATA_EA "DSET_NDATA_EA"
50 #define DSET_BT2 "DSET_BT2"
51 #define DSET_NDATA_BT2 "DSET_NDATA_BT2"
52 #define DSET_FA "DSET_FA"
53 #define DSET_NDATA_FA "DSET_NDATA_FA"
54 #define DSET_NONE "DSET_NONE"
55 #define DSET_NDATA_NONE "DSET_NDATA_NONE"
56
57 #define DSET_EDGE "DSET_EDGE"
58 #define DSET_ERR "DSET_ERR"
59
60 #define ISTORE_IK 64
61 #define ISTORE_ERR 1
62
63 #define NUM 500
64
65
66 /*
67 * Function: gen_non()
68 *
69 * Create a file with SWMR write+non-latest-format--this will result in v3 superbock+latest version support:
70 * 1) 1 chunked dataset with extensible array chunk indexing type (without data)
71 * 2) 1 chunked dataset with version 2 B-tree chunk indexing type (with data)
72 * Re-open the file with write+non-latest-format and create:
73 * 3) 1 chunked dataset with version 2 B-tree chunk indexing type (without data)
74 * 4) 1 chunked dataset with extensible array indexing type (with data)
75 * 5) 1 compact and 1 contiguous datasets
76 */
77 static void
gen_non(const char * fname)78 gen_non(const char *fname)
79 {
80 hid_t fid = -1; /* file id */
81 hid_t fcpl = -1; /* file creation property list */
82 hid_t gid = -1; /* group id */
83 hid_t sid = -1; /* space id */
84 hid_t dcpl = -1; /* dataset creation property id */
85 hid_t did1 = -1, did2 = -1; /* dataset id */
86 hsize_t dims1[1] = {10}; /* dataset dimension */
87 hsize_t dims2[2] = {4, 6}; /* dataset dimension */
88 hsize_t max_dims[2]; /* maximum dataset dimension */
89 hsize_t c_dims[2] = {2, 3}; /* chunk dimension */
90 int i; /* local index variable */
91 int buf[24]; /* data buffer */
92
93 if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
94 goto error;
95 if(H5Pset_shared_mesg_nindexes(fcpl, 4) < 0)
96 goto error;
97 if(H5Pset_istore_k(fcpl, 64) < 0)
98 goto error;
99
100 /* Create an empty file with latest-format */
101 if((fid = H5Fcreate(fname, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, fcpl, H5P_DEFAULT)) < 0)
102 goto error;
103
104 /* Create a group */
105 if((gid = H5Gcreate2(fid, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
106 goto error;
107
108 /* Create data */
109 for(i = 0; i < 24; i++)
110 buf[i] = i;
111
112 /* Set chunk */
113 if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
114 goto error;
115 if(H5Pset_chunk(dcpl, 2, c_dims) < 0)
116 goto error;
117
118 /*
119 * Create a chunked dataset with extensible array chunk indexing type (without data)
120 */
121
122 /* Create dataspace */
123 max_dims[0] = 10;
124 max_dims[1] = H5S_UNLIMITED;
125 if((sid = H5Screate_simple(2, dims2, max_dims)) < 0)
126 goto error;
127
128 /* Create the dataset */
129 if((did1 = H5Dcreate2(fid, DSET_NDATA_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
130 goto error;
131
132 /* Closing */
133 if(H5Sclose(sid) < 0)
134 goto error;
135 if(H5Dclose(did1) < 0)
136 goto error;
137
138 /*
139 * Create a chunked dataset with version 2 B-tree chunk indexing type (with data)
140 */
141
142 /* Create dataspace */
143 max_dims[0] = 10;
144 max_dims[0] = H5S_UNLIMITED;
145 max_dims[1] = H5S_UNLIMITED;
146 if((sid = H5Screate_simple(2, dims2, max_dims)) < 0)
147 goto error;
148
149 /* Create the dataset */
150 if((did1 = H5Dcreate2(gid, DSET_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
151 goto error;
152
153 /* Write to the dataset */
154 if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
155 goto error;
156
157 /* Closing */
158 if(H5Sclose(sid) < 0)
159 goto error;
160 if(H5Dclose(did1) < 0)
161 goto error;
162 if(H5Pclose(dcpl) < 0)
163 goto error;
164 if(H5Gclose(gid) < 0)
165 goto error;
166 if(H5Fclose(fid) < 0)
167 goto error;
168
169 /* Re-open the file with old format */
170 if((fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
171 goto error;
172
173 /* Open the group */
174 if((gid = H5Gopen2(fid, GROUP, H5P_DEFAULT)) < 0)
175 goto error;
176
177 /*
178 * Create a dataset with version 2 B-btree chunk indexing type (without data)
179 */
180
181 /* Set chunk */
182 if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
183 goto error;
184 if(H5Pset_chunk(dcpl, 2, c_dims) < 0)
185 goto error;
186
187 /* Create dataspace */
188 max_dims[0] = H5S_UNLIMITED;
189 max_dims[1] = H5S_UNLIMITED;
190 if((sid = H5Screate_simple(2, dims2, max_dims)) < 0)
191 goto error;
192
193 /* Create the dataset */
194 if((did1 = H5Dcreate2(fid, DSET_NDATA_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
195 goto error;
196
197 /* Close the dataspace */
198 if(H5Sclose(sid) < 0)
199 goto error;
200
201 /*
202 * Create a dataset with extensible array chunk indexing type (with data) in the group
203 */
204
205 /* Create dataspace */
206 max_dims[0] = 10;
207 max_dims[1] = H5S_UNLIMITED;
208 if((sid = H5Screate_simple(2, dims2, max_dims)) < 0)
209 goto error;
210
211 /* Create the dataset */
212 if((did2 = H5Dcreate2(gid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
213 goto error;
214
215 /* Write to the dataset */
216 if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
217 goto error;
218
219 /* Closing */
220 if(H5Sclose(sid) < 0)
221 goto error;
222 if(H5Pclose(dcpl) < 0)
223 goto error;
224 if(H5Dclose(did1) < 0)
225 goto error;
226 if(H5Dclose(did2) < 0)
227 goto error;
228
229 /*
230 * Create a compact dataset in the group
231 */
232
233 /* Create dataspace */
234 if((sid = H5Screate_simple(1, dims1, NULL)) < 0)
235 goto error;
236
237 if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
238 goto error;
239 if(H5Pset_layout(dcpl, H5D_COMPACT) < 0)
240 goto error;
241
242 /* Create the dataset */
243 if((did1 = H5Dcreate2(gid, DSET_COMPACT, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
244 goto error;
245
246 /* Closing */
247 if(H5Dclose(did1) < 0)
248 goto error;
249 if(H5Pclose(dcpl) < 0)
250 goto error;
251 if(H5Sclose(sid) < 0)
252 goto error;
253
254 /*
255 * Create a contiguous dataset with (2d with data) in the file
256 */
257 if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
258 goto error;
259 if(H5Pset_layout(dcpl, H5D_CONTIGUOUS) < 0)
260 goto error;
261
262 if((sid = H5Screate_simple(2, dims2, NULL)) < 0)
263 goto error;
264
265 /* Create the dataset */
266 if((did2 = H5Dcreate2(fid, DSET_CONTIGUOUS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
267 goto error;
268 /* Write to the dataset */
269 if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
270 goto error;
271
272 /* Closing */
273 if(H5Dclose(did2) < 0)
274 goto error;
275 if(H5Pclose(dcpl) < 0)
276 goto error;
277 if(H5Sclose(sid) < 0)
278 goto error;
279
280 if(H5Gclose(gid) < 0)
281 goto error;
282 if(H5Pclose(fcpl) < 0)
283 goto error;
284 if(H5Fclose(fid) < 0)
285 goto error;
286
287 error:
288 H5E_BEGIN_TRY {
289 H5Pclose(dcpl);
290 H5Sclose(sid);
291 H5Dclose(did1);
292 H5Dclose(did2);
293 H5Gclose(gid);
294 H5Fclose(fcpl);
295 H5Fclose(fid);
296 } H5E_END_TRY;
297
298 } /* gen_non() */
299
300 /*
301 * Function: gen_edge()
302 *
303 * Create a file with write+latest-format--this will result in v3 superblock+latest version support:
304 * A dataset: chunked, filtered, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS enabled
305 * (i.e. the dataset does not filter partial edge chunks)
306 */
307 static void
gen_edge(const char * fname)308 gen_edge(const char *fname)
309 {
310 hid_t fid = -1; /* file id */
311 hid_t fapl = -1; /* file access property list */
312 hid_t sid = -1; /* dataspace id */
313 hid_t dcpl = -1; /* dataset creation property id */
314 hid_t did = -1; /* dataset id */
315 hsize_t dims2[2] = {12, 6}; /* Dataset dimensions */
316 hsize_t c_dims[2] = {5, 5}; /* Chunk dimensions */
317 float buf[12][6]; /* Buffer for writing data */
318 int i, j; /* local index variable */
319
320 /* Create a new format file */
321 if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
322 goto error;
323 if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
324 goto error;
325 if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
326 goto error;
327
328 /* Set chunk, filter, no-filter-edge-chunk */
329 if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
330 goto error;
331 if(H5Pset_chunk(dcpl, 2, c_dims) < 0)
332 goto error;
333 if(H5Pset_deflate(dcpl, 9) < 0)
334 goto error;
335 if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0)
336 goto error;
337
338 /* Create dataspace */
339 if((sid = H5Screate_simple(2, dims2, NULL)) < 0)
340 goto error;
341
342 /* Create the dataset */
343 if((did = H5Dcreate2(fid, DSET_EDGE, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
344 goto error;
345
346 /* Create data */
347 for (i = 0; i< 12; i++)
348 for (j = 0; j< 6; j++)
349 buf[i][j] = 100.0F;
350
351 /* Write to the dataset */
352 if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
353 goto error;
354
355 /* Closing */
356 if(H5Pclose(dcpl) < 0)
357 goto error;
358 if(H5Sclose(sid) < 0)
359 goto error;
360 if(H5Dclose(did) < 0)
361 goto error;
362 if(H5Pclose(fapl) < 0)
363 goto error;
364 if(H5Fclose(fid) < 0)
365 goto error;
366
367 error:
368 H5E_BEGIN_TRY {
369 H5Pclose(dcpl);
370 H5Sclose(sid);
371 H5Dclose(did);
372 H5Fclose(fid);
373 H5Pclose(fapl);
374 } H5E_END_TRY;
375
376 } /* gen_edge() */
377
378
379 /*
380 * Function: gen_err_level()
381 *
382 * Generate a file to test the situtation described in HDFFV-9434:
383 * Exceed the limit of v1-btree level
384 *
385 * Create a file with H5Pset_istore_k(fcpl, 1).
386 * Create a chunked dataset with extensible array chunk index and
387 * appends many chunks to the dataset.
388 *
389 * When h5format_convert tries to convert the dataset with
390 * extensive array index in the file to v1-btree chunk index,
391 * it will insert the dataset chunks to the v1-btree chunk index.
392 * The tree will split quickly due to the 'K' value of 1 and the
393 * tree level will eventually hit the maximum: 2^8(256).
394 */
395 static void
gen_err_level(const char * fname)396 gen_err_level(const char *fname)
397 {
398 hid_t fid = -1; /* file ID */
399 hid_t fapl = -1; /* file access property list */
400 hid_t fcpl = -1; /* file creation property list */
401 hid_t sid = -1; /* dataspace id */
402 hid_t dcpl = -1; /* dataset creation property list */
403 hid_t did = -1; /* dataset ID */
404 hid_t fsid = -1; /* file dataspace ID */
405 hid_t msid = -1; /* memory dataspace ID */
406 unsigned char *buf = NULL; /* buffer for data */
407 hsize_t dims[2] = {0, 1}; /* dataset dimension sizes */
408 hsize_t max_dims[2] = {1, H5S_UNLIMITED}; /* dataset maximum dimension sizes */
409 hsize_t chunk_dims[2] = {1, 1}; /* chunk dimension sizes */
410 int n = 0; /* local index variable */
411
412 /* Create a new format file */
413 if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
414 goto error;
415 if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
416 goto error;
417
418 /* Set 'K' value to 1 in file creation property list */
419 if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
420 goto error;
421 if(H5Pset_istore_k(fcpl, ISTORE_ERR) < 0)
422 goto error;
423
424 /* Initialize data buffer */
425 buf = (unsigned char *)HDmalloc(NUM * sizeof(unsigned char *));
426 HDmemset(buf, 42, NUM * sizeof(unsigned char));
427
428 /* Create the test file */
429 if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
430 goto error;
431
432 /* Create a chunked dataset with extensible array chunk index */
433 if((sid = H5Screate_simple(2, dims, max_dims)) < 0)
434 goto error;
435 if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
436 goto error;
437 if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
438 goto error;
439 if((did = H5Dcreate2(fid, DSET_ERR, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
440 goto error;
441
442 /* Closing */
443 if(H5Pclose(fcpl) < 0)
444 goto error;
445 if(H5Pclose(dcpl) < 0)
446 goto error;
447 if(H5Sclose(sid) < 0)
448 goto error;
449 if(H5Dclose(did) < 0)
450 goto error;
451 if(H5Fclose(fid) < 0)
452 goto error;
453
454 /* Re-open the file */
455 if((fid = H5Fopen(fname, H5F_ACC_RDWR, fapl)) < 0)
456 goto error;
457
458 /* Open the dataset */
459 if((did = H5Dopen2(fid, DSET_ERR, H5P_DEFAULT)) < 0)
460 goto error;
461
462 /* Loop through appending 1 element at a time */
463 for(n = 0; n < NUM; n++) {
464 hsize_t start[2] = {0, 0};
465 hsize_t count[2] = {1, 1};
466 hsize_t extent[2] = {0, 0};
467
468 start[0] = 0;
469 start[1] = (hsize_t)n;
470 extent[0] = 1;
471 extent[1] = (hsize_t)(n + 1);
472
473 /* Set current dimension sizes for the dataset */
474 if(H5Dset_extent(did, extent) < 0)
475 goto error;
476
477 /* Set up memory dataspace */
478 if((msid = H5Screate_simple(2, count, NULL)) < 0)
479 goto error;
480
481 /* Get file dataspace */
482 if((fsid = H5Dget_space(did)) < 0)
483 goto error;
484
485 if((H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, count, NULL)) < 0)
486 goto error;
487
488 /* Write to the dataset */
489 if(H5Dwrite(did, H5T_NATIVE_UCHAR, msid, fsid, H5P_DEFAULT, buf) < 0)
490 goto error;
491
492 if(H5Sclose(fsid) < 0)
493 goto error;
494 if(H5Sclose(msid) < 0)
495 goto error;
496 }
497
498 /* Closing */
499 if(H5Dclose(did) < 0)
500 goto error;
501 if(H5Fclose(fid) < 0)
502 goto error;
503 if(H5Pclose(fapl) < 0)
504 goto error;
505
506 error:
507 if(buf)
508 free(buf);
509 H5E_BEGIN_TRY {
510 H5Pclose(dcpl);
511 H5Sclose(sid);
512 H5Dclose(did);
513 H5Sclose(msid);
514 H5Sclose(fsid);
515 H5Fclose(fid);
516 H5Pclose(fapl);
517 H5Pclose(fcpl);
518 } H5E_END_TRY;
519
520 } /* gen_err_level() */
521
522 /*
523 * Function: gen_ext()
524 *
525 * Create a file with/without latest format with:
526 * 1) 1 contiguous dataset (without data)
527 * 2) 2 chunked datasets with extensible array chunk indexing type (with/without data)
528 * 3) 2 chunked datasets with version 2 B-tree chunk indexing type (with/without data)
529 * 4) 2 chunked datasets with fixed array chunk indexing type (with/without data)
530 * 5) 2 chunked datasets with implicit array chunk indexing type (with/without data)
531 * It will create the file with/without messages in the superblock extension depending
532 * on the parameter "what".
533 */
534 static void
gen_ext(const char * fname,unsigned new_format,unsigned what)535 gen_ext(const char *fname, unsigned new_format, unsigned what)
536 {
537 hid_t fid = -1; /* file id */
538 hid_t fapl = -1; /* file access property list */
539 hid_t fcpl = -1; /* file creation property list */
540 hid_t gid = -1; /* group id */
541 hid_t sid = -1; /* space id */
542 hid_t dcpl = -1; /* dataset creation property id */
543 hid_t did1 = -1, did2 = -1; /* dataset id */
544 hsize_t dims1[1] = {10}; /* dataset dimension */
545 hsize_t dims2[2] = {4, 6}; /* dataset dimension */
546 hsize_t max_dims[2]; /* maximum dataset dimension */
547 hsize_t c_dims[2] = {2, 3}; /* chunk dimension */
548 int i; /* local index variable */
549 int buf[24]; /* data buffer */
550
551 if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
552 goto error;
553
554 if(new_format) {
555 /* Create a new format file */
556 if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
557 goto error;
558 } /* end if */
559
560 /* Create a file creation property list */
561 fcpl = H5Pcreate(H5P_FILE_CREATE);
562
563 /* Generate messages that might be placed in superblock extension */
564 switch(what) {
565 case 0:
566 H5Pset_istore_k(fcpl, ISTORE_IK);
567 break;
568 case 1:
569 H5Pset_shared_mesg_nindexes(fcpl, 4);
570 break;
571 case 2:
572 H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1);
573 break;
574 case 3:
575 H5Pset_istore_k(fcpl, ISTORE_IK);
576 H5Pset_shared_mesg_nindexes(fcpl, 4);
577 break;
578 case 4:
579 H5Pset_istore_k(fcpl, ISTORE_IK);
580 H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1);
581 break;
582 case 5:
583 H5Pset_shared_mesg_nindexes(fcpl, 4);
584 H5Pset_file_space_page_size(fcpl, (hsize_t)512);
585 break;
586 case 6:
587 H5Pset_istore_k(fcpl, ISTORE_IK);
588 H5Pset_shared_mesg_nindexes(fcpl, 4);
589 H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1);
590 break;
591 default:
592 break;
593 }
594
595 /* Create the file */
596 if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
597 goto error;
598
599 /* Create a group */
600 if((gid = H5Gcreate2(fid, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
601 goto error;
602
603 /* Set chunk */
604 if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
605 goto error;
606 if(H5Pset_chunk(dcpl, 2, c_dims) < 0)
607 goto error;
608
609
610 /*
611 * Create a contiguous dataset
612 */
613
614 /* Create dataspace */
615 if((sid = H5Screate_simple(1, dims1, NULL)) < 0)
616 goto error;
617
618 /* Create the dataset */
619 if((did1 = H5Dcreate2(fid, DSET_CONTIGUOUS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
620 goto error;
621
622 /* Closing */
623 if(H5Sclose(sid) < 0)
624 goto error;
625 if(H5Dclose(did1) < 0)
626 goto error;
627
628 /*
629 * Create 2 chunked datasets with extensible array chunk indexing type
630 * (one with data; one without data)
631 */
632
633 /* Create dataspace */
634 max_dims[0] = 10;
635 max_dims[1] = H5S_UNLIMITED;
636 if((sid = H5Screate_simple(2, dims2, max_dims)) < 0)
637 goto error;
638
639 /* Create the 2 datasets */
640 if((did1 = H5Dcreate2(gid, DSET_NDATA_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
641 goto error;
642
643 if((did2 = H5Dcreate2(fid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
644 goto error;
645
646 /* Create data */
647 for(i = 0; i < 24; i++)
648 buf[i] = i;
649
650 /* Write to one dataset */
651 if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
652 goto error;
653
654 /* Closing */
655 if(H5Sclose(sid) < 0)
656 goto error;
657 if(H5Dclose(did1) < 0)
658 goto error;
659 if(H5Dclose(did2) < 0)
660 goto error;
661
662
663 /*
664 * Create 2 chunked datasets with version 2 B-tree chunk indexing type
665 * (one with data; one without data)
666 */
667
668 /* Create dataspace */
669 max_dims[0] = 10;
670 max_dims[0] = H5S_UNLIMITED;
671 max_dims[1] = H5S_UNLIMITED;
672 if((sid = H5Screate_simple(2, dims2, max_dims)) < 0)
673 goto error;
674
675 /* Create the 2 datasets */
676 if((did1 = H5Dcreate2(fid, DSET_NDATA_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
677 goto error;
678
679 if((did2 = H5Dcreate2(gid, DSET_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
680 goto error;
681
682 /* Write to one dataset */
683 if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
684 goto error;
685
686 /* Closing */
687 if(H5Sclose(sid) < 0)
688 goto error;
689 if(H5Dclose(did1) < 0)
690 goto error;
691 if(H5Dclose(did2) < 0)
692 goto error;
693
694 /*
695 * Create 2 chunked datasets with fixed array chunk indexing type
696 * (one with data; one without data)
697 */
698
699 /* Create dataspace */
700 max_dims[0] = 20;
701 max_dims[1] = 10;
702 if((sid = H5Screate_simple(2, dims2, max_dims)) < 0)
703 goto error;
704
705 /* Create the datasets */
706 if((did1 = H5Dcreate2(fid, DSET_FA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
707 goto error;
708
709 if((did2 = H5Dcreate2(gid, DSET_NDATA_FA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
710 goto error;
711
712 /* Write to the dataset */
713 if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
714 goto error;
715
716 /* Closing */
717 if(H5Sclose(sid) < 0)
718 goto error;
719 if(H5Dclose(did1) < 0)
720 goto error;
721 if(H5Dclose(did2) < 0)
722 goto error;
723
724
725 /*
726 * Create 2 chunked datasets with implicit chunk indexing type
727 * (one with data; one without data)
728 */
729
730 /* Create dataspace */
731 if((sid = H5Screate_simple(2, dims2, NULL)) < 0)
732 goto error;
733
734 /* Set early allocation */
735 if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0)
736 goto error;
737
738 /* Create the 2 datasets */
739 if((did1 = H5Dcreate2(fid, DSET_NONE, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
740 goto error;
741
742 if((did2 = H5Dcreate2(gid, DSET_NDATA_NONE, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
743 goto error;
744
745 /* Write to one dataset */
746 if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
747 goto error;
748
749 /* Closing */
750 if(H5Dclose(did1) < 0)
751 goto error;
752 if(H5Dclose(did2) < 0)
753 goto error;
754 if(H5Sclose(sid) < 0)
755 goto error;
756
757 if(H5Pclose(dcpl) < 0)
758 goto error;
759 if(H5Gclose(gid) < 0)
760 goto error;
761 if(H5Fclose(fid) < 0)
762 goto error;
763
764 error:
765 H5E_BEGIN_TRY {
766 H5Pclose(dcpl);
767 H5Sclose(sid);
768 H5Dclose(did1);
769 H5Dclose(did2);
770 H5Gclose(gid);
771 H5Fclose(fid);
772 H5Pclose(fapl);
773 H5Pclose(fcpl);
774 } H5E_END_TRY;
775
776 } /* end gen_ext() */
777
778 int
main(void)779 main(void)
780 {
781 unsigned i, new_format;
782
783 /* Generate a non-latest-format file with v3 superblock */
784 gen_non(NON_V3_FILE);
785
786 /* Generate a new format file with a no-filter-edge-chunk dataset */
787 gen_edge(EDGE_V3_FILE);
788
789 /* Generate a new format file with 'K' value of 1 in H5Pset_istore_k() */
790 gen_err_level(ERR_LEVEL_FILE);
791
792 /* Generate old/new format file with/without messages in the superblock extension */
793 for(new_format = FALSE; new_format <= TRUE; new_format++) {
794 for(i = 0; i < 8; i++) {
795 char filename[50];
796
797 HDmemset(filename, 0, sizeof(filename));
798 if(!new_format)
799 HDstrcat(filename, "old_");
800 HDstrcat(filename, FILENAME[i]);
801
802 gen_ext(filename, new_format, i);
803 } /* end for */
804 } /* end for */
805
806 return 0;
807 } /* end main */
808
809