summaryrefslogtreecommitdiffstats
path: root/tools/h5repack/h5repacktst.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2009-04-02 20:17:10 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2009-04-02 20:17:10 (GMT)
commit443e2e355acda5d49168108e89cc5468b49dd183 (patch)
treed562c05d64995cf3b87ac43ff76cc895789d19a9 /tools/h5repack/h5repacktst.c
parent38cf2e201dc4e950d71da3219fc5c5bca0bae8c2 (diff)
downloadhdf5-443e2e355acda5d49168108e89cc5468b49dd183.zip
hdf5-443e2e355acda5d49168108e89cc5468b49dd183.tar.gz
hdf5-443e2e355acda5d49168108e89cc5468b49dd183.tar.bz2
[svn-r16656] #1402 (B1) h5repack does not preserve creation order indexing.
ISSUE : h5repack does not handle group creation order flags. ACTION: call H5P(g)(s)et_link_creation_order functions when handling groups, add new groups with these flags to the test generation program, and verify results in the test program. TEST: in the test program, function that compares property lists, added code to verify groups tested: windows, linux, solaris
Diffstat (limited to 'tools/h5repack/h5repacktst.c')
-rw-r--r--tools/h5repack/h5repacktst.c3191
1 files changed, 1773 insertions, 1418 deletions
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c
index c6afce1..27a30b4 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -1,17 +1,17 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+* 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. *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5repack.h"
#include "h5test.h"
@@ -76,7 +76,7 @@
const char *H5REPACK_FILENAMES[] = {
- "h5repack_big_out",
+ "h5repack_big_out",
NULL
};
@@ -98,9 +98,9 @@ int d_status = EXIT_SUCCESS;
#define USERBLOCK_SIZE 2048
/*-------------------------------------------------------------------------
- * prototypes
- *-------------------------------------------------------------------------
- */
+* prototypes
+*-------------------------------------------------------------------------
+*/
int make_all_objects(hid_t loc_id);
int make_attributes(hid_t loc_id);
int make_hlinks(hid_t loc_id);
@@ -118,12 +118,12 @@ int make_all(hid_t loc_id);
int make_fill(hid_t loc_id);
int make_big(hid_t loc_id);
int make_testfiles(void);
-void write_dset_in(hid_t loc_id,const char* dset_name,hid_t file_id,int make_diffs );
-void write_attr_in(hid_t loc_id,const char* dset_name,hid_t fid,int make_diffs );
-int write_dset(hid_t loc_id,int rank,hsize_t *dims,const char *dset_name,hid_t type_id,void *buf );
+int write_dset_in(hid_t loc_id,const char* dset_name,hid_t file_id,int make_diffs );
+int write_attr_in(hid_t loc_id,const char* dset_name,hid_t fid,int make_diffs );
+int write_dset(hid_t loc_id,int rank,hsize_t *dims,const char *dset_name,hid_t tid,void *buf );
int make_dset(hid_t loc_id,const char *name,hid_t sid,hid_t dcpl,void *buf);
-int make_attr(hid_t loc_id,int rank,hsize_t *dims,const char *attr_name,hid_t type_id,void *buf);
-void make_dset_reg_ref(hid_t loc_id);
+int make_attr(hid_t loc_id,int rank,hsize_t *dims,const char *attr_name,hid_t tid,void *buf);
+int make_dset_reg_ref(hid_t loc_id);
int make_external(hid_t loc_id);
static int make_userblock(void);
static int verify_userblock( const char* filename);
@@ -131,18 +131,18 @@ static int make_userblock_file(void);
/*-------------------------------------------------------------------------
- * Function: main
- *
- * Purpose: Executes h5repack tests
- *
- * Return: Success: zero
- * Failure: 1
- *
- * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
- * January, 6, 2004
- *
- *-------------------------------------------------------------------------
- */
+* Function: main
+*
+* Purpose: Executes h5repack tests
+*
+* Return: Success: zero
+* Failure: 1
+*
+* Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu>
+* January, 6, 2004
+*
+*-------------------------------------------------------------------------
+*/
int main (void)
{
@@ -151,20 +151,20 @@ int main (void)
#if defined (H5_HAVE_FILTER_SZIP)
int szip_can_encode = 0;
#endif
-
+
/* initialize */
memset(&diff_options, 0, sizeof (diff_opt_t));
memset(&pack_options, 0, sizeof (pack_opt_t));
-
+
/* run tests */
puts("Testing h5repack:");
-
+
/* make the test files */
TESTING(" generating datasets");
if (make_testfiles() < 0)
GOERROR;
PASSED();
-
+
/*-------------------------------------------------------------------------
* Format of the tests:
*
@@ -177,7 +177,7 @@ int main (void)
* file with fill values
*-------------------------------------------------------------------------
*/
-
+
TESTING(" copy of datasets (fill values)");
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -187,7 +187,7 @@ int main (void)
GOERROR;
if (h5repack_verify(FNAME0OUT,&pack_options)<=0)
GOERROR;
- if (h5repack_cmpdcpl(FNAME0,FNAME0OUT)<=0)
+ if (h5repack_cmp_pl(FNAME0,FNAME0OUT)<=0)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
@@ -207,13 +207,13 @@ int main (void)
GOERROR;
if (h5repack_verify(FNAME1OUT,&pack_options)<=0)
GOERROR;
- if (h5repack_cmpdcpl(FNAME1,FNAME1OUT)<=0)
+ if (h5repack_cmp_pl(FNAME1,FNAME1OUT)<=0)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
-
+
+
/*-------------------------------------------------------------------------
* file with attributes
*-------------------------------------------------------------------------
@@ -227,12 +227,12 @@ int main (void)
GOERROR;
if (h5repack_verify(FNAME2OUT,&pack_options)<=0)
GOERROR;
- if (h5repack_cmpdcpl(FNAME2,FNAME2OUT)<=0)
+ if (h5repack_cmp_pl(FNAME2,FNAME2OUT)<=0)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
/*-------------------------------------------------------------------------
* file with hardlinks
*-------------------------------------------------------------------------
@@ -246,13 +246,13 @@ int main (void)
GOERROR;
if (h5repack_verify(FNAME3OUT,&pack_options)<=0)
GOERROR;
- if (h5repack_cmpdcpl(FNAME3,FNAME3OUT)<=0)
+ if (h5repack_cmp_pl(FNAME3,FNAME3OUT)<=0)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
-
+
/*-------------------------------------------------------------------------
* alloc early test
*-------------------------------------------------------------------------
@@ -269,25 +269,25 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
/*-------------------------------------------------------------------------
* the remaining files differ in the dcpl's
*-------------------------------------------------------------------------
*/
-
+
/*-------------------------------------------------------------------------
* deflate
*-------------------------------------------------------------------------
*/
TESTING(" adding deflate filter");
-
+
#ifdef H5_HAVE_FILTER_DEFLATE
-
+
/*-------------------------------------------------------------------------
* test an individual object option
*-------------------------------------------------------------------------
*/
-
+
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
if (h5repack_addfilter("dset1:GZIP=9",&pack_options) < 0)
@@ -306,16 +306,16 @@ int main (void)
#else
SKIPPED();
#endif
-
+
/*-------------------------------------------------------------------------
* test all objects option
*-------------------------------------------------------------------------
*/
-
+
TESTING(" adding deflate filter to all");
-
+
#ifdef H5_HAVE_FILTER_DEFLATE
-
+
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
if (h5repack_addfilter("GZIP=1",&pack_options) < 0)
@@ -330,29 +330,29 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
+
/*-------------------------------------------------------------------------
* SZIP
*-------------------------------------------------------------------------
*/
-
+
TESTING(" adding szip filter");
-
+
#if defined (H5_HAVE_FILTER_SZIP)
if (h5tools_can_encode(H5Z_FILTER_SZIP) >0) {
szip_can_encode = 1;
}
-
+
/*-------------------------------------------------------------------------
* test an individual object option
*-------------------------------------------------------------------------
*/
-
+
if (szip_can_encode) {
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -368,7 +368,7 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
} else {
SKIPPED();
@@ -376,14 +376,14 @@ int main (void)
#else
SKIPPED();
#endif
-
-
+
+
/*-------------------------------------------------------------------------
* test all objects option
*-------------------------------------------------------------------------
*/
TESTING(" adding szip filter to all");
-
+
#if defined (H5_HAVE_FILTER_SZIP)
if (szip_can_encode) {
if (h5repack_init (&pack_options, 0) < 0)
@@ -398,7 +398,7 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
} else {
SKIPPED();
@@ -406,17 +406,17 @@ int main (void)
#else
SKIPPED();
#endif
-
-
+
+
TESTING(" addding shuffle filter");
-
+
#ifdef H5_HAVE_FILTER_SHUFFLE
-
+
/*-------------------------------------------------------------------------
* test an individual object option
*-------------------------------------------------------------------------
*/
-
+
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
if (h5repack_addfilter("dset1:SHUF",&pack_options) < 0)
@@ -431,21 +431,21 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
+
/*-------------------------------------------------------------------------
* test all objects option
*-------------------------------------------------------------------------
*/
-
+
TESTING(" addding shuffle filter to all");
-
+
#ifdef H5_HAVE_FILTER_SHUFFLE
-
+
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
if (h5repack_addfilter("SHUF",&pack_options) < 0)
@@ -460,21 +460,21 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
+
TESTING(" adding checksum filter");
-
+
#ifdef H5_HAVE_FILTER_FLETCHER32
-
+
/*-------------------------------------------------------------------------
* test an individual object option
*-------------------------------------------------------------------------
*/
-
+
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
if (h5repack_addfilter("dset1:FLET",&pack_options) < 0)
@@ -489,22 +489,22 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
+
/*-------------------------------------------------------------------------
* test all objects option
*-------------------------------------------------------------------------
*/
-
-
+
+
TESTING(" adding checksum filter to all");
-
+
#ifdef H5_HAVE_FILTER_FLETCHER32
-
+
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
if (h5repack_addfilter("FLET",&pack_options) < 0)
@@ -519,47 +519,47 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
-
+
+
TESTING(" filter queue fletcher, shuffle, deflate, szip");
-
+
/*-------------------------------------------------------------------------
* add some filters
*-------------------------------------------------------------------------
*/
-
+
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
if (h5repack_addlayout("dset1:CHUNK 20x10",&pack_options) < 0)
GOERROR;
-
+
#if defined (H5_HAVE_FILTER_FLETCHER32)
if (h5repack_addfilter("dset1:FLET",&pack_options) < 0)
GOERROR;
#endif
-
+
#ifdef H5_HAVE_FILTER_SHUFFLE
if (h5repack_addfilter("dset1:SHUF",&pack_options) < 0)
GOERROR;
#endif
-
+
#if defined (H5_HAVE_FILTER_SZIP)
if (szip_can_encode) {
if (h5repack_addfilter("dset1:SZIP=8,NN",&pack_options) < 0)
GOERROR;
}
#endif
-
+
#ifdef H5_HAVE_FILTER_DEFLATE
if (h5repack_addfilter("dset1:GZIP=1",&pack_options) < 0)
GOERROR;
#endif
-
+
if (h5repack(FNAME4,FNAME4OUT,&pack_options) < 0)
GOERROR;
if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) >0)
@@ -568,17 +568,17 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
-
-
+
+
TESTING(" adding layout chunked");
-
+
/*-------------------------------------------------------------------------
* test an individual object option
*-------------------------------------------------------------------------
*/
-
+
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
if (h5repack_addlayout("dset1:CHUNK=20x10",&pack_options) < 0)
@@ -592,13 +592,13 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
/*-------------------------------------------------------------------------
* test all objects option
*-------------------------------------------------------------------------
*/
TESTING(" adding layout chunked to all");
-
+
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
if (h5repack_addlayout("CHUNK=20x10",&pack_options) < 0)
@@ -611,11 +611,11 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
-
+
TESTING(" adding layout contiguous");
-
+
/*-------------------------------------------------------------------------
* test an individual object option
*-------------------------------------------------------------------------
@@ -632,11 +632,11 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
-
+
TESTING(" adding layout contiguous to all");
-
+
/*-------------------------------------------------------------------------
* test all objects option
*-------------------------------------------------------------------------
@@ -653,16 +653,16 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
-
+
TESTING(" adding layout compact");
-
+
/*-------------------------------------------------------------------------
* test an individual object option
*-------------------------------------------------------------------------
*/
-
+
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
if (h5repack_addlayout("dset1:COMPA",&pack_options) < 0)
@@ -676,14 +676,14 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
TESTING(" adding layout compact to all");
-
+
/*-------------------------------------------------------------------------
* test all objects option
*-------------------------------------------------------------------------
*/
-
+
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
if (h5repack_addlayout("COMPA",&pack_options) < 0)
@@ -696,12 +696,12 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
-
-
+
+
TESTING(" layout compact to contiguous conversion");
-
+
/*-------------------------------------------------------------------------
* layout compact to contiguous conversion
*-------------------------------------------------------------------------
@@ -719,9 +719,9 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
TESTING(" layout compact to chunk conversion");
-
+
/*-------------------------------------------------------------------------
* layout compact to chunk conversion
*-------------------------------------------------------------------------
@@ -739,9 +739,9 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
TESTING(" layout compact to compact conversion");
-
+
/*-------------------------------------------------------------------------
* layout compact to compact conversion
*-------------------------------------------------------------------------
@@ -759,7 +759,7 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
TESTING(" layout contiguous to compact conversion");
/*-------------------------------------------------------------------------
* layout contiguous to compact conversion
@@ -778,7 +778,7 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
TESTING(" layout contiguous to chunk conversion");
/*-------------------------------------------------------------------------
* layout contiguous to chunk conversion
@@ -797,9 +797,9 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
TESTING(" layout contiguous to contiguous conversion");
-
+
/*-------------------------------------------------------------------------
* layout contiguous to contiguous conversion
*-------------------------------------------------------------------------
@@ -817,7 +817,7 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
TESTING(" layout chunked to compact conversion");
/*-------------------------------------------------------------------------
* layout chunked to compact conversion
@@ -836,9 +836,9 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
TESTING(" layout chunked to contiguous conversion");
-
+
/*-------------------------------------------------------------------------
* layout chunked to contiguous conversion
*-------------------------------------------------------------------------
@@ -856,7 +856,7 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
TESTING(" layout chunked to chunk conversion");
/*-------------------------------------------------------------------------
* layout chunked to chunked conversion
@@ -875,8 +875,8 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
-
+
+
/*-------------------------------------------------------------------------
* the following tests assume the input files have filters
* FNAME7
@@ -886,10 +886,10 @@ int main (void)
* FNAME11
*-------------------------------------------------------------------------
*/
-
-
+
+
TESTING(" copy of szip filter");
-
+
#if defined (H5_HAVE_FILTER_SZIP)
if (szip_can_encode) {
if (h5repack_init (&pack_options, 0) < 0)
@@ -900,11 +900,11 @@ int main (void)
GOERROR;
if (h5repack_verify(FNAME7OUT,&pack_options)<=0)
GOERROR;
- if (h5repack_cmpdcpl(FNAME7,FNAME7OUT)<=0)
+ if (h5repack_cmp_pl(FNAME7,FNAME7OUT)<=0)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
} else {
SKIPPED();
@@ -912,9 +912,9 @@ int main (void)
#else
SKIPPED();
#endif
-
+
TESTING(" removing szip filter");
-
+
#if defined (H5_HAVE_FILTER_SZIP)
if (szip_can_encode) {
if (h5repack_init (&pack_options, 0) < 0)
@@ -929,7 +929,7 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
} else {
SKIPPED();
@@ -937,10 +937,10 @@ int main (void)
#else
SKIPPED();
#endif
-
-
+
+
TESTING(" copy of deflate filter");
-
+
#ifdef H5_HAVE_FILTER_DEFLATE
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -952,15 +952,15 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
-
+
+
TESTING(" removing deflate filter");
-
+
#ifdef H5_HAVE_FILTER_DEFLATE
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -974,16 +974,16 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
-
-
+
+
+
TESTING(" copy of shuffle filter");
-
+
#ifdef H5_HAVE_FILTER_SHUFFLE
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -995,14 +995,14 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
+
TESTING(" removing shuffle filter");
-
+
#ifdef H5_HAVE_FILTER_SHUFFLE
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -1016,14 +1016,14 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
+
TESTING(" copy of fletcher filter");
-
+
#ifdef H5_HAVE_FILTER_FLETCHER32
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -1035,14 +1035,14 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
+
TESTING(" removing fletcher filter");
-
+
#ifdef H5_HAVE_FILTER_FLETCHER32
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -1056,15 +1056,15 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
-
+
+
TESTING(" copy of nbit filter");
-
+
#ifdef H5_HAVE_FILTER_NBIT
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -1076,14 +1076,14 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
+
TESTING(" removing nbit filter");
-
+
#ifdef H5_HAVE_FILTER_NBIT
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -1097,15 +1097,15 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
-
+
+
TESTING(" adding nbit filter");
-
+
#ifdef H5_HAVE_FILTER_NBIT
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -1119,15 +1119,15 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
-
+
+
TESTING(" copy of scaleoffset filter");
-
+
#ifdef H5_HAVE_FILTER_SCALEOFFSET
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -1139,14 +1139,14 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
+
TESTING(" removing scaleoffset filter");
-
+
#ifdef H5_HAVE_FILTER_SCALEOFFSET
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -1160,15 +1160,15 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
-
+
+
TESTING(" adding scaleoffset filter");
-
+
#ifdef H5_HAVE_FILTER_SCALEOFFSET
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -1182,14 +1182,14 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
-
-
+
+
+
/*-------------------------------------------------------------------------
* file with all filters
* dset_all
@@ -1199,14 +1199,14 @@ int main (void)
* dset_fletcher32
*-------------------------------------------------------------------------
*/
-
-
+
+
TESTING(" filter conversion from deflate to szip");
-
+
#if defined (H5_HAVE_FILTER_SZIP) \
&& defined (H5_HAVE_FILTER_DEFLATE) \
&& defined (H5_HAVE_FILTER_FLETCHER32) && defined (H5_HAVE_FILTER_SHUFFLE)
-
+
if (szip_can_encode) {
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -1220,7 +1220,7 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
} else {
SKIPPED();
@@ -1228,13 +1228,13 @@ int main (void)
#else
SKIPPED();
#endif
-
+
TESTING(" filter conversion from szip to deflate");
-
+
#if defined (H5_HAVE_FILTER_SZIP) \
&& defined (H5_HAVE_FILTER_DEFLATE) \
&& defined (H5_HAVE_FILTER_FLETCHER32) && defined (H5_HAVE_FILTER_SHUFFLE)
-
+
if (szip_can_encode) {
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
@@ -1248,7 +1248,7 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
} else {
SKIPPED();
@@ -1256,18 +1256,18 @@ int main (void)
#else
SKIPPED();
#endif
-
-
+
+
/*-------------------------------------------------------------------------
* test the NONE global option
*-------------------------------------------------------------------------
*/
-
+
TESTING(" removing all filters");
-
+
#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_HAVE_FILTER_DEFLATE) \
&& defined (H5_HAVE_FILTER_FLETCHER32) && defined (H5_HAVE_FILTER_SHUFFLE)
-
+
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
if (h5repack_addfilter("NONE",&pack_options) < 0)
@@ -1280,12 +1280,12 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
+
/*-------------------------------------------------------------------------
* test a big file
*-------------------------------------------------------------------------
@@ -1302,7 +1302,7 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
/*-------------------------------------------------------------------------
* test external dataset
*-------------------------------------------------------------------------
@@ -1319,7 +1319,7 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
+
/*-------------------------------------------------------------------------
* test file with userblock
*-------------------------------------------------------------------------
@@ -1338,7 +1338,7 @@ int main (void)
if(h5repack_end(&pack_options) < 0)
GOERROR;
PASSED();
-
+
/*-------------------------------------------------------------------------
* test --latest options
*-------------------------------------------------------------------------
@@ -1363,17 +1363,17 @@ int main (void)
if (h5repack_end (&pack_options) < 0)
GOERROR;
PASSED();
-
-
+
+
/*-------------------------------------------------------------------------
* test several global filters
*-------------------------------------------------------------------------
*/
-
+
TESTING(" several global filters");
-
+
#if defined (H5_HAVE_FILTER_DEFLATE) && defined (H5_HAVE_FILTER_SHUFFLE)
-
+
if (h5repack_init (&pack_options, 0) < 0)
GOERROR;
if (h5repack_addfilter("GZIP=1",&pack_options) < 0)
@@ -1388,28 +1388,28 @@ int main (void)
GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
-
+
PASSED();
#else
SKIPPED();
#endif
-
-
+
+
/*-------------------------------------------------------------------------
* test file with userblock
*-------------------------------------------------------------------------
*/
TESTING(" file with added userblock");
-
+
#ifdef H5_HAVE_FILTER_DEFLATE
-
+
if(h5repack_init(&pack_options, 0) < 0)
GOERROR;
-
+
/* add the options for a user block size and user block filename */
pack_options.ublock_size = USERBLOCK_SIZE;
pack_options.ublock_filename = FNAME_UB;
-
+
if(h5repack(FNAME8, FNAME8OUT, &pack_options) < 0)
GOERROR;
if(h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0)
@@ -1420,44 +1420,44 @@ int main (void)
GOERROR;
if(h5repack_end(&pack_options) < 0)
GOERROR;
-
-
+
+
PASSED();
#else
SKIPPED();
#endif
-
-
+
+
/*-------------------------------------------------------------------------
* test file with aligment
*-------------------------------------------------------------------------
*/
TESTING(" file with aligment");
-
+
#ifdef H5_HAVE_FILTER_DEFLATE
-
+
if(h5repack_init(&pack_options, 0) < 0)
GOERROR;
-
+
/* add the options for aligment */
pack_options.alignment = 1;
pack_options.threshold = 1;
-
+
if(h5repack(FNAME8, FNAME8OUT, &pack_options) < 0)
GOERROR;
if(h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0)
GOERROR;
if(h5repack_verify(FNAME8OUT, &pack_options) <= 0)
GOERROR;
-
-
+
+
/* verify aligment */
{
hsize_t threshold;
hsize_t alignment;
hid_t fapl;
hid_t fid;
-
+
if (( fid = H5Fopen(FNAME8OUT, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 )
GOERROR;
if ((fapl = H5Fget_access_plist(fid)) < 0)
@@ -1472,264 +1472,264 @@ int main (void)
GOERROR;
if (H5Fclose(fid) < 0)
GOERROR;
-
+
}
-
-
+
+
if(h5repack_end(&pack_options) < 0)
GOERROR;
-
-
+
+
PASSED();
#else
SKIPPED();
#endif
-
-
-
-
-
+
+
+
+
+
/*-------------------------------------------------------------------------
* clean temporary test files
*-------------------------------------------------------------------------
*/
{
hid_t fapl;
-
+
/* setup */
h5_reset();
fapl = h5_fileaccess();
h5_cleanup(H5REPACK_FILENAMES, fapl);
-
+
}
-
+
puts("All h5repack tests passed.");
-
+
return 0;
-
+
error:
puts("***** H5REPACK TESTS FAILED *****");
return 1;
-
+
}
/*-------------------------------------------------------------------------
- * Function: make_testfiles
- *
- * Purpose: make a test file with all types of HDF5 objects,
- * datatypes and filters
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_testfiles
+*
+* Purpose: make a test file with all types of HDF5 objects,
+* datatypes and filters
+*
+*-------------------------------------------------------------------------
+*/
int make_testfiles(void)
{
- hid_t loc_id;
-
-
+ hid_t fid;
+
/*-------------------------------------------------------------------------
* create a file for general copy test
*-------------------------------------------------------------------------
*/
- if((loc_id = H5Fcreate(FNAME0,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME0,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_fill(loc_id) < 0)
+ if (make_fill(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* create another file for general copy test (all datatypes)
*-------------------------------------------------------------------------
*/
- if((loc_id = H5Fcreate(FNAME1,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME1,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_all_objects(loc_id) < 0)
+ if (make_all_objects(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* create a file for attributes copy test
*-------------------------------------------------------------------------
*/
- if((loc_id = H5Fcreate(FNAME2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_attributes(loc_id) < 0)
+ if (make_attributes(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* create a file for hard links test
*-------------------------------------------------------------------------
*/
- if((loc_id = H5Fcreate(FNAME3,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME3,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_hlinks(loc_id) < 0)
+ if (make_hlinks(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* create a file for layouts test
*-------------------------------------------------------------------------
*/
- if((loc_id = H5Fcreate(FNAME4,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME4,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_layout(loc_id) < 0)
+ if (make_layout(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* create a file for the H5D_ALLOC_TIME_EARLY test
*-------------------------------------------------------------------------
*/
if (make_early() < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* create a file with the SZIP filter
*-------------------------------------------------------------------------
*/
#ifdef H5_HAVE_FILTER_SZIP
- if((loc_id = H5Fcreate(FNAME7,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME7,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_szip(loc_id) < 0)
+ if (make_szip(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
#endif /* H5_HAVE_FILTER_SZIP */
-
-
+
+
/*-------------------------------------------------------------------------
* create a file with the deflate filter
*-------------------------------------------------------------------------
*/
- if((loc_id = H5Fcreate(FNAME8,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME8,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_deflate(loc_id) < 0)
+ if (make_deflate(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* create a file with the shuffle filter
*-------------------------------------------------------------------------
*/
- if((loc_id = H5Fcreate(FNAME9,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME9,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_shuffle(loc_id) < 0)
+ if (make_shuffle(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* create a file with the fletcher32 filter
*-------------------------------------------------------------------------
*/
- if((loc_id = H5Fcreate(FNAME10,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME10,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_fletcher32(loc_id) < 0)
+ if (make_fletcher32(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* create a file with all the filters
*-------------------------------------------------------------------------
*/
- if((loc_id = H5Fcreate(FNAME11,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME11,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_all(loc_id) < 0)
+ if (make_all(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* create a file with the nbit filter
*-------------------------------------------------------------------------
*/
- if((loc_id = H5Fcreate(FNAME12,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME12,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_nbit(loc_id) < 0)
+ if (make_nbit(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* create a file with the scaleoffset filter
*-------------------------------------------------------------------------
*/
- if((loc_id = H5Fcreate(FNAME13,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME13,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_scaleoffset(loc_id) < 0)
+ if (make_scaleoffset(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* create a big dataset
*-------------------------------------------------------------------------
*/
- if((loc_id = H5Fcreate(FNAME14,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME14,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_big(loc_id) < 0)
+ if (make_big(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* create a file with external dataset
*-------------------------------------------------------------------------
*/
- if((loc_id = H5Fcreate(FNAME15,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(FNAME15,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
return -1;
- if (make_external(loc_id) < 0)
+ if (make_external(fid) < 0)
goto out;
- if(H5Fclose(loc_id) < 0)
+ if(H5Fclose(fid) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* create a file with userblock
*-------------------------------------------------------------------------
*/
if(make_userblock() < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* create a userblock file
*-------------------------------------------------------------------------
*/
if(make_userblock_file() < 0)
goto out;
-
+
return 0;
-
+
out:
- H5Fclose(loc_id);
+ H5Fclose(fid);
return -1;
}
/*-------------------------------------------------------------------------
- * Function: make_all_objects
- *
- * Purpose: make a test file with all types of HDF5 objects
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_all_objects
+*
+* Purpose: make a test file with all types of HDF5 objects
+*
+*-------------------------------------------------------------------------
+*/
int make_all_objects(hid_t loc_id)
{
- hid_t dset_id;
- hid_t group_id;
- hid_t type_id;
- hid_t root_id;
- hid_t space_id;
+ hid_t did=-1;
+ hid_t gid=-1;
+ hid_t tid=-1;
+ hid_t rid=-1;
+ hid_t sid=-1;
+ hid_t gcplid=-1;
hsize_t dims[1]={2};
- /* Compound datatype */
+ /* compound datatype */
typedef struct s_t
{
int a;
@@ -1737,124 +1737,184 @@ int make_all_objects(hid_t loc_id)
} s_t;
/*-------------------------------------------------------------------------
- * H5G_DATASET
- *-------------------------------------------------------------------------
- */
- space_id = H5Screate_simple(1, dims, NULL);
- dset_id = H5Dcreate2(loc_id, "dset_referenced", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Sclose(space_id);
+ * H5G_DATASET
+ *-------------------------------------------------------------------------
+ */
+ if ((sid = H5Screate_simple(1, dims, NULL)) < 0)
+ goto out;
+ if ((did = H5Dcreate2(loc_id, "dset_referenced", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
- * H5G_GROUP
- *-------------------------------------------------------------------------
- */
- group_id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- root_id = H5Gopen2(loc_id, "/", H5P_DEFAULT);
+ * H5G_GROUP
+ *-------------------------------------------------------------------------
+ */
+ if ((gid = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5Gclose(gid) < 0)
+ goto out;
- /*-------------------------------------------------------------------------
- * H5G_TYPE
- *-------------------------------------------------------------------------
- */
+ /* create a group "g2" with H5P_CRT_ORDER_TRACKED set */
+ if ((gcplid = H5Pcreate(H5P_GROUP_CREATE)) < 0)
+ goto out;
+ if (H5Pset_link_creation_order(gcplid, H5P_CRT_ORDER_TRACKED) < 0)
+ goto out;
+ if ((gid = H5Gcreate2(loc_id, "g2", H5P_DEFAULT, gcplid, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5Gclose(gid) < 0)
+ goto out;
- /* Create a memory compound datatype */
- type_id = H5Tcreate(H5T_COMPOUND, sizeof(s_t));
- H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_INT);
- H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_FLOAT);
+ /*-------------------------------------------------------------------------
+ * H5G_TYPE
+ *-------------------------------------------------------------------------
+ */
- /* Commit compound datatype and close it */
- H5Tcommit2(loc_id, "type", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Tclose(type_id);
+ /* create a compound datatype */
+ if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0)
+ goto out;
+ if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_INT) < 0)
+ goto out;
+ if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_FLOAT) < 0)
+ goto out;
+ if (H5Tcommit2(loc_id, "type", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
/*-------------------------------------------------------------------------
- * H5G_LINK
- *-------------------------------------------------------------------------
- */
+ * H5G_LINK
+ *-------------------------------------------------------------------------
+ */
- H5Lcreate_soft("dset", loc_id, "link", H5P_DEFAULT, H5P_DEFAULT);
+ if (H5Lcreate_soft("dset", loc_id, "link", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
/*-------------------------------------------------------------------------
- * H5G_UDLINK
- *-------------------------------------------------------------------------
- */
+ * H5G_UDLINK
+ *-------------------------------------------------------------------------
+ */
/* Create an external link. Other UD links are not supported by h5repack */
- H5Lcreate_external("file", "path", loc_id, "ext_link", H5P_DEFAULT, H5P_DEFAULT);
+ if (H5Lcreate_external("file", "path", loc_id, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
/*-------------------------------------------------------------------------
- * write a series of datasetes
- *-------------------------------------------------------------------------
- */
+ * write a series of datasetes at root
+ *-------------------------------------------------------------------------
+ */
- write_dset_in(root_id,"dset_referenced",loc_id,0);
+ if ((rid = H5Gopen2(loc_id, "/", H5P_DEFAULT)) < 0)
+ goto out;
+ if (write_dset_in(rid,"dset_referenced",loc_id,0) < 0)
+ goto out;
+ if (H5Gclose(rid) < 0)
+ goto out;
- /* Close */
- H5Dclose(dset_id);
- H5Gclose(group_id);
- H5Gclose(root_id);
+ /* close */
+ if (H5Dclose(did) < 0)
+ goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+ if (H5Pclose(gcplid) < 0)
+ goto out;
return 0;
+
+out:
+ H5E_BEGIN_TRY
+ {
+ H5Dclose(did);
+ H5Gclose(gid);
+ H5Gclose(rid);
+ H5Sclose(sid);
+ H5Tclose(tid);
+ H5Pclose(gcplid);
+ } H5E_END_TRY;
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: make_attributes
- *
- * Purpose: make a test file with all types of attributes
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_attributes
+*
+* Purpose: make a test file with all types of attributes
+*
+*-------------------------------------------------------------------------
+*/
int make_attributes(hid_t loc_id)
{
- hid_t dset_id;
- hid_t group_id;
- hid_t root_id;
- hid_t space_id;
+ hid_t did=-1;
+ hid_t gid=-1;
+ hid_t rid=-1;
+ hid_t sid=-1;
hsize_t dims[1]={2};
/*-------------------------------------------------------------------------
* H5G_DATASET
*-------------------------------------------------------------------------
*/
-
- space_id = H5Screate_simple(1, dims, NULL);
- dset_id = H5Dcreate2(loc_id, "dset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Sclose(space_id);
+ if ((sid = H5Screate_simple(1, dims, NULL)) < 0)
+ goto out;
+ if ((did = H5Dcreate2(loc_id, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
/*-------------------------------------------------------------------------
* H5G_GROUP
*-------------------------------------------------------------------------
*/
- group_id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- root_id = H5Gopen2(loc_id, "/", H5P_DEFAULT);
+ if ((gid = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if ((rid = H5Gopen2(loc_id, "/", H5P_DEFAULT)) < 0)
+ goto out;
/*-------------------------------------------------------------------------
* write a series of attributes on the dataset, group, and root group
*-------------------------------------------------------------------------
*/
- write_attr_in(dset_id,"dset",loc_id,0);
- write_attr_in(group_id,"dset",loc_id,0);
- write_attr_in(root_id,"dset",loc_id,0);
-
- /* Close */
- H5Dclose(dset_id);
- H5Gclose(group_id);
- H5Gclose(root_id);
+ if ( write_attr_in(did,"dset",loc_id,0) < 0)
+ goto out;
+ if (write_attr_in(gid,"dset",loc_id,0) < 0)
+ goto out;
+ if (write_attr_in(rid,"dset",loc_id,0) < 0)
+ goto out;
+ /* close */
+ if (H5Dclose(did) < 0)
+ goto out;
+ if (H5Gclose(gid) < 0)
+ goto out;
+ if (H5Gclose(rid) < 0)
+ goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+
return 0;
+
+out:
+ H5E_BEGIN_TRY
+ {
+ H5Dclose(did);
+ H5Gclose(gid);
+ H5Gclose(rid);
+ H5Sclose(sid);
+ } H5E_END_TRY;
+ return -1;
+
}
/*-------------------------------------------------------------------------
- * Function: make_hlinks
- *
- * Purpose: make a test file with hard links
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_hlinks
+*
+* Purpose: make a test file with hard links
+*
+*-------------------------------------------------------------------------
+*/
int make_hlinks(hid_t loc_id)
{
- hid_t group1_id;
- hid_t group2_id;
- hid_t group3_id;
+ hid_t g1id=-1;
+ hid_t g2id=-1;
+ hid_t g3id=-1;
hsize_t dims[2]={3,2};
int buf[3][2]= {{1,1},{1,2},{2,2}};
@@ -1872,39 +1932,53 @@ int make_hlinks(hid_t loc_id)
if(H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link3 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0)
return -1;
-
/*-------------------------------------------------------------------------
* create a group and some hard links to it
*-------------------------------------------------------------------------
*/
- if((group1_id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- return -1;
- if((group2_id = H5Gcreate2(group1_id, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- return -1;
- if((group3_id = H5Gcreate2(group2_id, "g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- return -1;
+ if((g1id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if((g2id = H5Gcreate2(g1id, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if((g3id = H5Gcreate2(g2id, "g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if(H5Lcreate_hard(loc_id, "g1", group2_id, "link1 to g1", H5P_DEFAULT, H5P_DEFAULT) < 0)
- return -1;
- if(H5Lcreate_hard(group1_id, "g2", group3_id, "link1 to g2", H5P_DEFAULT, H5P_DEFAULT) < 0)
- return -1;
+ if(H5Lcreate_hard(loc_id, "g1", g2id, "link1 to g1", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+ if(H5Lcreate_hard(g1id, "g2", g3id, "link1 to g2", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
- H5Gclose(group1_id);
- H5Gclose(group2_id);
- H5Gclose(group3_id);
+ /* close */
+ if (H5Gclose(g1id) < 0)
+ goto out;
+ if (H5Gclose(g2id) < 0)
+ goto out;
+ if (H5Gclose(g3id) < 0)
+ goto out;
+
return 0;
+
+out:
+ H5E_BEGIN_TRY
+ {
+ H5Gclose(g1id);
+ H5Gclose(g2id);
+ H5Gclose(g3id);
+ } H5E_END_TRY;
+ return -1;
+
}
/*-------------------------------------------------------------------------
- * Function: make_szip
- *
- * Purpose: make a dataset with the SZIP filter
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_szip
+*
+* Purpose: make a dataset with the SZIP filter
+*
+*-------------------------------------------------------------------------
+*/
#ifdef H5_HAVE_FILTER_SZIP
int make_szip(hid_t loc_id)
{
@@ -1916,8 +1990,8 @@ int make_szip(hid_t loc_id)
hsize_t chunk_dims[RANK]={CDIM1,CDIM2};
int buf[DIM1][DIM2];
int i, j, n;
- int szip_can_encode = 0;
-
+ int szip_can_encode = 0;
+
for (i=n=0; i<DIM1; i++)
{
for (j=0; j<DIM2; j++)
@@ -1934,7 +2008,7 @@ int make_szip(hid_t loc_id)
/* set up chunk */
if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* SZIP
*-------------------------------------------------------------------------
@@ -1956,14 +2030,14 @@ int make_szip(hid_t loc_id)
{
/* WARNING? SZIP is decoder only, can't generate test files */
}
-
+
if(H5Sclose(sid) < 0)
goto out;
if(H5Pclose(dcpl) < 0)
goto out;
-
+
return 0;
-
+
out:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
@@ -1976,12 +2050,12 @@ out:
/*-------------------------------------------------------------------------
- * Function: make_deflate
- *
- * Purpose: make a dataset with the deflate filter
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_deflate
+*
+* Purpose: make a dataset with the deflate filter
+*
+*-------------------------------------------------------------------------
+*/
int make_deflate(hid_t loc_id)
{
hid_t dcpl; /* dataset creation property list */
@@ -1992,7 +2066,7 @@ int make_deflate(hid_t loc_id)
hobj_ref_t bufref[1]; /* reference */
hsize_t dims1r[1]={1};
int i, j, n;
-
+
for (i=n=0; i<DIM1; i++)
{
for (j=0; j<DIM2; j++)
@@ -2000,7 +2074,7 @@ int make_deflate(hid_t loc_id)
buf[i][j]=n++;
}
}
-
+
/* create a space */
if((sid = H5Screate_simple(RANK, dims, NULL)) < 0)
return -1;
@@ -2010,7 +2084,7 @@ int make_deflate(hid_t loc_id)
/* set up chunk */
if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* GZIP
*-------------------------------------------------------------------------
@@ -2021,16 +2095,16 @@ int make_deflate(hid_t loc_id)
goto out;
if (make_dset(loc_id,"dset_deflate",sid,dcpl,buf) < 0)
goto out;
-
+
/* create a reference to the dataset, test second seeep of file for references */
-
+
if (H5Rcreate(&bufref[0],loc_id,"dset_deflate",H5R_OBJECT,-1) < 0)
goto out;
if (write_dset(loc_id,1,dims1r,"ref",H5T_STD_REF_OBJ,bufref) < 0)
goto out;
#endif
-
-
+
+
/*-------------------------------------------------------------------------
* close space and dcpl
*-------------------------------------------------------------------------
@@ -2039,9 +2113,9 @@ int make_deflate(hid_t loc_id)
goto out;
if(H5Pclose(dcpl) < 0)
goto out;
-
+
return 0;
-
+
out:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
@@ -2052,12 +2126,12 @@ out:
/*-------------------------------------------------------------------------
- * Function: make_shuffle
- *
- * Purpose: make a dataset with the shuffle filter
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_shuffle
+*
+* Purpose: make a dataset with the shuffle filter
+*
+*-------------------------------------------------------------------------
+*/
int make_shuffle(hid_t loc_id)
{
hid_t dcpl; /* dataset creation property list */
@@ -2066,7 +2140,7 @@ int make_shuffle(hid_t loc_id)
hsize_t chunk_dims[RANK]={CDIM1,CDIM2};
int buf[DIM1][DIM2];
int i, j, n;
-
+
for (i=n=0; i<DIM1; i++)
{
for (j=0; j<DIM2; j++)
@@ -2083,7 +2157,7 @@ int make_shuffle(hid_t loc_id)
/* set up chunk */
if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* shuffle
*-------------------------------------------------------------------------
@@ -2095,8 +2169,8 @@ int make_shuffle(hid_t loc_id)
if (make_dset(loc_id,"dset_shuffle",sid,dcpl,buf) < 0)
goto out;
#endif
-
-
+
+
/*-------------------------------------------------------------------------
* close space and dcpl
*-------------------------------------------------------------------------
@@ -2105,9 +2179,9 @@ int make_shuffle(hid_t loc_id)
goto out;
if(H5Pclose(dcpl) < 0)
goto out;
-
+
return 0;
-
+
out:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
@@ -2117,12 +2191,12 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: make_fletcher32
- *
- * Purpose: make a dataset with the fletcher32 filter
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_fletcher32
+*
+* Purpose: make a dataset with the fletcher32 filter
+*
+*-------------------------------------------------------------------------
+*/
int make_fletcher32(hid_t loc_id)
{
hid_t dcpl; /* dataset creation property list */
@@ -2131,7 +2205,7 @@ int make_fletcher32(hid_t loc_id)
hsize_t chunk_dims[RANK]={CDIM1,CDIM2};
int buf[DIM1][DIM2];
int i, j, n;
-
+
for (i=n=0; i<DIM1; i++)
{
for (j=0; j<DIM2; j++)
@@ -2148,8 +2222,8 @@ int make_fletcher32(hid_t loc_id)
/* set up chunk */
if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0)
goto out;
-
-
+
+
/*-------------------------------------------------------------------------
* fletcher32
*-------------------------------------------------------------------------
@@ -2164,7 +2238,7 @@ int make_fletcher32(hid_t loc_id)
if (make_dset(loc_id,"dset_fletcher32",sid,dcpl,buf) < 0)
goto out;
#endif
-
+
/*-------------------------------------------------------------------------
* close space and dcpl
*-------------------------------------------------------------------------
@@ -2173,9 +2247,9 @@ int make_fletcher32(hid_t loc_id)
goto out;
if(H5Pclose(dcpl) < 0)
goto out;
-
+
return 0;
-
+
out:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
@@ -2186,12 +2260,12 @@ out:
/*-------------------------------------------------------------------------
- * Function: make_nbit
- *
- * Purpose: make a dataset with the nbit filter
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_nbit
+*
+* Purpose: make a dataset with the nbit filter
+*
+*-------------------------------------------------------------------------
+*/
int make_nbit(hid_t loc_id)
{
hid_t dcpl; /* dataset creation property list */
@@ -2202,7 +2276,7 @@ int make_nbit(hid_t loc_id)
hsize_t chunk_dims[RANK]={CDIM1,CDIM2};
int buf[DIM1][DIM2];
int i, j, n;
-
+
for (i=n=0; i<DIM1; i++)
{
for (j=0; j<DIM2; j++)
@@ -2219,14 +2293,14 @@ int make_nbit(hid_t loc_id)
/* set up chunk */
if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0)
goto out;
-
+
dtid = H5Tcopy(H5T_NATIVE_INT);
if (H5Tset_precision(dtid,(H5Tget_precision(dtid) - 1)) < 0)
{
H5Tclose(dtid);
goto out;
}
-
+
#if defined H5_HAVE_FILTER_NBIT
/* remove the filters from the dcpl */
if(H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0)
@@ -2247,7 +2321,7 @@ int make_nbit(hid_t loc_id)
goto out;
}
H5Dclose(dsid);
-
+
if(H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) {
H5Tclose(dtid);
goto out;
@@ -2262,7 +2336,7 @@ int make_nbit(hid_t loc_id)
}
H5Dclose(dsid);
#endif
-
+
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
@@ -2273,9 +2347,9 @@ int make_nbit(hid_t loc_id)
goto out;
if (H5Tclose(dtid) < 0)
goto out;
-
+
return 0;
-
+
out:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
@@ -2286,12 +2360,12 @@ out:
/*-------------------------------------------------------------------------
- * Function: make_scaleoffset
- *
- * Purpose: make a dataset with the scaleoffset filter
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_scaleoffset
+*
+* Purpose: make a dataset with the scaleoffset filter
+*
+*-------------------------------------------------------------------------
+*/
int make_scaleoffset(hid_t loc_id)
{
hid_t dcpl; /* dataset creation property list */
@@ -2302,7 +2376,7 @@ int make_scaleoffset(hid_t loc_id)
hsize_t chunk_dims[RANK]={CDIM1,CDIM2};
int buf[DIM1][DIM2];
int i, j, n;
-
+
for (i=n=0; i<DIM1; i++)
{
for (j=0; j<DIM2; j++)
@@ -2319,9 +2393,9 @@ int make_scaleoffset(hid_t loc_id)
/* set up chunk */
if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0)
goto out;
-
+
dtid = H5Tcopy(H5T_NATIVE_INT);
-
+
#if defined (H5_HAVE_FILTER_SCALEOFFSET)
/* remove the filters from the dcpl */
if(H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) {
@@ -2352,7 +2426,7 @@ int make_scaleoffset(hid_t loc_id)
H5Tclose(dtid);
H5Dclose(dsid);
#endif
-
+
/*-------------------------------------------------------------------------
* close space and dcpl
*-------------------------------------------------------------------------
@@ -2361,9 +2435,9 @@ int make_scaleoffset(hid_t loc_id)
goto out;
if(H5Pclose(dcpl) < 0)
goto out;
-
+
return 0;
-
+
out:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
@@ -2374,12 +2448,12 @@ out:
/*-------------------------------------------------------------------------
- * Function: make_all
- *
- * Purpose: make a file with all filters
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_all
+*
+* Purpose: make a file with all filters
+*
+*-------------------------------------------------------------------------
+*/
int make_all(hid_t loc_id)
{
hid_t dcpl; /* dataset creation property list */
@@ -2399,7 +2473,7 @@ int make_all(hid_t loc_id)
#if defined (H5_HAVE_FILTER_SZIP)
int szip_can_encode = 0;
#endif
-
+
for (i=n=0; i<DIM1; i++)
{
for (j=0; j<DIM2; j++)
@@ -2414,26 +2488,28 @@ int make_all(hid_t loc_id)
if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto out;
/* set up chunk */
- if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0)
+ if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0)
goto out;
-
+
#if defined (H5_HAVE_FILTER_SHUFFLE)
/* set the shuffle filter */
if (H5Pset_shuffle(dcpl) < 0)
goto out;
#endif
-
+
#if defined (H5_HAVE_FILTER_FLETCHER32)
/* set the checksum filter */
if (H5Pset_fletcher32(dcpl) < 0)
goto out;
#endif
-
+
#if defined (H5_HAVE_FILTER_SZIP)
- if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) {
+ if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1)
+ {
szip_can_encode = 1;
}
- if (szip_can_encode) {
+ if (szip_can_encode)
+ {
/* set szip data */
if(H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block) < 0)
goto out;
@@ -2441,16 +2517,16 @@ int make_all(hid_t loc_id)
/* WARNING? SZIP is decoder only, can't generate test data using szip */
}
#endif
-
+
#if defined (H5_HAVE_FILTER_DEFLATE)
/* set deflate data */
if(H5Pset_deflate(dcpl, 9) < 0)
goto out;
#endif
-
+
if (make_dset(loc_id,"dset_all",sid,dcpl,buf) < 0)
goto out;
-
+
#if defined (H5_HAVE_FILTER_FLETCHER32)
/* remove the filters from the dcpl */
if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0)
@@ -2461,11 +2537,12 @@ int make_all(hid_t loc_id)
if (make_dset(loc_id,"dset_fletcher32",sid,dcpl,buf) < 0)
goto out;
#endif
-
-
+
+
/* Make sure encoding is enabled */
#if defined (H5_HAVE_FILTER_SZIP)
- if (szip_can_encode) {
+ if (szip_can_encode)
+ {
/* remove the filters from the dcpl */
if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0)
goto out;
@@ -2474,12 +2551,13 @@ int make_all(hid_t loc_id)
goto out;
if (make_dset(loc_id,"dset_szip",sid,dcpl,buf) < 0)
goto out;
- } else {
+ } else
+ {
/* WARNING? SZIP is decoder only, can't generate test dataset */
}
#endif
-
-
+
+
#if defined (H5_HAVE_FILTER_SHUFFLE)
/* remove the filters from the dcpl */
if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0)
@@ -2490,8 +2568,8 @@ int make_all(hid_t loc_id)
if (make_dset(loc_id,"dset_shuffle",sid,dcpl,buf) < 0)
goto out;
#endif
-
-
+
+
#if defined (H5_HAVE_FILTER_DEFLATE)
/* remove the filters from the dcpl */
if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0)
@@ -2502,40 +2580,43 @@ int make_all(hid_t loc_id)
if (make_dset(loc_id,"dset_deflate",sid,dcpl,buf) < 0)
goto out;
#endif
-
-
-
+
+
+
#if defined (H5_HAVE_FILTER_NBIT)
/* remove the filters from the dcpl */
- if(H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0)
+ if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0)
goto out;
/* set the shuffle filter */
- if(H5Pset_nbit(dcpl) < 0)
+ if (H5Pset_nbit(dcpl) < 0)
+ goto out;
+ if ((dtid = H5Tcopy(H5T_NATIVE_INT)) < 0)
+ goto out;
+ if (H5Tset_precision(dtid, (H5Tget_precision(dtid) - 1)) < 0)
goto out;
- dtid = H5Tcopy(H5T_NATIVE_INT);
- H5Tset_precision(dtid, (H5Tget_precision(dtid) - 1));
if((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
goto out;
if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
goto out;
-
+
/* close */
if(H5Tclose(dtid) < 0)
return -1;
if(H5Dclose(dsid) < 0)
return -1;
#endif
-
-
+
+
if(H5Sclose(sid) < 0)
goto out;
if(H5Pclose(dcpl) < 0)
goto out;
-
+
return 0;
-
+
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dcpl);
H5Sclose(sid);
} H5E_END_TRY;
@@ -2545,18 +2626,18 @@ out:
/*-------------------------------------------------------------------------
- * Function: make_early
- *
- * Purpose: create a file for the H5D_ALLOC_TIME_EARLY test
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_early
+*
+* Purpose: create a file for the H5D_ALLOC_TIME_EARLY test
+*
+*-------------------------------------------------------------------------
+*/
int make_early(void)
{
hsize_t dims[1] ={3000};
hsize_t cdims[1]={30};
hid_t fid=-1;
- hid_t dset_id=-1;
+ hid_t did=-1;
hid_t sid=-1;
hid_t tid=-1;
hid_t dcpl=-1;
@@ -2564,37 +2645,38 @@ int make_early(void)
char name[10];
int iter=100;
- if((fid = H5Fcreate(FNAME5, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FNAME5, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
return -1;
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
goto out;
- if((sid = H5Screate_simple(1, dims, NULL)) < 0)
+ if ((sid = H5Screate_simple(1, dims, NULL)) < 0)
goto out;
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto out;
- if(H5Pset_chunk(dcpl, 1, cdims) < 0)
+ if (H5Pset_chunk(dcpl, 1, cdims) < 0)
goto out;
- if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0)
+ if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0)
goto out;
- for(i = 0; i < iter; i++) {
- if((fid = H5Fopen(FNAME5, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ for(i = 0; i < iter; i++)
+ {
+ if ((fid = H5Fopen(FNAME5, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
goto out;
- if((dset_id = H5Dcreate2(fid, "early", H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ if ((did = H5Dcreate2(fid, "early", H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
goto out;
- if((tid = H5Tcopy(H5T_NATIVE_DOUBLE)) < 0)
+ if ((tid = H5Tcopy(H5T_NATIVE_DOUBLE)) < 0)
goto out;
sprintf(name, "%d", i);
- if((H5Tcommit2(fid, name, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((H5Tcommit2(fid, name, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
- if(H5Dclose(dset_id) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Ldelete(fid, "early", H5P_DEFAULT) < 0)
+ if (H5Ldelete(fid, "early", H5P_DEFAULT) < 0)
goto out;
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
goto out;
}
@@ -2603,34 +2685,36 @@ int make_early(void)
*-------------------------------------------------------------------------
*/
- if((fid = H5Fcreate(FNAME6, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FNAME6, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
return -1;
- for(i = 0; i < iter; i++) {
- if((tid = H5Tcopy(H5T_NATIVE_DOUBLE)) < 0)
+ for(i = 0; i < iter; i++)
+ {
+ if ((tid = H5Tcopy(H5T_NATIVE_DOUBLE)) < 0)
goto out;
sprintf(name, "%d", i);
- if((H5Tcommit2(fid, name, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((H5Tcommit2(fid, name, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
}
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Pclose(dcpl) < 0)
+ if (H5Pclose(dcpl) < 0)
goto out;
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
goto out;
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Tclose(tid);
H5Pclose(dcpl);
H5Sclose(sid);
- H5Dclose(dset_id);
+ H5Dclose(did);
H5Fclose(fid);
} H5E_END_TRY;
return -1;
@@ -2638,23 +2722,23 @@ out:
/*-------------------------------------------------------------------------
- * Function: make_layout
- *
- * Purpose: make several datasets with several layouts in location LOC_ID
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_layout
+*
+* Purpose: make several datasets with several layouts in location LOC_ID
+*
+*-------------------------------------------------------------------------
+*/
int make_layout(hid_t loc_id)
{
- hid_t dcpl; /* dataset creation property list */
- hid_t sid; /* dataspace ID */
+ hid_t dcpl=-1; /* dataset creation property list */
+ hid_t sid=-1; /* dataspace ID */
hsize_t dims[RANK]={DIM1,DIM2};
hsize_t chunk_dims[RANK]={CDIM1,CDIM2};
int buf[DIM1][DIM2];
int i, j, n;
char name[6];
-
-
+
+
for (i=n=0; i<DIM1; i++)
{
for (j=0; j<DIM2; j++)
@@ -2662,7 +2746,7 @@ int make_layout(hid_t loc_id)
buf[i][j]=n++;
}
}
-
+
/*-------------------------------------------------------------------------
* make several dataset with no filters
*-------------------------------------------------------------------------
@@ -2673,8 +2757,8 @@ int make_layout(hid_t loc_id)
if (write_dset(loc_id,RANK,dims,name,H5T_NATIVE_INT,buf) < 0)
return -1;
}
-
-
+
+
/*-------------------------------------------------------------------------
* make several dataset with several layout options
*-------------------------------------------------------------------------
@@ -2687,7 +2771,7 @@ int make_layout(hid_t loc_id)
{
goto out;
}
-
+
/*-------------------------------------------------------------------------
* H5D_COMPACT
*-------------------------------------------------------------------------
@@ -2698,7 +2782,7 @@ int make_layout(hid_t loc_id)
{
goto out;
}
-
+
/*-------------------------------------------------------------------------
* H5D_CONTIGUOUS
*-------------------------------------------------------------------------
@@ -2709,7 +2793,7 @@ int make_layout(hid_t loc_id)
{
goto out;
}
-
+
/*-------------------------------------------------------------------------
* H5D_CHUNKED
*-------------------------------------------------------------------------
@@ -2720,7 +2804,7 @@ int make_layout(hid_t loc_id)
{
goto out;
}
-
+
/*-------------------------------------------------------------------------
* close space and dcpl
*-------------------------------------------------------------------------
@@ -2729,11 +2813,12 @@ int make_layout(hid_t loc_id)
goto out;
if(H5Pclose(dcpl) < 0)
goto out;
-
+
return 0;
-
+
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dcpl);
H5Sclose(sid);
} H5E_END_TRY;
@@ -2741,12 +2826,12 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: make a file with an integer dataset with a fill value
- *
- * Purpose: test copy of fill values
- *
- *-------------------------------------------------------------------------
- */
+* Function: make a file with an integer dataset with a fill value
+*
+* Purpose: test copy of fill values
+*
+*-------------------------------------------------------------------------
+*/
int make_fill(hid_t loc_id)
{
hid_t did=-1;
@@ -2755,7 +2840,7 @@ int make_fill(hid_t loc_id)
hsize_t dims[2]={3,2};
int buf[3][2]= {{1,1},{1,2},{2,2}};
int fillvalue = 2;
-
+
/*-------------------------------------------------------------------------
* H5T_INTEGER, write a fill value
*-------------------------------------------------------------------------
@@ -2770,7 +2855,7 @@ int make_fill(hid_t loc_id)
goto out;
if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
goto out;
-
+
/* close */
if(H5Sclose(sid) < 0)
goto out;
@@ -2778,9 +2863,9 @@ int make_fill(hid_t loc_id)
goto out;
if(H5Dclose(did) < 0)
goto out;
-
+
return 0;
-
+
out:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
@@ -2792,13 +2877,13 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: make_big
- *
- * Purpose: used in test read by hyperslabs. Creates a 128MB dataset.
- * Only 1 1024Kb hyperslab is written.
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_big
+*
+* Purpose: used in test read by hyperslabs. Creates a 128MB dataset.
+* Only 1 1024Kb hyperslab is written.
+*
+*-------------------------------------------------------------------------
+*/
int make_big(hid_t loc_id)
{
@@ -2815,11 +2900,11 @@ int make_big(hid_t loc_id)
size_t nelmts=(size_t)1024;
signed char fillvalue=-1;
signed char *buf=NULL;
-
+
/* write one 1024 byte hyperslab */
hs_start[0] = 0;
hs_size[0] = 1024;
-
+
/* create */
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto out;
@@ -2837,18 +2922,18 @@ int make_big(hid_t loc_id)
goto out;
if((size = H5Tget_size(tid))<=0)
goto out;
-
+
/* initialize buffer to 0 */
buf=(signed char *) calloc( nelmts, size);
-
+
if (H5Sselect_hyperslab (f_sid,H5S_SELECT_SET,hs_start,NULL,hs_size, NULL) < 0)
goto out;
if (H5Dwrite (did,H5T_NATIVE_SCHAR,m_sid,f_sid,H5P_DEFAULT,buf) < 0)
goto out;
-
+
free(buf);
buf=NULL;
-
+
/* close */
if(H5Sclose(f_sid) < 0)
goto out;
@@ -2858,9 +2943,9 @@ int make_big(hid_t loc_id)
goto out;
if(H5Dclose(did) < 0)
goto out;
-
+
return 0;
-
+
out:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
@@ -2874,12 +2959,12 @@ out:
/*-------------------------------------------------------------------------
- * Function: make_external
- *
- * Purpose: create a external dataset
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_external
+*
+* Purpose: create a external dataset
+*
+*-------------------------------------------------------------------------
+*/
int make_external(hid_t loc_id)
{
@@ -2890,10 +2975,10 @@ int make_external(hid_t loc_id)
hsize_t cur_size[1]; /* data space current size */
hsize_t max_size[1]; /* data space maximum size */
hsize_t size;
-
+
cur_size[0] = max_size[0] = 2;
size = max_size[0] * sizeof(int);
-
+
/* create */
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto out;
@@ -2905,7 +2990,7 @@ int make_external(hid_t loc_id)
goto out;
if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
goto out;
-
+
/* close */
if(H5Sclose(sid) < 0)
goto out;
@@ -2913,11 +2998,12 @@ int make_external(hid_t loc_id)
goto out;
if(H5Dclose(did) < 0)
goto out;
-
+
return 0;
-
+
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dcpl);
H5Sclose(sid);
H5Dclose(did);
@@ -2927,12 +3013,12 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: make_userblock
- *
- * Purpose: create a file for the userblock copying test
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_userblock
+*
+* Purpose: create a file for the userblock copying test
+*
+*-------------------------------------------------------------------------
+*/
static int
make_userblock(void)
{
@@ -2989,12 +3075,12 @@ out:
} /* end make_userblock() */
/*-------------------------------------------------------------------------
- * Function: verify_userblock
- *
- * Purpose: Verify that the userblock was copied correctly
- *
- *-------------------------------------------------------------------------
- */
+* Function: verify_userblock
+*
+* Purpose: Verify that the userblock was copied correctly
+*
+*-------------------------------------------------------------------------
+*/
static int
verify_userblock( const char* filename)
{
@@ -3059,12 +3145,12 @@ out:
/*-------------------------------------------------------------------------
- * Function: make_userblock_file
- *
- * Purpose: create a file for the userblock add test
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_userblock_file
+*
+* Purpose: create a file for the userblock add test
+*
+*-------------------------------------------------------------------------
+*/
static int
make_userblock_file(void)
{
@@ -3099,44 +3185,43 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: write_dset_in
- *
- * Purpose: write datasets in LOC_ID
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 12, 2003
- *
- *-------------------------------------------------------------------------
- */
-
-
-void write_dset_in(hid_t loc_id,
+* Function: write_dset_in
+*
+* Purpose: write datasets in LOC_ID
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 12, 2003
+*
+*-------------------------------------------------------------------------
+*/
+
+
+int write_dset_in(hid_t loc_id,
const char* dset_name, /* for saving reference to dataset*/
hid_t file_id,
int make_diffs /* flag to modify data buffers */)
{
- /* Compound datatype */
+ /* compound datatype */
typedef struct s_t
{
char a;
double b;
} s_t;
-
+
typedef enum
{
RED,
- GREEN
+ GREEN
} e_t;
-
- hid_t dset_id;
- hid_t space_id;
- hid_t type_id;
- hid_t plist_id;
- herr_t status;
+
+ hid_t did=-1;
+ hid_t sid=-1;
+ hid_t tid=-1;
+ hid_t pid=-1;
int val, i, j, k, n;
float f;
-
+
/* create 1D attributes with dimension [2], 2 elements */
hsize_t dims[1]={2};
hsize_t dims1r[1]={2};
@@ -3150,7 +3235,7 @@ void write_dset_in(hid_t loc_id,
int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */
int buf7[2]= {1,2}; /* integer */
float buf8[2]= {1,2}; /* float */
-
+
/* create 2D attributes with dimension [3][2], 6 elements */
hsize_t dims2[2]={3,2};
hsize_t dims2r[2]={1,1};
@@ -3162,7 +3247,7 @@ void write_dset_in(hid_t loc_id,
int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */
int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */
float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */
-
+
/* create 3D attributes with dimension [4][3][2], 24 elements */
hsize_t dims3[3]={4,3,2};
hsize_t dims3r[3]={1,1,1};
@@ -3176,19 +3261,19 @@ void write_dset_in(hid_t loc_id,
int buf63[24][3]; /* array */
int buf73[4][3][2]; /* integer */
float buf83[4][3][2]; /* float */
-
-
+
+
/*-------------------------------------------------------------------------
* 1D
*-------------------------------------------------------------------------
*/
-
+
/*-------------------------------------------------------------------------
* H5T_STRING
*-------------------------------------------------------------------------
*/
-
-
+
+
if (make_diffs)
{
for (i=0; i<2; i++)
@@ -3197,37 +3282,45 @@ void write_dset_in(hid_t loc_id,
buf1[i][j]='z';
}
}
-
-
- type_id = H5Tcopy(H5T_C_S1);
- status = H5Tset_size(type_id, (size_t)2);
- write_dset(loc_id,1,dims,"string",type_id,buf1);
- status = H5Tclose(type_id);
-
-
+
+
+ if ((tid = H5Tcopy(H5T_C_S1)) < 0)
+ goto out;
+ if (H5Tset_size(tid, (size_t)2) < 0)
+ goto out;
+ if (write_dset(loc_id,1,dims,"string",tid,buf1) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
+
/* create hard link */
- status = H5Lcreate_hard(loc_id, "string", H5L_SAME_LOC, "string_link", H5P_DEFAULT, H5P_DEFAULT);
-
+ if (H5Lcreate_hard(loc_id, "string", H5L_SAME_LOC, "string_link", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_BITFIELD
*-------------------------------------------------------------------------
*/
-
+
if (make_diffs)
{
for (i=0; i<2; i++)
buf2[i]=buf2[1]=0;
}
-
- type_id = H5Tcopy(H5T_STD_B8LE);
- write_dset(loc_id,1,dims,"bitfield",type_id,buf2);
- status = H5Tclose(type_id);
-
+
+ if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0)
+ goto out;
+ if (write_dset(loc_id,1,dims,"bitfield",tid,buf2) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_OPAQUE
*-------------------------------------------------------------------------
*/
-
+
if (make_diffs)
{
for (i=0; i<2; i++)
@@ -3235,18 +3328,22 @@ void write_dset_in(hid_t loc_id,
buf3[i].a=0; buf3[i].b=0;
}
}
-
- type_id = H5Tcreate(H5T_OPAQUE, (size_t)1);
- status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */
- write_dset(loc_id,1,dims,"opaque",type_id,buf2);
- status = H5Tclose(type_id);
-
+
+ if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0)
+ goto out;
+ if (H5Tset_tag(tid, "1-byte opaque type") < 0)
+ goto out;
+ if (write_dset(loc_id,1,dims,"opaque",tid,buf2) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_COMPOUND
*-------------------------------------------------------------------------
*/
-
-
+
+
if (make_diffs)
{
for (i=0; i<2; i++)
@@ -3254,13 +3351,18 @@ void write_dset_in(hid_t loc_id,
buf45[i]=GREEN;
}
}
-
- type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
- H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR);
- H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE);
- write_dset(loc_id,1,dims,"compound",type_id,buf3);
- status = H5Tclose(type_id);
-
+
+ if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0)
+ goto out;
+ if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0)
+ goto out;
+ if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0)
+ goto out;
+ if (write_dset(loc_id,1,dims,"compound",tid,buf3) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_REFERENCE
*-------------------------------------------------------------------------
@@ -3270,31 +3372,39 @@ void write_dset_in(hid_t loc_id,
buf4[1]=0;
if (dset_name)
{
- status=H5Rcreate(&buf4[0],file_id,dset_name,H5R_OBJECT,-1);
- write_dset(loc_id,1,dims1r,"refobj",H5T_STD_REF_OBJ,buf4);
+ if (H5Rcreate(&buf4[0],file_id,dset_name,H5R_OBJECT,-1) < 0)
+ goto out;
+ if (write_dset(loc_id,1,dims1r,"refobj",H5T_STD_REF_OBJ,buf4) < 0)
+ goto out;
}
-
+
/* Dataset region reference ( H5R_DATASET_REGION ) */
- make_dset_reg_ref(loc_id);
-
-
+ if (make_dset_reg_ref(loc_id) < 0)
+ goto out;
+
+
/*-------------------------------------------------------------------------
* H5T_ENUM
*-------------------------------------------------------------------------
*/
- type_id = H5Tcreate(H5T_ENUM, sizeof(e_t));
- H5Tenum_insert(type_id, "RED", (val = 0, &val));
- H5Tenum_insert(type_id, "GREEN", (val = 1, &val));
- write_dset(loc_id,1,dims,"enum",type_id,buf45);
- status = H5Tclose(type_id);
-
+ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0)
+ goto out;
+ if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0)
+ goto out;
+ if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0)
+ goto out;
+ if (write_dset(loc_id,1,dims,"enum",tid,buf45) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_VLEN
*-------------------------------------------------------------------------
*/
-
+
/* Allocate and initialize VL dataset to write */
-
+
buf5[0].len = 1;
buf5[0].p = malloc( 1 * sizeof(int));
((int *)buf5[0].p)[0]=1;
@@ -3302,29 +3412,35 @@ void write_dset_in(hid_t loc_id,
buf5[1].p = malloc( 2 * sizeof(int));
((int *)buf5[1].p)[0] = 2;
((int *)buf5[1].p)[1] = 3;
-
+
if(make_diffs) {
((int *)buf5[0].p)[0] = 0;
((int *)buf5[1].p)[0] = 0;
((int *)buf5[1].p)[1] = 0;
}
-
- space_id = H5Screate_simple(1, dims, NULL);
- type_id = H5Tvlen_create(H5T_NATIVE_INT);
- dset_id = H5Dcreate2(loc_id, "vlen", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- status = H5Dwrite(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5);
- assert(status >= 0);
- status = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, buf5);
- assert(status >= 0);
- status = H5Dclose(dset_id);
- status = H5Tclose(type_id);
- status = H5Sclose(space_id);
-
+
+ if ((sid = H5Screate_simple(1, dims, NULL)) < 0)
+ goto out;
+ if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0)
+ goto out;
+ if ((did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5) < 0)
+ goto out;
+ if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5) < 0)
+ goto out;
+ if (H5Dclose(did) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_ARRAY
*-------------------------------------------------------------------------
*/
-
+
if (make_diffs)
{
for (i=0; i<2; i++)
@@ -3333,10 +3449,13 @@ void write_dset_in(hid_t loc_id,
buf6[i][j]=0;
}
}
-
- type_id = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray);
- write_dset(loc_id, 1, dims, "array", type_id, buf6);
- status = H5Tclose(type_id);
+
+ if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0)
+ goto out;
+ if (write_dset(loc_id, 1, dims, "array", tid, buf6) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
{
@@ -3363,10 +3482,13 @@ void write_dset_in(hid_t loc_id,
}
/* create a type larger than H5TOOLS_MALLOCSIZE */
- tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, 1, tdims);
+ if ((tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, 1, tdims)) < 0)
+ goto out;
size = H5Tget_size(tid);
- sid = H5Screate_simple(1, sdims, NULL);
- did = H5Dcreate2(loc_id, "arrayd", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if ((sid = H5Screate_simple(1, sdims, NULL)) < 0)
+ goto out;
+ if ((did = H5Dcreate2(loc_id, "arrayd", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
#if defined(WRITE_ARRAY)
H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf);
#endif
@@ -3377,12 +3499,12 @@ void write_dset_in(hid_t loc_id,
H5Sclose(sid);
free( dbuf );
}
-
+
/*-------------------------------------------------------------------------
* H5T_INTEGER and H5T_FLOAT
*-------------------------------------------------------------------------
*/
-
+
if (make_diffs)
{
for (i=0; i<2; i++)
@@ -3391,72 +3513,90 @@ void write_dset_in(hid_t loc_id,
buf8[i]=0;
}
}
-
- write_dset(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7);
- write_dset(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8);
-
-
+
+ if (write_dset(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7) < 0)
+ goto out;
+ if (write_dset(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8) < 0)
+ goto out;
+
+
/*-------------------------------------------------------------------------
* 2D
*-------------------------------------------------------------------------
*/
-
+
/*-------------------------------------------------------------------------
* H5T_STRING
*-------------------------------------------------------------------------
*/
-
+
if (make_diffs)
{
memset(buf12, 'z', sizeof buf12);
}
-
-
- type_id = H5Tcopy(H5T_C_S1);
- status = H5Tset_size(type_id, (size_t)2);
- write_dset(loc_id,2,dims2,"string2D",type_id,buf12);
- status = H5Tclose(type_id);
-
+
+
+ if ((tid = H5Tcopy(H5T_C_S1)) < 0)
+ goto out;
+ if (H5Tset_size(tid, (size_t)2) < 0)
+ goto out;
+ if (write_dset(loc_id,2,dims2,"string2D",tid,buf12) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_BITFIELD
*-------------------------------------------------------------------------
*/
-
-
+
+
if (make_diffs)
{
memset(buf22,0,sizeof buf22);
}
-
- type_id = H5Tcopy(H5T_STD_B8LE);
- write_dset(loc_id,2,dims2,"bitfield2D",type_id,buf22);
- status = H5Tclose(type_id);
-
+
+ if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0)
+ goto out;
+ if (write_dset(loc_id,2,dims2,"bitfield2D",tid,buf22) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_OPAQUE
*-------------------------------------------------------------------------
*/
- type_id = H5Tcreate(H5T_OPAQUE, (size_t)1);
- status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */
- write_dset(loc_id,2,dims2,"opaque2D",type_id,buf22);
- status = H5Tclose(type_id);
-
+ if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0)
+ goto out;
+ if (H5Tset_tag(tid, "1-byte opaque type") < 0)
+ goto out;
+ if (write_dset(loc_id,2,dims2,"opaque2D",tid,buf22) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_COMPOUND
*-------------------------------------------------------------------------
*/
-
+
if (make_diffs)
{
memset(buf32,0,sizeof buf32);
}
-
- type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
- H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR);
- H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE);
- write_dset(loc_id,2,dims2,"compound2D",type_id,buf32);
- status = H5Tclose(type_id);
-
+
+ if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0)
+ goto out;
+ if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0)
+ goto out;
+ if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0)
+ goto out;
+ if (write_dset(loc_id,2,dims2,"compound2D",tid,buf32) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_REFERENCE
*-------------------------------------------------------------------------
@@ -3464,277 +3604,367 @@ void write_dset_in(hid_t loc_id,
/* Create references to dataset */
if (dset_name)
{
- status = H5Rcreate(&buf42[0][0], file_id, dset_name, H5R_OBJECT, -1);
- write_dset(loc_id, 2, dims2r, "refobj2D", H5T_STD_REF_OBJ, buf42);
+ if (H5Rcreate(&buf42[0][0], file_id, dset_name, H5R_OBJECT, -1) < 0)
+ goto out;
+ if (write_dset(loc_id, 2, dims2r, "refobj2D", H5T_STD_REF_OBJ, buf42) < 0)
+ goto out;
}
-
+
/*-------------------------------------------------------------------------
* H5T_ENUM
*-------------------------------------------------------------------------
*/
-
- type_id = H5Tcreate(H5T_ENUM, sizeof(e_t));
- H5Tenum_insert(type_id, "RED", (val = 0, &val));
- H5Tenum_insert(type_id, "GREEN", (val = 1, &val));
- write_dset(loc_id,2,dims2,"enum2D",type_id,0);
- status = H5Tclose(type_id);
-
+
+ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0)
+ goto out;
+ if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0)
+ goto out;
+ if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0)
+ goto out;
+ if (write_dset(loc_id,2,dims2,"enum2D",tid,0) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_VLEN
*-------------------------------------------------------------------------
*/
-
+
/* Allocate and initialize VL dataset to write */
n = 0;
for(i = 0; i < 3; i++)
- for(j = 0; j < 2; j++) {
+ {
+ for(j = 0; j < 2; j++)
+ {
int l;
-
+
buf52[i][j].p = malloc((i + 1) * sizeof(int));
buf52[i][j].len = i + 1;
for(l = 0; l < i + 1; l++)
+ {
if(make_diffs)
((int *)buf52[i][j].p)[l] = 0;
else
((int *)buf52[i][j].p)[l] = n++;
+ }
}
-
- space_id = H5Screate_simple(2, dims2, NULL);
- type_id = H5Tvlen_create(H5T_NATIVE_INT);
- dset_id = H5Dcreate2(loc_id, "vlen2D", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- status = H5Dwrite(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf52);
- assert(status >= 0);
- status = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, buf52);
- assert(status >= 0);
- status = H5Dclose(dset_id);
- status = H5Tclose(type_id);
- status = H5Sclose(space_id);
-
- /*-------------------------------------------------------------------------
- * H5T_ARRAY
- *-------------------------------------------------------------------------
- */
-
- if (make_diffs)
- {
- memset(buf62,0,sizeof buf62);
- }
-
-
- type_id = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray);
- write_dset(loc_id, 2, dims2, "array2D", type_id, buf62);
- status = H5Tclose(type_id);
-
- /*-------------------------------------------------------------------------
- * H5T_INTEGER, write a fill value
- *-------------------------------------------------------------------------
- */
-
-
- if(make_diffs) {
- memset(buf72, 0, sizeof buf72);
- memset(buf82, 0, sizeof buf82);
- }
-
-
- plist_id = H5Pcreate(H5P_DATASET_CREATE);
- space_id = H5Screate_simple(2, dims2, NULL);
- dset_id = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT);
- status = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf72);
- status = H5Pclose(plist_id);
- status = H5Dclose(dset_id);
- status = H5Sclose(space_id);
-
- /*-------------------------------------------------------------------------
- * H5T_FLOAT
- *-------------------------------------------------------------------------
- */
-
- write_dset(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82);
-
-
- /*-------------------------------------------------------------------------
- * 3D
- *-------------------------------------------------------------------------
- */
-
- /*-------------------------------------------------------------------------
- * H5T_STRING
- *-------------------------------------------------------------------------
- */
-
- if (make_diffs)
- {
- memset(buf13,'z',sizeof buf13);
+ }
+
+ if ((sid = H5Screate_simple(2, dims2, NULL)) < 0)
+ goto out;
+ if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0)
+ goto out;
+ if ((did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf52) < 0)
+ goto out;
+ if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52) < 0)
+ goto out;
+ if (H5Dclose(did) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+
+ /*-------------------------------------------------------------------------
+ * H5T_ARRAY
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ memset(buf62,0,sizeof buf62);
+ }
+
+
+ if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0)
+ goto out;
+ if (write_dset(loc_id, 2, dims2, "array2D", tid, buf62) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
+ /*-------------------------------------------------------------------------
+ * H5T_INTEGER, write a fill value
+ *-------------------------------------------------------------------------
+ */
+
+
+ if(make_diffs) {
+ memset(buf72, 0, sizeof buf72);
+ memset(buf82, 0, sizeof buf82);
+ }
+
+
+ if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ goto out;
+ if ((sid = H5Screate_simple(2, dims2, NULL)) < 0)
+ goto out;
+ if ((did = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf72) < 0)
+ goto out;
+ if (H5Pclose(pid) < 0)
+ goto out;
+ if (H5Dclose(did) < 0)
+ goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+
+ /*-------------------------------------------------------------------------
+ * H5T_FLOAT
+ *-------------------------------------------------------------------------
+ */
+
+ if (write_dset(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82) < 0)
+ goto out;
+
+
+ /*-------------------------------------------------------------------------
+ * 3D
+ *-------------------------------------------------------------------------
+ */
+
+ /*-------------------------------------------------------------------------
+ * H5T_STRING
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ memset(buf13,'z',sizeof buf13);
+ }
+
+ if ((tid = H5Tcopy(H5T_C_S1)) < 0)
+ goto out;
+ if (H5Tset_size(tid, (size_t)2) < 0)
+ goto out;
+ if (write_dset(loc_id,3,dims3,"string3D",tid,buf13) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
+ /*-------------------------------------------------------------------------
+ * H5T_BITFIELD
+ *-------------------------------------------------------------------------
+ */
+
+
+ n=1;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 3; j++) {
+ for (k = 0; k < 2; k++) {
+ if (make_diffs) buf23[i][j][k]=0;
+ else buf23[i][j][k]=n++;
+ }
}
-
- type_id = H5Tcopy(H5T_C_S1);
- status = H5Tset_size(type_id, (size_t)2);
- write_dset(loc_id,3,dims3,"string3D",type_id,buf13);
- status = H5Tclose(type_id);
-
- /*-------------------------------------------------------------------------
- * H5T_BITFIELD
- *-------------------------------------------------------------------------
- */
-
-
- n=1;
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 3; j++) {
- for (k = 0; k < 2; k++) {
- if (make_diffs) buf23[i][j][k]=0;
- else buf23[i][j][k]=n++;
+ }
+
+
+ if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0)
+ goto out;
+ if (write_dset(loc_id,3,dims3,"bitfield3D",tid,buf23) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
+ /*-------------------------------------------------------------------------
+ * H5T_OPAQUE
+ *-------------------------------------------------------------------------
+ */
+ if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0)
+ goto out;
+ if (H5Tset_tag(tid, "1-byte opaque type") < 0)
+ goto out;
+ if (write_dset(loc_id,3,dims3,"opaque3D",tid,buf23) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
+ /*-------------------------------------------------------------------------
+ * H5T_COMPOUND
+ *-------------------------------------------------------------------------
+ */
+
+ n=1;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 3; j++) {
+ for (k = 0; k < 2; k++) {
+ if (make_diffs) {
+ buf33[i][j][k].a=0;
+ buf33[i][j][k].b=0;
+ }
+ else {
+ buf33[i][j][k].a=n++;
+ buf33[i][j][k].b=n++;
}
}
}
-
-
- type_id = H5Tcopy(H5T_STD_B8LE);
- write_dset(loc_id,3,dims3,"bitfield3D",type_id,buf23);
- status = H5Tclose(type_id);
-
- /*-------------------------------------------------------------------------
- * H5T_OPAQUE
- *-------------------------------------------------------------------------
- */
- type_id = H5Tcreate(H5T_OPAQUE, (size_t)1);
- status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */
- write_dset(loc_id,3,dims3,"opaque3D",type_id,buf23);
- status = H5Tclose(type_id);
-
- /*-------------------------------------------------------------------------
- * H5T_COMPOUND
- *-------------------------------------------------------------------------
- */
-
- n=1;
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 3; j++) {
- for (k = 0; k < 2; k++) {
- if (make_diffs) {
- buf33[i][j][k].a=0;
- buf33[i][j][k].b=0;
- }
- else {
- buf33[i][j][k].a=n++;
- buf33[i][j][k].b=n++;
- }
+ }
+
+
+ if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0)
+ goto out;
+ if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0)
+ goto out;
+ if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0)
+ goto out;
+ if (write_dset(loc_id,3,dims3,"compound3D",tid,buf33) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
+ /*-------------------------------------------------------------------------
+ * H5T_REFERENCE
+ *-------------------------------------------------------------------------
+ */
+ /* Create references to dataset */
+ if (dset_name)
+ {
+ if (H5Rcreate(&buf43[0][0][0], file_id, dset_name, H5R_OBJECT, -1) < 0)
+ goto out;
+ if (write_dset(loc_id, 3, dims3r, "refobj3D", H5T_STD_REF_OBJ, buf43) < 0)
+ goto out;
+ }
+
+ /*-------------------------------------------------------------------------
+ * H5T_ENUM
+ *-------------------------------------------------------------------------
+ */
+
+ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0)
+ goto out;
+ if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0)
+ goto out;
+ if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0)
+ goto out;
+ if (write_dset(loc_id,3,dims3,"enum3D",tid,0) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
+ /*-------------------------------------------------------------------------
+ * H5T_VLEN
+ *-------------------------------------------------------------------------
+ */
+
+ /* Allocate and initialize VL dataset to write */
+ n = 0;
+ for(i = 0; i < 4; i++)
+ {
+ for(j = 0; j < 3; j++)
+ {
+ for(k = 0; k < 2; k++)
+ {
+ int l;
+
+ buf53[i][j][k].p = malloc((i + 1) * sizeof(int));
+ buf53[i][j][k].len = i + 1;
+ for(l = 0; l < i + 1; l++)
+ {
+ if(make_diffs)
+ ((int *)buf53[i][j][k].p)[l] = 0;
+ else
+ ((int *)buf53[i][j][k].p)[l] = n++;
}
}
}
-
-
- type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
- H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR);
- H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE);
- write_dset(loc_id,3,dims3,"compound3D",type_id,buf33);
- status = H5Tclose(type_id);
-
- /*-------------------------------------------------------------------------
- * H5T_REFERENCE
- *-------------------------------------------------------------------------
- */
- /* Create references to dataset */
- if (dset_name)
+ }
+
+ if ((sid = H5Screate_simple(3, dims3, NULL)) < 0)
+ goto out;
+ if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0)
+ goto out;
+ if ((did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf53) < 0)
+ goto out;
+
+ if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53) < 0)
+ goto out;
+
+ if (H5Dclose(did) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+
+ /*-------------------------------------------------------------------------
+ * H5T_ARRAY
+ *-------------------------------------------------------------------------
+ */
+
+
+ n = 1;
+ for(i = 0; i < 24; i++)
+ {
+ for(j = 0; j < (int)dimarray[0]; j++)
{
- status = H5Rcreate(&buf43[0][0][0], file_id, dset_name, H5R_OBJECT, -1);
- write_dset(loc_id, 3, dims3r, "refobj3D", H5T_STD_REF_OBJ, buf43);
+ if(make_diffs)
+ buf63[i][j] = 0;
+ else
+ buf63[i][j] = n++;
}
-
- /*-------------------------------------------------------------------------
- * H5T_ENUM
- *-------------------------------------------------------------------------
- */
-
- type_id = H5Tcreate(H5T_ENUM, sizeof(e_t));
- H5Tenum_insert(type_id, "RED", (val = 0, &val));
- H5Tenum_insert(type_id, "GREEN", (val = 1, &val));
- write_dset(loc_id,3,dims3,"enum3D",type_id,0);
- status = H5Tclose(type_id);
-
- /*-------------------------------------------------------------------------
- * H5T_VLEN
- *-------------------------------------------------------------------------
- */
-
- /* Allocate and initialize VL dataset to write */
- n = 0;
- for(i = 0; i < 4; i++)
- for(j = 0; j < 3; j++)
- for(k = 0; k < 2; k++) {
- int l;
-
- buf53[i][j][k].p = malloc((i + 1) * sizeof(int));
- buf53[i][j][k].len = i + 1;
- for(l = 0; l < i + 1; l++)
- if(make_diffs)
- ((int *)buf53[i][j][k].p)[l] = 0;
- else
- ((int *)buf53[i][j][k].p)[l] = n++;
+ }
+
+ if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0)
+ goto out;
+ if (write_dset(loc_id, 3, dims3, "array3D", tid, buf63) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
+ /*-------------------------------------------------------------------------
+ * H5T_INTEGER and H5T_FLOAT
+ *-------------------------------------------------------------------------
+ */
+ n=1; f=1;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 3; j++) {
+ for (k = 0; k < 2; k++) {
+ if (make_diffs) {
+ buf73[i][j][k]=0;
+ buf83[i][j][k]=0;
}
-
- space_id = H5Screate_simple(3, dims3, NULL);
- type_id = H5Tvlen_create(H5T_NATIVE_INT);
- dset_id = H5Dcreate2(loc_id, "vlen3D", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- status = H5Dwrite(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf53);
- assert(status >= 0);
- status = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, buf53);
- assert(status >= 0);
- status = H5Dclose(dset_id);
- status = H5Tclose(type_id);
- status = H5Sclose(space_id);
-
- /*-------------------------------------------------------------------------
- * H5T_ARRAY
- *-------------------------------------------------------------------------
- */
-
-
- n = 1;
- for(i = 0; i < 24; i++)
- for(j = 0; j < (int)dimarray[0]; j++)
- if(make_diffs)
- buf63[i][j] = 0;
- else
- buf63[i][j] = n++;
-
- type_id = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray);
- write_dset(loc_id, 3, dims3, "array3D", type_id, buf63);
- status = H5Tclose(type_id);
-
- /*-------------------------------------------------------------------------
- * H5T_INTEGER and H5T_FLOAT
- *-------------------------------------------------------------------------
- */
- n=1; f=1;
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 3; j++) {
- for (k = 0; k < 2; k++) {
- if (make_diffs) {
- buf73[i][j][k]=0;
- buf83[i][j][k]=0;
- }
- else {
- buf73[i][j][k]=n++;
- buf83[i][j][k]=f++;
- }
- }
- }
- }
- write_dset(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73);
- write_dset(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83);
-}
+ else {
+ buf73[i][j][k]=n++;
+ buf83[i][j][k]=f++;
+ }
+ }
+ }
+ }
+ if (write_dset(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73) < 0)
+ goto out;
+ if (write_dset(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83) < 0)
+ goto out;
+
+ return 0;
+
+
+out:
+ H5E_BEGIN_TRY
+ {
+ H5Pclose(pid);
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Tclose(tid);
+ } H5E_END_TRY;
+ return -1;
+}
+
/*-------------------------------------------------------------------------
- * Function: make_dset_reg_ref
- *
- * Purpose: write dataset region references
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_dset_reg_ref
+*
+* Purpose: write dataset region references
+*
+*-------------------------------------------------------------------------
+*/
#define SPACE1_RANK 1
#define SPACE1_DIM1 1
@@ -3743,94 +3973,110 @@ void write_dset_in(hid_t loc_id,
#define SPACE2_DIM2 10
#define NPOINTS 10
-void make_dset_reg_ref(hid_t loc_id)
+int make_dset_reg_ref(hid_t loc_id)
{
- hid_t dset1; /* Dataset ID */
- hid_t dset2; /* Dereferenced dataset ID */
- hid_t sid1; /* Dataspace ID #1 */
- hid_t sid2; /* Dataspace ID #2 */
+ hid_t did1=-1; /* Dataset ID */
+ hid_t did2=-1; /* Dereferenced dataset ID */
+ hid_t sid1=-1; /* Dataspace ID #1 */
+ hid_t sid2=-1; /* Dataspace ID #2 */
hsize_t dims1[] = {SPACE1_DIM1};
hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */
hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */
hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */
hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */
- hdset_reg_ref_t *wbuf; /* buffer to write to disk */
- int *dwbuf; /* Buffer for writing numeric data to disk */
+ hdset_reg_ref_t *wbuf=NULL; /* buffer to write to disk */
+ int *dwbuf=NULL; /* Buffer for writing numeric data to disk */
int i; /* counting variables */
- herr_t ret; /* Generic return value */
-
+
/* Allocate write & read buffers */
wbuf = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1);
dwbuf = (int *)malloc(sizeof(int) * SPACE2_DIM1 * SPACE2_DIM2);
-
+
/* Create dataspace for datasets */
- sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
-
+ if ((sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL)) < 0)
+ goto out;
+
/* Create a dataset */
- dset2 = H5Dcreate2(loc_id, "dsetreg", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- for(i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++)
+ if ((did2 = H5Dcreate2(loc_id, "dsetreg", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+
+ for (i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++)
dwbuf[i] = i * 3;
-
+
/* Write selection to disk */
- ret = H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf);
- assert(ret >= 0);
-
- /* Close Dataset */
- ret = H5Dclose(dset2);
- assert(ret >= 0);
-
+ if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf) < 0)
+ goto out;
+
/* Create dataspace for the reference dataset */
- sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
-
+ if ((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0)
+ goto out;
+
/* Create a dataset */
- dset1 = H5Dcreate2(loc_id, "refreg", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
-
- /* Create references */
-
+ if ((did1 = H5Dcreate2(loc_id, "refreg", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+
/* Select 6x6 hyperslab for first reference */
start[0] = 2; start[1] = 2;
stride[0] = 1; stride[1] = 1;
count[0] = 6; count[1] = 6;
block[0] = 1; block[1] = 1;
- ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block);
- assert(ret >= 0);
-
+ if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block) < 0)
+ goto out;
+
+
/* Store dataset region */
- ret = H5Rcreate(&wbuf[0], loc_id, "dsetreg", H5R_DATASET_REGION, sid2);
- assert(ret >= 0);
-
+ if (H5Rcreate(&wbuf[0], loc_id, "dsetreg", H5R_DATASET_REGION, sid2) < 0)
+ goto out;
+
/* Write selection to disk */
- ret=H5Dwrite(dset1,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf);
- assert(ret >= 0);
-
+ if (H5Dwrite(did1,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf) < 0)
+ goto out;
+
/* Close all objects */
- ret = H5Sclose(sid1);
- assert(ret >= 0);
- ret = H5Dclose(dset1);
- assert(ret >= 0);
- ret = H5Sclose(sid2);
- assert(ret >= 0);
-
- free(wbuf);
- free(dwbuf);
+ if (H5Sclose(sid1) < 0)
+ goto out;
+ if (H5Dclose(did1) < 0)
+ goto out;
+ if (H5Sclose(sid2) < 0)
+ goto out;
+ if (H5Dclose(did2) < 0)
+ goto out;
+
+ if (wbuf)
+ free(wbuf);
+ if (dwbuf)
+ free(dwbuf);
+
+ return 0;
+
+out:
+ H5E_BEGIN_TRY
+ {
+
+ H5Sclose(sid1);
+ H5Sclose(sid2);
+ H5Dclose(did1);
+ H5Dclose(did2);
+
+ } H5E_END_TRY;
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: write_attr_in
- *
- * Purpose: write attributes in LOC_ID (dataset, group, named datatype)
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 12, 2003
- *
- *-------------------------------------------------------------------------
- */
-
-
-void write_attr_in(hid_t loc_id,
+* Function: write_attr_in
+*
+* Purpose: write attributes in LOC_ID (dataset, group, named datatype)
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 12, 2003
+*
+*-------------------------------------------------------------------------
+*/
+
+
+int write_attr_in(hid_t loc_id,
const char* dset_name, /* for saving reference to dataset*/
hid_t fid, /* for reference create */
int make_diffs /* flag to modify data buffers */)
@@ -3841,20 +4087,19 @@ void write_attr_in(hid_t loc_id,
char a;
double b;
} s_t;
-
+
typedef enum
{
RED,
- GREEN
+ GREEN
} e_t;
-
- hid_t attr_id;
- hid_t space_id;
- hid_t type_id;
- herr_t status;
+
+ hid_t aid;
+ hid_t sid;
+ hid_t tid;
int val, i, j, k, n;
float f;
-
+
/* create 1D attributes with dimension [2], 2 elements */
hsize_t dims[1]={2};
char buf1[2][2]= {"ab","de"}; /* string */
@@ -3867,7 +4112,7 @@ void write_attr_in(hid_t loc_id,
int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */
int buf7[2]= {1,2}; /* integer */
float buf8[2]= {1,2}; /* float */
-
+
/* create 2D attributes with dimension [3][2], 6 elements */
hsize_t dims2[2]={3,2};
char buf12[6][2]= {"ab","cd","ef","gh","ij","kl"}; /* string */
@@ -3879,7 +4124,7 @@ void write_attr_in(hid_t loc_id,
int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */
int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */
float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */
-
+
/* create 3D attributes with dimension [4][3][2], 24 elements */
hsize_t dims3[3]={4,3,2};
char buf13[24][2]= {"ab","cd","ef","gh","ij","kl","mn","pq",
@@ -3893,18 +4138,18 @@ void write_attr_in(hid_t loc_id,
int buf63[24][3]; /* array */
int buf73[4][3][2]; /* integer */
float buf83[4][3][2]; /* float */
-
-
+
+
/*-------------------------------------------------------------------------
* 1D attributes
*-------------------------------------------------------------------------
*/
-
+
/*-------------------------------------------------------------------------
* H5T_STRING
*-------------------------------------------------------------------------
*/
-
+
if (make_diffs)
{
for (i=0; i<2; i++)
@@ -3925,16 +4170,20 @@ void write_attr_in(hid_t loc_id,
[ 1 ] d z
[ 1 ] e z
*/
- type_id = H5Tcopy(H5T_C_S1);
- status = H5Tset_size(type_id, (size_t)2);
- make_attr(loc_id,1,dims,"string",type_id,buf1);
- status = H5Tclose(type_id);
+ if ((tid = H5Tcopy(H5T_C_S1)) < 0)
+ goto out;
+ if (H5Tset_size(tid, (size_t)2) < 0)
+ goto out;
+ if (make_attr(loc_id,1,dims,"string",tid,buf1) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
/*-------------------------------------------------------------------------
* H5T_BITFIELD
*-------------------------------------------------------------------------
*/
-
+
if (make_diffs)
{
for (i=0; i<2; i++)
@@ -3952,15 +4201,18 @@ void write_attr_in(hid_t loc_id,
[ 1 ] 2 0 2
*/
- type_id = H5Tcopy(H5T_STD_B8LE);
- make_attr(loc_id,1,dims,"bitfield",type_id,buf2);
- status = H5Tclose(type_id);
-
+ if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0)
+ goto out;
+ if (make_attr(loc_id,1,dims,"bitfield",tid,buf2) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_OPAQUE
*-------------------------------------------------------------------------
*/
-
+
/*
buf2[2]= {1,2};
$h5diff file7.h5 file6.h5 g1 g1 -v
@@ -3972,17 +4224,21 @@ void write_attr_in(hid_t loc_id,
[ 0 ] 1 0 1
[ 1 ] 2 0 2
*/
-
- type_id = H5Tcreate(H5T_OPAQUE, (size_t)1);
- status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */
- make_attr(loc_id,1,dims,"opaque",type_id,buf2);
- status = H5Tclose(type_id);
-
+
+ if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0)
+ goto out;
+ if (H5Tset_tag(tid, "1-byte opaque type") < 0)
+ goto out;
+ if (make_attr(loc_id,1,dims,"opaque",tid,buf2) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_COMPOUND
*-------------------------------------------------------------------------
*/
-
+
if (make_diffs)
{
for (i=0; i<2; i++)
@@ -3990,7 +4246,7 @@ void write_attr_in(hid_t loc_id,
buf3[i].a=0; buf3[i].b=0;
}
}
-
+
/*
buf3[2]= {{1,2},{3,4}};
$h5diff file7.h5 file6.h5 g1 g1 -v
@@ -4003,13 +4259,18 @@ void write_attr_in(hid_t loc_id,
[ 1 ] 3 5 2
[ 1 ] 4 5 1
*/
-
- type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
- H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR);
- H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE);
- make_attr(loc_id,1,dims,"compound",type_id,buf3);
- status = H5Tclose(type_id);
-
+
+ if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0)
+ goto out;
+ if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0)
+ goto out;
+ if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0)
+ goto out;
+ if (make_attr(loc_id,1,dims,"compound",tid,buf3) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_REFERENCE
*-------------------------------------------------------------------------
@@ -4017,12 +4278,15 @@ void write_attr_in(hid_t loc_id,
/* object references ( H5R_OBJECT */
if (dset_name)
{
- status=H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,-1);
- status=H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,-1);
- make_attr(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4);
+ if (H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,-1) < 0)
+ goto out;
+ if (H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,-1) < 0)
+ goto out;
+ if (make_attr(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4) < 0)
+ goto out;
}
-
-
+
+
/*-------------------------------------------------------------------------
* H5T_ENUM
*-------------------------------------------------------------------------
@@ -4044,19 +4308,24 @@ void write_attr_in(hid_t loc_id,
[ 0 ] RED GREEN
[ 1 ] RED GREEN
*/
- type_id = H5Tcreate(H5T_ENUM, sizeof(e_t));
- H5Tenum_insert(type_id, "RED", (val = 0, &val));
- H5Tenum_insert(type_id, "GREEN", (val = 1, &val));
- make_attr(loc_id,1,dims,"enum",type_id,buf45);
- status = H5Tclose(type_id);
+ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0)
+ goto out;
+ if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0)
+ goto out;
+ if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0)
+ goto out;
+ if (make_attr(loc_id,1,dims,"enum",tid,buf45) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
/*-------------------------------------------------------------------------
* H5T_VLEN
*-------------------------------------------------------------------------
*/
-
+
/* Allocate and initialize VL dataset to write */
-
+
buf5[0].len = 1;
buf5[0].p = malloc( 1 * sizeof(int));
((int *)buf5[0].p)[0]=1;
@@ -4064,7 +4333,7 @@ void write_attr_in(hid_t loc_id,
buf5[1].p = malloc(2 * sizeof(int));
((int *)buf5[1].p)[0] = 2;
((int *)buf5[1].p)[1] = 3;
-
+
if(make_diffs)
{
((int *)buf5[0].p)[0] = 0;
@@ -4080,23 +4349,29 @@ void write_attr_in(hid_t loc_id,
[ 1 ] 2 0 2
[ 1 ] 3 0 3
*/
-
- space_id = H5Screate_simple(1, dims, NULL);
- type_id = H5Tvlen_create(H5T_NATIVE_INT);
- attr_id = H5Acreate2(loc_id, "vlen", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
- status = H5Awrite(attr_id, type_id, buf5);
- assert(status >= 0);
- status = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, buf5);
- assert(status >= 0);
- status = H5Aclose(attr_id);
- status = H5Tclose(type_id);
- status = H5Sclose(space_id);
-
+
+ if ((sid = H5Screate_simple(1, dims, NULL)) < 0)
+ goto out;
+ if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0)
+ goto out;
+ if ((aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5Awrite(aid, tid, buf5) < 0)
+ goto out;
+ if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5) < 0)
+ goto out;
+ if (H5Aclose(aid) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_ARRAY
*-------------------------------------------------------------------------
*/
-
+
if (make_diffs)
{
for (i=0; i<2; i++)
@@ -4119,15 +4394,18 @@ void write_attr_in(hid_t loc_id,
[ 1 ] 5 0 5
[ 1 ] 6 0 6
*/
- type_id = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray);
- make_attr(loc_id, 1, dims, "array", type_id, buf6);
- status = H5Tclose(type_id);
+ if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0)
+ goto out;
+ if (make_attr(loc_id, 1, dims, "array", tid, buf6) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
/*-------------------------------------------------------------------------
* H5T_INTEGER and H5T_FLOAT
*-------------------------------------------------------------------------
*/
-
+
if(make_diffs)
{
for(i = 0; i < 2; i++)
@@ -4136,7 +4414,7 @@ void write_attr_in(hid_t loc_id,
buf8[i]=0;
}
}
-
+
/*
buf7[2]= {1,2};
buf8[2]= {1,2};
@@ -4151,15 +4429,17 @@ void write_attr_in(hid_t loc_id,
[ 0 ] 1 0 1
[ 1 ] 2 0 2
*/
- make_attr(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7);
- make_attr(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8);
+ if (make_attr(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7) < 0)
+ goto out;
+ if (make_attr(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8) < 0)
+ goto out;
+
-
/*-------------------------------------------------------------------------
* 2D attributes
*-------------------------------------------------------------------------
*/
-
+
/*-------------------------------------------------------------------------
* H5T_STRING
*-------------------------------------------------------------------------
@@ -4168,7 +4448,7 @@ void write_attr_in(hid_t loc_id,
{
memset(buf12, 'z', sizeof buf12);
}
-
+
/*
buf12[6][2]= {"ab","cd","ef","gh","ij","kl"};
$h5diff file7.h5 file6.h5 g1 g1 -v
@@ -4188,22 +4468,26 @@ void write_attr_in(hid_t loc_id,
[ 2 1 ] k z
[ 2 1 ] l z
*/
-
- type_id = H5Tcopy(H5T_C_S1);
- status = H5Tset_size(type_id, (size_t)2);
- make_attr(loc_id,2,dims2,"string2D",type_id,buf12);
- status = H5Tclose(type_id);
-
+
+ if ((tid = H5Tcopy(H5T_C_S1)) < 0)
+ goto out;
+ if (H5Tset_size(tid, (size_t)2) < 0)
+ goto out;
+ if (make_attr(loc_id,2,dims2,"string2D",tid,buf12) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_BITFIELD
*-------------------------------------------------------------------------
*/
-
+
if (make_diffs)
{
memset(buf22,0,sizeof buf22);
}
-
+
/*
buf22[3][2]= {{1,2},{3,4},{5,6}};
$h5diff file7.h5 file6.h5 g1 g1 -v
@@ -4217,17 +4501,20 @@ void write_attr_in(hid_t loc_id,
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
*/
-
-
- type_id = H5Tcopy(H5T_STD_B8LE);
- make_attr(loc_id,2,dims2,"bitfield2D",type_id,buf22);
- status = H5Tclose(type_id);
-
+
+
+ if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0)
+ goto out;
+ if (make_attr(loc_id,2,dims2,"bitfield2D",tid,buf22) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_OPAQUE
*-------------------------------------------------------------------------
*/
-
+
/*
buf22[3][2]= {{1,2},{3,4},{5,6}};
$h5diff file7.h5 file6.h5 g1 g1 -v
@@ -4241,11 +4528,15 @@ void write_attr_in(hid_t loc_id,
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
*/
- type_id = H5Tcreate(H5T_OPAQUE, (size_t)1);
- status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */
- make_attr(loc_id,2,dims2,"opaque2D",type_id,buf22);
- status = H5Tclose(type_id);
-
+ if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0)
+ goto out;
+ if (H5Tset_tag(tid, "1-byte opaque type") < 0)
+ goto out;
+ if (make_attr(loc_id,2,dims2,"opaque2D",tid,buf22) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_COMPOUND
*-------------------------------------------------------------------------
@@ -4254,7 +4545,7 @@ void write_attr_in(hid_t loc_id,
{
memset(buf32,0,sizeof buf32);
}
-
+
/*
buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}};
$h5diff file7.h5 file6.h5 g1 g1 -v
@@ -4268,14 +4559,19 @@ void write_attr_in(hid_t loc_id,
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
*/
-
-
- type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
- H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR);
- H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE);
- make_attr(loc_id,2,dims2,"compound2D",type_id,buf32);
- status = H5Tclose(type_id);
-
+
+
+ if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0)
+ goto out;
+ if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0)
+ goto out;
+ if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0)
+ goto out;
+ if (make_attr(loc_id,2,dims2,"compound2D",tid,buf32) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_REFERENCE
*-------------------------------------------------------------------------
@@ -4287,12 +4583,14 @@ void write_attr_in(hid_t loc_id,
{
for (j = 0; j < 2; j++)
{
- status=H5Rcreate(&buf42[i][j],fid,dset_name,H5R_OBJECT,-1);
+ if (H5Rcreate(&buf42[i][j],fid,dset_name,H5R_OBJECT,-1) < 0)
+ goto out;
}
}
- make_attr(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42);
+ if (make_attr(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42) < 0)
+ goto out;
}
-
+
/*-------------------------------------------------------------------------
* H5T_ENUM
*-------------------------------------------------------------------------
@@ -4304,7 +4602,7 @@ void write_attr_in(hid_t loc_id,
if (make_diffs) buf452[i][j]=GREEN; else buf452[i][j]=RED;
}
}
-
+
/*
Attribute: <enum2D> and <enum2D>
position enum2D of </g1> enum2D of </g1> difference
@@ -4316,18 +4614,23 @@ void write_attr_in(hid_t loc_id,
[ 2 0 ] RED GREEN
[ 2 1 ] RED GREEN
*/
-
- type_id = H5Tcreate(H5T_ENUM, sizeof(e_t));
- H5Tenum_insert(type_id, "RED", (val = 0, &val));
- H5Tenum_insert(type_id, "GREEN", (val = 1, &val));
- make_attr(loc_id,2,dims2,"enum2D",type_id,buf452);
- status = H5Tclose(type_id);
-
+
+ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0)
+ goto out;
+ if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0)
+ goto out;
+ if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0)
+ goto out;
+ if (make_attr(loc_id,2,dims2,"enum2D",tid,buf452) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_VLEN
*-------------------------------------------------------------------------
*/
-
+
/* Allocate and initialize VL dataset to write */
n=0;
for (i = 0; i < 3; i++)
@@ -4342,7 +4645,7 @@ void write_attr_in(hid_t loc_id,
else ((int *)buf52[i][j].p)[l] = n++;
}
}
-
+
/*
position vlen2D of </g1> vlen2D of </g1> difference
------------------------------------------------------------
@@ -4358,23 +4661,29 @@ void write_attr_in(hid_t loc_id,
[ 2 1 ] 10 0 10
[ 2 1 ] 11 0 11
*/
-
- space_id = H5Screate_simple(2, dims2, NULL);
- type_id = H5Tvlen_create(H5T_NATIVE_INT);
- attr_id = H5Acreate2(loc_id, "vlen2D", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
- status = H5Awrite(attr_id, type_id, buf52);
- assert(status >= 0);
- status = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, buf52);
- assert(status >= 0);
- status = H5Aclose(attr_id);
- status = H5Tclose(type_id);
- status = H5Sclose(space_id);
-
+
+ if ((sid = H5Screate_simple(2, dims2, NULL)) < 0)
+ goto out;
+ if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0)
+ goto out;
+ if ((aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5Awrite(aid, tid, buf52) < 0)
+ goto out;
+ if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52) < 0)
+ goto out;
+ if (H5Aclose(aid) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_ARRAY
*-------------------------------------------------------------------------
*/
-
+
if (make_diffs)
{
memset(buf62,0,sizeof buf62);
@@ -4405,15 +4714,18 @@ void write_attr_in(hid_t loc_id,
[ 2 1 ] 17 0 17
[ 2 1 ] 18 0 18
*/
- type_id = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray);
- make_attr(loc_id, 2, dims2, "array2D", type_id, buf62);
- status = H5Tclose(type_id);
-
+ if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0)
+ goto out;
+ if (make_attr(loc_id, 2, dims2, "array2D", tid, buf62) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_INTEGER and H5T_FLOAT
*-------------------------------------------------------------------------
*/
-
+
if(make_diffs)
{
HDmemset(buf72, 0, sizeof buf72);
@@ -4440,93 +4752,99 @@ void write_attr_in(hid_t loc_id,
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
*/
-
- make_attr(loc_id,2,dims2,"integer2D",H5T_NATIVE_INT,buf72);
- make_attr(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82);
-
-
+
+ if (make_attr(loc_id,2,dims2,"integer2D",H5T_NATIVE_INT,buf72) < 0)
+ goto out;
+ if (make_attr(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82) < 0)
+ goto out;
+
+
/*-------------------------------------------------------------------------
* 3D attributes
*-------------------------------------------------------------------------
*/
-
+
/*-------------------------------------------------------------------------
* H5T_STRING
*-------------------------------------------------------------------------
*/
-
+
if (make_diffs)
{
memset(buf13,'z',sizeof buf13);
}
-
+
/*
buf13[24][2]= {"ab","cd","ef","gh","ij","kl","mn","pq",
"rs","tu","vw","xz","AB","CD","EF","GH",
"IJ","KL","MN","PQ","RS","TU","VW","XZ"};
-
- Attribute: <string3D> and <string3D>
- position string3D of </g1> string3D of </g1> difference
- ------------------------------------------------------------
- [ 0 0 0 ] a z
- [ 0 0 0 ] b z
- [ 0 0 1 ] c z
- [ 0 0 1 ] d z
- [ 0 1 0 ] e z
- [ 0 1 0 ] f z
- [ 0 1 1 ] g z
- [ 0 1 1 ] h z
- [ 0 2 0 ] i z
- [ 0 2 0 ] j z
- [ 0 2 1 ] k z
- [ 0 2 1 ] l z
- [ 1 0 0 ] m z
- [ 1 0 0 ] n z
- [ 1 0 1 ] p z
- [ 1 0 1 ] q z
- [ 1 1 0 ] r z
- [ 1 1 0 ] s z
- [ 1 1 1 ] t z
- [ 1 1 1 ] u z
- [ 1 2 0 ] v z
- [ 1 2 0 ] w z
- [ 1 2 1 ] x z
- [ 2 0 0 ] A z
- [ 2 0 0 ] B z
- [ 2 0 1 ] C z
- [ 2 0 1 ] D z
- [ 2 1 0 ] E z
- [ 2 1 0 ] F z
- [ 2 1 1 ] G z
- [ 2 1 1 ] H z
- [ 2 2 0 ] I z
- [ 2 2 0 ] J z
- [ 2 2 1 ] K z
- [ 2 2 1 ] L z
- [ 3 0 0 ] M z
- [ 3 0 0 ] N z
- [ 3 0 1 ] P z
- [ 3 0 1 ] Q z
- [ 3 1 0 ] R z
- [ 3 1 0 ] S z
- [ 3 1 1 ] T z
- [ 3 1 1 ] U z
- [ 3 2 0 ] V z
- [ 3 2 0 ] W z
- [ 3 2 1 ] X z
- [ 3 2 1 ] Z z
- */
-
- type_id = H5Tcopy(H5T_C_S1);
- status = H5Tset_size(type_id, (size_t)2);
- make_attr(loc_id,3,dims3,"string3D",type_id,buf13);
- status = H5Tclose(type_id);
-
+
+ Attribute: <string3D> and <string3D>
+ position string3D of </g1> string3D of </g1> difference
+ ------------------------------------------------------------
+ [ 0 0 0 ] a z
+ [ 0 0 0 ] b z
+ [ 0 0 1 ] c z
+ [ 0 0 1 ] d z
+ [ 0 1 0 ] e z
+ [ 0 1 0 ] f z
+ [ 0 1 1 ] g z
+ [ 0 1 1 ] h z
+ [ 0 2 0 ] i z
+ [ 0 2 0 ] j z
+ [ 0 2 1 ] k z
+ [ 0 2 1 ] l z
+ [ 1 0 0 ] m z
+ [ 1 0 0 ] n z
+ [ 1 0 1 ] p z
+ [ 1 0 1 ] q z
+ [ 1 1 0 ] r z
+ [ 1 1 0 ] s z
+ [ 1 1 1 ] t z
+ [ 1 1 1 ] u z
+ [ 1 2 0 ] v z
+ [ 1 2 0 ] w z
+ [ 1 2 1 ] x z
+ [ 2 0 0 ] A z
+ [ 2 0 0 ] B z
+ [ 2 0 1 ] C z
+ [ 2 0 1 ] D z
+ [ 2 1 0 ] E z
+ [ 2 1 0 ] F z
+ [ 2 1 1 ] G z
+ [ 2 1 1 ] H z
+ [ 2 2 0 ] I z
+ [ 2 2 0 ] J z
+ [ 2 2 1 ] K z
+ [ 2 2 1 ] L z
+ [ 3 0 0 ] M z
+ [ 3 0 0 ] N z
+ [ 3 0 1 ] P z
+ [ 3 0 1 ] Q z
+ [ 3 1 0 ] R z
+ [ 3 1 0 ] S z
+ [ 3 1 1 ] T z
+ [ 3 1 1 ] U z
+ [ 3 2 0 ] V z
+ [ 3 2 0 ] W z
+ [ 3 2 1 ] X z
+ [ 3 2 1 ] Z z
+ */
+
+ if ((tid = H5Tcopy(H5T_C_S1)) < 0)
+ goto out;
+ if (H5Tset_size(tid, (size_t)2) < 0)
+ goto out;
+ if (make_attr(loc_id,3,dims3,"string3D",tid,buf13) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_BITFIELD
*-------------------------------------------------------------------------
*/
-
+
n=1;
for (i = 0; i < 4; i++)
{
@@ -4539,7 +4857,7 @@ void write_attr_in(hid_t loc_id,
}
}
}
-
+
/*
position bitfield3D of </g1> bitfield3D of </g1> difference
------------------------------------------------------------
@@ -4568,25 +4886,32 @@ void write_attr_in(hid_t loc_id,
[ 3 2 0 ] 23 0 23
[ 3 2 1 ] 24 0 24
*/
-
- type_id = H5Tcopy(H5T_STD_B8LE);
- make_attr(loc_id,3,dims3,"bitfield3D",type_id,buf23);
- status = H5Tclose(type_id);
-
+
+ if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0)
+ goto out;
+ if (make_attr(loc_id,3,dims3,"bitfield3D",tid,buf23) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_OPAQUE
*-------------------------------------------------------------------------
*/
- type_id = H5Tcreate(H5T_OPAQUE, (size_t)1);
- status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */
- make_attr(loc_id,3,dims3,"opaque3D",type_id,buf23);
- status = H5Tclose(type_id);
-
+ if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0)
+ goto out;
+ if (H5Tset_tag(tid, "1-byte opaque type") < 0)
+ goto out;
+ if (make_attr(loc_id,3,dims3,"opaque3D",tid,buf23) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_COMPOUND
*-------------------------------------------------------------------------
*/
-
+
n=1;
for (i = 0; i < 4; i++)
{
@@ -4658,15 +4983,20 @@ void write_attr_in(hid_t loc_id,
[ 3 2 1 ] 47 0 47
[ 3 2 1 ] 48 0 48
*/
-
-
-
- type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
- H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR);
- H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE);
- make_attr(loc_id,3,dims3,"compound3D",type_id,buf33);
- status = H5Tclose(type_id);
-
+
+
+
+ if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0)
+ goto out;
+ if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0)
+ goto out;
+ if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0)
+ goto out;
+ if (make_attr(loc_id,3,dims3,"compound3D",tid,buf33) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_REFERENCE
*-------------------------------------------------------------------------
@@ -4679,17 +5009,19 @@ void write_attr_in(hid_t loc_id,
for (j = 0; j < 3; j++)
{
for (k = 0; k < 2; k++)
- status=H5Rcreate(&buf43[i][j][k],fid,dset_name,H5R_OBJECT,-1);
+ if (H5Rcreate(&buf43[i][j][k],fid,dset_name,H5R_OBJECT,-1) < 0)
+ goto out;
}
}
- make_attr(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43);
+ if (make_attr(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43) < 0)
+ goto out;
}
-
+
/*-------------------------------------------------------------------------
* H5T_ENUM
*-------------------------------------------------------------------------
*/
-
+
for (i = 0; i < 4; i++)
{
for (j = 0; j < 3; j++)
@@ -4707,7 +5039,7 @@ void write_attr_in(hid_t loc_id,
}
}
}
-
+
/*
position enum3D of </g1> enum3D of </g1> difference
------------------------------------------------------------
@@ -4736,19 +5068,24 @@ void write_attr_in(hid_t loc_id,
[ 3 2 0 ] GREEN RED
[ 3 2 1 ] GREEN RED
*/
-
-
- type_id = H5Tcreate(H5T_ENUM, sizeof(e_t));
- H5Tenum_insert(type_id, "RED", (val = 0, &val));
- H5Tenum_insert(type_id, "GREEN", (val = 1, &val));
- make_attr(loc_id,3,dims3,"enum3D",type_id,buf453);
- status = H5Tclose(type_id);
-
+
+
+ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0)
+ goto out;
+ if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0)
+ goto out;
+ if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0)
+ goto out;
+ if (make_attr(loc_id,3,dims3,"enum3D",tid,buf453) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_VLEN
*-------------------------------------------------------------------------
*/
-
+
/* Allocate and initialize VL dataset to write */
n=0;
for (i = 0; i < 4; i++)
@@ -4785,17 +5122,23 @@ void write_attr_in(hid_t loc_id,
[ 1 1 0 ] 10 0 10
etc
*/
- space_id = H5Screate_simple(3, dims3, NULL);
- type_id = H5Tvlen_create(H5T_NATIVE_INT);
- attr_id = H5Acreate2(loc_id, "vlen3D", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
- status = H5Awrite(attr_id, type_id, buf53);
- assert(status >= 0);
- status = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, buf53);
- assert(status >= 0);
- status = H5Aclose(attr_id);
- status = H5Tclose(type_id);
- status = H5Sclose(space_id);
-
+ if ((sid = H5Screate_simple(3, dims3, NULL)) < 0)
+ goto out;
+ if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0)
+ goto out;
+ if ((aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5Awrite(aid, tid, buf53) < 0)
+ goto out;
+ if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53) < 0)
+ goto out;
+ if (H5Aclose(aid) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_ARRAY
*-------------------------------------------------------------------------
@@ -4821,11 +5164,14 @@ void write_attr_in(hid_t loc_id,
[ 0 1 0 ] 7 0 7
etc
*/
-
- type_id = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray);
- make_attr(loc_id, 3, dims3, "array3D", type_id, buf63);
- status = H5Tclose(type_id);
-
+
+ if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0)
+ goto out;
+ if (make_attr(loc_id, 3, dims3, "array3D", tid, buf63) < 0)
+ goto out;
+ if (H5Tclose(tid) < 0)
+ goto out;
+
/*-------------------------------------------------------------------------
* H5T_INTEGER and H5T_FLOAT
*-------------------------------------------------------------------------
@@ -4850,7 +5196,7 @@ void write_attr_in(hid_t loc_id,
}
}
}
-
+
/*
position integer3D of </g1> integer3D of </g1> difference
------------------------------------------------------------
@@ -4866,144 +5212,153 @@ void write_attr_in(hid_t loc_id,
[ 1 1 1 ] 10 0 10
etc
*/
- make_attr(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73);
- make_attr(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83);
+ if (make_attr(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73) < 0)
+ goto out;
+ if (make_attr(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83) < 0)
+ goto out;
+
+
+ return 0;
+
+out:
+ H5E_BEGIN_TRY
+ {
+ H5Aclose(aid);
+ H5Sclose(sid);
+ H5Tclose(tid);
+ } H5E_END_TRY;
+ return -1;
}
+
/*-------------------------------------------------------------------------
- * Function: make_dset
- *
- * Purpose: utility function to create and write a dataset in LOC_ID
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 12, 2003
- *
- *-------------------------------------------------------------------------
- */
+* Function: make_dset
+*
+* Purpose: utility function to create and write a dataset in LOC_ID
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 12, 2003
+*
+*-------------------------------------------------------------------------
+*/
int make_dset(hid_t loc_id,
const char *name,
hid_t sid,
hid_t dcpl,
void *buf)
{
- hid_t dsid;
+ hid_t did=-1;
- /* create the dataset */
- if((dsid = H5Dcreate2(loc_id, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ if ((did = H5Dcreate2(loc_id, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
return -1;
-
- /* write */
- if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
goto out;
-
- /* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(did) < 0)
return -1;
-
return 0;
out:
H5E_BEGIN_TRY {
- H5Dclose(dsid);
+ H5Dclose(did);
} H5E_END_TRY;
return -1;
}
/*-------------------------------------------------------------------------
- * Function: write_dset
- *
- * Purpose: utility function to create and write a dataset in LOC_ID
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 12, 2003
- *
- *-------------------------------------------------------------------------
- */
+* Function: write_dset
+*
+* Purpose: utility function to create and write a dataset in LOC_ID
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 12, 2003
+*
+*-------------------------------------------------------------------------
+*/
int write_dset( hid_t loc_id,
- int rank,
- hsize_t *dims,
- const char *dset_name,
- hid_t type_id,
- void *buf )
+ int rank,
+ hsize_t *dims,
+ const char *dset_name,
+ hid_t tid,
+ void *buf )
{
- hid_t dset_id;
- hid_t space_id;
-
- /* Create a buf space */
- if((space_id = H5Screate_simple(rank, dims, NULL)) < 0)
- return -1;
-
- /* Create a dataset */
- if((dset_id = H5Dcreate2(loc_id, dset_name, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- return -1;
-
- /* Write the buf */
- if(buf)
- if(H5Dwrite(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- return -1;
+ hid_t did=-1;
+ hid_t sid=-1;
- /* Close */
- if(H5Dclose(dset_id) < 0)
- return -1;
- if(H5Sclose(space_id) < 0)
+ if ((sid = H5Screate_simple(rank, dims, NULL)) < 0)
return -1;
+ if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if (buf)
+ {
+ if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ goto out;
+ }
+ if (H5Dclose(did) < 0)
+ goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
return 0;
+
+out:
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ H5Sclose(sid);
+ } H5E_END_TRY;
+ return -1;
}
+
/*-------------------------------------------------------------------------
- * Function: write_attr
- *
- * Purpose: utility function to write an attribute in LOC_ID
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 12, 2003
- *
- *-------------------------------------------------------------------------
- */
+* Function: write_attr
+*
+* Purpose: utility function to write an attribute in LOC_ID
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 12, 2003
+*
+*-------------------------------------------------------------------------
+*/
int make_attr(hid_t loc_id,
- int rank,
- hsize_t *dims,
- const char *attr_name,
- hid_t type_id,
- void *buf)
+ int rank,
+ hsize_t *dims,
+ const char *attr_name,
+ hid_t tid,
+ void *buf)
{
- hid_t attr_id;
- hid_t space_id;
-
- /* create a space */
- if((space_id = H5Screate_simple(rank, dims, NULL)) < 0)
- return -1;
+ hid_t aid;
+ hid_t sid;
- /* create the attribute */
- if((attr_id = H5Acreate2(loc_id, attr_name, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto out;
-
- /* write the buffer */
- if(buf)
- if(H5Awrite(attr_id, type_id, buf) < 0)
- goto out;
-
- /* close */
- H5Aclose(attr_id);
- H5Sclose(space_id);
- return 0;
+ if ((sid = H5Screate_simple(rank, dims, NULL)) < 0)
+ return -1;
+ if ((aid = H5Acreate2(loc_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ if(buf)
+ {
+ if(H5Awrite(aid, tid, buf) < 0)
+ goto out;
+ }
+ if (H5Aclose(aid) < 0)
+ goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+ return 0;
out:
- H5E_BEGIN_TRY {
- H5Aclose(attr_id);
- H5Sclose(space_id);
- } H5E_END_TRY;
- return -1;
+ H5E_BEGIN_TRY {
+ H5Aclose(aid);
+ H5Sclose(sid);
+ } H5E_END_TRY;
+ return -1;
}