diff options
-rw-r--r-- | MANIFEST | 4 | ||||
-rwxr-xr-x | bin/release | 11 | ||||
-rwxr-xr-x | bin/snapshot | 1 | ||||
-rwxr-xr-x | bin/trace | 6 | ||||
-rw-r--r-- | src/.distdep | 824 | ||||
-rw-r--r-- | src/H5.c | 24 | ||||
-rw-r--r-- | src/H5A.c | 24 | ||||
-rw-r--r-- | src/H5D.c | 69 | ||||
-rw-r--r-- | src/H5Distore.c | 10 | ||||
-rw-r--r-- | src/H5Dprivate.h | 1 | ||||
-rw-r--r-- | src/H5E.c | 13 | ||||
-rw-r--r-- | src/H5Epublic.h | 3 | ||||
-rw-r--r-- | src/H5F.c | 14 | ||||
-rw-r--r-- | src/H5Fistore.c | 10 | ||||
-rw-r--r-- | src/H5Flow.c | 14 | ||||
-rw-r--r-- | src/H5G.c | 28 | ||||
-rw-r--r-- | src/H5Iprivate.h | 5 | ||||
-rw-r--r-- | src/H5Ipublic.h | 1 | ||||
-rw-r--r-- | src/H5MF.c | 2 | ||||
-rw-r--r-- | src/H5P.c | 94 | ||||
-rw-r--r-- | src/H5R.c | 1075 | ||||
-rw-r--r-- | src/H5Rprivate.h | 27 | ||||
-rw-r--r-- | src/H5Rpublic.h | 28 | ||||
-rw-r--r-- | src/H5S.c | 26 | ||||
-rw-r--r-- | src/H5Shyper.c | 14 | ||||
-rw-r--r-- | src/H5Sprivate.h | 5 | ||||
-rw-r--r-- | src/H5Sselect.c | 239 | ||||
-rw-r--r-- | src/H5T.c | 94 | ||||
-rw-r--r-- | src/H5TB.c | 8 | ||||
-rw-r--r-- | src/H5Tconv.c | 3 | ||||
-rw-r--r-- | src/H5Z.c | 2 | ||||
-rw-r--r-- | src/H5private.h | 3 | ||||
-rw-r--r-- | src/Makefile.in | 8 | ||||
-rw-r--r-- | src/hdf5.h | 1 | ||||
-rw-r--r-- | test/.distdep | 160 | ||||
-rw-r--r-- | test/bittests.c | 2 | ||||
-rw-r--r-- | test/cmpd_dset.c | 500 | ||||
-rw-r--r-- | test/ragged.c | 249 | ||||
-rw-r--r-- | tools/h5import.c | 12 | ||||
-rw-r--r-- | tools/h5tools.c | 20 |
40 files changed, 2662 insertions, 972 deletions
@@ -223,6 +223,9 @@ ./src/H5P.c ./src/H5Pprivate.h ./src/H5Ppublic.h +./src/H5R.c +./src/H5Rprivate.h +./src/H5Rpublic.h ./src/H5S.c ./src/H5Sall.c ./src/H5Shyper.c @@ -266,6 +269,7 @@ ./test/istore.c ./test/links.c ./test/mtime.c +./test/ragged.c ./test/shtype.c ./test/testhdf5.c ./test/testhdf5.h diff --git a/bin/release b/bin/release index 8c1e5aa..3b975d3 100755 --- a/bin/release +++ b/bin/release @@ -73,6 +73,17 @@ for cvs in `find . -type d -name CVS -print`; do fi done done +for file in ./Changes `svf ls`; do + if (grep $file MANIFEST >/dev/null); then + : + elif [ $file = ./Changes ]; then + : + else + echo "+ $file" + fail=yes + fi +done + if [ "X$fail" = "Xyes" ]; then cat 1>&2 <<EOF The MANIFEST is out of date. Files marked with a minus sign (-) no diff --git a/bin/snapshot b/bin/snapshot index 0b0edd4..74a724b 100755 --- a/bin/snapshot +++ b/bin/snapshot @@ -41,6 +41,7 @@ cvs -Q co -d ${COMPARE}/current hdf5 || exit 1 snapshot=yes if [ -d ${COMPARE}/previous ]; then if (diff -c ${COMPARE}/previous/MANIFEST ${COMPARE}/current/MANIFEST); then + snapshot=no for src in `cat ${COMPARE}/current/MANIFEST`; do if (diff -I H5_VERS_RELEASE -I " released on " \ ${COMPARE}/previous/$src ${COMPARE}/current/$src); then @@ -93,10 +93,10 @@ sub argstring ($$$) { $atype =~ s/\s+$//; if ($atype =~ /(.*)\[(.*)\]$/) { ($array, $atype) = ($2, $1); + $atype =~ s/\s+$//; } $fq_atype = $atype . ('*' x $ptr); - if ($ptr>0 && exists $TypeString{$fq_atype}) { $ptr = 0; $tstr = $TypeString{$fq_atype}; @@ -172,7 +172,7 @@ sub rewrite_func ($$$$$) { $trace .= join("", @arg_str) . "\""; my $len = 4 + length $trace; for (@arg_name) { - if ($len + length >= 78) { + if ($len + length >= 77) { $trace .= ",\n $_"; $len = 13 + length; } else { @@ -203,7 +203,7 @@ sub rewrite_func ($$$$$) { error: - return "\n$type\n$name ($args)\n$body"; + return "\n$type\n$name($args)\n$body"; } ############################################################################## diff --git a/src/.distdep b/src/.distdep index 9f9d5a9..adc5f19 100644 --- a/src/.distdep +++ b/src/.distdep @@ -1,172 +1,3 @@ -H5.o: \ - H5.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5ACprivate.h \ - H5ACpublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Ipublic.h \ - H5Dpublic.h \ - H5Bprivate.h \ - H5Bpublic.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5Iprivate.h \ - H5MMprivate.h \ - H5MMpublic.h \ - H5Pprivate.h \ - H5Ppublic.h \ - H5Zpublic.h \ - H5Sprivate.h \ - H5Spublic.h \ - H5Gprivate.h \ - H5Gpublic.h \ - H5Oprivate.h \ - H5Opublic.h \ - H5HGprivate.h \ - H5HGpublic.h \ - H5Tprivate.h \ - H5Tpublic.h -H5A.o: \ - H5A.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5Iprivate.h \ - H5Ipublic.h \ - H5Bprivate.h \ - H5Bpublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Dpublic.h \ - H5Dprivate.h \ - H5Gprivate.h \ - H5Gpublic.h \ - H5Oprivate.h \ - H5Opublic.h \ - H5HGprivate.h \ - H5HGpublic.h \ - H5Tprivate.h \ - H5Tpublic.h \ - H5Sprivate.h \ - H5Spublic.h \ - H5Zprivate.h \ - H5Zpublic.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5MMprivate.h \ - H5MMpublic.h \ - H5Pprivate.h \ - H5Ppublic.h \ - H5Apkg.h \ - H5Aprivate.h -H5AC.o: \ - H5AC.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5ACprivate.h \ - H5ACpublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Ipublic.h \ - H5Dpublic.h \ - H5Eprivate.h \ - H5Epublic.h -H5B.o: \ - H5B.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5ACprivate.h \ - H5ACpublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Ipublic.h \ - H5Dpublic.h \ - H5Bprivate.h \ - H5Bpublic.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5MFprivate.h \ - H5MFpublic.h \ - H5MMprivate.h -H5D.o: \ - H5D.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5Iprivate.h \ - H5Ipublic.h \ - H5ACprivate.h \ - H5ACpublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Dpublic.h \ - H5Dprivate.h \ - H5Gprivate.h \ - H5Gpublic.h \ - H5Bprivate.h \ - H5Bpublic.h \ - H5Oprivate.h \ - H5Opublic.h \ - H5HGprivate.h \ - H5HGpublic.h \ - H5Tprivate.h \ - H5Tpublic.h \ - H5Sprivate.h \ - H5Spublic.h \ - H5Zprivate.h \ - H5Zpublic.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5HLprivate.h \ - H5HLpublic.h \ - H5MFprivate.h \ - H5MFpublic.h -H5E.o: \ - H5E.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5Iprivate.h \ - H5Ipublic.h \ - H5Eprivate.h -H5F.o: \ - H5F.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5Aprivate.h \ - H5Apublic.h \ - H5Ipublic.h \ - H5Gprivate.h \ - H5Gpublic.h \ - H5Bprivate.h \ - H5Bpublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Dpublic.h \ - H5Dprivate.h \ - H5Oprivate.h \ - H5Opublic.h \ - H5HGprivate.h \ - H5HGpublic.h \ - H5Tprivate.h \ - H5Tpublic.h \ - H5Sprivate.h \ - H5Spublic.h \ - H5Zprivate.h \ - H5Zpublic.h \ - H5Iprivate.h \ - H5ACprivate.h \ - H5ACpublic.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5MMprivate.h \ - H5MMpublic.h H5Farray.o: \ H5Farray.c \ H5private.h \ @@ -203,55 +34,6 @@ H5Fcore.o: \ H5Eprivate.h \ H5Epublic.h \ H5Ipublic.h -H5Ffamily.o: \ - H5Ffamily.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5Ipublic.h -H5Fistore.o: \ - H5Fistore.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5Dprivate.h \ - H5Dpublic.h \ - H5Ipublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Gprivate.h \ - H5Gpublic.h \ - H5Bprivate.h \ - H5Bpublic.h \ - H5Oprivate.h \ - H5Opublic.h \ - H5HGprivate.h \ - H5HGpublic.h \ - H5Tprivate.h \ - H5Tpublic.h \ - H5Sprivate.h \ - H5Spublic.h \ - H5Zprivate.h \ - H5Zpublic.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5MFprivate.h \ - H5MFpublic.h -H5Flow.o: \ - H5Flow.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5Ipublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Dpublic.h \ - H5MMprivate.h \ - H5MMpublic.h H5Fmpio.o: \ H5Fmpio.c \ H5private.h \ @@ -319,39 +101,6 @@ H5Fstdio.o: \ H5Dpublic.h \ H5MMprivate.h \ H5MMpublic.h -H5G.o: \ - H5G.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5Bprivate.h \ - H5Bpublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Ipublic.h \ - H5Dpublic.h \ - H5Dprivate.h \ - H5Gprivate.h \ - H5Gpublic.h \ - H5Oprivate.h \ - H5Opublic.h \ - H5HGprivate.h \ - H5HGpublic.h \ - H5Tprivate.h \ - H5Tpublic.h \ - H5Sprivate.h \ - H5Spublic.h \ - H5Zprivate.h \ - H5Zpublic.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5Gpkg.h \ - H5ACprivate.h \ - H5ACpublic.h \ - H5HLprivate.h \ - H5HLpublic.h \ - H5Iprivate.h \ - H5MMprivate.h H5Gent.o: \ H5Gent.c \ H5private.h \ @@ -450,24 +199,6 @@ H5HG.o: \ H5MFprivate.h \ H5MFpublic.h \ H5MMprivate.h -H5HL.o: \ - H5HL.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5ACprivate.h \ - H5ACpublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Ipublic.h \ - H5Dpublic.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5HLprivate.h \ - H5HLpublic.h \ - H5MFprivate.h \ - H5MFpublic.h \ - H5MMprivate.h H5I.o: \ H5I.c \ H5private.h \ @@ -476,14 +207,6 @@ H5I.o: \ H5Iprivate.h \ H5Ipublic.h \ H5Eprivate.h -H5MF.o: \ - H5MF.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5Ipublic.h H5MM.o: \ H5MM.c \ H5private.h \ @@ -492,34 +215,6 @@ H5MM.o: \ H5Eprivate.h \ H5Epublic.h \ H5Ipublic.h -H5O.o: \ - H5O.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5ACprivate.h \ - H5ACpublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Ipublic.h \ - H5Dpublic.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5MFprivate.h \ - H5MFpublic.h \ - H5MMprivate.h \ - H5MMpublic.h \ - H5Oprivate.h \ - H5Opublic.h \ - H5Gprivate.h \ - H5Gpublic.h \ - H5Bprivate.h \ - H5Bpublic.h \ - H5HGprivate.h \ - H5HGpublic.h \ - H5Tprivate.h \ - H5Tpublic.h \ - H5Sprivate.h H5Oattr.o: \ H5Oattr.c \ H5private.h \ @@ -668,8 +363,8 @@ H5Olayout.o: \ H5Sprivate.h \ H5Spublic.h \ H5Zprivate.h -H5Omtime.o: \ - H5Omtime.c \ +H5Oname.o: \ + H5Oname.c \ H5private.h \ H5public.h \ H5config.h \ @@ -691,8 +386,49 @@ H5Omtime.o: \ H5HGpublic.h \ H5Tprivate.h \ H5Tpublic.h -H5Oname.o: \ - H5Oname.c \ +H5Onull.o: \ + H5Onull.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5Oprivate.h \ + H5Opublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Ipublic.h \ + H5Dpublic.h \ + H5Gprivate.h \ + H5Gpublic.h \ + H5Bprivate.h \ + H5Bpublic.h \ + H5HGprivate.h \ + H5HGpublic.h \ + H5Tprivate.h +H5Osdspace.o: \ + H5Osdspace.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5Ipublic.h \ + H5Gprivate.h \ + H5Gpublic.h \ + H5Bprivate.h \ + H5Bpublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Dpublic.h \ + H5MMprivate.h \ + H5MMpublic.h \ + H5Oprivate.h \ + H5Opublic.h \ + H5HGprivate.h \ + H5HGpublic.h \ + H5Tprivate.h \ + H5Tpublic.h +H5Oshared.o: \ + H5Oshared.c \ H5private.h \ H5public.h \ H5config.h \ @@ -714,49 +450,198 @@ H5Oname.o: \ H5HGpublic.h \ H5Tprivate.h \ H5Tpublic.h -H5Onull.o: \ - H5Onull.c \ +H5Ostab.o: \ + H5Ostab.c \ H5private.h \ H5public.h \ H5config.h \ - H5Oprivate.h \ - H5Opublic.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5Ipublic.h \ + H5Gprivate.h \ + H5Gpublic.h \ + H5Bprivate.h \ + H5Bpublic.h \ H5Fprivate.h \ H5Fpublic.h \ - H5Ipublic.h \ H5Dpublic.h \ + H5MMprivate.h \ + H5MMpublic.h \ + H5Oprivate.h \ + H5Opublic.h \ + H5HGprivate.h \ + H5HGpublic.h \ + H5Tprivate.h \ + H5Tpublic.h +H5Sall.o: \ + H5Sall.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5Ipublic.h \ + H5Sprivate.h \ + H5Spublic.h \ H5Gprivate.h \ H5Gpublic.h \ H5Bprivate.h \ H5Bpublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Dpublic.h \ + H5Oprivate.h \ + H5Opublic.h \ + H5HGprivate.h \ + H5HGpublic.h \ + H5Tprivate.h \ + H5Tpublic.h +H5Tbit.o: \ + H5Tbit.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5Ipublic.h \ + H5Iprivate.h \ + H5Tpkg.h \ + H5HGprivate.h \ + H5HGpublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Dpublic.h \ + H5Tprivate.h \ + H5Tpublic.h \ + H5Gprivate.h +H5Tinit.o: \ + H5Tinit.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5Iprivate.h \ + H5Ipublic.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5MMprivate.h \ + H5MMpublic.h \ + H5Tpkg.h \ H5HGprivate.h \ H5HGpublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Dpublic.h \ H5Tprivate.h -H5Osdspace.o: \ - H5Osdspace.c \ +H5V.o: \ + H5V.c \ H5private.h \ H5public.h \ H5config.h \ H5Eprivate.h \ H5Epublic.h \ H5Ipublic.h \ + H5Oprivate.h \ + H5Opublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Dpublic.h \ H5Gprivate.h \ H5Gpublic.h \ H5Bprivate.h \ H5Bpublic.h \ + H5HGprivate.h \ + H5HGpublic.h \ + H5Tprivate.h \ + H5Tpublic.h \ + H5Sprivate.h \ + H5Spublic.h +H5AC.o: \ + H5AC.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5ACprivate.h \ + H5ACpublic.h \ H5Fprivate.h \ H5Fpublic.h \ + H5Ipublic.h \ H5Dpublic.h \ + H5Eprivate.h \ + H5Epublic.h +H5B.o: \ + H5B.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5ACprivate.h \ + H5ACpublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Ipublic.h \ + H5Dpublic.h \ + H5Bprivate.h \ + H5Bpublic.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5MFprivate.h \ + H5MFpublic.h \ + H5MMprivate.h +H5Ffamily.o: \ + H5Ffamily.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5Ipublic.h +H5HL.o: \ + H5HL.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5ACprivate.h \ + H5ACpublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Ipublic.h \ + H5Dpublic.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5HLprivate.h \ + H5HLpublic.h \ + H5MFprivate.h \ + H5MFpublic.h \ + H5MMprivate.h +H5O.o: \ + H5O.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5ACprivate.h \ + H5ACpublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Ipublic.h \ + H5Dpublic.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5MFprivate.h \ + H5MFpublic.h \ H5MMprivate.h \ H5MMpublic.h \ H5Oprivate.h \ H5Opublic.h \ + H5Gprivate.h \ + H5Gpublic.h \ + H5Bprivate.h \ + H5Bpublic.h \ H5HGprivate.h \ H5HGpublic.h \ H5Tprivate.h \ - H5Tpublic.h -H5Oshared.o: \ - H5Oshared.c \ + H5Tpublic.h \ + H5Sprivate.h +H5Omtime.o: \ + H5Omtime.c \ H5private.h \ H5public.h \ H5config.h \ @@ -778,31 +663,67 @@ H5Oshared.o: \ H5HGpublic.h \ H5Tprivate.h \ H5Tpublic.h -H5Ostab.o: \ - H5Ostab.c \ +H5Fistore.o: \ + H5Fistore.c \ H5private.h \ H5public.h \ H5config.h \ - H5Eprivate.h \ - H5Epublic.h \ + H5Dprivate.h \ + H5Dpublic.h \ H5Ipublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ H5Gprivate.h \ H5Gpublic.h \ H5Bprivate.h \ H5Bpublic.h \ + H5Oprivate.h \ + H5Opublic.h \ + H5HGprivate.h \ + H5HGpublic.h \ + H5Tprivate.h \ + H5Tpublic.h \ + H5Sprivate.h \ + H5Spublic.h \ + H5Zprivate.h \ + H5Zpublic.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5MFprivate.h \ + H5MFpublic.h +H5.o: \ + H5.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5ACprivate.h \ + H5ACpublic.h \ H5Fprivate.h \ H5Fpublic.h \ + H5Ipublic.h \ H5Dpublic.h \ + H5Bprivate.h \ + H5Bpublic.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5Iprivate.h \ H5MMprivate.h \ H5MMpublic.h \ + H5Pprivate.h \ + H5Ppublic.h \ + H5Zpublic.h \ + H5Sprivate.h \ + H5Spublic.h \ + H5Gprivate.h \ + H5Gpublic.h \ H5Oprivate.h \ H5Opublic.h \ H5HGprivate.h \ H5HGpublic.h \ H5Tprivate.h \ H5Tpublic.h -H5P.o: \ - H5P.c \ +H5A.o: \ + H5A.c \ H5private.h \ H5public.h \ H5config.h \ @@ -828,53 +749,219 @@ H5P.o: \ H5Zpublic.h \ H5Eprivate.h \ H5Epublic.h \ - H5MMprivate.h -H5S.o: \ - H5S.c \ + H5MMprivate.h \ + H5MMpublic.h \ + H5Pprivate.h \ + H5Ppublic.h \ + H5Apkg.h \ + H5Aprivate.h +H5D.o: \ + H5D.c \ H5private.h \ H5public.h \ H5config.h \ H5Iprivate.h \ H5Ipublic.h \ + H5ACprivate.h \ + H5ACpublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Dpublic.h \ + H5Dprivate.h \ + H5Gprivate.h \ + H5Gpublic.h \ + H5Bprivate.h \ + H5Bpublic.h \ + H5Oprivate.h \ + H5Opublic.h \ + H5HGprivate.h \ + H5HGpublic.h \ + H5Tprivate.h \ + H5Tpublic.h \ + H5Sprivate.h \ + H5Spublic.h \ + H5Zprivate.h \ + H5Zpublic.h \ H5Eprivate.h \ H5Epublic.h \ - H5MMprivate.h \ - H5MMpublic.h \ + H5HLprivate.h \ + H5HLpublic.h \ + H5MFprivate.h \ + H5MFpublic.h +H5E.o: \ + H5E.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5Iprivate.h \ + H5Ipublic.h \ + H5Eprivate.h +H5F.o: \ + H5F.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5Aprivate.h \ + H5Apublic.h \ + H5Ipublic.h \ + H5Gprivate.h \ + H5Gpublic.h \ + H5Bprivate.h \ + H5Bpublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Dpublic.h \ + H5Dprivate.h \ H5Oprivate.h \ H5Opublic.h \ + H5HGprivate.h \ + H5HGpublic.h \ + H5Tprivate.h \ + H5Tpublic.h \ + H5Sprivate.h \ + H5Spublic.h \ + H5Zprivate.h \ + H5Zpublic.h \ + H5Iprivate.h \ + H5ACprivate.h \ + H5ACpublic.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5MMprivate.h \ + H5MMpublic.h +H5Flow.o: \ + H5Flow.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5Ipublic.h \ H5Fprivate.h \ H5Fpublic.h \ H5Dpublic.h \ - H5Gprivate.h \ - H5Gpublic.h \ + H5MMprivate.h \ + H5MMpublic.h +H5G.o: \ + H5G.c \ + H5private.h \ + H5public.h \ + H5config.h \ H5Bprivate.h \ H5Bpublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Ipublic.h \ + H5Dpublic.h \ + H5Dprivate.h \ + H5Gprivate.h \ + H5Gpublic.h \ + H5Oprivate.h \ + H5Opublic.h \ H5HGprivate.h \ H5HGpublic.h \ - H5Tprivate.h -H5Sall.o: \ - H5Sall.c \ + H5Tprivate.h \ + H5Tpublic.h \ + H5Sprivate.h \ + H5Spublic.h \ + H5Zprivate.h \ + H5Zpublic.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5Gpkg.h \ + H5ACprivate.h \ + H5ACpublic.h \ + H5HLprivate.h \ + H5HLpublic.h \ + H5Iprivate.h \ + H5MMprivate.h +H5MF.o: \ + H5MF.c \ H5private.h \ H5public.h \ H5config.h \ H5Eprivate.h \ H5Epublic.h \ + H5Ipublic.h +H5P.o: \ + H5P.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5Iprivate.h \ H5Ipublic.h \ + H5Bprivate.h \ + H5Bpublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Dpublic.h \ + H5Dprivate.h \ + H5Gprivate.h \ + H5Gpublic.h \ + H5Oprivate.h \ + H5Opublic.h \ + H5HGprivate.h \ + H5HGpublic.h \ + H5Tprivate.h \ + H5Tpublic.h \ H5Sprivate.h \ H5Spublic.h \ + H5Zprivate.h \ + H5Zpublic.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5MMprivate.h +H5R.o: \ + H5R.c \ + H5Rprivate.h \ + H5Rpublic.h \ + H5Ipublic.h \ + H5public.h \ + H5config.h \ + H5Dprivate.h \ + H5Dpublic.h \ + H5private.h \ + H5Fprivate.h \ + H5Fpublic.h \ H5Gprivate.h \ H5Gpublic.h \ H5Bprivate.h \ H5Bpublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Dpublic.h \ H5Oprivate.h \ H5Opublic.h \ H5HGprivate.h \ H5HGpublic.h \ H5Tprivate.h \ - H5Tpublic.h + H5Tpublic.h \ + H5Sprivate.h \ + H5Spublic.h \ + H5Zprivate.h \ + H5Zpublic.h \ + H5Eprivate.h \ + H5Epublic.h +H5S.o: \ + H5S.c \ + H5private.h \ + H5public.h \ + H5config.h \ + H5Iprivate.h \ + H5Ipublic.h \ + H5Eprivate.h \ + H5Epublic.h \ + H5MMprivate.h \ + H5MMpublic.h \ + H5Oprivate.h \ + H5Opublic.h \ + H5Fprivate.h \ + H5Fpublic.h \ + H5Dpublic.h \ + H5Gprivate.h \ + H5Gpublic.h \ + H5Bprivate.h \ + H5Bpublic.h \ + H5HGprivate.h \ + H5HGpublic.h \ + H5Tprivate.h H5Shyper.o: \ H5Shyper.c \ H5private.h \ @@ -1000,24 +1087,6 @@ H5T.o: \ H5Eprivate.h \ H5Epublic.h \ H5MMprivate.h -H5Tbit.o: \ - H5Tbit.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5Ipublic.h \ - H5Iprivate.h \ - H5Tpkg.h \ - H5HGprivate.h \ - H5HGpublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Dpublic.h \ - H5Tprivate.h \ - H5Tpublic.h \ - H5Gprivate.h H5Tconv.o: \ H5Tconv.c \ H5Iprivate.h \ @@ -1041,24 +1110,6 @@ H5Tconv.o: \ H5Gpublic.h \ H5Bprivate.h \ H5Bpublic.h -H5Tinit.o: \ - H5Tinit.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5Iprivate.h \ - H5Ipublic.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5MMprivate.h \ - H5MMpublic.h \ - H5Tpkg.h \ - H5HGprivate.h \ - H5HGpublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Dpublic.h \ - H5Tprivate.h H5TB.o: \ H5TB.c \ H5private.h \ @@ -1067,29 +1118,6 @@ H5TB.o: \ H5Iprivate.h \ H5Ipublic.h \ H5Eprivate.h -H5V.o: \ - H5V.c \ - H5private.h \ - H5public.h \ - H5config.h \ - H5Eprivate.h \ - H5Epublic.h \ - H5Ipublic.h \ - H5Oprivate.h \ - H5Opublic.h \ - H5Fprivate.h \ - H5Fpublic.h \ - H5Dpublic.h \ - H5Gprivate.h \ - H5Gpublic.h \ - H5Bprivate.h \ - H5Bpublic.h \ - H5HGprivate.h \ - H5HGpublic.h \ - H5Tprivate.h \ - H5Tpublic.h \ - H5Sprivate.h \ - H5Spublic.h H5Z.o: \ H5Z.c \ H5private.h \ @@ -92,8 +92,6 @@ DESCRIPTION herr_t H5_init_library(void) { - const char *s = NULL; - FUNC_ENTER_INIT(H5_init_library, NULL, FAIL); /* @@ -349,7 +347,8 @@ H5_debug_mask(const char *s) { FILE *stream = stderr; char pkg_name[32], *rest; - int i, clear; + size_t i; + int clear; while (s && *s) { if (isalpha(*s) || '-'==*s || '+'==*s) { @@ -1685,6 +1684,12 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...) fprintf(out, " (tbuf"); } break; + case H5_RAGGED: + fprintf(out, "%ld", (long)obj); + if (strcmp(argname, "array")) { + fprintf(out, " (array)"); + } + break; default: fprintf(out, "%ld", (long)obj); fprintf (out, " (unknown class)"); @@ -2120,6 +2125,19 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...) if (ptr) { if (vp) { fprintf (out, "0x%lx", (unsigned long)vp); + if (asize_idx>=0 && asize[asize_idx]>=0) { + void **p = (void**)vp; + fprintf(out, " {"); + for (i=0; i<asize[asize_idx]; i++) { + if (p[i]) { + fprintf(out, "%s0x%lx", i?", ":"", + (unsigned long)(p[i])); + } else { + fprintf(out, "%sNULL", i?", ":""); + } + } + fprintf(out, "}"); + } } else { fprintf(out, "NULL"); } @@ -150,7 +150,7 @@ H5A_term_interface(void) * --------------------------------------------------------------------------*/ hid_t -H5Acreate (hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, +H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t plist_id) { void *obj = NULL; @@ -397,7 +397,7 @@ H5A_get_index(H5G_entry_t *ent, const char *name) * The LOC_ID can also be a named (committed) data type. --------------------------------------------------------------------------*/ hid_t -H5Aopen_name (hid_t loc_id, const char *name) +H5Aopen_name(hid_t loc_id, const char *name) { H5G_entry_t *ent = NULL; /*Symtab entry of object to attribute*/ void *obj = NULL; @@ -474,7 +474,7 @@ H5Aopen_name (hid_t loc_id, const char *name) * --------------------------------------------------------------------------*/ hid_t -H5Aopen_idx (hid_t loc_id, unsigned idx) +H5Aopen_idx(hid_t loc_id, unsigned idx) { H5G_entry_t *ent = NULL; /*Symtab entry of object to attribute */ void *obj = NULL; @@ -595,7 +595,7 @@ done: This function writes a complete attribute to disk. --------------------------------------------------------------------------*/ herr_t -H5Awrite (hid_t attr_id, hid_t type_id, void *buf) +H5Awrite(hid_t attr_id, hid_t type_id, void *buf) { H5A_t *attr = NULL; const H5T_t *mem_type = NULL; @@ -766,7 +766,7 @@ done: This function reads a complete attribute from disk. --------------------------------------------------------------------------*/ herr_t -H5Aread (hid_t attr_id, hid_t type_id, void *buf) +H5Aread(hid_t attr_id, hid_t type_id, void *buf) { H5A_t *attr = NULL; const H5T_t *mem_type = NULL; @@ -921,7 +921,7 @@ done: or resource leaks will develop. --------------------------------------------------------------------------*/ hid_t -H5Aget_space (hid_t attr_id) +H5Aget_space(hid_t attr_id) { H5A_t *attr = NULL; H5S_t *dst = NULL; @@ -978,7 +978,7 @@ H5Aget_space (hid_t attr_id) * then the data type is closed. --------------------------------------------------------------------------*/ hid_t -H5Aget_type (hid_t attr_id) +H5Aget_type(hid_t attr_id) { H5A_t *attr = NULL; H5T_t *dst = NULL; @@ -1043,7 +1043,7 @@ H5Aget_type (hid_t attr_id) properly terminate the string. --------------------------------------------------------------------------*/ size_t -H5Aget_name (hid_t attr_id, size_t buf_size, char *buf) +H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) { H5A_t *attr = NULL; size_t copy_len=0; @@ -1099,7 +1099,7 @@ H5Aget_name (hid_t attr_id, size_t buf_size, char *buf) * The LOC_ID can also be a named (committed) data type. --------------------------------------------------------------------------*/ int -H5Anum_attrs (hid_t loc_id) +H5Anum_attrs(hid_t loc_id) { H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */ void *obj = NULL; @@ -1184,7 +1184,7 @@ H5Anum_attrs (hid_t loc_id) * --------------------------------------------------------------------------*/ int -H5Aiterate (hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data) +H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data) { H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */ void *obj = NULL; @@ -1272,7 +1272,7 @@ H5Aiterate (hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data) * --------------------------------------------------------------------------*/ herr_t -H5Adelete (hid_t loc_id, const char *name) +H5Adelete(hid_t loc_id, const char *name) { H5A_t found_attr; H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */ @@ -1356,7 +1356,7 @@ H5Adelete (hid_t loc_id, const char *name) attribute ID will result in undefined behavior. --------------------------------------------------------------------------*/ herr_t -H5Aclose (hid_t attr_id) +H5Aclose(hid_t attr_id) { FUNC_ENTER(H5Aclose, FAIL); H5TRACE1("e","i",attr_id); @@ -178,7 +178,7 @@ H5D_term_interface(void) *------------------------------------------------------------------------- */ hid_t -H5Dcreate (hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, +H5Dcreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t plist_id) { H5G_t *loc = NULL; @@ -206,14 +206,12 @@ H5Dcreate (hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, NULL == (space = H5I_object(space_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); } - if (plist_id >= 0) { - if (H5P_DATASET_CREATE != H5P_get_class(plist_id) || - NULL == (create_parms = H5I_object(plist_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a dataset creation property list"); - } - } else { + if (H5P_DEFAULT==plist_id) { create_parms = &H5D_create_dflt; + } else if (H5P_DATASET_CREATE != H5P_get_class(plist_id) || + NULL == (create_parms = H5I_object(plist_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation property list"); } /* build and open the new dataset */ @@ -222,7 +220,7 @@ H5Dcreate (hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset"); } - /* Register the new datatype and get an ID for it */ + /* Register the new dataset to get an ID for it */ if ((ret_value = H5I_register(H5_DATASET, new_dset)) < 0) { H5D_close(new_dset); HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, @@ -253,7 +251,7 @@ H5Dcreate (hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, *------------------------------------------------------------------------- */ hid_t -H5Dopen (hid_t loc_id, const char *name) +H5Dopen(hid_t loc_id, const char *name) { H5G_t *loc = NULL; /*location holding the dataset */ H5D_t *dataset = NULL; /*the dataset */ @@ -307,7 +305,7 @@ H5Dopen (hid_t loc_id, const char *name) *------------------------------------------------------------------------- */ herr_t -H5Dclose (hid_t dset_id) +H5Dclose(hid_t dset_id) { H5D_t *dset = NULL; /* dataset object to release */ @@ -351,7 +349,7 @@ H5Dclose (hid_t dset_id) *------------------------------------------------------------------------- */ hid_t -H5Dget_space (hid_t dset_id) +H5Dget_space(hid_t dset_id) { H5D_t *dset = NULL; H5S_t *space = NULL; @@ -367,9 +365,9 @@ H5Dget_space (hid_t dset_id) } /* Read the data space message and return a data space object */ - if (NULL==(space=H5S_read (&(dset->ent)))) { + if (NULL==(space=H5D_get_space (dset))) { HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to load space info from dataset header"); + "unable to get data space"); } /* Create an atom */ @@ -384,6 +382,39 @@ H5Dget_space (hid_t dset_id) /*------------------------------------------------------------------------- + * Function: H5D_get_space + * + * Purpose: Returns the data space associated with the dataset. + * + * Return: Success: Ptr to a copy of the data space. + * + * Failure: NULL + * + * Programmer: Robb Matzke + * Tuesday, August 25, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +H5S_t * +H5D_get_space(H5D_t *dset) +{ + H5S_t *space = NULL; + + FUNC_ENTER(H5D_get_space, NULL); + assert(dset); + + if (NULL==(space=H5S_read(&(dset->ent)))) { + HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, + "unable to load space info from dataset header"); + } + + FUNC_LEAVE(space); +} + + +/*------------------------------------------------------------------------- * Function: H5Dget_type * * Purpose: Returns a copy of the file data type for a dataset. @@ -407,7 +438,7 @@ H5Dget_space (hid_t dset_id) *------------------------------------------------------------------------- */ hid_t -H5Dget_type (hid_t dset_id) +H5Dget_type(hid_t dset_id) { H5D_t *dset = NULL; @@ -464,7 +495,7 @@ H5Dget_type (hid_t dset_id) *------------------------------------------------------------------------- */ hid_t -H5Dget_create_plist (hid_t dset_id) +H5Dget_create_plist(hid_t dset_id) { H5D_t *dset = NULL; H5D_create_t *copied_parms = NULL; @@ -540,7 +571,7 @@ H5Dget_create_plist (hid_t dset_id) *------------------------------------------------------------------------- */ herr_t -H5Dread (hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, +H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf/*out*/) { H5D_t *dset = NULL; @@ -641,7 +672,7 @@ H5Dread (hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, *------------------------------------------------------------------------- */ herr_t -H5Dwrite (hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, +H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf) { H5D_t *dset = NULL; @@ -723,7 +754,7 @@ H5Dwrite (hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, *------------------------------------------------------------------------- */ herr_t -H5Dextend (hid_t dset_id, const hsize_t *size) +H5Dextend(hid_t dset_id, const hsize_t *size) { H5D_t *dset = NULL; diff --git a/src/H5Distore.c b/src/H5Distore.c index e94e627..6f758a8 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -508,7 +508,8 @@ H5F_istore_found(H5F_t __unused__ *f, const haddr_t *addr, /* Is this *really* the requested chunk? */ for (i=0; i<udata->mesg.ndims; i++) { - if (udata->key.offset[i]>=lt_key->offset[i]+udata->mesg.dim[i]) { + if (udata->key.offset[i] >= + lt_key->offset[i]+(hssize_t)(udata->mesg.dim[i])) { HRETURN(FAIL); } } @@ -1961,8 +1962,11 @@ H5F_istore_allocate (H5F_t *f, const H5O_layout_t *layout, /* Increment indices */ for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) { chunk_offset[i] += layout->dim[i]; - if (chunk_offset[i] >= space_dim[i]) chunk_offset[i] = 0; - else carry = 0; + if (chunk_offset[i] >= (hssize_t)(space_dim[i])) { + chunk_offset[i] = 0; + } else { + carry = 0; + } } if (carry) break; } diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index b5f2d26..4462e80 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -77,5 +77,6 @@ hid_t H5D_find_name (hid_t file_id, H5I_group_t UNUSED, const char *name); herr_t H5D_extend (H5D_t *dataset, const hsize_t *size); H5G_entry_t *H5D_entof (H5D_t *dataset); H5T_t *H5D_typeof (H5D_t *dset); +H5S_t *H5D_get_space(H5D_t *dset); #endif @@ -57,6 +57,7 @@ static const H5E_major_mesg_t H5E_major_mesg_g[] = { {H5E_ATTR, "Attribute layer"}, {H5E_PLINE, "Data filters layer"}, {H5E_EFL, "External file list"}, + {H5E_RAGGED, "Ragged array layer"}, }; static const H5E_minor_mesg_t H5E_minor_mesg_g[] = { @@ -157,7 +158,7 @@ void *H5E_auto_data_g = stderr; *------------------------------------------------------------------------- */ herr_t -H5Eset_auto (H5E_auto_t func, void *client_data) +H5Eset_auto(H5E_auto_t func, void *client_data) { FUNC_ENTER (H5Eset_auto, FAIL); H5TRACE2("e","xx",func,client_data); @@ -188,7 +189,7 @@ H5Eset_auto (H5E_auto_t func, void *client_data) *------------------------------------------------------------------------- */ herr_t -H5Eget_auto (H5E_auto_t *func, void **client_data) +H5Eget_auto(H5E_auto_t *func, void **client_data) { FUNC_ENTER (H5Eget_auto, FAIL); H5TRACE2("e","*x*x",func,client_data); @@ -219,7 +220,7 @@ H5Eget_auto (H5E_auto_t *func, void **client_data) *------------------------------------------------------------------------- */ herr_t -H5Eclear (void) +H5Eclear(void) { FUNC_ENTER (H5Eclear, FAIL); H5TRACE0("e",""); @@ -248,7 +249,7 @@ H5Eclear (void) *------------------------------------------------------------------------- */ herr_t -H5Eprint (FILE *stream) +H5Eprint(FILE *stream) { H5E_t *estack = H5E_get_my_stack (); hbool_t H5E_clearable_g = FALSE; /*override global*/ @@ -286,7 +287,7 @@ H5Eprint (FILE *stream) *------------------------------------------------------------------------- */ herr_t -H5Ewalk (H5E_direction_t direction, H5E_walk_t func, void *client_data) +H5Ewalk(H5E_direction_t direction, H5E_walk_t func, void *client_data) { hbool_t H5E_clearable_g = FALSE; /*override global*/ herr_t status = FAIL; @@ -334,7 +335,7 @@ H5Ewalk (H5E_direction_t direction, H5E_walk_t func, void *client_data) *------------------------------------------------------------------------- */ herr_t -H5Ewalk_cb (int n, H5E_error_t *err_desc, void *client_data) +H5Ewalk_cb(int n, H5E_error_t *err_desc, void *client_data) { FILE *stream = (FILE *)client_data; const char *maj_str = NULL; diff --git a/src/H5Epublic.h b/src/H5Epublic.h index 64f0ff4..43db4b3 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -73,7 +73,8 @@ typedef enum H5E_major_t { H5E_TEMPLATE, /*Property lists */ H5E_ATTR, /*Attribute */ H5E_PLINE, /*Data filters */ - H5E_EFL /*External file list */ + H5E_EFL, /*External file list */ + H5E_RAGGED /*Ragged arrays */ } H5E_major_t; /* Declare an enumerated type which holds all the valid minor HDF error codes */ @@ -260,7 +260,7 @@ H5F_encode_length_unusual(const H5F_t *f, uint8 **p, uint8 *l) *------------------------------------------------------------------------- */ hid_t -H5Fget_create_template (hid_t file_id) +H5Fget_create_template(hid_t file_id) { H5F_t *file = NULL; hid_t ret_value = FAIL; @@ -311,7 +311,7 @@ H5Fget_create_template (hid_t file_id) *------------------------------------------------------------------------- */ hid_t -H5Fget_access_template (hid_t file_id) +H5Fget_access_template(hid_t file_id) { H5F_t *f = NULL; H5F_access_t *tmpl = NULL; @@ -444,7 +444,7 @@ H5F_locate_signature(H5F_low_t *f_handle, const H5F_access_t *access_parms, This function determines if a file is an HDF5 format file. --------------------------------------------------------------------------*/ hbool_t -H5Fis_hdf5 (const char *filename) +H5Fis_hdf5(const char *filename) { H5F_low_t *f_handle = NULL; /* file handle */ haddr_t addr; /* Address of file signature & header */ @@ -1135,7 +1135,7 @@ H5F_open(const char *name, uintn flags, *------------------------------------------------------------------------- */ hid_t -H5Fcreate (const char *filename, unsigned flags, hid_t create_id, +H5Fcreate(const char *filename, unsigned flags, hid_t create_id, hid_t access_id) { @@ -1249,7 +1249,7 @@ H5Fcreate (const char *filename, unsigned flags, hid_t create_id, *------------------------------------------------------------------------- */ hid_t -H5Fopen (const char *filename, unsigned flags, hid_t access_id) +H5Fopen(const char *filename, unsigned flags, hid_t access_id) { H5F_t *new_file = NULL; /* file struct for new file */ const H5F_access_t *access_parms; /* pointer to the file access @@ -1317,7 +1317,7 @@ H5Fopen (const char *filename, unsigned flags, hid_t access_id) *------------------------------------------------------------------------- */ herr_t -H5Fflush (hid_t object_id) +H5Fflush(hid_t object_id) { H5F_t *f = NULL; H5G_t *grp = NULL; @@ -1612,7 +1612,7 @@ H5F_close(H5F_t *f) changed. --------------------------------------------------------------------------*/ herr_t -H5Fclose (hid_t file_id) +H5Fclose(hid_t file_id) { herr_t ret_value = SUCCEED; diff --git a/src/H5Fistore.c b/src/H5Fistore.c index e94e627..6f758a8 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -508,7 +508,8 @@ H5F_istore_found(H5F_t __unused__ *f, const haddr_t *addr, /* Is this *really* the requested chunk? */ for (i=0; i<udata->mesg.ndims; i++) { - if (udata->key.offset[i]>=lt_key->offset[i]+udata->mesg.dim[i]) { + if (udata->key.offset[i] >= + lt_key->offset[i]+(hssize_t)(udata->mesg.dim[i])) { HRETURN(FAIL); } } @@ -1961,8 +1962,11 @@ H5F_istore_allocate (H5F_t *f, const H5O_layout_t *layout, /* Increment indices */ for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) { chunk_offset[i] += layout->dim[i]; - if (chunk_offset[i] >= space_dim[i]) chunk_offset[i] = 0; - else carry = 0; + if (chunk_offset[i] >= (hssize_t)(space_dim[i])) { + chunk_offset[i] = 0; + } else { + carry = 0; + } } if (carry) break; } diff --git a/src/H5Flow.c b/src/H5Flow.c index 7fd81a9..eec5714 100644 --- a/src/H5Flow.c +++ b/src/H5Flow.c @@ -282,7 +282,7 @@ H5F_low_write(H5F_low_t *lf, const H5F_access_t *access_parms, haddr_t tmp_addr; #ifdef HAVE_PARALLEL - int use_types; + int use_types=0; #endif FUNC_ENTER(H5F_low_write, FAIL); @@ -293,8 +293,8 @@ H5F_low_write(H5F_low_t *lf, const H5F_access_t *access_parms, /* check for writing past the end of file marker */ #ifdef HAVE_PARALLEL - if (H5F_LOW_MPIO==access_parms->driver - && access_parms->u.mpio.use_types) { + if (H5F_LOW_MPIO==access_parms->driver && + access_parms->u.mpio.use_types) { /* In the case of fancy use of MPI datatypes, the addr and size * parameters have a very peculiar interpretation. * It is logically possible, but quite complex, to calculate @@ -335,11 +335,11 @@ H5F_low_write(H5F_low_t *lf, const H5F_access_t *access_parms, if (H5F_LOW_MPIO==access_parms->driver && use_types) { /* set logical eof to current physical eof * (ephemeral though it may be...) */ - MPI_Offset size; - if (MPI_SUCCESS != MPI_File_get_size(lf->u.mpio.f,&size)) { - HRETURN_ERROR(H5E_IO, H5E_MPI, NULL, "couldn't get file size" ); + MPI_Offset mpi_offset_size; + if (MPI_SUCCESS != MPI_File_get_size(lf->u.mpio.f,&mpi_offset_size)) { + HRETURN_ERROR(H5E_IO, H5E_MPI, FAIL, "couldn't get file size" ); } - lf->eof.offset = size; + lf->eof.offset = mpi_offset_size; } #endif @@ -125,7 +125,7 @@ static void H5G_term_interface(void); *------------------------------------------------------------------------- */ hid_t -H5Gcreate (hid_t loc_id, const char *name, size_t size_hint) +H5Gcreate(hid_t loc_id, const char *name, size_t size_hint) { H5G_t *loc = NULL; H5G_t *grp = NULL; @@ -175,7 +175,7 @@ H5Gcreate (hid_t loc_id, const char *name, size_t size_hint) *------------------------------------------------------------------------- */ hid_t -H5Gopen (hid_t loc_id, const char *name) +H5Gopen(hid_t loc_id, const char *name) { hid_t ret_value = FAIL; H5G_t *grp = NULL; @@ -224,7 +224,7 @@ H5Gopen (hid_t loc_id, const char *name) *------------------------------------------------------------------------- */ herr_t -H5Gclose (hid_t group_id) +H5Gclose(hid_t group_id) { FUNC_ENTER(H5Gclose, FAIL); H5TRACE1("e","i",group_id); @@ -275,7 +275,7 @@ H5Gclose (hid_t group_id) *------------------------------------------------------------------------- */ herr_t -H5Gset (hid_t loc_id, const char *name) +H5Gset(hid_t loc_id, const char *name) { H5G_t *grp = NULL; H5G_t *loc = NULL; @@ -336,7 +336,7 @@ H5Gset (hid_t loc_id, const char *name) *------------------------------------------------------------------------- */ herr_t -H5Gpush (hid_t loc_id, const char *name) +H5Gpush(hid_t loc_id, const char *name) { H5G_t *grp = NULL; H5G_t *loc = NULL; @@ -401,7 +401,7 @@ H5Gpush (hid_t loc_id, const char *name) *------------------------------------------------------------------------- */ herr_t -H5Gpop (hid_t loc_id) +H5Gpop(hid_t loc_id) { H5G_t *loc = NULL; @@ -449,7 +449,7 @@ H5Gpop (hid_t loc_id) *------------------------------------------------------------------------- */ herr_t -H5Giterate (hid_t loc_id, const char *name, int *idx, +H5Giterate(hid_t loc_id, const char *name, int *idx, H5G_iterate_t op, void *op_data) { int _idx = 0; @@ -521,7 +521,7 @@ H5Giterate (hid_t loc_id, const char *name, int *idx, *------------------------------------------------------------------------- */ herr_t -H5Gmove (hid_t __unused__ loc_id, const char __unused__ *src, +H5Gmove(hid_t __unused__ loc_id, const char __unused__ *src, const char __unused__ *dst) { FUNC_ENTER (H5Gmove, FAIL); @@ -563,7 +563,7 @@ H5Gmove (hid_t __unused__ loc_id, const char __unused__ *src, *------------------------------------------------------------------------- */ herr_t -H5Glink (hid_t loc_id, H5G_link_t type, const char *cur_name, +H5Glink(hid_t loc_id, H5G_link_t type, const char *cur_name, const char *new_name) { H5G_t *loc = NULL; @@ -616,7 +616,7 @@ H5Glink (hid_t loc_id, H5G_link_t type, const char *cur_name, *------------------------------------------------------------------------- */ herr_t -H5Gunlink (hid_t __unused__ loc_id, const char __unused__ *name) +H5Gunlink(hid_t __unused__ loc_id, const char __unused__ *name) { FUNC_ENTER (H5Gunlink, FAIL); H5TRACE2("e","is",loc_id,name); @@ -648,7 +648,7 @@ H5Gunlink (hid_t __unused__ loc_id, const char __unused__ *name) *------------------------------------------------------------------------- */ herr_t -H5Gstat (hid_t loc_id, const char *name, hbool_t follow_link, +H5Gstat(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/) { H5G_t *loc = NULL; @@ -692,7 +692,7 @@ H5Gstat (hid_t loc_id, const char *name, hbool_t follow_link, *------------------------------------------------------------------------- */ herr_t -H5Gget_linkval (hid_t loc_id, const char *name, size_t size, char *buf/*out*/) +H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/) { H5G_t *loc = NULL; @@ -737,7 +737,7 @@ H5Gget_linkval (hid_t loc_id, const char *name, size_t size, char *buf/*out*/) *------------------------------------------------------------------------- */ herr_t -H5Gset_comment (hid_t loc_id, const char *name, const char *comment) +H5Gset_comment(hid_t loc_id, const char *name, const char *comment) { H5G_t *loc = NULL; @@ -784,7 +784,7 @@ H5Gset_comment (hid_t loc_id, const char *name, const char *comment) *------------------------------------------------------------------------- */ int -H5Gget_comment (hid_t loc_id, const char *name, size_t bufsize, char *buf) +H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) { H5G_t *loc = NULL; intn retval = FAIL; diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 81c53d2..0cc0286 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -67,8 +67,9 @@ #define H5I_DATASETID_HASHSIZE 64 #define H5I_OID_HASHSIZE 64 #define H5I_GROUPID_HASHSIZE 64 -#define H5I_ATTRID_HASHSIZE 64 -#define H5I_TEMPBUFID_HASHSIZE 64 +#define H5I_ATTRID_HASHSIZE 64 +#define H5I_TEMPBUFID_HASHSIZE 64 +#define H5I_RAGGED_HASHSIZE 64 /* Atom information structure used */ typedef struct H5I_id_info_t { diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index e673734..d678fc8 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -44,6 +44,7 @@ typedef enum { H5_DATASET, /*group ID for Dataset objects */ H5_ATTR, /*group ID for Attribute objects */ H5_TEMPBUF, /*group ID for Temporary buffer objects */ + H5_RAGGED, /*group ID for Ragged array objects */ MAXGROUP /*highest group in group_t (Invalid as true group)*/ } H5I_group_t; @@ -58,7 +58,7 @@ herr_t H5MF_alloc(H5F_t *f, intn op, hsize_t size, haddr_t *addr/*out*/) { haddr_t tmp_addr; - intn i, found, status; + intn i, found, status=-1; hsize_t n; H5MF_free_t blk; hsize_t thresh = f->shared->access_parms->threshold; @@ -146,7 +146,7 @@ H5P_term_interface(void) * lists. --------------------------------------------------------------------------*/ hid_t -H5Pcreate (H5P_class_t type) +H5Pcreate(H5P_class_t type) { hid_t ret_value = FAIL; void *plist = NULL; @@ -254,7 +254,7 @@ H5P_create(H5P_class_t type, void *plist) This function releases access to a property list object --------------------------------------------------------------------------*/ herr_t -H5Pclose (hid_t plist_id) +H5Pclose(hid_t plist_id) { H5P_class_t type; void *plist = NULL; @@ -382,7 +382,7 @@ H5P_close (H5P_class_t type, void *plist) *------------------------------------------------------------------------- */ H5P_class_t -H5Pget_class (hid_t plist_id) +H5Pget_class(hid_t plist_id) { H5I_group_t group; H5P_class_t ret_value = H5P_NO_CLASS; @@ -467,7 +467,7 @@ H5P_get_class(hid_t plist_id) *------------------------------------------------------------------------- */ herr_t -H5Pget_version (hid_t plist_id, int *boot/*out*/, int *freelist/*out*/, +H5Pget_version(hid_t plist_id, int *boot/*out*/, int *freelist/*out*/, int *stab/*out*/, int *shhdr/*out*/) { H5F_create_t *plist = NULL; @@ -508,7 +508,7 @@ H5Pget_version (hid_t plist_id, int *boot/*out*/, int *freelist/*out*/, *------------------------------------------------------------------------- */ herr_t -H5Pset_userblock (hid_t plist_id, hsize_t size) +H5Pset_userblock(hid_t plist_id, hsize_t size) { uintn i; H5F_create_t *plist = NULL; @@ -554,7 +554,7 @@ H5Pset_userblock (hid_t plist_id, hsize_t size) *------------------------------------------------------------------------- */ herr_t -H5Pget_userblock (hid_t plist_id, hsize_t *size) +H5Pget_userblock(hid_t plist_id, hsize_t *size) { H5F_create_t *plist = NULL; @@ -603,7 +603,7 @@ H5Pget_userblock (hid_t plist_id, hsize_t *size) *------------------------------------------------------------------------- */ herr_t -H5Pset_alignment (hid_t fapl_id, hsize_t threshold, hsize_t alignment) +H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignment) { H5F_access_t *fapl = NULL; @@ -648,7 +648,7 @@ H5Pset_alignment (hid_t fapl_id, hsize_t threshold, hsize_t alignment) *------------------------------------------------------------------------- */ herr_t -H5Pget_alignment (hid_t fapl_id, hsize_t *threshold/*out*/, +H5Pget_alignment(hid_t fapl_id, hsize_t *threshold/*out*/, hsize_t *alignment/*out*/) { H5F_access_t *fapl = NULL; @@ -690,7 +690,7 @@ H5Pget_alignment (hid_t fapl_id, hsize_t *threshold/*out*/, *------------------------------------------------------------------------- */ herr_t -H5Pset_sizes (hid_t plist_id, size_t sizeof_addr, size_t sizeof_size) +H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, size_t sizeof_size) { H5F_create_t *plist = NULL; @@ -745,7 +745,7 @@ H5Pset_sizes (hid_t plist_id, size_t sizeof_addr, size_t sizeof_size) *------------------------------------------------------------------------- */ herr_t -H5Pget_sizes (hid_t plist_id, +H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr /*out */ , size_t *sizeof_size /*out */ ) { H5F_create_t *plist = NULL; @@ -798,7 +798,7 @@ H5Pget_sizes (hid_t plist_id, *------------------------------------------------------------------------- */ herr_t -H5Pset_sym_k (hid_t plist_id, int ik, int lk) +H5Pset_sym_k(hid_t plist_id, int ik, int lk) { H5F_create_t *plist = NULL; @@ -841,7 +841,7 @@ H5Pset_sym_k (hid_t plist_id, int ik, int lk) *------------------------------------------------------------------------- */ herr_t -H5Pget_sym_k (hid_t plist_id, int *ik /*out */ , int *lk /*out */ ) +H5Pget_sym_k(hid_t plist_id, int *ik /*out */ , int *lk /*out */ ) { H5F_create_t *plist = NULL; @@ -882,7 +882,7 @@ H5Pget_sym_k (hid_t plist_id, int *ik /*out */ , int *lk /*out */ ) *------------------------------------------------------------------------- */ herr_t -H5Pset_istore_k (hid_t plist_id, int ik) +H5Pset_istore_k(hid_t plist_id, int ik) { H5F_create_t *plist = NULL; @@ -924,7 +924,7 @@ H5Pset_istore_k (hid_t plist_id, int ik) *------------------------------------------------------------------------- */ herr_t -H5Pget_istore_k (hid_t plist_id, int *ik /*out */ ) +H5Pget_istore_k(hid_t plist_id, int *ik /*out */ ) { H5F_create_t *plist = NULL; @@ -961,7 +961,7 @@ H5Pget_istore_k (hid_t plist_id, int *ik /*out */ ) *------------------------------------------------------------------------- */ herr_t -H5Pset_layout (hid_t plist_id, H5D_layout_t layout) +H5Pset_layout(hid_t plist_id, H5D_layout_t layout) { H5D_create_t *plist = NULL; @@ -1001,7 +1001,7 @@ H5Pset_layout (hid_t plist_id, H5D_layout_t layout) *------------------------------------------------------------------------- */ H5D_layout_t -H5Pget_layout (hid_t plist_id) +H5Pget_layout(hid_t plist_id) { H5D_create_t *plist = NULL; @@ -1039,7 +1039,7 @@ H5Pget_layout (hid_t plist_id) *------------------------------------------------------------------------- */ herr_t -H5Pset_chunk (hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) +H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) { int i; H5D_create_t *plist = NULL; @@ -1102,7 +1102,7 @@ H5Pset_chunk (hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) *------------------------------------------------------------------------- */ int -H5Pget_chunk (hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/) +H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/) { int i; H5D_create_t *plist = NULL; @@ -1156,7 +1156,7 @@ H5Pget_chunk (hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/) *------------------------------------------------------------------------- */ herr_t -H5Pset_external (hid_t plist_id, const char *name, off_t offset, hsize_t size) +H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) { int idx; size_t total, tmp; @@ -1238,7 +1238,7 @@ H5Pset_external (hid_t plist_id, const char *name, off_t offset, hsize_t size) *------------------------------------------------------------------------- */ int -H5Pget_external_count (hid_t plist_id) +H5Pget_external_count(hid_t plist_id) { H5D_create_t *plist = NULL; @@ -1286,7 +1286,7 @@ H5Pget_external_count (hid_t plist_id) *------------------------------------------------------------------------- */ herr_t -H5Pget_external (hid_t plist_id, int idx, size_t name_size, char *name/*out*/, +H5Pget_external(hid_t plist_id, int idx, size_t name_size, char *name/*out*/, off_t *offset/*out*/, hsize_t *size/*out*/) { H5D_create_t *plist = NULL; @@ -1334,7 +1334,7 @@ H5Pget_external (hid_t plist_id, int idx, size_t name_size, char *name/*out*/, *------------------------------------------------------------------------- */ H5F_driver_t -H5Pget_driver (hid_t plist_id) +H5Pget_driver(hid_t plist_id) { H5F_access_t *plist = NULL; @@ -1371,7 +1371,7 @@ H5Pget_driver (hid_t plist_id) *------------------------------------------------------------------------- */ herr_t -H5Pset_stdio (hid_t plist_id) +H5Pset_stdio(hid_t plist_id) { H5F_access_t *plist = NULL; @@ -1412,7 +1412,7 @@ H5Pset_stdio (hid_t plist_id) *------------------------------------------------------------------------- */ herr_t -H5Pget_stdio (hid_t plist_id) +H5Pget_stdio(hid_t plist_id) { H5F_access_t *plist = NULL; @@ -1453,7 +1453,7 @@ H5Pget_stdio (hid_t plist_id) *------------------------------------------------------------------------- */ herr_t -H5Pset_sec2 (hid_t plist_id) +H5Pset_sec2(hid_t plist_id) { H5F_access_t *plist = NULL; @@ -1494,7 +1494,7 @@ H5Pset_sec2 (hid_t plist_id) *------------------------------------------------------------------------- */ herr_t -H5Pget_sec2 (hid_t plist_id) +H5Pget_sec2(hid_t plist_id) { H5F_access_t *plist = NULL; @@ -1539,7 +1539,7 @@ H5Pget_sec2 (hid_t plist_id) *------------------------------------------------------------------------- */ herr_t -H5Pset_core (hid_t plist_id, size_t increment) +H5Pset_core(hid_t plist_id, size_t increment) { H5F_access_t *plist = NULL; @@ -1587,7 +1587,7 @@ H5Pset_core (hid_t plist_id, size_t increment) *------------------------------------------------------------------------- */ herr_t -H5Pget_core (hid_t plist_id, size_t *increment/*out*/) +H5Pget_core(hid_t plist_id, size_t *increment/*out*/) { H5F_access_t *plist = NULL; @@ -1632,7 +1632,7 @@ H5Pget_core (hid_t plist_id, size_t *increment/*out*/) *------------------------------------------------------------------------- */ herr_t -H5Pset_split (hid_t plist_id, const char *meta_ext, hid_t meta_plist_id, +H5Pset_split(hid_t plist_id, const char *meta_ext, hid_t meta_plist_id, const char *raw_ext, hid_t raw_plist_id) { H5F_access_t *plist = NULL; @@ -1701,7 +1701,7 @@ H5Pset_split (hid_t plist_id, const char *meta_ext, hid_t meta_plist_id, *------------------------------------------------------------------------- */ herr_t -H5Pget_split (hid_t plist_id, size_t meta_ext_size, char *meta_ext/*out*/, +H5Pget_split(hid_t plist_id, size_t meta_ext_size, char *meta_ext/*out*/, hid_t *meta_properties/*out*/, size_t raw_ext_size, char *raw_ext/*out*/, hid_t *raw_properties/*out*/) { @@ -1781,7 +1781,7 @@ H5Pget_split (hid_t plist_id, size_t meta_ext_size, char *meta_ext/*out*/, *------------------------------------------------------------------------- */ herr_t -H5Pset_family (hid_t plist_id, hsize_t memb_size, hid_t memb_plist_id) +H5Pset_family(hid_t plist_id, hsize_t memb_size, hid_t memb_plist_id) { H5F_access_t *plist = NULL; @@ -1840,7 +1840,7 @@ H5Pset_family (hid_t plist_id, hsize_t memb_size, hid_t memb_plist_id) *------------------------------------------------------------------------- */ herr_t -H5Pget_family (hid_t plist_id, hsize_t *memb_size/*out*/, +H5Pget_family(hid_t plist_id, hsize_t *memb_size/*out*/, hid_t *memb_plist_id/*out*/) { H5F_access_t *plist = NULL; @@ -1899,7 +1899,7 @@ H5Pget_family (hid_t plist_id, hsize_t *memb_size/*out*/, *------------------------------------------------------------------------- */ herr_t -H5Pset_cache (hid_t plist_id, int mdc_nelmts, size_t rdcc_nbytes, +H5Pset_cache(hid_t plist_id, int mdc_nelmts, size_t rdcc_nbytes, double rdcc_w0) { H5F_access_t *fapl = NULL; @@ -1953,7 +1953,7 @@ H5Pset_cache (hid_t plist_id, int mdc_nelmts, size_t rdcc_nbytes, *------------------------------------------------------------------------- */ herr_t -H5Pget_cache (hid_t plist_id, int *mdc_nelmts, size_t *rdcc_nbytes, +H5Pget_cache(hid_t plist_id, int *mdc_nelmts, size_t *rdcc_nbytes, double *rdcc_w0) { H5F_access_t *fapl = NULL; @@ -2007,7 +2007,7 @@ H5Pget_cache (hid_t plist_id, int *mdc_nelmts, size_t *rdcc_nbytes, *------------------------------------------------------------------------- */ herr_t -H5Pset_buffer (hid_t plist_id, size_t size, void *tconv, void *bkg) +H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, void *bkg) { H5D_xfer_t *plist = NULL; @@ -2051,7 +2051,7 @@ H5Pset_buffer (hid_t plist_id, size_t size, void *tconv, void *bkg) *------------------------------------------------------------------------- */ size_t -H5Pget_buffer (hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/) +H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/) { H5D_xfer_t *plist = NULL; @@ -2094,7 +2094,7 @@ H5Pget_buffer (hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/) *------------------------------------------------------------------------- */ herr_t -H5Pset_preserve (hid_t plist_id, hbool_t status) +H5Pset_preserve(hid_t plist_id, hbool_t status) { H5D_xfer_t *plist = NULL; @@ -2132,7 +2132,7 @@ H5Pset_preserve (hid_t plist_id, hbool_t status) *------------------------------------------------------------------------- */ int -H5Pget_preserve (hid_t plist_id) +H5Pget_preserve(hid_t plist_id) { H5D_xfer_t *plist = NULL; @@ -2189,7 +2189,7 @@ H5Pget_preserve (hid_t plist_id) *------------------------------------------------------------------------- */ herr_t -H5Pset_filter (hid_t plist_id, H5Z_filter_t filter, unsigned int flags, +H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) { H5D_create_t *plist = NULL; @@ -2255,7 +2255,7 @@ H5Pset_filter (hid_t plist_id, H5Z_filter_t filter, unsigned int flags, *------------------------------------------------------------------------- */ int -H5Pget_nfilters (hid_t plist_id) +H5Pget_nfilters(hid_t plist_id) { H5D_create_t *plist = NULL; @@ -2302,7 +2302,7 @@ H5Pget_nfilters (hid_t plist_id) *------------------------------------------------------------------------- */ H5Z_filter_t -H5Pget_filter (hid_t plist_id, int idx, unsigned int *flags/*out*/, +H5Pget_filter(hid_t plist_id, int idx, unsigned int *flags/*out*/, size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, size_t namelen, char name[]/*out*/) { @@ -2395,7 +2395,7 @@ H5Pget_filter (hid_t plist_id, int idx, unsigned int *flags/*out*/, *------------------------------------------------------------------------- */ herr_t -H5Pset_deflate (hid_t plist_id, unsigned level) +H5Pset_deflate(hid_t plist_id, unsigned level) { H5D_create_t *plist = NULL; @@ -2482,7 +2482,7 @@ H5Pset_deflate (hid_t plist_id, unsigned level) *------------------------------------------------------------------------- */ herr_t -H5Pset_mpi (hid_t plist_id, MPI_Comm comm, MPI_Info info) +H5Pset_mpi(hid_t plist_id, MPI_Comm comm, MPI_Info info) { H5F_access_t *plist = NULL; @@ -2537,7 +2537,7 @@ H5Pset_mpi (hid_t plist_id, MPI_Comm comm, MPI_Info info) *------------------------------------------------------------------------- */ herr_t -H5Pget_mpi (hid_t plist_id, MPI_Comm *comm, MPI_Info *info) +H5Pget_mpi(hid_t plist_id, MPI_Comm *comm, MPI_Info *info) { H5F_access_t *plist = NULL; @@ -2600,7 +2600,7 @@ H5Pget_mpi (hid_t plist_id, MPI_Comm *comm, MPI_Info *info) *------------------------------------------------------------------------- */ herr_t -H5Pset_xfer (hid_t plist_id, H5D_transfer_t data_xfer_mode) +H5Pset_xfer(hid_t plist_id, H5D_transfer_t data_xfer_mode) { H5D_xfer_t *plist = NULL; @@ -2650,7 +2650,7 @@ H5Pset_xfer (hid_t plist_id, H5D_transfer_t data_xfer_mode) *------------------------------------------------------------------------- */ herr_t -H5Pget_xfer (hid_t plist_id, H5D_transfer_t *data_xfer_mode) +H5Pget_xfer(hid_t plist_id, H5D_transfer_t *data_xfer_mode) { H5D_xfer_t *plist = NULL; @@ -2695,7 +2695,7 @@ H5Pget_xfer (hid_t plist_id, H5D_transfer_t *data_xfer_mode) * parameter settings. --------------------------------------------------------------------------*/ hid_t -H5Pcopy (hid_t plist_id) +H5Pcopy(hid_t plist_id) { const void *plist = NULL; void *new_plist = NULL; diff --git a/src/H5R.c b/src/H5R.c new file mode 100644 index 0000000..02c4e25 --- /dev/null +++ b/src/H5R.c @@ -0,0 +1,1075 @@ +/* + * Copyright © 1998 NCSA + * All rights reserved. + * + * Programmer: Robb Matzke <matzke@llnl.gov> + * Tuesday, August 25, 1998 + * + * Purpose: A ragged array package layered on top of other HDF5 objects. + * This was originally implemented on the HDF5 API but has been + * moved under the API so it meshes better with other objects, + * is somewhat faster, and has better debugging support. + * + * Note: This file implementes a two dimensional array where each row + * of the array is a different length (a.k.a., ragged array). It + * is intended for applications where the distribution of row + * lengths is such that most rows near an average length with + * only a few rows that are significantly shorter or longer. The + * raw data is split among two datasets `raw' and `over': the + * `raw' dataset is a 2d chunked dataset whose width is large + * enough to hold most of the rows and the `over' dataset is a + * heap that stores the end of rows that overflow the first + * dataset. A third dataset called `meta' contains one record + * for each row and describes what elements (if any) overflow + * the `raw' dataset and where they are stored in the `over' + * dataset. All three datasets are contained in a single group + * whose name is the name of the ragged array. + */ +#include <H5Rprivate.h> + +#include <H5private.h> +#include <H5Eprivate.h> +#include <H5Iprivate.h> +#include <H5MMprivate.h> +#include <H5Pprivate.h> + +typedef struct H5R_meta_t { + hsize_t nelmts; /*num elements in row */ + hssize_t offset; /*offset into overflow array */ + hsize_t nover; /*allocated size in overflow array */ +} H5R_meta_t; + +struct H5R_t { + H5D_t *meta; /*ragged meta data array */ + H5D_t *raw; /*fixed-width raw data */ + H5D_t *over; /*overflow data */ +}; + +#define PABLO_MASK H5R_mask +static hbool_t interface_initialize_g = FALSE; +#define INTERFACE_INIT H5R_init_interface +static herr_t H5R_init_interface(void); +static void H5R_term_interface(void); +static H5T_t *H5R_meta_type_g = NULL; + +static herr_t H5R_fix_overflow(H5R_t *ra, H5T_t *type, H5R_meta_t *meta, + hsize_t nelmts, void *buf); + + +/*------------------------------------------------------------------------- + * Function: H5R_init_interface + * + * Purpose: Initialize the interface. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, August 25, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5R_init_interface(void) +{ + herr_t ret_value = SUCCEED; + H5T_t *type = NULL; + + FUNC_ENTER(H5R_init_interface, FAIL); + + /* The atom group */ + if ((ret_value=H5I_init_group(H5_RAGGED, H5I_RAGGED_HASHSIZE, 0, + (herr_t(*)(void*))H5R_close))>=0) { + ret_value = H5_add_exit(H5R_term_interface); + } + + /* The meta dataset type */ + if (NULL==(type=H5T_create(H5T_COMPOUND, sizeof(H5R_meta_t))) || + H5T_insert(type, "nelmts", HOFFSET(H5R_meta_t, nelmts), + 0, NULL, NULL, H5I_object(H5T_NATIVE_HSIZE_g))<0 || + H5T_insert(type, "offset", HOFFSET(H5R_meta_t, offset), + 0, NULL, NULL, H5I_object(H5T_NATIVE_HSSIZE_g))<0 || + H5T_insert(type, "nover", HOFFSET(H5R_meta_t, nover), + 0, NULL, NULL, H5I_object(H5T_NATIVE_HSIZE_g))) { + HRETURN_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to define ragged array meta type"); + } + H5R_meta_type_g = type; + + FUNC_LEAVE(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5R_term_interface + * + * Purpose: Terminate the ragged array interface. + * + * Return: void + * + * Programmer: Robb Matzke + * Tuesday, August 25, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +H5R_term_interface(void) +{ + H5I_destroy_group(H5_RAGGED); + H5T_close(H5R_meta_type_g); + H5R_meta_type_g = NULL; +} + + +/*------------------------------------------------------------------------- + * Function: H5Rcreate + * + * Purpose: Create a new ragged array with the specified name. A ragged + * array is implemented as a group containing three datasets. + * The dataset `raw' is a fixed width dataset which will hold + * the majority of the data. The dataset `over' is a one + * dimensional heap which will hold the end of rows which are + * too long to fit in `raw'. Finally, the `meta' dataset + * contains information about the `over' array. All elements of + * the ragged array are stored with the same data type. + * + * The property list PLIST_ID should contain information about + * chunking. The chunk width will determine the width of the + * `raw' dataset while the chunk length should be such that the + * total chunk size is reasonably large (I/O will be performed + * in units of chunks). If the PLIST_ID doesn't have a chunk + * size defined (e.g., H5P_DEFAULT) then this function will fail. + * + * Return: Success: A ragged array ID. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, August 25, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hid_t +H5Rcreate(hid_t loc_id, const char *name, hid_t type_id, hid_t plist_id) +{ + H5R_t *ra=NULL; + H5G_t *loc=NULL; + H5T_t *type=NULL; + const H5D_create_t *plist=NULL; + hid_t ret_value=FAIL; + + FUNC_ENTER(H5Rcreate, FAIL); + H5TRACE4("i","isii",loc_id,name,type_id,plist_id); + + /* Check args */ + if (NULL==(loc=H5G_loc(loc_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); + } + if (!name || !*name) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given"); + } + if (H5_DATATYPE!=H5I_group(type_id) || + NULL==(type=H5I_object(type_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); + } + if (H5P_DEFAULT==plist_id) { + plist = &H5D_create_dflt; + } else if (H5P_DATASET_CREATE!=H5P_get_class(plist_id) || + NULL==(plist=H5I_object(plist_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation property list"); + } + if (H5D_CHUNKED!=plist->layout) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "property list must define a chunked storage layout"); + } + if (2!=plist->layout) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "chunked storage is not two dimensional"); + } + + /* Do the real work */ + if (NULL==(ra=H5R_create(loc, name, type, plist))) { + HRETURN_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to create ragged array"); + } + + /* Register the new dataset to get an ID for it */ + if ((ret_value=H5I_register(H5_RAGGED, ra))<0) { + H5R_close(ra); + HRETURN_ERROR(H5E_RAGGED, H5E_CANTREGISTER, FAIL, + "unable to register ragged array"); + } + + FUNC_LEAVE(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5R_create + * + * Purpose: Create a new ragged array implemented as a group. + * + * Return: Success: Pointer to the new ragged array. + * + * Failure: NULL + * + * Programmer: Robb Matzke + * Tuesday, August 25, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +H5R_t * +H5R_create(H5G_t *loc, const char *name, H5T_t *type, const H5D_create_t *dcpl) +{ + H5R_t *ra = NULL; + H5G_t *grp = NULL; + H5S_t *space = NULL; + hsize_t cur_dims[2]; + hsize_t max_dims[2]; + H5R_t *ret_value=NULL; + H5D_create_t d1_dcpl; + + FUNC_ENTER(H5R_create, NULL); + + /* Check args */ + assert(loc); + assert(name && *name); + assert(type); + assert(dcpl); + assert(H5D_CHUNKED==dcpl->layout); + + /* Create the data struct */ + if (NULL==(ra=H5MM_calloc(sizeof(H5R_t)))) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for ragged array struct"); + } + + /* Create the group to contain the arrays */ + if (NULL==(grp=H5G_create(loc, name, 0))) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, NULL, + "unable to create container group"); + } + + /* The raw data array */ + cur_dims[0] = 0; + max_dims[0] = H5S_UNLIMITED; + cur_dims[1] = max_dims[1] = dcpl->chunk_size[1]; + if (NULL==(space=H5S_create(H5S_SIMPLE)) || + H5S_set_extent_simple(space, 2, cur_dims, max_dims)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, NULL, + "unable to define raw dataset extents"); + } + if (NULL==(ra->raw=H5D_create(grp, "raw", type, space, dcpl))) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, NULL, + "unable to create raw dataset"); + } + if (H5S_close(space)<0) { + space = NULL; + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, NULL, + "unable to close raw dataset extents"); + } + space = NULL; + + /* The overflow data array */ + cur_dims[0] = 0; + max_dims[0] = H5S_UNLIMITED; + if (NULL==(space=H5S_create(H5S_SIMPLE)) || + H5S_set_extent_simple(space, 1, cur_dims, max_dims)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, NULL, + "unable to define overflow dataset extents"); + } + d1_dcpl = *dcpl; + d1_dcpl.chunk_ndims = 1; + d1_dcpl.chunk_size[0] = dcpl->chunk_size[0]*dcpl->chunk_size[1]; + if (NULL==(ra->over=H5D_create(grp, "over", type, space, &d1_dcpl))) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, NULL, + "unable to create overflow dataset"); + } + if (H5S_close(space)<0) { + space = NULL; + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, NULL, + "unable to close overflow dataset extents"); + } + space = NULL; + + /* The meta data array */ + cur_dims[0] = 0; + max_dims[0] = H5S_UNLIMITED; + if (NULL==(space=H5S_create(H5S_SIMPLE)) || + H5S_set_extent_simple(space, 1, cur_dims, max_dims)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, NULL, + "unable to define meta dataset extents"); + } + d1_dcpl.chunk_size[0] = MAX(1, + (dcpl->chunk_size[0]*dcpl->chunk_size[1]* + H5T_get_size(type))/ + H5T_get_size(H5R_meta_type_g)); + if (NULL==(ra->meta=H5D_create(grp, "meta", H5R_meta_type_g, space, + &d1_dcpl))) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, NULL, + "unable to create meta dataset"); + } + if (H5S_close(space)<0) { + space = NULL; + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, NULL, + "unable to close meta dataset extents"); + } + space = NULL; + + /* Close the group -- we no longer need it */ + if (H5G_close(grp)<0) { + grp = NULL; + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, NULL, + "unable to close ragged array group"); + } + grp = NULL; + ret_value = ra; + + done: + if (!ret_value) { + if (grp) H5G_close(grp); + if (space) H5S_close(space); + if (ra) { + if (ra->raw) H5D_close(ra->raw); + if (ra->over) H5D_close(ra->over); + if (ra->meta) H5D_close(ra->meta); + H5MM_xfree(ra); + } + } + FUNC_LEAVE(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5Ropen + * + * Purpose: Opens an existing ragged array. The name of the array should + * be the same that was used when the array was created; that is, + * the name of the group which implements the array. + * + * Return: Success: An array ID + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, August 25, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hid_t +H5Ropen(hid_t loc_id, const char *name) +{ + H5G_t *loc=NULL; + H5R_t *ra=NULL; + hid_t ret_value=FAIL; + + FUNC_ENTER(H5Ropen, FAIL); + H5TRACE2("i","is",loc_id,name); + + /* Check args */ + if (NULL==(loc=H5G_loc(loc_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); + } + if (!name || !*name) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given"); + } + + /* The real work */ + if (NULL==(ra=H5R_open(loc, name))) { + HRETURN_ERROR(H5E_RAGGED, H5E_CANTOPENOBJ, FAIL, + "unable to open ragged array"); + } + + /* Turn it into an atom */ + if ((ret_value=H5I_register(H5_RAGGED, ra))<0) { + H5R_close(ra); + HRETURN_ERROR(H5E_RAGGED, H5E_CANTREGISTER, FAIL, + "unable to register ragged array"); + } + + FUNC_LEAVE(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5R_open + * + * Purpose: Open a ragged array. The name of the array is the same as + * the group that implements the array. + * + * Return: Success: Ptr to a new ragged array object. + * + * Failure: NULL + * + * Programmer: Robb Matzke + * Tuesday, August 25, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +H5R_t * +H5R_open(H5G_t *loc, const char *name) +{ + H5R_t *ra = NULL; + H5R_t *ret_value = NULL; + H5G_t *grp=NULL; + + FUNC_ENTER(H5R_open, NULL); + + /* Check arguments */ + assert(loc); + assert(name && *name); + + /* Create the struct */ + if (NULL==(ra=H5MM_calloc(sizeof(H5R_t)))) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for ragged array struct"); + } + + /* Open the containing group */ + if (NULL==(grp=H5G_open(loc, name))) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTOPENOBJ, NULL, + "unable to open container group"); + } + + /* Open the datasets */ + if (NULL==(ra->raw=H5D_open(grp, "raw")) || + NULL==(ra->over=H5D_open(grp, "over")) || + NULL==(ra->meta=H5D_open(grp, "meta"))) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTOPENOBJ, NULL, + "unable to open one or more component datasets"); + } + + /* Close group */ + if (H5G_close(grp)<0) { + grp = NULL; + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, NULL, + "unable to close container group"); + } + grp = NULL; + ret_value = ra; + + done: + if (!ret_value) { + if (grp) H5G_close(grp); + if (ra) { + if (ra->raw) H5D_close(ra->raw); + if (ra->over) H5D_close(ra->over); + if (ra->meta) H5D_close(ra->meta); + H5MM_xfree(ra); + } + } + FUNC_LEAVE(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5Rclose + * + * Purpose: Close a ragged array. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, August 25, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Rclose(hid_t array_id) +{ + H5R_t *ra=NULL; + + FUNC_ENTER(H5Rclose, FAIL); + H5TRACE1("e","i",array_id); + + /* Check args */ + if (H5_RAGGED!=H5I_group(array_id) || + NULL==(ra=H5I_object(array_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a ragged array"); + } + + /* + * Decrement the counter on the array. It will be freed if the count + * reaches zero. + */ + if (H5I_dec_ref(array_id) < 0) { + HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to free"); + } + + FUNC_LEAVE(SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5R_close + * + * Purpose: Close a ragged array + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, August 25, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5R_close(H5R_t *ra) +{ + FUNC_ENTER(H5R_close, FAIL); + + assert(ra); + if ((ra->raw && H5D_close(ra->raw)<0) || + (ra->over && H5D_close(ra->over)<0) || + (ra->meta && H5D_close(ra->meta)<0)) { + HRETURN_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to close one or more component datasets"); + } + HDmemset(ra, 0, sizeof(H5R_t)); + H5MM_xfree(ra); + + FUNC_LEAVE(SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Rwrite + * + * Purpose: Write a contiguous set of rows to a ragged array beginning at + * row number START_ROW and continuing for NROWS rows. Each row + * of the ragged array contains SIZE[] elements of type TYPE_ID + * and each row is stored in a buffer pointed to by BUF[]. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, August 25, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Rwrite(hid_t array_id, hssize_t start_row, hsize_t nrows, + hid_t type_id, hsize_t size[/*nrows*/], void *buf[/*nrows*/]) +{ + H5R_t *ra=NULL; + H5T_t *type=NULL; + hsize_t i; + + FUNC_ENTER(H5Rwrite, FAIL); + H5TRACE6("e","iHshi*[a2]h*[a2]x",array_id,start_row,nrows,type_id,size, + buf); + + /* Check args */ + if (H5_RAGGED!=H5I_group(array_id) || + NULL==(ra=H5I_object(array_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a ragged array"); + } + if (H5_DATATYPE!=H5I_group(type_id) || + NULL==(type=H5I_object(type_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); + } + if (nrows>0 && !size) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size array"); + } + if (nrows>0 && !buf) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer array"); + } + for (i=0; i<nrows; i++) { + if (size[i]>0 && !buf[i]) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "one or more buffer points are null"); + } + } + + /* Do the work */ + if (H5R_write(ra, start_row, nrows, type, size, buf)<0) { + HRETURN_ERROR(H5E_RAGGED, H5E_WRITEERROR, FAIL, + "unable to write to ragged array"); + } + + FUNC_LEAVE(SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5R_write + * + * Purpose: Write a contiguous set of rows to a ragged array beginning at + * row number START_ROW and continuing for NROWS rows. Each row + * of the ragged array contains SIZE[] elements of type TYPE_ID + * and each row is stored in a buffer pointed to by BUF[]. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, August 25, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5R_write(H5R_t *ra, hssize_t start_row, hsize_t nrows, H5T_t *type, + hsize_t size[], void *buf[]) +{ + herr_t ret_value=FAIL; + H5R_meta_t *meta = NULL; + H5S_t *mf_space=NULL; /*meta file data space */ + H5S_t *mm_space=NULL; /*meta memory data space */ + H5S_t *rf_space=NULL; /*raw data file space */ + H5S_t *rm_space=NULL; /*raw data memory space */ + hsize_t meta_cur_size; /*current meta data nelmts */ + hsize_t meta_read_size; /*amount to read */ + hsize_t raw_cur_size[2]; /*raw data current size */ + hssize_t hs_offset[2]; /*hyperslab offset */ + hsize_t hs_size[2]; /*hyperslab size */ + uint8 *raw_buf=NULL; /*raw buffer */ + size_t type_size; /*size of the TYPE argument */ + hsize_t i; + + FUNC_ENTER(H5R_write, FAIL); + + /* Check args */ + assert(ra); + assert(type); + assert(0==nrows || size); + assert(0==nrows || buf); + if (0==nrows) HRETURN(SUCCEED); + type_size = H5T_get_size(type); + + /* Get the meta data */ + if (NULL==(mf_space=H5D_get_space(ra->meta)) || + H5S_extent_dims(mf_space, &meta_cur_size, NULL)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to get current meta data extents"); + } + if ((hsize_t)start_row>=meta_cur_size) { + meta_read_size = 0; + } else { + meta_read_size = MIN(nrows, meta_cur_size-(hsize_t)start_row); + } + if (NULL==(mm_space=H5S_create(H5S_SIMPLE)) || + H5S_set_extent_simple(mm_space, 1, &meta_read_size, NULL)<0 || + H5S_select_hyperslab(mf_space, H5S_SELECT_SET, &start_row, NULL, + &meta_read_size, NULL)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to set meta data selection"); + } + if (NULL==(meta=H5MM_malloc(nrows*sizeof(H5R_meta_t)))) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for meta data"); + } + if (H5D_read(ra->meta, H5R_meta_type_g, mm_space, mf_space, + &H5D_xfer_dflt, meta)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_READERROR, FAIL, + "unable to read meta data"); + } + HDmemset(meta+meta_read_size, 0, + (nrows-meta_read_size)*sizeof(H5R_meta_t)); + + /* Write the part of the data that will fit in the raw dataset */ + if (NULL==(rf_space=H5D_get_space(ra->raw)) || + H5S_extent_dims(rf_space, raw_cur_size, NULL)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to determine current raw data extents"); + } + if (NULL==(raw_buf=H5MM_malloc(nrows*raw_cur_size[1]*type_size))) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate buffer for raw data"); + } + for (i=0; i<nrows; i++) { + size_t nbytes = MIN(size[i], raw_cur_size[1])*type_size; + HDmemcpy(raw_buf+i*raw_cur_size[1]*type_size, buf[i], nbytes); + HDmemset(raw_buf+i*raw_cur_size[1]*type_size+nbytes, 0, + raw_cur_size[1]*type_size-nbytes); + } + if ((hsize_t)start_row+nrows>raw_cur_size[0]) { + raw_cur_size[0] = (hsize_t)start_row + nrows; + if (H5D_extend(ra->raw, raw_cur_size)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to extend raw dataset"); + } + } + hs_offset[0] = start_row; + hs_offset[1] = 0; + hs_size[0] = nrows; + hs_size[1] = raw_cur_size[1]; + if (NULL==(rm_space=H5S_create(H5S_SIMPLE)) || + H5S_set_extent_simple(rm_space, 2, hs_size, NULL)<0 || + H5S_select_hyperslab(rf_space, H5S_SELECT_SET, + hs_offset, NULL, hs_size, NULL)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to set meta data selection"); + } + if (H5D_write(ra->raw, type, rm_space, rf_space, &H5D_xfer_dflt, + raw_buf)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_WRITEERROR, FAIL, + "unable to write raw data"); + } + + /* Update the meta data */ + for (i=0; i<nrows; i++) { + if (size[i]>raw_cur_size[1]) { + H5R_fix_overflow(ra, type, meta+i, size[i]-raw_cur_size[1], + (uint8*)(buf[i])+raw_cur_size[1]); + } + meta[i].nelmts = size[i]; + } + + /* Extend and write the new meta data */ + if ((hsize_t)start_row+nrows>meta_cur_size) { + meta_cur_size = (hsize_t)start_row+nrows; + if (H5D_extend(ra->meta, &meta_cur_size)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to extend meta dataset"); + } + } + if (H5S_set_extent_simple(mm_space, 1, &nrows, NULL)<0 || + H5S_select_hyperslab(mf_space, H5S_SELECT_SET, &start_row, NULL, + &nrows, NULL)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to set meta data selection"); + } + if (H5D_write(ra->meta, H5R_meta_type_g, mm_space, mf_space, + &H5D_xfer_dflt, meta)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_WRITEERROR, FAIL, + "unable to write meta data"); + } + + ret_value = SUCCEED; + done: + H5MM_xfree(meta); + H5MM_xfree(raw_buf); + if (mm_space) H5S_close(mm_space); + if (mf_space) H5S_close(mf_space); + if (rm_space) H5S_close(rm_space); + if (rf_space) H5S_close(rf_space); + + FUNC_LEAVE(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5R_fix_overflow + * + * Purpose: Updates the overflow information for a row. This is where + * the heap management comes into play. The NELMTS is the + * number of elements that overflow into the heap and BUF is a + * pointer to those elements. The first part of the row has + * already been written to the raw dataset. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, August 26, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5R_fix_overflow(H5R_t *ra, H5T_t *type, H5R_meta_t *meta, hsize_t nelmts, + void *buf) +{ + H5S_t *of_space=NULL; /*overflow file space */ + H5S_t *om_space=NULL; /*overflow memory space */ + hsize_t cur_size; /*num elmts in overflow dataset */ + herr_t ret_value=FAIL; /*return value */ + + FUNC_ENTER(H5R_fix_overflow, FAIL); + + assert(ra); + assert(meta); + assert(buf); + + if (nelmts==meta->nover) { + /* The space is already allocated -- do nothing */ + + } else if (nelmts<meta->nover) { + /* Too much space is allocated -- free the extra */ +#ifndef LATER + /* + * For now we don't worry about reclaiming space. But we remember + * the original amount allocated to allow the row to grow again up to + * that amount. + */ +#endif + + } else if (meta->nover>0) { + /* Space is allocated but we need more */ +#ifndef LATER + /* + * For now we'll just reallocate space at the end of the overflow + * dataset, but eventually we'll want to move the smallest of the + * current overflow, the previous overflow, or the following overflow + * region to the end of the file and be careful to reclaim space. + */ + if (NULL==(of_space=H5D_get_space(ra->over)) || + H5S_extent_dims(of_space, &cur_size, NULL)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to get overflow dataset extents"); + } + meta->offset = (hssize_t)cur_size; + meta->nover = nelmts; + cur_size += nelmts; + if (H5D_extend(ra->over, &cur_size)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to extend overflow dataset"); + } +#endif + + } else { + /* No space is allocated */ + assert(nelmts>0); + if (NULL==(of_space=H5D_get_space(ra->over)) || + H5S_extent_dims(of_space, &cur_size, NULL)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to get overflow dataset extents"); + } + meta->offset = (hssize_t)cur_size; + meta->nover = nelmts; + cur_size += nelmts; + if (H5D_extend(ra->over, &cur_size)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to extend overflow dataset"); + } + } + + /* Write the data */ + if (nelmts>0) { + if (!of_space && NULL==(of_space=H5D_get_space(ra->over))) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to get overflow dataset extents"); + } + if (NULL==(om_space=H5S_create(H5S_SIMPLE)) || + H5S_set_extent_simple(om_space, 1, &nelmts, NULL)<0 || + H5S_select_hyperslab(of_space, H5S_SELECT_SET, &(meta->offset), + NULL, &nelmts, NULL)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to set overflow selection"); + } + if (H5D_write(ra->over, type, om_space, of_space, &H5D_xfer_dflt, + buf)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_WRITEERROR, FAIL, + "unable to write to overflow dataset"); + } + } + + ret_value = SUCCEED; + + done: + if (of_space) H5S_close(of_space); + if (om_space) H5S_close(om_space); + if (ret_value<0) { + meta->offset = 0; + meta->nover = 0; + } + FUNC_LEAVE(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5Rread + * + * Purpose: Reads the contents of one or more rows of a ragged array + * pointed to by ARRAY_ID. The rows to read begin at row + * START_ROW and continue for NROWS rows with all raw data + * converted to type TYPE_ID. + * + * The caller must allocate the SIZE[] and BUF[] arrays but + * memory for the data can be allocated by either the caller or + * the library. In the former case the caller should initialize + * the BUF[] array with pointers to valid memory and the SIZE[] + * array with the lengths of the buffers. In the latter case + * the caller should initialize BUF[] with null pointers (the + * input value of SIZE[] is irrelevant in this case) and the + * library will allocate memory for each row by calling malloc(). + * + * Return: Success: SUCCEED. The values of the SIZE[] array will + * be the true length of each row. If a row is + * longer than the caller-allocated length then + * SIZE[] will contain the true length of the + * row although not all elements of that row + * will be stored in the buffer. + * + * Failure: FAIL. The BUF[] array will contain it's + * original pointers (null or otherwise) + * although the caller-supplied buffers may have + * been modified. The SIZE[] array may also be + * modified. + * + * Programmer: Robb Matzke + * Tuesday, August 25, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Rread(hid_t array_id, hssize_t start_row, hsize_t nrows, + hid_t type_id, hsize_t size[/*nrows*/], void *buf[/*nrows*/]) +{ + H5R_t *ra=NULL; + H5T_t *type=NULL; + + FUNC_ENTER(H5Rread, FAIL); + H5TRACE6("e","iHshi*[a2]h*[a2]x",array_id,start_row,nrows,type_id,size, + buf); + + /* Check args */ + if (H5_RAGGED!=H5I_group(array_id) || + NULL==(ra=H5I_object(array_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a ragged array"); + } + if (H5_DATATYPE!=H5I_group(type_id) || + NULL==(type=H5I_object(type_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); + } + if (nrows>0 && !size) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size array"); + } + if (nrows>0 && !buf) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer array"); + } + + /* Do the work */ + if (H5R_read(ra, start_row, nrows, type, size, buf)<0) { + HRETURN_ERROR(H5E_RAGGED, H5E_READERROR, FAIL, + "unable to read ragged array"); + } + + FUNC_LEAVE(SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5R_read + * + * Purpose: Reads (part of) a ragged array. See H5Rread() for details. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, August 26, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5R_read(H5R_t *ra, hssize_t start_row, hsize_t nrows, H5T_t *type, + hsize_t size[], void *buf[]) +{ + herr_t ret_value=FAIL; + H5R_meta_t *meta = NULL; + H5S_t *mf_space=NULL; /*meta file data space */ + H5S_t *mm_space=NULL; /*meta memory data space */ + H5S_t *rf_space=NULL; /*raw data file space */ + H5S_t *rm_space=NULL; /*raw data memory space */ + hsize_t meta_cur_size; /*current meta data nelmts */ + hsize_t meta_read_size; /*amount of meta data to read */ + hsize_t raw_cur_size[2]; /*raw data current size */ + hsize_t raw_read_size; /*amount of raw data to read */ + hssize_t hs_offset[2]; /*hyperslab offset */ + hsize_t hs_size[2]; /*hyperslab size */ + uint8 *raw_buf=NULL; /*raw buffer */ + size_t type_size; /*size of the TYPE argument */ + hsize_t i; + + FUNC_ENTER(H5R_read, FAIL); + + /* Check args */ + assert(ra); + assert(type); + assert(0==nrows || size); + assert(0==nrows || buf); + if (0==nrows) HRETURN(SUCCEED); + type_size = H5T_get_size(type); + + /* Read from the raw dataset */ + if (NULL==(rf_space=H5D_get_space(ra->raw)) || + H5S_extent_dims(rf_space, raw_cur_size, NULL)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to determine current raw data extents"); + } + if ((hsize_t)start_row>=raw_cur_size[0]) { + raw_read_size = 0; + } else { + raw_read_size = MIN(nrows, raw_cur_size[0]-(hsize_t)start_row); + } + + + + + + + + /* Get the meta data */ + if (NULL==(meta=H5MM_malloc(nrows*sizeof(H5R_meta_t)))) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for meta data"); + } + if (NULL==(mf_space=H5D_get_space(ra->meta)) || + H5S_extent_dims(mf_space, &meta_cur_size, NULL)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to get current meta data extents"); + } + if ((hsize_t)start_row>=meta_cur_size) { + meta_read_size = 0; + } else { + meta_read_size = MIN(nrows, meta_cur_size-(hsize_t)start_row); + } + if (NULL==(mm_space=H5S_create(H5S_SIMPLE)) || + H5S_set_extent_simple(mm_space, 1, &meta_read_size, NULL)<0 || + H5S_select_hyperslab(mf_space, H5S_SELECT_SET, &start_row, NULL, + &meta_read_size, NULL)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, + "unable to set meta data selection"); + } + if (H5D_read(ra->meta, H5R_meta_type_g, mm_space, mf_space, + &H5D_xfer_dflt, meta)<0) { + HGOTO_ERROR(H5E_RAGGED, H5E_READERROR, FAIL, + "unable to read meta data"); + } + HDmemset(meta+meta_read_size, 0, + (nrows-meta_read_size)*sizeof(H5R_meta_t)); + + + HGOTO_ERROR(H5E_RAGGED, H5E_UNSUPPORTED, FAIL, + "not implemented yet"); + + done: + FUNC_LEAVE(ret_value); +} + diff --git a/src/H5Rprivate.h b/src/H5Rprivate.h new file mode 100644 index 0000000..c4b8471 --- /dev/null +++ b/src/H5Rprivate.h @@ -0,0 +1,27 @@ +/* + * Copyright © 1998 NCSA + * All rights reserved. + * + * Programmer: Robb Matzke <matzke@llnl.gov> + * Tuesday, August 25, 1998 + */ +#ifndef _H5Rprivate_H +#define _H5Rprivate_H +#include <H5Rpublic.h> + +#include <H5Dprivate.h> +#include <H5Gprivate.h> +#include <H5Tprivate.h> + +typedef struct H5R_t H5R_t; + +herr_t H5R_close(H5R_t *ra); +H5R_t *H5R_create(H5G_t *loc, const char *name, H5T_t *type, + const H5D_create_t *dcpl); +H5R_t *H5R_open(H5G_t *loc, const char *name); +herr_t H5R_write(H5R_t *ra, hssize_t start_row, hsize_t nrows, H5T_t *type, + hsize_t size[], void *buf[]); +herr_t H5R_read(H5R_t *ra, hssize_t start_row, hsize_t nrows, H5T_t *type, + hsize_t size[], void *buf[]); + +#endif diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h new file mode 100644 index 0000000..bcdcee7 --- /dev/null +++ b/src/H5Rpublic.h @@ -0,0 +1,28 @@ +/* + * Copyright © 1998 NCSA + * All rights reserved. + * + * Programmer: Robb Matzke <matzke@llnl.gov> + * Tuesday, August 25, 1998 + */ +#ifndef _H5Rpublic_H +#define _H5Rpublic_H + +#include <H5Ipublic.h> + +#ifdef __cplusplus +extern "C" { +#endif + +hid_t H5Rcreate(hid_t loc_id, const char *name, hid_t type_id, hid_t plist_id); +hid_t H5Ropen(hid_t loc_id, const char *name); +herr_t H5Rclose(hid_t array_id); +herr_t H5Rwrite(hid_t array_id, hssize_t start_row, hsize_t nrows, + hid_t type_id, hsize_t size[], void *buf[]); +herr_t H5Rread(hid_t array_id, hssize_t start_row, hsize_t nrows, + hid_t type_id, hsize_t size[], void *buf[]); + +#ifdef __cplusplus +} +#endif +#endif @@ -292,7 +292,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ hid_t -H5Screate (H5S_class_t type) +H5Screate(H5S_class_t type) { H5S_t *new_ds=NULL; hid_t ret_value = FAIL; @@ -426,7 +426,7 @@ H5S_close(H5S_t *ds) *------------------------------------------------------------------------- */ herr_t -H5Sclose (hid_t space_id) +H5Sclose(hid_t space_id) { FUNC_ENTER(H5Sclose, FAIL); H5TRACE1("e","i",space_id); @@ -492,7 +492,7 @@ H5S_release_simple(H5S_simple_t *simple) *------------------------------------------------------------------------- */ hid_t -H5Scopy (hid_t space_id) +H5Scopy(hid_t space_id) { H5S_t *src = NULL; H5S_t *dst = NULL; @@ -535,7 +535,7 @@ H5Scopy (hid_t space_id) *------------------------------------------------------------------------- */ herr_t -H5Sextent_copy (hid_t dst_id,hid_t src_id) +H5Sextent_copy(hid_t dst_id,hid_t src_id) { H5S_t *src = NULL; H5S_t *dst = NULL; @@ -730,7 +730,7 @@ H5S_extent_npoints(const H5S_t *ds) *------------------------------------------------------------------------- */ hsize_t -H5Sextent_npoints (hid_t space_id) +H5Sextent_npoints(hid_t space_id) { H5S_t *ds = NULL; hsize_t ret_value = 0; @@ -832,7 +832,7 @@ H5S_get_npoints_max(const H5S_t *ds) *------------------------------------------------------------------------- */ int -H5Sextent_ndims (hid_t space_id) +H5Sextent_ndims(hid_t space_id) { H5S_t *ds = NULL; intn ret_value = 0; @@ -922,7 +922,7 @@ H5S_extent_ndims(const H5S_t *ds) *------------------------------------------------------------------------- */ int -H5Sextent_dims (hid_t space_id, hsize_t dims[]/*out*/, +H5Sextent_dims(hid_t space_id, hsize_t dims[]/*out*/, hsize_t maxdims[]/*out*/) { H5S_t *ds = NULL; @@ -1215,7 +1215,7 @@ H5S_is_simple(const H5S_t *sdim) has orthogonal, evenly spaced dimensions. --------------------------------------------------------------------------*/ hbool_t -H5Sis_simple (hid_t space_id) +H5Sis_simple(hid_t space_id) { H5S_t *space = NULL; /* dataspace to modify */ hbool_t ret_value = FAIL; @@ -1262,7 +1262,7 @@ H5Sis_simple (hid_t space_id) dimension in the array (the slowest) may be unlimited in size. --------------------------------------------------------------------------*/ herr_t -H5Sset_extent_simple (hid_t space_id, int rank, const hsize_t dims[/*rank*/], +H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], const hsize_t max[/*rank*/]) { H5S_t *space = NULL; /* dataspace to modify */ @@ -1578,7 +1578,7 @@ H5S_extend (H5S_t *space, const hsize_t *size) *------------------------------------------------------------------------- */ hid_t -H5Screate_simple (int rank, const hsize_t dims[/*rank*/], +H5Screate_simple(int rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]) { hid_t ret_value = FAIL; @@ -1646,7 +1646,7 @@ H5Screate_simple (int rank, const hsize_t dims[/*rank*/], *------------------------------------------------------------------------- */ H5S_class_t -H5Sextent_class (hid_t sid) +H5Sextent_class(hid_t sid) { H5S_class_t ret_value = H5S_NO_CLASS; H5S_t *space = NULL; @@ -1680,7 +1680,7 @@ H5Sextent_class (hid_t sid) extent information stored for the dataspace. --------------------------------------------------------------------------*/ herr_t -H5Sset_extent_none (hid_t space_id) +H5Sset_extent_none(hid_t space_id) { H5S_t *space = NULL; /* dataspace to modify */ @@ -1718,7 +1718,7 @@ H5Sset_extent_none (hid_t space_id) dataspace without requiring it to be re-defined. --------------------------------------------------------------------------*/ herr_t -H5Soffset_simple (hid_t space_id, const hssize_t *offset) +H5Soffset_simple(hid_t space_id, const hssize_t *offset) { H5S_t *space = NULL; /* dataspace to modify */ diff --git a/src/H5Shyper.c b/src/H5Shyper.c index d9a0e4a..cd0138c 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -1698,6 +1698,11 @@ done: COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG + * Robb Matzke, 1998-08-25 + * The fields which are freed are set to NULL to prevent them from being + * freed again later. This fixes some allocation problems where + * changing the hyperslab selection of one data space causes a core dump + * when closing some other data space. --------------------------------------------------------------------------*/ herr_t H5S_hyper_release (H5S_t *space) @@ -1718,21 +1723,26 @@ H5S_hyper_release (H5S_t *space) /* Release the per-dimension selection info */ H5MM_xfree(space->select.sel_info.hyper.diminfo); + space->select.sel_info.hyper.diminfo = NULL; /* Release hi and lo boundary information */ for(i=0; i<space->extent.u.simple.rank; i++) { H5MM_xfree(space->select.sel_info.hyper.hyper_lst->lo_bounds[i]); + space->select.sel_info.hyper.hyper_lst->lo_bounds[i] = NULL; H5MM_xfree(space->select.sel_info.hyper.hyper_lst->hi_bounds[i]); + space->select.sel_info.hyper.hyper_lst->hi_bounds[i] = NULL; } /* end for */ H5MM_xfree(space->select.sel_info.hyper.hyper_lst->lo_bounds); + space->select.sel_info.hyper.hyper_lst->lo_bounds = NULL; H5MM_xfree(space->select.sel_info.hyper.hyper_lst->hi_bounds); + space->select.sel_info.hyper.hyper_lst->hi_bounds = NULL; /* Release list of selected regions */ curr=space->select.sel_info.hyper.hyper_lst->head; while(curr!=NULL) { next=curr->next; - H5MM_xfree(curr->start); - H5MM_xfree(curr->end); + curr->start = H5MM_xfree(curr->start); + curr->end = H5MM_xfree(curr->end); H5MM_xfree(curr); curr=next; } /* end while */ diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 1e2ca6f..24dd4f6 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -285,6 +285,11 @@ intn H5S_cmp (const H5S_t *ds1, const H5S_t *ds2); hbool_t H5S_is_simple (const H5S_t *sdim); uintn H5S_nelem (const H5S_t *space); H5S_conv_t *H5S_find (const H5S_t *mem_space, const H5S_t *file_space); +herr_t H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, + const hssize_t start[], + const hsize_t _stride[], + const hsize_t count[], + const hsize_t _block[]); intn H5S_get_hyperslab (const H5S_t *ds, hssize_t offset[]/*out*/, hsize_t size[]/*out*/, hsize_t stride[]/*out*/); herr_t H5S_release_simple(H5S_simple_t *simple); diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 1426f59..f790021 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -182,22 +182,25 @@ H5S_select_release (H5S_t *space) assert (space); switch(space->select.type) { - case H5S_SEL_POINTS: /* Sequence of points selected */ - ret_value=H5S_point_release(space); - break; + case H5S_SEL_POINTS: /* Sequence of points selected */ + ret_value=H5S_point_release(space); + break; - case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ - ret_value=H5S_hyper_release(space); - break; + case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ + ret_value=H5S_hyper_release(space); + break; - case H5S_SEL_ALL: /* Entire extent selected */ - ret_value=H5S_all_release(space); - break; + case H5S_SEL_ALL: /* Entire extent selected */ + ret_value=H5S_all_release(space); + break; - case H5S_SEL_NONE: /* Nothing selected */ - default: - break; - } /* end switch() */ + case H5S_SEL_NONE: /* Nothing selected */ + break; + + case H5S_SEL_ERROR: + case H5S_SEL_N: + break; + } /* Reset type of selection to "all" */ space->select.type=H5S_SEL_ALL; @@ -233,22 +236,13 @@ H5S_select_release (H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Sselect_hyperslab (hid_t space_id, H5S_seloper_t op, +H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[/*space_id*/], const hsize_t _stride[/*space_id*/], const hsize_t count[/*space_id*/], const hsize_t _block[/*space_id*/]) { H5S_t *space = NULL; /* Dataspace to modify selection of */ - hsize_t *stride, /* Stride array */ - *block=NULL; /* Block size array */ - hssize_t slab[H5O_LAYOUT_NDIMS]; /* Location of the block to add for strided selections */ - size_t slice[H5O_LAYOUT_NDIMS]; /* Size of preceding dimension's slice */ - uintn acc; /* Accumulator for building slices */ - uintn contig; /* whether selection is contiguous or not */ - int i,j; /* Counters */ - H5S_hyper_dim_t *diminfo; /* per-dimension info for the selection */ - herr_t ret_value=FAIL; /* return value */ FUNC_ENTER (H5Sselect_hyperslab, FAIL); H5TRACE6("e","iSs*[a0]Hs*[a0]h*[a0]h*[a0]h",space_id,op,start,_stride, @@ -261,41 +255,103 @@ H5Sselect_hyperslab (hid_t space_id, H5S_seloper_t op, } if(start==NULL || count==NULL) { HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified"); - } /* end if */ + } if(op!=H5S_SELECT_SET) { HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "operations other than H5S_SELECT_SET not supported currently"); - } /* end if */ + } + + if (H5S_select_hyperslab(space, op, start, _stride, count, _block)<0) { + HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, + "unable to set hyperslab selection"); + } + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5S_select_hyperslab + * + * Purpose: Internal version of H5Sselect_hyperslab(). + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke (split from HSselect_hyperslab()). + * Tuesday, August 25, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, + const hssize_t start[/*space_id*/], + const hsize_t stride[/*space_id*/], + const hsize_t count[/*space_id*/], + const hsize_t block[/*space_id*/]) +{ + + hsize_t *_stride=NULL; /* Stride array */ + hsize_t *_block=NULL; /* Block size array */ + hssize_t slab[H5O_LAYOUT_NDIMS]; /* Location of the block to add for strided selections */ + size_t slice[H5O_LAYOUT_NDIMS]; /* Size of preceding dimension's slice */ + uintn acc; /* Accumulator for building slices */ + uintn contig; /* whether selection is contiguous or not */ + int i,j; /* Counters */ + H5S_hyper_dim_t *diminfo; /* per-dimension info for the selection */ + herr_t ret_value=FAIL; /* return value */ + + FUNC_ENTER (H5S_select_hyperslab, FAIL); + + /* Check args */ + assert(space); + assert(start); + assert(count); + assert(H5S_SELECT_SET==op); + /* Fill in the correct stride values */ - if(_stride==NULL) { + if(stride==NULL) { hssize_t fill=1; - if((stride = H5MM_malloc(sizeof(hssize_t)*space->extent.u.simple.rank))==NULL) + if((_stride = H5MM_malloc(sizeof(hssize_t)*space->extent.u.simple.rank))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate stride vector"); - H5V_array_fill(stride,&fill,sizeof(hssize_t),space->extent.u.simple.rank); - } else { - stride=(hsize_t *)_stride; - } /* end else */ + H5V_array_fill(_stride,&fill,sizeof(hssize_t),space->extent.u.simple.rank); + stride = _stride; + } /* Fill in the correct block values */ - if(_block==NULL) { + if(block==NULL) { hssize_t fill=1; - if((block = H5MM_malloc(sizeof(hssize_t)*space->extent.u.simple.rank))==NULL) + if((_block = H5MM_malloc(sizeof(hssize_t)*space->extent.u.simple.rank))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate block vector"); - H5V_array_fill(block,&fill,sizeof(hssize_t),space->extent.u.simple.rank); - } else { - block=(hsize_t *)_block; - } /* end else */ + H5V_array_fill(_block,&fill,sizeof(hssize_t),space->extent.u.simple.rank); + block = _block; + } + + /* Copy all the per-dimension selection info into the space descriptor */ + if((diminfo = H5MM_malloc(sizeof(H5S_hyper_dim_t)*space->extent.u.simple.rank))==NULL) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "can't allocate per-dimension vector"); + } /* end if */ + for(i=0; i<space->extent.u.simple.rank; i++) { + diminfo[i].start = start[i]; + diminfo[i].stride = stride[i]; + diminfo[i].count = count[i]; + diminfo[i].block = block[i]; + } /* end for */ + space->select.sel_info.hyper.diminfo = diminfo; /* * Check for overlapping blocks (remove when real block-merging algorithm * is in place). */ - if(op==H5S_SELECT_SET && _block!=NULL) { + if(op==H5S_SELECT_SET && block!=NULL) { for(i=0; i<space->extent.u.simple.rank; i++) { if(stride[i]<block[i]) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, @@ -410,13 +466,11 @@ H5Sselect_hyperslab (hid_t space_id, H5S_seloper_t op, #endif /* QAK */ done: - if(_stride==NULL && stride!=NULL) - H5MM_xfree(stride); - if(_block==NULL && block!=NULL) - H5MM_xfree(block); - + H5MM_xfree(_stride); + H5MM_xfree(_block); FUNC_LEAVE (ret_value); -} /* H5Sselect_hyperslab() */ +} + /*-------------------------------------------------------------------------- NAME @@ -616,7 +670,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ hsize_t -H5Sselect_npoints (hid_t spaceid) +H5Sselect_npoints(hid_t spaceid) { H5S_t *space = NULL; /* Dataspace to modify selection of */ hsize_t ret_value=0; /* return value */ @@ -662,23 +716,26 @@ H5S_select_npoints (const H5S_t *space) assert(space); switch(space->select.type) { - case H5S_SEL_POINTS: /* Sequence of points selected */ - ret_value=H5S_point_npoints(space); - break; + case H5S_SEL_POINTS: /* Sequence of points selected */ + ret_value=H5S_point_npoints(space); + break; - case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ - ret_value=H5S_hyper_npoints(space); - break; + case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ + ret_value=H5S_hyper_npoints(space); + break; - case H5S_SEL_ALL: /* Entire extent selected */ - ret_value=H5S_all_npoints(space); - break; + case H5S_SEL_ALL: /* Entire extent selected */ + ret_value=H5S_all_npoints(space); + break; - case H5S_SEL_NONE: /* Nothing selected */ - default: - ret_value=0; - break; - } /* end switch */ + case H5S_SEL_NONE: /* Nothing selected */ + ret_value=0; + break; + + case H5S_SEL_ERROR: + case H5S_SEL_N: + break; + } FUNC_LEAVE (ret_value); } /* H5Sselect_npoints() */ @@ -712,20 +769,23 @@ H5S_sel_iter_release (const H5S_t *space, H5S_sel_iter_t *sel_iter) assert (sel_iter); switch(space->select.type) { - case H5S_SEL_POINTS: /* Sequence of points selected */ - case H5S_SEL_ALL: /* Entire extent selected */ - /* no action needed */ - ret_value=SUCCEED; - break; - - case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ - ret_value=H5S_hyper_sel_iter_release(sel_iter); - break; - - case H5S_SEL_NONE: /* Nothing selected */ - default: - break; - } /* end switch() */ + case H5S_SEL_POINTS: /* Sequence of points selected */ + case H5S_SEL_ALL: /* Entire extent selected */ + /* no action needed */ + ret_value=SUCCEED; + break; + + case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ + ret_value=H5S_hyper_sel_iter_release(sel_iter); + break; + + case H5S_SEL_NONE: /* Nothing selected */ + break; + + case H5S_SEL_ERROR: + case H5S_SEL_N: + break; + } FUNC_LEAVE (ret_value); } /* H5S_sel_iter_release() */ @@ -751,7 +811,7 @@ H5S_sel_iter_release (const H5S_t *space, H5S_sel_iter_t *sel_iter) REVISION LOG --------------------------------------------------------------------------*/ hbool_t -H5Sselect_valid (hid_t spaceid) +H5Sselect_valid(hid_t spaceid) { H5S_t *space = NULL; /* Dataspace to modify selection of */ hbool_t ret_value=FAIL; /* return value */ @@ -800,20 +860,23 @@ H5S_select_valid (const H5S_t *space) assert(space); switch(space->select.type) { - case H5S_SEL_POINTS: /* Sequence of points selected */ - ret_value=H5S_point_select_valid(space); - break; - - case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ - ret_value=H5S_hyper_select_valid(space); - break; - - case H5S_SEL_ALL: /* Entire extent selected */ - case H5S_SEL_NONE: /* Nothing selected */ - default: - ret_value=TRUE; - break; - } /* end switch */ + case H5S_SEL_POINTS: /* Sequence of points selected */ + ret_value=H5S_point_select_valid(space); + break; + + case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ + ret_value=H5S_hyper_select_valid(space); + break; + + case H5S_SEL_ALL: /* Entire extent selected */ + case H5S_SEL_NONE: /* Nothing selected */ + ret_value=TRUE; + break; + + case H5S_SEL_ERROR: + case H5S_SEL_N: + break; + } FUNC_LEAVE (ret_value); } /* H5S_select_valid() */ @@ -846,7 +846,7 @@ H5T_term_interface(void) *------------------------------------------------------------------------- */ hid_t -H5Tcreate (H5T_class_t type, size_t size) +H5Tcreate(H5T_class_t type, size_t size) { H5T_t *dt = NULL; hid_t ret_value = FAIL; @@ -891,7 +891,7 @@ H5Tcreate (H5T_class_t type, size_t size) *------------------------------------------------------------------------- */ hid_t -H5Topen (hid_t loc_id, const char *name) +H5Topen(hid_t loc_id, const char *name) { H5G_t *loc = NULL; H5T_t *type = NULL; @@ -943,7 +943,7 @@ H5Topen (hid_t loc_id, const char *name) *------------------------------------------------------------------------- */ herr_t -H5Tcommit (hid_t loc_id, const char *name, hid_t type_id) +H5Tcommit(hid_t loc_id, const char *name, hid_t type_id) { H5G_t *loc = NULL; H5T_t *type = NULL; @@ -990,7 +990,7 @@ H5Tcommit (hid_t loc_id, const char *name, hid_t type_id) *------------------------------------------------------------------------- */ hbool_t -H5Tcommitted (hid_t type_id) +H5Tcommitted(hid_t type_id) { H5T_t *type = NULL; @@ -1032,7 +1032,7 @@ H5Tcommitted (hid_t type_id) *------------------------------------------------------------------------- */ hid_t -H5Tcopy (hid_t type_id) +H5Tcopy(hid_t type_id) { H5T_t *dt = NULL; H5T_t *new_dt = NULL; @@ -1099,7 +1099,7 @@ H5Tcopy (hid_t type_id) *------------------------------------------------------------------------- */ herr_t -H5Tclose (hid_t type_id) +H5Tclose(hid_t type_id) { H5T_t *dt = NULL; @@ -1143,7 +1143,7 @@ H5Tclose (hid_t type_id) *------------------------------------------------------------------------- */ hbool_t -H5Tequal (hid_t type1_id, hid_t type2_id) +H5Tequal(hid_t type1_id, hid_t type2_id) { const H5T_t *dt1 = NULL; const H5T_t *dt2 = NULL; @@ -1192,7 +1192,7 @@ H5Tequal (hid_t type1_id, hid_t type2_id) *------------------------------------------------------------------------- */ herr_t -H5Tlock (hid_t type_id) +H5Tlock(hid_t type_id) { H5T_t *dt = NULL; @@ -1235,7 +1235,7 @@ H5Tlock (hid_t type_id) *------------------------------------------------------------------------- */ H5T_class_t -H5Tget_class (hid_t type_id) +H5Tget_class(hid_t type_id) { H5T_t *dt = NULL; @@ -1271,7 +1271,7 @@ H5Tget_class (hid_t type_id) *------------------------------------------------------------------------- */ size_t -H5Tget_size (hid_t type_id) +H5Tget_size(hid_t type_id) { H5T_t *dt = NULL; size_t size; @@ -1321,7 +1321,7 @@ H5Tget_size (hid_t type_id) *------------------------------------------------------------------------- */ herr_t -H5Tset_size (hid_t type_id, size_t size) +H5Tset_size(hid_t type_id, size_t size) { H5T_t *dt = NULL; size_t prec, offset; @@ -1419,7 +1419,7 @@ H5Tset_size (hid_t type_id, size_t size) *------------------------------------------------------------------------- */ H5T_order_t -H5Tget_order (hid_t type_id) +H5Tget_order(hid_t type_id) { H5T_t *dt = NULL; H5T_order_t order; @@ -1459,7 +1459,7 @@ H5Tget_order (hid_t type_id) *------------------------------------------------------------------------- */ herr_t -H5Tset_order (hid_t type_id, H5T_order_t order) +H5Tset_order(hid_t type_id, H5T_order_t order) { H5T_t *dt = NULL; @@ -1506,7 +1506,7 @@ H5Tset_order (hid_t type_id, H5T_order_t order) *------------------------------------------------------------------------- */ size_t -H5Tget_precision (hid_t type_id) +H5Tget_precision(hid_t type_id) { H5T_t *dt = NULL; size_t prec; @@ -1558,7 +1558,7 @@ H5Tget_precision (hid_t type_id) *------------------------------------------------------------------------- */ herr_t -H5Tset_precision (hid_t type_id, size_t prec) +H5Tset_precision(hid_t type_id, size_t prec) { H5T_t *dt = NULL; size_t offset, size; @@ -1662,7 +1662,7 @@ H5Tset_precision (hid_t type_id, size_t prec) *------------------------------------------------------------------------- */ size_t -H5Tget_offset (hid_t type_id) +H5Tget_offset(hid_t type_id) { H5T_t *dt = NULL; size_t offset; @@ -1724,7 +1724,7 @@ H5Tget_offset (hid_t type_id) *------------------------------------------------------------------------- */ herr_t -H5Tset_offset (hid_t type_id, size_t offset) +H5Tset_offset(hid_t type_id, size_t offset) { H5T_t *dt = NULL; @@ -1776,7 +1776,7 @@ H5Tset_offset (hid_t type_id, size_t offset) *------------------------------------------------------------------------- */ herr_t -H5Tget_pad (hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/) +H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/) { H5T_t *dt = NULL; @@ -1815,7 +1815,7 @@ H5Tget_pad (hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/) *------------------------------------------------------------------------- */ herr_t -H5Tset_pad (hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb) +H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb) { H5T_t *dt = NULL; @@ -1860,7 +1860,7 @@ H5Tset_pad (hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb) *------------------------------------------------------------------------- */ H5T_sign_t -H5Tget_sign (hid_t type_id) +H5Tget_sign(hid_t type_id) { H5T_t *dt = NULL; H5T_sign_t sign; @@ -1900,7 +1900,7 @@ H5Tget_sign (hid_t type_id) *------------------------------------------------------------------------- */ herr_t -H5Tset_sign (hid_t type_id, H5T_sign_t sign) +H5Tset_sign(hid_t type_id, H5T_sign_t sign) { H5T_t *dt = NULL; @@ -1949,7 +1949,7 @@ H5Tset_sign (hid_t type_id, H5T_sign_t sign) *------------------------------------------------------------------------- */ herr_t -H5Tget_fields (hid_t type_id, size_t *spos/*out*/, +H5Tget_fields(hid_t type_id, size_t *spos/*out*/, size_t *epos/*out*/, size_t *esize/*out*/, size_t *mpos/*out*/, size_t *msize/*out*/) { @@ -2000,7 +2000,7 @@ H5Tget_fields (hid_t type_id, size_t *spos/*out*/, *------------------------------------------------------------------------- */ herr_t -H5Tset_fields (hid_t type_id, size_t spos, size_t epos, size_t esize, +H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) { H5T_t *dt = NULL; @@ -2074,7 +2074,7 @@ H5Tset_fields (hid_t type_id, size_t spos, size_t epos, size_t esize, *------------------------------------------------------------------------- */ size_t -H5Tget_ebias (hid_t type_id) +H5Tget_ebias(hid_t type_id) { H5T_t *dt = NULL; size_t ebias; @@ -2114,7 +2114,7 @@ H5Tget_ebias (hid_t type_id) *------------------------------------------------------------------------- */ herr_t -H5Tset_ebias (hid_t type_id, size_t ebias) +H5Tset_ebias(hid_t type_id, size_t ebias) { H5T_t *dt = NULL; @@ -2157,7 +2157,7 @@ H5Tset_ebias (hid_t type_id, size_t ebias) *------------------------------------------------------------------------- */ H5T_norm_t -H5Tget_norm (hid_t type_id) +H5Tget_norm(hid_t type_id) { H5T_t *dt = NULL; H5T_norm_t norm; @@ -2198,7 +2198,7 @@ H5Tget_norm (hid_t type_id) *------------------------------------------------------------------------- */ herr_t -H5Tset_norm (hid_t type_id, H5T_norm_t norm) +H5Tset_norm(hid_t type_id, H5T_norm_t norm) { H5T_t *dt = NULL; @@ -2245,7 +2245,7 @@ H5Tset_norm (hid_t type_id, H5T_norm_t norm) *------------------------------------------------------------------------- */ H5T_pad_t -H5Tget_inpad (hid_t type_id) +H5Tget_inpad(hid_t type_id) { H5T_t *dt = NULL; H5T_pad_t pad; @@ -2288,7 +2288,7 @@ H5Tget_inpad (hid_t type_id) *------------------------------------------------------------------------- */ herr_t -H5Tset_inpad (hid_t type_id, H5T_pad_t pad) +H5Tset_inpad(hid_t type_id, H5T_pad_t pad) { H5T_t *dt = NULL; @@ -2335,7 +2335,7 @@ H5Tset_inpad (hid_t type_id, H5T_pad_t pad) *------------------------------------------------------------------------- */ H5T_cset_t -H5Tget_cset (hid_t type_id) +H5Tget_cset(hid_t type_id) { H5T_t *dt = NULL; H5T_cset_t cset; @@ -2377,7 +2377,7 @@ H5Tget_cset (hid_t type_id) *------------------------------------------------------------------------- */ herr_t -H5Tset_cset (hid_t type_id, H5T_cset_t cset) +H5Tset_cset(hid_t type_id, H5T_cset_t cset) { H5T_t *dt = NULL; @@ -2424,7 +2424,7 @@ H5Tset_cset (hid_t type_id, H5T_cset_t cset) *------------------------------------------------------------------------- */ H5T_str_t -H5Tget_strpad (hid_t type_id) +H5Tget_strpad(hid_t type_id) { H5T_t *dt = NULL; H5T_str_t strpad; @@ -2477,7 +2477,7 @@ H5Tget_strpad (hid_t type_id) *------------------------------------------------------------------------- */ herr_t -H5Tset_strpad (hid_t type_id, H5T_str_t strpad) +H5Tset_strpad(hid_t type_id, H5T_str_t strpad) { H5T_t *dt = NULL; @@ -2523,7 +2523,7 @@ H5Tset_strpad (hid_t type_id, H5T_str_t strpad) *------------------------------------------------------------------------- */ int -H5Tget_nmembers (hid_t type_id) +H5Tget_nmembers(hid_t type_id) { H5T_t *dt = NULL; @@ -2607,7 +2607,7 @@ H5Tget_member_name(hid_t type_id, int membno) *------------------------------------------------------------------------- */ size_t -H5Tget_member_offset (hid_t type_id, int membno) +H5Tget_member_offset(hid_t type_id, int membno) { H5T_t *dt = NULL; size_t offset = 0; @@ -2652,7 +2652,7 @@ H5Tget_member_offset (hid_t type_id, int membno) *------------------------------------------------------------------------- */ int -H5Tget_member_dims (hid_t type_id, int membno, +H5Tget_member_dims(hid_t type_id, int membno, size_t dims[]/*out*/, int perm[]/*out*/) { H5T_t *dt = NULL; @@ -2707,7 +2707,7 @@ H5Tget_member_dims (hid_t type_id, int membno, *------------------------------------------------------------------------- */ hid_t -H5Tget_member_type (hid_t type_id, int membno) +H5Tget_member_type(hid_t type_id, int membno) { H5T_t *dt = NULL, *memb_dt = NULL; hid_t memb_type_id; @@ -2770,7 +2770,7 @@ H5Tget_member_type (hid_t type_id, int membno) *------------------------------------------------------------------------- */ herr_t -H5Tinsert (hid_t parent_id, const char *name, size_t offset, hid_t member_id) +H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id) { H5T_t *parent = NULL; /*the compound parent data type */ H5T_t *member = NULL; /*the atomic member type */ @@ -2828,7 +2828,7 @@ H5Tinsert (hid_t parent_id, const char *name, size_t offset, hid_t member_id) *------------------------------------------------------------------------- */ herr_t -H5Tinsert_array (hid_t parent_id, const char *name, size_t offset, +H5Tinsert_array(hid_t parent_id, const char *name, size_t offset, int ndims, const size_t dim[/*ndims*/], const int *perm, hid_t member_id) { @@ -2896,7 +2896,7 @@ H5Tinsert_array (hid_t parent_id, const char *name, size_t offset, *------------------------------------------------------------------------- */ herr_t -H5Tpack (hid_t type_id) +H5Tpack(hid_t type_id) { H5T_t *dt = NULL; @@ -2949,7 +2949,7 @@ H5Tpack (hid_t type_id) *------------------------------------------------------------------------- */ herr_t -H5Tregister_hard (const char *name, hid_t src_id, hid_t dst_id, +H5Tregister_hard(const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func) { H5T_t *src = NULL; @@ -3013,7 +3013,7 @@ H5Tregister_hard (const char *name, hid_t src_id, hid_t dst_id, *------------------------------------------------------------------------- */ herr_t -H5Tregister_soft (const char *name, H5T_class_t src_cls, H5T_class_t dst_cls, +H5Tregister_soft(const char *name, H5T_class_t src_cls, H5T_class_t dst_cls, H5T_conv_t func) { intn i; @@ -3140,7 +3140,7 @@ H5Tregister_soft (const char *name, H5T_class_t src_cls, H5T_class_t dst_cls, *------------------------------------------------------------------------- */ herr_t -H5Tunregister (H5T_conv_t func) +H5Tunregister(H5T_conv_t func) { intn i, j; H5T_path_t *path = NULL; @@ -3262,7 +3262,7 @@ H5Tunregister (H5T_conv_t func) *------------------------------------------------------------------------- */ H5T_conv_t -H5Tfind (hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) +H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) { H5T_conv_t ret_value = NULL; H5T_t *src = NULL, *dst = NULL; @@ -3318,7 +3318,7 @@ H5Tfind (hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) *------------------------------------------------------------------------- */ herr_t -H5Tconvert (hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, +H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, void *background) { H5T_cdata_t *cdata = NULL; /*conversion data */ @@ -3383,7 +3383,7 @@ H5Tconvert (hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, *------------------------------------------------------------------------- */ H5T_overflow_t -H5Tget_overflow (void) +H5Tget_overflow(void) { FUNC_ENTER(H5Tget_overflow, NULL); H5TRACE0("x",""); @@ -3418,7 +3418,7 @@ H5Tget_overflow (void) *------------------------------------------------------------------------- */ herr_t -H5Tset_overflow (H5T_overflow_t func) +H5Tset_overflow(H5T_overflow_t func) { FUNC_ENTER(H5Tset_overflow, FAIL); H5TRACE1("e","x",func); @@ -169,7 +169,7 @@ herr_t H5TB_close(H5TB_t *tb) REVISION LOG --------------------------------------------------------------------------*/ hid_t -H5TBget_buf (hsize_t size, hbool_t resize) +H5TBget_buf(hsize_t size, hbool_t resize) { hid_t ret_value = FAIL; H5TB_t *curr=H5TB_list_head, /* pointer to current temp. buffer */ @@ -335,7 +335,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5TBresize_ptr (hid_t tbuf_id, hsize_t size) +H5TBresize_ptr(hid_t tbuf_id, hsize_t size) { herr_t ret_value = FAIL; H5TB_t *tbuf, /* Pointer to temporary buffer */ @@ -430,7 +430,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5TBgarbage_coll (void) +H5TBgarbage_coll(void) { herr_t ret_value = FAIL; H5TB_t *curr,*next; /* Current temp. buffer node */ @@ -494,7 +494,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5TBrelease_buf (hid_t tbuf_id) +H5TBrelease_buf(hid_t tbuf_id) { herr_t ret_value = FAIL; H5TB_t *tbuf; /* Pointer to temporary buffer */ diff --git a/src/H5Tconv.c b/src/H5Tconv.c index ce0df3e..a8dcbf3 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -64,7 +64,6 @@ H5T_conv_noop(hid_t __unused__ src_id, hid_t __unused__ dst_id, break; case H5T_CONV_FREE: - /* Nothing to free */ cdata->stats = H5MM_xfree (cdata->stats); break; @@ -1345,7 +1344,7 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, intn direction; /*direction of traversal */ size_t elmtno; /*element number */ size_t olap; /*num overlapping elements */ - size_t nchars; /*number of characters copied */ + size_t nchars=0; /*number of characters copied */ uint8 *s, *sp, *d, *dp; /*src and dst traversal pointers*/ uint8 *dbuf=NULL; /*temp buf for overlap convers. */ herr_t ret_value=FAIL; /*return value */ @@ -160,7 +160,7 @@ H5Z_term_interface (void) *------------------------------------------------------------------------- */ herr_t -H5Zregister (H5Z_filter_t id, const char *comment, H5Z_func_t func) +H5Zregister(H5Z_filter_t id, const char *comment, H5Z_func_t func) { FUNC_ENTER (H5Zregister, FAIL); H5TRACE3("e","Zfsx",id,comment,func); diff --git a/src/H5private.h b/src/H5private.h index e0147e5..99da0dd 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -86,6 +86,9 @@ # define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d)) #endif +/* limit the middle value to be within a range (inclusive) */ +#define RANGE(LO,X,HI) MAX(LO,MIN(X,HI)) + /* absolute value */ #ifndef ABS # define ABS(a) (((a)>=0) ? (a) : -(a)) diff --git a/src/Makefile.in b/src/Makefile.in index 213cdc6..158b452 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -19,7 +19,7 @@ LIB_SRC=H5.c H5A.c H5AC.c H5B.c H5D.c H5E.c H5F.c H5Farray.c H5Fcore.c \ H5Fstdio.c H5G.c H5Gent.c H5Gnode.c H5Gstab.c H5HG.c H5HL.c H5I.c H5MF.c \ H5MM.c H5O.c H5Oattr.c H5Ocomp.c H5Ocont.c H5Odtype.c H5Oefl.c \ H5Olayout.c H5Omtime.c H5Oname.c H5Onull.c H5Osdspace.c H5Oshared.c \ - H5Ostab.c H5P.c H5S.c H5Sall.c H5Shyper.c H5Smpio.c H5Spoint.c \ + H5Ostab.c H5P.c H5R.c H5S.c H5Sall.c H5Shyper.c H5Smpio.c H5Spoint.c \ H5Sselect.c H5T.c H5Tbit.c H5Tconv.c H5Tinit.c H5TB.c H5V.c H5Z.c LIB_OBJ=$(LIB_SRC:.c=.o) @@ -31,14 +31,14 @@ MOSTLYCLEAN=H5detect.o H5detect H5Tinit.o H5Tinit.c PUB_HDR=H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5Dpublic.h \ H5Epublic.h H5Fpublic.h H5Gpublic.h H5HGpublic.h H5HLpublic.h \ H5Ipublic.h H5MFpublic.h H5MMpublic.h H5Opublic.h H5Ppublic.h \ - H5Spublic.h H5Tpublic.h H5Zpublic.h H5config.h hdf5.h + H5Rpublic.h H5Spublic.h H5Tpublic.h H5Zpublic.h H5config.h hdf5.h # Other header files (not to be installed)... PRIVATE_HDR=H5private.h H5Aprivate.h H5Apkg.h H5ACprivate.h H5Bprivate.h \ H5Dprivate.h H5Eprivate.h H5Fprivate.h H5Gprivate.h H5Gpkg.h \ H5HGprivate.h H5HLprivate.h H5Iprivate.h H5MFprivate.h H5MMprivate.h \ - H5Oprivate.h H5Pprivate.h H5Sprivate.h H5Tprivate.h H5TBprivate.h \ - H5Tpkg.h H5Vprivate.h H5Zprivate.h + H5Oprivate.h H5Pprivate.h H5Rprivate.h H5Sprivate.h H5Tprivate.h \ + H5TBprivate.h H5Tpkg.h H5Vprivate.h H5Zprivate.h # Number format detection H5Tinit.c: H5detect @@ -33,6 +33,7 @@ #include <H5MMpublic.h> /* Core memory management */ #include <H5Opublic.h> /* Object headers */ #include <H5Ppublic.h> /* Property lists */ +#include <H5Rpublic.h> /* Ragged arrays */ #include <H5Spublic.h> /* Dataspaces */ #include <H5Tpublic.h> /* Datatypes */ #include <H5Zpublic.h> /* Data filters */ diff --git a/test/.distdep b/test/.distdep index 2b28ca4..9eb0b5b 100644 --- a/test/.distdep +++ b/test/.distdep @@ -178,40 +178,6 @@ th5s.o: \ ../src/H5Tpublic.h \ ../src/H5Zprivate.h \ ../src/H5Zpublic.h -dtypes.o: \ - dtypes.c \ - ../src/hdf5.h \ - ../src/H5public.h \ - ../src/H5config.h \ - ../src/H5Ipublic.h \ - ../src/H5Apublic.h \ - ../src/H5ACpublic.h \ - ../src/H5Bpublic.h \ - ../src/H5Dpublic.h \ - ../src/H5Epublic.h \ - ../src/H5Fpublic.h \ - ../src/H5Gpublic.h \ - ../src/H5HGpublic.h \ - ../src/H5HLpublic.h \ - ../src/H5MFpublic.h \ - ../src/H5MMpublic.h \ - ../src/H5Opublic.h \ - ../src/H5Ppublic.h \ - ../src/H5Zpublic.h \ - ../src/H5Spublic.h \ - ../src/H5Tpublic.h \ - ../src/H5Tpkg.h \ - ../src/H5HGprivate.h \ - ../src/H5Fprivate.h \ - ../src/H5private.h \ - ../src/H5Tprivate.h -hyperslab.o: \ - hyperslab.c \ - ../src/H5private.h \ - ../src/H5public.h \ - ../src/H5config.h \ - ../src/H5MMprivate.h \ - ../src/H5MMpublic.h istore.o: \ istore.c \ ../src/H5private.h \ @@ -240,8 +206,8 @@ istore.o: \ ../src/H5Sprivate.h \ ../src/H5Spublic.h \ ../src/H5Zprivate.h -dsets.o: \ - dsets.c \ +external.o: \ + external.c \ ../src/hdf5.h \ ../src/H5public.h \ ../src/H5config.h \ @@ -262,8 +228,27 @@ dsets.o: \ ../src/H5Zpublic.h \ ../src/H5Spublic.h \ ../src/H5Tpublic.h -cmpd_dset.o: \ - cmpd_dset.c \ +gheap.o: \ + gheap.c \ + ../src/H5private.h \ + ../src/H5public.h \ + ../src/H5config.h \ + ../src/H5Eprivate.h \ + ../src/H5Epublic.h \ + ../src/H5Ipublic.h \ + ../src/H5Fprivate.h \ + ../src/H5Fpublic.h \ + ../src/H5Dpublic.h \ + ../src/H5Gprivate.h \ + ../src/H5Gpublic.h \ + ../src/H5Bprivate.h \ + ../src/H5Bpublic.h \ + ../src/H5HGprivate.h \ + ../src/H5HGpublic.h \ + ../src/H5Pprivate.h \ + ../src/H5Ppublic.h +shtype.o: \ + shtype.c \ ../src/hdf5.h \ ../src/H5public.h \ ../src/H5config.h \ @@ -283,8 +268,8 @@ cmpd_dset.o: \ ../src/H5Ppublic.h \ ../src/H5Zpublic.h \ ../src/H5Spublic.h -extend.o: \ - extend.c \ +big.o: \ + big.c \ ../src/hdf5.h \ ../src/H5public.h \ ../src/H5config.h \ @@ -303,9 +288,11 @@ extend.o: \ ../src/H5Opublic.h \ ../src/H5Ppublic.h \ ../src/H5Zpublic.h \ - ../src/H5Spublic.h -external.o: \ - external.c \ + ../src/H5Spublic.h \ + ../src/H5Tpublic.h \ + ../src/H5private.h +chunk.o: \ + chunk.c \ ../src/hdf5.h \ ../src/H5public.h \ ../src/H5config.h \ @@ -348,27 +335,15 @@ iopipe.o: \ ../src/H5Zpublic.h \ ../src/H5Spublic.h \ ../src/H5Tpublic.h -gheap.o: \ - gheap.c \ +hyperslab.o: \ + hyperslab.c \ ../src/H5private.h \ ../src/H5public.h \ ../src/H5config.h \ - ../src/H5Eprivate.h \ - ../src/H5Epublic.h \ - ../src/H5Ipublic.h \ - ../src/H5Fprivate.h \ - ../src/H5Fpublic.h \ - ../src/H5Dpublic.h \ - ../src/H5Gprivate.h \ - ../src/H5Gpublic.h \ - ../src/H5Bprivate.h \ - ../src/H5Bpublic.h \ - ../src/H5HGprivate.h \ - ../src/H5HGpublic.h \ - ../src/H5Pprivate.h \ - ../src/H5Ppublic.h -shtype.o: \ - shtype.c \ + ../src/H5MMprivate.h \ + ../src/H5MMpublic.h +extend.o: \ + extend.c \ ../src/hdf5.h \ ../src/H5public.h \ ../src/H5config.h \ @@ -388,8 +363,8 @@ shtype.o: \ ../src/H5Ppublic.h \ ../src/H5Zpublic.h \ ../src/H5Spublic.h -big.o: \ - big.c \ +mtime.o: \ + mtime.c \ ../src/hdf5.h \ ../src/H5public.h \ ../src/H5config.h \ @@ -433,8 +408,8 @@ links.o: \ ../src/H5Zpublic.h \ ../src/H5Spublic.h \ ../src/H5Tpublic.h -chunk.o: \ - chunk.c \ +dtypes.o: \ + dtypes.c \ ../src/hdf5.h \ ../src/H5public.h \ ../src/H5config.h \ @@ -454,25 +429,36 @@ chunk.o: \ ../src/H5Ppublic.h \ ../src/H5Zpublic.h \ ../src/H5Spublic.h \ - ../src/H5Tpublic.h -bittests.o: \ - bittests.c \ + ../src/H5Tpublic.h \ ../src/H5Tpkg.h \ ../src/H5HGprivate.h \ - ../src/H5HGpublic.h \ + ../src/H5Fprivate.h \ + ../src/H5private.h \ + ../src/H5Tprivate.h +dsets.o: \ + dsets.c \ + ../src/hdf5.h \ ../src/H5public.h \ ../src/H5config.h \ - ../src/H5Fprivate.h \ - ../src/H5Fpublic.h \ ../src/H5Ipublic.h \ - ../src/H5private.h \ + ../src/H5Apublic.h \ + ../src/H5ACpublic.h \ + ../src/H5Bpublic.h \ ../src/H5Dpublic.h \ - ../src/H5Tprivate.h \ - ../src/H5Tpublic.h \ - ../src/H5Gprivate.h \ - ../src/H5Gpublic.h -mtime.o: \ - mtime.c \ + ../src/H5Epublic.h \ + ../src/H5Fpublic.h \ + ../src/H5Gpublic.h \ + ../src/H5HGpublic.h \ + ../src/H5HLpublic.h \ + ../src/H5MFpublic.h \ + ../src/H5MMpublic.h \ + ../src/H5Opublic.h \ + ../src/H5Ppublic.h \ + ../src/H5Zpublic.h \ + ../src/H5Spublic.h \ + ../src/H5Tpublic.h +cmpd_dset.o: \ + cmpd_dset.c \ ../src/hdf5.h \ ../src/H5public.h \ ../src/H5config.h \ @@ -491,6 +477,22 @@ mtime.o: \ ../src/H5Opublic.h \ ../src/H5Ppublic.h \ ../src/H5Zpublic.h \ + ../src/H5Rpublic.h \ ../src/H5Spublic.h \ + ../src/H5Tpublic.h +bittests.o: \ + bittests.c \ + ../src/H5Tpkg.h \ + ../src/H5HGprivate.h \ + ../src/H5HGpublic.h \ + ../src/H5public.h \ + ../src/H5config.h \ + ../src/H5Fprivate.h \ + ../src/H5Fpublic.h \ + ../src/H5Ipublic.h \ + ../src/H5private.h \ + ../src/H5Dpublic.h \ + ../src/H5Tprivate.h \ ../src/H5Tpublic.h \ - ../src/H5private.h + ../src/H5Gprivate.h \ + ../src/H5Gpublic.h diff --git a/test/bittests.c b/test/bittests.c index 520bace..e0e47b5 100644 --- a/test/bittests.c +++ b/test/bittests.c @@ -521,7 +521,7 @@ main (void) nerrors += test_copy ()<0?1:0; if (nerrors) { - printf("***** %lu FAILURE%s! *****\n", + printf("***** %u FAILURE%s! *****\n", nerrors, 1==nerrors?"":"S"); exit(1); } diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index 60219d0..5cfcb29 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -12,6 +12,15 @@ #include <stdlib.h> #include <string.h> +#include <H5config.h> +#ifndef HAVE_ATTRIBUTE +# undef __attribute__ +# define __attribute__(X) /*void*/ +# define __unused__ /*void*/ +#else +# define __unused__ __attribute__((unused)) +#endif + #define TEST_FILE_NAME "cmpd_dset.h5" /* The first dataset */ @@ -88,6 +97,31 @@ cleanup(void) /*------------------------------------------------------------------------- + * Function: display_error_cb + * + * Purpose: Displays the error stack after printing "*FAILED*". + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Robb Matzke + * Wednesday, March 4, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +display_error_cb (void __unused__ *client_data) +{ + puts ("*FAILED*"); + H5Eprint (stdout); + return 0; +} + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Creates a simple dataset of a compound type and then reads @@ -143,40 +177,39 @@ main (void) /* Tenth dataset */ /* Eleventh dataset */ +#if 0 s4_t *s11 = NULL; + int ndims; +#endif /* Other variables */ unsigned int i, j; - int ndims; hid_t file, dataset, space, PRESERVE; - herr_t status; static hsize_t dim[] = {NX, NY}; hssize_t f_offset[2]; /*offset of hyperslab in file */ hsize_t h_size[2]; /*size of hyperslab */ size_t memb_size[1] = {4}; + /* Set up error handling */ + H5Eset_auto(display_error_cb, NULL); + /* Create the file */ - file = H5Fcreate (TEST_FILE_NAME, H5F_ACC_TRUNC|H5F_ACC_DEBUG, - H5P_DEFAULT, H5P_DEFAULT); - assert (file>=0); + if ((file = H5Fcreate (TEST_FILE_NAME, H5F_ACC_TRUNC|H5F_ACC_DEBUG, + H5P_DEFAULT, H5P_DEFAULT))<0) goto error; /* Create the data space */ - space = H5Screate_simple (2, dim, NULL); - assert (space>=0); + if ((space = H5Screate_simple (2, dim, NULL))<0) goto error; /* Create xfer properties to preserve initialized data */ - PRESERVE = H5Pcreate (H5P_DATASET_XFER); - assert (PRESERVE>=0); - status = H5Pset_preserve (PRESERVE, 1); - assert (status>=0); + if ((PRESERVE = H5Pcreate (H5P_DATASET_XFER))<0) goto error; + if (H5Pset_preserve (PRESERVE, 1)<0) goto error; /* *###################################################################### * STEP 1: Save the original dataset natively. */ - printf ("\ -STEP 1: Initialize dataset `s1' and store it on disk in native order.\n"); - fflush (stdout); + printf("%-70s", "Testing basic compound write"); + fflush(stdout); /* Initialize the dataset */ for (i=0; i<NX*NY; i++) { @@ -191,22 +224,26 @@ STEP 1: Initialize dataset `s1' and store it on disk in native order.\n"); } /* Create the memory data type */ - s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)); - H5Tinsert (s1_tid, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); - H5Tinsert (s1_tid, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); - H5Tinsert_array (s1_tid, "c", HOFFSET(s1_t,c), 1, memb_size, NULL, - H5T_NATIVE_INT); - H5Tinsert (s1_tid, "d", HOFFSET(s1_t,d), H5T_NATIVE_INT); - H5Tinsert (s1_tid, "e", HOFFSET(s1_t,e), H5T_NATIVE_INT); - assert (s1_tid>=0); + if ((s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)))<0) goto error; + if (H5Tinsert (s1_tid, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT)<0 || + H5Tinsert (s1_tid, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT)<0 || + H5Tinsert_array (s1_tid, "c", HOFFSET(s1_t,c), 1, memb_size, NULL, + H5T_NATIVE_INT)<0 || + H5Tinsert (s1_tid, "d", HOFFSET(s1_t,d), H5T_NATIVE_INT)<0 || + H5Tinsert (s1_tid, "e", HOFFSET(s1_t,e), H5T_NATIVE_INT)<0) { + goto error; + } /* Create the dataset */ - dataset = H5Dcreate (file, "s1", s1_tid, space, H5P_DEFAULT); - assert (dataset>=0); + if ((dataset = H5Dcreate (file, "s1", s1_tid, space, H5P_DEFAULT))<0) { + goto error; + } /* Write the data */ - status = H5Dwrite (dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1); - assert (status>=0); + if (H5Dwrite (dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1)<0) { + goto error; + } + puts(" PASSED"); /* *###################################################################### @@ -214,37 +251,41 @@ STEP 1: Initialize dataset `s1' and store it on disk in native order.\n"); * it's the same as the first just to test things better, but * in fact, we could have used s1_tid. */ - printf ("\ -STEP 2: Read the dataset from disk into a new memory buffer which has the\n\ - same data type and space. This will be the typical case.\n"); - fflush (stdout); + printf("%-70s", "Testing basic compound read"); + fflush(stdout); - /* Create a data type for s2 */ - s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t)); - H5Tinsert (s2_tid, "a", HOFFSET(s2_t,a), H5T_NATIVE_INT); - H5Tinsert (s2_tid, "b", HOFFSET(s2_t,b), H5T_NATIVE_INT); - H5Tinsert_array (s2_tid, "c", HOFFSET(s2_t,c), 1, memb_size, NULL, - H5T_NATIVE_INT); - H5Tinsert (s2_tid, "d", HOFFSET(s2_t,d), H5T_NATIVE_INT); - H5Tinsert (s2_tid, "e", HOFFSET(s2_t,e), H5T_NATIVE_INT); - assert (s2_tid>=0); + if ((s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t)))<0) goto error; + if (H5Tinsert (s2_tid, "a", HOFFSET(s2_t,a), H5T_NATIVE_INT)<0 || + H5Tinsert (s2_tid, "b", HOFFSET(s2_t,b), H5T_NATIVE_INT)<0 || + H5Tinsert_array (s2_tid, "c", HOFFSET(s2_t,c), 1, memb_size, NULL, + H5T_NATIVE_INT)<0 || + H5Tinsert (s2_tid, "d", HOFFSET(s2_t,d), H5T_NATIVE_INT)<0 || + H5Tinsert (s2_tid, "e", HOFFSET(s2_t,e), H5T_NATIVE_INT)<0) { + goto error; + } /* Read the data */ - status = H5Dread (dataset, s2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s2); - assert (status>=0); + if (H5Dread (dataset, s2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s2)<0) { + goto error; + } /* Compare s2 with s1. They should be the same */ for (i=0; i<NX*NY; i++) { - assert (s1[i].a==s2[i].a); - assert (s1[i].b==s2[i].b); - assert (s1[i].c[0]==s2[i].c[0]); - assert (s1[i].c[1]==s2[i].c[1]); - assert (s1[i].c[2]==s2[i].c[2]); - assert (s1[i].c[3]==s2[i].c[3]); - assert (s1[i].d==s2[i].d); - assert (s1[i].e==s2[i].e); + if (s1[i].a!=s2[i].a || + s1[i].b!=s2[i].b || + s1[i].c[0]!=s2[i].c[0] || + s1[i].c[1]!=s2[i].c[1] || + s1[i].c[2]!=s2[i].c[2] || + s1[i].c[3]!=s2[i].c[3] || + s1[i].d!=s2[i].d || + s1[i].e!=s2[i].e) { + puts("*FAILED*"); + puts(" Incorrect values read from the file"); + goto error; + } } + puts(" PASSED"); /* *###################################################################### @@ -252,69 +293,78 @@ STEP 2: Read the dataset from disk into a new memory buffer which has the\n\ * has the same data space but the data type is different: the * data type is a struct whose members are in the opposite order. */ - printf ("\ -STEP 3: Read the dataset again with members in a different order.\n"); + printf("%-70s", "Testing reversal of struct members"); fflush (stdout); /* Create a data type for s3 */ - s3_tid = H5Tcreate (H5T_COMPOUND, sizeof(s3_t)); - H5Tinsert (s3_tid, "a", HOFFSET(s3_t,a), H5T_NATIVE_INT); - H5Tinsert (s3_tid, "b", HOFFSET(s3_t,b), H5T_NATIVE_INT); - H5Tinsert_array (s3_tid, "c", HOFFSET(s3_t,c), 1, memb_size, NULL, - H5T_NATIVE_INT); - H5Tinsert (s3_tid, "d", HOFFSET(s3_t,d), H5T_NATIVE_INT); - H5Tinsert (s3_tid, "e", HOFFSET(s3_t,e), H5T_NATIVE_INT); - assert (s3_tid>=0); + if ((s3_tid = H5Tcreate (H5T_COMPOUND, sizeof(s3_t)))<0) goto error; + if (H5Tinsert (s3_tid, "a", HOFFSET(s3_t,a), H5T_NATIVE_INT)<0 || + H5Tinsert (s3_tid, "b", HOFFSET(s3_t,b), H5T_NATIVE_INT)<0 || + H5Tinsert_array (s3_tid, "c", HOFFSET(s3_t,c), 1, memb_size, NULL, + H5T_NATIVE_INT)<0 || + H5Tinsert (s3_tid, "d", HOFFSET(s3_t,d), H5T_NATIVE_INT)<0 || + H5Tinsert (s3_tid, "e", HOFFSET(s3_t,e), H5T_NATIVE_INT)<0) { + goto error; + } /* Read the data */ - status = H5Dread (dataset, s3_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s3); - assert (status>=0); + if (H5Dread (dataset, s3_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s3)<0) { + goto error; + } /* Compare s3 with s1. They should be the same */ for (i=0; i<NX*NY; i++) { - assert (s1[i].a==s3[i].a); - assert (s1[i].b==s3[i].b); - assert (s1[i].c[0]==s3[i].c[0]); - assert (s1[i].c[1]==s3[i].c[1]); - assert (s1[i].c[2]==s3[i].c[2]); - assert (s1[i].c[3]==s3[i].c[3]); - assert (s1[i].d==s3[i].d); - assert (s1[i].e==s3[i].e); + if (s1[i].a!=s3[i].a || + s1[i].b!=s3[i].b || + s1[i].c[0]!=s3[i].c[0] || + s1[i].c[1]!=s3[i].c[1] || + s1[i].c[2]!=s3[i].c[2] || + s1[i].c[3]!=s3[i].c[3] || + s1[i].d!=s3[i].d || + s1[i].e!=s3[i].e) { + puts("*FAILED*"); + puts(" Incorrect values read from the file"); + goto error; + } } + puts(" PASSED"); /* *###################################################################### * STEP 4: Read a subset of the members. Of the <a,b,c,d,e> members * stored on disk we'll read <b,d>. */ - printf ("\ -STEP 4: Read a subset of the members.\n"); + printf("%-70s", "Testing subset struct read"); fflush (stdout); /* Create a datatype for s4 */ - s4_tid = H5Tcreate (H5T_COMPOUND, sizeof(s4_t)); - H5Tinsert (s4_tid, "b", HOFFSET(s4_t,b), H5T_NATIVE_INT); - H5Tinsert (s4_tid, "d", HOFFSET(s4_t,d), H5T_NATIVE_INT); - assert (s4_tid>=0); + if ((s4_tid = H5Tcreate (H5T_COMPOUND, sizeof(s4_t)))<0) goto error; + if (H5Tinsert (s4_tid, "b", HOFFSET(s4_t,b), H5T_NATIVE_INT)<0) goto error; + if (H5Tinsert (s4_tid, "d", HOFFSET(s4_t,d), H5T_NATIVE_INT)<0) goto error; /* Read the data */ - status = H5Dread (dataset, s4_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s4); - assert (status>=0); + if (H5Dread (dataset, s4_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s4)<0) { + goto error; + } /* Compare s4 with s1 */ for (i=0; i<NX*NY; i++) { - assert (s1[i].b==s4[i].b); - assert (s1[i].d==s4[i].d); + if (s1[i].b!=s4[i].b || + s1[i].d!=s4[i].d) { + puts("*FAILED*"); + puts(" Incorrect values read from the file"); + goto error; + } } + puts(" PASSED"); /* *###################################################################### * STEP 5: Read all the members into a struct which has other members * which have already been initialized. */ - printf ("\ -STEP 5: Read members into a superset which is partially initialized.\n"); - fflush (stdout); + printf("%-70s", "Testing partially initialized superset read"); + fflush(stdout); /* Initialize some members */ for (i=0; i<NX*NY; i++) { @@ -325,38 +375,49 @@ STEP 5: Read members into a superset which is partially initialized.\n"); } /* Create a data type for s5 */ - s5_tid = H5Tcreate (H5T_COMPOUND, sizeof(s5_t)); - H5Tinsert (s5_tid, "a", HOFFSET(s5_t,a), H5T_NATIVE_INT); - H5Tinsert (s5_tid, "b", HOFFSET(s5_t,b), H5T_NATIVE_INT); - H5Tinsert_array (s5_tid, "c", HOFFSET(s5_t,c), 1, memb_size, NULL, - H5T_NATIVE_INT); - H5Tinsert (s5_tid, "d", HOFFSET(s5_t,d), H5T_NATIVE_INT); - H5Tinsert (s5_tid, "e", HOFFSET(s5_t,e), H5T_NATIVE_INT); - assert (s5_tid>=0); + if ((s5_tid = H5Tcreate (H5T_COMPOUND, sizeof(s5_t)))<0) goto error; + if (H5Tinsert (s5_tid, "a", HOFFSET(s5_t,a), H5T_NATIVE_INT)<0 || + H5Tinsert (s5_tid, "b", HOFFSET(s5_t,b), H5T_NATIVE_INT)<0 || + H5Tinsert_array (s5_tid, "c", HOFFSET(s5_t,c), 1, memb_size, NULL, + H5T_NATIVE_INT)<0 || + H5Tinsert (s5_tid, "d", HOFFSET(s5_t,d), H5T_NATIVE_INT)<0 || + H5Tinsert (s5_tid, "e", HOFFSET(s5_t,e), H5T_NATIVE_INT)) { + goto error; + } /* Read the data */ - status = H5Dread (dataset, s5_tid, H5S_ALL, H5S_ALL, PRESERVE, s5); - assert (status>=0); + if (H5Dread (dataset, s5_tid, H5S_ALL, H5S_ALL, PRESERVE, s5)<0) { + goto error; + } /* Check that the data was read properly */ for (i=0; i<NX*NY; i++) { - assert (s1[i].a==s5[i].a); - assert (s1[i].b==s5[i].b); - assert (s1[i].c[0]==s5[i].c[0]); - assert (s1[i].c[1]==s5[i].c[1]); - assert (s1[i].c[2]==s5[i].c[2]); - assert (s1[i].c[3]==s5[i].c[3]); - assert (s1[i].d==s5[i].d); - assert (s1[i].e==s5[i].e); + if (s1[i].a!=s5[i].a || + s1[i].b!=s5[i].b || + s1[i].c[0]!=s5[i].c[0] || + s1[i].c[1]!=s5[i].c[1] || + s1[i].c[2]!=s5[i].c[2] || + s1[i].c[3]!=s5[i].c[3] || + s1[i].d!=s5[i].d || + s1[i].e!=s5[i].e) { + puts("*FAILED*"); + puts(" Incorrect values read from the file"); + goto error; + } } /* Check that no previous values were clobbered */ for (i=0; i<NX*NY; i++) { - assert (s5[i].pre == 1000+4*i); - assert (s5[i].mid1 == 1001+4*i); - assert (s5[i].mid2 == 1002+4*i); - assert (s5[i].post == 1003+4*i); + if (s5[i].pre != 1000+4*i || + s5[i].mid1 != 1001+4*i || + s5[i].mid2 != 1002+4*i || + s5[i].post != 1003+4*i) { + puts("*FAILED*"); + puts(" Memory values were clobbered"); + goto error; + } } + puts(" PASSED"); /* *###################################################################### @@ -364,9 +425,7 @@ STEP 5: Read members into a superset which is partially initialized.\n"); * fields unchanged. This tests member alignment and background * buffers. */ - printf ("\ -STEP 6: Update fields `b' and `d' on the file, leaving the other fields\n\ - unchanged.\n"); + printf("%-70s", "Testing partially initialized superset write"); fflush (stdout); /* Initialize `s4' with new values */ @@ -376,24 +435,31 @@ STEP 6: Update fields `b' and `d' on the file, leaving the other fields\n\ } /* Write the data to file */ - status = H5Dwrite (dataset, s4_tid, H5S_ALL, H5S_ALL, PRESERVE, s4); - assert (status>=0); - + if (H5Dwrite (dataset, s4_tid, H5S_ALL, H5S_ALL, PRESERVE, s4)<0) { + goto error; + } + /* Read the data back */ - status = H5Dread (dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1); - assert (status>=0); + if (H5Dread (dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1)<0) { + goto error; + } /* Compare */ for (i=0; i<NX*NY; i++) { - assert (s1[i].a == 8*i+0); - assert (s1[i].b == 8*i+1); - assert (s1[i].c[0] == 8*i+2); - assert (s1[i].c[1] == 8*i+3); - assert (s1[i].c[2] == 8*i+4); - assert (s1[i].c[3] == 8*i+5); - assert (s1[i].d == 8*i+6); - assert (s1[i].e == 8*i+7); + if (s1[i].a != 8*i+0 || + s1[i].b != 8*i+1 || + s1[i].c[0] != 8*i+2 || + s1[i].c[1] != 8*i+3 || + s1[i].c[2] != 8*i+4 || + s1[i].c[3] != 8*i+5 || + s1[i].d != 8*i+6 || + s1[i].e != 8*i+7) { + puts("*FAILED*"); + puts(" File values were clobbered"); + goto error; + } } + puts(" PASSED"); /* *###################################################################### @@ -401,29 +467,33 @@ STEP 6: Update fields `b' and `d' on the file, leaving the other fields\n\ * though these data spaces are equal it tests a different part of the * library. */ - printf ("\ -STEP 7: Reading original dataset with explicit data space.\n"); + printf("%-70s", "Testing explicit data space"); fflush (stdout); /* Create the data space */ - s7_sid = H5Screate_simple (2, dim, NULL); - assert (s7_sid>=0); + if ((s7_sid = H5Screate_simple (2, dim, NULL))<0) goto error; /* Read the dataset */ - status = H5Dread (dataset, s2_tid, s7_sid, H5S_ALL, H5P_DEFAULT, s2); - assert (status>=0); + if (H5Dread (dataset, s2_tid, s7_sid, H5S_ALL, H5P_DEFAULT, s2)<0) { + goto error; + } /* Compare */ for (i=0; i<NX*NY; i++) { - assert (s2[i].a == s1[i].a); - assert (s2[i].b == s1[i].b); - assert (s2[i].c[0] == s1[i].c[0]); - assert (s2[i].c[1] == s1[i].c[1]); - assert (s2[i].c[2] == s1[i].c[2]); - assert (s2[i].c[3] == s1[i].c[3]); - assert (s2[i].d == s1[i].d); - assert (s2[i].e == s1[i].e); + if (s2[i].a != s1[i].a || + s2[i].b != s1[i].b || + s2[i].c[0] != s1[i].c[0] || + s2[i].c[1] != s1[i].c[1] || + s2[i].c[2] != s1[i].c[2] || + s2[i].c[3] != s1[i].c[3] || + s2[i].d != s1[i].d || + s2[i].e != s1[i].e) { + puts("*FAILED*"); + puts(" Incorrect values read from file"); + goto error; + } } + puts(" PASSED"); /* @@ -431,30 +501,27 @@ STEP 7: Reading original dataset with explicit data space.\n"); * STEP 8. Read a hyperslab of the file into a complete array in memory. * The hyperslab is the middle third of the array. */ - printf ("\ -STEP 8: Read middle third hyperslab into memory array.\n"); + printf("%-70s", "Testing hyperslab partial read to array"); fflush (stdout); /* Create the file data space */ - s8_f_sid = H5Dget_space (dataset); - assert (s8_f_sid>=0); + if ((s8_f_sid = H5Dget_space (dataset))<0) goto error; f_offset[0] = NX/3; f_offset[1] = NY/3; h_size[0] = 2*NX/3 - f_offset[0]; h_size[1] = 2*NY/3 - f_offset[1]; - status = H5Sselect_hyperslab (s8_f_sid, H5S_SELECT_SET, f_offset, NULL, - h_size, NULL); - assert (status>=0); + if (H5Sselect_hyperslab (s8_f_sid, H5S_SELECT_SET, f_offset, NULL, + h_size, NULL)<0) goto error; /* Create memory data space */ - s8_m_sid = H5Screate_simple (2, h_size, NULL); - assert (s8_m_sid>=0); + if ((s8_m_sid = H5Screate_simple (2, h_size, NULL))<0) goto error; /* Read the dataset */ s8 = calloc ((size_t)(h_size[0]*h_size[1]), sizeof(s1_t)); assert (s8); - status = H5Dread (dataset, s1_tid, s8_m_sid, s8_f_sid, H5P_DEFAULT, s8); - assert (status>=0); + if (H5Dread (dataset, s1_tid, s8_m_sid, s8_f_sid, H5P_DEFAULT, s8)<0) { + goto error; + } /* Compare */ for (i=0; i<h_size[0]; i++) { @@ -462,19 +529,24 @@ STEP 8: Read middle third hyperslab into memory array.\n"); s1_t *ps1 = s1 + (f_offset[0]+i)*NY + f_offset[1] + j; s1_t *ps8 = s8 + i*h_size[1] + j; - assert (ps8->a == ps1->a); - assert (ps8->b == ps1->b); - assert (ps8->c[0] == ps1->c[0]); - assert (ps8->c[1] == ps1->c[1]); - assert (ps8->c[2] == ps1->c[2]); - assert (ps8->c[3] == ps1->c[3]); - assert (ps8->d == ps1->d); - assert (ps8->e == ps1->e); + if (ps8->a != ps1->a || + ps8->b != ps1->b || + ps8->c[0] != ps1->c[0] || + ps8->c[1] != ps1->c[1] || + ps8->c[2] != ps1->c[2] || + ps8->c[3] != ps1->c[3] || + ps8->d != ps1->d || + ps8->e != ps1->e) { + puts("*FAILED*"); + puts(" Incorrect values read from file"); + goto error; + } } } free (s8); s8 = NULL; + puts(" PASSED"); /* @@ -482,8 +554,7 @@ STEP 8: Read middle third hyperslab into memory array.\n"); * STEP 9. Read a hyperslab of the file into a hyperslab of memory. The * part of memory not read is already initialized and must not change. */ - printf ("\ -STEP 9: Read middle third of hyperslab into middle third of memory array.\n"); + printf("%-70s", "Testing hyperslab partial read to another hyperslab"); fflush (stdout); /* Initialize */ @@ -493,8 +564,9 @@ STEP 9: Read middle third of hyperslab into middle third of memory array.\n"); } /* Read the hyperslab */ - status = H5Dread (dataset, s2_tid, s8_f_sid, s8_f_sid, H5P_DEFAULT, s2); - assert (status>=0); + if (H5Dread (dataset, s2_tid, s8_f_sid, s8_f_sid, H5P_DEFAULT, s2)<0) { + goto error; + } /* Compare */ for (i=0; i<NX; i++) { @@ -505,35 +577,42 @@ STEP 9: Read middle third of hyperslab into middle third of memory array.\n"); (hsize_t)i<f_offset[0]+h_size[0] && (hssize_t)j>=f_offset[1] && (hsize_t)j<f_offset[1]+h_size[1]) { - assert (ps2->a == ps1->a); - assert (ps2->b == ps1->b); - assert (ps2->c[0] == ps1->c[0]); - assert (ps2->c[1] == ps1->c[1]); - assert (ps2->c[2] == ps1->c[2]); - assert (ps2->c[3] == ps1->c[3]); - assert (ps2->d == ps1->d); - assert (ps2->e == ps1->e); + if (ps2->a != ps1->a || + ps2->b != ps1->b || + ps2->c[0] != ps1->c[0] || + ps2->c[1] != ps1->c[1] || + ps2->c[2] != ps1->c[2] || + ps2->c[3] != ps1->c[3] || + ps2->d != ps1->d || + ps2->e != ps1->e) { + puts("*FAILED*"); + puts(" Memory values clobbered"); + goto error; + } } else { - assert (ps2->a == (unsigned)(-1)); - assert (ps2->b == (unsigned)(-1)); - assert (ps2->c[0] == (unsigned)(-1)); - assert (ps2->c[1] == (unsigned)(-1)); - assert (ps2->c[2] == (unsigned)(-1)); - assert (ps2->c[3] == (unsigned)(-1)); - assert (ps2->d == (unsigned)(-1)); - assert (ps2->e == (unsigned)(-1)); + if (ps2->a != (unsigned)(-1) || + ps2->b != (unsigned)(-1) || + ps2->c[0] != (unsigned)(-1) || + ps2->c[1] != (unsigned)(-1) || + ps2->c[2] != (unsigned)(-1) || + ps2->c[3] != (unsigned)(-1) || + ps2->d != (unsigned)(-1) || + ps2->e != (unsigned)(-1)) { + puts("*FAILED*"); + puts(" Incorrect values read from file"); + goto error; + } } } } + puts(" PASSED"); /* *###################################################################### * STEP 10. Same as step 9 except the memory array contains some members * which are already initialized, like step 5. */ - printf ("\ -STEP 10: Read middle third of hyperslab into middle third of memory array\n\ - where some of the struct members are already initialized.\n"); + printf("%-70s", "Testing hyperslab to hyperslab part initialized read"); fflush (stdout); /* Initialize */ @@ -544,8 +623,9 @@ STEP 10: Read middle third of hyperslab into middle third of memory array\n\ } /* Read the hyperslab */ - status = H5Dread (dataset, s5_tid, s8_f_sid, s8_f_sid, PRESERVE, s5); - assert (status>=0); + if (H5Dread (dataset, s5_tid, s8_f_sid, s8_f_sid, PRESERVE, s5)<0) { + goto error; + } /* Compare */ for (i=0; i<NX; i++) { @@ -556,34 +636,43 @@ STEP 10: Read middle third of hyperslab into middle third of memory array\n\ (hsize_t)i<f_offset[0]+h_size[0] && (hssize_t)j>=f_offset[1] && (hsize_t)j<f_offset[1]+h_size[1]) { - assert (ps5->pre == (unsigned)(-1)); - assert (ps5->a == ps1->a); - assert (ps5->b == ps1->b); - assert (ps5->mid1 == (unsigned)(-1)); - assert (ps5->c[0] == ps1->c[0]); - assert (ps5->c[1] == ps1->c[1]); - assert (ps5->c[2] == ps1->c[2]); - assert (ps5->c[3] == ps1->c[3]); - assert (ps5->mid2 == (unsigned)(-1)); - assert (ps5->d == ps1->d); - assert (ps5->e == ps1->e); - assert (ps5->post == (unsigned)(-1)); + if (ps5->pre != (unsigned)(-1) || + ps5->a != ps1->a || + ps5->b != ps1->b || + ps5->mid1 != (unsigned)(-1) || + ps5->c[0] != ps1->c[0] || + ps5->c[1] != ps1->c[1] || + ps5->c[2] != ps1->c[2] || + ps5->c[3] != ps1->c[3] || + ps5->mid2 != (unsigned)(-1) || + ps5->d != ps1->d || + ps5->e != ps1->e || + ps5->post != (unsigned)(-1)) { + puts("*FAILED*"); + puts(" Memory values clobbered"); + goto error; + } } else { - assert (ps5->pre == (unsigned)(-1)); - assert (ps5->a == (unsigned)(-1)); - assert (ps5->b == (unsigned)(-1)); - assert (ps5->mid1 == (unsigned)(-1)); - assert (ps5->c[0] == (unsigned)(-1)); - assert (ps5->c[1] == (unsigned)(-1)); - assert (ps5->c[2] == (unsigned)(-1)); - assert (ps5->c[3] == (unsigned)(-1)); - assert (ps5->mid2 == (unsigned)(-1)); - assert (ps5->d == (unsigned)(-1)); - assert (ps5->e == (unsigned)(-1)); - assert (ps5->post == (unsigned)(-1)); + if (ps5->pre != (unsigned)(-1) || + ps5->a != (unsigned)(-1) || + ps5->b != (unsigned)(-1) || + ps5->mid1 != (unsigned)(-1) || + ps5->c[0] != (unsigned)(-1) || + ps5->c[1] != (unsigned)(-1) || + ps5->c[2] != (unsigned)(-1) || + ps5->c[3] != (unsigned)(-1) || + ps5->mid2 != (unsigned)(-1) || + ps5->d != (unsigned)(-1) || + ps5->e != (unsigned)(-1) || + ps5->post != (unsigned)(-1)) { + puts("*FAILED*"); + puts(" Incorrect values read from file"); + goto error; + } } } } + puts(" PASSED"); /* *###################################################################### @@ -656,5 +745,12 @@ STEP 11: Write an array back to the middle third of the dataset to\n\ H5Fclose (file); cleanup(); + puts("All compound dataset tests passed."); return 0; + +error: + cleanup(); + puts("Remaining tests have been skipped."); + puts("*** DATASET TESTS FAILED ***"); + return 1; } diff --git a/test/ragged.c b/test/ragged.c new file mode 100644 index 0000000..43e3ca4 --- /dev/null +++ b/test/ragged.c @@ -0,0 +1,249 @@ +/* + * Copyright © 1998 Spizella Software + * All rights reserved. + * + * Programmer: Robb Matzke <robb@arborea.spizella.com> + * Tuesday, August 25, 1998 + */ +#include <assert.h> +#include <hdf5.h> +#include <signal.h> +#include <stdlib.h> + +#include <H5private.h> /*for performance monitoring*/ + + +#define NOTIFY_INTERVAL 2 /*seconds*/ +#define TIME_LIMIT 60 /*seconds*/ +#define CH_SIZE 8192*8 /*approx chunk size in bytes*/ + +typedef struct { + double percent; + size_t lo, hi; + size_t nhits; +} quant_t; + +#if 1 +/* Typical VBT sizes */ +static quant_t quant_g[] = { + {10.00, 1, 5}, + {89.00, 6, 20}, + { 0.90, 21, 100}, + { 0.09, 101, 1000}, + { 0.01, 1001, 10000}, +}; +#elif 0 +/* Sizes for testing */ +static quant_t quant_g[] = { + {10.0, 1, 5}, + {80.0, 6, 15}, + {10.0, 16, 20}, +}; +#elif 0 +/* Larger I/O */ +static quant_t quant_g[] = { + {10.0, 1, 1000}, + {80.0, 1001, 5000}, + {10.0, 5001, 10000}, +}; +#else +/* All same size */ +static quant_t quant_g[] = { + {100.0, 1000, 1000} +}; +#endif + +static volatile sig_atomic_t alarm_g = 0; +static volatile sig_atomic_t abort_g = 0; + + +/*------------------------------------------------------------------------- + * Function: catch_alarm + * + * Purpose: Increments the global `alarm_g' and resets the alarm for + * another few seconds. + * + * Return: void + * + * Programmer: Robb Matzke + * Wednesday, August 26, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +catch_alarm(int signum) +{ + static int ncalls=0; + + ncalls++; + if (0==ncalls % NOTIFY_INTERVAL) { + alarm_g++; + } + if (ncalls>=TIME_LIMIT) { + abort_g=1; + } + alarm(1); +} + + +/*------------------------------------------------------------------------- + * Function: rand_nelmts + * + * Purpose: Returns a the length of a 1-d array according to the + * probabilities described above. + * + * Return: Success: Number of elements + * + * Failure: never fails + * + * Programmer: Robb Matzke + * Thursday, August 20, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static size_t +rand_nelmts(void) +{ + double p = (rand() % 1000000)/1000000.0; + double total = 0.0; + size_t size, i; + + for (i=0; i<NELMTS(quant_g); i++) { + total += quant_g[i].percent/100.0; + if (p<total) { + size = rand()%(1+(quant_g[i].hi-quant_g[i].lo)) + quant_g[i].lo; + quant_g[i].nhits++; + break; + } + } + assert(i<NELMTS(quant_g)); + return size; +} + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: + * + * Return: Success: + * + * Failure: + * + * Programmer: Robb Matzke + * Friday, August 21, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t file, dcpl, ra; + int *dd, max_nelmts=3000000, total_nelmts=0; + int i, rows_at_once=100; + hssize_t row; /*current row number */ + hsize_t max_width = quant_g[NELMTS(quant_g)-1].hi; + hsize_t ch_size[2]; /*chunk size */ + hsize_t interval_nelmts; /*elmts/interval timer */ + hsize_t *size=NULL; /*size of each row */ + void **buf=NULL; /*buffer for each row */ + struct sigaction act; /*alarm signal handler */ + H5_timer_t timer, timer_total; /*performance timers */ + char s[64]; /*tempory string buffer */ + + /* Get a SIGALRM every few seconds */ + act.sa_handler = catch_alarm; + sigemptyset(&(act.sa_mask)); + act.sa_flags = 0; + sigaction(SIGALRM, &act, NULL); + alarm(1); + + /* Create the file and ragged array */ + if ((file=H5Fcreate("ragged.h5", H5F_ACC_TRUNC, H5P_DEFAULT, + H5P_DEFAULT))<0) goto error; + if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error; + ch_size[1] = 20; + ch_size[0] = MAX(1, CH_SIZE/(ch_size[1]*sizeof(int))); /*length*/ + printf("Chunk size is %lu by %lu\n", + (unsigned long)(ch_size[0]), (unsigned long)(ch_size[1])); + if (H5Pset_chunk(dcpl, 2, ch_size)<0) goto error; + if ((ra=H5Rcreate(file, "ra", H5T_NATIVE_INT, dcpl))<0) goto error; + if (H5Pclose(dcpl)<0) goto error; + + /* Create the ragged array row in memory */ + if (NULL==(dd = malloc(max_width*sizeof(int)))) goto error; + for (i=0; i<max_width; i++) dd[i] = i+1; + size = malloc(rows_at_once*sizeof(*size)); + buf = malloc(rows_at_once*sizeof(*buf)); + + /* + * Describe a few rows then add them to the ragged array. Print a status + * report every once in a while too. + */ + printf("Aggregated to %d row%s\n", rows_at_once, 1==rows_at_once?"":"s"); + printf(" %8s %8s %8s %10s\n", + "Row", "Nelmts", "Complete", "Bandwidth"); + printf(" -------- -------- -------- ----------\n"); + H5_timer_reset(&timer_total); + H5_timer_begin(&timer); + interval_nelmts = 0; + for (row=0; total_nelmts<max_nelmts && !abort_g; row+=i) { + for (i=0; i<rows_at_once && total_nelmts<max_nelmts; i++) { + size[i] = rand_nelmts(); + total_nelmts += size[i]; + buf[i] = dd; + interval_nelmts += size[i]; + } + if (H5Rwrite(ra, row, i, H5T_NATIVE_INT, size, buf)<0) goto error; + if (0==row || alarm_g) { + alarm_g = 0; + H5_timer_end(&timer_total, &timer); + H5_bandwidth(s, (double)interval_nelmts*sizeof(int), timer.etime); + printf(" %8lu %8lu %7.3f%% %10s%s\n", + (unsigned long)(row+i), (unsigned long)total_nelmts, + 100.0*total_nelmts/max_nelmts, s, abort_g?" (aborting)":""); + interval_nelmts = 0; + H5_timer_begin(&timer); + } + } + + /* Conclusions */ + if (!abort_g) { + H5_timer_end(&timer_total, &timer); + H5_bandwidth(s, (double)interval_nelmts*sizeof(int), timer.etime); + printf(" %8lu %8lu %7.3f%% %10s\n", + (unsigned long)row, (unsigned long)total_nelmts, + 100.0*total_nelmts/max_nelmts, s); + } + printf(" -------- -------- -------- ----------\n"); + H5_bandwidth(s, (double)total_nelmts*sizeof(int), timer_total.etime); + printf(" %27s%10s\n\n", "", s); + + + printf(" %9s %8s %8s\n", "Length", "Requsted", "Actual"); + printf(" --------------- -------- --------\n"); + for (i=0; i<NELMTS(quant_g); i++) { + printf(" [%6lu,%6lu] %7.3f%% %7.3f%%\n", + (unsigned long)(quant_g[i].lo), (unsigned long)(quant_g[i].hi), + quant_g[i].percent, + 100.0*(double)(quant_g[i].nhits)/(double)row); + } + printf(" --------------- -------- --------\n"); + + /* Cleanup */ + if (H5Rclose(ra)<0) goto error; + if (H5Fclose(file)<0) goto error; + free(dd); + free(size); + free(buf); + return 0; + + error: + return -1; +} diff --git a/tools/h5import.c b/tools/h5import.c index de1af53..dd88ba6 100644 --- a/tools/h5import.c +++ b/tools/h5import.c @@ -56,7 +56,7 @@ usage (const char *argv0) int main (int argc, char *argv[]) { - hid_t file, space, dset; + hid_t file, space=-1, dset=-1; const char *output_name, *dset_name; int argno, fd=-1; hsize_t size[1]; @@ -108,8 +108,14 @@ main (int argc, char *argv[]) if (fd>=0) close (fd); fd = -1; H5E_BEGIN_TRY { - H5Sclose (space); - H5Dclose (dset); + if (space>=0) { + H5Sclose (space); + space = -1; + } + if (dset>=0) { + H5Dclose (dset); + dset = -1; + } } H5E_END_TRY; } diff --git a/tools/h5tools.c b/tools/h5tools.c index bfb46a3..f6b7c24 100644 --- a/tools/h5tools.c +++ b/tools/h5tools.c @@ -157,6 +157,26 @@ h5dump_sprint(char *s/*out*/, const h5dump_t *info, hid_t type, void *vp) sprintf(temp, "%ld", *((long*)vp)); } else if (H5Tequal(type, H5T_NATIVE_ULONG)) { sprintf(temp, "%lu", *((unsigned long*)vp)); + } else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) { + if (sizeof(hssize_t)==sizeof(long)) { + sprintf(temp, "%ld", *((long*)vp)); + } else { + char fmt[8]; + strcpy(fmt, "%"); + strcat(fmt, PRINTF_LL_WIDTH); + strcat(fmt, "d"); + sprintf(temp, fmt, *((long long*)vp)); + } + } else if (H5Tequal(type, H5T_NATIVE_HSIZE)) { + if (sizeof(hsize_t)==sizeof(long)) { + sprintf(temp, "%lu", *((unsigned long*)vp)); + } else { + char fmt[8]; + strcpy(fmt, "%"); + strcat(fmt, PRINTF_LL_WIDTH); + strcat(fmt, "u"); + sprintf(temp, fmt, *((unsigned long long*)vp)); + } } else if (H5T_COMPOUND==H5Tget_class(type)) { nmembs = H5Tget_nmembers(type); strcpy(temp, OPT(info->cmpd_pre, "{")); |