summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2006-04-25 18:19:40 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2006-04-25 18:19:40 (GMT)
commit50c9a237255f5e1917e564e9f1f0d2bc95f3ac04 (patch)
tree70443d8454bf1d1302a88e722d233661bb928bc1
parent8b90adeac6716fe17fc0f4241bdd48333d15941a (diff)
downloadhdf5-50c9a237255f5e1917e564e9f1f0d2bc95f3ac04.zip
hdf5-50c9a237255f5e1917e564e9f1f0d2bc95f3ac04.tar.gz
hdf5-50c9a237255f5e1917e564e9f1f0d2bc95f3ac04.tar.bz2
[svn-r12297] Purpose:
new feature Description: added support for the printout of dataset region references differences added a new test for this merged the h5diff generator of test files into a single file Solution: Platforms tested: linux 32, 64 solaris Misc. update:
-rw-r--r--MANIFEST8
-rw-r--r--tools/h5diff/Makefile.am5
-rw-r--r--tools/h5diff/Makefile.in38
-rw-r--r--tools/h5diff/h5diffgentest.c2461
-rw-r--r--tools/h5diff/testh5diff.h53
-rwxr-xr-xtools/h5diff/testh5diff.sh14
-rw-r--r--tools/h5diff/testh5diff_attr.c1088
-rw-r--r--tools/h5diff/testh5diff_basic.c515
-rw-r--r--tools/h5diff/testh5diff_dset.c665
-rw-r--r--tools/h5diff/testh5diff_main.c36
-rw-r--r--tools/h5diff/testh5diff_util.c99
-rw-r--r--tools/lib/h5diff_array.c225
-rw-r--r--tools/lib/h5diff_dset.c202
-rw-r--r--tools/testfiles/file7.h5bin19104 -> 20768 bytes
-rw-r--r--tools/testfiles/file8.h5bin19104 -> 20768 bytes
-rw-r--r--tools/testfiles/h5diff_80.txt14
16 files changed, 2777 insertions, 2646 deletions
diff --git a/MANIFEST b/MANIFEST
index b92ff07..0abd403 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -812,12 +812,7 @@
./tools/h5diff/h5diff_common.h
./tools/h5diff/h5diff_main.c
./tools/h5diff/ph5diff_main.c
-./tools/h5diff/testh5diff_attr.c
-./tools/h5diff/testh5diff_basic.c
-./tools/h5diff/testh5diff_dset.c
-./tools/h5diff/testh5diff_main.c
-./tools/h5diff/testh5diff_util.c
-./tools/h5diff/testh5diff.h
+./tools/h5diff/h5diffgentest.c
./tools/h5diff/testh5diff.sh
./tools/h5diff/testph5diff.sh
@@ -1186,6 +1181,7 @@
./tools/testfiles/h5diff_55.txt
./tools/testfiles/h5diff_56.txt
./tools/testfiles/h5diff_57.txt
+./tools/testfiles/h5diff_58.txt
./tools/testfiles/h5diff_600.txt
./tools/testfiles/h5diff_601.txt
./tools/testfiles/h5diff_602.txt
diff --git a/tools/h5diff/Makefile.am b/tools/h5diff/Makefile.am
index aa08864..0243f92 100644
--- a/tools/h5diff/Makefile.am
+++ b/tools/h5diff/Makefile.am
@@ -33,7 +33,7 @@ endif
bin_PROGRAMS=h5diff $(H5PDIFF)
# Test programs and scripts
-TEST_PROG=h5difftst
+TEST_PROG=h5diffgentest
TEST_SCRIPT=$(srcdir)/testh5diff.sh
check_PROGRAMS=$(TEST_PROG)
@@ -44,8 +44,7 @@ SCRIPT_DEPEND=h5diff$(EXEEXT) $(H5PDIFF) $(srcdir)/testh5diff.sh
# Source files for the program
h5diff_SOURCES=h5diff_main.c h5diff_common.c
ph5diff_SOURCES=ph5diff_main.c h5diff_common.c
-h5difftst_SOURCES=testh5diff_main.c testh5diff_attr.c \
- testh5diff_basic.c testh5diff_dset.c testh5diff_util.c
+h5diffgentest_SOURCES=h5diffgentest.c
# Programs depend on the main HDF5 library and tools library
LDADD=$(LIBH5TOOLS) $(LIBHDF5)
diff --git a/tools/h5diff/Makefile.in b/tools/h5diff/Makefile.in
index 812180c..f8e4c6f 100644
--- a/tools/h5diff/Makefile.in
+++ b/tools/h5diff/Makefile.in
@@ -30,7 +30,7 @@
# HDF5 Library Makefile(.in)
#
-SOURCES = $(h5diff_SOURCES) $(h5difftst_SOURCES) $(ph5diff_SOURCES)
+SOURCES = $(h5diff_SOURCES) $(h5diffgentest_SOURCES) $(ph5diff_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -70,7 +70,7 @@ CONFIG_CLEAN_FILES =
@BUILD_PARALLEL_CONDITIONAL_TRUE@am__EXEEXT_1 = ph5diff$(EXEEXT)
am__installdirs = "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
-am__EXEEXT_2 = h5difftst$(EXEEXT)
+am__EXEEXT_2 = h5diffgentest$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS)
am_h5diff_OBJECTS = h5diff_main.$(OBJEXT) h5diff_common.$(OBJEXT)
h5diff_OBJECTS = $(am_h5diff_OBJECTS)
@@ -78,12 +78,11 @@ h5diff_LDADD = $(LDADD)
am__DEPENDENCIES_1 = $(top_builddir)/tools/lib/libh5tools.la
am__DEPENDENCIES_2 = $(top_builddir)/src/libhdf5.la
h5diff_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
-am_h5difftst_OBJECTS = testh5diff_main.$(OBJEXT) \
- testh5diff_attr.$(OBJEXT) testh5diff_basic.$(OBJEXT) \
- testh5diff_dset.$(OBJEXT) testh5diff_util.$(OBJEXT)
-h5difftst_OBJECTS = $(am_h5difftst_OBJECTS)
-h5difftst_LDADD = $(LDADD)
-h5difftst_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
+am_h5diffgentest_OBJECTS = h5diffgentest.$(OBJEXT)
+h5diffgentest_OBJECTS = $(am_h5diffgentest_OBJECTS)
+h5diffgentest_LDADD = $(LDADD)
+h5diffgentest_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_2)
am_ph5diff_OBJECTS = ph5diff_main.$(OBJEXT) h5diff_common.$(OBJEXT)
ph5diff_OBJECTS = $(am_ph5diff_OBJECTS)
ph5diff_LDADD = $(LDADD)
@@ -99,8 +98,9 @@ LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(h5diff_SOURCES) $(h5difftst_SOURCES) $(ph5diff_SOURCES)
-DIST_SOURCES = $(h5diff_SOURCES) $(h5difftst_SOURCES) \
+SOURCES = $(h5diff_SOURCES) $(h5diffgentest_SOURCES) \
+ $(ph5diff_SOURCES)
+DIST_SOURCES = $(h5diff_SOURCES) $(h5diffgentest_SOURCES) \
$(ph5diff_SOURCES)
ETAGS = etags
CTAGS = ctags
@@ -359,7 +359,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.h5 expect_sorted \
@BUILD_PARALLEL_CONDITIONAL_TRUE@TEST_SCRIPT_PARA = $(srcdir)/testph5diff.sh
# Test programs and scripts
-TEST_PROG = h5difftst
+TEST_PROG = h5diffgentest
TEST_SCRIPT = $(srcdir)/testh5diff.sh
check_SCRIPTS = $(TEST_SCRIPT) $(TEST_SCRIPT_PARA)
# The parallel test script testph5diff.sh actually depends on testh5diff.sh.
@@ -368,9 +368,7 @@ SCRIPT_DEPEND = h5diff$(EXEEXT) $(H5PDIFF) $(srcdir)/testh5diff.sh
# Source files for the program
h5diff_SOURCES = h5diff_main.c h5diff_common.c
ph5diff_SOURCES = ph5diff_main.c h5diff_common.c
-h5difftst_SOURCES = testh5diff_main.c testh5diff_attr.c \
- testh5diff_basic.c testh5diff_dset.c testh5diff_util.c
-
+h5diffgentest_SOURCES = h5diffgentest.c
# Programs depend on the main HDF5 library and tools library
LDADD = $(LIBH5TOOLS) $(LIBHDF5)
@@ -462,9 +460,9 @@ clean-checkPROGRAMS:
h5diff$(EXEEXT): $(h5diff_OBJECTS) $(h5diff_DEPENDENCIES)
@rm -f h5diff$(EXEEXT)
$(LINK) $(h5diff_LDFLAGS) $(h5diff_OBJECTS) $(h5diff_LDADD) $(LIBS)
-h5difftst$(EXEEXT): $(h5difftst_OBJECTS) $(h5difftst_DEPENDENCIES)
- @rm -f h5difftst$(EXEEXT)
- $(LINK) $(h5difftst_LDFLAGS) $(h5difftst_OBJECTS) $(h5difftst_LDADD) $(LIBS)
+h5diffgentest$(EXEEXT): $(h5diffgentest_OBJECTS) $(h5diffgentest_DEPENDENCIES)
+ @rm -f h5diffgentest$(EXEEXT)
+ $(LINK) $(h5diffgentest_LDFLAGS) $(h5diffgentest_OBJECTS) $(h5diffgentest_LDADD) $(LIBS)
ph5diff$(EXEEXT): $(ph5diff_OBJECTS) $(ph5diff_DEPENDENCIES)
@rm -f ph5diff$(EXEEXT)
$(LINK) $(ph5diff_LDFLAGS) $(ph5diff_OBJECTS) $(ph5diff_LDADD) $(LIBS)
@@ -477,12 +475,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5diff_common.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5diff_main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5diffgentest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ph5diff_main.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testh5diff_attr.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testh5diff_basic.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testh5diff_dset.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testh5diff_main.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testh5diff_util.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c
new file mode 100644
index 0000000..c99c8df
--- /dev/null
+++ b/tools/h5diff/h5diffgentest.c
@@ -0,0 +1,2461 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 "hdf5.h"
+#include "H5private.h"
+
+/*-------------------------------------------------------------------------
+ * Program: h5diffgentest
+ *
+ * Purpose: generate files for h5diff testting
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: November 12, 2003
+ *
+ *-------------------------------------------------------------------------
+ */
+
+
+#define UIMAX 4294967295u /*Maximum value for a variable of type unsigned int */
+#define STR_SIZE 3
+#define FILE1 "file1.h5"
+#define FILE2 "file2.h5"
+#define FILE3 "file3.h5"
+#define FILE4 "file4.h5"
+#define FILE5 "file5.h5"
+#define FILE6 "file6.h5"
+#define FILE7 "file7.h5"
+#define FILE8 "file8.h5"
+
+
+/*-------------------------------------------------------------------------
+ * Function: write_attr
+ *
+ * Purpose: utility function to write an attribute in LOC_ID
+ *
+ *-------------------------------------------------------------------------
+ */
+static
+int write_attr(hid_t loc_id,
+ int rank,
+ hsize_t *dims,
+ const char *attr_name,
+ hid_t tid,
+ void *buf)
+{
+ hid_t aid;
+ hid_t sid;
+ herr_t status;
+
+ /* Create a buf space */
+ sid = H5Screate_simple(rank,dims,NULL);
+
+ /* Create the attribute */
+ aid = H5Acreate(loc_id,attr_name,tid,sid,H5P_DEFAULT);
+
+ /* Write the buf */
+ if ( buf )
+ status = H5Awrite(aid,tid,buf);
+
+ /* Close */
+ status = H5Aclose(aid);
+ status = H5Sclose(sid);
+ return status;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: write_dset
+ *
+ * Purpose: utility function to create and write a dataset in LOC_ID
+ *
+ *-------------------------------------------------------------------------
+ */
+static
+int write_dset( hid_t loc_id,
+ int rank,
+ hsize_t *dims,
+ const char *dset_name,
+ hid_t tid,
+ void *buf )
+{
+ hid_t did;
+ hid_t sid;
+ herr_t status;
+
+ /* Create a buf space */
+ sid = H5Screate_simple(rank,dims,NULL);
+
+ /* Create a dataset */
+ did = H5Dcreate(loc_id,dset_name,tid,sid,H5P_DEFAULT);
+
+ /* Write the buf */
+ if ( buf )
+ status = H5Dwrite(did,tid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf);
+
+ /* Close */
+ status = H5Dclose(did);
+ status = H5Sclose(sid);
+
+ return status;
+}
+
+
+
+/*
+
+# ##############################################################################
+# # Common usage
+# ##############################################################################
+
+
+# 1.0
+ -h
+
+# 1.1
+ file1.h5 file2.h5 g1/dset1 g1/dset2
+
+# 1.2
+ file1.h5 file2.h5 -n 2 g1/dset1 g1/dset2
+
+# 1.3
+ file1.h5 file2.h5 -d 5 g1/dset3 g1/dset4
+
+# 1.4
+ file1.h5 file2.h5 -p 0.05 g1/dset3 g1/dset4
+
+# 1.5
+ file1.h5 file2.h5 -r g1/dset1 g1/dset2
+
+# 1.6
+ file1.h5 file2.h5
+
+# ##############################################################################
+# # basic types
+# ##############################################################################
+
+# 2.0
+ file3.h5 file3.h5 dset group
+
+# 2.1
+ file3.h5 file3.h5 dset link
+
+# 2.2
+ file3.h5 file3.h5 dset type
+
+# 2.3
+ file3.h5 file3.h5 group group
+
+# 2.4
+ file3.h5 file3.h5 type type
+
+# 2.5
+ file3.h5 file3.h5 link link
+
+
+# ##############################################################################
+# # Dimensions
+# ##############################################################################
+
+# 4.0
+ file5.h5 file5.h5 dset1 dset2
+
+# 4.1
+ file5.h5 file5.h5 dset3 dset4
+
+# 4.2
+ file5.h5 file5.h5 dset5 dset6
+
+
+# ##############################################################################
+# # Dataset types
+# ##############################################################################
+
+# 5.0
+ file6.h5 file6.h5 dset0a dset0b
+
+# 5.1
+ file6.h5 file6.h5 dset1a dset1b
+
+# 5.2
+ file6.h5 file6.h5 dset2a dset2b
+
+# 5.3
+ file6.h5 file6.h5 dset3a dset4b
+
+# 5.4
+ file6.h5 file6.h5 dset4a dset4b
+
+# 5.5
+ file6.h5 file6.h5 dset5a dset5b
+
+# 5.6
+ file6.h5 file6.h5 dset6a dset6b
+
+# 5.7
+ file6.h5 file6.h5 dset7a dset7b
+
+# 5.8
+ file6.h5 file6.h5 dset8a dset8b
+
+# ##############################################################################
+# # Error messages
+# ##############################################################################
+
+
+# 6.0: Check if the command line number of arguments is less than 3
+ h5diff_test1.h5
+
+# 6.1: Check for invalid options
+ h5diff_test1.h5 h5diff_test2.h5 -x
+
+# ##############################################################################
+# # -d
+# ##############################################################################
+
+# 6.2: no value
+ file1.h5 file2.h5 -d g1/dset3 g1/dset4
+
+# 6.3: negative value
+ file1.h5 file2.h5 -d -4 g1/dset3 g1/dset4
+
+# 6.4: zero
+ file1.h5 file2.h5 -d 0 g1/dset3 g1/dset4
+
+# 6.5: non number
+ file1.h5 file2.h5 -d u g1/dset3 g1/dset4
+
+# 6.6: hexadecimal
+ file1.h5 file2.h5 -d 0x1 g1/dset3 g1/dset4
+
+# 6.7: string
+ file1.h5 file2.h5 -d "1" g1/dset3 g1/dset4
+
+# 6.8: repeated option
+ file1.h5 file2.h5 -d 1 -d 2 g1/dset3 g1/dset4
+
+# 6.9: number larger than biggest difference
+ file1.h5 file2.h5 -d 200 g1/dset3 g1/dset4
+
+# 6.10: number smaller than smallest difference
+ file1.h5 file2.h5 -d 1 g1/dset3 g1/dset4
+
+
+# ##############################################################################
+# # -p
+# ##############################################################################
+
+
+# 6.11: no value
+ file1.h5 file2.h5 -p g1/dset3 g1/dset4
+
+# 6.12: negative value
+ file1.h5 file2.h5 -p -4 g1/dset3 g1/dset4
+
+# 6.13: zero
+ file1.h5 file2.h5 -p 0 g1/dset3 g1/dset4
+
+# 6.14: non number
+ file1.h5 file2.h5 -p u g1/dset3 g1/dset4
+
+# 6.15: hexadecimal
+ file1.h5 file2.h5 -p 0x1 g1/dset3 g1/dset4
+
+# 6.16: string
+ file1.h5 file2.h5 -p "0.21" g1/dset3 g1/dset4
+
+# 6.17: repeated option
+ file1.h5 file2.h5 -p 0.21 -p 0.22 g1/dset3 g1/dset4
+
+# 6.18: number larger than biggest difference
+ file1.h5 file2.h5 -p 2 g1/dset3 g1/dset4
+
+# 6.19: number smaller than smallest difference
+ file1.h5 file2.h5 -p 0.005 g1/dset3 g1/dset4
+
+
+
+# ##############################################################################
+# # -n
+# ##############################################################################
+
+
+# 6.20: no value
+ file1.h5 file2.h5 -n g1/dset3 g1/dset4
+
+# 6.21: negative value
+ file1.h5 file2.h5 -n -4 g1/dset3 g1/dset4
+
+# 6.22: zero
+ file1.h5 file2.h5 -n 0 g1/dset3 g1/dset4
+
+# 6.23: non number
+ file1.h5 file2.h5 -n u g1/dset3 g1/dset4
+
+# 6.24: hexadecimal
+ file1.h5 file2.h5 -n 0x1 g1/dset3 g1/dset4
+
+# 6.25: string
+ file1.h5 file2.h5 -n "2" g1/dset3 g1/dset4
+
+# 6.26: repeated option
+ file1.h5 file2.h5 -n 2 -n 3 g1/dset3 g1/dset4
+
+# 6.27: number larger than biggest difference
+ file1.h5 file2.h5 -n 200 g1/dset3 g1/dset4
+
+# 6.28: number smaller than smallest difference
+ file1.h5 file2.h5 -n 1 g1/dset3 g1/dset4
+
+# ##############################################################################
+# # non valid files
+# ##############################################################################
+
+ file1.h6 file2.h6
+
+*/
+
+
+/*-------------------------------------------------------------------------
+ * Function: gen_datareg
+ *
+ * Purpose: generate a dataset region and its reference
+ *
+ * Date: April 19, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static
+void gen_datareg(hid_t fid,
+ int make_diffs /* flag to modify data buffers */)
+{
+ /* data dataset */
+ hid_t did1; /* dataset ID */
+ hid_t sid1; /* dataspace ID */
+ hsize_t dims1[2] = {10,10};/* dimensions */
+ int *buf; /* dataset buffer */
+ /* reference dataset */
+ hid_t did2; /* dataset ID */
+ hid_t sid2; /* dataspace ID */
+ hsize_t dims2[] = {2}; /* 2 references */
+ hdset_reg_ref_t *rbuf; /* buffer for write the references */
+ hsize_t start[10]; /* starting location of hyperslab */
+ hsize_t count[10]; /* element count of hyperslab */
+ hsize_t coord[5][2]; /* coordinates for point selection */
+ herr_t status;
+ int i;
+
+ /* allocate the buffer for write the references */
+ rbuf=calloc(2,sizeof(hdset_reg_ref_t));
+
+ /* allocate the buffer for write the data dataset */
+ buf=malloc(10*10*sizeof(int));
+
+ for (i=0; i<10*10; i++)
+ {
+ buf[i]=i;
+ }
+
+ /* create the data dataset */
+ sid1 = H5Screate_simple(2,dims1,NULL);
+ did1 = H5Dcreate(fid,"dsetref",H5T_NATIVE_INT,sid1,H5P_DEFAULT);
+ status = H5Dwrite(did1,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf);
+
+ /* create the reference dataset */
+ sid2 = H5Screate_simple(1,dims2,NULL);
+ did2 = H5Dcreate(fid,"refreg",H5T_STD_REF_DSETREG,sid2,H5P_DEFAULT);
+
+ /* create the references */
+ /* select hyperslab for first reference */
+
+ start[0]=2; start[1]=2;
+ count[0]=6; count[1]=6;
+ if (make_diffs)
+ {
+ start[0]=0; start[1]=0;
+ count[0]=3; count[1]=3;
+ }
+
+ status = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,NULL,count,NULL);
+ H5Sget_select_npoints(sid1);
+
+ /* store first dataset region */
+ status = H5Rcreate(&rbuf[0],fid,"dsetref",H5R_DATASET_REGION,sid1);
+
+ /* select sequence of five points for second reference */
+ coord[0][0]=6; coord[0][1]=9;
+ coord[1][0]=2; coord[1][1]=2;
+ coord[2][0]=8; coord[2][1]=4;
+ coord[3][0]=1; coord[3][1]=6;
+ coord[4][0]=2; coord[4][1]=8;
+ if (make_diffs)
+ {
+ coord[0][0]=5; coord[0][1]=8;
+ coord[1][0]=3; coord[1][1]=3;
+ coord[2][0]=7; coord[2][1]=5;
+ }
+ H5Sselect_elements(sid1,H5S_SELECT_SET,5,(const hsize_t **)coord);
+ H5Sget_select_npoints(sid1);
+
+ /* store second dataset region */
+ H5Rcreate(&rbuf[1],fid,"dsetref",H5R_DATASET_REGION,sid1);
+
+ /* write */
+ status = H5Dwrite(did2,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,rbuf);
+
+ /* close, free memory buffers */
+ status = H5Dclose(did1);
+ status = H5Sclose(sid1);
+ status = H5Dclose(did2);
+ status = H5Sclose(sid2);
+ free(rbuf);
+ free(buf);
+
+}
+
+/*-------------------------------------------------------------------------
+ * Function: write_dset_in
+ *
+ * Purpose: write datasets in LOC_ID
+ *
+ *-------------------------------------------------------------------------
+ */
+static
+void write_dset_in(hid_t loc_id,
+ const char* dset_name, /* for saving reference to dataset*/
+ hid_t fid,
+ 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 did;
+ hid_t sid;
+ hid_t tid;
+ hid_t dcpl;
+ 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][STR_SIZE]= {"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][STR_SIZE]= {"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 */
+ 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][STR_SIZE]= {"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 */
+ 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';
+ }
+ }
+
+
+ tid = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(tid,STR_SIZE);
+ write_dset(loc_id,1,dims,"string",tid,buf1);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_BITFIELD
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ for (i=0; i<2; i++)
+ buf2[i]=buf2[1]=0;
+ }
+
+ tid = H5Tcopy(H5T_STD_B8LE);
+ write_dset(loc_id,1,dims,"bitfield",tid,buf2);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_OPAQUE
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ for (i=0; i<2; i++)
+ {
+ buf3[i].a=0; buf3[i].b=0;
+ }
+ }
+
+ tid = H5Tcreate(H5T_OPAQUE, 1);
+ status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */
+ write_dset(loc_id,1,dims,"opaque",tid,buf2);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_COMPOUND
+ *-------------------------------------------------------------------------
+ */
+
+
+ if (make_diffs)
+ {
+ for (i=0; i<2; i++)
+ {
+ buf45[i]=GREEN;
+ }
+ }
+
+ tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
+ H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR);
+ H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE);
+ write_dset(loc_id,1,dims,"compound",tid,buf3);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_REFERENCE (H5R_OBJECT object reference)
+ *-------------------------------------------------------------------------
+ */
+ /* Create references to dataset */
+ if (dset_name)
+ {
+ status=H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,-1);
+ status=H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,-1);
+ write_dset(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4);
+ }
+
+/*-------------------------------------------------------------------------
+ * H5T_REFERENCE (H5R_DATASET_REGION dataset region reference)
+ *-------------------------------------------------------------------------
+ */
+
+ gen_datareg(fid,make_diffs);
+
+/*-------------------------------------------------------------------------
+ * H5T_ENUM
+ *-------------------------------------------------------------------------
+ */
+ tid = H5Tcreate(H5T_ENUM, sizeof(e_t));
+ H5Tenum_insert(tid, "RED", (val = 0, &val));
+ H5Tenum_insert(tid, "GREEN", (val = 1, &val));
+ write_dset(loc_id,1,dims,"enum",tid,buf45);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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;
+ }
+
+ sid = H5Screate_simple(1,dims,NULL);
+ tid = H5Tvlen_create(H5T_NATIVE_INT);
+ did = H5Dcreate(loc_id,"vlen",tid,sid,H5P_DEFAULT);
+ status = H5Dwrite(did,tid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf5);
+ assert(status>=0);
+ status = H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf5);
+ assert(status>=0);
+ status = H5Dclose(did);
+ status = H5Tclose(tid);
+ status = H5Sclose(sid);
+
+/*-------------------------------------------------------------------------
+ * H5T_ARRAY
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ for (i=0; i<2; i++)
+ for (j=0; j<3; j++)
+ {
+ buf6[i][j]=0;
+ }
+ }
+
+ tid = H5Tarray_create(H5T_NATIVE_INT,1,dimarray,NULL);
+ write_dset(loc_id,1,dims,"array",tid,buf6);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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);
+ }
+
+
+ tid = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(tid,STR_SIZE);
+ write_dset(loc_id,2,dims2,"string2D",tid,buf12);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_BITFIELD
+ *-------------------------------------------------------------------------
+ */
+
+
+ if (make_diffs)
+ {
+ memset(buf22,0,sizeof buf22);
+ }
+
+ tid = H5Tcopy(H5T_STD_B8LE);
+ write_dset(loc_id,2,dims2,"bitfield2D",tid,buf22);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_OPAQUE
+ *-------------------------------------------------------------------------
+ */
+ tid = H5Tcreate(H5T_OPAQUE, 1);
+ status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */
+ write_dset(loc_id,2,dims2,"opaque2D",tid,buf22);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_COMPOUND
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ memset(buf32,0,sizeof buf32);
+ }
+
+ tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
+ H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR);
+ H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE);
+ write_dset(loc_id,2,dims2,"compound2D",tid,buf32);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_REFERENCE (H5R_OBJECT object 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],fid,dset_name,H5R_OBJECT,-1);
+ }
+ }
+ write_dset(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42);
+ }
+
+/*-------------------------------------------------------------------------
+ * H5T_ENUM
+ *-------------------------------------------------------------------------
+ */
+
+ tid = H5Tcreate(H5T_ENUM, sizeof(e_t));
+ H5Tenum_insert(tid, "RED", (val = 0, &val));
+ H5Tenum_insert(tid, "GREEN", (val = 1, &val));
+ write_dset(loc_id,2,dims2,"enum2D",tid,0);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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++;
+ }
+ }
+
+ sid = H5Screate_simple(2,dims2,NULL);
+ tid = H5Tvlen_create(H5T_NATIVE_INT);
+ did = H5Dcreate(loc_id,"vlen2D",tid,sid,H5P_DEFAULT);
+ status = H5Dwrite(did,tid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf52);
+ assert(status>=0);
+ status = H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf52);
+ assert(status>=0);
+ status = H5Dclose(did);
+ status = H5Tclose(tid);
+ status = H5Sclose(sid);
+
+/*-------------------------------------------------------------------------
+ * H5T_ARRAY
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ memset(buf62,0,sizeof buf62);
+ }
+
+
+ tid = H5Tarray_create(H5T_NATIVE_INT,1,dimarray,NULL);
+ write_dset(loc_id,2,dims2,"array2D",tid,buf62);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_INTEGER, write a fill value
+ *-------------------------------------------------------------------------
+ */
+
+
+ if (make_diffs)
+ {
+ memset(buf72,0,sizeof buf72);
+ memset(buf82,0,sizeof buf82);
+ }
+
+
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ status = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue);
+ sid = H5Screate_simple(2,dims2,NULL);
+ did = H5Dcreate(loc_id,"integer2D",H5T_NATIVE_INT,sid,dcpl);
+ status = H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf72);
+ status = H5Pclose(dcpl);
+ status = H5Dclose(did);
+ status = H5Sclose(sid);
+
+/*-------------------------------------------------------------------------
+ * H5T_FLOAT
+ *-------------------------------------------------------------------------
+ */
+
+ write_dset(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82);
+
+
+/*-------------------------------------------------------------------------
+ * 3D
+ *-------------------------------------------------------------------------
+ */
+
+/*-------------------------------------------------------------------------
+ * H5T_STRING
+ *-------------------------------------------------------------------------
+ */
+
+ if (make_diffs)
+ {
+ memset(buf13,'z',sizeof buf13);
+ }
+
+ tid = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(tid,STR_SIZE);
+ write_dset(loc_id,3,dims3,"string3D",tid,buf13);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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++;
+ }
+ }
+ }
+
+
+ tid = H5Tcopy(H5T_STD_B8LE);
+ write_dset(loc_id,3,dims3,"bitfield3D",tid,buf23);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_OPAQUE
+ *-------------------------------------------------------------------------
+ */
+ tid = H5Tcreate(H5T_OPAQUE, 1);
+ status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */
+ write_dset(loc_id,3,dims3,"opaque3D",tid,buf23);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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++;
+ }
+ }
+ }
+ }
+
+
+ tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
+ H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR);
+ H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE);
+ write_dset(loc_id,3,dims3,"compound3D",tid,buf33);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_REFERENCE (H5R_OBJECT object 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],fid,dset_name,H5R_OBJECT,-1);
+ }
+ }
+ write_dset(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43);
+ }
+
+/*-------------------------------------------------------------------------
+ * H5T_ENUM
+ *-------------------------------------------------------------------------
+ */
+
+ tid = H5Tcreate(H5T_ENUM, sizeof(e_t));
+ H5Tenum_insert(tid, "RED", (val = 0, &val));
+ H5Tenum_insert(tid, "GREEN", (val = 1, &val));
+ write_dset(loc_id,3,dims3,"enum3D",tid,0);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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++;
+ }
+ }
+ }
+
+ sid = H5Screate_simple(3,dims3,NULL);
+ tid = H5Tvlen_create(H5T_NATIVE_INT);
+ did = H5Dcreate(loc_id,"vlen3D",tid,sid,H5P_DEFAULT);
+ status = H5Dwrite(did,tid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf53);
+ assert(status>=0);
+ status = H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf53);
+ assert(status>=0);
+ status = H5Dclose(did);
+ status = H5Tclose(tid);
+ status = H5Sclose(sid);
+
+/*-------------------------------------------------------------------------
+ * 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++;
+ }
+ }
+
+ tid = H5Tarray_create(H5T_NATIVE_INT,1,dimarray,NULL);
+ write_dset(loc_id,3,dims3,"array3D",tid,buf63);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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);
+}
+
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: write_attr_in
+ *
+ * Purpose: write attributes in LOC_ID (dataset, group, named datatype)
+ *
+ *-------------------------------------------------------------------------
+ */
+static
+void write_attr_in(hid_t loc_id,
+ const char* dset_name, /* for saving reference to dataset*/
+ hid_t fid,
+ 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 aid;
+ hid_t sid;
+ hid_t tid;
+ 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
+ */
+ tid = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(tid, 2);
+ write_attr(loc_id,1,dims,"string",tid,buf1);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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
+ */
+
+ tid = H5Tcopy(H5T_STD_B8LE);
+ write_attr(loc_id,1,dims,"bitfield",tid,buf2);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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
+*/
+
+ tid = H5Tcreate(H5T_OPAQUE, 1);
+ status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */
+ write_attr(loc_id,1,dims,"opaque",tid,buf2);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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
+ */
+
+ tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
+ H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR);
+ H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE);
+ write_attr(loc_id,1,dims,"compound",tid,buf3);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_REFERENCE (H5R_OBJECT object reference)
+ *-------------------------------------------------------------------------
+ */
+ /* Create references to dataset */
+ if (dset_name)
+ {
+ status=H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,-1);
+ status=H5Rcreate(&buf4[1],fid,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
+ */
+ tid = H5Tcreate(H5T_ENUM, sizeof(e_t));
+ H5Tenum_insert(tid, "RED", (val = 0, &val));
+ H5Tenum_insert(tid, "GREEN", (val = 1, &val));
+ write_attr(loc_id,1,dims,"enum",tid,buf45);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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
+ */
+
+ sid = H5Screate_simple(1,dims,NULL);
+ tid = H5Tvlen_create(H5T_NATIVE_INT);
+ aid = H5Acreate(loc_id,"vlen",tid,sid,H5P_DEFAULT);
+ status = H5Awrite(aid,tid,buf5);
+ assert(status>=0);
+ status = H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf5);
+ assert(status>=0);
+ status = H5Aclose(aid);
+ status = H5Tclose(tid);
+ status = H5Sclose(sid);
+
+/*-------------------------------------------------------------------------
+ * 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
+ */
+ tid = H5Tarray_create(H5T_NATIVE_INT,1,dimarray,NULL);
+ write_attr(loc_id,1,dims,"array",tid,buf6);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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
+ */
+
+ tid = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(tid, 2);
+ write_attr(loc_id,2,dims2,"string2D",tid,buf12);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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
+ */
+
+
+ tid = H5Tcopy(H5T_STD_B8LE);
+ write_attr(loc_id,2,dims2,"bitfield2D",tid,buf22);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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
+ */
+ tid = H5Tcreate(H5T_OPAQUE, 1);
+ status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */
+ write_attr(loc_id,2,dims2,"opaque2D",tid,buf22);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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
+ */
+
+
+ tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
+ H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR);
+ H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE);
+ write_attr(loc_id,2,dims2,"compound2D",tid,buf32);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_REFERENCE (H5R_OBJECT object 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],fid,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
+*/
+
+ tid = H5Tcreate(H5T_ENUM, sizeof(e_t));
+ H5Tenum_insert(tid, "RED", (val = 0, &val));
+ H5Tenum_insert(tid, "GREEN", (val = 1, &val));
+ write_attr(loc_id,2,dims2,"enum2D",tid,buf452);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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
+*/
+
+ sid = H5Screate_simple(2,dims2,NULL);
+ tid = H5Tvlen_create(H5T_NATIVE_INT);
+ aid = H5Acreate(loc_id,"vlen2D",tid,sid,H5P_DEFAULT);
+ status = H5Awrite(aid,tid,buf52);
+ assert(status>=0);
+ status = H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf52);
+ assert(status>=0);
+ status = H5Aclose(aid);
+ status = H5Tclose(tid);
+ status = H5Sclose(sid);
+
+/*-------------------------------------------------------------------------
+ * 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
+ */
+ tid = H5Tarray_create(H5T_NATIVE_INT,1,dimarray,NULL);
+ write_attr(loc_id,2,dims2,"array2D",tid,buf62);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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
+ */
+
+ tid = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(tid, 2);
+ write_attr(loc_id,3,dims3,"string3D",tid,buf13);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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
+*/
+
+ tid = H5Tcopy(H5T_STD_B8LE);
+ write_attr(loc_id,3,dims3,"bitfield3D",tid,buf23);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_OPAQUE
+ *-------------------------------------------------------------------------
+ */
+ tid = H5Tcreate(H5T_OPAQUE, 1);
+ status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */
+ write_attr(loc_id,3,dims3,"opaque3D",tid,buf23);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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
+*/
+
+
+
+ tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
+ H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR);
+ H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE);
+ write_attr(loc_id,3,dims3,"compound3D",tid,buf33);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * H5T_REFERENCE (H5R_OBJECT object 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],fid,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
+*/
+
+
+ tid = H5Tcreate(H5T_ENUM, sizeof(e_t));
+ H5Tenum_insert(tid, "RED", (val = 0, &val));
+ H5Tenum_insert(tid, "GREEN", (val = 1, &val));
+ write_attr(loc_id,3,dims3,"enum3D",tid,buf453);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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
+*/
+ sid = H5Screate_simple(3,dims3,NULL);
+ tid = H5Tvlen_create(H5T_NATIVE_INT);
+ aid = H5Acreate(loc_id,"vlen3D",tid,sid,H5P_DEFAULT);
+ status = H5Awrite(aid,tid,buf53);
+ assert(status>=0);
+ status = H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf53);
+ assert(status>=0);
+ status = H5Aclose(aid);
+ status = H5Tclose(tid);
+ status = H5Sclose(sid);
+
+/*-------------------------------------------------------------------------
+ * 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
+*/
+
+ tid = H5Tarray_create(H5T_NATIVE_INT,1,dimarray,NULL);
+ write_attr(loc_id,3,dims3,"array3D",tid,buf63);
+ status = H5Tclose(tid);
+
+/*-------------------------------------------------------------------------
+ * 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);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: test_dsetall
+ *
+ * Purpose: 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
+ *
+ *-------------------------------------------------------------------------
+ */
+static
+int test_dsetall(const char *file,
+ int make_diffs /* flag to modify data buffers */)
+{
+ hid_t fid;
+ hid_t did;
+ hid_t gid;
+ hid_t sid;
+ 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 ((fid = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0)
+ return -1;
+
+ /* Create a 1D dataset */
+ sid = H5Screate_simple(1,dims,NULL);
+ did = H5Dcreate(fid,"dset",H5T_NATIVE_INT,sid,H5P_DEFAULT);
+ status = H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf);
+ status = H5Sclose(sid);
+ assert(status>=0);
+
+ /* Create a group */
+ gid = H5Gcreate(fid,"g1",0);
+
+/*-------------------------------------------------------------------------
+ * write a series of datasets on the group
+ *-------------------------------------------------------------------------
+ */
+
+ write_dset_in(gid,"/dset",fid,make_diffs);
+
+ /* Close */
+ status = H5Dclose(did);
+ assert(status>=0);
+ status = H5Gclose(gid);
+ assert(status>=0);
+
+ /* Close file */
+ status = H5Fclose(fid);
+ assert(status>=0);
+ return status;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: test_basic
+ *
+ * Purpose: Basic review tests
+ *
+ *-------------------------------------------------------------------------
+ */
+static
+int test_basic(const char *file1,
+ const char *file2)
+{
+
+ hid_t fid1, fid2;
+ hid_t gid1, gid2, gid3;
+ herr_t status;
+ hsize_t dims[2] = { 3,2 };
+
+ /* 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}};
+ double data3[3][2] = {{100,110},{100,100},{100,100}};
+ double data4[3][2] = {{110,100},{90,80},{140,200}};
+ int data5[3][2] = {{100,100},{100,100},{100,100}};
+ int data6[3][2] = {{101,102},{103,104},{150,200}};
+ unsigned long_long data7[3][2] = {{100,100},{100,100},{100,100}};
+ unsigned long_long data8[3][2] = {{101,102},{103,104},{150,200}};
+
+/*-------------------------------------------------------------------------
+ * Create two files
+ *-------------------------------------------------------------------------
+ */
+
+ fid1 = H5Fcreate (file1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ fid2 = H5Fcreate (file2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Create groups */
+ gid1 = H5Gcreate(fid1, "g1", 0);
+ gid2 = H5Gcreate(fid2, "g1", 0);
+ gid3 = H5Gcreate(fid2, "g2", 0);
+
+ write_dset(gid1,2,dims,"dset1",H5T_NATIVE_DOUBLE,data1);
+ write_dset(gid2,2,dims,"dset2",H5T_NATIVE_DOUBLE,data2);
+ write_dset(gid1,2,dims,"dset3",H5T_NATIVE_DOUBLE,data3);
+ write_dset(gid2,2,dims,"dset4",H5T_NATIVE_DOUBLE,data4);
+ write_dset(gid2,2,dims,"dset1",H5T_NATIVE_DOUBLE,data2);
+
+ /* relative (int) */
+ write_dset(gid1,2,dims,"dset5",H5T_NATIVE_INT,data5);
+ write_dset(gid1,2,dims,"dset6",H5T_NATIVE_INT,data6);
+ /* relative (unsigned long_long) */
+ write_dset(gid1,2,dims,"dset7",H5T_NATIVE_ULLONG,data7);
+ write_dset(gid1,2,dims,"dset8",H5T_NATIVE_ULLONG,data8);
+
+/*-------------------------------------------------------------------------
+ * Close
+ *-------------------------------------------------------------------------
+ */
+ status = H5Gclose(gid1);
+ status = H5Gclose(gid2);
+ status = H5Gclose(gid3);
+ status = H5Fclose(fid1);
+ status = H5Fclose(fid2);
+ return status;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: test_basic
+ *
+ * Purpose: Compare different HDF5 types (H5G_obj_t):
+ * H5G_DATASET, H5G_TYPE, H5G_GROUP, H5G_LINK
+ *
+ *-------------------------------------------------------------------------
+ */
+static
+int test_types(const char *file1,
+ const char UNUSED *file2)
+{
+
+ hid_t fid1;
+ hid_t gid1;
+ hid_t gid2;
+ hid_t tid1;
+ hid_t tid2;
+ herr_t status;
+ hsize_t dims[1]={1};
+ typedef struct s1_t
+ {
+ int a;
+ float b;
+ } s1_t;
+ typedef struct s2_t
+ {
+ int a;
+ } s2_t;
+
+/*-------------------------------------------------------------------------
+ * Create one file
+ *-------------------------------------------------------------------------
+ */
+ fid1 = H5Fcreate (file1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+/*-------------------------------------------------------------------------
+ * H5G_DATASET
+ *-------------------------------------------------------------------------
+ */
+ write_dset(fid1,1,dims,"dset",H5T_NATIVE_INT,0);
+
+/*-------------------------------------------------------------------------
+ * H5G_GROUP
+ *-------------------------------------------------------------------------
+ */
+ gid1 = H5Gcreate(fid1, "g1", 0);
+ status = H5Gclose(gid1);
+ gid2 = H5Gcreate(fid1, "g2", 0);
+ status = H5Gclose(gid2);
+
+/*-------------------------------------------------------------------------
+ * H5G_TYPE
+ *-------------------------------------------------------------------------
+ */
+
+ /* create and commit datatype 1 */
+ tid1 = H5Tcreate (H5T_COMPOUND, sizeof(s1_t));
+ H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT);
+ H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT);
+ H5Tcommit(fid1, "t1", tid1);
+ H5Tclose(tid1);
+ /* create and commit datatype 2 */
+ tid2 = H5Tcreate (H5T_COMPOUND, sizeof(s2_t));
+ H5Tinsert(tid2, "a", HOFFSET(s2_t, a), H5T_NATIVE_INT);
+ H5Tcommit(fid1, "t2", tid2);
+ H5Tclose(tid2);
+
+/*-------------------------------------------------------------------------
+ * H5G_LINK
+ *-------------------------------------------------------------------------
+ */
+
+ status = H5Glink(fid1, H5G_LINK_SOFT, "g1", "l1");
+ status = H5Glink(fid1, H5G_LINK_SOFT, "g2", "l2");
+
+/*-------------------------------------------------------------------------
+ * Close
+ *-------------------------------------------------------------------------
+ */
+ status = H5Fclose(fid1);
+ return status;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: test_native
+ *
+ * Purpose: test datasets datatypes
+ *
+ *-------------------------------------------------------------------------
+ */
+static
+int test_native(const char *file1,
+ const char UNUSED *file2)
+{
+
+ hid_t fid1;
+ hsize_t dims[2]={3,2};
+ herr_t status;
+ char buf1a[3][2] = {{1,1},{1,1},{1,1}};
+ char buf1b[3][2] = {{1,1},{3,4},{5,6}};
+ short buf2a[3][2] = {{1,1},{1,1},{1,1}};
+ short buf2b[3][2] = {{1,1},{3,4},{5,6}};
+ int buf3a[3][2] = {{1,1},{1,1},{1,1}};
+ int buf3b[3][2] = {{1,1},{3,4},{5,6}};
+ long buf4a[3][2] = {{1,1},{1,1},{1,1}};
+ long buf4b[3][2] = {{1,1},{3,4},{5,6}};
+ float buf5a[3][2] = {{1,1},{1,1},{1,1}};
+ float buf5b[3][2] = {{1,1},{3,4},{5,6}};
+ double buf6a[3][2] = {{1,1},{1,1},{1,1}};
+ double buf6b[3][2] = {{1,1},{3,4},{5,6}};
+
+ /*unsigned/signed test
+ signed char -128 to 127
+ unsigned char 0 to 255
+ */
+ char buf7a[3][2] = {{-1,-128},{-1,-1},{-1,-1}};
+ unsigned char buf7b[3][2] = {{1,128},{1,1},{1,1}};
+
+ /* long_long test */
+ long_long buf8a[3][2] = {{1,1},{1,1},{1,1}};
+ long_long buf8b[3][2] = {{1,1},{3,4},{5,6}};
+ unsigned long_long buf9a[3][2] = {{1,1},{1,1},{1,1}};
+ unsigned long_long buf9b[3][2] = {{1,1},{3,4},{5,6}};
+
+ unsigned int buf10a[3][2] = {{UIMAX,1},{1,1},{1,1}};
+ unsigned int buf10b[3][2] = {{UIMAX-1,1},{3,4},{5,6}};
+
+
+/*-------------------------------------------------------------------------
+ * Create a file
+ *-------------------------------------------------------------------------
+ */
+ fid1 = H5Fcreate (file1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+/*-------------------------------------------------------------------------
+ * Check for different storage order. Give a warning if they are different
+ *-------------------------------------------------------------------------
+ */
+
+ write_dset(fid1,2,dims,"dset0a",H5T_STD_I16LE,buf2a);
+ write_dset(fid1,2,dims,"dset0b",H5T_STD_I32LE,buf3b);
+
+/*-------------------------------------------------------------------------
+ * Check H5T_NATIVE_CHAR
+ *-------------------------------------------------------------------------
+ */
+ write_dset(fid1,2,dims,"dset1a",H5T_NATIVE_CHAR,buf1a);
+ write_dset(fid1,2,dims,"dset1b",H5T_NATIVE_CHAR,buf1b);
+
+/*-------------------------------------------------------------------------
+ * Check H5T_NATIVE_SHORT
+ *-------------------------------------------------------------------------
+ */
+ write_dset(fid1,2,dims,"dset2a",H5T_NATIVE_SHORT,buf2a);
+ write_dset(fid1,2,dims,"dset2b",H5T_NATIVE_SHORT,buf2b);
+
+/*-------------------------------------------------------------------------
+ * Check H5T_NATIVE_INT
+ *-------------------------------------------------------------------------
+ */
+ write_dset(fid1,2,dims,"dset3a",H5T_NATIVE_INT,buf3a);
+ write_dset(fid1,2,dims,"dset3b",H5T_NATIVE_INT,buf3b);
+
+/*-------------------------------------------------------------------------
+ * Check H5T_NATIVE_LONG
+ *-------------------------------------------------------------------------
+ */
+ write_dset(fid1,2,dims,"dset4a",H5T_NATIVE_LONG,buf4a);
+ write_dset(fid1,2,dims,"dset4b",H5T_NATIVE_LONG,buf4b);
+
+/*-------------------------------------------------------------------------
+ * Check H5T_NATIVE_FLOAT
+ *-------------------------------------------------------------------------
+ */
+ write_dset(fid1,2,dims,"dset5a",H5T_NATIVE_FLOAT,buf5a);
+ write_dset(fid1,2,dims,"dset5b",H5T_NATIVE_FLOAT,buf5b);
+
+/*-------------------------------------------------------------------------
+ * Check H5T_NATIVE_DOUBLE
+ *-------------------------------------------------------------------------
+ */
+
+ write_dset(fid1,2,dims,"dset6a",H5T_NATIVE_DOUBLE,buf6a);
+ write_dset(fid1,2,dims,"dset6b",H5T_NATIVE_DOUBLE,buf6b);
+
+/*-------------------------------------------------------------------------
+ * H5T_NATIVE_CHAR and H5T_NATIVE_UCHAR
+ *-------------------------------------------------------------------------
+ */
+
+ write_dset(fid1,2,dims,"dset7a",H5T_NATIVE_CHAR,buf7a);
+ write_dset(fid1,2,dims,"dset7b",H5T_NATIVE_UCHAR,buf7b);
+
+/*-------------------------------------------------------------------------
+ * H5T_NATIVE_LLONG
+ *-------------------------------------------------------------------------
+ */
+
+ write_dset(fid1,2,dims,"dset8a",H5T_NATIVE_LLONG,buf8a);
+ write_dset(fid1,2,dims,"dset8b",H5T_NATIVE_LLONG,buf8b);
+
+/*-------------------------------------------------------------------------
+ * H5T_NATIVE_ULLONG
+ *-------------------------------------------------------------------------
+ */
+
+ write_dset(fid1,2,dims,"dset9a",H5T_NATIVE_ULLONG,buf9a);
+ write_dset(fid1,2,dims,"dset9b",H5T_NATIVE_ULLONG,buf9b);
+
+/*-------------------------------------------------------------------------
+ * H5T_NATIVE_INT
+ *-------------------------------------------------------------------------
+ */
+
+ write_dset(fid1,2,dims,"dset10a",H5T_NATIVE_UINT,buf10a);
+ write_dset(fid1,2,dims,"dset10b",H5T_NATIVE_UINT,buf10b);
+
+
+/*-------------------------------------------------------------------------
+ * Close
+ *-------------------------------------------------------------------------
+ */
+ status = H5Fclose(fid1);
+ return status;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: test_attr
+ *
+ * Purpose: test attributes
+ *
+ *-------------------------------------------------------------------------
+ */
+static
+int test_attr(const char *file,
+ int make_diffs /* flag to modify data buffers */)
+{
+ hid_t fid;
+ hid_t did;
+ hid_t gid;
+ hid_t root_id;
+ hid_t sid;
+ hsize_t dims[1]={2};
+ herr_t status;
+
+ /* Create a file */
+ if ((fid = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0)
+ return -1;
+
+ /* Create a 1D dataset */
+ sid = H5Screate_simple(1,dims,NULL);
+ did = H5Dcreate(fid,"dset",H5T_NATIVE_INT,sid,H5P_DEFAULT);
+ status = H5Sclose(sid);
+ assert(status>=0);
+
+ /* Create groups */
+ gid = H5Gcreate(fid,"g1",0);
+ root_id = H5Gopen(fid, "/");
+
+/*-------------------------------------------------------------------------
+ * write a series of attributes on the dataset, group, and root group
+ *-------------------------------------------------------------------------
+ */
+
+ write_attr_in(did,"dset",fid,make_diffs);
+ write_attr_in(gid,NULL,0,make_diffs);
+ write_attr_in(root_id,NULL,0,make_diffs);
+
+
+ /* Close */
+ status = H5Dclose(did);
+ assert(status>=0);
+ status = H5Gclose(gid);
+ assert(status>=0);
+ status = H5Gclose(root_id);
+ assert(status>=0);
+
+ /* Close file */
+ status = H5Fclose(fid);
+ assert(status>=0);
+ return status;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: main program
+ *
+ *-------------------------------------------------------------------------
+ */
+
+int main(int UNUSED argc, const UNUSED char *argv[])
+{
+
+ test_basic (FILE1,FILE2);
+ test_types (FILE3,NULL);
+ test_native(FILE4,NULL);
+
+ /* generate 2 files with attribute differences */
+ test_attr(FILE5,0);
+ test_attr(FILE6,1);
+
+ /* generate 2 files with all datatype differences */
+ test_dsetall(FILE7,0);
+ test_dsetall(FILE8,1);
+ return 0;
+}
+
diff --git a/tools/h5diff/testh5diff.h b/tools/h5diff/testh5diff.h
deleted file mode 100644
index c450e3e..0000000
--- a/tools/h5diff/testh5diff.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 "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 4cbad3f..044206a 100755
--- a/tools/h5diff/testh5diff.sh
+++ b/tools/h5diff/testh5diff.sh
@@ -240,7 +240,7 @@ SKIP() {
##############################################################################
##############################################################################
-### T H E T E S T S ###
+### T H E T E S T S ###
##############################################################################
##############################################################################
@@ -348,8 +348,8 @@ TOOLTEST h5diff_56.txt file4.h5 file4.h5 -v dset6a dset6b
# 5.7
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 file4.h5 file4.h5 dset8a dset8b
+# 5.8 (region reference)
+TOOLTEST h5diff_58.txt file7.h5 file8.h5 -v refreg
# ##############################################################################
# # Error messages
@@ -482,18 +482,10 @@ TOOLTEST h5diff_80.txt file7.h5 file8.h5 -v
TOOLTEST h5diff_90.txt file1.h5 file1.h5
-
-
-
-
-
-
# ##############################################################################
# # END
# ##############################################################################
-
-
if test $nerrors -eq 0 ; then
echo "All $H5DIFF tests passed."
fi
diff --git a/tools/h5diff/testh5diff_attr.c b/tools/h5diff/testh5diff_attr.c
deleted file mode 100644
index 3a962de..0000000
--- a/tools/h5diff/testh5diff_attr.c
+++ /dev/null
@@ -1,1088 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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
- *
- *-------------------------------------------------------------------------
- */
-
-
-static 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/testh5diff_basic.c b/tools/h5diff/testh5diff_basic.c
deleted file mode 100644
index 4a99c84..0000000
--- a/tools/h5diff/testh5diff_basic.c
+++ /dev/null
@@ -1,515 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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"
-
-/*UINT_MAX Maximum value for a variable of type unsigned int. 4294967295 */
-#define UIMAX 4294967295u
-
-/*
-
-# ##############################################################################
-# # Common usage
-# ##############################################################################
-
-
-# 1.0
- -h
-
-# 1.1
- file1.h5 file2.h5 g1/dset1 g1/dset2
-
-# 1.2
- file1.h5 file2.h5 -n 2 g1/dset1 g1/dset2
-
-# 1.3
- file1.h5 file2.h5 -d 5 g1/dset3 g1/dset4
-
-# 1.4
- file1.h5 file2.h5 -p 0.05 g1/dset3 g1/dset4
-
-# 1.5
- file1.h5 file2.h5 -r g1/dset1 g1/dset2
-
-# 1.6
- file1.h5 file2.h5
-
-# ##############################################################################
-# # basic types
-# ##############################################################################
-
-# 2.0
- file3.h5 file3.h5 dset group
-
-# 2.1
- file3.h5 file3.h5 dset link
-
-# 2.2
- file3.h5 file3.h5 dset type
-
-# 2.3
- file3.h5 file3.h5 group group
-
-# 2.4
- file3.h5 file3.h5 type type
-
-# 2.5
- file3.h5 file3.h5 link link
-
-
-# ##############################################################################
-# # Dimensions
-# ##############################################################################
-
-# 4.0
- file5.h5 file5.h5 dset1 dset2
-
-# 4.1
- file5.h5 file5.h5 dset3 dset4
-
-# 4.2
- file5.h5 file5.h5 dset5 dset6
-
-
-# ##############################################################################
-# # Dataset types
-# ##############################################################################
-
-# 5.0
- file6.h5 file6.h5 dset0a dset0b
-
-# 5.1
- file6.h5 file6.h5 dset1a dset1b
-
-# 5.2
- file6.h5 file6.h5 dset2a dset2b
-
-# 5.3
- file6.h5 file6.h5 dset3a dset4b
-
-# 5.4
- file6.h5 file6.h5 dset4a dset4b
-
-# 5.5
- file6.h5 file6.h5 dset5a dset5b
-
-# 5.6
- file6.h5 file6.h5 dset6a dset6b
-
-# 5.7
- file6.h5 file6.h5 dset7a dset7b
-
-# 5.8
- file6.h5 file6.h5 dset8a dset8b
-
-# ##############################################################################
-# # Error messages
-# ##############################################################################
-
-
-# 6.0: Check if the command line number of arguments is less than 3
- h5diff_test1.h5
-
-# 6.1: Check for invalid options
- h5diff_test1.h5 h5diff_test2.h5 -x
-
-# ##############################################################################
-# # -d
-# ##############################################################################
-
-# 6.2: no value
- file1.h5 file2.h5 -d g1/dset3 g1/dset4
-
-# 6.3: negative value
- file1.h5 file2.h5 -d -4 g1/dset3 g1/dset4
-
-# 6.4: zero
- file1.h5 file2.h5 -d 0 g1/dset3 g1/dset4
-
-# 6.5: non number
- file1.h5 file2.h5 -d u g1/dset3 g1/dset4
-
-# 6.6: hexadecimal
- file1.h5 file2.h5 -d 0x1 g1/dset3 g1/dset4
-
-# 6.7: string
- file1.h5 file2.h5 -d "1" g1/dset3 g1/dset4
-
-# 6.8: repeated option
- file1.h5 file2.h5 -d 1 -d 2 g1/dset3 g1/dset4
-
-# 6.9: number larger than biggest difference
- file1.h5 file2.h5 -d 200 g1/dset3 g1/dset4
-
-# 6.10: number smaller than smallest difference
- file1.h5 file2.h5 -d 1 g1/dset3 g1/dset4
-
-
-# ##############################################################################
-# # -p
-# ##############################################################################
-
-
-# 6.11: no value
- file1.h5 file2.h5 -p g1/dset3 g1/dset4
-
-# 6.12: negative value
- file1.h5 file2.h5 -p -4 g1/dset3 g1/dset4
-
-# 6.13: zero
- file1.h5 file2.h5 -p 0 g1/dset3 g1/dset4
-
-# 6.14: non number
- file1.h5 file2.h5 -p u g1/dset3 g1/dset4
-
-# 6.15: hexadecimal
- file1.h5 file2.h5 -p 0x1 g1/dset3 g1/dset4
-
-# 6.16: string
- file1.h5 file2.h5 -p "0.21" g1/dset3 g1/dset4
-
-# 6.17: repeated option
- file1.h5 file2.h5 -p 0.21 -p 0.22 g1/dset3 g1/dset4
-
-# 6.18: number larger than biggest difference
- file1.h5 file2.h5 -p 2 g1/dset3 g1/dset4
-
-# 6.19: number smaller than smallest difference
- file1.h5 file2.h5 -p 0.005 g1/dset3 g1/dset4
-
-
-
-# ##############################################################################
-# # -n
-# ##############################################################################
-
-
-# 6.20: no value
- file1.h5 file2.h5 -n g1/dset3 g1/dset4
-
-# 6.21: negative value
- file1.h5 file2.h5 -n -4 g1/dset3 g1/dset4
-
-# 6.22: zero
- file1.h5 file2.h5 -n 0 g1/dset3 g1/dset4
-
-# 6.23: non number
- file1.h5 file2.h5 -n u g1/dset3 g1/dset4
-
-# 6.24: hexadecimal
- file1.h5 file2.h5 -n 0x1 g1/dset3 g1/dset4
-
-# 6.25: string
- file1.h5 file2.h5 -n "2" g1/dset3 g1/dset4
-
-# 6.26: repeated option
- file1.h5 file2.h5 -n 2 -n 3 g1/dset3 g1/dset4
-
-# 6.27: number larger than biggest difference
- file1.h5 file2.h5 -n 200 g1/dset3 g1/dset4
-
-# 6.28: number smaller than smallest difference
- file1.h5 file2.h5 -n 1 g1/dset3 g1/dset4
-
-# ##############################################################################
-# # non valid files
-# ##############################################################################
-
- file1.h6 file2.h6
-
-*/
-
-
-/*-------------------------------------------------------------------------
- * Basic review tests
- *-------------------------------------------------------------------------
- */
-
-int test_basic(const char *file1, const char *file2)
-{
-
- hid_t file1_id, file2_id;
- hid_t group1_id, group2_id, group3_id;
- herr_t status;
- hsize_t dims[2] = { 3,2 };
-
- /* 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}};
- double data3[3][2] = {{100,110},{100,100},{100,100}};
- double data4[3][2] = {{110,100},{90,80},{140,200}};
- int data5[3][2] = {{100,100},{100,100},{100,100}};
- int data6[3][2] = {{101,102},{103,104},{150,200}};
- unsigned long_long data7[3][2] = {{100,100},{100,100},{100,100}};
- unsigned long_long data8[3][2] = {{101,102},{103,104},{150,200}};
-
-/*-------------------------------------------------------------------------
- * Create two files
- *-------------------------------------------------------------------------
- */
-
- file1_id = H5Fcreate (file1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- file2_id = H5Fcreate (file2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- /* Create groups */
- group1_id = H5Gcreate(file1_id, "g1", 0);
- group2_id = H5Gcreate(file2_id, "g1", 0);
- group3_id = H5Gcreate(file2_id, "g2", 0);
-
- 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);
-
- /* relative (int) */
- write_dset(group1_id,2,dims,"dset5",H5T_NATIVE_INT,data5);
- write_dset(group1_id,2,dims,"dset6",H5T_NATIVE_INT,data6);
- /* relative (unsigned long_long) */
- write_dset(group1_id,2,dims,"dset7",H5T_NATIVE_ULLONG,data7);
- write_dset(group1_id,2,dims,"dset8",H5T_NATIVE_ULLONG,data8);
-
-/*-------------------------------------------------------------------------
- * Close
- *-------------------------------------------------------------------------
- */
- status = H5Gclose(group1_id);
- status = H5Gclose(group2_id);
- status = H5Gclose(group3_id);
- status = H5Fclose(file1_id);
- status = H5Fclose(file2_id);
- return status;
-}
-
-/*-------------------------------------------------------------------------
- * Compare different HDF5 types (H5G_obj_t):
- * H5G_DATASET, H5G_TYPE, H5G_GROUP, H5G_LINK
- *-------------------------------------------------------------------------
- */
-
-int test_types(const char *file1, const char UNUSED *file2)
-{
-
- hid_t file1_id;
- hid_t g1_id;
- hid_t g2_id;
- hid_t t1_id;
- hid_t t2_id;
- herr_t status;
- hsize_t dims[1]={1};
- typedef struct s1_t
- {
- int a;
- float b;
- } s1_t;
- typedef struct s2_t
- {
- int a;
- } s2_t;
-
-/*-------------------------------------------------------------------------
- * Create one file
- *-------------------------------------------------------------------------
- */
- file1_id = H5Fcreate (file1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
-/*-------------------------------------------------------------------------
- * H5G_DATASET
- *-------------------------------------------------------------------------
- */
- write_dset(file1_id,1,dims,"dset",H5T_NATIVE_INT,0);
-
-/*-------------------------------------------------------------------------
- * H5G_GROUP
- *-------------------------------------------------------------------------
- */
- g1_id = H5Gcreate(file1_id, "g1", 0);
- status = H5Gclose(g1_id);
- g2_id = H5Gcreate(file1_id, "g2", 0);
- status = H5Gclose(g2_id);
-
-/*-------------------------------------------------------------------------
- * H5G_TYPE
- *-------------------------------------------------------------------------
- */
-
- /* create and commit datatype 1 */
- t1_id = H5Tcreate (H5T_COMPOUND, sizeof(s1_t));
- H5Tinsert(t1_id, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT);
- H5Tinsert(t1_id, "b", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT);
- H5Tcommit(file1_id, "t1", t1_id);
- H5Tclose(t1_id);
- /* create and commit datatype 2 */
- t2_id = H5Tcreate (H5T_COMPOUND, sizeof(s2_t));
- H5Tinsert(t2_id, "a", HOFFSET(s2_t, a), H5T_NATIVE_INT);
- H5Tcommit(file1_id, "t2", t2_id);
- H5Tclose(t2_id);
-
-/*-------------------------------------------------------------------------
- * H5G_LINK
- *-------------------------------------------------------------------------
- */
-
- status = H5Glink(file1_id, H5G_LINK_SOFT, "g1", "l1");
- status = H5Glink(file1_id, H5G_LINK_SOFT, "g2", "l2");
-
-/*-------------------------------------------------------------------------
- * Close
- *-------------------------------------------------------------------------
- */
- status = H5Fclose(file1_id);
- return status;
-}
-
-
-/*-------------------------------------------------------------------------
- * Datasets datatypes
- *-------------------------------------------------------------------------
- */
-
-int test_native(const char *file1, const char UNUSED *file2)
-{
-
- hid_t file1_id;
- hsize_t dims[2]={3,2};
- herr_t status;
- char buf1a[3][2] = {{1,1},{1,1},{1,1}};
- char buf1b[3][2] = {{1,1},{3,4},{5,6}};
- short buf2a[3][2] = {{1,1},{1,1},{1,1}};
- short buf2b[3][2] = {{1,1},{3,4},{5,6}};
- int buf3a[3][2] = {{1,1},{1,1},{1,1}};
- int buf3b[3][2] = {{1,1},{3,4},{5,6}};
- long buf4a[3][2] = {{1,1},{1,1},{1,1}};
- long buf4b[3][2] = {{1,1},{3,4},{5,6}};
- float buf5a[3][2] = {{1,1},{1,1},{1,1}};
- float buf5b[3][2] = {{1,1},{3,4},{5,6}};
- double buf6a[3][2] = {{1,1},{1,1},{1,1}};
- double buf6b[3][2] = {{1,1},{3,4},{5,6}};
-
- /*unsigned/signed test
- signed char -128 to 127
- unsigned char 0 to 255
- */
- char buf7a[3][2] = {{-1,-128},{-1,-1},{-1,-1}};
- unsigned char buf7b[3][2] = {{1,128},{1,1},{1,1}};
-
- /* long_long test */
- long_long buf8a[3][2] = {{1,1},{1,1},{1,1}};
- long_long buf8b[3][2] = {{1,1},{3,4},{5,6}};
- unsigned long_long buf9a[3][2] = {{1,1},{1,1},{1,1}};
- unsigned long_long buf9b[3][2] = {{1,1},{3,4},{5,6}};
-
- unsigned int buf10a[3][2] = {{UIMAX,1},{1,1},{1,1}};
- unsigned int buf10b[3][2] = {{UIMAX-1,1},{3,4},{5,6}};
-
-
-/*-------------------------------------------------------------------------
- * Create a file
- *-------------------------------------------------------------------------
- */
- file1_id = H5Fcreate (file1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
-/*-------------------------------------------------------------------------
- * Check for different storage order. Give a warning if they are different
- *-------------------------------------------------------------------------
- */
-
- 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_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_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_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_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_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_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_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_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_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_dset(file1_id,2,dims,"dset10a",H5T_NATIVE_UINT,buf10a);
- write_dset(file1_id,2,dims,"dset10b",H5T_NATIVE_UINT,buf10b);
-
-
-/*-------------------------------------------------------------------------
- * Close
- *-------------------------------------------------------------------------
- */
- status = H5Fclose(file1_id);
- return status;
-}
-
-
diff --git a/tools/h5diff/testh5diff_dset.c b/tools/h5diff/testh5diff_dset.c
deleted file mode 100644
index 6d18c8a..0000000
--- a/tools/h5diff/testh5diff_dset.c
+++ /dev/null
@@ -1,665 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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"
-
-#define STR_SIZE 3
-
-/*-------------------------------------------------------------------------
- * Function: write_dset_in
- *
- * Purpose: write datasets in LOC_ID
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 12, 2003
- *
- *-------------------------------------------------------------------------
- */
-
-
-static 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][STR_SIZE]= {"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][STR_SIZE]= {"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 */
- 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][STR_SIZE]= {"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 */
- 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,STR_SIZE);
- 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,STR_SIZE);
- 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
- *-------------------------------------------------------------------------
- */
-
- 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,STR_SIZE);
- 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
- *-------------------------------------------------------------------------
- */
-
- 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
deleted file mode 100644
index 8480675..0000000
--- a/tools/h5diff/testh5diff_main.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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
deleted file mode 100644
index 5e81881..0000000
--- a/tools/h5diff/testh5diff_util.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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;
-
-}
-
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index f17a364..abf1f74 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -52,7 +52,8 @@
/* local functions */
static void close_obj(H5G_obj_t obj_type, hid_t obj_id);
-static int diff_region(hid_t region1_id, hid_t region2_id);
+static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id,
+ hid_t region1_id, hid_t region2_id, diff_opt_t *options);
static hbool_t is_zero(const void *_mem, size_t size);
static int ull2float(unsigned long_long ull_value, float *f_value);
@@ -344,8 +345,6 @@ hsize_t diff_datum(void *_mem1,
H5G_obj_t obj2_type;
hid_t obj1_id;
hid_t obj2_id;
- H5G_stat_t sb1;
- H5G_stat_t sb2;
hsize_t nfound=0; /* differences found */
int ret=0; /* check return error */
float f1, f2, per;
@@ -606,10 +605,10 @@ hsize_t diff_datum(void *_mem1,
iszero1=is_zero(_mem1, H5Tget_size(m_type));
iszero2=is_zero(_mem2, H5Tget_size(m_type));
- if (iszero1==1 && iszero2==1)
+ if (iszero1==1 || iszero2==1)
+ {
return 0;
- else if (iszero1!=iszero2)
- return 1;
+ }
else
{
@@ -628,10 +627,6 @@ hsize_t diff_datum(void *_mem1,
ret= -1;
if ((obj2_id = H5Rdereference(container2_id, H5R_DATASET_REGION, _mem2))<0)
ret= -1;
- if (H5Gget_objinfo(obj1_id, ".", FALSE, &sb1)<0)
- ret= -1;
- if (H5Gget_objinfo(obj2_id, ".", FALSE, &sb2)<0)
- ret= -1;
if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1))<0)
ret= -1;
if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2))<0)
@@ -642,10 +637,7 @@ hsize_t diff_datum(void *_mem1,
return 0;
}
- if (diff_region(region1_id,region2_id))
- {
- parallel_print("Different region referenced\n");
- }
+ nfound = diff_region(obj1_id,obj2_id,region1_id,region2_id,options);
close_obj(H5G_DATASET,obj1_id);
close_obj(H5G_DATASET,obj2_id);
@@ -676,7 +668,8 @@ hsize_t diff_datum(void *_mem1,
if (obj1_type!=obj2_type)
{
parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2);
- return 1;
+ options->not_cmp=1;
+ return 0;
}
if ((obj1_id = H5Rdereference(container1_id, H5R_OBJECT, _mem1))<0)
@@ -688,7 +681,7 @@ hsize_t diff_datum(void *_mem1,
return 0;
}
- /*deep compare */
+ /* compare */
switch (obj1_type) {
case H5G_DATASET:
nfound=diff_datasetid(obj1_id,
@@ -1716,29 +1709,97 @@ static void close_obj(H5G_obj_t obj_type, hid_t obj_id)
break;
}
}
+
+/*-------------------------------------------------------------------------
+ * Function: print_region_block
+ *
+ * Purpose: print start coordinates and opposite corner of a region block
+ *
+ * Return: void
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static
+void print_region_block(int i, hsize_t *ptdata, int ndims)
+{
+ int j;
+
+ parallel_print(" ");
+ for (j = 0; j < ndims; j++)
+ parallel_print("%s%lu", j ? "," : " (",
+ (unsigned long)ptdata[i * 2 * ndims + j]);
+ for (j = 0; j < ndims; j++)
+ parallel_print("%s%lu", j ? "," : ")-(",
+ (unsigned long)ptdata[i * 2 * ndims + j + ndims]);
+ parallel_print(")");
+
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_points
+ *
+ * Purpose: print points of a region reference
+ *
+ * Return: void
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static
+void print_points(int i, hsize_t *ptdata, int ndims)
+{
+ int j;
+
+ parallel_print(" ");
+ for (j = 0; j < ndims; j++)
+ parallel_print("%s%lu", j ? "," : "(",
+ (unsigned long)(ptdata[i * ndims + j]));
+ parallel_print(")");
+
+}
/*-------------------------------------------------------------------------
* Function: diff_region
*
* Purpose: diff a dataspace region
*
- * Return: 0, diff not found, 1 found
+ * Return: number of differences
*
*-------------------------------------------------------------------------
*/
-static int diff_region(hid_t region1_id,
- hid_t region2_id)
+static
+hsize_t diff_region(hid_t obj1_id,
+ hid_t obj2_id,
+ hid_t region1_id,
+ hid_t region2_id,
+ diff_opt_t *options)
{
- hssize_t nblocks1, npoints1;
- hssize_t nblocks2, npoints2;
- hsize_t alloc_size;
- hsize_t *ptdata1;
- hsize_t *ptdata2;
- int ndims1 = H5Sget_simple_extent_ndims(region1_id);
- int ndims2 = H5Sget_simple_extent_ndims(region2_id);
- int ret=0;
+ hssize_t nblocks1, npoints1;
+ hssize_t nblocks2, npoints2;
+ H5G_stat_t sb1;
+ H5G_stat_t sb2;
+ hsize_t alloc_size;
+ hsize_t *ptdata1;
+ hsize_t *ptdata2;
+ int ndims1;
+ int ndims2;
+ int i, j, ret;
+ haddr_t objno1, objno2; /* compact form of object's location */
+ hsize_t nfound_b=0; /* block differences found */
+ hsize_t nfound_p=0; /* point differences found */
+
+ ndims1 = H5Sget_simple_extent_ndims(region1_id);
+ ndims2 = H5Sget_simple_extent_ndims(region2_id);
+
+ H5Gget_objinfo(obj1_id, ".", FALSE, &sb1);
+ H5Gget_objinfo(obj2_id, ".", FALSE, &sb2);
+
+ objno1 = (haddr_t)sb1.objno[0] | ((haddr_t)sb1.objno[1] << (8 * sizeof(long)));
+ objno2 = (haddr_t)sb2.objno[0] | ((haddr_t)sb2.objno[1] << (8 * sizeof(long)));
/*
* These two functions fail if the region does not have blocks or points,
@@ -1752,11 +1813,17 @@ static int diff_region(hid_t region1_id,
npoints1 = H5Sget_select_elem_npoints(region1_id);
npoints2 = H5Sget_select_elem_npoints(region2_id);
} H5E_END_TRY;
-
+
if (nblocks1!=nblocks2 || npoints1!=npoints2 || ndims1!=ndims2)
- return 1;
-
- /* compare block information */
+ {
+ options->not_cmp=1;
+ return 0;
+ }
+
+/*-------------------------------------------------------------------------
+ * compare block information
+ *-------------------------------------------------------------------------
+ */
if (nblocks1 > 0)
{
@@ -1771,32 +1838,50 @@ static int diff_region(hid_t region1_id,
H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t);
H5Sget_select_hyper_blocklist(region2_id, (hsize_t)0, (hsize_t)nblocks2, ptdata2);
- ret=HDmemcmp(ptdata1,ptdata2,(size_t)alloc_size);
-
-#if defined (H5DIFF_DEBUG)
for (i = 0; i < nblocks1; i++)
{
- int j;
-
/* start coordinates and opposite corner */
for (j = 0; j < ndims1; j++)
- parallel_print("%s%lu", j ? "," : "(",
- (unsigned long)ptdata1[i * 2 * ndims1 + j]);
-
- for (j = 0; j < ndims1; j++)
- parallel_print("%s%lu", j ? "," : ")-(",
- (unsigned long)ptdata1[i * 2 * ndims1 + j + ndims1]);
-
- parallel_print(")\n");
+ {
+ hsize_t start1, start2, end1, end2;
+ start1 = ptdata1[i * 2 * ndims1 + j];
+ start2 = ptdata2[i * 2 * ndims1 + j];
+ end1 = ptdata1[i * 2 * ndims1 + j + ndims1];
+ end2 = ptdata2[i * 2 * ndims1 + j + ndims1];
+ if (start1 != start2 || end1 != end2)
+ {
+ nfound_b++;
+ }
+ }
}
-#endif
-
+
+ /* print differences if found */
+ if (nfound_b)
+ {
+ parallel_print("Referenced dataset %lu %lu\n",
+ (unsigned long)objno1,(unsigned long)objno2);
+ parallel_print("------------------------------------------------------------\n");
+
+ parallel_print("Region blocks\n");
+ for (i = 0; i < nblocks1; i++)
+ {
+ parallel_print("block #%d", i);
+ print_region_block(i, ptdata1, ndims1);
+ print_region_block(i, ptdata2, ndims1);
+ parallel_print("\n");
+
+ }
+ }
HDfree(ptdata1);
HDfree(ptdata2);
}
-
- /* Print point information */
+
+/*-------------------------------------------------------------------------
+ * compare point information
+ *-------------------------------------------------------------------------
+ */
+
if (npoints1 > 0)
{
alloc_size = npoints1 * ndims1 * sizeof(ptdata1[0]);
@@ -1809,9 +1894,45 @@ static int diff_region(hid_t region1_id,
ptdata2 = malloc((size_t)alloc_size);
H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t);
H5Sget_select_elem_pointlist(region2_id, (hsize_t)0, (hsize_t)npoints2, ptdata2);
-
- ret=HDmemcmp(ptdata1,ptdata2,(size_t)alloc_size);
-
+
+ for (i = 0; i < npoints1; i++)
+ {
+ hsize_t pt1, pt2;
+
+ for (j = 0; j < ndims1; j++)
+ {
+ pt1 = ptdata1[i * ndims1 + j];
+ pt2 = ptdata2[i * ndims1 + j];
+ if (pt1 != pt2)
+ nfound_p++;
+ }
+ }
+
+ if (nfound_p)
+ {
+ parallel_print("Region points\n");
+ for (i = 0; i < npoints1; i++)
+ {
+ hsize_t pt1, pt2;
+ int diff=0;
+ for (j = 0; j < ndims1; j++)
+ {
+ pt1 = ptdata1[i * ndims1 + j];
+ pt2 = ptdata2[i * ndims1 + j];
+ if (pt1 != pt2)
+ diff=1;
+ }
+ if (diff)
+ {
+ parallel_print("point #%d", i);
+ print_points(i, ptdata1, ndims1);
+ print_points(i, ptdata2, ndims1);
+ parallel_print("\n");
+ }
+ }
+ }
+
+
#if defined (H5DIFF_DEBUG)
for (i = 0; i < npoints1; i++)
{
@@ -1833,7 +1954,7 @@ static int diff_region(hid_t region1_id,
HDfree(ptdata2);
}
- return ret;
+ return (nfound_p + nfound_b)/2;
}
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index 3fd280c..ad49b1a 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -26,17 +26,20 @@
*-------------------------------------------------------------------------
*/
#if defined (H5DIFF_DEBUG)
-void print_sizes( const char *obj1, const char *obj2,
- hid_t f_type1, hid_t f_type2,
- hid_t m_type1, hid_t m_type2 )
+void print_sizes( const char *obj1,
+ const char *obj2,
+ hid_t f_tid1,
+ hid_t f_tid2,
+ hid_t m_tid1,
+ hid_t m_tid2 )
{
size_t f_size1, f_size2; /* size of type in file */
size_t m_size1, m_size2; /* size of type in memory */
- f_size1 = H5Tget_size( f_type1 );
- f_size2 = H5Tget_size( f_type2 );
- m_size1 = H5Tget_size( m_type1 );
- m_size2 = H5Tget_size( m_type2 );
+ f_size1 = H5Tget_size( f_tid1 );
+ f_size2 = H5Tget_size( f_tid2 );
+ m_size1 = H5Tget_size( m_tid1 );
+ m_size2 = H5Tget_size( m_tid2 );
printf("\n");
printf("------------------\n");
@@ -46,23 +49,23 @@ void print_sizes( const char *obj1, const char *obj2,
printf("sizeof(long) %u\n", sizeof(long) );
printf("<%s> ------------------\n", obj1);
printf("type on file ");
- print_type(f_type1);
+ print_type(f_tid1);
printf("\n");
printf("size on file %u\n", f_size1 );
printf("type on memory ");
- print_type(m_type1);
+ print_type(m_tid1);
printf("\n");
printf("size on memory %u\n", m_size1 );
printf("<%s> ------------------\n", obj2);
printf("type on file ");
- print_type(f_type2);
+ print_type(f_tid2);
printf("\n");
printf("size on file %u\n", f_size2 );
printf("type on memory ");
- print_type(m_type2);
+ print_type(m_tid2);
printf("\n");
printf("size on memory %u\n", m_size2 );
printf("\n");
@@ -91,10 +94,10 @@ hsize_t diff_dataset( hid_t file1_id,
const char *obj2_name,
diff_opt_t *options )
{
- hid_t dset1_id=-1;
- hid_t dset2_id=-1;
- hid_t dcpl1_id=-1;
- hid_t dcpl2_id=-1;
+ hid_t did1;
+ hid_t did2;
+ hid_t dcpl1;
+ hid_t dcpl2;
hsize_t nfound=0;
/*-------------------------------------------------------------------------
@@ -104,12 +107,12 @@ hsize_t diff_dataset( hid_t file1_id,
/* disable error reporting */
H5E_BEGIN_TRY {
/* Open the datasets */
- if ( (dset1_id = H5Dopen(file1_id,obj1_name)) < 0 )
+ if ( (did1 = H5Dopen(file1_id,obj1_name)) < 0 )
{
printf("Cannot open dataset <%s>\n", obj1_name );
goto error;
}
- if ( (dset2_id = H5Dopen(file2_id,obj2_name)) < 0 )
+ if ( (did2 = H5Dopen(file2_id,obj2_name)) < 0 )
{
printf("Cannot open dataset <%s>\n", obj2_name );
goto error;
@@ -118,9 +121,9 @@ hsize_t diff_dataset( hid_t file1_id,
} H5E_END_TRY;
- if ((dcpl1_id=H5Dget_create_plist(dset1_id))<0)
+ if ((dcpl1=H5Dget_create_plist(did1))<0)
goto error;
- if ((dcpl2_id=H5Dget_create_plist(dset2_id))<0)
+ if ((dcpl2=H5Dget_create_plist(did2))<0)
goto error;
/*-------------------------------------------------------------------------
@@ -130,14 +133,14 @@ hsize_t diff_dataset( hid_t file1_id,
* 2) the internal filters might be turned off
*-------------------------------------------------------------------------
*/
- if ((h5tools_canreadf((options->m_verbose?obj1_name:NULL),dcpl1_id)==1) &&
- (h5tools_canreadf((options->m_verbose?obj2_name:NULL),dcpl2_id)==1))
+ if ((h5tools_canreadf((options->m_verbose?obj1_name:NULL),dcpl1)==1) &&
+ (h5tools_canreadf((options->m_verbose?obj2_name:NULL),dcpl2)==1))
{
- nfound=diff_datasetid(dset1_id,
- dset2_id,
- obj1_name,
- obj2_name,
- options);
+ nfound=diff_datasetid(did1,
+ did2,
+ obj1_name,
+ obj2_name,
+ options);
}
/*-------------------------------------------------------------------------
* close
@@ -145,10 +148,10 @@ hsize_t diff_dataset( hid_t file1_id,
*/
/* disable error reporting */
H5E_BEGIN_TRY {
- H5Pclose(dcpl1_id);
- H5Pclose(dcpl2_id);
- H5Dclose(dset1_id);
- H5Dclose(dset2_id);
+ H5Pclose(dcpl1);
+ H5Pclose(dcpl2);
+ H5Dclose(did1);
+ H5Dclose(did2);
/* enable error reporting */
} H5E_END_TRY;
@@ -158,10 +161,10 @@ error:
options->err_stat=1;
/* disable error reporting */
H5E_BEGIN_TRY {
- H5Pclose(dcpl1_id);
- H5Pclose(dcpl2_id);
- H5Dclose(dset1_id);
- H5Dclose(dset2_id);
+ H5Pclose(dcpl1);
+ H5Pclose(dcpl2);
+ H5Dclose(did1);
+ H5Dclose(did2);
/* enable error reporting */
} H5E_END_TRY;
@@ -182,21 +185,28 @@ error:
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_datasetid( hid_t dset1_id,
- hid_t dset2_id,
+hsize_t diff_datasetid( hid_t did1,
+ hid_t did2,
const char *obj1_name,
const char *obj2_name,
diff_opt_t *options )
{
- hid_t space1_id =-1;
- hid_t space2_id =-1;
- hid_t f_type1=-1, f_type2=-1; /* file data type */
- hid_t m_type1=-1, m_type2=-1; /* memory data type */
- size_t m_size1, m_size2; /* size of type in memory */
- H5T_sign_t sign1, sign2; /* sign of type */
- int rank1, rank2;
- void *buf1=NULL, *buf2=NULL;
- hsize_t nelmts1, nelmts2;
+ hid_t sid1;
+ hid_t sid2;
+ hid_t f_tid1;
+ hid_t f_tid2; /* file data type */
+ hid_t m_tid1;
+ hid_t m_tid2; /* memory data type */
+ size_t m_size1;
+ size_t m_size2; /* size of type in memory */
+ H5T_sign_t sign1;
+ H5T_sign_t sign2; /* sign of type */
+ int rank1;
+ int rank2;
+ void *buf1=NULL;
+ void *buf2=NULL;
+ hsize_t nelmts1;
+ hsize_t nelmts2;
hsize_t dims1[H5S_MAX_RANK];
hsize_t dims2[H5S_MAX_RANK];
hsize_t maxdim1[H5S_MAX_RANK];
@@ -210,27 +220,27 @@ hsize_t diff_datasetid( hid_t dset1_id,
int i;
/* Get the dataspace handle */
- if ( (space1_id = H5Dget_space(dset1_id)) < 0 )
+ if ( (sid1 = H5Dget_space(did1)) < 0 )
goto error;
/* Get rank */
- if ( (rank1 = H5Sget_simple_extent_ndims(space1_id)) < 0 )
+ if ( (rank1 = H5Sget_simple_extent_ndims(sid1)) < 0 )
goto error;
/* Get the dataspace handle */
- if ( (space2_id = H5Dget_space(dset2_id)) < 0 )
+ if ( (sid2 = H5Dget_space(did2)) < 0 )
goto error;
/* Get rank */
- if ( (rank2 = H5Sget_simple_extent_ndims(space2_id)) < 0 )
+ if ( (rank2 = H5Sget_simple_extent_ndims(sid2)) < 0 )
goto error;
/* Get dimensions */
- if ( H5Sget_simple_extent_dims(space1_id,dims1,maxdim1) < 0 )
+ if ( H5Sget_simple_extent_dims(sid1,dims1,maxdim1) < 0 )
goto error;
/* Get dimensions */
- if ( H5Sget_simple_extent_dims(space2_id,dims2,maxdim2) < 0 )
+ if ( H5Sget_simple_extent_dims(sid2,dims2,maxdim2) < 0 )
goto error;
/*-------------------------------------------------------------------------
@@ -239,11 +249,11 @@ hsize_t diff_datasetid( hid_t dset1_id,
*/
/* Get the data type */
- if ( (f_type1 = H5Dget_type(dset1_id)) < 0 )
+ if ( (f_tid1 = H5Dget_type(did1)) < 0 )
goto error;
/* Get the data type */
- if ( (f_type2 = H5Dget_type(dset2_id)) < 0 )
+ if ( (f_tid2 = H5Dget_type(did2)) < 0 )
goto error;
@@ -252,8 +262,8 @@ hsize_t diff_datasetid( hid_t dset1_id,
*-------------------------------------------------------------------------
*/
- storage_size1=H5Dget_storage_size(dset1_id);
- storage_size2=H5Dget_storage_size(dset2_id);
+ storage_size1=H5Dget_storage_size(did1);
+ storage_size2=H5Dget_storage_size(did2);
if (storage_size1<=0 && storage_size2<=0)
{
if (options->m_verbose && obj1_name && obj2_name)
@@ -268,8 +278,8 @@ hsize_t diff_datasetid( hid_t dset1_id,
*-------------------------------------------------------------------------
*/
- if (diff_can_type(f_type1,
- f_type2,
+ if (diff_can_type(f_tid1,
+ f_tid2,
rank1,
rank2,
dims1,
@@ -288,18 +298,18 @@ hsize_t diff_datasetid( hid_t dset1_id,
* memory type and sizes
*-------------------------------------------------------------------------
*/
- if ((m_type1=h5tools_get_native_type(f_type1))<0)
+ if ((m_tid1=h5tools_get_native_type(f_tid1))<0)
goto error;
- if ((m_type2=h5tools_get_native_type(f_type2))<0)
+ if ((m_tid2=h5tools_get_native_type(f_tid2))<0)
goto error;
- m_size1 = H5Tget_size( m_type1 );
- m_size2 = H5Tget_size( m_type2 );
+ m_size1 = H5Tget_size( m_tid1 );
+ m_size2 = H5Tget_size( m_tid2 );
#if defined (H5DIFF_DEBUG)
if (obj1_name)
- print_sizes(obj1_name,obj2_name,f_type1,f_type2,m_type1,m_type2);
+ print_sizes(obj1_name,obj2_name,f_tid1,f_tid2,m_tid1,m_tid2);
#endif
/*-------------------------------------------------------------------------
@@ -307,8 +317,8 @@ hsize_t diff_datasetid( hid_t dset1_id,
*-------------------------------------------------------------------------
*/
- sign1=H5Tget_sign(m_type1);
- sign2=H5Tget_sign(m_type2);
+ sign1=H5Tget_sign(m_tid1);
+ sign2=H5Tget_sign(m_tid2);
if ( sign1 != sign2 )
{
if (options->m_verbose && obj1_name) {
@@ -355,26 +365,26 @@ hsize_t diff_datasetid( hid_t dset1_id,
{
if ( m_size1 < m_size2 )
{
- H5Tclose(m_type1);
+ H5Tclose(m_tid1);
- if ((m_type1=h5tools_get_native_type(f_type2))<0)
+ if ((m_tid1=h5tools_get_native_type(f_tid2))<0)
goto error;
- m_size1 = H5Tget_size( m_type1 );
+ m_size1 = H5Tget_size( m_tid1 );
}
else
{
- H5Tclose(m_type2);
+ H5Tclose(m_tid2);
- if ((m_type2=h5tools_get_native_type(f_type1))<0)
+ if ((m_tid2=h5tools_get_native_type(f_tid1))<0)
goto error;
- m_size2 = H5Tget_size( m_type2 );
+ m_size2 = H5Tget_size( m_tid2 );
}
#if defined (H5DIFF_DEBUG)
printf("WARNING: Size was upgraded\n");
if (obj1_name)
- print_sizes(obj1_name,obj2_name,f_type1,f_type2,m_type1,m_type2);
+ print_sizes(obj1_name,obj2_name,f_tid1,f_tid2,m_tid1,m_tid2);
#endif
}
assert(m_size1==m_size2);
@@ -394,10 +404,10 @@ hsize_t diff_datasetid( hid_t dset1_id,
*-------------------------------------------------------------------------
*/
- if ( H5Dread(dset1_id,m_type1,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf1) < 0 )
+ if ( H5Dread(did1,m_tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf1) < 0 )
goto error;
- if ( H5Dread(dset2_id,m_type2,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf2) < 0 )
+ if ( H5Dread(did2,m_tid2,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf2) < 0 )
goto error;
/*-------------------------------------------------------------------------
@@ -418,9 +428,9 @@ hsize_t diff_datasetid( hid_t dset1_id,
options,
name1,
name2,
- m_type1,
- dset1_id,
- dset2_id);
+ m_tid1,
+ did1,
+ did2);
/*-------------------------------------------------------------------------
* compare attributes
* the if condition refers to cases when the dataset is a referenced object
@@ -428,7 +438,7 @@ hsize_t diff_datasetid( hid_t dset1_id,
*/
if (obj1_name)
- diff_attr(dset1_id,dset2_id,obj1_name,obj2_name,options);
+ diff_attr(did1,did2,obj1_name,obj2_name,options);
}/*cmp*/
@@ -443,12 +453,12 @@ hsize_t diff_datasetid( hid_t dset1_id,
/* close */
/* disable error reporting */
H5E_BEGIN_TRY {
- H5Sclose(space1_id);
- H5Sclose(space2_id);
- H5Tclose(f_type1);
- H5Tclose(f_type2);
- H5Tclose(m_type1);
- H5Tclose(m_type2);
+ H5Sclose(sid1);
+ H5Sclose(sid2);
+ H5Tclose(f_tid1);
+ H5Tclose(f_tid2);
+ H5Tclose(m_tid1);
+ H5Tclose(m_tid2);
/* enable error reporting */
} H5E_END_TRY;
@@ -461,12 +471,12 @@ error:
/* close */
/* disable error reporting */
H5E_BEGIN_TRY {
- H5Sclose(space1_id);
- H5Sclose(space2_id);
- H5Tclose(f_type1);
- H5Tclose(f_type2);
- H5Tclose(m_type1);
- H5Tclose(m_type2);
+ H5Sclose(sid1);
+ H5Sclose(sid2);
+ H5Tclose(f_tid1);
+ H5Tclose(f_tid2);
+ H5Tclose(m_tid1);
+ H5Tclose(m_tid2);
/* enable error reporting */
} H5E_END_TRY;
@@ -490,8 +500,8 @@ error:
*-------------------------------------------------------------------------
*/
-int diff_can_type( hid_t f_type1, /* file data type */
- hid_t f_type2, /* file data type */
+int diff_can_type( hid_t f_tid1, /* file data type */
+ hid_t f_tid2, /* file data type */
int rank1,
int rank2,
hsize_t *dims1,
@@ -515,10 +525,10 @@ int diff_can_type( hid_t f_type1, /* file data type */
*-------------------------------------------------------------------------
*/
- if ((tclass1=H5Tget_class(f_type1))<0)
+ if ((tclass1=H5Tget_class(f_tid1))<0)
return -1;
- if ((tclass2=H5Tget_class(f_type2))<0)
+ if ((tclass2=H5Tget_class(f_tid2))<0)
return -1;
if ( tclass1 != tclass2 )
@@ -564,14 +574,14 @@ int diff_can_type( hid_t f_type1, /* file data type */
*-------------------------------------------------------------------------
*/
- if ( (H5Tequal(f_type1, f_type2)==0) && options->m_verbose && obj1_name)
+ if ( (H5Tequal(f_tid1, f_tid2)==0) && options->m_verbose && obj1_name)
{
printf("warning: different storage datatype\n");
printf("<%s> has file datatype ", obj1_name);
- print_type(f_type1);
+ print_type(f_tid1);
printf("\n");
printf("<%s> has file datatype ", obj2_name);
- print_type(f_type2);
+ print_type(f_tid2);
printf("\n");
}
diff --git a/tools/testfiles/file7.h5 b/tools/testfiles/file7.h5
index 18dd816..4b6aa3c 100644
--- a/tools/testfiles/file7.h5
+++ b/tools/testfiles/file7.h5
Binary files differ
diff --git a/tools/testfiles/file8.h5 b/tools/testfiles/file8.h5
index 643483b..1229ea7 100644
--- a/tools/testfiles/file8.h5
+++ b/tools/testfiles/file8.h5
Binary files differ
diff --git a/tools/testfiles/h5diff_80.txt b/tools/testfiles/h5diff_80.txt
index a3a5b15..2e0c6ac 100644
--- a/tools/testfiles/h5diff_80.txt
+++ b/tools/testfiles/h5diff_80.txt
@@ -5,6 +5,7 @@ Expected output for 'h5diff file7.h5 file8.h5 -v'
file1 file2
---------------------------------------
x x /dset
+ x x /dsetref
x x /g1
x x /g1/array
x x /g1/array2D
@@ -36,6 +37,7 @@ file1 file2
x x /g1/vlen
x x /g1/vlen2D
x x /g1/vlen3D
+ x x /refreg
Dataset: </dset> and </dset>
position dset dset difference
@@ -43,6 +45,8 @@ position dset dset difference
[ 0 ] 1 0 1
[ 1 ] 2 0 2
2 differences found
+Dataset: </dsetref> and </dsetref>
+0 differences found
Group: </g1> and </g1>
0 differences found
Dataset: </g1/array> and </g1/array>
@@ -710,6 +714,16 @@ position vlen3D vlen3D difference
[ 3 2 1 ] 58 0 58
[ 3 2 1 ] 59 0 59
59 differences found
+Dataset: </refreg> and </refreg>
+Referenced dataset 5888 5888
+------------------------------------------------------------
+Region blocks
+block #0 (2,2)-(7,7) (0,0)-(2,2)
+Region points
+point #0 (6,9) (5,8)
+point #1 (2,2) (3,3)
+point #2 (8,4) (7,5)
+4 differences found
Group: </> and </>
0 differences found
--------------------------------