summaryrefslogtreecommitdiffstats
path: root/tools/h5diff
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5diff')
-rw-r--r--tools/h5diff/Makefile.in9
-rw-r--r--tools/h5diff/h5diff_main.c47
-rw-r--r--tools/h5diff/testh5diff.h54
-rwxr-xr-xtools/h5diff/testh5diff.sh86
-rw-r--r--tools/h5diff/testh5diff_attr.c1088
-rw-r--r--tools/h5diff/testh5diff_basic.c (renamed from tools/h5diff/test_h5diff.c)366
-rw-r--r--tools/h5diff/testh5diff_dset.c683
-rw-r--r--tools/h5diff/testh5diff_main.c36
-rw-r--r--tools/h5diff/testh5diff_util.c99
9 files changed, 2060 insertions, 408 deletions
diff --git a/tools/h5diff/Makefile.in b/tools/h5diff/Makefile.in
index 3726718..a616658 100644
--- a/tools/h5diff/Makefile.in
+++ b/tools/h5diff/Makefile.in
@@ -49,11 +49,12 @@ MOSTLYCLEAN=*.h5
## Source and object files for programs...
##
-PROG_SRC= h5diff_main.c test_h5diff.c
+PROG_SRC= h5diff_main.c testh5diff_attr.c testh5diff_basic.c testh5diff_dset.c testh5diff_util.c testh5diff_main.c
PROG_OBJ=$(PROG_SRC:.c=.lo)
OBJS= h5diff_main.lo
+TEST_OBJS=testh5diff_attr.lo testh5diff_basic.lo testh5diff_dset.lo testh5diff_util.lo testh5diff_main.lo
-PRIVATE_HDR=
+PRIVATE_HDR=testh5diff.h
## Source and object files for the tests
##
@@ -72,8 +73,8 @@ $(PROGS): $(LIBTOOLS) $(LIBHDF5)
h5diff: $(OBJS)
@$(LT_LINK_EXE) $(CFLAGS) -o $@ $(OBJS) $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS)
-h5difftst: test_h5diff.lo
- @$(LT_LINK_EXE) $(CFLAGS) -o $@ test_h5diff.lo $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS)
+h5difftst: $(TEST_OBJS)
+ @$(LT_LINK_EXE) $(CFLAGS) -o $@ $(TEST_OBJS) $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS)
@CONCLUDE@
diff --git a/tools/h5diff/h5diff_main.c b/tools/h5diff/h5diff_main.c
index 2ac3703..58fc9a9 100644
--- a/tools/h5diff/h5diff_main.c
+++ b/tools/h5diff/h5diff_main.c
@@ -19,7 +19,7 @@
/* Due to alignment issue in Alpha clusters, options must be declared here
* not as a local variable in main().
*/
-diff_opt_t options = {0,0,0,0,0,0,0,0,0};
+diff_opt_t options = {0,0,0,0,0,0,0,0};
static void usage(void);
static int check_n_input( const char* );
@@ -56,19 +56,6 @@ int main(int argc, const char *argv[])
int nfound=0, ret;
/*-------------------------------------------------------------------------
- * print the command line options
- *-------------------------------------------------------------------------
- */
-
- printf("$h5diff");
- for (i=1; i<argc ; i++)
- {
- printf(" %s", argv[i] );
- }
- printf("\n");
-
-
-/*-------------------------------------------------------------------------
* initial check of command line options
*-------------------------------------------------------------------------
*/
@@ -116,9 +103,7 @@ int main(int argc, const char *argv[])
case 'v':
options.verbose = 1;
break;
- case 'a':
- options.attr = 1;
- break;
+ break;
case 'r':
options.r = 1;
break;
@@ -172,7 +157,9 @@ int main(int argc, const char *argv[])
{
/* check if it is not a -d, -p parameter */
- if ( '-' !=argv[i-1][0] )
+ if ( '-'==argv[i-1][0] && ('d'==argv[i-1][1] ||'p'==argv[i-1][1] ))
+ continue;
+ else
{
if ( objname1==NULL )
objname1 = argv[i];
@@ -185,11 +172,28 @@ int main(int argc, const char *argv[])
else
/* no */
objname2 = objname1;
- }
- }
- }
+ } /*objname2*/
+ } /*else*/
+ } /*else*/
}/*for*/
+
+
+/*-------------------------------------------------------------------------
+ * print the command line options
+ *-------------------------------------------------------------------------
+ */
+
+ if (options.verbose)
+ {
+ printf("$h5diff");
+ for (i=1; i<argc ; i++)
+ {
+ printf(" %s", argv[i] );
+ }
+ printf("\n");
+ }
+
nfound = h5diff(fname1,fname2,objname1,objname2,&options);
@@ -307,7 +311,6 @@ void usage(void)
printf("[-n count] Print difference up to count number\n");
printf("[-d delta] Print difference when it is greater than limit delta\n");
printf("[-p relative] Print difference when it is greater than a relative limit\n");
- printf("[-a] Compare attributes\n");
printf("\n");
printf("Items in [] are optional\n");
printf("[obj1] and [obj2] are HDF5 objects (datasets, groups or datatypes)\n");
diff --git a/tools/h5diff/testh5diff.h b/tools/h5diff/testh5diff.h
new file mode 100644
index 0000000..5d9a651
--- /dev/null
+++ b/tools/h5diff/testh5diff.h
@@ -0,0 +1,54 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include "hdf5.h"
+#include "H5private.h"
+
+
+int test_basic(const char *file1,
+ const char *file2);
+
+int test_types(const char *file1,
+ const char *file2);
+
+int test_native(const char *file1,
+ const char *file2);
+
+
+int test_dsetall(const char *file,
+ int make_diffs /* flag to modify data buffers */);
+
+int test_attr(const char *file,
+ int make_diffs /* flag to modify data buffers */);
+
+
+int write_attr(hid_t loc_id,
+ int rank,
+ hsize_t *dims,
+ const char *attr_name,
+ hid_t type_id,
+ void *buf);
+
+
+int write_dset( hid_t loc_id,
+ int rank,
+ hsize_t *dims,
+ const char *dset_name,
+ hid_t type_id,
+ void *buf );
+
+
diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh
index 59d52cd..23cbfaa 100755
--- a/tools/h5diff/testh5diff.sh
+++ b/tools/h5diff/testh5diff.sh
@@ -103,7 +103,7 @@ TOOLTEST() {
TOOLTEST h5diff_10.txt -h
# 1.1
-TOOLTEST h5diff_11.txt file6.h5 file6.h5 -v dset3a dset3b
+TOOLTEST h5diff_11.txt file1.h5 file2.h5 g1/dset1 g1/dset2
# 1.2
TOOLTEST h5diff_12.txt file1.h5 file2.h5 -v -n 2 g1/dset1 g1/dset2
@@ -118,7 +118,7 @@ TOOLTEST h5diff_14.txt file1.h5 file2.h5 -v -p 0.05 g1/dset3 g1/dset4
TOOLTEST h5diff_15.txt file1.h5 file2.h5 -v -r g1/dset1 g1/dset2
# 1.6
-TOOLTEST h5diff_16.txt file6.h5 file6.h5
+TOOLTEST h5diff_16.txt file1.h5 file2.h5
# ##############################################################################
# # not comparable types
@@ -142,82 +142,37 @@ TOOLTEST h5diff_24.txt file3.h5 file3.h5 -v type type
# 2.5
TOOLTEST h5diff_25.txt file3.h5 file3.h5 -v link link
-# ##############################################################################
-# # Class issues
-# ##############################################################################
-
-
-# 3.0
-TOOLTEST h5diff_30.txt file4.h5 file4.h5 -v string
-
-# 3.1
-TOOLTEST h5diff_31.txt file4.h5 file4.h5 -v bitfield
-
-# 3.2
-TOOLTEST h5diff_32.txt file4.h5 file4.h5 -v opaque
-
-# 3.3
-TOOLTEST h5diff_33.txt file4.h5 file4.h5 -v compound
-
-# 3.4
-TOOLTEST h5diff_34.txt file4.h5 file4.h5 -v ref
-
-# 3.5
-TOOLTEST h5diff_35.txt file4.h5 file4.h5 -v enum
-
-# 3.6
-TOOLTEST h5diff_36.txt file4.h5 file4.h5 -v vlen
-
-# 3.7
-TOOLTEST h5diff_37.txt file4.h5 file4.h5 -v array
-
-# 3.8
-TOOLTEST h5diff_38.txt file4.h5 file4.h5 -v integer float
-
-# ##############################################################################
-# # Dimensions
-# ##############################################################################
-
-# 4.0
-TOOLTEST h5diff_40.txt file5.h5 file5.h5 -v dset1 dset2
-
-# 4.1
-TOOLTEST h5diff_41.txt file5.h5 file5.h5 -v dset3 dset4
-
-# 4.2
-TOOLTEST h5diff_42.txt file5.h5 file5.h5 -v dset5 dset6
-
# ##############################################################################
# # Dataset types
# ##############################################################################
# 5.0
-TOOLTEST h5diff_50.txt file6.h5 file6.h5 -v dset0a dset0b
+TOOLTEST h5diff_50.txt file4.h5 file4.h5 -v dset0a dset0b
# 5.1
-TOOLTEST h5diff_51.txt file6.h5 file6.h5 -v dset1a dset1b
+TOOLTEST h5diff_51.txt file4.h5 file4.h5 -v dset1a dset1b
# 5.2
-TOOLTEST h5diff_52.txt file6.h5 file6.h5 -v dset2a dset2b
+TOOLTEST h5diff_52.txt file4.h5 file4.h5 -v dset2a dset2b
# 5.3
-TOOLTEST h5diff_53.txt file6.h5 file6.h5 -v dset3a dset4b
+TOOLTEST h5diff_53.txt file4.h5 file4.h5 -v dset3a dset4b
# 5.4
-TOOLTEST h5diff_54.txt file6.h5 file6.h5 -v dset4a dset4b
+TOOLTEST h5diff_54.txt file4.h5 file4.h5 -v dset4a dset4b
# 5.5
-TOOLTEST h5diff_55.txt file6.h5 file6.h5 -v dset5a dset5b
+TOOLTEST h5diff_55.txt file4.h5 file4.h5 -v dset5a dset5b
# 5.6
-TOOLTEST h5diff_56.txt file6.h5 file6.h5 -v dset6a dset6b
+TOOLTEST h5diff_56.txt file4.h5 file4.h5 -v dset6a dset6b
# 5.7
-TOOLTEST h5diff_57.txt file6.h5 file6.h5 -v dset7a dset7b
+TOOLTEST h5diff_57.txt file4.h5 file4.h5 -v dset7a dset7b
# 5.8 long_long test; different format of long_long print in Linux and IRIX
-#TOOLTEST h5diff_58.txt file6.h5 file6.h5 dset8a dset8b
+#TOOLTEST h5diff_58.txt file4.h5 file4.h5 dset8a dset8b
# ##############################################################################
# # Error messages
@@ -334,6 +289,25 @@ TOOLTEST h5diff_628.txt file1.h5 file2.h5 -n 1 g1/dset3 g1/dset4
TOOLTEST h5diff_629.txt file1.h6 file2.h6
+# ##############################################################################
+# # attributes
+# ##############################################################################
+
+TOOLTEST h5diff_70.txt file5.h5 file6.h5
+
+# ##############################################################################
+# # all dataset datatypes
+# ##############################################################################
+
+TOOLTEST h5diff_80.txt file7.h5 file8.h5
+
+
+
+
+
+
+
+
# ##############################################################################
# # END
diff --git a/tools/h5diff/testh5diff_attr.c b/tools/h5diff/testh5diff_attr.c
new file mode 100644
index 0000000..5124792
--- /dev/null
+++ b/tools/h5diff/testh5diff_attr.c
@@ -0,0 +1,1088 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#include "testh5diff.h"
+
+
+
+/*-------------------------------------------------------------------------
+ * 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,
+ const char* dset_name, /* for saving reference to dataset*/
+ hid_t file_id,
+ int make_diffs /* flag to modify data buffers */)
+{
+ /* Compound datatype */
+ typedef struct s_t
+ {
+ char a;
+ double b;
+ } s_t;
+
+ typedef enum
+ {
+ RED,
+ GREEN
+ } e_t;
+
+ hid_t attr_id;
+ hid_t space_id;
+ hid_t type_id;
+ herr_t status;
+ 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 */
+ char buf2[2]= {1,2}; /* bitfield, opaque */
+ s_t buf3[2]= {{1,2},{3,4}}; /* compound */
+ hobj_ref_t buf4[2]; /* reference */
+ e_t buf45[2]= {RED,RED}; /* enum */
+ hvl_t buf5[2]; /* vlen */
+ hsize_t dimarray[1]={3}; /* array dimension */
+ 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 */
+ char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */
+ s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */
+ hobj_ref_t buf42[3][2]; /* reference */
+ e_t buf452[3][2]; /* enum */
+ hvl_t buf52[3][2]; /* vlen */
+ 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",
+ "rs","tu","vw","xz","AB","CD","EF","GH",
+ "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */
+ char buf23[4][3][2]; /* bitfield, opaque */
+ s_t buf33[4][3][2]; /* compound */
+ hobj_ref_t buf43[4][3][2]; /* reference */
+ e_t buf453[4][3][2]; /* enum */
+ hvl_t buf53[4][3][2]; /* vlen */
+ 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++)
+ for (j=0; j<2; j++)
+ {
+ buf1[i][j]='z';
+ }
+ }
+ /*
+ buf1[2][2]= {"ab","de"};
+ $h5diff file7.h5 file6.h5 g1 g1 -v
+ Group: </g1> and </g1>
+ Attribute: <string> and <string>
+ position string of </g1> string of </g1> difference
+ ------------------------------------------------------------
+[ 0 ] a z
+[ 0 ] b z
+[ 1 ] d z
+[ 1 ] e z
+ */
+ type_id = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(type_id, 2);
+ write_attr(loc_id,1,dims,"string",type_id,buf1);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_BITFIELD
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ for (i=0; i<2; i++)
+ buf2[i]=buf2[1]=0;
+ }
+ /*
+ buf2[2]= {1,2};
+ $h5diff file7.h5 file6.h5 g1 g1 -v
+ Group: </g1> and </g1>
+ Attribute: <bitfield> and <bitfield>
+ position bitfield of </g1> bitfield of </g1> difference
+ position opaque of </g1> opaque of </g1> difference
+------------------------------------------------------------
+[ 0 ] 1 0 1
+[ 1 ] 2 0 2
+ */
+
+ type_id = H5Tcopy(H5T_STD_B8LE);
+ write_attr(loc_id,1,dims,"bitfield",type_id,buf2);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_OPAQUE
+ *-------------------------------------------------------------------------
+ */
+
+ /*
+ buf2[2]= {1,2};
+ $h5diff file7.h5 file6.h5 g1 g1 -v
+ Group: </g1> and </g1>
+ Attribute: <opaque> and <opaque>
+ position opaque of </g1> opaque of </g1> difference
+ position opaque of </g1> opaque of </g1> difference
+------------------------------------------------------------
+[ 0 ] 1 0 1
+[ 1 ] 2 0 2
+*/
+
+ type_id = H5Tcreate(H5T_OPAQUE, 1);
+ status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */
+ write_attr(loc_id,1,dims,"opaque",type_id,buf2);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_COMPOUND
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ for (i=0; i<2; i++)
+ {
+ buf3[i].a=0; buf3[i].b=0;
+ }
+ }
+
+ /*
+ buf3[2]= {{1,2},{3,4}};
+ $h5diff file7.h5 file6.h5 g1 g1 -v
+ Group: </g1> and </g1>
+ Attribute: <compound> and <compound>
+ position compound of </g1> compound of </g1> difference
+ ------------------------------------------------------------
+ [ 0 ] 1 5 4
+ [ 0 ] 2 5 3
+ [ 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);
+ write_attr(loc_id,1,dims,"compound",type_id,buf3);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_REFERENCE
+ *-------------------------------------------------------------------------
+ */
+ /* Create references to dataset */
+ if (dset_name)
+ {
+ status=H5Rcreate(&buf4[0],file_id,dset_name,H5R_OBJECT,-1);
+ status=H5Rcreate(&buf4[1],file_id,dset_name,H5R_OBJECT,-1);
+ write_attr(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4);
+ }
+
+/*-------------------------------------------------------------------------
+ * H5T_ENUM
+ *-------------------------------------------------------------------------
+ */
+ if (make_diffs)
+ {
+ for (i=0; i<2; i++)
+ {
+ buf45[i]=GREEN;
+ }
+ }
+ /*
+ buf45[2]= {RED,RED};
+ $h5diff file7.h5 file6.h5 g1 g1 -v
+ Group: </g1> and </g1>
+ Attribute: <enum> and <enum>
+ position enum of </g1> enum of </g1> difference
+------------------------------------------------------------
+[ 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));
+ write_attr(loc_id,1,dims,"enum",type_id,buf45);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * 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;
+ buf5[1].len = 2;
+ 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;
+ }
+ /*
+ $h5diff file7.h5 file6.h5 g1 g1 -v
+ Group: </g1> and </g1>
+ position vlen of </g1> vlen of </g1> difference
+------------------------------------------------------------
+[ 0 ] 1 0 1
+[ 1 ] 2 0 2
+[ 1 ] 3 0 3
+ */
+
+ space_id = H5Screate_simple(1,dims,NULL);
+ type_id = H5Tvlen_create(H5T_NATIVE_INT);
+ attr_id = H5Acreate(loc_id,"vlen",type_id,space_id,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);
+
+/*-------------------------------------------------------------------------
+ * H5T_ARRAY
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ for (i=0; i<2; i++)
+ for (j=0; j<3; j++)
+ {
+ buf6[i][j]=0;
+ }
+ }
+ /*
+ buf6[2][3]= {{1,2,3},{4,5,6}};
+ $h5diff file7.h5 file6.h5 g1 g1 -v
+ Group: </g1> and </g1>
+ Attribute: <array> and <array>
+position array of </g1> array of </g1> difference
+------------------------------------------------------------
+[ 0 ] 1 0 1
+[ 0 ] 2 0 2
+[ 0 ] 3 0 3
+[ 1 ] 4 0 4
+[ 1 ] 5 0 5
+[ 1 ] 6 0 6
+ */
+ type_id = H5Tarray_create(H5T_NATIVE_INT,1,dimarray,NULL);
+ write_attr(loc_id,1,dims,"array",type_id,buf6);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_INTEGER and H5T_FLOAT
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ for (i=0; i<2; i++)
+ {
+ buf7[i]=0;
+ buf8[i]=0;
+ }
+ }
+ /*
+ buf7[2]= {1,2};
+ buf8[2]= {1,2};
+ $h5diff file7.h5 file6.h5 g1 g1 -v
+ Group: </g1> and </g1>
+ position integer of </g1> integer of </g1> difference
+ ------------------------------------------------------------
+ [ 0 ] 1 0 1
+ [ 1 ] 2 0 2
+ position float of </g1> float of </g1> difference
+ ------------------------------------------------------------
+ [ 0 ] 1 0 1
+ [ 1 ] 2 0 2
+ */
+ write_attr(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7);
+ write_attr(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8);
+
+
+/*-------------------------------------------------------------------------
+ * 2D attributes
+ *-------------------------------------------------------------------------
+ */
+
+/*-------------------------------------------------------------------------
+ * H5T_STRING
+ *-------------------------------------------------------------------------
+ */
+ if (make_diffs)
+ {
+ memset(buf12, 'z', sizeof buf12);
+ }
+
+ /*
+ buf12[6][2]= {"ab","cd","ef","gh","ij","kl"};
+ $h5diff file7.h5 file6.h5 g1 g1 -v
+ Attribute: <string2D> and <string2D>
+ position string2D of </g1> string2D of </g1> difference
+ ------------------------------------------------------------
+[ 0 0 ] a z
+[ 0 0 ] b z
+[ 0 1 ] c z
+[ 0 1 ] d z
+[ 1 0 ] e z
+[ 1 0 ] f z
+[ 1 1 ] g z
+[ 1 1 ] h z
+[ 2 0 ] i z
+[ 2 0 ] j z
+[ 2 1 ] k z
+[ 2 1 ] l z
+ */
+
+ type_id = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(type_id, 2);
+ write_attr(loc_id,2,dims2,"string2D",type_id,buf12);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * 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
+ Attribute: <bitfield2D> and <bitfield2D>
+ position bitfield2D of </g1> bitfield2D of </g1> difference
+------------------------------------------------------------
+[ 0 0 ] 1 0 1
+[ 0 1 ] 2 0 2
+[ 1 0 ] 3 0 3
+[ 1 1 ] 4 0 4
+[ 2 0 ] 5 0 5
+[ 2 1 ] 6 0 6
+ */
+
+
+ type_id = H5Tcopy(H5T_STD_B8LE);
+ write_attr(loc_id,2,dims2,"bitfield2D",type_id,buf22);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_OPAQUE
+ *-------------------------------------------------------------------------
+ */
+
+ /*
+ buf22[3][2]= {{1,2},{3,4},{5,6}};
+ $h5diff file7.h5 file6.h5 g1 g1 -v
+ Attribute: <opaque2D> and <opaque2D>
+ position opaque2D of </g1> opaque2D of </g1> difference
+------------------------------------------------------------
+[ 0 0 ] 1 0 1
+[ 0 1 ] 2 0 2
+[ 1 0 ] 3 0 3
+[ 1 1 ] 4 0 4
+[ 2 0 ] 5 0 5
+[ 2 1 ] 6 0 6
+ */
+ type_id = H5Tcreate(H5T_OPAQUE, 1);
+ status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */
+ write_attr(loc_id,2,dims2,"opaque2D",type_id,buf22);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_COMPOUND
+ *-------------------------------------------------------------------------
+ */
+ if (make_diffs)
+ {
+ 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
+ Attribute: <opaque2D> and <opaque2D>
+ position opaque2D of </g1> opaque2D of </g1> difference
+------------------------------------------------------------
+[ 0 0 ] 1 0 1
+[ 0 1 ] 2 0 2
+[ 1 0 ] 3 0 3
+[ 1 1 ] 4 0 4
+[ 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);
+ write_attr(loc_id,2,dims2,"compound2D",type_id,buf32);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_REFERENCE
+ *-------------------------------------------------------------------------
+ */
+ /* Create references to dataset */
+ if (dset_name)
+ {
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 2; j++) {
+ status=H5Rcreate(&buf42[i][j],file_id,dset_name,H5R_OBJECT,-1);
+ }
+ }
+ write_attr(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42);
+ }
+
+/*-------------------------------------------------------------------------
+ * H5T_ENUM
+ *-------------------------------------------------------------------------
+ */
+ for (i=0; i<3; i++)
+ for (j=0; j<2; j++)
+ {
+ if (make_diffs) buf452[i][j]=GREEN; else buf452[i][j]=RED;
+ }
+
+/*
+Attribute: <enum2D> and <enum2D>
+position enum2D of </g1> enum2D of </g1> difference
+------------------------------------------------------------
+[ 0 0 ] RED GREEN
+[ 0 1 ] RED GREEN
+[ 1 0 ] RED GREEN
+[ 1 1 ] RED GREEN
+[ 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));
+ write_attr(loc_id,2,dims2,"enum2D",type_id,buf452);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_VLEN
+ *-------------------------------------------------------------------------
+ */
+
+ /* Allocate and initialize VL dataset to write */
+ n=0;
+ for (i = 0; i < 3; i++) {
+ 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++;
+ }
+ }
+
+ /*
+ position vlen2D of </g1> vlen2D of </g1> difference
+------------------------------------------------------------
+[ 0 1 ] 1 0 1
+[ 1 0 ] 2 0 2
+[ 1 0 ] 3 0 3
+[ 1 1 ] 4 0 4
+[ 1 1 ] 5 0 5
+[ 2 0 ] 6 0 6
+[ 2 0 ] 7 0 7
+[ 2 0 ] 8 0 8
+[ 2 1 ] 9 0 9
+[ 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 = H5Acreate(loc_id,"vlen2D",type_id,space_id,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);
+
+/*-------------------------------------------------------------------------
+ * H5T_ARRAY
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ memset(buf62,0,sizeof buf62);
+ }
+ /*
+ buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}};
+ $h5diff file7.h5 file6.h5 g1 g1 -v
+ Group: </g1> and </g1>
+Attribute: <array2D> and <array2D>
+position array2D of </g1> array2D of </g1> difference
+------------------------------------------------------------
+[ 0 0 ] 1 0 1
+[ 0 0 ] 2 0 2
+[ 0 0 ] 3 0 3
+[ 0 1 ] 4 0 4
+[ 0 1 ] 5 0 5
+[ 0 1 ] 6 0 6
+[ 1 0 ] 7 0 7
+[ 1 0 ] 8 0 8
+[ 1 0 ] 9 0 9
+[ 1 1 ] 10 0 10
+[ 1 1 ] 11 0 11
+[ 1 1 ] 12 0 12
+[ 2 0 ] 13 0 13
+[ 2 0 ] 14 0 14
+[ 2 0 ] 15 0 15
+[ 2 1 ] 16 0 16
+[ 2 1 ] 17 0 17
+[ 2 1 ] 18 0 18
+ */
+ type_id = H5Tarray_create(H5T_NATIVE_INT,1,dimarray,NULL);
+ write_attr(loc_id,2,dims2,"array2D",type_id,buf62);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_INTEGER and H5T_FLOAT
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ memset(buf72,0,sizeof buf72);
+ memset(buf82,0,sizeof buf82);
+ }
+/*
+Attribute: <integer2D> and <integer2D>
+position integer2D of </g1> integer2D of </g1> difference
+------------------------------------------------------------
+[ 0 0 ] 1 0 1
+[ 0 1 ] 2 0 2
+[ 1 0 ] 3 0 3
+[ 1 1 ] 4 0 4
+[ 2 0 ] 5 0 5
+[ 2 1 ] 6 0 6
+6 differences found
+Attribute: <float2D> and <float2D>
+position float2D of </g1> float2D of </g1> difference
+------------------------------------------------------------
+[ 0 0 ] 1 0 1
+[ 0 1 ] 2 0 2
+[ 1 0 ] 3 0 3
+[ 1 1 ] 4 0 4
+[ 2 0 ] 5 0 5
+[ 2 1 ] 6 0 6
+*/
+
+ write_attr(loc_id,2,dims2,"integer2D",H5T_NATIVE_INT,buf72);
+ write_attr(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82);
+
+
+/*-------------------------------------------------------------------------
+ * 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, 2);
+ write_attr(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++;
+ }
+ }
+ }
+
+/*
+position bitfield3D of </g1> bitfield3D of </g1> difference
+------------------------------------------------------------
+[ 0 0 0 ] 1 0 1
+[ 0 0 1 ] 2 0 2
+[ 0 1 0 ] 3 0 3
+[ 0 1 1 ] 4 0 4
+[ 0 2 0 ] 5 0 5
+[ 0 2 1 ] 6 0 6
+[ 1 0 0 ] 7 0 7
+[ 1 0 1 ] 8 0 8
+[ 1 1 0 ] 9 0 9
+[ 1 1 1 ] 10 0 10
+[ 1 2 0 ] 11 0 11
+[ 1 2 1 ] 12 0 12
+[ 2 0 0 ] 13 0 13
+[ 2 0 1 ] 14 0 14
+[ 2 1 0 ] 15 0 15
+[ 2 1 1 ] 16 0 16
+[ 2 2 0 ] 17 0 17
+[ 2 2 1 ] 18 0 18
+[ 3 0 0 ] 19 0 19
+[ 3 0 1 ] 20 0 20
+[ 3 1 0 ] 21 0 21
+[ 3 1 1 ] 22 0 22
+[ 3 2 0 ] 23 0 23
+[ 3 2 1 ] 24 0 24
+*/
+
+ type_id = H5Tcopy(H5T_STD_B8LE);
+ write_attr(loc_id,3,dims3,"bitfield3D",type_id,buf23);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_OPAQUE
+ *-------------------------------------------------------------------------
+ */
+ type_id = H5Tcreate(H5T_OPAQUE, 1);
+ status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */
+ write_attr(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++;
+ }
+ }
+ }
+ }
+/*position compound3D of </g1> compound3D of </g1> difference
+------------------------------------------------------------
+[ 0 0 0 ] 1 0 1
+[ 0 0 0 ] 2 0 2
+[ 0 0 1 ] 3 0 3
+[ 0 0 1 ] 4 0 4
+[ 0 1 0 ] 5 0 5
+[ 0 1 0 ] 6 0 6
+[ 0 1 1 ] 7 0 7
+[ 0 1 1 ] 8 0 8
+[ 0 2 0 ] 9 0 9
+[ 0 2 0 ] 10 0 10
+[ 0 2 1 ] 11 0 11
+[ 0 2 1 ] 12 0 12
+[ 1 0 0 ] 13 0 13
+[ 1 0 0 ] 14 0 14
+[ 1 0 1 ] 15 0 15
+[ 1 0 1 ] 16 0 16
+[ 1 1 0 ] 17 0 17
+[ 1 1 0 ] 18 0 18
+[ 1 1 1 ] 19 0 19
+[ 1 1 1 ] 20 0 20
+[ 1 2 0 ] 21 0 21
+[ 1 2 0 ] 22 0 22
+[ 1 2 1 ] 23 0 23
+[ 1 2 1 ] 24 0 24
+[ 2 0 0 ] 25 0 25
+[ 2 0 0 ] 26 0 26
+[ 2 0 1 ] 27 0 27
+[ 2 0 1 ] 28 0 28
+[ 2 1 0 ] 29 0 29
+[ 2 1 0 ] 30 0 30
+[ 2 1 1 ] 31 0 31
+[ 2 1 1 ] 32 0 32
+[ 2 2 0 ] 33 0 33
+[ 2 2 0 ] 34 0 34
+[ 2 2 1 ] 35 0 35
+[ 2 2 1 ] 36 0 36
+[ 3 0 0 ] 37 0 37
+[ 3 0 0 ] 38 0 38
+[ 3 0 1 ] 39 0 39
+[ 3 0 1 ] 40 0 40
+[ 3 1 0 ] 41 0 41
+[ 3 1 0 ] 42 0 42
+[ 3 1 1 ] 43 0 43
+[ 3 1 1 ] 44 0 44
+[ 3 2 0 ] 45 0 45
+[ 3 2 0 ] 46 0 46
+[ 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);
+ write_attr(loc_id,3,dims3,"compound3D",type_id,buf33);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_REFERENCE
+ *-------------------------------------------------------------------------
+ */
+ /* Create references to dataset */
+ if (dset_name)
+ {
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 3; j++) {
+ for (k = 0; k < 2; k++)
+ status=H5Rcreate(&buf43[i][j][k],file_id,dset_name,H5R_OBJECT,-1);
+ }
+ }
+ write_attr(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43);
+ }
+
+/*-------------------------------------------------------------------------
+ * H5T_ENUM
+ *-------------------------------------------------------------------------
+ */
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 3; j++) {
+ for (k = 0; k < 2; k++) {
+ if (make_diffs) buf453[i][j][k]=RED; else buf453[i][j][k]=GREEN;
+ }
+ }
+ }
+
+/*
+position enum3D of </g1> enum3D of </g1> difference
+------------------------------------------------------------
+[ 0 0 0 ] GREEN RED
+[ 0 0 1 ] GREEN RED
+[ 0 1 0 ] GREEN RED
+[ 0 1 1 ] GREEN RED
+[ 0 2 0 ] GREEN RED
+[ 0 2 1 ] GREEN RED
+[ 1 0 0 ] GREEN RED
+[ 1 0 1 ] GREEN RED
+[ 1 1 0 ] GREEN RED
+[ 1 1 1 ] GREEN RED
+[ 1 2 0 ] GREEN RED
+[ 1 2 1 ] GREEN RED
+[ 2 0 0 ] GREEN RED
+[ 2 0 1 ] GREEN RED
+[ 2 1 0 ] GREEN RED
+[ 2 1 1 ] GREEN RED
+[ 2 2 0 ] GREEN RED
+[ 2 2 1 ] GREEN RED
+[ 3 0 0 ] GREEN RED
+[ 3 0 1 ] GREEN RED
+[ 3 1 0 ] GREEN RED
+[ 3 1 1 ] GREEN RED
+[ 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));
+ write_attr(loc_id,3,dims3,"enum3D",type_id,buf453);
+ 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++;
+ }
+ }
+ }
+/*
+position vlen3D of </g1> vlen3D of </g1> difference
+------------------------------------------------------------
+[ 0 0 1 ] 1 0 1
+[ 0 1 0 ] 2 0 2
+[ 0 1 1 ] 3 0 3
+[ 0 2 0 ] 4 0 4
+[ 0 2 1 ] 5 0 5
+[ 1 0 0 ] 6 0 6
+[ 1 0 0 ] 7 0 7
+[ 1 0 1 ] 8 0 8
+[ 1 0 1 ] 9 0 9
+[ 1 1 0 ] 10 0 10
+etc
+*/
+ space_id = H5Screate_simple(3,dims3,NULL);
+ type_id = H5Tvlen_create(H5T_NATIVE_INT);
+ attr_id = H5Acreate(loc_id,"vlen3D",type_id,space_id,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);
+
+/*-------------------------------------------------------------------------
+ * 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++;
+ }
+ }
+ /*
+ position array3D of </g1> array3D of </g1> difference
+------------------------------------------------------------
+[ 0 0 0 ] 1 0 1
+[ 0 0 0 ] 2 0 2
+[ 0 0 0 ] 3 0 3
+[ 0 0 1 ] 4 0 4
+[ 0 0 1 ] 5 0 5
+[ 0 0 1 ] 6 0 6
+[ 0 1 0 ] 7 0 7
+etc
+*/
+
+ type_id = H5Tarray_create(H5T_NATIVE_INT,1,dimarray,NULL);
+ write_attr(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++;
+ }
+ }
+ }
+ }
+
+ /*
+ position integer3D of </g1> integer3D of </g1> difference
+------------------------------------------------------------
+[ 0 0 0 ] 1 0 1
+[ 0 0 1 ] 2 0 2
+[ 0 1 0 ] 3 0 3
+[ 0 1 1 ] 4 0 4
+[ 0 2 0 ] 5 0 5
+[ 0 2 1 ] 6 0 6
+[ 1 0 0 ] 7 0 7
+[ 1 0 1 ] 8 0 8
+[ 1 1 0 ] 9 0 9
+[ 1 1 1 ] 10 0 10
+etc
+*/
+ write_attr(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73);
+ write_attr(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83);
+}
+
+
+
+/*-------------------------------------------------------------------------
+ * Check all HDF5 classes
+ * H5T_INTEGER, H5T_FLOAT
+ * H5T_TIME, H5T_STRING, H5T_BITFIELD, H5T_OPAQUE, H5T_COMPOUND, H5T_REFERENCE,
+ * H5T_ENUM, H5T_VLEN, H5T_ARRAY
+ *-------------------------------------------------------------------------
+ */
+
+
+int test_attr(const char *file,
+ int make_diffs /* flag to modify data buffers */)
+{
+ hid_t file_id;
+ hid_t dset_id;
+ hid_t group_id;
+ hid_t root_id;
+ hid_t space_id;
+ hsize_t dims[1]={2};
+ herr_t status;
+
+ /* Create a file */
+ if ((file_id = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0)
+ return -1;
+
+ /* Create a 1D dataset */
+ space_id = H5Screate_simple(1,dims,NULL);
+ dset_id = H5Dcreate(file_id,"dset",H5T_NATIVE_INT,space_id,H5P_DEFAULT);
+ status = H5Sclose(space_id);
+ assert(status>=0);
+
+ /* Create groups */
+ group_id = H5Gcreate(file_id,"g1",0);
+ root_id = H5Gopen(file_id, "/");
+
+/*-------------------------------------------------------------------------
+ * write a series of attributes on the dataset, group, and root group
+ *-------------------------------------------------------------------------
+ */
+
+ write_attr_in(dset_id,"dset",file_id,make_diffs);
+ write_attr_in(group_id,NULL,0,make_diffs);
+ write_attr_in(root_id,NULL,0,make_diffs);
+
+
+ /* Close */
+ status = H5Dclose(dset_id);
+ assert(status>=0);
+ status = H5Gclose(group_id);
+ assert(status>=0);
+ status = H5Gclose(root_id);
+ assert(status>=0);
+
+ /* Close file */
+ status = H5Fclose(file_id);
+ assert(status>=0);
+ return status;
+}
diff --git a/tools/h5diff/test_h5diff.c b/tools/h5diff/testh5diff_basic.c
index 7247fcd..fe0282d 100644
--- a/tools/h5diff/test_h5diff.c
+++ b/tools/h5diff/testh5diff_basic.c
@@ -12,78 +12,13 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include "hdf5.h"
-#include "H5private.h"
+#include "testh5diff.h"
+
/*UINT_MAX Maximum value for a variable of type unsigned int. 4294967295 */
#define UIMAX 4294967295u
-/* diff test*/
-static int do_test_1(const char *file1, const char *file2);
-static int do_test_2(const char *file1, const char *file2);
-static int do_test_3(const char *file1, const char *file2);
-static int do_test_4(const char *file1, const char *file2);
-static int do_test_5(const char *file1, const char *file2);
-static int write_dataset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name,
- hid_t type_id, void *buf );
-
-
-int main(int UNUSED argc, const UNUSED char *argv[])
-{
-
- do_test_1("file1.h5","file2.h5");
- do_test_2("file3.h5",NULL);
- do_test_3("file4.h5",NULL);
- do_test_4("file5.h5",NULL);
- do_test_5("file6.h5",NULL);
- return 0;
-}
-
-
-
-/*-------------------------------------------------------------------------
- * Function: write_dataset
- *
- * Purpose: utility function to write a dataset
- *
- * Return:
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: April 7, 2003
- *
- *-------------------------------------------------------------------------
- */
-
-static
-int write_dataset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name,
- hid_t type_id, void *buf )
-{
- hid_t dataset_id;
- hid_t space_id;
- herr_t status;
-
- /* Create a buf space */
- space_id = H5Screate_simple(rank,dims,NULL);
-
- /* Create a dataset */
- dataset_id = H5Dcreate(loc_id,dset_name,type_id,space_id,H5P_DEFAULT);
-
- /* Write the buf */
- if ( buf )
- H5Dwrite(dataset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf);
- /* Close */
- status = H5Dclose(dataset_id);
- status = H5Sclose(space_id);
- assert(status>=0);
-
- return status;
-
-}
/*
@@ -114,7 +49,7 @@ int write_dataset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name,
file1.h5 file2.h5
# ##############################################################################
-# # not comparable types
+# # basic types
# ##############################################################################
# 2.0
@@ -135,37 +70,6 @@ int write_dataset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name,
# 2.5
file3.h5 file3.h5 link link
-# ##############################################################################
-# # Class issues
-# ##############################################################################
-
-
-# 3.0
- file4.h5 file4.h5 string
-
-# 3.1
- file4.h5 file4.h5 bitfield
-
-# 3.2
- file4.h5 file4.h5 opaque
-
-# 3.3
- file4.h5 file4.h5 compound
-
-# 3.4
- file4.h5 file4.h5 ref
-
-# 3.5
- file4.h5 file4.h5 enum
-
-# 3.6
- file4.h5 file4.h5 vlen
-
-# 3.7
- file4.h5 file4.h5 array
-
-# 3.8
- file4.h5 file4.h5 integer float
# ##############################################################################
# # Dimensions
@@ -334,8 +238,8 @@ int write_dataset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name,
* Basic review tests
*-------------------------------------------------------------------------
*/
-static
-int do_test_1(const char *file1, const char *file2)
+
+int test_basic(const char *file1, const char *file2)
{
hid_t file1_id, file2_id;
@@ -345,7 +249,7 @@ int do_test_1(const char *file1, const char *file2)
/* Test */
double data1[3][2] = {{1,1},{1,1},{1,1}};
- double data2[3][2] = {{1,1.1},{1.01,1.001},{1.0001,1.000000001}};
+ double data2[3][2] = {{1,1.1},{1.01,1.001},{1.0001,1}};
double data3[3][2] = {{100,110},{100,100},{100,100}};
double data4[3][2] = {{110,100},{90,80},{140,200}};
@@ -362,11 +266,11 @@ int do_test_1(const char *file1, const char *file2)
group2_id = H5Gcreate(file2_id, "g1", 0);
group3_id = H5Gcreate(file2_id, "g2", 0);
- write_dataset(group1_id,2,dims,"dset1",H5T_NATIVE_DOUBLE,data1);
- write_dataset(group2_id,2,dims,"dset2",H5T_NATIVE_DOUBLE,data2);
- write_dataset(group1_id,2,dims,"dset3",H5T_NATIVE_DOUBLE,data3);
- write_dataset(group2_id,2,dims,"dset4",H5T_NATIVE_DOUBLE,data4);
- write_dataset(group2_id,2,dims,"dset1",H5T_NATIVE_DOUBLE,data2);
+ write_dset(group1_id,2,dims,"dset1",H5T_NATIVE_DOUBLE,data1);
+ write_dset(group2_id,2,dims,"dset2",H5T_NATIVE_DOUBLE,data2);
+ write_dset(group1_id,2,dims,"dset3",H5T_NATIVE_DOUBLE,data3);
+ write_dset(group2_id,2,dims,"dset4",H5T_NATIVE_DOUBLE,data4);
+ write_dset(group2_id,2,dims,"dset1",H5T_NATIVE_DOUBLE,data2);
/*-------------------------------------------------------------------------
* Close
@@ -384,8 +288,8 @@ int do_test_1(const char *file1, const char *file2)
* Compare different types: H5G_DATASET, H5G_TYPE, H5G_GROUP, H5G_LINK
*-------------------------------------------------------------------------
*/
-static
-int do_test_2(const char *file1, const char UNUSED *file2)
+
+int test_types(const char *file1, const char UNUSED *file2)
{
hid_t file1_id;
@@ -399,6 +303,7 @@ int do_test_2(const char *file1, const char UNUSED *file2)
int a;
float b;
} s_t;
+
/*-------------------------------------------------------------------------
* Create one file
@@ -410,7 +315,7 @@ int do_test_2(const char *file1, const char UNUSED *file2)
* H5G_DATASET
*-------------------------------------------------------------------------
*/
- write_dataset(file1_id,1,dims,"dset",H5T_NATIVE_INT,0);
+ write_dset(file1_id,1,dims,"dset",H5T_NATIVE_INT,0);
/*-------------------------------------------------------------------------
* H5G_GROUP
@@ -450,205 +355,13 @@ int do_test_2(const char *file1, const char UNUSED *file2)
-/*-------------------------------------------------------------------------
- * Check for non supported classes. Supported classes are H5T_INTEGER and H5T_FLOAT
- * Non supported classes are
- * H5T_TIME, H5T_STRING, H5T_BITFIELD, H5T_OPAQUE, H5T_COMPOUND, H5T_REFERENCE,
- * H5T_ENUM, H5T_VLEN, H5T_ARRAY
- *-------------------------------------------------------------------------
- */
-static
-int do_test_3(const char *file1, const char UNUSED *file2)
-{
-
- hid_t file1_id;
- hid_t dataset_id;
- hid_t space_id;
- hid_t type_id;
- hsize_t dims[1]={1};
- herr_t status;
- int val;
-
- /* Compound datatype */
- typedef struct s_t
- {
- int a;
- float b;
- } s_t;
-
- typedef enum
- {
- E_RED,
- E_GREEN
-} e_t;
-
-/*-------------------------------------------------------------------------
- * Create a file
- *-------------------------------------------------------------------------
- */
- file1_id = H5Fcreate (file1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
-/*-------------------------------------------------------------------------
- * H5T_STRING
- *-------------------------------------------------------------------------
- */
- space_id = H5Screate(H5S_SCALAR);
- type_id = H5Tcopy(H5T_C_S1);
- dataset_id = H5Dcreate(file1_id,"string",type_id,space_id,H5P_DEFAULT);
- status = H5Dclose(dataset_id);
- status = H5Sclose(space_id);
- status = H5Tclose(type_id);
-
-/*-------------------------------------------------------------------------
- * H5T_BITFIELD
- *-------------------------------------------------------------------------
- */
-
- type_id = H5Tcopy(H5T_STD_B8LE);
- write_dataset(file1_id,1,dims,"bitfield",type_id,0);
- status = H5Tclose(type_id);
-
-
-/*-------------------------------------------------------------------------
- * H5T_OPAQUE
- *-------------------------------------------------------------------------
- */
-
- type_id = H5Tcreate(H5T_OPAQUE, 1);
- status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */
- write_dataset(file1_id,1,dims,"opaque",type_id,0);
- status = H5Tclose(type_id);
-
-/*-------------------------------------------------------------------------
- * H5T_COMPOUND
- *-------------------------------------------------------------------------
- */
-
- 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);
- write_dataset(file1_id,1,dims,"compound",type_id,0);
- status = H5Tclose(type_id);
-
-/*-------------------------------------------------------------------------
- * H5T_REFERENCE
- *-------------------------------------------------------------------------
- */
- write_dataset(file1_id,1,dims,"ref",H5T_STD_REF_OBJ,0);
-
-/*-------------------------------------------------------------------------
- * 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_dataset(file1_id,1,dims,"enum",type_id,0);
- status = H5Tclose(type_id);
-
-/*-------------------------------------------------------------------------
- * H5T_VLEN
- *-------------------------------------------------------------------------
- */
- type_id = H5Tvlen_create(H5T_NATIVE_INT);
- write_dataset(file1_id,1,dims,"vlen",type_id,0);
- status = H5Tclose(type_id);
-
-/*-------------------------------------------------------------------------
- * H5T_ARRAY
- *-------------------------------------------------------------------------
- */
- type_id = H5Tarray_create(H5T_NATIVE_INT,1,dims,NULL);
- write_dataset(file1_id,1,dims,"array",type_id,0);
- status = H5Tclose(type_id);
-
-/*-------------------------------------------------------------------------
- * H5T_INTEGER vs H5T_FLOAT
- *-------------------------------------------------------------------------
- */
-
- write_dataset(file1_id,1,dims,"integer",H5T_NATIVE_INT,0);
- write_dataset(file1_id,1,dims,"float",H5T_NATIVE_FLOAT,0);
-
-/*-------------------------------------------------------------------------
- * Close
- *-------------------------------------------------------------------------
- */
- status = H5Fclose(file1_id);
- return status;
-}
-
-
-/*-------------------------------------------------------------------------
- * Dimension issues
- *-------------------------------------------------------------------------
- */
-static
-int do_test_4(const char *file1, const char UNUSED *file2)
-{
-
- hid_t file1_id;
- hid_t dataset_id;
- hid_t space_id;
- hid_t plist_id;
- herr_t status;
- hsize_t dims1 [1]={7};
- hsize_t dims2 [4]={2,2,2,2};
- hsize_t dims21[4]={2,2,2,3};
-
-/*-------------------------------------------------------------------------
- * Create a file
- *-------------------------------------------------------------------------
- */
- file1_id = H5Fcreate (file1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
-/*-------------------------------------------------------------------------
- * rank
- *-------------------------------------------------------------------------
- */
- write_dataset(file1_id,1,dims1,"dset1",H5T_NATIVE_INT,NULL);
- write_dataset(file1_id,4,dims2,"dset2",H5T_NATIVE_INT,NULL);
-
-/*-------------------------------------------------------------------------
- * current dimensions
- *-------------------------------------------------------------------------
- */
- write_dataset(file1_id,4,dims2,"dset3",H5T_NATIVE_INT,NULL);
- write_dataset(file1_id,4,dims21,"dset4",H5T_NATIVE_INT,NULL);
-
-/*-------------------------------------------------------------------------
- * Check for the same maximum dimensions. Give a warning if they are different
- *-------------------------------------------------------------------------
- */
-
- space_id = H5Screate_simple(4,dims2,dims2);
- dataset_id = H5Dcreate(file1_id,"dset5",H5T_NATIVE_INT,space_id,H5P_DEFAULT);
- status = H5Dclose(dataset_id);
- status = H5Sclose(space_id);
- space_id = H5Screate_simple(4,dims2,dims21);
- plist_id = H5Pcreate(H5P_DATASET_CREATE);
- status = H5Pset_chunk(plist_id,4,dims2);
- dataset_id = H5Dcreate(file1_id,"dset6",H5T_NATIVE_INT,space_id,plist_id);
- status = H5Dclose(dataset_id);
- status = H5Sclose(space_id);
-
-/*-------------------------------------------------------------------------
- * Close
- *-------------------------------------------------------------------------
- */
- status = H5Fclose(file1_id);
- return status;
-}
-
-
-
/*-------------------------------------------------------------------------
* Datasets datatypes
*-------------------------------------------------------------------------
*/
-static
-int do_test_5(const char *file1, const char UNUSED *file2)
+
+int test_native(const char *file1, const char UNUSED *file2)
{
hid_t file1_id;
@@ -695,83 +408,83 @@ int do_test_5(const char *file1, const char UNUSED *file2)
*-------------------------------------------------------------------------
*/
- write_dataset(file1_id,2,dims,"dset0a",H5T_STD_I16LE,buf2a);
- write_dataset(file1_id,2,dims,"dset0b",H5T_STD_I32LE,buf3b);
+ write_dset(file1_id,2,dims,"dset0a",H5T_STD_I16LE,buf2a);
+ write_dset(file1_id,2,dims,"dset0b",H5T_STD_I32LE,buf3b);
/*-------------------------------------------------------------------------
* Check H5T_NATIVE_CHAR
*-------------------------------------------------------------------------
*/
- write_dataset(file1_id,2,dims,"dset1a",H5T_NATIVE_CHAR,buf1a);
- write_dataset(file1_id,2,dims,"dset1b",H5T_NATIVE_CHAR,buf1b);
+ write_dset(file1_id,2,dims,"dset1a",H5T_NATIVE_CHAR,buf1a);
+ write_dset(file1_id,2,dims,"dset1b",H5T_NATIVE_CHAR,buf1b);
/*-------------------------------------------------------------------------
* Check H5T_NATIVE_SHORT
*-------------------------------------------------------------------------
*/
- write_dataset(file1_id,2,dims,"dset2a",H5T_NATIVE_SHORT,buf2a);
- write_dataset(file1_id,2,dims,"dset2b",H5T_NATIVE_SHORT,buf2b);
+ write_dset(file1_id,2,dims,"dset2a",H5T_NATIVE_SHORT,buf2a);
+ write_dset(file1_id,2,dims,"dset2b",H5T_NATIVE_SHORT,buf2b);
/*-------------------------------------------------------------------------
* Check H5T_NATIVE_INT
*-------------------------------------------------------------------------
*/
- write_dataset(file1_id,2,dims,"dset3a",H5T_NATIVE_INT,buf3a);
- write_dataset(file1_id,2,dims,"dset3b",H5T_NATIVE_INT,buf3b);
+ write_dset(file1_id,2,dims,"dset3a",H5T_NATIVE_INT,buf3a);
+ write_dset(file1_id,2,dims,"dset3b",H5T_NATIVE_INT,buf3b);
/*-------------------------------------------------------------------------
* Check H5T_NATIVE_LONG
*-------------------------------------------------------------------------
*/
- write_dataset(file1_id,2,dims,"dset4a",H5T_NATIVE_LONG,buf4a);
- write_dataset(file1_id,2,dims,"dset4b",H5T_NATIVE_LONG,buf4b);
+ write_dset(file1_id,2,dims,"dset4a",H5T_NATIVE_LONG,buf4a);
+ write_dset(file1_id,2,dims,"dset4b",H5T_NATIVE_LONG,buf4b);
/*-------------------------------------------------------------------------
* Check H5T_NATIVE_FLOAT
*-------------------------------------------------------------------------
*/
- write_dataset(file1_id,2,dims,"dset5a",H5T_NATIVE_FLOAT,buf5a);
- write_dataset(file1_id,2,dims,"dset5b",H5T_NATIVE_FLOAT,buf5b);
+ write_dset(file1_id,2,dims,"dset5a",H5T_NATIVE_FLOAT,buf5a);
+ write_dset(file1_id,2,dims,"dset5b",H5T_NATIVE_FLOAT,buf5b);
/*-------------------------------------------------------------------------
* Check H5T_NATIVE_DOUBLE
*-------------------------------------------------------------------------
*/
- write_dataset(file1_id,2,dims,"dset6a",H5T_NATIVE_DOUBLE,buf6a);
- write_dataset(file1_id,2,dims,"dset6b",H5T_NATIVE_DOUBLE,buf6b);
+ write_dset(file1_id,2,dims,"dset6a",H5T_NATIVE_DOUBLE,buf6a);
+ write_dset(file1_id,2,dims,"dset6b",H5T_NATIVE_DOUBLE,buf6b);
/*-------------------------------------------------------------------------
* H5T_NATIVE_CHAR and H5T_NATIVE_UCHAR
*-------------------------------------------------------------------------
*/
- write_dataset(file1_id,2,dims,"dset7a",H5T_NATIVE_CHAR,buf7a);
- write_dataset(file1_id,2,dims,"dset7b",H5T_NATIVE_UCHAR,buf7b);
+ write_dset(file1_id,2,dims,"dset7a",H5T_NATIVE_CHAR,buf7a);
+ write_dset(file1_id,2,dims,"dset7b",H5T_NATIVE_UCHAR,buf7b);
/*-------------------------------------------------------------------------
* H5T_NATIVE_LLONG
*-------------------------------------------------------------------------
*/
- write_dataset(file1_id,2,dims,"dset8a",H5T_NATIVE_LLONG,buf8a);
- write_dataset(file1_id,2,dims,"dset8b",H5T_NATIVE_LLONG,buf8b);
+ write_dset(file1_id,2,dims,"dset8a",H5T_NATIVE_LLONG,buf8a);
+ write_dset(file1_id,2,dims,"dset8b",H5T_NATIVE_LLONG,buf8b);
/*-------------------------------------------------------------------------
* H5T_NATIVE_ULLONG
*-------------------------------------------------------------------------
*/
- write_dataset(file1_id,2,dims,"dset9a",H5T_NATIVE_ULLONG,buf9a);
- write_dataset(file1_id,2,dims,"dset9b",H5T_NATIVE_ULLONG,buf9b);
+ write_dset(file1_id,2,dims,"dset9a",H5T_NATIVE_ULLONG,buf9a);
+ write_dset(file1_id,2,dims,"dset9b",H5T_NATIVE_ULLONG,buf9b);
/*-------------------------------------------------------------------------
* H5T_NATIVE_INT
*-------------------------------------------------------------------------
*/
- write_dataset(file1_id,2,dims,"dset10a",H5T_NATIVE_UINT,buf10a);
- write_dataset(file1_id,2,dims,"dset10b",H5T_NATIVE_UINT,buf10b);
+ write_dset(file1_id,2,dims,"dset10a",H5T_NATIVE_UINT,buf10a);
+ write_dset(file1_id,2,dims,"dset10b",H5T_NATIVE_UINT,buf10b);
/*-------------------------------------------------------------------------
@@ -782,3 +495,4 @@ int do_test_5(const char *file1, const char UNUSED *file2)
return status;
}
+
diff --git a/tools/h5diff/testh5diff_dset.c b/tools/h5diff/testh5diff_dset.c
new file mode 100644
index 0000000..44b2445
--- /dev/null
+++ b/tools/h5diff/testh5diff_dset.c
@@ -0,0 +1,683 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#include "testh5diff.h"
+
+
+
+/*-------------------------------------------------------------------------
+ * 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,
+ const char* dset_name, /* for saving reference to dataset*/
+ hid_t file_id,
+ int make_diffs /* flag to modify data buffers */)
+{
+ /* Compound datatype */
+ typedef struct s_t
+ {
+ char a;
+ double b;
+ } s_t;
+
+ typedef enum
+ {
+ RED,
+ GREEN
+ } e_t;
+
+ hid_t dset_id;
+ hid_t space_id;
+ hid_t type_id;
+ hid_t plist_id;
+ herr_t status;
+ int val, i, j, k, n;
+ float f;
+ int fillvalue=2;
+
+ /* create 1D attributes with dimension [2], 2 elements */
+ hsize_t dims[1]={2};
+ char buf1[2][2]= {"ab","de"}; /* string */
+ char buf2[2]= {1,2}; /* bitfield, opaque */
+ s_t buf3[2]= {{1,2},{3,4}}; /* compound */
+ hobj_ref_t buf4[2]; /* reference */
+ e_t buf45[2]= {RED,GREEN}; /* enum */
+ hvl_t buf5[2]; /* vlen */
+ hsize_t dimarray[1]={3}; /* array dimension */
+ 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 */
+ char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */
+ s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */
+ hobj_ref_t buf42[3][2]; /* reference */
+ e_t buf452[3][2]; /* enum */
+ hvl_t buf52[3][2]; /* vlen */
+ 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",
+ "rs","tu","vw","xz","AB","CD","EF","GH",
+ "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */
+ char buf23[4][3][2]; /* bitfield, opaque */
+ s_t buf33[4][3][2]; /* compound */
+ hobj_ref_t buf43[4][3][2]; /* reference */
+ e_t buf453[4][3][2]; /* enum */
+ hvl_t buf53[4][3][2]; /* vlen */
+ 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++)
+ for (j=0; j<2; j++)
+ {
+ buf1[i][j]='z';
+ }
+ }
+
+
+ type_id = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(type_id, 2);
+ write_dset(loc_id,1,dims,"string",type_id,buf1);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * 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);
+
+/*-------------------------------------------------------------------------
+ * H5T_OPAQUE
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ for (i=0; i<2; i++)
+ {
+ buf3[i].a=0; buf3[i].b=0;
+ }
+ }
+
+ type_id = H5Tcreate(H5T_OPAQUE, 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);
+
+/*-------------------------------------------------------------------------
+ * H5T_COMPOUND
+ *-------------------------------------------------------------------------
+ */
+
+
+ if (make_diffs)
+ {
+ for (i=0; i<2; i++)
+ {
+ 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);
+
+/*-------------------------------------------------------------------------
+ * H5T_REFERENCE
+ *-------------------------------------------------------------------------
+ */
+ /* Create references to dataset */
+ if (dset_name)
+ {
+ status=H5Rcreate(&buf4[0],file_id,dset_name,H5R_OBJECT,-1);
+ status=H5Rcreate(&buf4[1],file_id,dset_name,H5R_OBJECT,-1);
+ write_dset(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4);
+ }
+
+/*-------------------------------------------------------------------------
+ * 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);
+
+/*-------------------------------------------------------------------------
+ * 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;
+ buf5[1].len = 2;
+ 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 = H5Dcreate(loc_id,"vlen",type_id,space_id,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);
+
+/*-------------------------------------------------------------------------
+ * H5T_ARRAY
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ for (i=0; i<2; i++)
+ for (j=0; j<3; j++)
+ {
+ buf6[i][j]=0;
+ }
+ }
+
+ type_id = H5Tarray_create(H5T_NATIVE_INT,1,dimarray,NULL);
+ write_dset(loc_id,1,dims,"array",type_id,buf6);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_INTEGER and H5T_FLOAT
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ for (i=0; i<2; i++)
+ {
+ buf7[i]=0;
+ 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);
+
+
+/*-------------------------------------------------------------------------
+ * 2D
+ *-------------------------------------------------------------------------
+ */
+
+/*-------------------------------------------------------------------------
+ * H5T_STRING
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ memset(buf12, 'z', sizeof buf12);
+ }
+
+
+ type_id = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(type_id, 2);
+ write_dset(loc_id,2,dims2,"string2D",type_id,buf12);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * 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);
+
+/*-------------------------------------------------------------------------
+ * H5T_OPAQUE
+ *-------------------------------------------------------------------------
+ */
+ type_id = H5Tcreate(H5T_OPAQUE, 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);
+
+/*-------------------------------------------------------------------------
+ * 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);
+
+/*-------------------------------------------------------------------------
+ * H5T_REFERENCE
+ *-------------------------------------------------------------------------
+ */
+ /* Create references to dataset */
+ if (dset_name)
+ {
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 2; j++) {
+ status=H5Rcreate(&buf42[i][j],file_id,dset_name,H5R_OBJECT,-1);
+ }
+ }
+ write_dset(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42);
+ }
+
+/*-------------------------------------------------------------------------
+ * H5T_ENUM
+ *-------------------------------------------------------------------------
+ */
+
+ for (i=0; i<3; i++)
+ for (j=0; j<2; j++)
+ {
+ if (make_diffs) buf452[i][j]=GREEN; else buf452[i][j]=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));
+ write_dset(loc_id,2,dims2,"enum2D",type_id,0);
+ status = H5Tclose(type_id);
+
+/*-------------------------------------------------------------------------
+ * H5T_VLEN
+ *-------------------------------------------------------------------------
+ */
+
+/* Allocate and initialize VL dataset to write */
+ n=0;
+ for (i = 0; i < 3; i++) {
+ 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 = H5Dcreate(loc_id,"vlen2D",type_id,space_id,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_create(H5T_NATIVE_INT,1,dimarray,NULL);
+ 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);
+ status = H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &fillvalue);
+ space_id = H5Screate_simple(2,dims2,NULL);
+ dset_id = H5Dcreate(loc_id,"integer2D",H5T_NATIVE_INT,space_id,plist_id);
+ 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);
+ }
+
+ type_id = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(type_id, 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++;
+ }
+ }
+ }
+
+
+ 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, 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++;
+ }
+ }
+ }
+ }
+
+
+ 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)
+ {
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 3; j++) {
+ for (k = 0; k < 2; k++)
+ status=H5Rcreate(&buf43[i][j][k],file_id,dset_name,H5R_OBJECT,-1);
+ }
+ }
+ write_dset(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43);
+ }
+
+/*-------------------------------------------------------------------------
+ * H5T_ENUM
+ *-------------------------------------------------------------------------
+ */
+
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 3; j++) {
+ for (k = 0; k < 2; k++) {
+ if (make_diffs) buf453[i][j][k]=RED; else buf453[i][j][k]=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));
+ 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++;
+ }
+ }
+ }
+
+ space_id = H5Screate_simple(3,dims3,NULL);
+ type_id = H5Tvlen_create(H5T_NATIVE_INT);
+ dset_id = H5Dcreate(loc_id,"vlen3D",type_id,space_id,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_create(H5T_NATIVE_INT,1,dimarray,NULL);
+ 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);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Check all HDF5 classes
+ * H5T_INTEGER, H5T_FLOAT
+ * H5T_TIME, H5T_STRING, H5T_BITFIELD, H5T_OPAQUE, H5T_COMPOUND, H5T_REFERENCE,
+ * H5T_ENUM, H5T_VLEN, H5T_ARRAY
+ *-------------------------------------------------------------------------
+ */
+
+
+int test_dsetall(const char *file,
+ int make_diffs /* flag to modify data buffers */)
+{
+ hid_t file_id;
+ hid_t dset_id;
+ hid_t group_id;
+ hid_t space_id;
+ hsize_t dims[1]={2};
+ herr_t status;
+ int buf[2]={1,2};
+
+ if (make_diffs)
+ {
+ memset(buf,0,sizeof buf);
+ }
+
+ /* Create a file */
+ if ((file_id = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0)
+ return -1;
+
+ /* Create a 1D dataset */
+ space_id = H5Screate_simple(1,dims,NULL);
+ dset_id = H5Dcreate(file_id,"dset",H5T_NATIVE_INT,space_id,H5P_DEFAULT);
+ status = H5Dwrite(dset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf);
+ status = H5Sclose(space_id);
+ assert(status>=0);
+
+ /* Create a group */
+ group_id = H5Gcreate(file_id,"g1",0);
+
+/*-------------------------------------------------------------------------
+ * write a series of datasets on the group
+ *-------------------------------------------------------------------------
+ */
+
+ write_dset_in(group_id,"/dset",file_id,make_diffs);
+
+ /* Close */
+ status = H5Dclose(dset_id);
+ assert(status>=0);
+ status = H5Gclose(group_id);
+ assert(status>=0);
+
+ /* Close file */
+ status = H5Fclose(file_id);
+ assert(status>=0);
+ return status;
+}
+
+
+
diff --git a/tools/h5diff/testh5diff_main.c b/tools/h5diff/testh5diff_main.c
new file mode 100644
index 0000000..70a1ff1
--- /dev/null
+++ b/tools/h5diff/testh5diff_main.c
@@ -0,0 +1,36 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#include "testh5diff.h"
+
+
+
+
+int main(int UNUSED argc, const UNUSED char *argv[])
+{
+
+ test_basic ("file1.h5","file2.h5");
+ test_types ("file3.h5",NULL);
+ test_native("file4.h5",NULL);
+
+ /* generate 2 files with attribute differences */
+ test_attr("file5.h5",0);
+ test_attr("file6.h5",1);
+
+ /* generate 2 files with all datatype differences */
+ test_dsetall("file7.h5",0);
+ test_dsetall("file8.h5",1);
+ return 0;
+}
+
diff --git a/tools/h5diff/testh5diff_util.c b/tools/h5diff/testh5diff_util.c
new file mode 100644
index 0000000..b0abf81
--- /dev/null
+++ b/tools/h5diff/testh5diff_util.c
@@ -0,0 +1,99 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#include "testh5diff.h"
+
+
+/*-------------------------------------------------------------------------
+ * 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 write_attr(hid_t loc_id,
+ int rank,
+ hsize_t *dims,
+ const char *attr_name,
+ hid_t type_id,
+ void *buf)
+{
+ hid_t attr_id;
+ hid_t space_id;
+ herr_t status;
+
+ /* Create a buf space */
+ space_id = H5Screate_simple(rank,dims,NULL);
+
+ /* Create the attribute */
+ attr_id = H5Acreate(loc_id,attr_name,type_id,space_id,H5P_DEFAULT);
+
+ /* Write the buf */
+ if ( buf )
+ status = H5Awrite(attr_id,type_id,buf);
+
+ /* Close */
+ status = H5Aclose(attr_id);
+ status = H5Sclose(space_id);
+ return status;
+}
+
+/*-------------------------------------------------------------------------
+ * 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 )
+{
+ hid_t dset_id;
+ hid_t space_id;
+ herr_t status;
+
+ /* Create a buf space */
+ space_id = H5Screate_simple(rank,dims,NULL);
+
+ /* Create a dataset */
+ dset_id = H5Dcreate(loc_id,dset_name,type_id,space_id,H5P_DEFAULT);
+
+ /* Write the buf */
+ if ( buf )
+ status = H5Dwrite(dset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf);
+
+ /* Close */
+ status = H5Dclose(dset_id);
+ status = H5Sclose(space_id);
+
+ return status;
+
+}
+