From 79757db4c2ba2181ab88ba23f392790782802645 Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Mon, 7 Mar 2011 11:37:49 -0500 Subject: [svn-r20196] This checkin consists of the following: A) - Changes to add the new tool "h5watch" to High Level - Changes to add three new High Level public routines for retrieving elements appended to a dataset B) A patch from Mike M. to fix the H5Dflush/refresh problem: src/H5Dpkg.h src/H5Dint.c src/H5D.c C) Fix for an assertion failure in H5FS_sect_link_size() in H5FSsection.c src/H5Dbtree2.c h5committested; tested also on linew, duty, fred. --- configure | 7 +- configure.in | 3 + hl/src/H5HLprivate2.h | 53 ++ hl/src/H5LD.c | 652 ++++++++++++++ hl/src/H5LDprivate.h | 48 + hl/src/H5LDpublic.h | 32 + hl/src/Makefile.am | 4 +- hl/src/Makefile.in | 7 +- hl/src/hdf5_hl.h | 1 + hl/test/Makefile.am | 15 +- hl/test/Makefile.in | 75 +- hl/test/gen_test_ld.c | 360 ++++++++ hl/test/ld_extend.c | 151 ++++ hl/test/ld_monitor.c | 148 +++ hl/test/test_ld.c | 1397 +++++++++++++++++++++++++++++ hl/test/test_ld.h5 | Bin 0 -> 28336 bytes hl/test/test_ld.sh.in | 94 ++ hl/test/testfiles/test_ld_out1 | 31 + hl/test/testfiles/test_ld_out2 | 72 ++ hl/tools/Makefile.am | 4 +- hl/tools/Makefile.in | 3 +- hl/tools/h5watch/Makefile.am | 54 ++ hl/tools/h5watch/Makefile.in | 970 ++++++++++++++++++++ hl/tools/h5watch/WATCH.h5 | Bin 0 -> 26032 bytes hl/tools/h5watch/extend_dset.c | 380 ++++++++ hl/tools/h5watch/h5watch.c | 917 +++++++++++++++++++ hl/tools/h5watch/h5watchgentest.c | 328 +++++++ hl/tools/h5watch/testh5watch.sh.in | 372 ++++++++ hl/tools/testfiles/w-err-cmpd1.ddl | 5 + hl/tools/testfiles/w-err-cmpd2.ddl | 5 + hl/tools/testfiles/w-err-cmpd3.ddl | 5 + hl/tools/testfiles/w-err-cmpd4.ddl | 5 + hl/tools/testfiles/w-err-cmpd5.ddl | 5 + hl/tools/testfiles/w-err-dset-nomax.ddl | 5 + hl/tools/testfiles/w-err-dset-none.ddl | 5 + hl/tools/testfiles/w-err-dset1.ddl | 5 + hl/tools/testfiles/w-err-dset2.ddl | 5 + hl/tools/testfiles/w-err-file.ddl | 4 + hl/tools/testfiles/w-err-poll.ddl | 37 + hl/tools/testfiles/w-err-poll0.ddl | 37 + hl/tools/testfiles/w-err-width.ddl | 37 + hl/tools/testfiles/w-ext-cmpd-esc-f1.ddl | 14 + hl/tools/testfiles/w-ext-cmpd-esc-f2.ddl | 14 + hl/tools/testfiles/w-ext-cmpd-esc-f3.ddl | 13 + hl/tools/testfiles/w-ext-cmpd-esc-ff1.ddl | 14 + hl/tools/testfiles/w-ext-cmpd-esc-ff2.ddl | 14 + hl/tools/testfiles/w-ext-cmpd-esc-ff3.ddl | 13 + hl/tools/testfiles/w-ext-cmpd-esc.ddl | 16 + hl/tools/testfiles/w-ext-cmpd-f1.ddl | 14 + hl/tools/testfiles/w-ext-cmpd-f2.ddl | 14 + hl/tools/testfiles/w-ext-cmpd-f3.ddl | 13 + hl/tools/testfiles/w-ext-cmpd-ff1.ddl | 14 + hl/tools/testfiles/w-ext-cmpd-ff2.ddl | 14 + hl/tools/testfiles/w-ext-cmpd-ff3.ddl | 13 + hl/tools/testfiles/w-ext-cmpd-label.ddl | 21 + hl/tools/testfiles/w-ext-cmpd-two-f1.ddl | 50 ++ hl/tools/testfiles/w-ext-cmpd-two-f2.ddl | 50 ++ hl/tools/testfiles/w-ext-cmpd-two-f3.ddl | 44 + hl/tools/testfiles/w-ext-cmpd-two-ff1.ddl | 50 ++ hl/tools/testfiles/w-ext-cmpd-two-ff2.ddl | 50 ++ hl/tools/testfiles/w-ext-cmpd-two-ff3.ddl | 44 + hl/tools/testfiles/w-ext-cmpd-two.ddl | 70 ++ hl/tools/testfiles/w-ext-cmpd.ddl | 16 + hl/tools/testfiles/w-ext-early.ddl | 13 + hl/tools/testfiles/w-ext-late.ddl | 13 + hl/tools/testfiles/w-ext-one-d.ddl | 9 + hl/tools/testfiles/w-ext-one-simple.ddl | 16 + hl/tools/testfiles/w-ext-one.ddl | 13 + hl/tools/testfiles/w-ext-two-d.ddl | 21 + hl/tools/testfiles/w-ext-two-width.ddl | 44 + hl/tools/testfiles/w-ext-two.ddl | 40 + hl/tools/testfiles/w-help1.ddl | 37 + hl/tools/testfiles/w-help2.ddl | 37 + src/H5D.c | 4 + src/H5Dbtree2.c | 14 +- src/H5Dint.c | 1 - src/H5Dpkg.h | 1 + tools/h5dump/h5dump.c | 3 +- tools/lib/h5tools.c | 10 + tools/lib/h5tools.h | 10 +- tools/lib/h5tools_str.c | 168 +++- 81 files changed, 7285 insertions(+), 82 deletions(-) create mode 100644 hl/src/H5LD.c create mode 100644 hl/src/H5LDprivate.h create mode 100644 hl/src/H5LDpublic.h create mode 100644 hl/test/gen_test_ld.c create mode 100644 hl/test/ld_extend.c create mode 100644 hl/test/ld_monitor.c create mode 100644 hl/test/test_ld.c create mode 100644 hl/test/test_ld.h5 create mode 100644 hl/test/test_ld.sh.in create mode 100644 hl/test/testfiles/test_ld_out1 create mode 100644 hl/test/testfiles/test_ld_out2 create mode 100644 hl/tools/h5watch/Makefile.am create mode 100644 hl/tools/h5watch/Makefile.in create mode 100644 hl/tools/h5watch/WATCH.h5 create mode 100644 hl/tools/h5watch/extend_dset.c create mode 100644 hl/tools/h5watch/h5watch.c create mode 100644 hl/tools/h5watch/h5watchgentest.c create mode 100644 hl/tools/h5watch/testh5watch.sh.in create mode 100644 hl/tools/testfiles/w-err-cmpd1.ddl create mode 100644 hl/tools/testfiles/w-err-cmpd2.ddl create mode 100644 hl/tools/testfiles/w-err-cmpd3.ddl create mode 100644 hl/tools/testfiles/w-err-cmpd4.ddl create mode 100644 hl/tools/testfiles/w-err-cmpd5.ddl create mode 100644 hl/tools/testfiles/w-err-dset-nomax.ddl create mode 100644 hl/tools/testfiles/w-err-dset-none.ddl create mode 100644 hl/tools/testfiles/w-err-dset1.ddl create mode 100644 hl/tools/testfiles/w-err-dset2.ddl create mode 100644 hl/tools/testfiles/w-err-file.ddl create mode 100644 hl/tools/testfiles/w-err-poll.ddl create mode 100644 hl/tools/testfiles/w-err-poll0.ddl create mode 100644 hl/tools/testfiles/w-err-width.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-esc-f1.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-esc-f2.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-esc-f3.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-esc-ff1.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-esc-ff2.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-esc-ff3.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-esc.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-f1.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-f2.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-f3.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-ff1.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-ff2.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-ff3.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-label.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-two-f1.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-two-f2.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-two-f3.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-two-ff1.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-two-ff2.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-two-ff3.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd-two.ddl create mode 100644 hl/tools/testfiles/w-ext-cmpd.ddl create mode 100644 hl/tools/testfiles/w-ext-early.ddl create mode 100644 hl/tools/testfiles/w-ext-late.ddl create mode 100644 hl/tools/testfiles/w-ext-one-d.ddl create mode 100644 hl/tools/testfiles/w-ext-one-simple.ddl create mode 100644 hl/tools/testfiles/w-ext-one.ddl create mode 100644 hl/tools/testfiles/w-ext-two-d.ddl create mode 100644 hl/tools/testfiles/w-ext-two-width.ddl create mode 100644 hl/tools/testfiles/w-ext-two.ddl create mode 100644 hl/tools/testfiles/w-help1.ddl create mode 100644 hl/tools/testfiles/w-help2.ddl diff --git a/configure b/configure index 3c0356e..8e851d0 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Id: configure.in 19879 2010-12-08 21:56:28Z mamcgree . +# From configure.in Id: configure.in 20146 2011-02-22 20:37:06Z koziol . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68 for HDF5 1.9.80-FA_a5. # @@ -29522,7 +29522,7 @@ if test -n "$TESTPARALLEL"; then fi fi -ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testcheck_version.sh test/testerror.sh test/testflushrefresh.sh test/H5srcdir_str.h test/testlibinfo.sh test/testlinks_env.sh testpar/Makefile testpar/testph5.sh perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumpxml.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5diff/Makefile tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5ls/Makefile tools/h5copy/Makefile tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile examples/Makefile examples/run-c-ex.sh examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/test/H5srcdir_str.h c++/examples/Makefile c++/examples/run-c++-ex.sh c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/run-fortran-ex.sh fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/test/H5srcdir_str.h hl/tools/Makefile hl/tools/gif2h5/Makefile hl/examples/Makefile hl/examples/run-hlc-ex.sh hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/c++/examples/run-hlc++-ex.sh hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile hl/fortran/examples/run-hlfortran-ex.sh" +ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testcheck_version.sh test/testerror.sh test/testflushrefresh.sh test/H5srcdir_str.h test/testlibinfo.sh test/testlinks_env.sh testpar/Makefile testpar/testph5.sh perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumpxml.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5diff/Makefile tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5ls/Makefile tools/h5copy/Makefile tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile examples/Makefile examples/run-c-ex.sh examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/test/H5srcdir_str.h c++/examples/Makefile c++/examples/run-c++-ex.sh c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/run-fortran-ex.sh fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/test/H5srcdir_str.h hl/test/test_ld.sh hl/tools/Makefile hl/tools/gif2h5/Makefile hl/tools/h5watch/Makefile hl/tools/h5watch/testh5watch.sh hl/examples/Makefile hl/examples/run-hlc-ex.sh hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/c++/examples/run-hlc++-ex.sh hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile hl/fortran/examples/run-hlfortran-ex.sh" cat >confcache <<\_ACEOF @@ -30832,8 +30832,11 @@ do "hl/src/Makefile") CONFIG_FILES="$CONFIG_FILES hl/src/Makefile" ;; "hl/test/Makefile") CONFIG_FILES="$CONFIG_FILES hl/test/Makefile" ;; "hl/test/H5srcdir_str.h") CONFIG_FILES="$CONFIG_FILES hl/test/H5srcdir_str.h" ;; + "hl/test/test_ld.sh") CONFIG_FILES="$CONFIG_FILES hl/test/test_ld.sh" ;; "hl/tools/Makefile") CONFIG_FILES="$CONFIG_FILES hl/tools/Makefile" ;; "hl/tools/gif2h5/Makefile") CONFIG_FILES="$CONFIG_FILES hl/tools/gif2h5/Makefile" ;; + "hl/tools/h5watch/Makefile") CONFIG_FILES="$CONFIG_FILES hl/tools/h5watch/Makefile" ;; + "hl/tools/h5watch/testh5watch.sh") CONFIG_FILES="$CONFIG_FILES hl/tools/h5watch/testh5watch.sh" ;; "hl/examples/Makefile") CONFIG_FILES="$CONFIG_FILES hl/examples/Makefile" ;; "hl/examples/run-hlc-ex.sh") CONFIG_FILES="$CONFIG_FILES hl/examples/run-hlc-ex.sh" ;; "hl/c++/Makefile") CONFIG_FILES="$CONFIG_FILES hl/c++/Makefile" ;; diff --git a/configure.in b/configure.in index b5036ab..6911f13 100644 --- a/configure.in +++ b/configure.in @@ -4365,8 +4365,11 @@ AC_CONFIG_FILES([src/libhdf5.settings hl/src/Makefile hl/test/Makefile hl/test/H5srcdir_str.h + hl/test/test_ld.sh hl/tools/Makefile hl/tools/gif2h5/Makefile + hl/tools/h5watch/Makefile + hl/tools/h5watch/testh5watch.sh hl/examples/Makefile hl/examples/run-hlc-ex.sh hl/c++/Makefile diff --git a/hl/src/H5HLprivate2.h b/hl/src/H5HLprivate2.h index e2597db..7480bd8 100644 --- a/hl/src/H5HLprivate2.h +++ b/hl/src/H5HLprivate2.h @@ -60,6 +60,59 @@ #ifndef TRUE # define TRUE 1 #endif +#ifndef HDcalloc + #define HDcalloc(N,Z) calloc(N,Z) +#endif /* HDcalloc */ +#ifndef HDrealloc + #define HDrealloc(M,Z) realloc(M,Z) +#endif /* HDrealloc */ +#ifndef HDfree + #define HDfree(M) free(M) +#endif /* HDfree */ +#ifndef HDmemcpy + #define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z) +#endif /* HDmemcpy */ +#ifndef HDmemset + #define HDmemset(X,C,Z) memset(X,C,Z) +#endif /* HDmemset */ +#ifndef HDassert + #define HDassert(X) assert(X) +#endif /* HDassert */ +#ifndef HDstrlen + #define HDstrlen(S) strlen(S) +#endif /* HDstrlen */ +#ifndef HDstrcat + #define HDstrcat(X,Y) strcat(X,Y) +#endif /* HDstrcat */ +#ifndef HDstrrchr + #define HDstrrchr(S,C) strrchr(S,C) +#endif /* HDstrrchr */ +#ifndef HDstrtol + #define HDstrtol(S,R,N) strtol(S,R,N) +#endif /* HDstrtol */ +#ifndef HDstrtod + #define HDstrtod(S,R) strtod(S,R) +#endif /* HDstrtod */ +#ifndef HDsleep + #define HDsleep(N) sleep(N) +#endif /* HDsleep */ +#ifndef HDfflush + #define HDfflush(F) fflush(F) +#endif /* HDfflush */ +#ifndef HDstrcmp + #define HDstrcmp(X,Y) strcmp(X,Y) +#endif /* HDstrcmp */ +/* + * And now for a couple non-Posix functions... Watch out for systems that + * define these in terms of macros. + */ +#if !defined strdup && !defined H5_HAVE_STRDUP +extern char *strdup(const char *s); +#endif + +#ifndef HDstrdup + #define HDstrdup(S) strdup(S) +#endif /* HDstrdup */ #endif /* _H5HLprivate2_H */ diff --git a/hl/src/H5LD.c b/hl/src/H5LD.c new file mode 100644 index 0000000..409ecd7 --- /dev/null +++ b/hl/src/H5LD.c @@ -0,0 +1,652 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* Copyright by The HDF Group. * +* Copyright by the Board of Trustees of the University of Illinois. * +* All rights reserved. * +* * +* This file is part of HDF5. The full HDF5 copyright notice, including * +* terms governing use, modification, and redistribution, is contained in * +* the files COPYING and Copyright.html. COPYING can be found at the root * +* of the source code distribution tree; Copyright.html can be found at the * +* root level of an installed copy of the electronic HDF5 document set and * +* is linked from the top-level documents page. It can also be found at * +* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +* access to either file, you may request a copy from help@hdfgroup.org. * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include +#include +#include +#include +#include "H5LDprivate.h" + +/*------------------------------------------------------------------------- + * + * internal functions + * + *------------------------------------------------------------------------- + */ +static size_t H5LD_get_dset_type_size(hid_t did, const char *fields); +static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, + const char *fields, void *buf); +static herr_t H5LD_get_dset_dims(hid_t did, hsize_t *cur_dims); +static herr_t H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid); + +/*------------------------------------------------------------------------- + * Function: H5LD_clean_vector + * + * Purpose: Process the vector of info: + * 1) free the array of pointers to member names in listv[n] + * 2) close the type id of the last member in listv[n] + * 3) free the H5LD_memb_t structure itself as pointed to by listv[n] + * + * Return: void + * + * Programmer: Vailin Choi; Aug 2010 + * + *------------------------------------------------------------------------- + */ +void +H5LD_clean_vector(H5LD_memb_t *listv[]) +{ + unsigned n; /* Local index variable */ + + HDassert(listv); + + /* Go through info for each field stored in listv[] */ + for(n = 0; listv[n] != NULL; n++) { + if(listv[n]->names) { + HDfree(listv[n]->names); + listv[n]->names = NULL; + } + + /* Close the type id of the last member in the field */ + if(!(listv[n]->last_tid < 0)) { + H5Tclose(listv[n]->last_tid); + listv[n]->last_tid = -1; + } + /* Free the H5LD_memb_t structure for the field */ + HDfree(listv[n]); + listv[n] = NULL; + } +} /* H5LD_clean_vector() */ + +/*------------------------------------------------------------------------- + * Function: H5LD_construct_info() + * + * Purpose: Get the remaining info for a field: + * 1) Get the type id of the last member in the field + * 2) Get the total offset of all the members in the field + * 3) Get the type size of the last member in the field + * + * Return: Success: 0 + * Failure: negative + * + * Programmer: Vailin Choi; Aug 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid) +{ + hid_t tmp_tid; /* Dataset type id */ + hid_t memb_tid; /* Type id for a member in a field */ + unsigned i; /* Local index variable */ + int idx; /* Index # of a member in a compound data type */ + herr_t ret_value = SUCCEED; /* Return value */ + + tmp_tid = H5Tcopy(par_tid); + + /* Validate all the members in a field */ + for(i = 0; memb->names[i] != NULL; i++) { + /* Get the member index and member type id */ + if((idx = H5Tget_member_index(tmp_tid, memb->names[i])) < 0 || + (memb_tid = H5Tget_member_type(tmp_tid, (unsigned)idx)) < 0) { + ret_value = FAIL; + goto error; + } + + /* Sum up the offset of all the members in the field */ + memb->tot_offset += H5Tget_member_offset(tmp_tid, (unsigned)idx); + if(H5Tclose(tmp_tid) < 0) { + ret_value = FAIL; + goto error; + } + tmp_tid = memb_tid; + } + + /* Get the type size of the last member in the field */ + memb->last_tsize = H5Tget_size(tmp_tid); + /* Save the type id of the last member in the field */ + memb->last_tid = H5Tcopy(tmp_tid); + +error: + H5E_BEGIN_TRY + H5Tclose(tmp_tid); + H5E_END_TRY + + return(ret_value); +} /* H5LD_construct_info() */ + + +/*------------------------------------------------------------------------- + * Function: H5LD_construct_vector + * + * Purpose: Process the comma-separated list of fields in "fields" as follows: + * Example: + * "fields": "a.b.c,d" + * listv[0]->tot_offset = total offset of "a" & "b" & "c" + * listv[0]->last_tid = type id of "c" + * listv[0]->last_tsize = type size of "c" + * listv[0]->names[0] = "a" + * listv[0]->names[1] = "b" + * listv[0]->names[2] = "c" + * listv[0]->names[3] = NULL + * + * listv[1]->tot_offset = offset of "d" + * listv[1]->last_tid = type id of "d" + * listv[1]->last_tsize = type size of "d" + * listv[1]->names[0] = "d" + * listv[1]->names[1] = NULL + * + * Return: Success: # of comma-separated fields in "fields" + * Failure: negative value + * + * Programmer: Vailin Choi; Aug 2010 + * +*------------------------------------------------------------------------- +*/ +int +H5LD_construct_vector(char *fields, H5LD_memb_t *listv[]/*OUT*/, hid_t par_tid) +{ + int n; /* The # of comma-separated fields in "fields" */ + hbool_t valid; /* Whether a field being processed is valid or not */ + hbool_t end_of_fields = FALSE; /* end of "fields" */ + char *fields_ptr; /* Pointer to "fields" */ + char *cur; /* Pointer to a member in a field */ + int ret_value = SUCCEED; /* Return value */ + + HDassert(listv); + HDassert(fields); + + fields_ptr = fields; + n = 0; + + /* Process till end of "fields" */ + while(!end_of_fields) { + + hbool_t gotcomma = FALSE; /* A comma encountered */ + hbool_t gotmember = FALSE; /* Getting member in a field */ + H5LD_memb_t *memb = NULL; /* Pointer to structure for storing a field's info */ + size_t len; /* Estimated # of members in a field */ + int j = 0; /* The # of members in a field */ + + valid = TRUE; + len = HDstrlen(fields_ptr)/2 + 2; + + /* Allocate memory for an H5LD_memb_t for storing a field's info */ + if((memb = (H5LD_memb_t *)HDcalloc(1, sizeof(H5LD_memb_t))) == NULL) { + ret_value = FAIL; + break; + } + /* Allocate memory for an array of pointers to member names */ + if((memb->names = (char **)HDcalloc(len, sizeof(char *))) == NULL) { + ret_value = FAIL; + break; + } + + memb->names[j] = fields_ptr; + memb->last_tid = -1; + cur = fields_ptr; + + /* Continue processing till: not valid or comma encountered or "fields" ended */ + while(valid && !gotcomma && !end_of_fields) { + + switch(*fields_ptr) { + + case '\0': /* end of list */ + if(gotmember) { /* getting something and end of "fields" */ + *cur++ = '\0';; + memb->names[++j] = NULL; + } else /* getting nothing but end of list */ + valid = FALSE; + end_of_fields = TRUE; + break; + + case '\\': /* escape character */ + ++fields_ptr; /* skip it */ + if(*fields_ptr == '\0') + valid = FALSE; + else { + *cur++ = *fields_ptr++; + gotmember = TRUE; + } + break; + + case '.': /* nested field separator */ + *fields_ptr++ = *cur++ = '\0';; + if(gotmember) { + memb->names[++j] = cur; + gotmember = FALSE; + } else + valid = FALSE; + break; + + case ',': /* field separator */ + *fields_ptr++ = *cur++ = '\0';; + if(gotmember) { + memb->names[++j] = NULL; + gotmember = FALSE; + } else + valid = FALSE; + gotcomma = TRUE; + break; + + default: + *cur++ = *fields_ptr++; + gotmember = TRUE; + break; + } + } /* while (valid && !gotcomma && !end_of_fields) */ + + /* If valid, put into listv and continue processing further info */ + if(valid) { + listv[n++] = memb; + if((ret_value = H5LD_construct_info(memb, par_tid)) < 0) + break; + } else { + if(memb) HDfree(memb); + ret_value = FAIL; + break; + } + } /* while !end_of_fields */ + + listv[n] = NULL; + if(ret_value == FAIL) + (void) H5LD_clean_vector(listv); + else + ret_value = n; + + return(ret_value); +} /* H5LD_construct_vector() */ + +/*------------------------------------------------------------------------- + * Function: H5LD_get_dset_dims + * + * Purpose: To return the current size for each dimension of the + * dataset's dataspace + * + * Return: Success: 0 + * Failure: negative value + * + * Programmer: Vailin Choi; March 2010 + * +*------------------------------------------------------------------------- +*/ +static herr_t +H5LD_get_dset_dims(hid_t did, hsize_t *cur_dims) +{ + hid_t sid; /* dataspace id */ + int ret_value = SUCCEED; /* return_value */ + + /* Verify parameter */ + if(cur_dims == NULL) { + ret_value = FAIL; + goto out; + } + + /* Get the dataset's dataspace */ + if((sid = H5Dget_space(did)) < 0) { + ret_value = FAIL; + goto out; + } + + /* Get the current dimension size */ + if(H5Sget_simple_extent_dims(sid, cur_dims, NULL) < 0) + ret_value = FAIL; + +out: + H5E_BEGIN_TRY { + H5Sclose(sid); + } H5E_END_TRY; + return(ret_value); +} /* H5LD_get_dset_dims() */ + +/*------------------------------------------------------------------------- + * Function: H5LD_get_dset_type_size + * + * Purpose: To return the size of the dataset's data type in bytes + * null "fields": return the size of the dataset's data type + * non-null "fields": return the size of the dataset's data type + * with respect to the selection in "fields" + * + * Return: Success: size of the dataset's data type + * Failure: 0 (valid datatypes are never zero size) + * + * Programmer: Vailin Choi; March 2010 + * + *------------------------------------------------------------------------- + */ +static size_t +H5LD_get_dset_type_size(hid_t did, const char *fields) +{ + hid_t dset_tid; /* Dataset's type identifier */ + hid_t tid; /* Native Type identifier */ + size_t tot = 0; /* Data type size of all the fields in "fields" */ + H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */ + char *dup_fields = NULL; /* A copy of "fields" */ + int n = 0, num = 0; /* Local index variable */ + size_t len; /* Estimate the number of comma-separated fields in "fields" */ + size_t ret_value = 0; /* Return value */ + + /* Get the data type of the dataset */ + if(((dset_tid = H5Dget_type(did)) < 0) || (tid = H5Tget_native_type(dset_tid, H5T_DIR_DEFAULT)) < 0) + goto out; + + if(fields == NULL) /* If no "fields" is specified */ + ret_value = H5Tget_size(tid); + else { /* "fields" are specified */ + HDassert(fields && *fields); + + /* Should be a compound data type if "fields" exists */ + if(H5Tget_class(dset_tid) != H5T_COMPOUND) + goto out; + + /* Get a copy of "fields" */ + if((dup_fields = HDstrdup(fields)) == NULL) + goto out; + + /* Allocate memory for a list of H5LD_memb_t pointers to store "fields" info */ + len = HDstrlen(fields)/2 + 2; + if((listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))) == NULL) + goto out; + + /* Process and store info for "fields" */ + if((num = H5LD_construct_vector(dup_fields, listv/*OUT*/, tid)) < 0) + goto out; + + /* Sum up the size of all the data types in "fields" */ + for(n = 0; n < num; n++) + tot += listv[n]->last_tsize; + + /* Clean up the vector of H5LD_memb_t structures */ + (void) H5LD_clean_vector(listv); + + /* Return the total size */ + ret_value = tot; + } + +out: + H5E_BEGIN_TRY + H5Tclose(tid); + H5Tclose(dset_tid); + H5E_END_TRY + + /* Free the array of H5LD_memb_t pointers */ + if(listv) HDfree(listv); + /* Free memory */ + if(dup_fields) HDfree(dup_fields); + + return(ret_value); +} /* H5LD_get_dset_type_size() */ + +/*------------------------------------------------------------------------- + * Function: H5LD_get_dset_elmts + * + * Purpose: To retrieve selected data from the dataset + * + * Return: Success: 0 + * Failure: negative + * + * Programmer: Vailin Choi; August 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, void *buf) +{ + int ndims; /* Number of dimensions for the dataset */ + hid_t dtid, tid; /* Dataset type id */ + size_t tot_tsize; /* Total data type size */ + hid_t sid, mid; /* Dataspace and memory space id */ + hsize_t num_elmts; /* Number of dataset elements in the selection */ + hsize_t start[H5S_MAX_RANK];/* Starting offset */ + hsize_t count[H5S_MAX_RANK];/* ??offset */ + H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */ + char *dup_fields = NULL; /* A copy of "fields" */ + char *tmp_buf = NULL; /* Temporary buffer for data read */ + char *sav_buf = NULL; /* Saved pointer temporary buffer */ + int n = 0, i = 0; /* Local index variable */ + size_t len; /* Estimate the number of comma-separated fields in "fields" */ + unsigned int ctr = 0; /* Counter for # of curr_dims > prev_dims */ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Verify parameters */ + if(prev_dims == NULL || cur_dims == NULL || buf == NULL) { + ret_value = FAIL; + goto done; + } + + /* Get dataset's dataspace */ + if((sid = H5Dget_space(did)) < 0) { + ret_value = FAIL; + goto done; + } + + /* Get the number of dimensions */ + if((ndims = H5Sget_simple_extent_ndims(sid)) < 0) { + ret_value = FAIL; + goto done; + } + + /* Verify that cur_dims must have one dimension whose size is greater than prev_dims */ + HDmemset(start, 0, sizeof start); + HDmemset(count, 0, sizeof count); + for(i = 0; i < ndims; i++) + if(cur_dims[i] > prev_dims[i]) { + ++ctr; + count[i] = cur_dims[i] - prev_dims[i]; + start[i] = prev_dims[i]; + } else { /* < or = */ + start[i] = 0; + count[i] = MIN(prev_dims[i], cur_dims[i]); + } + + if(!ctr) { + ret_value = FAIL; + goto done; + } + + if(ctr == 1) { /* changes for only one dimension */ + /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */ + if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) { + ret_value = FAIL; + goto done; + } + } else { /* changes for more than one dimensions */ + + HDmemset(start, 0, sizeof start); + /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */ + if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, cur_dims, NULL) < 0) { + ret_value = FAIL; + goto done; + } + if(H5Sselect_hyperslab(sid, H5S_SELECT_NOTB, start, NULL, prev_dims, NULL) < 0) { + ret_value = FAIL; + goto done; + } + } + + /* Get the number of elements in the selection */ + if((num_elmts = H5Sget_select_npoints(sid)) == 0) { + ret_value = FAIL; + goto done; + } + + /* Create the memory space for the selection */ + if((mid = H5Screate_simple(1, &num_elmts, NULL)) < 0) { + ret_value = FAIL; + goto done; + } + + /* Get the native data type size */ + if(((dtid = H5Dget_type(did)) < 0) || (tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0) { + ret_value = FAIL; + goto done; + } + + if(fields == NULL) { /* nothing in "fields" */ + /* Read and store all the elements in "buf" */ + if(H5Dread(did, tid, mid, sid, H5P_DEFAULT, buf) < 0) { + ret_value = FAIL; + goto done; + } + } else { /* "fields" is specified */ + unsigned char *buf_p = (unsigned char *)buf; /* Pointer to the destination buffer */ + + /* should be a compound data type if "fields" exists */ + if(H5Tget_class(tid) != H5T_COMPOUND) { + ret_value = FAIL; + goto done; + } + + /* Get the total size of the dataset's data types */ + if((tot_tsize = H5LD_get_dset_type_size(did, NULL)) == 0) { + ret_value = FAIL; + goto done; + } + + /* Allocate memory for reading in the elements in the dataset selection */ + if((sav_buf = tmp_buf = (char *)HDcalloc((size_t)num_elmts, tot_tsize)) == NULL) { + ret_value = FAIL; + goto done; + } + + /* Read the dataset elements in the selection */ + if(H5Dread(did, tid, mid, sid, H5P_DEFAULT, tmp_buf) < 0) { + ret_value = FAIL; + goto done; + } + + /* Make a copy of "fields" */ + if((dup_fields = HDstrdup(fields)) == NULL) { + ret_value = FAIL; + goto done; + } + + /* Allocate memory for the vector of H5LD_memb_t pointers */ + len = HDstrlen(fields)/2 + 2; + if((listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))) == NULL) { + ret_value = FAIL; + goto done; + } + + /* Process and store information for "fields" */ + if(H5LD_construct_vector(dup_fields, listv, tid) < 0) { + ret_value = FAIL; + goto done; + } + + /* Copy data for each dataset element in the selection */ + for(i = 0; i < (int)num_elmts; i++) { + /* Copy data for "fields" to the input buffer */ + for(n = 0; listv[n] != NULL; n++) { + HDmemcpy(buf_p, tmp_buf + listv[n]->tot_offset, listv[n]->last_tsize); + buf_p += listv[n]->last_tsize; + } + tmp_buf += tot_tsize; + } + + /* Clean up the vector of H5LD_memb_t structures */ + (void) H5LD_clean_vector(listv); + } + +done: + H5E_BEGIN_TRY + H5Tclose(dtid); + H5Tclose(tid); + H5Sclose(sid); + H5Sclose(mid); + H5E_END_TRY + + /* Free the array of H5LD_memb_t pointers */ + if(listv) HDfree(listv); + /* Free memory */ + if(dup_fields) HDfree(dup_fields); + if(sav_buf) HDfree(sav_buf); + + return(ret_value); +} /* H5LD_get_dset_elmts() */ + +/*------------------------------------------------------------------------- + * + * Public functions + * + *------------------------------------------------------------------------- + */ + +/*------------------------------------------------------------------------- + * Function: H5LDget_dset_dims + * + * Purpose: To retrieve the current dimension sizes for a dataset + * + * Return: Success: 0 + * Failure: negative value + * + * Programmer: Vailin Choi; March 2010 + * + *------------------------------------------------------------------------- + */ +herr_t +H5LDget_dset_dims(hid_t did, hsize_t *cur_dims) +{ + int ret_value; /* return_value */ + + ret_value = H5LD_get_dset_dims(did, cur_dims); + + return(ret_value); +} /* H5LDget_dset_dims() */ + + +/*------------------------------------------------------------------------- + * Function: H5LDget_dset_type_size + * + * Purpose: To return the size in bytes of the data type for the dataset + * + * Return: Success: size in bytes of the dataset's data type + * Failure: 0 (valid datatypes are never zero size) + * + * Programmer: Vailin Choi; March 2010 + * + *------------------------------------------------------------------------- + */ +size_t +H5LDget_dset_type_size(hid_t did, const char *fields) +{ + size_t ret_value; /* Return value */ + + ret_value = H5LD_get_dset_type_size(did, fields); + + return(ret_value); +} /* H5LDget_dset_type_size() */ + +/*------------------------------------------------------------------------- + * Function: H5LDget_dset_elmts + * + * Purpose: To retrieve selected data from the dataset + * + * Return: Success: 0 + * Failure: negative value + * + * Programmer: Vailin Choi; March 2010 + * + *------------------------------------------------------------------------- + */ +herr_t +H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, void *buf) +{ + herr_t ret_value; /* Return value */ + + ret_value = H5LD_get_dset_elmts(did, prev_dims, cur_dims, fields, buf); + + return(ret_value); +} /* H5LDget_dset_elmts() */ diff --git a/hl/src/H5LDprivate.h b/hl/src/H5LDprivate.h new file mode 100644 index 0000000..2b29ca2 --- /dev/null +++ b/hl/src/H5LDprivate.h @@ -0,0 +1,48 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _H5LDprivate_H +#define _H5LDprivate_H + +/* High-level library internal header file */ +#include "H5HLprivate2.h" +#include "H5LDpublic.h" + +/* Store information for a field in for a compound data type */ +/* + * Note: This data structure is used by both H5LD.c and hl/tools/h5watch + * This declaration is repeated in tools/lib/h5tools_str.c + */ +typedef struct H5LD_memb_t { + size_t tot_offset; + size_t last_tsize; + hid_t last_tid; + char **names; +} H5LD_memb_t; + +/* + * Note that these two private routines are called by hl/tools/h5watch. + * Have considered the following options: + * 1) Repeat the coding in both H5LD.c and h5watch + * 2) Make these public routines + * 3) Break the rule "to avoid tools calling private routines in the library" + * #1: not good for maintenance + * #2: these two routines are too specific to be made as public routines + * Decide to do #3 at this point of time after some discussion. + */ +void H5LD_clean_vector(H5LD_memb_t *listv[]); +int H5LD_construct_vector(char *fields, H5LD_memb_t *listv[], hid_t par_tid); + +#endif diff --git a/hl/src/H5LDpublic.h b/hl/src/H5LDpublic.h new file mode 100644 index 0000000..a3da126 --- /dev/null +++ b/hl/src/H5LDpublic.h @@ -0,0 +1,32 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _H5LDpublic_H +#define _H5LDpublic_H + +#ifdef __cplusplus +extern "C" { +#endif + +H5_HLDLL herr_t H5LDget_dset_dims(hid_t did, hsize_t *cur_dims); +H5_HLDLL size_t H5LDget_dset_type_size(hid_t did, const char *fields); +H5_HLDLL herr_t H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, void *buf); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/hl/src/Makefile.am b/hl/src/Makefile.am index 0eecbbb..08a8e4a 100644 --- a/hl/src/Makefile.am +++ b/hl/src/Makefile.am @@ -30,9 +30,9 @@ lib_LTLIBRARIES=libhdf5_hl.la # Add libtool numbers to the HDF5 hl library (from config/lt_vers.am) libhdf5_hl_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) $(AM_LDFLAGS) -libhdf5_hl_la_SOURCES=H5DS.c H5IM.c H5LT.c H5LTanalyze.c H5LTparse.c H5PT.c H5TB.c +libhdf5_hl_la_SOURCES=H5DS.c H5IM.c H5LT.c H5LTanalyze.c H5LTparse.c H5PT.c H5TB.c H5LD.c # Public header files (to be installed) -include_HEADERS=hdf5_hl.h H5IMpublic.h H5LTpublic.h H5TBpublic.h H5DSpublic.h H5PTpublic.h +include_HEADERS=hdf5_hl.h H5IMpublic.h H5LTpublic.h H5TBpublic.h H5DSpublic.h H5PTpublic.h H5LDpublic.h include $(top_srcdir)/config/conclude.am diff --git a/hl/src/Makefile.in b/hl/src/Makefile.in index 2e04858..1254154 100644 --- a/hl/src/Makefile.in +++ b/hl/src/Makefile.in @@ -91,7 +91,7 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" LTLIBRARIES = $(lib_LTLIBRARIES) libhdf5_hl_la_LIBADD = am_libhdf5_hl_la_OBJECTS = H5DS.lo H5IM.lo H5LT.lo H5LTanalyze.lo \ - H5LTparse.lo H5PT.lo H5TB.lo + H5LTparse.lo H5PT.lo H5TB.lo H5LD.lo libhdf5_hl_la_OBJECTS = $(am_libhdf5_hl_la_OBJECTS) libhdf5_hl_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -403,10 +403,10 @@ lib_LTLIBRARIES = libhdf5_hl.la # Add libtool numbers to the HDF5 hl library (from config/lt_vers.am) libhdf5_hl_la_LDFLAGS = -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) $(AM_LDFLAGS) -libhdf5_hl_la_SOURCES = H5DS.c H5IM.c H5LT.c H5LTanalyze.c H5LTparse.c H5PT.c H5TB.c +libhdf5_hl_la_SOURCES = H5DS.c H5IM.c H5LT.c H5LTanalyze.c H5LTparse.c H5PT.c H5TB.c H5LD.c # Public header files (to be installed) -include_HEADERS = hdf5_hl.h H5IMpublic.h H5LTpublic.h H5TBpublic.h H5DSpublic.h H5PTpublic.h +include_HEADERS = hdf5_hl.h H5IMpublic.h H5LTpublic.h H5TBpublic.h H5DSpublic.h H5PTpublic.h H5LDpublic.h # Automake needs to be taught how to build lib, progs, and tests targets. # These will be filled in automatically for the most part (e.g., @@ -499,6 +499,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5DS.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5IM.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5LD.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5LT.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5LTanalyze.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5LTparse.Plo@am__quote@ diff --git a/hl/src/hdf5_hl.h b/hl/src/hdf5_hl.h index 0fff932..3b3a2a0 100644 --- a/hl/src/hdf5_hl.h +++ b/hl/src/hdf5_hl.h @@ -27,6 +27,7 @@ #include "H5IMpublic.h" /* image */ #include "H5TBpublic.h" /* table */ #include "H5PTpublic.h" /* table */ +#include "H5LDpublic.h" /* lite dataset */ #endif /*H5_INCLUDE_HL*/ diff --git a/hl/test/Makefile.am b/hl/test/Makefile.am index 86e3318..013db18 100644 --- a/hl/test/Makefile.am +++ b/hl/test/Makefile.am @@ -1,4 +1,3 @@ -# # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. # All rights reserved. @@ -24,20 +23,25 @@ include $(top_srcdir)/config/commence.am # Add include directories to C preprocessor flags AM_CPPFLAGS+=-I. -I$(srcdir) -I$(top_builddir)/src -I$(top_srcdir)/src -I$(top_builddir)/test -I$(top_srcdir)/test -I$(top_srcdir)/hl/src +# Test script +TEST_SCRIPT = test_ld.sh +check_SCRIPTS = $(TEST_SCRIPT) +SCRIPT_DEPEND = ld_monitor$(EXEEXT) ld_extend$(EXEEXT) + # The tests depend on the hdf5, hdf5 test, and hdf5_hl libraries LDADD=$(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) # Test programs. These are our main targets. They should be listed in the # order to be executed, generally most specific tests to least specific tests. -TEST_PROG=test_lite test_image test_table test_ds test_packet -check_PROGRAMS=$(TEST_PROG) +TEST_PROG=test_lite test_image test_table test_ds test_packet test_ld +check_PROGRAMS=$(TEST_PROG) ld_monitor ld_extend # These programs generate test files for the tests. They don't need to be # compiled every time we want to test the library. However, putting # them in a conditional causes automake to generate rules so that they # can be built by hand. They can also be built by specifying # --enable-build-all at configure time. -BUILD_ALL_PROGS=gen_test_ds +BUILD_ALL_PROGS=gen_test_ds gen_test_ld if BUILD_ALL_CONDITIONAL noinst_PROGRAMS=$(BUILD_ALL_PROGS) @@ -46,6 +50,7 @@ endif # Temporary files. These files are the ones created by running `make test'. CHECK_CLEANFILES+=combine_tables[1-2].h5 test_ds[1-9].h5 test_image[1-3].h5 \ test_lite[1-2].h5 test_table.h5 test_packet_table.h5 \ - test_packet_compress.h5 test_detach.h5 + test_packet_compress.h5 test_detach.h5 test_ld.h5 +DISTCLEANFILES=test_ld.sh include $(top_srcdir)/config/conclude.am diff --git a/hl/test/Makefile.in b/hl/test/Makefile.in index 4e639a6..31e1cd5 100644 --- a/hl/test/Makefile.in +++ b/hl/test/Makefile.in @@ -15,7 +15,6 @@ @SET_MAKE@ -# # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. # All rights reserved. @@ -54,11 +53,13 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ DIST_COMMON = $(srcdir)/H5srcdir_str.h.in $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(top_srcdir)/config/commence.am \ + $(srcdir)/Makefile.in $(srcdir)/test_ld.sh.in \ + $(top_srcdir)/config/commence.am \ $(top_srcdir)/config/conclude.am COPYING -check_PROGRAMS = $(am__EXEEXT_1) +check_PROGRAMS = $(am__EXEEXT_1) ld_monitor$(EXEEXT) \ + ld_extend$(EXEEXT) @BUILD_ALL_CONDITIONAL_TRUE@noinst_PROGRAMS = $(am__EXEEXT_2) -TESTS = $(check_PROGRAMS) +TESTS = $(check_PROGRAMS) $(check_SCRIPTS) subdir = hl/test ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in @@ -66,16 +67,29 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs CONFIG_HEADER = $(top_builddir)/src/H5config.h -CONFIG_CLEAN_FILES = H5srcdir_str.h +CONFIG_CLEAN_FILES = H5srcdir_str.h test_ld.sh CONFIG_CLEAN_VPATH_FILES = am__EXEEXT_1 = test_lite$(EXEEXT) test_image$(EXEEXT) \ - test_table$(EXEEXT) test_ds$(EXEEXT) test_packet$(EXEEXT) -am__EXEEXT_2 = gen_test_ds$(EXEEXT) + test_table$(EXEEXT) test_ds$(EXEEXT) test_packet$(EXEEXT) \ + test_ld$(EXEEXT) +am__EXEEXT_2 = gen_test_ds$(EXEEXT) gen_test_ld$(EXEEXT) PROGRAMS = $(noinst_PROGRAMS) gen_test_ds_SOURCES = gen_test_ds.c gen_test_ds_OBJECTS = gen_test_ds.$(OBJEXT) gen_test_ds_LDADD = $(LDADD) gen_test_ds_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) +gen_test_ld_SOURCES = gen_test_ld.c +gen_test_ld_OBJECTS = gen_test_ld.$(OBJEXT) +gen_test_ld_LDADD = $(LDADD) +gen_test_ld_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) +ld_extend_SOURCES = ld_extend.c +ld_extend_OBJECTS = ld_extend.$(OBJEXT) +ld_extend_LDADD = $(LDADD) +ld_extend_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) +ld_monitor_SOURCES = ld_monitor.c +ld_monitor_OBJECTS = ld_monitor.$(OBJEXT) +ld_monitor_LDADD = $(LDADD) +ld_monitor_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) test_ds_SOURCES = test_ds.c test_ds_OBJECTS = test_ds.$(OBJEXT) test_ds_LDADD = $(LDADD) @@ -84,6 +98,10 @@ test_image_SOURCES = test_image.c test_image_OBJECTS = test_image.$(OBJEXT) test_image_LDADD = $(LDADD) test_image_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) +test_ld_SOURCES = test_ld.c +test_ld_OBJECTS = test_ld.$(OBJEXT) +test_ld_LDADD = $(LDADD) +test_ld_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) test_lite_SOURCES = test_lite.c test_lite_OBJECTS = test_lite.$(OBJEXT) test_lite_LDADD = $(LDADD) @@ -109,10 +127,12 @@ CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = gen_test_ds.c test_ds.c test_image.c test_lite.c \ - test_packet.c test_table.c -DIST_SOURCES = gen_test_ds.c test_ds.c test_image.c test_lite.c \ - test_packet.c test_table.c +SOURCES = gen_test_ds.c gen_test_ld.c ld_extend.c ld_monitor.c \ + test_ds.c test_image.c test_ld.c test_lite.c test_packet.c \ + test_table.c +DIST_SOURCES = gen_test_ds.c gen_test_ld.c ld_extend.c ld_monitor.c \ + test_ds.c test_image.c test_ld.c test_lite.c test_packet.c \ + test_table.c ETAGS = etags CTAGS = ctags am__tty_colors = \ @@ -399,21 +419,27 @@ TRACE = perl $(top_srcdir)/bin/trace CHECK_CLEANFILES = *.chkexe *.chklog *.clog combine_tables[1-2].h5 \ test_ds[1-9].h5 test_image[1-3].h5 test_lite[1-2].h5 \ test_table.h5 test_packet_table.h5 test_packet_compress.h5 \ - test_detach.h5 + test_detach.h5 test_ld.h5 + +# Test script +TEST_SCRIPT = test_ld.sh +check_SCRIPTS = $(TEST_SCRIPT) +SCRIPT_DEPEND = ld_monitor$(EXEEXT) ld_extend$(EXEEXT) # The tests depend on the hdf5, hdf5 test, and hdf5_hl libraries LDADD = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) # Test programs. These are our main targets. They should be listed in the # order to be executed, generally most specific tests to least specific tests. -TEST_PROG = test_lite test_image test_table test_ds test_packet +TEST_PROG = test_lite test_image test_table test_ds test_packet test_ld # These programs generate test files for the tests. They don't need to be # compiled every time we want to test the library. However, putting # them in a conditional causes automake to generate rules so that they # can be built by hand. They can also be built by specifying # --enable-build-all at configure time. -BUILD_ALL_PROGS = gen_test_ds +BUILD_ALL_PROGS = gen_test_ds gen_test_ld +DISTCLEANFILES = test_ld.sh # Automake needs to be taught how to build lib, progs, and tests targets. # These will be filled in automatically for the most part (e.g., @@ -466,6 +492,8 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): H5srcdir_str.h: $(top_builddir)/config.status $(srcdir)/H5srcdir_str.h.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +test_ld.sh: $(top_builddir)/config.status $(srcdir)/test_ld.sh.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ @@ -487,12 +515,24 @@ clean-noinstPROGRAMS: gen_test_ds$(EXEEXT): $(gen_test_ds_OBJECTS) $(gen_test_ds_DEPENDENCIES) @rm -f gen_test_ds$(EXEEXT) $(LINK) $(gen_test_ds_OBJECTS) $(gen_test_ds_LDADD) $(LIBS) +gen_test_ld$(EXEEXT): $(gen_test_ld_OBJECTS) $(gen_test_ld_DEPENDENCIES) + @rm -f gen_test_ld$(EXEEXT) + $(LINK) $(gen_test_ld_OBJECTS) $(gen_test_ld_LDADD) $(LIBS) +ld_extend$(EXEEXT): $(ld_extend_OBJECTS) $(ld_extend_DEPENDENCIES) + @rm -f ld_extend$(EXEEXT) + $(LINK) $(ld_extend_OBJECTS) $(ld_extend_LDADD) $(LIBS) +ld_monitor$(EXEEXT): $(ld_monitor_OBJECTS) $(ld_monitor_DEPENDENCIES) + @rm -f ld_monitor$(EXEEXT) + $(LINK) $(ld_monitor_OBJECTS) $(ld_monitor_LDADD) $(LIBS) test_ds$(EXEEXT): $(test_ds_OBJECTS) $(test_ds_DEPENDENCIES) @rm -f test_ds$(EXEEXT) $(LINK) $(test_ds_OBJECTS) $(test_ds_LDADD) $(LIBS) test_image$(EXEEXT): $(test_image_OBJECTS) $(test_image_DEPENDENCIES) @rm -f test_image$(EXEEXT) $(LINK) $(test_image_OBJECTS) $(test_image_LDADD) $(LIBS) +test_ld$(EXEEXT): $(test_ld_OBJECTS) $(test_ld_DEPENDENCIES) + @rm -f test_ld$(EXEEXT) + $(LINK) $(test_ld_OBJECTS) $(test_ld_LDADD) $(LIBS) test_lite$(EXEEXT): $(test_lite_OBJECTS) $(test_lite_DEPENDENCIES) @rm -f test_lite$(EXEEXT) $(LINK) $(test_lite_OBJECTS) $(test_lite_LDADD) $(LIBS) @@ -510,8 +550,12 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_test_ds.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_test_ld.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ld_extend.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ld_monitor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_ds.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_image.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_ld.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_lite.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_packet.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_table.Po@am__quote@ @@ -626,7 +670,7 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(check_SCRIPTS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(PROGRAMS) all-local @@ -652,6 +696,7 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" diff --git a/hl/test/gen_test_ld.c b/hl/test/gen_test_ld.c new file mode 100644 index 0000000..bf130df --- /dev/null +++ b/hl/test/gen_test_ld.c @@ -0,0 +1,360 @@ +#include "hdf5.h" +#include "H5LDprivate.h" +#include +#include +#include +#include + +/* + * WATCH.h5: file with various types of datasets for testing-- + * + * The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting: + * DSET_ONE: one-dimensional dataset + * DSET_TWO: two-dimensional dataset + * DSET_CMPD: one-dimensional dataset with compound type + * DSET_CMPD_ESC: one-dimensional dataset with compound type and member names with + * escape/separator characters + * DSET_CMPD_TWO: two-dimensional dataset with compound type + * + * The following datasets are one-dimensional, chunked, max. dimension setting: + * DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY + * DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE + * + * The following datasets are one-dimensional: + * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE + * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR + */ +#define ONE_DIMS0 10 +#define MAX_ONE_DIMS0 100 + +#define DSET_ONE "DSET_ONE" +#define DSET_NONE "DSET_NONE" +#define DSET_NOMAX "DSET_NOMAX" +#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" +#define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" +#define DSET_NULL "DSET_NULL" +#define DSET_SCALAR "DSET_SCALAR" + +#define TWO_DIMS0 4 +#define TWO_DIMS1 10 +#define MAX_TWO_DIMS0 60 +#define MAX_TWO_DIMS1 100 + +#define DSET_TWO "DSET_TWO" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" + +#define CHUNK_SIZE 2 + +#define FILE "test_ld.h5" + +/* Data structures for datasets with compound types */ +typedef struct sub22_t { + unsigned int a; + unsigned int b; + unsigned int c; +} sub22_t; + +typedef struct sub2_t { + unsigned int a; + sub22_t b; + unsigned int c; +} sub2_t; + +typedef struct sub4_t { + unsigned int a; + unsigned int b; +} sub4_t; + +typedef struct set_t { + unsigned int field1; + sub2_t field2; + double field3; + sub4_t field4; +} set_t; + +/* + ************************************************************************************** + * + * Create a dataset with the given input parameters + * Write to the dataset with the given "data" + * + ************************************************************************************** + */ +static int +generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, hsize_t *maxdims, hid_t dtid, void *data) +{ + hid_t dcpl; /* Dataset creation property */ + hid_t did; /* Dataset id */ + hid_t sid; /* Dataspace id */ + int i; /* Local index variable */ + hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */ + + /* Create the dataspace */ + if((sid = H5Screate_simple(ndims, dims, maxdims)) < 0) + goto done; + + /* Set up dataset's creation properties */ + if(!HDstrcmp(dname, DSET_NONE)) + dcpl = H5P_DEFAULT; + else { + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto done; + for(i = 0; i < ndims; i++) + chunk_dims[i] = CHUNK_SIZE; + if(H5Pset_chunk(dcpl, ndims, chunk_dims) < 0) + goto done; + } + + if(!HDstrcmp(dname, DSET_ALLOC_LATE)) { + if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) + goto done; + } else if(!HDstrcmp(dname, DSET_ALLOC_EARLY)) { + if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + goto done; + } + + /* Create the dataset */ + if((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto done; + + /* Write to the dataset */ + if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + goto done; + + /* Closing */ + if(H5Pclose(dcpl) < 0) goto done; + if(H5Sclose(sid) < 0) goto done; + if(H5Dclose(did) < 0) goto done; + + return(SUCCEED); + +done: + H5E_BEGIN_TRY + H5Sclose(sid); + H5Pclose(dcpl); + H5Dclose(did); + H5E_END_TRY + + return(FAIL); +} /* generate_dset() */ + +int +main(void) +{ + hid_t fid; /* File id */ + hsize_t cur_dims[1]; /* Dimension sizes */ + hsize_t max_dims[1]; /* Maximum dimension sizes */ + hsize_t cur2_dims[2]; /* Current dimension sizes */ + hsize_t max2_dims[2]; /* Maximum dimension sizes */ + hid_t set_tid, esc_set_tid; /* Compound type id */ + hid_t sub22_tid; /* Compound type id */ + hid_t sub2_tid, esc_sub2_tid; /* Compound type id */ + hid_t sub4_tid, esc_sub4_tid; /* Compound type id */ + hid_t null_did, null_sid; /* H5S_NULL dataset & dataspace ids */ + hid_t scalar_did, scalar_sid; /* H5S_SCALAR dataset & dataspace ids */ + int one_data[ONE_DIMS0]; /* Buffer for data */ + int two_data[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data */ + set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */ + set_t two_cbuf[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data with compound type */ + int i; /* Local index variable */ + + /* Create a file */ + if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto done; + + /* Initialization for one-dimensional dataset */ + cur_dims[0] = ONE_DIMS0; + max_dims[0] = MAX_ONE_DIMS0; + for(i = 0; i < ONE_DIMS0; i++) + one_data[i] = i; + + /* Generate DSET_ONE, DSET_NONE, DSET_NOMAX, DSET_ALLOC_LATE, DSET_EARLY */ + if(generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + if(generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + goto done; + if(generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + goto done; + if(generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + if(generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + + /* Initialization for two-dimensional dataset */ + cur2_dims[0] = TWO_DIMS0; + cur2_dims[1] = TWO_DIMS1; + max2_dims[0] = MAX_TWO_DIMS0; + max2_dims[1] = MAX_TWO_DIMS1; + + for(i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) + two_data[i] = i; + + /* Generate DSET_TWO */ + if(generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0) + goto done; + + /* Initialization for one-dimensional compound typed dataset */ + cur_dims[0] = ONE_DIMS0; + max_dims[0] = MAX_ONE_DIMS0; + + for (i = 0; i < ONE_DIMS0; i++) { + one_cbuf[i].field1 = 1; + one_cbuf[i].field2.a = 2; + one_cbuf[i].field2.c = 4; + one_cbuf[i].field2.b.a = 20; + one_cbuf[i].field2.b.b = 40; + one_cbuf[i].field2.b.c = 80; + one_cbuf[i].field3 = 3.0; + one_cbuf[i].field4.a = 4; + one_cbuf[i].field4.b = 8; + } + + /* Create the compound type */ + if((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0) + goto done; + if(H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + goto done; + if(H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0) + goto done; + if(H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + goto done; + if(H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + goto done; + + if((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + goto done; + if(H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0) + goto done; + if(H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + goto done; + if(H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0) + goto done; + + /* Create the compound type with escape/separator characters */ + if((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + goto done; + if(H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0) + goto done; + if(H5Tinsert(esc_sub2_tid, "\\c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + goto done; + if(H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + goto done; + + if((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + goto done; + if(H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0) + goto done; + if(H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + goto done; + if(H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0) + goto done; + + /* Generate DSET_CMPD, DSET_CMPD_ESC */ + if(generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0) + goto done; + if(generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0) + goto done; + + /* Initialization for two-dimensional compound typed dataset */ + cur2_dims[0] = TWO_DIMS0; + cur2_dims[1] = TWO_DIMS1; + max2_dims[0] = MAX_TWO_DIMS0; + max2_dims[0] = MAX_TWO_DIMS1; + + for (i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) { + two_cbuf[i].field1 = 1; + two_cbuf[i].field2.a = 2; + two_cbuf[i].field2.c = 4; + two_cbuf[i].field2.b.a = 20; + two_cbuf[i].field2.b.b = 40; + two_cbuf[i].field2.b.c = 80; + two_cbuf[i].field3 = 3.0; + two_cbuf[i].field4.a = 4; + two_cbuf[i].field4.b = 8; + } + + /* Generate DSET_CMPD_TWO */ + if(generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0) + goto done; + + /* Create NULL dataspace */ + if((null_sid = H5Screate(H5S_NULL)) < 0) + goto done; + + /* Create the NULL dataset */ + if((null_did = H5Dcreate2(fid, DSET_NULL, H5T_NATIVE_UINT, null_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto done; + + /* Create SCALAR dataspace */ + if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) + goto done; + + /* Create the SCALAR dataset */ + if((scalar_did = H5Dcreate2(fid, DSET_SCALAR, H5T_NATIVE_INT, scalar_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto done; + + /* Closing */ + if(H5Dclose(scalar_did) < 0) goto done; + if(H5Sclose(scalar_sid) < 0) goto done; + + if(H5Dclose(null_did) < 0) goto done; + if(H5Sclose(null_sid) < 0) goto done; + + if(H5Tclose(sub22_tid) < 0) goto done; + if(H5Tclose(sub2_tid) < 0) goto done; + if(H5Tclose(sub4_tid) < 0) goto done; + if(H5Tclose(set_tid) < 0) goto done; + if(H5Tclose(esc_sub2_tid) < 0) goto done; + if(H5Tclose(esc_sub4_tid) < 0) goto done; + if(H5Tclose(esc_set_tid) < 0) goto done; + if(H5Fclose(fid) < 0) goto done; + + exit(EXIT_SUCCESS); + +done: + H5E_BEGIN_TRY + H5Tclose(sub22_tid); + H5Tclose(sub2_tid); + H5Tclose(sub4_tid); + H5Tclose(set_tid); + H5Tclose(esc_sub2_tid); + H5Tclose(esc_sub4_tid); + H5Tclose(esc_set_tid); + + H5Dclose(null_did); + H5Sclose(null_sid); + H5Dclose(scalar_did); + H5Sclose(scalar_sid); + + H5Fclose(fid); + H5E_END_TRY + + exit(EXIT_FAILURE); +} /* main() */ diff --git a/hl/test/ld_extend.c b/hl/test/ld_extend.c new file mode 100644 index 0000000..3ddd883 --- /dev/null +++ b/hl/test/ld_extend.c @@ -0,0 +1,151 @@ +#include "H5HLprivate2.h" +#include +#include +#include +#include +#include + +/* Size of data buffer */ +#define TEST_BUF_SIZE 100 + +/* + * Test variations (incremental) for one-dimensional dataset: + * Varies from 10->13->12->12->1->3 + */ +#define ONE_NTESTS 5 +int one_tests[ONE_NTESTS] = {3, -1, 0, -11, 2}; + +/* + * Test variations (incremental) for two-dimensional dataset: + * Varies from {4,10}->{6,12}->{8,1}->{10,1}-> + * {3,3}->{2,2}->{1,2}-> + * {1,4}->{1,3}->{1,3} + */ +#define TWO_NTESTS 9 +int two_tests[TWO_NTESTS][2] = { {2, 2}, {2, -11}, {2, 0}, + {-7, 2}, {-1, -1}, {-1, 0}, + {0, 2}, {0, -1}, {0, 0} + }; + +static int extend_dset(const char *file, char *dname); + +/* + * Extend the specified dataset in the file with ld_monitor.c monitoring + * the dataset on the other end: + * + * 1) Extend the dataset according to the variations: ONE_NTESTS, TWO_NTESTS + * 2) Write to the dataset (currently, only for integer dataset) + * 3) Flush the dataset + */ +static int +extend_dset(const char *file, char *dname) +{ + hid_t fid; /* file id */ + hid_t did; /* dataset id */ + hid_t dtype; /* dataset's datatype */ + hid_t sid; /* dataspace id */ + int i, j, k; /* local index variable */ + int ndims; /* number of dimensions */ + int buf[TEST_BUF_SIZE]; /* buffer for data */ + hsize_t cur_dims[2]; /* current dimension sizes */ + hsize_t ext_dims[2]; /* new dimension sizes after extension */ + + /* Open the file */ + if((fid = H5Fopen(file, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + goto done; + + /* Open the dataset */ + if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + goto done; + + /* Get the dataset's data space */ + if((sid = H5Dget_space(did)) < 0) + goto done; + + /* Get the # of dimensions for the dataset */ + if((ndims = H5Sget_simple_extent_ndims(sid)) < 0) + goto done; + + /* Initialize data written to the dataset */ + HDmemset(buf, 0, sizeof(buf)); + for(k = 0; k < TEST_BUF_SIZE; k++) + buf[k] = k; + + /* Loop through different variations of extending the dataset */ + for(i = 0; i < (ndims == 1 ? ONE_NTESTS: TWO_NTESTS); i++) { + + sleep(2); + + /* Get the dataset's current dimension sizes */ + if(H5LDget_dset_dims(did, cur_dims) < 0) + goto done; + + /* Set up the new extended dimension sizes */ + for(j = 0; j < ndims; j++) + ext_dims[j] = cur_dims[j] + (ndims == 1 ? (hsize_t)one_tests[i] : (hsize_t)two_tests[i][j]); + + /* Extend the dataset */ + if(H5Dset_extent(did, ext_dims) < 0) + goto done; + + /* Get the dataset's data type */ + if((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + goto done; + + /* Write to the whole dataset after extension */ + if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto done; + + /* Flush the data */ + if(H5Dflush(did) < 0) + goto done; + + } /* end for ONE_NTESTS or TWO_NTESTS */ + + /* Closing */ + if(H5Tclose(dtype) < 0) goto done; + if(H5Sclose(sid) < 0) goto done; + if(H5Dclose(did) < 0) goto done; + if(H5Fclose(fid) < 0) goto done; + + return(0); + +done: + H5E_BEGIN_TRY + H5Tclose(dtype); + H5Sclose(sid); + H5Dclose(did); + H5Fclose(fid); + H5E_END_TRY + + return(-1); +} /* extend_dset() */ + + +/* Usage: extend_dset xx.h5 dname */ +int +main(int argc, const char *argv[]) +{ + char *dname = NULL; /* dataset name */ + char *fname = NULL; /* file name */ + + if(argc != 3) { + fprintf(stderr, "Should have file name and dataset name to be extended...\n"); + goto done; + } + + /* Get the file and dataset names to be extended */ + fname = HDstrdup(argv[1]); + dname = HDstrdup(argv[2]); + + /* Extend the specified dataset in the file */ + if(extend_dset(fname, dname) < 0) + goto done; + + exit(EXIT_SUCCESS); + +done: + if(dname) HDfree(dname); + if(fname) HDfree(fname); + exit(EXIT_FAILURE); +} /* main() */ diff --git a/hl/test/ld_monitor.c b/hl/test/ld_monitor.c new file mode 100644 index 0000000..7b90715 --- /dev/null +++ b/hl/test/ld_monitor.c @@ -0,0 +1,148 @@ +#include "H5HLprivate2.h" +#include +#include +#include +#include +#include + +#define TEST_BUF_SIZE 100 + +/* + * Monitor the specified dataset in the file while ld_extend.c extending + * and writing to the dataset on the other end: + * + * 1) Retrieve the dataset's current dimension sizes + * 2) If there are changes in dimension sizes: + * print the dimension sizes + * retrieve the appended data and print them + */ +static int +monitor_dset(const char *fname, char *dname) +{ + hid_t fid; /* dataset id */ + hid_t did; /* dataset id */ + hid_t sid; /* dataspace id */ + int ndims; /* # of dimensions in the dataspace */ + int i, u; /* local index variable */ + hsize_t cur_dims[H5S_MAX_RANK]; /* current dimension sizes */ + hsize_t prev_dims[H5S_MAX_RANK]; /* previous dimension sizes */ + int buf[TEST_BUF_SIZE]; /* Buffer for data */ + herr_t ret_value = 0; /* return value */ + + /* Open the file with SWMR */ + if((fid = H5Fopen(fname, H5F_ACC_SWMR_READ, H5P_DEFAULT)) < 0) + goto done; + + HDfprintf(stdout, "Monitoring dataset %s...\n", dname); + + /* Open the dataset for minitoring */ + if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) { + HDfprintf(stdout, "error in opening dataset \"%s\"\n", dname); + ret_value = -1; + goto done; + } + + /* Get the dataset's data space */ + if((sid = H5Dget_space(did)) < 0) { + HDfprintf(stdout, "error in getting dataspace id for dataset \"%s\"\n", dname); + ret_value = -1; + goto done; + } + + /* Get the dataset's dimension sizes */ + if((ndims = H5Sget_simple_extent_dims(sid, prev_dims, NULL)) < 0) { + HDfprintf(stdout, "unable to get dimensions sizes for \"%s\"\n", dname); + ret_value = -1; + goto done; + } + + /* Monitor the dataset for changes */ + while(1) { + + /* Refresh the dataset */ + if(H5Drefresh(did) < 0) { + ret_value = -1; + goto done; + } + + /* Get the dataset's current dimension sizes */ + if(H5LDget_dset_dims(did, cur_dims) < 0) { + HDfprintf(stdout, "unable to get dimension sizes for \"%s\"\n", dname); + ret_value = -1; + goto done; + } + + /* Check for changes in dimension sizes */ + for(u = 0; u < ndims; u++) { + if(cur_dims[u] != prev_dims[u]) + break; + } + + /* Printing only when there are changes */ + if(u < ndims) { + /* Print the current dimension sizes */ + HDfprintf(stdout, "\n"); + for(i = 0; i < ndims; i++) + HDfprintf(stdout, "%d ", (int)cur_dims[i]); + HDfprintf(stdout, "\n"); + + /* Get data appended to the dataset and print the data */ + HDmemset(buf, 0, sizeof(buf)); + if(H5LDget_dset_elmts(did, prev_dims, cur_dims, NULL, buf) >= 0) { + + for(i = 0; i < TEST_BUF_SIZE; i++) { + if(i % 10) + HDfprintf(stdout, "%d ", buf[i]); + else + HDfprintf(stdout, "\n%d ", buf[i]); + } + HDfprintf(stdout, "\n"); + } + + /* Flush the output to stdout */ + HDfflush(stdout); + /* Update the dimension sizes */ + HDmemcpy(prev_dims, cur_dims, ndims * sizeof(hsize_t)); + } + + /* Sleep before next monitor */ + sleep(1); + } /* end while */ + +done: + /* Closing */ + H5E_BEGIN_TRY + H5Sclose(sid); + H5Dclose(did); + H5E_END_TRY + + return(ret_value); +} /* monitor_dset() */ + +/* usage: monitor xx.h5 dname */ +int +main(int argc, const char *argv[]) +{ + char *dname = NULL; /* dataset name */ + char *fname = NULL; /* file name */ + + if(argc != 3) { + HDfprintf(stderr, "Should have file name and dataset name to be monitored...\n"); + goto done; + } + + /* Get the file name and dataset name to be extended */ + fname = strdup(argv[1]); + dname = strdup(argv[2]); + + /* only integer dataset */ + if(monitor_dset(fname, dname) < 0) + goto done; + + exit(EXIT_SUCCESS); + +done: + if(dname) free(dname); + if(fname) free(fname); + exit(EXIT_FAILURE); +} diff --git a/hl/test/test_ld.c b/hl/test/test_ld.c new file mode 100644 index 0000000..3a282c8 --- /dev/null +++ b/hl/test/test_ld.c @@ -0,0 +1,1397 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* Copyright by The HDF Group. * +* Copyright by the Board of Trustees of the University of Illinois. * +* All rights reserved. * +* * +* This file is part of HDF5. The full HDF5 copyright notice, including * +* terms governing use, modification, and redistribution, is contained in * +* the files COPYING and Copyright.html. COPYING can be found at the root * +* of the source code distribution tree; Copyright.html can be found at the * +* root level of an installed copy of the electronic HDF5 document set and * +* is linked from the top-level documents page. It can also be found at * +* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +* access to either file, you may request a copy from help@hdfgroup.org. * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include +#include +#include +#include +#include +#include "h5hltest.h" +#include "H5srcdir.h" +#include "H5LDpublic.h" + +/* File name */ +#define FILE "test_ld.h5" +/* Copied file name */ +#define COPY_FILENAME "COPY_test_ld.h5" + +/* Dataset names */ +#define DSET_ONE "DSET_ONE" +#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" +#define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" +#define DSET_TWO "DSET_TWO" +#define TWO_DIM_1 4 +#define TWO_DIM_2 10 +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" +#define DSET_NULL "DSET_NULL" +#define DSET_SCALAR "DSET_SCALAR" + +/* Size of data buffer */ +#define TEST_BUF_SIZE 100 + +/* Temporary Buffer size */ +#define READ_BUF_SIZE 4096 + +/* Selected compound field members for testing */ +#define VALID_FIELDS1 "field1,field2.a,field3,field4" /* TEMPORORAY */ +#define VALID_FIELDS2 "field2.b.a,field2.c,field4.b" + +#define INVALID_FIELDS1 "field2.k.a,field2.c,field4.k" +#define INVALID_FIELDS2 "field2.b.a,field2.c,field4.b." +#define INVALID_FIELDS3 "field2.b.a,,field2.c,field4.b" + +#define VALID_ESC_FIELDS1 "field\\,1,field2\\..\\.a,field\\\\3,field4\\," +#define VALID_ESC_FIELDS2 "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," + +#define INVALID_ESC_FIELDS1 "field2\\..\\,k.a,field2\\..\\\\c,field4\\,.k\\," +#define INVALID_ESC_FIELDS2 "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\,." +#define INVALID_ESC_FIELDS3 "field2\\..\\,,b.a,field2\\..\\\\c,field4\\,.b\\," + +/* + * Test variations (retained original) for one-dimensional dataset: + * Varies from 10->13; 10->9, 10->10, 10->1, 10->11 + */ +#define ONE_NTESTS 5 +int one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1}; + +/* + * Test variations (retained original) for two-dimensional dataset: + * Varies from {4,10}->{6,12}; {4,10}->{6,9}; {4,10}->{6,10}; + * {4,10}->{3,12}; {4,10}->{3,9}; {4,10}->{3,10}; + * {4,10}->{4,12}; {4,10}->{4,9}; {4,10}->{4,10} + */ +#define TWO_NTESTS 9 +int two_tests[TWO_NTESTS][2] = { {2,2}, {2,-1}, {2,0}, + {-1,2}, {-1,-1}, {-1,0}, + {0,2}, {0,-1}, {0,0} }; + + +/* Verify that the two input values are the same */ +#define VERIFY_EQUAL(_x, _y) \ +{ \ + long __x = (long)_x, __y = (long)_y; \ + if(__x != __y) TEST_ERROR \ +} + +/* Copy srcfile to dstfile */ +#define COPY_FILE(srcfile, dstfile) \ +{ \ + int src_fd = (-1); /* Descriptor for input file */ \ + int dst_fd = (-1); /* Descriptor for output file */ \ + ssize_t nread; /* Number of bytes read in */ \ + char tmp_buf[READ_BUF_SIZE];/* Temporary buffer */ \ + \ + /* Open srcfile */ \ + if((src_fd = HDopen(srcfile, O_RDONLY, 0666)) < 0) \ + TEST_ERROR; \ + \ + /* Open dstfile */ \ + if((dst_fd = HDopen(dstfile, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) \ + TEST_ERROR; \ + \ + /* Copy data from srcfile to dstfile */ \ + while((nread = HDread(src_fd, tmp_buf, (size_t)READ_BUF_SIZE)) > 0) \ + HDwrite(dst_fd, tmp_buf, (size_t)nread); \ + \ + /* Close files */ \ + if(HDclose(src_fd) < 0) TEST_ERROR; \ + if(HDclose(dst_fd) < 0) TEST_ERROR; \ +} + +/* Macros for verifying compound fields */ +/* Verify all fields */ +#define VERIFY_ELMTS_ALL(ent1, ent2) { \ + VERIFY_EQUAL(ent1.field1, ent2.field1); \ + VERIFY_EQUAL(ent1.field2.a, ent2.field2.a); \ + VERIFY_EQUAL(ent1.field2.b.a, ent2.field2.b.a); \ + VERIFY_EQUAL(ent1.field2.b.b, ent2.field2.b.b); \ + VERIFY_EQUAL(ent1.field2.b.c, ent2.field2.b.c); \ + VERIFY_EQUAL(ent1.field2.c, ent2.field2.c); \ + VERIFY_EQUAL(ent1.field3, ent2.field3); \ + VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \ +} + +/* Verify fields selected in VALID_FIELDS1 */ +#define VERIFY_ELMTS_VALID1(ent1, ent2) { \ + VERIFY_EQUAL(ent1.field1, ent2.field1); \ + VERIFY_EQUAL(ent1.field2_a, ent2.field2.a); \ + VERIFY_EQUAL(ent1.field3, ent2.field3); \ + VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \ + VERIFY_EQUAL(ent1.field4.b, ent2.field4.b); \ +} + +/* Verify fields selected in VALID_FIELDS2 */ +#define VERIFY_ELMTS_VALID2(ent1, ent2) { \ + VERIFY_EQUAL(ent1.field2_b_a, ent2.field2.b.a); \ + VERIFY_EQUAL(ent1.field2_c, ent2.field2.c); \ + VERIFY_EQUAL(ent1.field4_b, ent2.field4.b); \ +} + +/* The types of 2-dimensional dataset: DSET_TWO or DSET_CMPD_TWO */ +#define TWO_NONE 0 /* DSET_TWO */ +#define TWO_CMPD_NULL 1 /* DSET_CMPD_TWO with NULL fields */ +#define TWO_CMPD_VALID1 2 /* DSET_CMPD_TWO with VALID_FIELDS1 or VALID_ESC_FIELDS1 */ +#define TWO_CMPD_VALID2 3 /* DSET_CMPD_TWO with VALID_FIELDS2 or VALID_ESC_FIELDS2 */ + +#define VERIFY_ELMTS(type, _ldbuf, _buf) { \ + if(type == TWO_NONE) { \ + int *iibuf = (int *)_ldbuf; \ + int *ibuf = (int *)_buf; \ + \ + VERIFY_EQUAL(iibuf[k], ibuf[ind+n]) \ + } else if(type == TWO_CMPD_NULL) { \ + set_t *ccbuf = (set_t *)_ldbuf; \ + set_t *cbuf = (set_t *)_buf; \ + \ + VERIFY_ELMTS_ALL(ccbuf[k], cbuf[ind+n]) \ + } else if(type == TWO_CMPD_VALID1) { \ + test_valid_fields1 *vbuf1 = (test_valid_fields1 *)_ldbuf; \ + set_t *cbuf = (set_t *)_buf; \ + \ + VERIFY_ELMTS_VALID1(vbuf1[k], cbuf[ind+n]) \ + } else if(type == TWO_CMPD_VALID2) { \ + test_valid_fields2 *vbuf2 = (test_valid_fields2 *)_ldbuf; \ + set_t *cbuf = (set_t *)_buf; \ + \ + VERIFY_ELMTS_VALID2(vbuf2[k], cbuf[ind+n]) \ + } \ +} + +/* Tests for test_LD_elmts_pipe() */ +#define ONE_TESTS 3 +int onetests[ONE_TESTS] = {3, 9, 1}; +#define TWO_TESTS 5 +int twotests[TWO_TESTS][2] = { {2,2}, {2,-1}, {2,0}, {-1,2}, {0,2} }; + + +static herr_t test_LD_dims_params(const char *file); +static herr_t test_LD_dims(const char *file); + +static herr_t test_LD_size(const char *file); + +static herr_t test_LD_elmts_invalid(const char *file); +static herr_t test_LD_elmts_one(const char *file, const char *dname, const char *fields); +static herr_t test_LD_elmts_two(const char *file, const char *dname, const char *fields); + +static herr_t verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf); + +/* data structures for compound data type */ +typedef struct sub22_t { + int a; + int b; + int c; +} sub22_t; + +typedef struct sub2_t { + int a; + sub22_t b; + int c; +} sub2_t; + +typedef struct sub4_t { + int a; + int b; +} sub4_t; + +typedef struct set_t { + int field1; + sub2_t field2; + double field3; + sub4_t field4; +} set_t; + + +/* NOTE: + * This will fail on heiwa and amani when VALID_FIELDS1 is "field1,field3,field4" + * because of alignment problems: + * amani and heiwa - 8 byte alignment + * jam - 4 byte alignemnt + * This will need to be fixed in the libarary for H5Tget_native_type(). + */ +/* VALID_FIELDS1 "field1,field2.a,field3,field4" */ +/* VALID_ESC_FIELDS1 "field\\,1,field2\\..\\.a,field\\\\3,field4\\," */ +typedef struct test_valid_fields1 { + int field1; + int field2_a; + double field3; + sub4_t field4; +} test_valid_fields1; + +/* VALID_FIELDS2 "field2.b.a,field2.c,field4.b" */ +/* VALID_ESC_FIELDS2 "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," */ +typedef struct test_valid_fields2 { + int field2_b_a; + int field2_c; + int field4_b; +} test_valid_fields2; + +/* + ********************************************************************************* + * + * Testing for the High Level public routine: H5LDget_dset_dims() + * 1) An invalid dataset id + * 2) "DSET_ALLOC_EARLY": NULL cur_dims + * 3) "DSET_ALLOC_LATE": nonNULL cur_dims + * 4) "DSET_CMPD_TWO": nonNULL cur_dims + * 5) "DSET_NULL": nonNULL cur_dims + * 6) "DSET_SCALAR": nonNULL cur_dims + * + ********************************************************************************* + */ +static herr_t +test_LD_dims_params(const char *file) +{ + hid_t fid; /* file identifier */ + hid_t did; /* dataset identifier */ + hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */ + hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */ + herr_t ret; /* return value */ + + const char *filename = H5_get_srcdir_filename(file); + + TESTING("H5LDget_dset_dims"); + + /* Make a copy of the test file */ + COPY_FILE(filename, COPY_FILENAME) + + /* Open the copied file */ + if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* + * 1. Verify failure with negative dataset id + */ + H5E_BEGIN_TRY { + ret = H5LDget_dset_dims(-1, one_cur_dims); + } H5E_END_TRY; + VERIFY_EQUAL(ret, FAIL) + + /* + * 2. Verify failure for NULL cur_dims + */ + if((did = H5Dopen2(fid, DSET_ALLOC_EARLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + H5E_BEGIN_TRY { + ret = H5LDget_dset_dims(did, NULL); + } H5E_END_TRY; + VERIFY_EQUAL(ret, FAIL) + H5Dclose(did); + + /* + * 3. Verify for nonNULL cur_dims + */ + if((did = H5Dopen2(fid, DSET_ALLOC_LATE, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if(H5LDget_dset_dims(did, one_cur_dims) < 0) + FAIL_STACK_ERROR + VERIFY_EQUAL(one_cur_dims[0], 10) + H5Dclose(did); + + /* + * 4. Verify nonNULL cur_dims for a 2-dimensional dataset + */ + if((did = H5Dopen2(fid, DSET_CMPD_TWO, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if(H5LDget_dset_dims(did, two_cur_dims) < 0) + FAIL_STACK_ERROR + VERIFY_EQUAL(two_cur_dims[0], TWO_DIM_1) + VERIFY_EQUAL(two_cur_dims[1], TWO_DIM_2) + H5Dclose(did); + + /* + * 5. Verify nonNULL cur_dims for dataset with H5S_NULL dataspace + */ + one_cur_dims[0] = 0; + + if((did = H5Dopen2(fid, DSET_NULL, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + if(H5LDget_dset_dims(did, one_cur_dims) < 0) + FAIL_STACK_ERROR + VERIFY_EQUAL(one_cur_dims[0], 0) + H5Dclose(did); + + /* + * 6. Verify nonNULL cur_dims for dataset with H5S_SCALAR dataspace + */ + one_cur_dims[0] = 0; + + if((did = H5Dopen2(fid, DSET_SCALAR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + if(H5LDget_dset_dims(did, one_cur_dims) < 0) + FAIL_STACK_ERROR + VERIFY_EQUAL(one_cur_dims[0], 0) + H5Dclose(did); + + /* Close the file */ + if(H5Fclose(fid) < 0) + FAIL_STACK_ERROR + + /* Remove the copied file */ + HDremove(COPY_FILENAME); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(did); + H5Fclose(fid); + } H5E_END_TRY; + return(-1); + +} /* test_LD_dims_params() */ + +/* + ********************************************************************************* + * + * Testing for the High Level public routine: H5LDget_dset_dims() + * Verify that the dimension sizes retrieved via H5LDget_dset_dims() are correct + * for the following cases: + * + * DSET_ONE: one-dimensional dataset + * 1. Increase dims[0] + * 2. Decrease dims[0] + * 3. same dims[0] + * 4. Decrease dims[0] + * 5. Increase dims[0] + * + * one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1} + * Varies from 10->3; 10->9, 10->10, 10->1, 10->11 + * + * DSET_TWO: two-dimensional dataset + * 1. Increase dims[0], increase dims[1] + * 2. Increase dims[0], decrease dims[1] + * 3. Increase dims[0], same dims[1] + * 4. Decrease dims[0], increase dims[1] + * 5. Decrease dims[0], decrease dims[1] + * 6. Decrease dims[0], same dims[1] + * 7. same dims[0], increase dims[1] + * 8. same dims[0], decrease dims[1] + * 9. same dims[0], same dims[1] + * + * two_tests[TWO_NTESTS][2] = { {2,2}, {2,-1}, {2,0}, + * {-1,2}, {-1,-1}, {-1,0}, + * {0,2}, {0,-1}, {0,0} } + * Varies from {4,10}->{6,12}; {4,10}->{6,9}; {4,10}->{6,10}; + * {4,10}->{3,12}; {4,10}->{3,9}; {4,10}->{3,10}; + * {4,10}->{4,12}; {4,10}->{4,9}; {4,10}->{4,10} + * + ********************************************************************************* + */ +static herr_t +test_LD_dims(const char *file) +{ + hid_t fid; /* file identifier */ + hid_t did; /* dataset identifier */ + int i; /* local index variable */ + hsize_t one_prev_dims[1]; /* original dimension sizes for 1-dimensonal dataset */ + hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */ + hsize_t one_ext_dims[1]; /* extended dimension sizes for 1-dimensonal dataset */ + hsize_t two_prev_dims[2]; /* original dimension sizes for 2-dimensional dataset */ + hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */ + hsize_t two_ext_dims[2]; /* extended dimension sizes for 2-dimensional dataset*/ + + const char *filename = H5_get_srcdir_filename(file); + + TESTING("H5LDget_dset_dims with H5Dset_extent"); + + /* Make a copy of the test file */ + COPY_FILE(filename, COPY_FILENAME) + + /* Open the copied file */ + if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* + * Testing with one-dimensional dataset: DSET_ONE + */ + if((did = H5Dopen2(fid, DSET_ONE, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Retrieve dimension sizes */ + if(H5LDget_dset_dims(did, one_prev_dims) < 0) + FAIL_STACK_ERROR + + for(i = 0; i < ONE_NTESTS; i++) { + + /* Set up the extended dimension sizes */ + one_ext_dims[0] = one_prev_dims[0] + one_tests[i]; + + /* Change the dimension size */ + if(H5Dset_extent(did, one_ext_dims) < 0) + FAIL_STACK_ERROR + + /* Retrieve the dimension size */ + if(H5LDget_dset_dims(did, one_cur_dims) < 0) + FAIL_STACK_ERROR + + /* Verify that the retrieved dimension size is correct as expected */ + VERIFY_EQUAL(one_cur_dims[0], one_ext_dims[0]) + } + + /* Close the dataset */ + if(H5Dclose(did) < 0) + FAIL_STACK_ERROR + + /* + * Testing with two-dimensional dataset: DSET_TWO + */ + if((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Retrieve the dimension sizes */ + if(H5LDget_dset_dims(did, two_prev_dims) < 0) + FAIL_STACK_ERROR + + for(i = 0; i < TWO_NTESTS; i++) { + + /* Set up the extended dimension sizes */ + two_ext_dims[0] = two_prev_dims[0] + two_tests[i][0]; + two_ext_dims[1] = two_prev_dims[1] + two_tests[i][1]; + + /* Change the dimension sizes */ + if(H5Dset_extent(did, two_ext_dims) < 0) + FAIL_STACK_ERROR + + /* Retrieve the dimension sizes */ + if(H5LDget_dset_dims(did, two_cur_dims) < 0) + FAIL_STACK_ERROR + + /* Verify that the retrieved dimension sizes are correct as expected */ + VERIFY_EQUAL(two_cur_dims[0], two_ext_dims[0]) + VERIFY_EQUAL(two_cur_dims[1], two_ext_dims[1]) + } /* end TWO_NTESTS */ + + /* Close the dataset */ + if(H5Dclose(did) < 0) + FAIL_STACK_ERROR + + /* Close the file */ + if(H5Fclose(fid) < 0) + FAIL_STACK_ERROR + + /* Remove the copied file */ + HDremove(COPY_FILENAME); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(did); + H5Fclose(fid); + } H5E_END_TRY; + return(-1); + +} /* test_LD_dims() */ + +/* + ********************************************************************************** + * + * Testing for the High Level public routine: H5LDget_dset_type_size() + * Verify that the data type size returned via H5LDget_dset_type_size() + * are correct for the following cases: + * + * Verify failure for an invalid dataset id + * + * DSET_CMPD: one-dimensional dataset with compound type + * 1. The whole element + * 2. VALID_FIELDS1: "field1,field2.a,field3,field4" + * 3. VALID_FIELDS2: "field2.b.a,field2.c,field4.b" + * 4. INVALID_FIELDS1: "field2.k.a,field2.c,field4.k" + * 5. INVALID_FIELDS2: "field2.b.a,field2.c,field4.b." + * 6. INVALID_FIELDS3: "field2.b.a,,field2.c,field4.b" + * + * DSET_CMPD_ESC: one-dimensional dataset with compound type and + * member names with escape/separator characters + * 1. The whole element + * 2. VALID_ESC_FIELDS1: "field\\,1,field2\\..\\.a,field\\\\3,field4\\," + * 3. VALID_ESC_FIELDS2: "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," + * 4. INVALID_ESC_FIELDS1: "field2\\..\\,k.a,field2\\..\\\\c,field4\\,.k\\," + * 5. INVALID_ESC_FIELDS2: "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\,." + * 6. INVALID_ESC_FIELDS3: "field2\\..\\,,b.a,field2\\..\\\\c,field4\\,.b\\," + * + ********************************************************************************** + */ +static int +test_LD_size(const char *file) +{ + hid_t fid; /* file identifier */ + hid_t did; /* dataset identifier */ + hid_t dtid; /* dataset's datatype identifier */ + hid_t memb0_tid; /* type identifier for a member in the compound type */ + hid_t memb1_tid; /* type identifier for a member in the compound type */ + hid_t memb2_tid; /* type identifier for a member in the compound type */ + hid_t memb3_tid; /* type identifier for a member in the compound type */ + hid_t memb_tid; /* type identifier for a member in the compound type */ + hid_t memb_tid2; /* type identifier for a member in the compound type */ + size_t dsize; /* size of the dataset's datatype */ + size_t ck_dsize; /* size of the dataset's datatype to be checked against */ + + const char *filename = H5_get_srcdir_filename(file); + + TESTING("H5LDget_dset_type_size"); + + /* Open the file */ + if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* + * Verify failure with an invalid dataset id + */ + H5E_BEGIN_TRY { + dsize = H5LDget_dset_type_size(-1, NULL); + } H5E_END_TRY; + VERIFY_EQUAL(dsize, 0) + + /* + * Testing one-dimensional dataset with compound datatype: + * DSET_CMPD + */ + + /* Open dataset DSET_CMPD */ + if((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Return size of the whole element */ + if((dsize = H5LDget_dset_type_size(did, NULL)) == 0) + FAIL_STACK_ERROR + + /* Get the dataset's datatype and then its datatype size */ + if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + FAIL_STACK_ERROR + + if((ck_dsize = H5Tget_size(dtid)) == 0) + FAIL_STACK_ERROR + + /* Verify case #1 */ + VERIFY_EQUAL(dsize, ck_dsize) + + /* Get datatype id for each member */ + if((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field1" */ + FAIL_STACK_ERROR + if((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2" */ + FAIL_STACK_ERROR + if((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field3" */ + FAIL_STACK_ERROR + if((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4" */ + FAIL_STACK_ERROR + + /* Obtain size for VALID_FIELDS1: "field1,field2.a,field3,field4" */ + if((dsize = H5LDget_dset_type_size(did, VALID_FIELDS1)) == 0) + FAIL_STACK_ERROR + + /* Get the datatype size for "field1" */ + if((ck_dsize = H5Tget_size(memb0_tid)) == 0) + FAIL_STACK_ERROR + + /* Add the datatype size for "field2.a" */ + if((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0) + FAIL_STACK_ERROR + if((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR + H5Tclose(memb_tid); + + /* Add the datatype size for "field3" */ + if((ck_dsize += H5Tget_size(memb2_tid)) == 0) + FAIL_STACK_ERROR + + /* Add the datatype size for "field4" */ + if((ck_dsize += H5Tget_size(memb3_tid)) == 0) + FAIL_STACK_ERROR + + /* Verify case #2 */ + VERIFY_EQUAL(dsize, ck_dsize) + + /* Obtain datatype size for VALID_FIELDS2: "field2.b.a,field2.c,field4.b" */ + if((dsize = H5LDget_dset_type_size(did, VALID_FIELDS2)) == 0) + FAIL_STACK_ERROR + + /* Get the datatype size for "field2.b.a" */ + if((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0) + FAIL_STACK_ERROR + if((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0) + FAIL_STACK_ERROR + if((ck_dsize = H5Tget_size(memb_tid2)) == 0) + FAIL_STACK_ERROR + H5Tclose(memb_tid); + H5Tclose(memb_tid2); + + /* Add the datatype size for "field2.c" */ + if((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0) + FAIL_STACK_ERROR + if((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR + H5Tclose(memb_tid); + + /* Add the datatype size for "field4.b" */ + if((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0) + FAIL_STACK_ERROR + if((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR + H5Tclose(memb_tid); + + /* Verify case #3 */ + VERIFY_EQUAL(dsize, ck_dsize) + + /* + * Verify failure for the following invalid nested fields: + * INVALID_FIELDS1: "field2.k.a,field2.c,field4.k" + * INVALID_FIELDS2: "field2.b.a,field2.c,field4.b." + * INVALID_FIELDS3: "field2.b.a,,field2.c,field4.b" + */ + /* Verify failure for case #4 */ + dsize = H5LDget_dset_type_size(did, INVALID_FIELDS1); + VERIFY_EQUAL(dsize, 0) + + /* Verify failure for case #5 */ + dsize = H5LDget_dset_type_size(did, INVALID_FIELDS2); + VERIFY_EQUAL(dsize, 0) + + /* Verify failure for case #6 */ + dsize = H5LDget_dset_type_size(did, INVALID_FIELDS3); + VERIFY_EQUAL(dsize, 0) + + /* Closing */ + H5Tclose(memb0_tid); + H5Tclose(memb1_tid); + H5Tclose(memb2_tid); + H5Tclose(memb3_tid); + H5Tclose(dtid); + H5Dclose(did); + + /* + * Testing one-dimensional dataset with compound datatype and + * member names consisting of escape/separator characters: + * DSET_CMPD_ESC + */ + + /* Open dataset DSET_CMPD_ESC */ + if((did = H5Dopen2(fid, DSET_CMPD_ESC, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Return size of the whole element */ + if((dsize = H5LDget_dset_type_size(did, NULL)) == 0) + FAIL_STACK_ERROR + + /* Get the dataset's datatype and then its datatype size */ + if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + FAIL_STACK_ERROR + if((ck_dsize = H5Tget_size(dtid)) == 0) + FAIL_STACK_ERROR + + /* Verify case #1 */ + VERIFY_EQUAL(dsize, ck_dsize) + + /* Get datatype id for each member */ + if((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field,1" */ + FAIL_STACK_ERROR + if((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2." */ + FAIL_STACK_ERROR + if((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field\3" */ + FAIL_STACK_ERROR + if((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4," */ + FAIL_STACK_ERROR + + /* Obtain size for VALID_ESC_FIELDS1: "field\\,1,field2\\..\\.a,field\\\\3,field4\\," */ + if((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS1)) == 0) + FAIL_STACK_ERROR + + /* Get the datatype size for "field\\,1" */ + if((ck_dsize = H5Tget_size(memb0_tid)) == 0) + FAIL_STACK_ERROR + + /* Add the datatype size for "field2\\..\\.a" */ + if((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0) + FAIL_STACK_ERROR + if((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR + H5Tclose(memb_tid); + + /* Add the datatype size for "field\\\\3" */ + if((ck_dsize += H5Tget_size(memb2_tid)) == 0) + FAIL_STACK_ERROR + + /* Add the datatype size for "field4\\," */ + if((ck_dsize += H5Tget_size(memb3_tid)) == 0) + FAIL_STACK_ERROR + + /* Verify case #2 */ + VERIFY_EQUAL(dsize, ck_dsize) + + /* Obtain datatype size for VALID_ESC_FIELDS2: + "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," */ + if((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS2)) == 0) + FAIL_STACK_ERROR + + /* Get the datatype size for "field2\..,b.a" */ + if((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0) + FAIL_STACK_ERROR + if((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0) + FAIL_STACK_ERROR + if((ck_dsize = H5Tget_size(memb_tid2)) == 0) + FAIL_STACK_ERROR + H5Tclose(memb_tid); + H5Tclose(memb_tid2); + + /* Add the datatype size for "field2\..\\c" */ + if((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0) + FAIL_STACK_ERROR + if((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR + H5Tclose(memb_tid); + + /* Add the datatype size for "field4\,.b\," */ + if((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0) + FAIL_STACK_ERROR + if((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR + H5Tclose(memb_tid); + + /* Verify case #3 */ + VERIFY_EQUAL(dsize, ck_dsize) + + /* + * Verify failure for the following invalid nested fields: + * INVALID_ESC_FIELDS1: "field2\..\,k.a,field2\..\\c,field4\,.k\," + * INVALID_ESC_FIELDS2: "field2\..\,b.a,field2\..\\c,field4\,.b\,." + * INVALID_ESC_FIELDS3: "field2\..\,,b.a,field2\..\\c,field4\,.b\," + */ + /* Verify failure for case #4 */ + dsize = H5LDget_dset_type_size(did, INVALID_ESC_FIELDS1); + VERIFY_EQUAL(dsize, 0) + + /* Verify failure for case #5 */ + dsize = H5LDget_dset_type_size(did, INVALID_ESC_FIELDS2); + VERIFY_EQUAL(dsize, 0) + + /* Verify failure for case #6 */ + dsize = H5LDget_dset_type_size(did, INVALID_ESC_FIELDS3); + VERIFY_EQUAL(dsize, 0) + + /* Closing */ + H5Tclose(memb0_tid); + H5Tclose(memb1_tid); + H5Tclose(memb2_tid); + H5Tclose(memb3_tid); + H5Tclose(dtid); + H5Dclose(did); + + H5Fclose(fid); + + /* Remove the copied file */ + HDremove(COPY_FILENAME); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Tclose(memb0_tid); + H5Tclose(memb1_tid); + H5Tclose(memb2_tid); + H5Tclose(memb3_tid); + H5Tclose(dtid); + H5Dclose(did); + H5Fclose(fid); + } H5E_END_TRY; + return(-1); + +} /* test_LD_size() */ + +/* + ************************************************************************************** + * Testing for the High Level public routine: H5LDget_dset_elmts() + * Verify failures when calling H5LDget_dset_elmts() with the following + * invalid conditions: + * + * A. DSET_TWO: two-dimensional dataset + * 1. CUR_DIMS and PREV_DIMS are NULL + * 2. PREV_DIMS is NULL + * 3. CUR_DIMS is NULL + * 4. FIELDS is nonnull but the dataset is not compound datatype + * 5. BUF is NULL + * 6. CUR_DIMS is not greater than PREV_DIMS + * + * B. DSET_CMPD: one-dimensional dataset with compound type + * 1. Invalid dataset id + * 2. FIELDS are not valid members in the compound type + * + ************************************************************************************** + */ +static int +test_LD_elmts_invalid(const char *file) +{ + hid_t fid; /* file identifier */ + hid_t did; /* dataset identifier */ + hid_t sid; /* dataspace identifier */ + int ret; /* return value */ + hsize_t cur_dims[2]; /* current dimension sizes of the dataset */ + hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */ + char tbuf[2]; /* temporary buffer for testing */ + int ndims; /* # of dimension sizes */ + int i; /* local index variable */ + + const char *filename = H5_get_srcdir_filename(file); + + TESTING("H5LDget_dset_elmts on invalid conditions"); + + /* Copied the test file */ + COPY_FILE(filename, COPY_FILENAME) + + /* Open the copied file */ + if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* + * Testing two-dimensional dataset: DSET_TWO + */ + + /* Open dataset: DSET_TWO */ + if((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Verify failure from case #1: cur_dims and prev_dims are NULL */ + ret = H5LDget_dset_elmts(did, NULL, NULL, NULL, NULL); + VERIFY_EQUAL(ret, FAIL) + + /* Verify failure from case #2: prev_dims is NULL */ + ret = H5LDget_dset_elmts(did, cur_dims, NULL, NULL, NULL); + VERIFY_EQUAL(ret, FAIL) + + /* Verify failure from case #3: cur_dims is NULL */ + ret = H5LDget_dset_elmts(did, NULL, prev_dims, NULL, NULL); + VERIFY_EQUAL(ret, FAIL) + + if((sid = H5Dget_space(did)) < 0) + FAIL_STACK_ERROR + + /* Get the # of dimensions and current dimension sizes */ + if((ndims = H5Sget_simple_extent_dims(sid, cur_dims, NULL)) < 0) + FAIL_STACK_ERROR + + /* Set up valid cur_dims and prev_dims */ + for(i = 0; i < ndims; i++) + prev_dims[i] = cur_dims[i] - 1; + + /* Verify failure from case #4: FIELDS is nonNULL but the dataset is not compound datatype */ + ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, "field1", tbuf); + VERIFY_EQUAL(ret, FAIL) + + /* Verify failure from case #5: BUF is NULL */ + ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, NULL, NULL); + VERIFY_EQUAL(ret, FAIL) + + /* Verify failure from case #6: cur_dims is not > than prev_dims */ + cur_dims[0] = prev_dims[0] - 1; + cur_dims[1] = prev_dims[1] - 1; + ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, NULL, tbuf); + VERIFY_EQUAL(ret, FAIL) + + /* Close DSET_TWO */ + H5Dclose(did); + + /* + * Testing one-dimensional dataset with compound datatype: + * DSET_CMPD + */ + + /* Verify failure from case #1: an invalid dataset id */ + H5E_BEGIN_TRY { + ret = H5LDget_dset_elmts(-1, prev_dims, cur_dims, NULL, tbuf); + } H5E_END_TRY; + VERIFY_EQUAL(ret, FAIL) + + /* Open dataset: DSET_CMPD */ + if((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Retrieve the current dimension sizes */ + if(H5LDget_dset_dims(did, cur_dims) < 0) + FAIL_STACK_ERROR + + /* Set up valid cur_dims, prev_dims */ + prev_dims[0] = cur_dims[0] - 1; + + /* Verify failure from case #2: invalid FIELDS */ + ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, "field2.k.a,field2.c,field4.k", tbuf); + VERIFY_EQUAL(ret, FAIL) + + /* Close DSET_CMPD */ + H5Dclose(did); + + /* Close the file */ + H5Fclose(fid); + + /* Remove the copied file */ + HDremove(COPY_FILENAME); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(did); + H5Fclose(fid); + } H5E_END_TRY; + return(-1); + +} /* test_LD_elmts_invalid() */ + + +/* + ************************************************************************************** + * Testing for the High Level public routine: H5LDget_dset_elmts() + * Verify elements retrieved via H5LDget_dset_elmts() are correct as expected + * when the dataset's dimension sizes are changed according to one_tests[]: + * + * one-dimensional dataset : + * DSET_ONE with NULL fields + * DSET_CMPD with fields: NULL, VALID_FIELDS1, VALID_FIELDS2 + * DSET_CMPD_ESC with fields: NULL, VALID_ESC_FIELDS1, VALID_ESC_FIELDS2 + * + * case #1. increase dims[0] + * case #2. decrease dims[0] (failure) + * case #3. same dims[0] (failure) + * case #4. decrease dims[0] (failure) + * case #5. increase dims[0] + * + ************************************************************************************** + */ +static herr_t +test_LD_elmts_one(const char *file, const char *dname, const char *fields) +{ + hid_t fid; /* file identifier */ + hid_t did; /* dataset identifier */ + hid_t dtype; /* dataset's data type */ + hsize_t ext_dims[1]; /* extended dimension sizes of the dataset */ + hsize_t prev_dims[1]; /* previous dimension sizes of the dataset */ + int i, j; /* local index variable */ + int iibuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elements */ + int ibuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elements (integer) */ + set_t cbuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elemnets (compound) */ + set_t ccbuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elemnets (compound) */ + test_valid_fields1 vbuf1[TEST_BUF_SIZE]; /* buffer for storing retrieved elements (FIELDS1) */ + test_valid_fields2 vbuf2[TEST_BUF_SIZE]; /* buffer for storing retrieved elements (FIELDS2) */ + int ret = 0; /* return value */ + + const char *filename = H5_get_srcdir_filename(file); + + TESTING("H5LDget_dset_elmts: one-dimensional dataset"); + + /* Copy the test file */ + COPY_FILE(filename, COPY_FILENAME) + + for (i = 0; i < TEST_BUF_SIZE; i++) { + cbuf[i].field1 = i; + cbuf[i].field2.a = i; + cbuf[i].field2.b.a = i; + cbuf[i].field2.b.b = i; + cbuf[i].field2.b.c = i; + cbuf[i].field2.c = i; + cbuf[i].field3 = (double)i; + cbuf[i].field4.a = i; + cbuf[i].field4.b = i; + ibuf[i] = i; + } + + /* Open the copied file */ + if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Open the dataset */ + if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Get the dataset's data type */ + if((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Get current dimension sizes before extending the dataset's dimension sizes */ + if(H5LDget_dset_dims(did, prev_dims) < 0) + FAIL_STACK_ERROR + + /* Loop through different variations of extending the dataset */ + for(i = 0; i < ONE_NTESTS; i++) { + ext_dims[0] = prev_dims[0] + one_tests[i]; + + /* Change the dimension sizes of the dataset */ + if(H5Dset_extent(did, ext_dims) < 0) + FAIL_STACK_ERROR + + /* Initialize data */ + if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) + FAIL_STACK_ERROR + + } else if(!HDstrcmp(dname, DSET_ONE)) { + if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) + FAIL_STACK_ERROR + } + + /* There are changes in dimension sizes */ + if(one_tests[i] > 0) { + + if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + + if(fields && (!HDstrcmp(fields, VALID_FIELDS1) || + !HDstrcmp(fields, VALID_ESC_FIELDS1))) { + /* Retrieve the elmemts in BUF */ + if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0) + TEST_ERROR + for(j = 0; j < one_tests[i]; j++) + VERIFY_ELMTS_VALID1(vbuf1[j], cbuf[prev_dims[0]+j]) + + } else if(fields && (!HDstrcmp(fields, VALID_FIELDS2) || + !HDstrcmp(fields, VALID_ESC_FIELDS2))) { + + /* Retrieve the elmemts in BUF */ + if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0) + TEST_ERROR + for(j = 0; j < one_tests[i]; j++) + VERIFY_ELMTS_VALID2(vbuf2[j], cbuf[prev_dims[0]+j]) + + } else if(fields == NULL) { + + /* Retrieve the elmemts in BUF */ + if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0) + TEST_ERROR + + for(j = 0; j < one_tests[i]; j++) + VERIFY_ELMTS_ALL(ccbuf[j], cbuf[prev_dims[0]+j]) + } + } else { + /* Retrieve the elmemts in BUF */ + if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0) + TEST_ERROR + for(j = 0; j < one_tests[i]; j++) + VERIFY_EQUAL(iibuf[j], ibuf[prev_dims[0] + j]) + } + } else { + /* Verify failure when changes between prev_dims and ext_dims are same/decrease */ + ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf); + VERIFY_EQUAL(ret, FAIL) + } + + } /* end for */ + + /* Closing */ + H5Tclose(dtype); + H5Dclose(did); + H5Fclose(fid); + + /* Remove the copied file */ + HDremove(COPY_FILENAME); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Tclose(dtype); + H5Dclose(did); + H5Fclose(fid); + } H5E_END_TRY; + return(-1); +} /* test_LD_elmts_one() */ + + +/* + ************************************************************************************** + * + * Helper routine to verify elements of a 2-dimensional dataset + * _ldbuf contains the elements retrieved via H5LDget_dset_elmts() + * _buf contains the data written to the dataset + * + * e.g. prev_dims[2] = {4, 6}; ext_dims[2] = {6, 10} + * elements marked in 'v' in _buf are compared to elements in _ldbuf + * 0 1 2 3 4 5 | 6 7 8 9 + * 0 | v v v v + * 1 | v v v v + * 2 | v v v v + * 3 | v v v v + * --------------------- + * 4 v v v v v v v v v v + * 5 v v v v v v v v v v + * + ************************************************************************************** + */ +static herr_t +verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf) +{ + int k, m, n, ind; /* Local index variable */ + + k = 0; + for(m = 0; m < (int)ext_dims[0]; m++) { + ind = m * ext_dims[1]; + if(m < (int)prev_dims[0]) { + for(n = (int)prev_dims[1]; n < (int)ext_dims[1]; n++) { + VERIFY_ELMTS(type, _ldbuf, _buf) + ++k; + } + } else { + for(n = 0; n < (int)ext_dims[1]; n++) { + VERIFY_ELMTS(type, _ldbuf, _buf) + ++k; + } + } + } /* end for */ + + return(0); +error: + return(-1); +} /* verify_elmts_two() */ + +/* + ************************************************************************************** + * Testing for the High Level public routine: H5LDget_dset_elmts() + * Verify elements retrieved via H5LDget_dset_elmts() are correct as expected when + * the datset's dimension sizes are changed accordingly to two_tests[]: + * + * two-dimensional dataset: DSET_TWO with NULL fields + * DSET_CMPD_TWO with fields: NULL, VALID_FIELDS1, VALID_FIELDS2 + * + * dims[0] dims[1] + * ------- ------- + * case #1: increase increase + * case #2: increase decrease + * case #3: increase same + * case #4: decrease increase + * case #5: decrease decrease (failure) + * case #6: decrease same (failure) + * case #7: same increase + * case #8: same decrease (failure) + * case #9: same same (failure) + * + ************************************************************************************** + */ +static herr_t +test_LD_elmts_two(const char *file, const char *dname, const char *fields) +{ + hid_t fid; /* file identifier */ + hid_t did; /* dataset identifier */ + hid_t dtype; /* dataset's data type */ + hsize_t ext_dims[2]; /* extended dimension sizes of the dataset */ + hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */ + int i; /* local index variable */ + int iibuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elements */ + int ibuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elements (integer) */ + set_t cbuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elemnets (compound) */ + set_t ccbuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elemnets (compound) */ + test_valid_fields1 vbuf1[TEST_BUF_SIZE]; /* buffer for storing retrieved elements (FIELDS1) */ + test_valid_fields2 vbuf2[TEST_BUF_SIZE]; /* buffer for storing retrieved elements (FIELDS2) */ + int ret = 0; /* return value */ + + const char *filename = H5_get_srcdir_filename(file); + + TESTING("H5LDget_dset_elmts: two-dimensional dataset"); + + /* Copy the test file */ + COPY_FILE(filename, COPY_FILENAME) + + for (i = 0; i < TEST_BUF_SIZE; i++) { + cbuf[i].field1 = i; + cbuf[i].field2.a = i; + cbuf[i].field2.b.a = i; + cbuf[i].field2.b.b = i; + cbuf[i].field2.b.c = i; + cbuf[i].field2.c = i; + cbuf[i].field3 = (double)i; + cbuf[i].field4.a = i; + cbuf[i].field4.b = i; + ibuf[i] = i; + } + + /* Open the copied file */ + if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Open the dataset */ + if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Get the dataset's data type */ + if((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Get current dimension sizes before extending the dataset's dimension sizes */ + if(H5LDget_dset_dims(did, prev_dims) < 0) + FAIL_STACK_ERROR + + /* Loop through different variations of extending the dataset */ + for(i = 0; i < TWO_NTESTS; i++) { + ext_dims[0] = prev_dims[0] + two_tests[i][0]; + ext_dims[1] = prev_dims[1] + two_tests[i][1]; + + /* Change the dimension sizes of the dataset */ + if(H5Dset_extent(did, ext_dims) < 0) + FAIL_STACK_ERROR + + /* Initialize data */ + if(!HDstrcmp(dname, DSET_CMPD_TWO)) { + if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) + FAIL_STACK_ERROR + + } else if(!HDstrcmp(dname, DSET_TWO)) { + if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) + FAIL_STACK_ERROR + } + + /* There are changes in dimension sizes */ + if(two_tests[i][0] > 0 || two_tests[i][1] > 0) { + + if(!HDstrcmp(dname, DSET_CMPD_TWO)) { + + if(fields && (!HDstrcmp(fields, VALID_FIELDS1) || + !HDstrcmp(fields, VALID_ESC_FIELDS1))) { + + HDmemset(vbuf1, 0, sizeof(vbuf1)); + + /* Retrieve the elmemts in BUF */ + if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0) + TEST_ERROR + + if(verify_elmts_two(TWO_CMPD_VALID1, ext_dims, prev_dims, vbuf1, cbuf) < 0) + TEST_ERROR + + } else if(fields && (!HDstrcmp(fields, VALID_FIELDS2) || + !HDstrcmp(fields, VALID_ESC_FIELDS2))) { + HDmemset(vbuf2, 0, sizeof(vbuf2)); + + /* Retrieve the elmemts in BUF */ + if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0) + TEST_ERROR + + if(verify_elmts_two(TWO_CMPD_VALID2, ext_dims, prev_dims, vbuf2, cbuf) < 0) + TEST_ERROR + + } else if(fields == NULL) { + + HDmemset(ccbuf, 0, sizeof(ccbuf)); + + /* Retrieve the elmemts in BUF */ + if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0) + TEST_ERROR + + if(verify_elmts_two(TWO_CMPD_NULL, ext_dims, prev_dims, ccbuf, cbuf) < 0) + TEST_ERROR + } + } else { /* DSET_TWO */ + HDmemset(iibuf, 0, sizeof(iibuf)); + + /* Retrieve the elmemts in BUF */ + if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0) + TEST_ERROR + + if(verify_elmts_two(TWO_NONE, ext_dims, prev_dims, iibuf, ibuf) < 0) + TEST_ERROR + } + } else { + /* Verify failure when changes between prev_dims and ext_dims are same/decrease */ + ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf); + VERIFY_EQUAL(ret, FAIL) + } + } /* end for */ + + /* Closing */ + H5Tclose(dtype); + H5Dclose(did); + H5Fclose(fid); + + /* Remove the copied file */ + HDremove(COPY_FILENAME); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Tclose(dtype); + H5Dclose(did); + H5Fclose(fid); + } H5E_END_TRY; + return(-1); +} /* test_LD_elmts_two() */ + +/* + * Tests for High Level routines: + * H5LDget_dset_dims(), H5LDget_dset_elmts, H5LDget_dset_type_size() + */ +int main(void) +{ + int nerrors = 0; + + /* + * Testing H5LDget_dset_dims() + */ + nerrors += test_LD_dims_params(FILE); + nerrors += test_LD_dims(FILE); + + /* + * Testing H5LDget_dset_type_size() + */ + nerrors += test_LD_size(FILE); + + /* + * Testing invalid conditions for H5LDget_dset_elmts() + */ + nerrors += test_LD_elmts_invalid(FILE); + + /* + * Testing H5LDget_dset_elmts(): + * 1-dimensional dataset + */ + nerrors += test_LD_elmts_one(FILE, DSET_ONE, NULL); + + /* + * Testing H5LDget_dset_elmts(): + * 1-dimensional dataset w/ compound datatype + */ + nerrors += test_LD_elmts_one(FILE, DSET_CMPD, NULL); + nerrors += test_LD_elmts_one(FILE, DSET_CMPD, VALID_FIELDS1); + nerrors += test_LD_elmts_one(FILE, DSET_CMPD, VALID_FIELDS2); + + /* + * Testing H5LDget_dset_elmts(): + * 1-dimensional dataset with compound datatype and + * member names with escape/separator characters + */ + nerrors += test_LD_elmts_one(FILE, DSET_CMPD_ESC, NULL); + nerrors += test_LD_elmts_one(FILE, DSET_CMPD_ESC, VALID_ESC_FIELDS1); + nerrors += test_LD_elmts_one(FILE, DSET_CMPD_ESC, VALID_ESC_FIELDS2); + + /* + * Testing H5LDget_dset_elmts() for 2-dimensional datasets + */ + nerrors += test_LD_elmts_two(FILE, DSET_TWO, NULL); + nerrors += test_LD_elmts_two(FILE, DSET_CMPD_TWO, NULL); + nerrors += test_LD_elmts_two(FILE, DSET_CMPD_TWO, VALID_FIELDS1); + nerrors += test_LD_elmts_two(FILE, DSET_CMPD_TWO, VALID_FIELDS2); + + /* check for errors */ + if(nerrors) + goto error; + + puts("All tests for H5LD high level routines passed."); + + return(0); + +error: + return(1); +} /* main() */ diff --git a/hl/test/test_ld.h5 b/hl/test/test_ld.h5 new file mode 100644 index 0000000..40c4ff0 Binary files /dev/null and b/hl/test/test_ld.h5 differ diff --git a/hl/test/test_ld.sh.in b/hl/test/test_ld.sh.in new file mode 100644 index 0000000..69beea6 --- /dev/null +++ b/hl/test/test_ld.sh.in @@ -0,0 +1,94 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# +# +# Concurrent tests for H5LD* routines +# +# Determine backward compatibility options eneabled +DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@" + +CMP='cmp -s' +DIFF='diff -c' +CP='cp' +KILL='kill' +SLEEP='sleep' +LD_MONITOR=ld_monitor +LD_MONITOR_BIN=`pwd`/$LD_MONITOR +LD_EXTEND=ld_extend +LD_EXTEND_BIN=`pwd`/$LD_EXTEND + +nerrors=0 +verbose=yes + +# The build (current) directory might be different than the source directory. +if test -z "$srcdir"; then + srcdir=. +fi + +test -d ./testfiles || mkdir ./testfiles + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +TESTING() { + SPACES=" " + echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# $1 -- the hdf5 file to be monitored and extended +# $2 -- the dataset name to be monitored and extended +# $3 -- the expected output from monitoring the dataset +TESTLD() { + expect="$srcdir/testfiles/$3" # the expected output + actual="./testfiles/$3.OUT" # the actual output + FNAME="`basename $1 .h5`_$2.h5" # the HDF5 file + $CP $srcdir/$1 ./$FNAME # copy the file to a temporary file + $LD_MONITOR_BIN $FNAME $2 > $actual 2>&1 & # monitor the dataset in the file + MONITOR_PID=$! # get the id of the monitor process + $LD_EXTEND_BIN $FNAME $2 # extend the dataset + echo "Sleeping for 3 seconds..." + $SLEEP 3 # sleep to allow output to be flushed + echo "Killing the monitor..." + $KILL $MONITOR_PID # kill the monitor process + if $CMP $expect $actual; then # compare the output with the expected output + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result differs from actual result" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + fi + if test -z "$HDF5_NOCLEANUP"; then # clean up output file, temporary HDF5 file + rm -f $actual $FNAME + fi +} + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + +# Monitor DSET_ONE while extending the dataset +TESTLD test_ld.h5 DSET_ONE test_ld_out1 +# +# Monitor DSET_TWO while extending the dataset +TESTLD test_ld.h5 DSET_TWO test_ld_out2 + +if test $nerrors -eq 0 ; then + echo "All high level H5LD concurrent tests passed." +fi + +exit $nerrors diff --git a/hl/test/testfiles/test_ld_out1 b/hl/test/testfiles/test_ld_out1 new file mode 100644 index 0000000..dda3552 --- /dev/null +++ b/hl/test/testfiles/test_ld_out1 @@ -0,0 +1,31 @@ +Monitoring dataset DSET_ONE... + +13 + +10 11 12 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 + +12 + +1 + +3 + +1 2 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 diff --git a/hl/test/testfiles/test_ld_out2 b/hl/test/testfiles/test_ld_out2 new file mode 100644 index 0000000..7a98c19 --- /dev/null +++ b/hl/test/testfiles/test_ld_out2 @@ -0,0 +1,72 @@ +Monitoring dataset DSET_TWO... + +6 12 + +10 11 22 23 34 35 46 47 48 49 +50 51 52 53 54 55 56 57 58 59 +60 61 62 63 64 65 66 67 68 69 +70 71 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 + +8 1 + +6 7 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 + +10 1 + +8 9 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 + +3 3 + +1 2 4 5 7 8 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 + +2 2 + +1 2 + +1 4 + +2 3 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 + +1 3 diff --git a/hl/tools/Makefile.am b/hl/tools/Makefile.am index 71eb149..7fab05f 100644 --- a/hl/tools/Makefile.am +++ b/hl/tools/Makefile.am @@ -21,7 +21,9 @@ include $(top_srcdir)/config/commence.am +CONFIG=ordered + # All subdirectories -SUBDIRS=gif2h5 +SUBDIRS=gif2h5 h5watch include $(top_srcdir)/config/conclude.am diff --git a/hl/tools/Makefile.in b/hl/tools/Makefile.in index 20d761d..9f925e4 100644 --- a/hl/tools/Makefile.in +++ b/hl/tools/Makefile.in @@ -380,9 +380,10 @@ TRACE = perl $(top_srcdir)/bin/trace # .chklog files are output from those tests. # *.clog are from the MPE option. CHECK_CLEANFILES = *.chkexe *.chklog *.clog +CONFIG = ordered # All subdirectories -SUBDIRS = gif2h5 +SUBDIRS = gif2h5 h5watch # Automake needs to be taught how to build lib, progs, and tests targets. # These will be filled in automatically for the most part (e.g., diff --git a/hl/tools/h5watch/Makefile.am b/hl/tools/h5watch/Makefile.am new file mode 100644 index 0000000..0bf7c1b --- /dev/null +++ b/hl/tools/h5watch/Makefile.am @@ -0,0 +1,54 @@ +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +## +## Makefile.am +## Run automake to generate a Makefile.in from this file. +# +# HDF5 Library Makefile(.in) +# + +include $(top_srcdir)/config/commence.am + +# Include src and tools/lib directories +INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib -I$(top_srcdir)/hl/src + +# These are our main targets, the tools +#TEST_PROG=h5watchgentest +TEST_SCRIPT=testh5watch.sh +#check_PROGRAMS=h5watchgentest +check_SCRIPTS=$(TEST_SCRIPT) +SCRIPT_DEPEND=h5watch$(EXEEXT) + +bin_PROGRAMS=h5watch +noinst_PROGRAMS=h5watchgentest extend_dset + +# Add h5watch specific linker flags here +h5watch_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) + +h5watch_SOURCES=h5watch.c + +#gen_onetwo_test_SOURCES=gen_onetwo_test.c +h5watchgentest_SOURCES=h5watchgentest.c +extend_dset_SOURCES=extend_dset.c +#extend_one_SOURCES=extend_one.c +#extend_two_SOURCES=extend_two.c + +# Programs all depend on the hdf5 library, the tools library, and the HL +# library. +LDADD=$(LIBH5_HL) $(LIBH5TOOLS) $(LIBHDF5) + +CHECK_CLEANFILES+=*.h5 +DISTCLEANFILES=testh5watch.sh + +include $(top_srcdir)/config/conclude.am diff --git a/hl/tools/h5watch/Makefile.in b/hl/tools/h5watch/Makefile.in new file mode 100644 index 0000000..8c9411a --- /dev/null +++ b/hl/tools/h5watch/Makefile.in @@ -0,0 +1,970 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# +# HDF5 Library Makefile(.in) +# + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/testh5watch.sh.in $(top_srcdir)/config/commence.am \ + $(top_srcdir)/config/conclude.am +bin_PROGRAMS = h5watch$(EXEEXT) +noinst_PROGRAMS = h5watchgentest$(EXEEXT) extend_dset$(EXEEXT) +TESTS = $(check_SCRIPTS) +subdir = hl/tools/h5watch +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/src/H5config.h +CONFIG_CLEAN_FILES = testh5watch.sh +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) +am_extend_dset_OBJECTS = extend_dset.$(OBJEXT) +extend_dset_OBJECTS = $(am_extend_dset_OBJECTS) +extend_dset_LDADD = $(LDADD) +extend_dset_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TOOLS) $(LIBHDF5) +am_h5watch_OBJECTS = h5watch.$(OBJEXT) +h5watch_OBJECTS = $(am_h5watch_OBJECTS) +h5watch_LDADD = $(LDADD) +h5watch_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TOOLS) $(LIBHDF5) +h5watch_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(h5watch_LDFLAGS) \ + $(LDFLAGS) -o $@ +am_h5watchgentest_OBJECTS = h5watchgentest.$(OBJEXT) +h5watchgentest_OBJECTS = $(am_h5watchgentest_OBJECTS) +h5watchgentest_LDADD = $(LDADD) +h5watchgentest_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TOOLS) $(LIBHDF5) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src +depcomp = $(SHELL) $(top_srcdir)/bin/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(extend_dset_SOURCES) $(h5watch_SOURCES) \ + $(h5watchgentest_SOURCES) +DIST_SOURCES = $(extend_dset_SOURCES) $(h5watch_SOURCES) \ + $(h5watchgentest_SOURCES) +ETAGS = etags +CTAGS = ctags +am__tty_colors = \ +red=; grn=; lgn=; blu=; std= +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = /home1/packages/automake/automake-1.9.6/bin/aclocal-1.9 -I /afs/ncsa/projects/hdf/packages/libtool_1.5.14/Linux_2.4/share/aclocal +ADD_PARALLEL_FILES = @ADD_PARALLEL_FILES@ +AMTAR = @AMTAR@ + +# H5_CFLAGS holds flags that should be used when building hdf5, +# but which should not be exported to h5cc for building other programs. +# AM_CFLAGS is an automake construct which should be used by Makefiles +# instead of CFLAGS, as CFLAGS is reserved solely for the user to define. +AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ +AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ +AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@ +AM_LDFLAGS = @AM_LDFLAGS@ +AM_MAKEFLAGS = @AM_MAKEFLAGS@ +AR = @AR@ + +# Set the paths for AFS installs of autotools for Linux machines +# Ideally, these tools should never be needed during the build. +AUTOCONF = /home1/packages/autoconf/autoconf-2.60/bin/autoconf +AUTOHEADER = /home1/packages/autoconf/autoconf-2.60/bin/autoheader +AUTOMAKE = /home1/packages/automake/automake-1.9.6/bin/automake-1.9 +AWK = @AWK@ +BYTESEX = @BYTESEX@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CC_VERSION = @CC_VERSION@ +CFLAGS = @CFLAGS@ +CLEARFILEBUF = @CLEARFILEBUF@ +CODESTACK = @CODESTACK@ +CONFIG_DATE = @CONFIG_DATE@ +CONFIG_MODE = @CONFIG_MODE@ +CONFIG_USER = @CONFIG_USER@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CXX_VERSION = @CXX_VERSION@ +CYGPATH_W = @CYGPATH_W@ +DEBUG_PKG = @DEBUG_PKG@ +DEFAULT_API_VERSION = @DEFAULT_API_VERSION@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@ +DIRECT_VFD = @DIRECT_VFD@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +DYNAMIC_DIRS = @DYNAMIC_DIRS@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTERNAL_FILTERS = @EXTERNAL_FILTERS@ + +# Make sure that these variables are exported to the Makefiles +F9XMODEXT = @F9XMODEXT@ +F9XMODFLAG = @F9XMODFLAG@ +F9XSUFFIXFLAG = @F9XSUFFIXFLAG@ +FC = @FC@ +FCFLAGS = @FCFLAGS@ +FCFLAGS_f90 = @FCFLAGS_f90@ +FCLIBS = @FCLIBS@ +FC_VERSION = @FC_VERSION@ +FGREP = @FGREP@ +FILTERS = @FILTERS@ +FSEARCH_DIRS = @FSEARCH_DIRS@ +GPFS = @GPFS@ +GREP = @GREP@ +H5_CFLAGS = @H5_CFLAGS@ +H5_CPPFLAGS = @H5_CPPFLAGS@ +H5_CXXFLAGS = @H5_CXXFLAGS@ +H5_FCFLAGS = @H5_FCFLAGS@ +H5_LONE_COLON = @H5_LONE_COLON@ +H5_VERSION = @H5_VERSION@ +HADDR_T = @HADDR_T@ +HAVE_DMALLOC = @HAVE_DMALLOC@ +HDF5_HL = @HDF5_HL@ +HDF5_INTERFACES = @HDF5_INTERFACES@ +HDF_CXX = @HDF_CXX@ +HDF_FORTRAN = @HDF_FORTRAN@ +HID_T = @HID_T@ +HL = @HL@ +HL_FOR = @HL_FOR@ +HSIZE_T = @HSIZE_T@ +HSSIZE_T = @HSSIZE_T@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTRUMENT = @INSTRUMENT@ +INSTRUMENT_LIBRARY = @INSTRUMENT_LIBRARY@ +LARGEFILE = @LARGEFILE@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LL_PATH = @LL_PATH@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_STATIC_EXEC = @LT_STATIC_EXEC@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MPE = @MPE@ +MPI_GET_SIZE = @MPI_GET_SIZE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJECT_NAMELEN_DEFAULT_F = @OBJECT_NAMELEN_DEFAULT_F@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PARALLEL = @PARALLEL@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PTHREAD = @PTHREAD@ +RANLIB = @RANLIB@ +ROOT = @ROOT@ +RUNPARALLEL = @RUNPARALLEL@ +RUNSERIAL = @RUNSERIAL@ +R_INTEGER = @R_INTEGER@ +R_LARGE = @R_LARGE@ +SEARCH = @SEARCH@ +SED = @SED@ +SETX = @SETX@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T = @SIZE_T@ +STATIC_EXEC = @STATIC_EXEC@ +STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ +STRIP = @STRIP@ +TESTPARALLEL = @TESTPARALLEL@ +THREADSAFE = @THREADSAFE@ +TIME = @TIME@ +TR = @TR@ +TRACE_API = @TRACE_API@ +UNAME_INFO = @UNAME_INFO@ +USE_FILTER_DEFLATE = @USE_FILTER_DEFLATE@ +USE_FILTER_FLETCHER32 = @USE_FILTER_FLETCHER32@ +USE_FILTER_NBIT = @USE_FILTER_NBIT@ +USE_FILTER_SCALEOFFSET = @USE_FILTER_SCALEOFFSET@ +USE_FILTER_SHUFFLE = @USE_FILTER_SHUFFLE@ +USE_FILTER_SZIP = @USE_FILTER_SZIP@ +USINGMEMCHECKER = @USINGMEMCHECKER@ +VERSION = @VERSION@ +WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +ac_ct_FC = @ac_ct_FC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ + +# Install directories that automake doesn't know about +docdir = $(exec_prefix)/doc +dvidir = @dvidir@ +enable_shared = @enable_shared@ +enable_static = @enable_static@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ + +# Shell commands used in Makefiles +RM = rm -f +CP = cp + +# Some machines need a command to run executables; this is that command +# so that our tests will run. +# We use RUNEXEC instead of RUNSERIAL directly because it may be that +# some tests need to be run with a different command. Older versions +# of the makefiles used the command +# $(LIBTOOL) --mode=execute +# in some directories, for instance. +RUNEXEC = $(RUNSERIAL) + +# Libraries to link to while building +LIBHDF5 = $(top_builddir)/src/libhdf5.la +LIBH5TEST = $(top_builddir)/test/libh5test.la +LIBH5F = $(top_builddir)/fortran/src/libhdf5_fortran.la +LIBH5FTEST = $(top_builddir)/fortran/test/libh5test_fortran.la +LIBH5CPP = $(top_builddir)/c++/src/libhdf5_cpp.la +LIBH5TOOLS = $(top_builddir)/tools/lib/libh5tools.la +LIBH5_HL = $(top_builddir)/hl/src/libhdf5_hl.la +LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la +LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la + +# Note that in svn revision 19400 the '/' after DESTDIR in H5* variables below +# has been removed. According to the official description of DESTDIR by Gnu at +# http://www.gnu.org/prep/standards/html_node/DESTDIR.html, DESTDIR is +# prepended to the normal and complete install path that it precedes for the +# purpose of installing in a temporary directory which is useful for building +# rpms and other packages. The '/' after ${DESTDIR} will be followed by another +# '/' at the beginning of the normal install path. When DESTDIR is empty the +# path then begins with '//', which is incorrect and causes problems at least for +# Cygwin. + +# Scripts used to build examples +# If only shared libraries have been installed, have h5cc build examples with +# shared libraries instead of static libraries +H5CC = ${DESTDIR}$(bindir)/h5cc +H5CC_PP = ${DESTDIR}$(bindir)/h5pcc +H5FC = ${DESTDIR}$(bindir)/h5fc +H5FC_PP = ${DESTDIR}$(bindir)/h5pfc +H5CPP = ${DESTDIR}$(bindir)/h5c++ +ACLOCAL_AMFLAGS = "-I m4" + +# The trace script; this is used on source files from the C library to +# insert tracing macros. +TRACE = perl $(top_srcdir)/bin/trace + +# .chkexe files are used to mark tests that have run successfully. +# .chklog files are output from those tests. +# *.clog are from the MPE option. +CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.h5 + +# Include src and tools/lib directories +INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/tools/lib -I$(top_srcdir)/hl/src + +# These are our main targets, the tools +#TEST_PROG=h5watchgentest +TEST_SCRIPT = testh5watch.sh +#check_PROGRAMS=h5watchgentest +check_SCRIPTS = $(TEST_SCRIPT) +SCRIPT_DEPEND = h5watch$(EXEEXT) + +# Add h5watch specific linker flags here +h5watch_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) +h5watch_SOURCES = h5watch.c + +#gen_onetwo_test_SOURCES=gen_onetwo_test.c +h5watchgentest_SOURCES = h5watchgentest.c +extend_dset_SOURCES = extend_dset.c +#extend_one_SOURCES=extend_one.c +#extend_two_SOURCES=extend_two.c + +# Programs all depend on the hdf5 library, the tools library, and the HL +# library. +LDADD = $(LIBH5_HL) $(LIBH5TOOLS) $(LIBHDF5) +DISTCLEANFILES = testh5watch.sh + +# Automake needs to be taught how to build lib, progs, and tests targets. +# These will be filled in automatically for the most part (e.g., +# lib_LIBRARIES are built for lib target), but EXTRA_LIB, EXTRA_PROG, and +# EXTRA_TEST variables are supplied to allow the user to force targets to +# be built at certain times. +LIB = $(lib_LIBRARIES) $(lib_LTLIBRARIES) $(noinst_LIBRARIES) \ + $(noinst_LTLIBRARIES) $(check_LIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LIB) + +PROGS = $(bin_PROGRAMS) $(bin_SCRIPTS) $(noinst_PROGRAMS) $(noinst_SCRIPTS) \ + $(EXTRA_PROG) + +TEST_PROG_CHKEXE = $(TEST_PROG:=.chkexe_) +TEST_PROG_PARA_CHKEXE = $(TEST_PROG_PARA:=.chkexe_) +TEST_SCRIPT_CHKSH = $(TEST_SCRIPT:=.chkexe_) +TEST_SCRIPT_PARA_CHKSH = $(TEST_SCRIPT_PARA:=.chkexe_) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/conclude.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hl/tools/h5watch/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign hl/tools/h5watch/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +testh5watch.sh: $(top_builddir)/config.status $(srcdir)/testh5watch.sh.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +extend_dset$(EXEEXT): $(extend_dset_OBJECTS) $(extend_dset_DEPENDENCIES) + @rm -f extend_dset$(EXEEXT) + $(LINK) $(extend_dset_OBJECTS) $(extend_dset_LDADD) $(LIBS) +h5watch$(EXEEXT): $(h5watch_OBJECTS) $(h5watch_DEPENDENCIES) + @rm -f h5watch$(EXEEXT) + $(h5watch_LINK) $(h5watch_OBJECTS) $(h5watch_LDADD) $(LIBS) +h5watchgentest$(EXEEXT): $(h5watchgentest_OBJECTS) $(h5watchgentest_DEPENDENCIES) + @rm -f h5watchgentest$(EXEEXT) + $(LINK) $(h5watchgentest_OBJECTS) $(h5watchgentest_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extend_dset.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5watch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5watchgentest.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_SCRIPTS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(PROGRAMS) all-local +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool \ + clean-noinstPROGRAMS mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool mostlyclean-local + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS all all-am all-local check check-TESTS check-am \ + clean clean-binPROGRAMS clean-generic clean-libtool \ + clean-noinstPROGRAMS ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + mostlyclean-local pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS + + +# List all build rules defined by HDF5 Makefiles as "PHONY" targets here. +# This tells the Makefiles that these targets are not files to be built but +# commands that should be executed even if a file with the same name already +# exists. +.PHONY: build-check-clean build-check-p build-check-s build-lib build-progs \ + build-tests check-clean check-install check-p check-s check-vfd \ + install-doc lib progs tests uninstall-doc _exec_check-s _test help + +help: + @$(top_srcdir)/bin/makehelp + +# lib/progs/tests targets recurse into subdirectories. build-* targets +# build files in this directory. +build-lib: $(LIB) +build-progs: $(LIB) $(PROGS) +build-tests: $(LIB) $(PROGS) $(TESTS) + +# General rule for recursive building targets. +# BUILT_SOURCES contain targets that need to be built before anything else +# in the directory (e.g., for Fortran type detection) +lib progs tests check-s check-p :: $(BUILT_SOURCES) + @$(MAKE) $(AM_MAKEFLAGS) build-$@ || exit 1; + @for d in X $(SUBDIRS); do \ + if test $$d != X && test $$d != .; then \ + (set -x; cd $$d && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1; \ + fi; \ + done + +# General rule for recursive cleaning targets. Like the rule above, +# but doesn't require building BUILT_SOURCES. +check-clean :: + @$(MAKE) $(AM_MAKEFLAGS) build-$@ || exit 1; + @for d in X $(SUBDIRS); do \ + if test $$d != X && test $$d != .; then \ + (set -x; cd $$d && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1; \ + fi; \ + done + +# Tell Automake to build tests when the user types `make all' (this is +# not its default behavior). Also build EXTRA_LIB and EXTRA_PROG since +# Automake won't build them automatically, either. +all-local: $(EXTRA_LIB) $(EXTRA_PROG) $(TESTS) + +# make install-doc doesn't do anything outside of doc directory, but +# Makefiles should recognize it. +# UPDATE: docs no longer reside in this build tree, so this target +# is depreciated. +install-doc uninstall-doc: + @echo "Nothing to be done." + +# clean up files generated by tests so they can be re-run. +build-check-clean: + $(RM) -rf $(CHECK_CLEANFILES) + +# run check-clean whenever mostlyclean is run +mostlyclean-local: build-check-clean + +# check-install is just a synonym for installcheck +check-install: installcheck + +# Run each test in order, passing $(TEST_FLAGS) to the program. +# Since tests are done in a shell loop, "make -i" does apply inside it. +# Set HDF5_Make_Ignore to a non-blank string to ignore errors inside the loop. +# The timestamps give a rough idea how much time the tests use. +# +# Note that targets in TESTS (defined above) will be built when the user +# types 'make tests' or 'make check', but only programs in TEST_PROG, +# TEST_PROG_PARA, or TEST_SCRIPT will actually be executed. +check-TESTS: test + +test _test: + @$(MAKE) build-check-s + @$(MAKE) build-check-p + +# Actual execution of check-s. +build-check-s: $(LIB) $(PROGS) $(TESTS) + @if test -n "$(TEST_PROG)$(TEST_SCRIPT)"; then \ + echo "===Serial tests in `echo ${PWD} | sed -e s:.*/::` begin `date`==="; \ + fi + @$(MAKE) $(AM_MAKEFLAGS) _exec_check-s + @if test -n "$(TEST_PROG)$(TEST_SCRIPT)"; then \ + echo "===Serial tests in `echo ${PWD} | sed -e s:.*/::` ended `date`===";\ + fi + +_exec_check-s: $(TEST_PROG_CHKEXE) $(TEST_SCRIPT_CHKSH) + +# The dummy.chkexe here prevents the target from being +# empty if there are no tests in the current directory. +# $${log} is the log file. +# $${tname} is the name of test. +$(TEST_PROG_CHKEXE) $(TEST_PROG_PARA_CHKEXE) dummy.chkexe_: + @if test "X$@" != "X.chkexe_" && test "X$@" != "Xdummy.chkexe_"; then \ + tname=$(@:.chkexe_=)$(EXEEXT);\ + log=$(@:.chkexe_=.chklog); \ + echo "============================"; \ + if $(top_srcdir)/bin/newer $(@:.chkexe_=.chkexe) $${tname}; then \ + echo "No need to test $${tname} again."; \ + else \ + echo "============================" > $${log}; \ + if test "X$(FORTRAN_API)" = "Xyes"; then \ + echo "Fortran API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ + echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ + elif test "X$(CXX_API)" = "Xyes"; then \ + echo "C++ API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ + echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log};\ + else \ + echo "Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ + echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ + fi; \ + echo "============================" >> $${log}; \ + srcdir="$(srcdir)" \ + $(TIME) $(RUNEXEC) ./$${tname} $(TEST_FLAGS) >> $${log} 2>&1 \ + && touch $(@:.chkexe_=.chkexe) || \ + (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ + (cat $${log} && false) || exit 1; \ + echo "" >> $${log}; \ + echo "Finished testing $${tname} $(TEST_FLAGS)" >> $${log}; \ + echo "============================" >> $${log}; \ + echo "Finished testing $${tname} $(TEST_FLAGS)"; \ + cat $${log}; \ + fi; \ + fi + +# The dummysh.chkexe here prevents the target from being +# empty if there are no tests in the current directory. +# $${log} is the log file. +# $${tname} is the name of test. +$(TEST_SCRIPT_CHKSH) $(TEST_SCRIPT_PARA_CHKSH) dummysh.chkexe_: + @if test "X$@" != "X.chkexe_" && test "X$@" != "Xdummysh.chkexe_"; then \ + cmd=$(@:.chkexe_=);\ + tname=`basename $$cmd`;\ + chkname=`basename $(@:.chkexe_=.chkexe)`;\ + log=`basename $(@:.chkexe_=.chklog)`; \ + echo "============================"; \ + if $(top_srcdir)/bin/newer $${chkname} $$cmd $(SCRIPT_DEPEND); then \ + echo "No need to test $${tname} again."; \ + else \ + echo "============================" > $${log}; \ + if test "X$(FORTRAN_API)" = "Xyes"; then \ + echo "Fortran API: Testing $${tname} $(TEST_FLAGS)"; \ + echo "Fortran API: $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ + elif test "X$(CXX_API)" = "Xyes"; then \ + echo "C++ API: Testing $${tname} $(TEST_FLAGS)"; \ + echo "C++ API: $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ + else \ + echo "Testing $${tname} $(TEST_FLAGS)"; \ + echo "$${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ + fi; \ + echo "============================" >> $${log}; \ + RUNSERIAL="$(RUNSERIAL)" RUNPARALLEL="$(RUNPARALLEL)" \ + srcdir="$(srcdir)" \ + $(TIME) $(SHELL) $$cmd $(TEST_FLAGS) >> $${log} 2>&1 \ + && touch $${chkname} || \ + (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ + (cat $${log} && false) || exit 1; \ + echo "" >> $${log}; \ + echo "Finished testing $${tname} $(TEST_FLAGS)" >> $${log}; \ + echo "============================" >> $${log}; \ + echo "Finished testing $${tname} $(TEST_FLAGS)"; \ + cat $${log}; \ + fi; \ + echo "============================"; \ + fi + +# Actual execution of check-p. +build-check-p: $(LIB) $(PROGS) $(TESTS) + @if test -n "$(TEST_PROG_PARA)$(TEST_SCRIPT_PARA)"; then \ + echo "===Parallel tests in `echo ${PWD} | sed -e s:.*/::` begin `date`==="; \ + fi + @if test -n "$(TEST_PROG_PARA)"; then \ + echo "**** Hint ****"; \ + echo "Parallel test files reside in the current directory" \ + "by default."; \ + echo "Set HDF5_PARAPREFIX to use another directory. E.g.,"; \ + echo " HDF5_PARAPREFIX=/PFS/user/me"; \ + echo " export HDF5_PARAPREFIX"; \ + echo " make check"; \ + echo "**** end of Hint ****"; \ + fi + @for test in $(TEST_PROG_PARA) dummy; do \ + if test $$test != dummy; then \ + $(MAKE) $(AM_MAKEFLAGS) $$test.chkexe_ \ + RUNEXEC="$(RUNPARALLEL)" || exit 1; \ + fi; \ + done + @for test in $(TEST_SCRIPT_PARA) dummy; do \ + if test $$test != dummy; then \ + $(MAKE) $(AM_MAKEFLAGS) $$test.chkexe_ || exit 1; \ + fi; \ + done + @if test -n "$(TEST_PROG_PARA)$(TEST_SCRIPT_PARA)"; then \ + echo "===Parallel tests in `echo ${PWD} | sed -e s:.*/::` ended `date`===";\ + fi + +# Run test with different Virtual File Driver +check-vfd: $(LIB) $(PROGS) $(TESTS) + @for vfd in $(VFD_LIST) dummy; do \ + if test $$vfd != dummy; then \ + echo "============================"; \ + echo "Testing Virtual File Driver $$vfd"; \ + echo "============================"; \ + $(MAKE) $(AM_MAKEFLAGS) check-clean || exit 1; \ + HDF5_DRIVER=$$vfd $(MAKE) $(AM_MAKEFLAGS) check || exit 1; \ + fi; \ + done + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/hl/tools/h5watch/WATCH.h5 b/hl/tools/h5watch/WATCH.h5 new file mode 100644 index 0000000..add819d Binary files /dev/null and b/hl/tools/h5watch/WATCH.h5 differ diff --git a/hl/tools/h5watch/extend_dset.c b/hl/tools/h5watch/extend_dset.c new file mode 100644 index 0000000..61cc09f --- /dev/null +++ b/hl/tools/h5watch/extend_dset.c @@ -0,0 +1,380 @@ +#include "H5HLprivate2.h" +#include +#include +#include +#include +#include + +/* + * Extending datasets in WATCH.h5 generated by h5watchgentest.c + */ +#define DSET_ONE "DSET_ONE" +#define DSET_TWO "DSET_TWO" +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" + +#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" +#define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" + +/* Size of data buffer */ +#define TEST_BUF_SIZE 100 + +/* + * Test variations (incremental) for one-dimensional dataset: + * Varies from 10->13->12->12->1->3 + */ +#define ONE_NTESTS 5 +int one_tests[ONE_NTESTS] = {3, -1, 0, -11, 2}; + +/* + * Test variations (incremental) for two-dimensional dataset: + * Varies from {4,10}->{6,12}->{8,1}->{10,1}-> + * {3,3}->{2,2}->{1,2}-> + * {1,4}->{1,3}->{1,3} + */ +#define TWO_NTESTS 9 +int two_tests[TWO_NTESTS][2] = { {2, 2}, {2, -11}, {2, 0}, + {-7, 2}, {-1, -1}, {-1, 0}, + {0, 2}, {0, -1}, {0, 0} + }; + +static int extend_dset_two(const char *file, char *dname); +static int extend_dset_one(const char *file, char *dname); + +/* Data structures for datasets with compound data type */ +typedef struct sub22_t { + unsigned int a; + unsigned int b; + unsigned int c; +} sub22_t; + +typedef struct sub2_t { + unsigned int a; + sub22_t b; + unsigned int c; +} sub2_t; + +typedef struct sub4_t { + unsigned int a; + unsigned int b; +} sub4_t; + +typedef struct set_t { + unsigned int field1; + sub2_t field2; + double field3; + sub4_t field4; +} set_t; + +/* + *********************************************************************** + * + * Extending a two-dimensional dataset: + * dims[0] dims[1] + * ------- ------- + * case #1: increase increase + * case #2: increase decrease + * case #3: increase same + * case #4: decrease increase + * case #5: decrease decrease (no action) + * case #6: decrease same (no action) + * case #7: same increase + * case #8: same decrease (no action) + * case #9: same same (no action) + * + * two_tests[TWO_NTESTS][2] = { {2,2}, {2,-11}, {2,0}, + * {-7,2}, {-1,-1}, {-1,0}, + * {0,2}, {0,-1}, {0,0} } + * varies from {4,10}->{6,12}->{8,1}->{10,1}-> + * {3,3}->{2,2}->{1,2}-> + * {1,4}->{1,3}->{1,3} + *********************************************************************** + */ +static int +extend_dset_two(const char *file, char *dname) +{ + hid_t fid; /* file id */ + hid_t did; /* dataset id */ + hid_t sid; /* dataspace id */ + hid_t dtid; /* dataset's datatype id */ + int ndims; /* # of dimension sizes */ + unsigned i, j; /* local index variable */ + hsize_t ext_dims[2]; /* new dimension sizes after extension */ + hsize_t cur_dims[2]; /* current dimension sizes */ + size_t dtype_size; /* size of the dataset's datatype */ + unsigned num_elmts; /* number of elements in the dataset */ + int ibuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elements (integer) */ + set_t cbuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elemnets (compound) */ + + /* Open the file and dataset */ + if((fid = H5Fopen(file, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + goto done; + + if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + goto done; + + if((sid = H5Dget_space(did)) < 0) + goto done; + + if((ndims = H5Sget_simple_extent_ndims(sid)) < 0) + goto done; + + /* Get the size of the dataset's datatype */ + if((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0) + goto done; + + /* Get the dataset's data type */ + if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + goto done; + + /* Loop through different variations of extending the dataset */ + for(i = 0; i < TWO_NTESTS; i++) { + + /* sleep to emulate about 2 seconds of application operation */ + sleep(2); + + /* Get current dimension sizes */ + if(H5LDget_dset_dims(did, cur_dims) < 0) + goto done; + + /* Set up the new extended dimension sizes */ + ext_dims[0] = cur_dims[0] + two_tests[i][0]; + ext_dims[1] = cur_dims[1] + two_tests[i][1]; + + /* Extend the dataset */ + if(H5Dset_extent(did, ext_dims) < 0) + goto done; + + num_elmts = 1; + for(j = 0; j < (unsigned)ndims; j++) + num_elmts *= ext_dims[j]; + + /* Compound type */ + if(!HDstrcmp(dname, DSET_CMPD_TWO)) { + + HDmemset(cbuf, 0, sizeof(cbuf)); + for(j = 0; j < num_elmts; j++) { + cbuf[j].field1 = i + 1; + cbuf[j].field2.a = i + 1; + cbuf[j].field2.c = i + 1; + cbuf[j].field2.b.a = i + 1; + cbuf[j].field2.b.b = i + 1; + cbuf[j].field2.b.c = i + 1; + cbuf[j].field3 = i + 1; + cbuf[j].field4.a = i + 1; + cbuf[j].field4.b = i + 1; + } + + /* Write to the dataset */ + if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) + goto done; + } else { /* Integer type */ + HDmemset(ibuf, 0, sizeof(ibuf)); + for(j = 0; j < num_elmts; j++) + ibuf[j] = i + 1; + + /* Write to the dataset */ + if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) + goto done; + } + + if(H5Dflush(did) < 0) + goto done; + + } /* end for TWO_NTESTS */ + + /* Closing */ + if(H5Tclose(dtid) < 0) goto done; + if(H5Dclose(did) < 0) goto done; + if(H5Fclose(fid) < 0) goto done; + + return(SUCCEED); + +done: + H5E_BEGIN_TRY + H5Tclose(dtid); + H5Dclose(did); + H5Fclose(fid); + H5E_END_TRY + + return(FAIL); + +} /* extend_dset_two() */ + +/* + *********************************************************************** + * + * Extending a one-dimensional dataset + * Test cases: + * #1: increase + * #2: decrease + * #3: same + * #4: decrease + * #5: increase + * + * one_tests[ONE_NTESTS] = {3, -1, 0, -11, 2} + * varies from 10->13->12->12->1->3 + * + *********************************************************************** + */ +static int +extend_dset_one(const char *file, char *dname) +{ + hid_t fid; /* file id */ + hid_t did; /* dataset id */ + hid_t dtid; /* dataset's datatype id */ + hid_t sid; /* dataspace id */ + hid_t mid; /* memory space id */ + unsigned i, j; /* local index variable */ + int ibuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elements (integer) */ + set_t cbuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elemnets (compound) */ + hsize_t cur_dims[1]; /* current dimension sizes */ + hsize_t ext_dims[1]; /* new dimension sizes after extension */ + hsize_t offset[1]; /* starting offsets of appended data */ + hsize_t count[1]; /* dimension sizes of appended data */ + size_t dtype_size; /* size of the dataset's datatype */ + + /* Open the file and dataset */ + if((fid = H5Fopen(file, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + goto done; + + if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + goto done; + + /* Get size of the dataset's datatype */ + if((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0) + goto done; + + /* Get dataset's datatype */ + if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + goto done; + + /* Loop through different variations of extending the dataset */ + for(i = 0; i < ONE_NTESTS; i++) { + + /* sleep to emulate about 2 seconds of application operation */ + sleep(2); + + /* Get current dimension sizes */ + if(H5LDget_dset_dims(did, cur_dims) < 0) + goto done; + + /* Set up the new extended dimension sizes */ + ext_dims[0] = cur_dims[0] + one_tests[i]; + + /* Extend the dataset */ + if(H5Dset_extent(did, ext_dims) < 0) + goto done; + + /* Write to the new appended region of the dataset */ + if(one_tests[i] > 0) { + + /* Select the extended region */ + offset[0] = cur_dims[0]; + count[0] = one_tests[i]; + if((sid = H5Dget_space(did)) < 0) + goto done; + if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + goto done; + + /* Set up memory space and get dataset's datatype */ + if((mid = H5Screate_simple(1, count, NULL)) < 0) + goto done; + + /* Initialize data for the extended region of the dataset */ + /* Compound type */ + if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + HDmemset(cbuf, 0, sizeof(cbuf)); + for(j = 0; j < (unsigned)one_tests[i]; j++) { + cbuf[j].field1 = j + 1; + cbuf[j].field2.a = j + 2; + cbuf[j].field2.b.a = j + 2; + cbuf[j].field2.b.b = j + 2; + cbuf[j].field2.b.c = j + 2; + cbuf[j].field2.c = j + 2; + + cbuf[j].field3 = j + 3; + + cbuf[j].field4.a = j + 4; + cbuf[j].field4.b = j + 4; + } /* end for */ + + /* Write to the extended region of the dataset */ + if(H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, cbuf) < 0) + goto done; + } else { /* Integer type */ + for(j = 0; j < (unsigned)one_tests[i]; j++) + ibuf[j] = j; + + /* Write to the extended region of the dataset */ + if(H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, ibuf) < 0) + goto done; + } + + /* Closing */ + if(H5Sclose(sid) < 0) goto done; + if(H5Sclose(mid) < 0) goto done; + } /* end if */ + + if(H5Dflush(did) < 0) + goto done; + + } /* end for ONE_NTESTS */ + + /* Closing */ + if(H5Tclose(dtid) < 0) goto done; + if(H5Dclose(did) < 0) goto done; + if(H5Fclose(fid) < 0) goto done; + + return(SUCCEED); + +done: + H5E_BEGIN_TRY + H5Sclose(sid); + H5Sclose(mid); + H5Tclose(dtid); + H5Dclose(did); + H5Fclose(fid); + H5E_END_TRY + + return(FAIL); +} /* extend_dset_one() */ + +/* Usage: extend_dset xx.h5 dname */ +int +main(int argc, const char *argv[]) +{ + char *dname = NULL; + char *fname = NULL; + + if(argc != 3) { + fprintf(stderr, "Should have file name and dataset name to be extended...\n"); + goto done; + } + + /* Get the dataset name to be extended */ + fname = strdup(argv[1]); + dname = strdup(argv[2]); + + if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + if(extend_dset_one(fname, dname) < 0) goto done; + } else if(!HDstrcmp(dname, DSET_ONE) || + !HDstrcmp(dname, DSET_ALLOC_LATE) || + !HDstrcmp(dname, DSET_ALLOC_EARLY)) { + if(extend_dset_one(fname, dname) < 0) + goto done; + } else if(!HDstrcmp(dname, DSET_TWO) || !HDstrcmp(dname, DSET_CMPD_TWO)) { + if(extend_dset_two(fname, dname) < 0) + goto done; + } else { + fprintf(stdout, "Dataset cannot be extended...\n"); + goto done; + } + exit(EXIT_SUCCESS); + +done: + if(dname) HDfree(dname); + if(fname) HDfree(fname); + exit(EXIT_FAILURE); +} /* main() */ diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c new file mode 100644 index 0000000..c9dfcf6 --- /dev/null +++ b/hl/tools/h5watch/h5watch.c @@ -0,0 +1,917 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include +#include +#include +#include +#include +#include + +#include "h5tools.h" +#include "h5tools_utils.h" +#include "h5tools_ref.h" +#include "h5trav.h" +#include "H5LDprivate.h" + +/* + * Note: This tool used private routine + */ +#define PROGRAMNAME "h5watch" /* Name of tool */ +#define FIELD_SEP "," /* nested field separator */ +#define DEFAULT_RETRY 10 /* number of times to try opening the file */ + +/* + * Note:(see comments in hl/src/H5LDprivate.h) + * This tool uses private routines H5LD_construct_vector()and H5LD_clean_vector() + * This tool uses H5LD_memb_t data structure declared in H5LDprivate.h + */ + +const char *progname = "h5watch"; /* tool name */ +static char *g_list_of_fields = NULL; /* command line input for "list_of_fields" */ +static char *g_dup_fields = NULL; /* copy of "list_of_fields" */ +static H5LD_memb_t **g_listv = NULL; /* vector info for "list_of_fields" */ + +static hbool_t g_monitor_size_only = FALSE; /* monitor changes in dataset dimension sizes */ +static unsigned g_polling_interval = 1; /* polling interval to check appended data */ +static hbool_t g_label = FALSE; /* label compound values */ +static int g_display_width = 80; /* output width in characters */ +static hbool_t g_simple_output = FALSE; /* make output more machine-readable */ +static unsigned g_retry = DEFAULT_RETRY; /* # of times to try opening the file if somehow file is unstable */ +static hbool_t g_display_hex = FALSE; /* display data in hexadecimal format : LATER */ + +static herr_t doprint(hid_t did, hsize_t *start, hsize_t *block, int rank); +static herr_t slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, + hsize_t *start, hsize_t *block, int rank, int subrank); +static herr_t monitor_dataset(hid_t fid, char *dsetname); +static herr_t process_cmpd_fields(hid_t fid, char *dsetname); +static herr_t check_dataset(hid_t fid, char *dsetname); +static void leave(int ret); +static void usage(const char *prog); +static void parse_command_line(int argc, const char *argv[]); + + +/* + * Command-line options: The user can only specify long-named parameters. + * The long-named ones can be partially spelled. When + * adding more, make sure that they don't clash with each other. + */ +static struct long_options l_opts[] = { + { "help", no_arg, 'h' }, + { "hel", no_arg, 'h' }, + { "dim", no_arg, 'd' }, + { "di", no_arg, 'd' }, + { "label", no_arg, 'l' }, + { "labe", no_arg, 'l' }, + { "lab", no_arg, 'l' }, + { "la", no_arg, 'l' }, + { "simple", no_arg, 'S' }, + { "simpl", no_arg, 'S' }, + { "simp", no_arg, 'S' }, + { "sim", no_arg, 'S' }, + { "si", no_arg, 'S' }, + { "hexdump", no_arg, 'x' }, + { "hexdum", no_arg, 'x' }, + { "hexdu", no_arg, 'x' }, + { "hexd", no_arg, 'x' }, + { "hex", no_arg, 'x' }, + { "width", require_arg, 'w' }, + { "widt", require_arg, 'w' }, + { "wid", require_arg, 'w' }, + { "wi", require_arg, 'w' }, + { "polling", require_arg, 'p' }, + { "pollin", require_arg, 'p' }, + { "polli", require_arg, 'p' }, + { "poll", require_arg, 'p' }, + { "pol", require_arg, 'p' }, + { "po", require_arg, 'p' }, + { "fields", require_arg, 'f' }, + { "field", require_arg, 'f' }, + { "fiel", require_arg, 'f' }, + { "fie", require_arg, 'f' }, + { "fi", require_arg, 'f' }, + { "version", no_arg, 'V' }, + { "versio", no_arg, 'V' }, + { "versi", no_arg, 'V' }, + { "vers", no_arg, 'V' }, + { "ver", no_arg, 'V' }, + { "ve", no_arg, 'V' }, + { NULL, 0, '\0' } +}; + + +/*------------------------------------------------------------------------- + * Function: doprint() + * + * Purpose: Prepare to print the dataset's appended data. + * Call the tools library routine h5tools_dump_dset() to do the printing. + * (This routine is mostly copied from dump_dataset_values() in tools/h5ls/h5ls.c + * and modified accordingly). + * + * Return: 0 on success; negative on failure + * + * Programmer: Vailin Choi; August 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) +{ + h5tool_format_t info; /* Format info for the tools library */ + static char fmt_double[16], fmt_float[16]; /* Format info */ + struct subset_t subset; /* Subsetting info */ + hsize_t ss_start[H5S_MAX_RANK]; /* Info for hyperslab */ + hsize_t ss_stride[H5S_MAX_RANK]; /* Info for hyperslab */ + hsize_t ss_block[H5S_MAX_RANK]; /* Info for hyperslab */ + hsize_t ss_count[H5S_MAX_RANK]; /* Info for hyperslab */ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Subsetting information for the tools library printing routines */ + subset.start.data = ss_start; + subset.stride.data = ss_stride; + subset.block.data = ss_block; + subset.count.data = ss_count; + + /* Initialize subsetting information */ + for(i = 0; i < rank; i++) { + subset.stride.data[i] = 1; + subset.count.data[i] = 1; + subset.start.data[i] = start[i]; + subset.block.data[i] = block[i]; + } + + /* Set to all default values and then override */ + HDmemset(&info, 0, sizeof info); + + if(g_simple_output) { + info.idx_fmt = ""; + info.line_ncols = 65535; /*something big*/ + info.line_per_line = 1; + info.line_multi_new = 0; + info.line_pre = " "; + info.line_cont = " "; + + info.arr_pre = ""; + info.arr_suf = ""; + info.arr_sep = " "; + + info.cmpd_pre = ""; + info.cmpd_suf = ""; + info.cmpd_sep = " "; + + /* The "fields" selected by the user */ + info.cmpd_listv = (const struct H5LD_memb_t **)g_listv; + + if(g_label) info.cmpd_name = "%s="; + + info.elmt_suf1 = " "; + info.str_locale = ESCAPE_HTML; + + } else { + info.idx_fmt = "(%s)"; + if(!g_display_width) { + info.line_ncols = 65535; + info.line_per_line = 1; + } + else + info.line_ncols = g_display_width; + + info.line_multi_new = 1; + + /* The "fields" selected by the user */ + info.cmpd_listv = (const struct H5LD_memb_t **)g_listv; + if(g_label) info.cmpd_name = "%s="; + info.line_pre = " %s "; + info.line_cont = " %s "; + info.str_repeat = 8; + } + + /* Floating point types should display full precision */ + sprintf(fmt_float, "%%1.%dg", FLT_DIG); + info.fmt_float = fmt_float; + sprintf(fmt_double, "%%1.%dg", DBL_DIG); + info.fmt_double = fmt_double; + + info.dset_format = "DSET-%s "; + info.dset_hidefileno = 0; + + info.obj_format = "-%lu:"H5_PRINTF_HADDR_FMT; + info.obj_hidefileno = 0; + + info.dset_blockformat_pre = "%sBlk%lu: "; + info.dset_ptformat_pre = "%sPt%lu: "; + + info.line_indent = ""; + + if(g_display_hex) { + /* Print all data in hexadecimal format if the `-x' or `--hexdump' + * command line switch was given. */ + info.raw = TRUE; + } + + /* Print the values. */ + if((ret_value = h5tools_dump_dset(stdout, &info, did, -1, &subset, -1)) < 0) + error_msg("unable to print data\n"); + + return(ret_value); + +} /* doprint() */ + +/*------------------------------------------------------------------------- + * Function: slicendump + * + * Purpose: To dump the slice for each dimension + * For example: prev_dims[2] = {5, 4}; cur_dims[2] = {7, 8} + * This routine will dump data as follows: + * {0, 3} to {0, 7} (1x4 elements) + * {1, 3} to {0, 7} (1x4 elements) + * {2, 3} to {0, 7} (1x4 elements) + * {3, 3} to {0, 7} (1x4 elements) + * {4, 3} to {0, 7} (1x4 elements) + * {5, 0} to {6, 7} (2x8 elements) + * + * Return: Non-negative on success + * Negative on failure + * + * Programmer: Vailin Choi; August 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsize_t *block, int rank, int subrank) +{ + int i; /* Local index variable */ + int ind; /* Index for the current rank */ + herr_t ret_value = SUCCEED; /* Return value */ + + ind = rank - subrank; + + if((subrank - 1) > 0) { + /* continue onto the next dimension */ + for (i = 0; i < (hssize_t)MIN(prev_dims[ind], cur_dims[ind]); i++){ + start[ind] = (hsize_t)i; + if((ret_value = slicendump(did, prev_dims, cur_dims, start, block, rank, subrank-1)) < 0) + goto done; + } + } + + /* this dimension remains the same or shrinking */ + if(cur_dims[ind] <= prev_dims[ind]) + goto done; + + /* select first the slice for the faster changing dimension */ + /* select later the whole slice for the slower changing dimension */ + start[ind] = prev_dims[ind]; + block[ind] = cur_dims[ind] - prev_dims[ind]; + + for(i = ind + 1; i < rank; i++){ + start[i] = 0; + block[i] = cur_dims[i]; + } + + /* Print the appended data */ + ret_value = doprint(did, start, block, rank); + +done: + return(ret_value); +} /* slicendump() */ + + +/*------------------------------------------------------------------------- + * Function: monitor_dataset + * + * Purpose: To poll a dataset periodically for changes in dimension sizes. + * For dataset with unchanged and/or decreased dimension sizes: + * it just prints the dimension size changes + * For dataset with increase in at least one of its dimension sizes: + * it will print the new appended data to the dataset + * + * Return: Non-negative on success: dataset can be monitored + * Negative on failure: dataset cannot be monitored + * + * Programmer: Vailin Choi; August 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +monitor_dataset(hid_t fid, char *dsetname) +{ + char drivername[50];/* Driver's name for opening the file */ + hid_t did; /* dataset id */ + hid_t sid; /* dataspace id */ + int ndims; /* # of dimensions in the dataspace */ + int i, u; /* local index variable */ + hsize_t prev_dims[H5S_MAX_RANK]; /* current dataspace dimensions */ + hsize_t cur_dims[H5S_MAX_RANK]; /* previous dataspace dimensions */ + herr_t ret_value = SUCCEED; /* return value */ + + HDfprintf(stdout, "Monitoring dataset %s...\n", dsetname); + + /* Open the dataset for minitoring */ + if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { + error_msg("error in opening dataset \"%s\"\n", dsetname); + ret_value = FAIL; + goto done; + } + if((sid = H5Dget_space(did)) < 0) { + error_msg("error in getting dataspace id for dataset \"%s\"\n", dsetname); + ret_value = FAIL; + goto done; + } + + /* Get the dataset's dimension sizes */ + if((ndims = H5Sget_simple_extent_dims(sid, prev_dims, NULL)) < 0) { + error_msg("unable to get dimensions sizes for \"%s\"\n", dsetname); + ret_value = FAIL; + goto done; + } + + while(1) { + + /* Refreshes the dataset */ + if(H5Drefresh(did) < 0) { + ret_value = FAIL; + goto done; + } + + /* Get the dataset's current dimension sizes */ + if(H5LDget_dset_dims(did, cur_dims) < 0) { + error_msg("unable to get dimension sizes for \"%s\"\n", dsetname); + ret_value = FAIL; + goto done; + } + + /* Check the dimension sizes */ + for(i = 0; i < ndims; i++) + if(cur_dims[i] != prev_dims[i]) + break; + + /* at least one dimension has changed */ + if(i != ndims) { + /* Printing changes in dimension sizes */ + for(u = 0; u < ndims; u++) { + HDfprintf(stdout, "dimension %u: %Hu->%Hu", u, prev_dims[u], cur_dims[u]); + if(cur_dims[u] > prev_dims[u]) + HDfprintf(stdout, " (increases)\n"); + else if(cur_dims[u] < prev_dims[u]) + HDfprintf(stdout, " (decreases)\n"); + else + HDfprintf(stdout, " (unchanged)\n"); + } + + /* Printing elements appended to the dataset if there is */ + if(!g_monitor_size_only) { + + /* See if at least one dimension size has increased */ + for(u = 0; u < ndims; u++) { + int j; + hsize_t start[H5S_MAX_RANK]; + hsize_t block[H5S_MAX_RANK]; + + /* Print the new appended data to the dataset */ + if(cur_dims[u] > prev_dims[u]) { + HDfprintf(stdout, " Data:\n"); + + for(j = 0; j < ndims; j++) { + start[j] = 0; + block[j] = 1; + } + + if((ret_value = slicendump(did, prev_dims, cur_dims, start, block, ndims, ndims)) < 0) + goto done; + break; + } + } /* end for */ + } + HDfflush(stdout); + } + + /* Save the current dimension sizes */ + HDmemcpy(prev_dims, cur_dims, ndims * sizeof(hsize_t)); + + /* Sleep before next monitor */ + HDsleep(g_polling_interval); + } /* end while */ + +done: + /* Closing */ + H5E_BEGIN_TRY + H5Dclose(did); + H5E_END_TRY + + return(ret_value); +} /* monitor_dataset() */ + +/*------------------------------------------------------------------------- + * Function: process_cmpd_fields + * + * Purpose: To check whether the fields selected in "g_list_of_fields" + * are valid fields associated with the dataset. + * + * Return: 0 on success; negative on failure + * + * Programmer: Vailin Choi; August 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +process_cmpd_fields(hid_t fid, char *dsetname) +{ + hid_t did; /* dataset id */ + hid_t dtid, tid; /* dataset's data type id */ + size_t len; /* number of comma-separated fields in "g_list_of_fields" */ + herr_t ret_value = SUCCEED; /* Return value */ + + HDassert(g_list_of_fields && *g_list_of_fields); + + /* Open the dataset */ + if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { + error_msg("error in opening dataset \"%s\"\n", dsetname); + ret_value = FAIL; + goto done; + } + + /* Get the dataset's datatype */ + if(((dtid = H5Dget_type(did)) < 0) || (tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0) { + error_msg("error in getting dataset's datatype\n"); + ret_value = FAIL; + goto done; + } + + /* Check to make sure that the dataset's datatype is compound type */ + if(H5Tget_class(dtid) != H5T_COMPOUND) { + error_msg("dataset should be compound type for \n"); + ret_value = FAIL; + goto done; + } + + /* Make a copy of "g_list_of_fields" */ + if((g_dup_fields = HDstrdup(g_list_of_fields)) == NULL) { + error_msg("error in duplicating g_list_of_fields\n"); + ret_value = FAIL; + goto done; + } + + /* Estimate the number of comma-separated fields in "g_list of_fields" */ + len = HDstrlen(g_list_of_fields)/2 + 2; + + /* Allocate memory for a list vector of H5LD_memb_t structures to store "g_list_of_fields" info */ + if((g_listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))) == NULL) { + error_msg("error in allocating memory for H5LD_memb_t\n"); + ret_value = FAIL; + goto done; + } + + /* Process and store info for "g_listv" */ + if(H5LD_construct_vector(g_dup_fields, g_listv, tid) < 0) { + error_msg("error in processing \n"); + ret_value = FAIL; + goto done; + } + + /* Will free memory for g_listv and g_dup_fields when exiting from h5watch */ +done: + /* Closing */ + H5E_BEGIN_TRY + H5Tclose(dtid); + H5Tclose(tid); + H5Dclose(did); + H5E_END_TRY + return(ret_value); +} /* process_cmpd_fields() */ + + +/*------------------------------------------------------------------------- + * Function: check_dataset + * + * Purpose: To check whether a dataset can be monitored: + A chunked dataset with unlimited or max. dimension setting + * + * Return: Non-negative on success: dataset can be monitored + * Negative on failure: dataset cannot be monitored + * + * Programmer: Vailin Choi; August 2010 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +check_dataset(hid_t fid, char *dsetname) +{ + hid_t did; /* Dataset id */ + hid_t dcp; /* Dataset creation property */ + hid_t sid; /* Dataset's dataspace id */ + int ndims; /* # of dimensions in the dataspace */ + unsigned u; /* Local index variable */ + hsize_t cur_dims[H5S_MAX_RANK]; /* size of dataspace dimensions */ + hsize_t max_dims[H5S_MAX_RANK]; /* maximum size of dataspace dimensions */ + hbool_t unlim_max_dims = FALSE; /* whether dataset has unlimited or max. dimension setting */ + void *edata; + H5E_auto2_t func; + herr_t ret_value = SUCCEED; /* Return value */ + + /* Disable error reporting */ + H5Eget_auto2(H5E_DEFAULT, &func, &edata); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + + /* Open the dataset */ + if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { + error_msg("unable to open dataset \"%s\"\n", dsetname); + ret_value = FAIL; + goto done; + } + + /* Get dataset's creation property list */ + if((dcp = H5Dget_create_plist(did)) < 0) { + error_msg("unable to get dataset's creation property list\"%s\"\n", dsetname); + ret_value = FAIL; + goto done; + } + + /* Query dataset's layout; the layout should be chunked */ + if(H5Pget_layout(dcp) != H5D_CHUNKED) { + error_msg("\"%s\" should be a chunked dataset\n", dsetname); + ret_value = FAIL; + goto done; + } + + HDmemset(cur_dims, 0, sizeof cur_dims); + HDmemset(max_dims, 0, sizeof max_dims); + + /* Get dataset's dataspace */ + if((sid = H5Dget_space(did)) < 0) { + error_msg("can't get dataset's dataspace\"%s\"\n", dsetname); + ret_value = FAIL; + goto done; + } + + /* Get dimension size of dataset's dataspace */ + if((ndims = H5Sget_simple_extent_dims(sid, cur_dims, max_dims)) < 0) { + error_msg("can't get dataspace dimensions for dataset \"%s\"\n", dsetname); + ret_value = FAIL; + goto done; + } + + /* Check whether dataset has unlimited dimension or max. dimension setting */ + for(u = 0; u < (unsigned)ndims; u++) + if(max_dims[u] == H5S_UNLIMITED || cur_dims[u] != max_dims[u]) { + unlim_max_dims = TRUE; + break; + } + + if(!unlim_max_dims) { + error_msg("\"%s\" should have unlimited or max. dimension setting\n", dsetname); + ret_value = FAIL; + } + +done: + /* Closing */ + H5E_BEGIN_TRY + H5Sclose(sid); + H5Pclose(dcp); + H5Dclose(did); + H5E_END_TRY + + H5Eset_auto2(H5E_DEFAULT, func, edata); + + return(ret_value); +} /* check_dataset() */ + + +/*------------------------------------------------------------------------- + * Function: leave + * + * Purpose: Close the H5 Tools library and exit + * + * Return: Does not return + * + * Programmer: Vailin Choi; August 2010 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +leave(int ret) +{ + h5tools_close(); + + exit(ret); +} + + +/*------------------------------------------------------------------------- + * Function: usage + * + * Purpose: Print the usage message about h5watch (only long options) + * + * Return: void + * + * Programmer: Vailin Choi; August 2010 + * + * Modifications: + *------------------------------------------------------------------------- + */ +static void +usage(const char *prog) +{ + HDfflush(stdout); + HDfprintf(stdout, "Usage: %s [OPTIONS] [OBJECT]\n", prog); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, " OPTIONS\n"); + HDfprintf(stdout, " --help Print a usage message and exit.\n"); + HDfprintf(stdout, " --version Print version number and exit.\n"); + HDfprintf(stdout, " --label Label members of compound typed dataset.\n"); + HDfprintf(stdout, " --simple Use a machine-readable output format.\n"); + HDfprintf(stdout, " --dim Monitor changes in size of dataset dimensions only.\n"); + HDfprintf(stdout, " --width=N Set the number of columns to N for output.\n"); + HDfprintf(stdout, " A value of 0 sets the number of columns to the\n"); + HDfprintf(stdout, " maximum (65535). The default width is 80 columns.\n"); + HDfprintf(stdout, " --polling=N Set the polling interval to N (in seconds) when the\n"); + HDfprintf(stdout, " dataset will be checked for appended data. The default\n"); + HDfprintf(stdout, " polling interval is 1.\n"); + HDfprintf(stdout, " --fields=\n"); + HDfprintf(stdout, " Display data for the fields specified in \n"); + HDfprintf(stdout, " for a compound data type. can be\n"); + HDfprintf(stdout, " specified as follows:\n"); + HDfprintf(stdout, " 1) A comma-separated list of field names in a\n"); + HDfprintf(stdout, " compound data type. \",\" is the separator\n"); + HDfprintf(stdout, " for field names while \".\" is the separator\n"); + HDfprintf(stdout, " for a nested field.\n"); + HDfprintf(stdout, " 2) A single field name in a compound data type.\n"); + HDfprintf(stdout, " Can use this option multiple times.\n"); + HDfprintf(stdout, " Note that backslash is the escape character to avoid\n"); + HDfprintf(stdout, " characters in field names that conflict with the tool's\n"); + HDfprintf(stdout, " separators.\n"); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, " OBJECT is specified as [//]\n"); + HDfprintf(stdout, " Name of the HDF5 file. It may be preceded by path\n"); + HDfprintf(stdout, " separated by slashes to the specified HDF5 file.\n"); + HDfprintf(stdout, " Path separated by slashes to the specified dataset\n"); + HDfprintf(stdout, " Name of the dataset\n"); + HDfprintf(stdout, "\n"); + +} /* usage() */ + + +/*------------------------------------------------------------------------- + * Function: parse_command_line + * + * Purpose: Parse the command line for h5watch (take only long options) + * + * Return: Success: Set the corresponding command flags and return void + * Failure: Exits program with EXIT_FAILURE value. + * + * Programmer: Vailin Choi; August 2010 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +parse_command_line(int argc, const char *argv[]) +{ + int opt; /* Command line option */ + int tmp; + + /* no arguments */ + if (argc == 1) { + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); + } + + /* parse command line options */ + while ((opt = get_option(argc, argv, NULL, l_opts)) != EOF) { + switch ((char)opt) { + case '?': + case 'h': /* --help */ + usage(h5tools_getprogname()); + leave(EXIT_SUCCESS); + + case 'V': /* --version */ + print_version(progname); + leave(EXIT_SUCCESS); + break; + + case 'w': /* --width=N */ + g_display_width = HDstrtol(opt_arg, NULL, 0); + if(g_display_width < 0) { + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); + } + break; + + case 'd': /* --dim */ + g_monitor_size_only = TRUE; + break; + + case 'S': /* --simple */ + g_simple_output = TRUE; + break; + + case 'l': /* --label */ + g_label = TRUE; + break; + + case 'p': /* --polling=N */ + /* g_polling_interval = HDstrtod(opt_arg, NULL); */ + if((tmp = (int)HDstrtol(opt_arg, NULL, 10)) <= 0) { + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); + } + g_polling_interval = (unsigned)tmp; + break; + + case 'f': /* --fields= */ + if(g_list_of_fields == NULL) { + if((g_list_of_fields = HDstrdup(opt_arg)) == NULL) { + error_msg("memory allocation failed (file %s:line %d)\n", + __FILE__, __LINE__); + leave(EXIT_FAILURE); + } + } else { + char *str; + + if((str = HDstrdup(opt_arg)) == NULL) { + error_msg("memory allocation failed (file %s:line %d)\n", + __FILE__, __LINE__); + leave(EXIT_FAILURE); + } + if((g_list_of_fields = (char *)HDrealloc(g_list_of_fields, HDstrlen(g_list_of_fields) + HDstrlen(str) + 2)) == NULL) { + error_msg("memory allocation failed (file %s:line %d)\n", + __FILE__, __LINE__); + leave(EXIT_FAILURE); + + } + HDstrcat(g_list_of_fields, FIELD_SEP); + HDstrcat(g_list_of_fields, str); + } + + break; + + default: + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); + } + } + + + /* check for object to be processed */ + if (argc <= opt_ind) { + error_msg("missing dataset name\n"); + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); + } +} /* parse_command_line() */ + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: h5watch + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Vailin Choi; August 2010 + * + *------------------------------------------------------------------------- + */ +int +main(int argc, const char *argv[]) +{ + char drivername[50]; + char *fname = NULL; + char *dname = NULL; + void *edata; + H5E_auto2_t func; + char *x; + hid_t fid = -1; + + /* Set up tool name and exit status */ + h5tools_setprogname(PROGRAMNAME); + h5tools_setstatus(EXIT_SUCCESS); + + /* Disable error reporting */ + H5Eget_auto2(H5E_DEFAULT, &func, &edata); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + + /* Initialize h5tools lib */ + h5tools_init(); + + /* parse command line options */ + parse_command_line(argc, argv); + + if(argc <= opt_ind) { + error_msg("missing dataset name\n"); + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); + } + + /* Mostly copied from tools/h5ls coding & modified accordingly */ + /* + * [OBJECT] is specified as + * [//] + * + * Example: ../dir1/foo/bar/dset + * \_________/\______/ + * file obj + * + * The dichotomy is determined by calling H5Fopen() repeatedly until it + * succeeds. The first call uses the entire name and each subsequent call + * chops off the last component. If we reach the beginning of the name + * then there must have been something wrong with the file (perhaps it + * doesn't exist). + */ + if((fname = HDstrdup(argv[opt_ind])) == NULL) { + error_msg("memory allocation failed (file %s:line %d)\n", + __FILE__, __LINE__); + h5tools_setstatus(EXIT_FAILURE); + } + + do { + while(fname && *fname) { + fid = h5tools_fopen(fname, H5F_ACC_SWMR_READ, H5P_DEFAULT, NULL, drivername, sizeof drivername); + + if(fid >= 0) { + HDfprintf(stdout, "Opened \"%s\" with %s driver.\n", fname, drivername); + break; /*success*/ + } /* end if */ + + /* Shorten the file name; lengthen the object name */ + x = dname; + dname = HDstrrchr(fname, '/'); + if(x) + *x = '/'; + if(!dname) + break; + *dname = '\0'; + } /* end while */ + /* Try opening the file again if somehow unstable */ + } while(g_retry-- > 0 && fid == FAIL && !HDsleep(g_polling_interval)); + + if(fid < 0) { + error_msg("unable to open file \"%s\"\n", fname); + HDfree(fname); + leave(EXIT_FAILURE); + } + + if(!dname) { + error_msg("no dataset specified\n"); + h5tools_setstatus(EXIT_FAILURE); + } else { + *dname = '/'; + x = dname; + if((dname = HDstrdup(dname)) == NULL) { + error_msg("memory allocation failed (file %s:line %d)\n", + __FILE__, __LINE__); + h5tools_setstatus(EXIT_FAILURE); + } else { + *x = '\0'; + /* Validate dataset */ + if(check_dataset(fid, dname) < 0) + h5tools_setstatus(EXIT_FAILURE); + /* Validate input "fields" */ + else if(g_list_of_fields && *g_list_of_fields) + if(process_cmpd_fields(fid, dname) < 0) + h5tools_setstatus(EXIT_FAILURE); + } + } + + /* If everything is fine, start monitoring the datset */ + if(h5tools_getstatus() != EXIT_FAILURE) + if(monitor_dataset(fid, dname) < 0) + h5tools_setstatus(EXIT_FAILURE); + + /* Free spaces */ + if(fname) HDfree(fname); + if(dname) HDfree(dname); + if(g_list_of_fields) HDfree(g_list_of_fields); + if(g_listv) { + H5LD_clean_vector(g_listv); + HDfree(g_listv); + } + if(g_dup_fields) HDfree(g_dup_fields); + + /* Close the file */ + if(H5Fclose(fid) < 0) { + error_msg("unable to close file\n"); + h5tools_setstatus(EXIT_FAILURE); + } + + H5Eset_auto2(H5E_DEFAULT, func, edata); + /* exit */ + leave(h5tools_getstatus()); +} /* main() */ diff --git a/hl/tools/h5watch/h5watchgentest.c b/hl/tools/h5watch/h5watchgentest.c new file mode 100644 index 0000000..36c90e6 --- /dev/null +++ b/hl/tools/h5watch/h5watchgentest.c @@ -0,0 +1,328 @@ +#include "hdf5.h" +#include "H5HLprivate2.h" +#include +#include +#include +#include + +/* + * WATCH.h5: file with various types of datasets for testing-- + * + * The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting: + * DSET_ONE: one-dimensional dataset + * DSET_TWO: two-dimensional dataset + * DSET_CMPD: one-dimensional dataset with compound type + * DSET_CMPD_ESC: one-dimensional dataset with compound type and member names with + * escape/separator characters + * DSET_CMPD_TWO: two-dimensional dataset with compound type + * + * The following datasets are one-dimensional, chunked, max. dimension setting: + * DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY + * DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE + * + * The following datasets are one-dimensional: + * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE + * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR + */ +#define ONE_DIMS0 10 +#define MAX_ONE_DIMS0 100 + +#define DSET_ONE "DSET_ONE" +#define DSET_NONE "DSET_NONE" +#define DSET_NOMAX "DSET_NOMAX" +#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" +#define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" + +#define TWO_DIMS0 4 +#define TWO_DIMS1 10 +#define MAX_TWO_DIMS0 60 +#define MAX_TWO_DIMS1 100 + +#define DSET_TWO "DSET_TWO" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" + +#define CHUNK_SIZE 2 + +#define FILE "WATCH.h5" + +/* Data structures for datasets with compound types */ +typedef struct sub22_t { + unsigned int a; + unsigned int b; + unsigned int c; +} sub22_t; + +typedef struct sub2_t { + unsigned int a; + sub22_t b; + unsigned int c; +} sub2_t; + +typedef struct sub4_t { + unsigned int a; + unsigned int b; +} sub4_t; + +typedef struct set_t { + unsigned int field1; + sub2_t field2; + double field3; + sub4_t field4; +} set_t; + +/* + ************************************************************************************** + * + * Create a dataset with the given input parameters + * Write to the dataset with the given "data" + * + ************************************************************************************** + */ +static int +generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, hsize_t *maxdims, hid_t dtid, void *data) +{ + hid_t dcpl; /* Dataset creation property */ + hid_t did; /* Dataset id */ + hid_t sid; /* Dataspace id */ + int i; /* Local index variable */ + hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */ + + /* Create the dataspace */ + if((sid = H5Screate_simple(ndims, dims, maxdims)) < 0) + goto done; + + /* Set up dataset's creation properties */ + if(!HDstrcmp(dname, DSET_NONE)) + dcpl = H5P_DEFAULT; + else { + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto done; + for(i = 0; i < ndims; i++) + chunk_dims[i] = CHUNK_SIZE; + if(H5Pset_chunk(dcpl, ndims, chunk_dims) < 0) + goto done; + } + + if(!HDstrcmp(dname, DSET_ALLOC_LATE)) { + if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) + goto done; + } else if(!HDstrcmp(dname, DSET_ALLOC_EARLY)) { + if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + goto done; + } + + /* Create the dataset */ + if((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto done; + + /* Write to the dataset */ + if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + goto done; + + /* Closing */ + if(H5Pclose(dcpl) < 0) goto done; + if(H5Sclose(sid) < 0) goto done; + if(H5Dclose(did) < 0) goto done; + + return(SUCCEED); + +done: + H5E_BEGIN_TRY + H5Sclose(sid); + H5Pclose(dcpl); + H5Dclose(did); + H5E_END_TRY + + return(FAIL); +} /* generate_dset() */ + +int +main(void) +{ + hid_t fid; /* File id */ + hsize_t cur_dims[1]; /* Dimension sizes */ + hsize_t max_dims[1]; /* Maximum dimension sizes */ + hsize_t cur2_dims[2]; /* Current dimension sizes */ + hsize_t max2_dims[2]; /* Maximum dimension sizes */ + hid_t set_tid, esc_set_tid; /* Compound type id */ + hid_t sub22_tid; /* Compound type id */ + hid_t sub2_tid, esc_sub2_tid; /* Compound type id */ + hid_t sub4_tid, esc_sub4_tid; /* Compound type id */ + int one_data[ONE_DIMS0]; /* Buffer for data */ + int two_data[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data */ + set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */ + set_t two_cbuf[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data with compound type */ + int i; /* Local index variable */ + + /* Create a file */ + if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto done; + + /* Initialization for one-dimensional dataset */ + cur_dims[0] = ONE_DIMS0; + max_dims[0] = MAX_ONE_DIMS0; + for(i = 0; i < ONE_DIMS0; i++) + one_data[i] = i; + + /* Generate DSET_ONE, DSET_NONE, DSET_NOMAX, DSET_ALLOC_LATE, DSET_EARLY */ + if(generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + if(generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + goto done; + if(generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + goto done; + if(generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + if(generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + + /* Initialization for two-dimensional dataset */ + cur2_dims[0] = TWO_DIMS0; + cur2_dims[1] = TWO_DIMS1; + max2_dims[0] = MAX_TWO_DIMS0; + max2_dims[1] = MAX_TWO_DIMS1; + + for(i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) + two_data[i] = i; + + /* Generate DSET_TWO */ + if(generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0) + goto done; + + /* Initialization for one-dimensional compound typed dataset */ + cur_dims[0] = ONE_DIMS0; + max_dims[0] = MAX_ONE_DIMS0; + + for (i = 0; i < ONE_DIMS0; i++) { + one_cbuf[i].field1 = 1; + one_cbuf[i].field2.a = 2; + one_cbuf[i].field2.c = 4; + one_cbuf[i].field2.b.a = 20; + one_cbuf[i].field2.b.b = 40; + one_cbuf[i].field2.b.c = 80; + one_cbuf[i].field3 = 3.0; + one_cbuf[i].field4.a = 4; + one_cbuf[i].field4.b = 8; + } + + /* Create the compound type */ + if((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0) + goto done; + if(H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + goto done; + if(H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0) + goto done; + if(H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + goto done; + if(H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + goto done; + + if((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + goto done; + if(H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0) + goto done; + if(H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + goto done; + if(H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0) + goto done; + + /* Create the compound type with escape/separator characters */ + if((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + goto done; + if(H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0) + goto done; + if(H5Tinsert(esc_sub2_tid, "\\K", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + goto done; + if(H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + goto done; + + if((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + goto done; + if(H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0) + goto done; + if(H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + goto done; + if(H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0) + goto done; + + /* Generate DSET_CMPD, DSET_CMPD_ESC */ + if(generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0) + goto done; + if(generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0) + goto done; + + /* Initialization for two-dimensional compound typed dataset */ + cur2_dims[0] = TWO_DIMS0; + cur2_dims[1] = TWO_DIMS1; + max2_dims[0] = MAX_TWO_DIMS0; + max2_dims[0] = MAX_TWO_DIMS1; + + for (i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) { + two_cbuf[i].field1 = 1; + two_cbuf[i].field2.a = 2; + two_cbuf[i].field2.c = 4; + two_cbuf[i].field2.b.a = 20; + two_cbuf[i].field2.b.b = 40; + two_cbuf[i].field2.b.c = 80; + two_cbuf[i].field3 = 3.0; + two_cbuf[i].field4.a = 4; + two_cbuf[i].field4.b = 8; + } + + /* Generate DSET_CMPD_TWO */ + if(generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0) + goto done; + + /* Closing */ + if(H5Tclose(sub22_tid) < 0) goto done; + if(H5Tclose(sub2_tid) < 0) goto done; + if(H5Tclose(sub4_tid) < 0) goto done; + if(H5Tclose(set_tid) < 0) goto done; + if(H5Tclose(esc_sub2_tid) < 0) goto done; + if(H5Tclose(esc_sub4_tid) < 0) goto done; + if(H5Tclose(esc_set_tid) < 0) goto done; + if(H5Fclose(fid) < 0) goto done; + + exit(EXIT_SUCCESS); + +done: + H5E_BEGIN_TRY + H5Tclose(sub22_tid); + H5Tclose(sub2_tid); + H5Tclose(sub4_tid); + H5Tclose(set_tid); + H5Tclose(esc_sub2_tid); + H5Tclose(esc_sub4_tid); + H5Tclose(esc_set_tid); + H5Fclose(fid); + H5E_END_TRY + + exit(EXIT_FAILURE); +} /* main() */ diff --git a/hl/tools/h5watch/testh5watch.sh.in b/hl/tools/h5watch/testh5watch.sh.in new file mode 100644 index 0000000..8451151 --- /dev/null +++ b/hl/tools/h5watch/testh5watch.sh.in @@ -0,0 +1,372 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# +# Tests for the h5watch tool +# +H5WATCH=h5watch # The tool name +H5WATCH_BIN=`pwd`/$H5WATCH # The path of H5WATCH +EXTEND_DSET=extend_dset # Helper to extend the dataset when watching +EXTEND_BIN=`pwd`/$EXTEND_DSET # The path of EXTEND_DSET +# +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +# +GEN_TEST=h5watchgentest # Generate HDF5 file with various datasets +GEN_TEST_BIN=`pwd`/$GEN_TEST # Path of the binary GEN_TEST +# + +CP='cp' +CMP='cmp -s' +DIFF='diff -c' +KILL='kill' +SLEEP='sleep' +NLINES=20 # Max. lines of output to display if test fails +# +# Mac OS: just to make sure echo "backslash backslash" behaves properly +if test `uname -s` = 'Darwin'; then + ECHO='/bin/echo' +else + ECHO='echo' +fi + +# Global variables +nerrors=0 +verbose=yes + +# The build (current) directory might be different than the source directory. +if test -z "$srcdir"; then + srcdir=. +fi +test -d ../testfiles || mkdir ../testfiles + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +TESTING() { + SPACES=" " + $ECHO "Testing $* $SPACES" |cut -c1-70 |tr -d '\012' +} + +# +# Overall algorithm: +# +# Run a test and print PASSED or FAILED +# If a test did not return with the expected return code, +# increment the `nerrors' global variable and (if $verbose is set) display up to $NLINES +# lines of the actual output from the test. +# If the test did return the expected code, +# compare the actual output with the expected output; +# If the outputs are the same, print PASSED, +# Otherwise print FAILED and the difference between the two outputs. +# The output files are not removed if $HDF5_NOCLEANUP has a non-zero value. +# +# +# TOOLTEST(): +# +# Arguments: +# +# $1 -- expected output +# $2 -- expected return code +# $3 and on -- arguments for h5watch +TOOLTEST() { + expect="$srcdir/../testfiles/$1" + actual="../testfiles/`basename $1 .ddl`.out" + actual_err="../testfiles/`basename $1 .ddl`.err" + shift + retvalexpect=$1 + shift + # Run test. + # Stderr is included in stdout so that the diff can detect + # any unexpected output from that stream too. + TESTING $H5WATCH $@ + ( + $ECHO "#############################" + $ECHO " output for '$H5WATCH $@'" + $ECHO "#############################" + $RUNSERIAL $H5WATCH_BIN "$@" + ) > $actual 2>$actual_err + exitcode=$? + cat $actual_err >> $actual + if [ $exitcode -ne $retvalexpect ]; then + $ECHO "*FAILED*" + nerrors="`expr $nerrors + 1`" + if [ yes = "$verbose" ]; then + $ECHO "test returned with exit code $exitcode" + $ECHO "test output: (up to $NLINES lines)" + head -$NLINES $actual + $ECHO "***end of test output***" + $ECHO "" + fi + elif $CMP $expect $actual; then + $ECHO " PASSED" + else + $ECHO "*FAILED*" + $ECHO " Expected result differs from actual result" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + fi + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual $actual_err + fi +} + +# +# TEST_WATCH(): TEST_WATCH $1 $2 $3 $4 $5 ... +# +# Arguments: +# $1 -- number of objects to watch and to extend +# $2 -- the specified file to watch and to extend +# (filename varies with $1 suffix) +# $3 -- the specified dataset to watch and to extend +# $4 -- the options to h5watch (can be NULL) +# $5 -- expected output from watching the object +# ($3, $4, $5) can be repeated for $1 times +# +# This is done to reduce the sleeping time for testing +# +TEST_WATCH() { + plist="" # plist: the list of h5watch process IDs + dlist="" # dlist: the list of dataset names to watch/extend + outlist="" # outlist: the list of expected output files with suffix ".ddl" stripped + xlist="" # xlist: the list of exit codes from extending the dataset + NUM=$1 # number of objects to watch/extend + shift + NFNAME="`basename $1 .h5`" #the file to watch and to extend stripped of suffix ".h5" + shift + ctr=1 #counter for tracking the # of objects to test + while [ $ctr -le $NUM ] ; #loop till end of all objects to test + do + actual="../testfiles/`basename $3 .ddl`.out" #the actual output + outlist="$outlist`basename $3 .ddl` " #store to the list of output names + dlist="$dlist$1 " #store to the list of datasets + # + $CP "$NFNAME.h5" "$NFNAME$ctr.h5" #copy the file to a temporary file + # + if test -z "$2"; then #compile options & object to h5watch + OBJ="$NFNAME$ctr.h5/$1" #no options, just object + else + OBJ="$2 $NFNAME$ctr.h5/$1" #option and object + fi + # + # Run h5watch and put in background, output to a file + # + TESTING $H5WATCH $OBJ + $ECHO "" + $ECHO "#############################" > $actual + $ECHO " output for '$H5WATCH $OBJ'" >>$actual + $ECHO "#############################" >>$actual + $RUNSERIAL $H5WATCH_BIN $2 "$NFNAME$ctr.h5/$1" >> $actual & + WATCH_PID=$! #get h5watch process ID + plist="$plist$! " #store to the list of process IDs + shift; shift; shift + ctr=`expr $ctr + 1` + done; + # + # Extend the list of datasets corresponding to the list of files + n=1; + for d in $dlist; do + $EXTEND_BIN "$NFNAME$n.h5" $d + xlist="$xlist$? " #store to the list of exit codes from extending the dataset + n=`expr $n + 1` + done; + # + # Sleep to make sure output is flushed out before stopping h5watch + $ECHO "Sleeping for 4 seconds..." + $SLEEP 4 + # + # Kill the list of h5watch processes + $ECHO "Killing h5watch processes..." + for p in $plist; do #kill the list of h5watch processes + $KILL $p + done + # + # Check the list of return codes from extending the dataset + # Compare the list of actual output from h5watch with the corresponding expected output + n=1 + for x in $xlist; do + outname=`$ECHO $outlist|cut -d' ' -f$n` + actual="../testfiles/$outname.out" + expect="$srcdir/../testfiles/$outname.ddl" + if [ $x -ne 0 ]; then + $ECHO "*FAILED*" + nerrors="`expr $nerrors + 1`" + if [ yes = "$verbose" ]; then + $ECHO "test returned with exit code $exitcode" + $ECHO "test output: (up to $NLINES lines)" + + head -$NLINES $actual + $ECHO "***end of test output***" + $ECHO "" + fi + elif $CMP $expect $actual; then + $ECHO " PASSED" + else + $ECHO "*FAILED*" + $ECHO " Expected result differs from actual result" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + fi + # + # Cleaning + rm -f "$NFNAME$n.h5" + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual + fi + n="`expr $n + 1`" + done; +} + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## +# +# +################################################################################################# +# # +# WATCH.h5: file with various types of datasets for testing-- # +# The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting: # +# DSET_ONE: one-dimensional dataset # +# DSET_TWO: two-dimensional dataset # +# DSET_CMPD: one-dimensional dataset with compound type # +# DSET_CMPD_ESC: one-dimensional dataset with compound type & escape/separator characters # +# DSET_CMPD_TWO: two-dimensional dataset with compound type # +# # +# The following datasets are one-dimensional, chunked, max. dimension setting: # +# DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY # +# DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE # +# # +# The following datasets are one-dimensional: # +# DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE # +# DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR # +# # +################################################################################################# +# +# +################################################################################################# +# # +# Tests on expected failures: # +# Invalid file name # +# Unable to find dataset, invalid dataset # +# DSET_NONE and DSET_NOMAX # +# Invalid input to options --width and --polling # +# Invalid field names for -f option # +# # +################################################################################################# +# +# Generate file with various types of datasets +$GEN_TEST_BIN +# Test on --help options +TOOLTEST w-help1.ddl 0 --help +# +# Tests on expected failures +TOOLTEST w-err-dset1.ddl 1 WATCH.h5 +TOOLTEST w-err-dset2.ddl 1 WATCH.h5/group/DSET_CMPD +TOOLTEST w-err-dset-none.ddl 1 WATCH.h5/DSET_NONE +TOOLTEST w-err-dset-nomax.ddl 1 WATCH.h5/DSET_NOMAX +TOOLTEST w-err-file.ddl 1 ../WATCH.h5/DSET_CMPD +TOOLTEST w-err-width.ddl 1 --width=-8 WATCH.h5/DSET_ONE +TOOLTEST w-err-poll.ddl 1 --polling=-8 WATCH.h5/DSET_ONE +TOOLTEST w-err-poll0.ddl 1 --polling=0 WATCH.h5/DSET_ONE +# +# Tests on invalid field names via --fields option for a compound typed dataset: DSET_CMPD +TOOLTEST w-err-cmpd1.ddl 1 --fields=fieldx WATCH.h5/DSET_CMPD +TOOLTEST w-err-cmpd2.ddl 1 --fields=field1,field2. WATCH.h5/DSET_CMPD +TOOLTEST w-err-cmpd3.ddl 1 --fields=field1,field2, WATCH.h5/DSET_CMPD +TOOLTEST w-err-cmpd4.ddl 1 --fields=field1,field2.b.k WATCH.h5/DSET_CMPD +TOOLTEST w-err-cmpd5.ddl 1 --fields=field1 --fields=field2.b.k WATCH.h5/DSET_CMPD +# +# +################################################################################################# +# # +# Tests on extending datasets-- # +# DSET_ONE, DSET_CMPD, DSET_CMPD_ESC # +# DSET_ALLOC_EARLY, DSET_ALLOC_LATE # +# DSET_TWO, DSET_CMPD_TWO # +# # +################################################################################################# +# +# Generate file with various types of datasets +$GEN_TEST_BIN +# +# Watching and extending: WATCH1.h5/DSET_ONE, WATCH2.h5/DSET_ALLOC_EARLY, WATCH3.h5/DSET_ALLOC_LATE WATCH4.h5/DSET_CMPD +# : WATCH5.h5/DSET_TWO, WATCH6.h5/DSET_CMPD_TWO, WATCH7.h5/DDSET_CMPD_ESC +TEST_WATCH 7 WATCH.h5 DSET_ONE '' w-ext-one.ddl DSET_ALLOC_EARLY '' w-ext-early.ddl DSET_ALLOC_LATE '' w-ext-late.ddl DSET_CMPD '' w-ext-cmpd.ddl DSET_TWO '' w-ext-two.ddl DSET_CMPD_TWO '' w-ext-cmpd-two.ddl DSET_CMPD_ESC '' w-ext-cmpd-esc.ddl +# +############################ +# Tests on --fields option # +############################ +# +# Watching and extending: +# WATCH1.h5/DSET_CMPD with --fields=field1,field2 +# WATCH2.h5/DSET_CMP_TWO with --fields=field1,field2 +# WATCH3.h5/DSET_CMPD_ESC with --fields=field\,1,field2\. +# WATCH4.h5/DSET_CMPD with --fields=field1 --fields=field2 +# WATCH5.h5/DSET_CMPD_ESC with --fields=field\,1 --fields=field2\. +# WATCH6.h5/DSET_CMPD_TWO with --fields=field1 --fields=field2 +# +TEST_WATCH 6 WATCH.h5 DSET_CMPD --fields=field1,field2 w-ext-cmpd-f1.ddl DSET_CMPD_TWO --fields=field1,field2 w-ext-cmpd-two-f1.ddl DSET_CMPD_ESC '--fields=field\,1,field2\.' w-ext-cmpd-esc-f1.ddl DSET_CMPD '--fields=field1 --fields=field2' w-ext-cmpd-ff1.ddl DSET_CMPD_ESC '--fields=field\,1 --fields=field2\.' w-ext-cmpd-esc-ff1.ddl DSET_CMPD_TWO '--fields=field1 --fields=field2' w-ext-cmpd-two-ff1.ddl +# +# +# +# Watching and extending: +# WATCH1.h5/DSET_CMPD with --fields=field2.b,field4 +# WATCH2.h5/DSET_CMPD_ESC with --fields=field2\..\,b,field4\ +# WATCH3.h5/DSET_CMPD_TWO with --fields=field2.b,field4 +# WATCH4.h5/DSET_CMPD with --fields=field2.b --fields=field4 +# WATCH5.h5/DSET_CMPD_ESC with --fields=field2\..\,b --fields=field4\, +# WATCH6.h5/DSET_CMPD_TWO with --fields=field2.b --fields=field4 +TEST_WATCH 6 WATCH.h5 DSET_CMPD --fields=field2.b,field4 w-ext-cmpd-f2.ddl DSET_CMPD_ESC '--fields=field2\..\,b,field4\,' w-ext-cmpd-esc-f2.ddl DSET_CMPD_TWO --fields=field2.b,field4 w-ext-cmpd-two-f2.ddl DSET_CMPD '--fields=field2.b --fields=field4' w-ext-cmpd-ff2.ddl DSET_CMPD_ESC '--fields=field2\..\,b --fields=field4\,' w-ext-cmpd-esc-ff2.ddl DSET_CMPD_TWO '--fields=field2.b --fields=field4' w-ext-cmpd-two-ff2.ddl +# +# +# +# Watching and extending: +# WATCH1.h5/DSET_CMPD with --fields=field2.b.a,field2.c +# WATCH2.h5/DSET_CMPD_ESC with --fields=field2\..\,b.a,field2\..\\K +# WATCH3.h5/DSET_CMPD_TWO with --fields=field2.b.a,field2.c +# WATCH4.h5/DSET_CMPD with --fields=field2.b.a --fields=field2.c +# WATCH5.h5/DSET_CMPD_ESC with --fields=field2\..\,b.a --fields=field2\..\\K +# WATCH6.h5/DSET_CMPD_TWO with --fields=field2.b.a --fields=field2.c +TEST_WATCH 6 WATCH.h5 DSET_CMPD --fields=field2.b.a,field2.c w-ext-cmpd-f3.ddl DSET_CMPD_ESC '--fields=field2\..\,b.a,field2\..\\K' w-ext-cmpd-esc-f3.ddl DSET_CMPD_TWO --fields=field2.b.a,field2.c w-ext-cmpd-two-f3.ddl DSET_CMPD '--fields=field2.b.a --fields=field2.c' w-ext-cmpd-ff3.ddl DSET_CMPD_ESC '--fields=field2\..\,b.a --fields=field2\..\\K' w-ext-cmpd-esc-ff3.ddl DSET_CMPD_TWO '--fields=field2.b.a --fields=field2.c' w-ext-cmpd-two-ff3.ddl +# +# +# +######################################################### +# # +# Tests on options: # +# --dim # +# --width, --label, --simple, --help # +# # +######################################################### +# +# Watching and extending: +# WATCH1.h5/DSET_ONE with -d option +# WATCH2.h5/DSET_TWO with --dim option +# WATCH3.h5/DSET_TWO with --width=60 option +# WATCH4.h5/DSET_CMPD with --label option +# WATCH5.h5/DSET_ONE with --simple option +TEST_WATCH 5 WATCH.h5 DSET_ONE --dim w-ext-one-d.ddl DSET_TWO --dim w-ext-two-d.ddl DSET_TWO --width=30 w-ext-two-width.ddl DSET_CMPD --label w-ext-cmpd-label.ddl DSET_ONE --simple w-ext-one-simple.ddl +# +# +# +if test $nerrors -eq 0 ; then + $ECHO "All h5watch tests passed." + exit $EXIT_SUCCESS +else + $ECHO "h5watch tests failed with $nerrors errors." + exit $EXIT_FAILURE +fi diff --git a/hl/tools/testfiles/w-err-cmpd1.ddl b/hl/tools/testfiles/w-err-cmpd1.ddl new file mode 100644 index 0000000..2a3f796 --- /dev/null +++ b/hl/tools/testfiles/w-err-cmpd1.ddl @@ -0,0 +1,5 @@ +############################# + output for 'h5watch --fields=fieldx WATCH.h5/DSET_CMPD' +############################# +Opened "WATCH.h5" with sec2 driver. +h5watch error: error in processing diff --git a/hl/tools/testfiles/w-err-cmpd2.ddl b/hl/tools/testfiles/w-err-cmpd2.ddl new file mode 100644 index 0000000..4de3fe2 --- /dev/null +++ b/hl/tools/testfiles/w-err-cmpd2.ddl @@ -0,0 +1,5 @@ +############################# + output for 'h5watch --fields=field1,field2. WATCH.h5/DSET_CMPD' +############################# +Opened "WATCH.h5" with sec2 driver. +h5watch error: error in processing diff --git a/hl/tools/testfiles/w-err-cmpd3.ddl b/hl/tools/testfiles/w-err-cmpd3.ddl new file mode 100644 index 0000000..f2f462e --- /dev/null +++ b/hl/tools/testfiles/w-err-cmpd3.ddl @@ -0,0 +1,5 @@ +############################# + output for 'h5watch --fields=field1,field2, WATCH.h5/DSET_CMPD' +############################# +Opened "WATCH.h5" with sec2 driver. +h5watch error: error in processing diff --git a/hl/tools/testfiles/w-err-cmpd4.ddl b/hl/tools/testfiles/w-err-cmpd4.ddl new file mode 100644 index 0000000..b11277b --- /dev/null +++ b/hl/tools/testfiles/w-err-cmpd4.ddl @@ -0,0 +1,5 @@ +############################# + output for 'h5watch --fields=field1,field2.b.k WATCH.h5/DSET_CMPD' +############################# +Opened "WATCH.h5" with sec2 driver. +h5watch error: error in processing diff --git a/hl/tools/testfiles/w-err-cmpd5.ddl b/hl/tools/testfiles/w-err-cmpd5.ddl new file mode 100644 index 0000000..7174d14 --- /dev/null +++ b/hl/tools/testfiles/w-err-cmpd5.ddl @@ -0,0 +1,5 @@ +############################# + output for 'h5watch --fields=field1 --fields=field2.b.k WATCH.h5/DSET_CMPD' +############################# +Opened "WATCH.h5" with sec2 driver. +h5watch error: error in processing diff --git a/hl/tools/testfiles/w-err-dset-nomax.ddl b/hl/tools/testfiles/w-err-dset-nomax.ddl new file mode 100644 index 0000000..c2fd65f --- /dev/null +++ b/hl/tools/testfiles/w-err-dset-nomax.ddl @@ -0,0 +1,5 @@ +############################# + output for 'h5watch WATCH.h5/DSET_NOMAX' +############################# +Opened "WATCH.h5" with sec2 driver. +h5watch error: "/DSET_NOMAX" should have unlimited or max. dimension setting diff --git a/hl/tools/testfiles/w-err-dset-none.ddl b/hl/tools/testfiles/w-err-dset-none.ddl new file mode 100644 index 0000000..2708473 --- /dev/null +++ b/hl/tools/testfiles/w-err-dset-none.ddl @@ -0,0 +1,5 @@ +############################# + output for 'h5watch WATCH.h5/DSET_NONE' +############################# +Opened "WATCH.h5" with sec2 driver. +h5watch error: "/DSET_NONE" should be a chunked dataset diff --git a/hl/tools/testfiles/w-err-dset1.ddl b/hl/tools/testfiles/w-err-dset1.ddl new file mode 100644 index 0000000..0594562 --- /dev/null +++ b/hl/tools/testfiles/w-err-dset1.ddl @@ -0,0 +1,5 @@ +############################# + output for 'h5watch WATCH.h5' +############################# +Opened "WATCH.h5" with sec2 driver. +h5watch error: no dataset specified diff --git a/hl/tools/testfiles/w-err-dset2.ddl b/hl/tools/testfiles/w-err-dset2.ddl new file mode 100644 index 0000000..ce26109 --- /dev/null +++ b/hl/tools/testfiles/w-err-dset2.ddl @@ -0,0 +1,5 @@ +############################# + output for 'h5watch WATCH.h5/group/DSET_CMPD' +############################# +Opened "WATCH.h5" with sec2 driver. +h5watch error: unable to open dataset "/group/DSET_CMPD" diff --git a/hl/tools/testfiles/w-err-file.ddl b/hl/tools/testfiles/w-err-file.ddl new file mode 100644 index 0000000..416fd44 --- /dev/null +++ b/hl/tools/testfiles/w-err-file.ddl @@ -0,0 +1,4 @@ +############################# + output for 'h5watch ../WATCH.h5/DSET_CMPD' +############################# +h5watch error: unable to open file "../WATCH.h5/DSET_CMPD" diff --git a/hl/tools/testfiles/w-err-poll.ddl b/hl/tools/testfiles/w-err-poll.ddl new file mode 100644 index 0000000..4395cc4 --- /dev/null +++ b/hl/tools/testfiles/w-err-poll.ddl @@ -0,0 +1,37 @@ +############################# + output for 'h5watch --polling=-8 WATCH.h5/DSET_ONE' +############################# +Usage: h5watch [OPTIONS] [OBJECT] + + OPTIONS + --help Print a usage message and exit. + --version Print version number and exit. + --label Label members of compound typed dataset. + --simple Use a machine-readable output format. + --dim Monitor changes in size of dataset dimensions only. + --width=N Set the number of columns to N for output. + A value of 0 sets the number of columns to the + maximum (65535). The default width is 80 columns. + --polling=N Set the polling interval to N (in seconds) when the + dataset will be checked for appended data. The default + polling interval is 1. + --fields= + Display data for the fields specified in + for a compound data type. can be + specified as follows: + 1) A comma-separated list of field names in a + compound data type. "," is the separator + for field names while "." is the separator + for a nested field. + 2) A single field name in a compound data type. + Can use this option multiple times. + Note that backslash is the escape character to avoid + characters in field names that conflict with the tool's + separators. + + OBJECT is specified as [//] + Name of the HDF5 file. It may be preceded by path + separated by slashes to the specified HDF5 file. + Path separated by slashes to the specified dataset + Name of the dataset + diff --git a/hl/tools/testfiles/w-err-poll0.ddl b/hl/tools/testfiles/w-err-poll0.ddl new file mode 100644 index 0000000..c71f1eb --- /dev/null +++ b/hl/tools/testfiles/w-err-poll0.ddl @@ -0,0 +1,37 @@ +############################# + output for 'h5watch --polling=0 WATCH.h5/DSET_ONE' +############################# +Usage: h5watch [OPTIONS] [OBJECT] + + OPTIONS + --help Print a usage message and exit. + --version Print version number and exit. + --label Label members of compound typed dataset. + --simple Use a machine-readable output format. + --dim Monitor changes in size of dataset dimensions only. + --width=N Set the number of columns to N for output. + A value of 0 sets the number of columns to the + maximum (65535). The default width is 80 columns. + --polling=N Set the polling interval to N (in seconds) when the + dataset will be checked for appended data. The default + polling interval is 1. + --fields= + Display data for the fields specified in + for a compound data type. can be + specified as follows: + 1) A comma-separated list of field names in a + compound data type. "," is the separator + for field names while "." is the separator + for a nested field. + 2) A single field name in a compound data type. + Can use this option multiple times. + Note that backslash is the escape character to avoid + characters in field names that conflict with the tool's + separators. + + OBJECT is specified as [//] + Name of the HDF5 file. It may be preceded by path + separated by slashes to the specified HDF5 file. + Path separated by slashes to the specified dataset + Name of the dataset + diff --git a/hl/tools/testfiles/w-err-width.ddl b/hl/tools/testfiles/w-err-width.ddl new file mode 100644 index 0000000..a16b641 --- /dev/null +++ b/hl/tools/testfiles/w-err-width.ddl @@ -0,0 +1,37 @@ +############################# + output for 'h5watch --width=-8 WATCH.h5/DSET_ONE' +############################# +Usage: h5watch [OPTIONS] [OBJECT] + + OPTIONS + --help Print a usage message and exit. + --version Print version number and exit. + --label Label members of compound typed dataset. + --simple Use a machine-readable output format. + --dim Monitor changes in size of dataset dimensions only. + --width=N Set the number of columns to N for output. + A value of 0 sets the number of columns to the + maximum (65535). The default width is 80 columns. + --polling=N Set the polling interval to N (in seconds) when the + dataset will be checked for appended data. The default + polling interval is 1. + --fields= + Display data for the fields specified in + for a compound data type. can be + specified as follows: + 1) A comma-separated list of field names in a + compound data type. "," is the separator + for field names while "." is the separator + for a nested field. + 2) A single field name in a compound data type. + Can use this option multiple times. + Note that backslash is the escape character to avoid + characters in field names that conflict with the tool's + separators. + + OBJECT is specified as [//] + Name of the HDF5 file. It may be preceded by path + separated by slashes to the specified HDF5 file. + Path separated by slashes to the specified dataset + Name of the dataset + diff --git a/hl/tools/testfiles/w-ext-cmpd-esc-f1.ddl b/hl/tools/testfiles/w-ext-cmpd-esc-f1.ddl new file mode 100644 index 0000000..215552b --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-esc-f1.ddl @@ -0,0 +1,14 @@ +############################# + output for 'h5watch --fields=field\,1,field2\. WATCH3.h5/DSET_CMPD_ESC' +############################# +Opened "WATCH3.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_ESC... +dimension 0: 10->13 (increases) + Data: + (10) {1, {2, {2, 2, 2}, 2}}, {2, {3, {3, 3, 3}, 3}}, + (12) {3, {4, {4, 4, 4}, 4}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {1, {2, {2, 2, 2}, 2}}, {2, {3, {3, 3, 3}, 3}} diff --git a/hl/tools/testfiles/w-ext-cmpd-esc-f2.ddl b/hl/tools/testfiles/w-ext-cmpd-esc-f2.ddl new file mode 100644 index 0000000..19e2dc8 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-esc-f2.ddl @@ -0,0 +1,14 @@ +############################# + output for 'h5watch --fields=field2\..\,b,field4\, WATCH2.h5/DSET_CMPD_ESC' +############################# +Opened "WATCH2.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_ESC... +dimension 0: 10->13 (increases) + Data: + (10) {{{2, 2, 2}}, {4, 4}}, {{{3, 3, 3}}, {5, 5}}, {{{4, 4, 4}}, {6, + (12) 6}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {{{2, 2, 2}}, {4, 4}}, {{{3, 3, 3}}, {5, 5}} diff --git a/hl/tools/testfiles/w-ext-cmpd-esc-f3.ddl b/hl/tools/testfiles/w-ext-cmpd-esc-f3.ddl new file mode 100644 index 0000000..58d86b6 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-esc-f3.ddl @@ -0,0 +1,13 @@ +############################# + output for 'h5watch --fields=field2\..\,b.a,field2\..\\K WATCH2.h5/DSET_CMPD_ESC' +############################# +Opened "WATCH2.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_ESC... +dimension 0: 10->13 (increases) + Data: + (10) {{{2}}, {2}}, {{{3}}, {3}}, {{{4}}, {4}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {{{2}}, {2}}, {{{3}}, {3}} diff --git a/hl/tools/testfiles/w-ext-cmpd-esc-ff1.ddl b/hl/tools/testfiles/w-ext-cmpd-esc-ff1.ddl new file mode 100644 index 0000000..f0fbc00 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-esc-ff1.ddl @@ -0,0 +1,14 @@ +############################# + output for 'h5watch --fields=field\,1 --fields=field2\. WATCH5.h5/DSET_CMPD_ESC' +############################# +Opened "WATCH5.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_ESC... +dimension 0: 10->13 (increases) + Data: + (10) {1, {2, {2, 2, 2}, 2}}, {2, {3, {3, 3, 3}, 3}}, + (12) {3, {4, {4, 4, 4}, 4}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {1, {2, {2, 2, 2}, 2}}, {2, {3, {3, 3, 3}, 3}} diff --git a/hl/tools/testfiles/w-ext-cmpd-esc-ff2.ddl b/hl/tools/testfiles/w-ext-cmpd-esc-ff2.ddl new file mode 100644 index 0000000..460c2ae --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-esc-ff2.ddl @@ -0,0 +1,14 @@ +############################# + output for 'h5watch --fields=field2\..\,b --fields=field4\, WATCH5.h5/DSET_CMPD_ESC' +############################# +Opened "WATCH5.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_ESC... +dimension 0: 10->13 (increases) + Data: + (10) {{{2, 2, 2}}, {4, 4}}, {{{3, 3, 3}}, {5, 5}}, {{{4, 4, 4}}, {6, + (12) 6}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {{{2, 2, 2}}, {4, 4}}, {{{3, 3, 3}}, {5, 5}} diff --git a/hl/tools/testfiles/w-ext-cmpd-esc-ff3.ddl b/hl/tools/testfiles/w-ext-cmpd-esc-ff3.ddl new file mode 100644 index 0000000..7c0afbf --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-esc-ff3.ddl @@ -0,0 +1,13 @@ +############################# + output for 'h5watch --fields=field2\..\,b.a --fields=field2\..\\K WATCH5.h5/DSET_CMPD_ESC' +############################# +Opened "WATCH5.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_ESC... +dimension 0: 10->13 (increases) + Data: + (10) {{{2}}, {2}}, {{{3}}, {3}}, {{{4}}, {4}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {{{2}}, {2}}, {{{3}}, {3}} diff --git a/hl/tools/testfiles/w-ext-cmpd-esc.ddl b/hl/tools/testfiles/w-ext-cmpd-esc.ddl new file mode 100644 index 0000000..8fd18d0 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-esc.ddl @@ -0,0 +1,16 @@ +############################# + output for 'h5watch WATCH7.h5/DSET_CMPD_ESC' +############################# +Opened "WATCH7.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_ESC... +dimension 0: 10->13 (increases) + Data: + (10) {1, {2, {2, 2, 2}, 2}, 3, {4, 4}}, + (11) {2, {3, {3, 3, 3}, 3}, 4, {5, 5}}, + (12) {3, {4, {4, 4, 4}, 4}, 5, {6, 6}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {1, {2, {2, 2, 2}, 2}, 3, {4, 4}}, {2, {3, {3, 3, 3}, 3}, 4, {5, + (2) 5}} diff --git a/hl/tools/testfiles/w-ext-cmpd-f1.ddl b/hl/tools/testfiles/w-ext-cmpd-f1.ddl new file mode 100644 index 0000000..4882a0c --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-f1.ddl @@ -0,0 +1,14 @@ +############################# + output for 'h5watch --fields=field1,field2 WATCH1.h5/DSET_CMPD' +############################# +Opened "WATCH1.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD... +dimension 0: 10->13 (increases) + Data: + (10) {1, {2, {2, 2, 2}, 2}}, {2, {3, {3, 3, 3}, 3}}, + (12) {3, {4, {4, 4, 4}, 4}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {1, {2, {2, 2, 2}, 2}}, {2, {3, {3, 3, 3}, 3}} diff --git a/hl/tools/testfiles/w-ext-cmpd-f2.ddl b/hl/tools/testfiles/w-ext-cmpd-f2.ddl new file mode 100644 index 0000000..178ce22 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-f2.ddl @@ -0,0 +1,14 @@ +############################# + output for 'h5watch --fields=field2.b,field4 WATCH1.h5/DSET_CMPD' +############################# +Opened "WATCH1.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD... +dimension 0: 10->13 (increases) + Data: + (10) {{{2, 2, 2}}, {4, 4}}, {{{3, 3, 3}}, {5, 5}}, {{{4, 4, 4}}, {6, + (12) 6}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {{{2, 2, 2}}, {4, 4}}, {{{3, 3, 3}}, {5, 5}} diff --git a/hl/tools/testfiles/w-ext-cmpd-f3.ddl b/hl/tools/testfiles/w-ext-cmpd-f3.ddl new file mode 100644 index 0000000..a3b34be --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-f3.ddl @@ -0,0 +1,13 @@ +############################# + output for 'h5watch --fields=field2.b.a,field2.c WATCH1.h5/DSET_CMPD' +############################# +Opened "WATCH1.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD... +dimension 0: 10->13 (increases) + Data: + (10) {{{2}}, {2}}, {{{3}}, {3}}, {{{4}}, {4}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {{{2}}, {2}}, {{{3}}, {3}} diff --git a/hl/tools/testfiles/w-ext-cmpd-ff1.ddl b/hl/tools/testfiles/w-ext-cmpd-ff1.ddl new file mode 100644 index 0000000..8ff1eee --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-ff1.ddl @@ -0,0 +1,14 @@ +############################# + output for 'h5watch --fields=field1 --fields=field2 WATCH4.h5/DSET_CMPD' +############################# +Opened "WATCH4.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD... +dimension 0: 10->13 (increases) + Data: + (10) {1, {2, {2, 2, 2}, 2}}, {2, {3, {3, 3, 3}, 3}}, + (12) {3, {4, {4, 4, 4}, 4}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {1, {2, {2, 2, 2}, 2}}, {2, {3, {3, 3, 3}, 3}} diff --git a/hl/tools/testfiles/w-ext-cmpd-ff2.ddl b/hl/tools/testfiles/w-ext-cmpd-ff2.ddl new file mode 100644 index 0000000..ceda0ae --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-ff2.ddl @@ -0,0 +1,14 @@ +############################# + output for 'h5watch --fields=field2.b --fields=field4 WATCH4.h5/DSET_CMPD' +############################# +Opened "WATCH4.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD... +dimension 0: 10->13 (increases) + Data: + (10) {{{2, 2, 2}}, {4, 4}}, {{{3, 3, 3}}, {5, 5}}, {{{4, 4, 4}}, {6, + (12) 6}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {{{2, 2, 2}}, {4, 4}}, {{{3, 3, 3}}, {5, 5}} diff --git a/hl/tools/testfiles/w-ext-cmpd-ff3.ddl b/hl/tools/testfiles/w-ext-cmpd-ff3.ddl new file mode 100644 index 0000000..f93f679 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-ff3.ddl @@ -0,0 +1,13 @@ +############################# + output for 'h5watch --fields=field2.b.a --fields=field2.c WATCH4.h5/DSET_CMPD' +############################# +Opened "WATCH4.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD... +dimension 0: 10->13 (increases) + Data: + (10) {{{2}}, {2}}, {{{3}}, {3}}, {{{4}}, {4}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {{{2}}, {2}}, {{{3}}, {3}} diff --git a/hl/tools/testfiles/w-ext-cmpd-label.ddl b/hl/tools/testfiles/w-ext-cmpd-label.ddl new file mode 100644 index 0000000..72add5b --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-label.ddl @@ -0,0 +1,21 @@ +############################# + output for 'h5watch --label WATCH4.h5/DSET_CMPD' +############################# +Opened "WATCH4.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD... +dimension 0: 10->13 (increases) + Data: + (10) {field1=1, field2={a=2, b={a=2, b=2, c=2}, c=2}, field3=3, + (10) field4={a=4, b=4}}, + (11) {field1=2, field2={a=3, b={a=3, b=3, c=3}, c=3}, field3=4, + (11) field4={a=5, b=5}}, + (12) {field1=3, field2={a=4, b={a=4, b=4, c=4}, c=4}, field3=5, + (12) field4={a=6, b=6}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {field1=1, field2={a=2, b={a=2, b=2, c=2}, c=2}, field3=3, + (1) field4={a=4, b=4}}, + (2) {field1=2, field2={a=3, b={a=3, b=3, c=3}, c=3}, field3=4, + (2) field4={a=5, b=5}} diff --git a/hl/tools/testfiles/w-ext-cmpd-two-f1.ddl b/hl/tools/testfiles/w-ext-cmpd-two-f1.ddl new file mode 100644 index 0000000..ed1f9ca --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-two-f1.ddl @@ -0,0 +1,50 @@ +############################# + output for 'h5watch --fields=field1,field2 WATCH2.h5/DSET_CMPD_TWO' +############################# +Opened "WATCH2.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} + (1,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} + (2,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} + (3,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} + (4,0) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,2) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,4) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,6) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,8) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,0) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,2) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,4) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,6) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,8) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) {2, {2, {2, 2, 2}, 2}}, + (7,0) {2, {2, {2, 2, 2}, 2}} +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) {3, {3, {3, 3, 3}, 3}}, + (9,0) {3, {3, {3, 3, 3}, 3}} +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) {4, {4, {4, 4, 4}, 4}}, {4, {4, {4, 4, 4}, 4}} + (1,1) {4, {4, {4, 4, 4}, 4}}, {4, {4, {4, 4, 4}, 4}} + (2,1) {4, {4, {4, 4, 4}, 4}}, {4, {4, {4, 4, 4}, 4}} +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) {7, {7, {7, 7, 7}, 7}}, {7, {7, {7, 7, 7}, 7}} +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-cmpd-two-f2.ddl b/hl/tools/testfiles/w-ext-cmpd-two-f2.ddl new file mode 100644 index 0000000..6ae1e29 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-two-f2.ddl @@ -0,0 +1,50 @@ +############################# + output for 'h5watch --fields=field2.b,field4 WATCH3.h5/DSET_CMPD_TWO' +############################# +Opened "WATCH3.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} + (1,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} + (2,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} + (3,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} + (4,0) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,2) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,4) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,6) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,8) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,0) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,2) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,4) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,6) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,8) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) {{{2, 2, 2}}, {2, 2}}, + (7,0) {{{2, 2, 2}}, {2, 2}} +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) {{{3, 3, 3}}, {3, 3}}, + (9,0) {{{3, 3, 3}}, {3, 3}} +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) {{{4, 4, 4}}, {4, 4}}, {{{4, 4, 4}}, {4, 4}} + (1,1) {{{4, 4, 4}}, {4, 4}}, {{{4, 4, 4}}, {4, 4}} + (2,1) {{{4, 4, 4}}, {4, 4}}, {{{4, 4, 4}}, {4, 4}} +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) {{{7, 7, 7}}, {7, 7}}, {{{7, 7, 7}}, {7, 7}} +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-cmpd-two-f3.ddl b/hl/tools/testfiles/w-ext-cmpd-two-f3.ddl new file mode 100644 index 0000000..1dc772b --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-two-f3.ddl @@ -0,0 +1,44 @@ +############################# + output for 'h5watch --fields=field2.b.a,field2.c WATCH3.h5/DSET_CMPD_TWO' +############################# +Opened "WATCH3.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) {{{1}}, {1}}, {{{1}}, {1}} + (1,10) {{{1}}, {1}}, {{{1}}, {1}} + (2,10) {{{1}}, {1}}, {{{1}}, {1}} + (3,10) {{{1}}, {1}}, {{{1}}, {1}} + (4,0) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (4,4) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (4,8) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (5,0) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (5,4) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (5,8) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}} +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) {{{2}}, {2}}, + (7,0) {{{2}}, {2}} +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) {{{3}}, {3}}, + (9,0) {{{3}}, {3}} +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) {{{4}}, {4}}, {{{4}}, {4}} + (1,1) {{{4}}, {4}}, {{{4}}, {4}} + (2,1) {{{4}}, {4}}, {{{4}}, {4}} +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) {{{7}}, {7}}, {{{7}}, {7}} +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-cmpd-two-ff1.ddl b/hl/tools/testfiles/w-ext-cmpd-two-ff1.ddl new file mode 100644 index 0000000..519894b --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-two-ff1.ddl @@ -0,0 +1,50 @@ +############################# + output for 'h5watch --fields=field1 --fields=field2 WATCH6.h5/DSET_CMPD_TWO' +############################# +Opened "WATCH6.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} + (1,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} + (2,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} + (3,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} + (4,0) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,2) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,4) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,6) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,8) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,0) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,2) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,4) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,6) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,8) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) {2, {2, {2, 2, 2}, 2}}, + (7,0) {2, {2, {2, 2, 2}, 2}} +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) {3, {3, {3, 3, 3}, 3}}, + (9,0) {3, {3, {3, 3, 3}, 3}} +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) {4, {4, {4, 4, 4}, 4}}, {4, {4, {4, 4, 4}, 4}} + (1,1) {4, {4, {4, 4, 4}, 4}}, {4, {4, {4, 4, 4}, 4}} + (2,1) {4, {4, {4, 4, 4}, 4}}, {4, {4, {4, 4, 4}, 4}} +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) {7, {7, {7, 7, 7}, 7}}, {7, {7, {7, 7, 7}, 7}} +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-cmpd-two-ff2.ddl b/hl/tools/testfiles/w-ext-cmpd-two-ff2.ddl new file mode 100644 index 0000000..c0f30d6 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-two-ff2.ddl @@ -0,0 +1,50 @@ +############################# + output for 'h5watch --fields=field2.b --fields=field4 WATCH6.h5/DSET_CMPD_TWO' +############################# +Opened "WATCH6.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} + (1,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} + (2,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} + (3,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} + (4,0) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,2) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,4) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,6) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,8) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,0) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,2) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,4) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,6) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,8) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) {{{2, 2, 2}}, {2, 2}}, + (7,0) {{{2, 2, 2}}, {2, 2}} +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) {{{3, 3, 3}}, {3, 3}}, + (9,0) {{{3, 3, 3}}, {3, 3}} +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) {{{4, 4, 4}}, {4, 4}}, {{{4, 4, 4}}, {4, 4}} + (1,1) {{{4, 4, 4}}, {4, 4}}, {{{4, 4, 4}}, {4, 4}} + (2,1) {{{4, 4, 4}}, {4, 4}}, {{{4, 4, 4}}, {4, 4}} +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) {{{7, 7, 7}}, {7, 7}}, {{{7, 7, 7}}, {7, 7}} +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-cmpd-two-ff3.ddl b/hl/tools/testfiles/w-ext-cmpd-two-ff3.ddl new file mode 100644 index 0000000..74bd5be --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-two-ff3.ddl @@ -0,0 +1,44 @@ +############################# + output for 'h5watch --fields=field2.b.a --fields=field2.c WATCH6.h5/DSET_CMPD_TWO' +############################# +Opened "WATCH6.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) {{{1}}, {1}}, {{{1}}, {1}} + (1,10) {{{1}}, {1}}, {{{1}}, {1}} + (2,10) {{{1}}, {1}}, {{{1}}, {1}} + (3,10) {{{1}}, {1}}, {{{1}}, {1}} + (4,0) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (4,4) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (4,8) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (5,0) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (5,4) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (5,8) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}} +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) {{{2}}, {2}}, + (7,0) {{{2}}, {2}} +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) {{{3}}, {3}}, + (9,0) {{{3}}, {3}} +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) {{{4}}, {4}}, {{{4}}, {4}} + (1,1) {{{4}}, {4}}, {{{4}}, {4}} + (2,1) {{{4}}, {4}}, {{{4}}, {4}} +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) {{{7}}, {7}}, {{{7}}, {7}} +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-cmpd-two.ddl b/hl/tools/testfiles/w-ext-cmpd-two.ddl new file mode 100644 index 0000000..9476c68 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-two.ddl @@ -0,0 +1,70 @@ +############################# + output for 'h5watch WATCH6.h5/DSET_CMPD_TWO' +############################# +Opened "WATCH6.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (0,11) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}} + (1,10) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (1,11) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}} + (2,10) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (2,11) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}} + (3,10) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (3,11) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}} + (4,0) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,1) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,2) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,3) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,4) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,5) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,6) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,7) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,8) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,9) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,10) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,11) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,0) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,1) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,2) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,3) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,4) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,5) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,6) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,7) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,8) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,9) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,10) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,11) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}} +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) {2, {2, {2, 2, 2}, 2}, 2, {2, 2}}, + (7,0) {2, {2, {2, 2, 2}, 2}, 2, {2, 2}} +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) {3, {3, {3, 3, 3}, 3}, 3, {3, 3}}, + (9,0) {3, {3, {3, 3, 3}, 3}, 3, {3, 3}} +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) {4, {4, {4, 4, 4}, 4}, 4, {4, 4}}, + (0,2) {4, {4, {4, 4, 4}, 4}, 4, {4, 4}} + (1,1) {4, {4, {4, 4, 4}, 4}, 4, {4, 4}}, + (1,2) {4, {4, {4, 4, 4}, 4}, 4, {4, 4}} + (2,1) {4, {4, {4, 4, 4}, 4}, 4, {4, 4}}, + (2,2) {4, {4, {4, 4, 4}, 4}, 4, {4, 4}} +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) {7, {7, {7, 7, 7}, 7}, 7, {7, 7}}, + (0,3) {7, {7, {7, 7, 7}, 7}, 7, {7, 7}} +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-cmpd.ddl b/hl/tools/testfiles/w-ext-cmpd.ddl new file mode 100644 index 0000000..e9b8deb --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd.ddl @@ -0,0 +1,16 @@ +############################# + output for 'h5watch WATCH4.h5/DSET_CMPD' +############################# +Opened "WATCH4.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD... +dimension 0: 10->13 (increases) + Data: + (10) {1, {2, {2, 2, 2}, 2}, 3, {4, 4}}, + (11) {2, {3, {3, 3, 3}, 3}, 4, {5, 5}}, + (12) {3, {4, {4, 4, 4}, 4}, 5, {6, 6}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {1, {2, {2, 2, 2}, 2}, 3, {4, 4}}, {2, {3, {3, 3, 3}, 3}, 4, {5, + (2) 5}} diff --git a/hl/tools/testfiles/w-ext-early.ddl b/hl/tools/testfiles/w-ext-early.ddl new file mode 100644 index 0000000..5af042e --- /dev/null +++ b/hl/tools/testfiles/w-ext-early.ddl @@ -0,0 +1,13 @@ +############################# + output for 'h5watch WATCH2.h5/DSET_ALLOC_EARLY' +############################# +Opened "WATCH2.h5" with sec2 driver. +Monitoring dataset /DSET_ALLOC_EARLY... +dimension 0: 10->13 (increases) + Data: + (10) 0, 1, 2 +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) 0, 1 diff --git a/hl/tools/testfiles/w-ext-late.ddl b/hl/tools/testfiles/w-ext-late.ddl new file mode 100644 index 0000000..b733d6e --- /dev/null +++ b/hl/tools/testfiles/w-ext-late.ddl @@ -0,0 +1,13 @@ +############################# + output for 'h5watch WATCH3.h5/DSET_ALLOC_LATE' +############################# +Opened "WATCH3.h5" with sec2 driver. +Monitoring dataset /DSET_ALLOC_LATE... +dimension 0: 10->13 (increases) + Data: + (10) 0, 1, 2 +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) 0, 1 diff --git a/hl/tools/testfiles/w-ext-one-d.ddl b/hl/tools/testfiles/w-ext-one-d.ddl new file mode 100644 index 0000000..64c8977 --- /dev/null +++ b/hl/tools/testfiles/w-ext-one-d.ddl @@ -0,0 +1,9 @@ +############################# + output for 'h5watch --dim WATCH1.h5/DSET_ONE' +############################# +Opened "WATCH1.h5" with sec2 driver. +Monitoring dataset /DSET_ONE... +dimension 0: 10->13 (increases) +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) diff --git a/hl/tools/testfiles/w-ext-one-simple.ddl b/hl/tools/testfiles/w-ext-one-simple.ddl new file mode 100644 index 0000000..dc14e6a --- /dev/null +++ b/hl/tools/testfiles/w-ext-one-simple.ddl @@ -0,0 +1,16 @@ +############################# + output for 'h5watch --simple WATCH5.h5/DSET_ONE' +############################# +Opened "WATCH5.h5" with sec2 driver. +Monitoring dataset /DSET_ONE... +dimension 0: 10->13 (increases) + Data: + 0 + 1 + 2 +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + 0 + 1 diff --git a/hl/tools/testfiles/w-ext-one.ddl b/hl/tools/testfiles/w-ext-one.ddl new file mode 100644 index 0000000..c091054 --- /dev/null +++ b/hl/tools/testfiles/w-ext-one.ddl @@ -0,0 +1,13 @@ +############################# + output for 'h5watch WATCH1.h5/DSET_ONE' +############################# +Opened "WATCH1.h5" with sec2 driver. +Monitoring dataset /DSET_ONE... +dimension 0: 10->13 (increases) + Data: + (10) 0, 1, 2 +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) 0, 1 diff --git a/hl/tools/testfiles/w-ext-two-d.ddl b/hl/tools/testfiles/w-ext-two-d.ddl new file mode 100644 index 0000000..926c786 --- /dev/null +++ b/hl/tools/testfiles/w-ext-two-d.ddl @@ -0,0 +1,21 @@ +############################# + output for 'h5watch --dim WATCH2.h5/DSET_TWO' +############################# +Opened "WATCH2.h5" with sec2 driver. +Monitoring dataset /DSET_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-two-width.ddl b/hl/tools/testfiles/w-ext-two-width.ddl new file mode 100644 index 0000000..1dcd4f3 --- /dev/null +++ b/hl/tools/testfiles/w-ext-two-width.ddl @@ -0,0 +1,44 @@ +############################# + output for 'h5watch --width=30 WATCH3.h5/DSET_TWO' +############################# +Opened "WATCH3.h5" with sec2 driver. +Monitoring dataset /DSET_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) 1, 1 + (1,10) 1, 1 + (2,10) 1, 1 + (3,10) 1, 1 + (4,0) 1, 1, 1, 1, 1, + (4,5) 1, 1, 1, 1, 1, + (4,10) 1, 1, + (5,0) 1, 1, 1, 1, 1, + (5,5) 1, 1, 1, 1, 1, + (5,10) 1, 1 +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) 2, + (7,0) 2 +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) 3, + (9,0) 3 +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) 4, 4 + (1,1) 4, 4 + (2,1) 4, 4 +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) 7, 7 +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-two.ddl b/hl/tools/testfiles/w-ext-two.ddl new file mode 100644 index 0000000..83d018c --- /dev/null +++ b/hl/tools/testfiles/w-ext-two.ddl @@ -0,0 +1,40 @@ +############################# + output for 'h5watch WATCH5.h5/DSET_TWO' +############################# +Opened "WATCH5.h5" with sec2 driver. +Monitoring dataset /DSET_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) 1, 1 + (1,10) 1, 1 + (2,10) 1, 1 + (3,10) 1, 1 + (4,0) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + (5,0) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) 2, + (7,0) 2 +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) 3, + (9,0) 3 +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) 4, 4 + (1,1) 4, 4 + (2,1) 4, 4 +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) 7, 7 +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-help1.ddl b/hl/tools/testfiles/w-help1.ddl new file mode 100644 index 0000000..27678cf --- /dev/null +++ b/hl/tools/testfiles/w-help1.ddl @@ -0,0 +1,37 @@ +############################# + output for 'h5watch --help' +############################# +Usage: h5watch [OPTIONS] [OBJECT] + + OPTIONS + --help Print a usage message and exit. + --version Print version number and exit. + --label Label members of compound typed dataset. + --simple Use a machine-readable output format. + --dim Monitor changes in size of dataset dimensions only. + --width=N Set the number of columns to N for output. + A value of 0 sets the number of columns to the + maximum (65535). The default width is 80 columns. + --polling=N Set the polling interval to N (in seconds) when the + dataset will be checked for appended data. The default + polling interval is 1. + --fields= + Display data for the fields specified in + for a compound data type. can be + specified as follows: + 1) A comma-separated list of field names in a + compound data type. "," is the separator + for field names while "." is the separator + for a nested field. + 2) A single field name in a compound data type. + Can use this option multiple times. + Note that backslash is the escape character to avoid + characters in field names that conflict with the tool's + separators. + + OBJECT is specified as [//] + Name of the HDF5 file. It may be preceded by path + separated by slashes to the specified HDF5 file. + Path separated by slashes to the specified dataset + Name of the dataset + diff --git a/hl/tools/testfiles/w-help2.ddl b/hl/tools/testfiles/w-help2.ddl new file mode 100644 index 0000000..1dff44e --- /dev/null +++ b/hl/tools/testfiles/w-help2.ddl @@ -0,0 +1,37 @@ +############################# + output for 'h5watch --help' +############################# +Usage: h5watch [OPTIONS] [OBJECT] + + OPTIONS + -h, --help Print a usage message and exit. + -V, --version Print version number and exit. + -l, --label Label members of compound typed dataset. + -S, --simple Use a machine-readable output format. + -d, --dim Monitor changes in size of dataset dimensions only. + -wN, --width=N Set the number of columns to N for output. + A value of 0 sets the number of columns to the + maximum (65535). The default width is 80 columns. + -pN, --polling=N Set the polling interval to N (in seconds) when the + dataset will be checked for appended data. The default + polling interval is 1. + -f, --fields= + Display data for the fields specified in + for a compound data type. can be + specified as follows: + 1) A comma-separated list of field names in a + compound data type. "," is the separator + for field names while "." is the separator + for a nested field. + 2) A single field name in a compound data type. + Can use this option multiple times. + Note that backslash is the escape character to avoid + characters in field names that conflict with the tool's + separators. + + OBJECT is specified as [//] + Name of the HDF5 file. It may be preceded by path + separated by slashes to the specified HDF5 file. + Path separated by slashes to the specified dataset + Name of the dataset + diff --git a/src/H5D.c b/src/H5D.c index c0966af..6e86e32 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -1127,6 +1127,10 @@ H5Dflush(hid_t dset_id) if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + /* Flush any dataset information still cached in memory */ + if (H5D_flush_real(dset, H5AC_dxpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info") + /* Call private function to flush dataset object */ if (H5O_flush_metadata(&dset->oloc, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") diff --git a/src/H5Dbtree2.c b/src/H5Dbtree2.c index 0cdf465..a28a33b 100644 --- a/src/H5Dbtree2.c +++ b/src/H5Dbtree2.c @@ -1516,6 +1516,13 @@ done: * * Programmer: Vailin Choi; June 2010 * + * Modifications: + * Vailin Choi; March 2011 + * Initialize size of an unfiltered chunk. + * This is a fix for for the assertion failure in: + * [src/H5FSsection.c:968: H5FS_sect_link_size: Assertion `bin < sinfo->nbins' failed.] + * which is uncovered by test_unlink_chunked_dataset() in test/unlink.c + * *------------------------------------------------------------------------- */ static herr_t @@ -1546,7 +1553,12 @@ H5D_bt2_idx_delete(const H5D_chk_idx_info_t *idx_info) remove_udata.f = idx_info->f; remove_udata.dxpl_id = idx_info->dxpl_id; - remove_op = idx_info->pline->nused > 0 ? H5D_bt2_filt_remove_cb : H5D_bt2_remove_cb; + if(idx_info->pline->nused > 0) /* filtered */ + remove_op = H5D_bt2_filt_remove_cb; + else { /* non-filtered */ + remove_op = H5D_bt2_remove_cb; + remove_udata.unfilt_size = idx_info->layout->size; + } /* Delete the v2 B-tree */ /*(space in the file for each object is freed in the 'remove' callback) */ diff --git a/src/H5Dint.c b/src/H5Dint.c index e8dc976..f3e0b3c 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -70,7 +70,6 @@ static herr_t H5D_swmr_teardown(const H5D_t *dataset, hid_t dxpl_id); static herr_t H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id); static herr_t H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id); -static herr_t H5D_flush_real(H5D_t *dataset, hid_t dxpl_id); /*********************/ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index daf8ca8..02eb950 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -604,6 +604,7 @@ H5_DLL herr_t H5D_check_filters(H5D_t *dataset); H5_DLL herr_t H5D_set_extent(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id); H5_DLL herr_t H5D_get_dxpl_cache(hid_t dxpl_id, H5D_dxpl_cache_t **cache); H5_DLL herr_t H5D_flush_sieve_buf(H5D_t *dataset, hid_t dxpl_id); +H5_DLL herr_t H5D_flush_real(H5D_t *dataset, hid_t dxpl_id); H5_DLL herr_t H5D_mark(H5D_t *dataset, hid_t dxpl_id, unsigned flags); /* Functions that perform direct serial I/O operations */ diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 6b1f576..e89af7e 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -157,7 +157,7 @@ static h5tool_format_t dataformat = { "{\n", /*cmpd_pre */ "}", /*cmpd_suf */ "\n", /*cmpd_end */ - + NULL, /* cmpd_listv */ ", ", /*vlen_sep */ "(", /*vlen_pre */ ")", /*vlen_suf */ @@ -241,6 +241,7 @@ static h5tool_format_t xml_dataformat = { "", /*cmpd_pre */ "", /*cmpd_suf */ "", /*cmpd_end */ + "", /*cmpd_listv */ " ", /*vlen_sep */ " ", /*vlen_pre */ diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index e7ba801..dbb20a0 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -74,6 +74,7 @@ NULL, /*fmt_ullong */ "{\n", /*cmpd_pre */ "}", /*cmpd_suf */ "\n", /*cmpd_end */ +NULL, /* cmpd_listv */ ", ", /*vlen_sep */ "(", /*vlen_pre */ @@ -2269,6 +2270,9 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools * + index_y * size_x * + index_x * + * Modifications: + * Vailin Choi; August 2010 + * Modified for h5watch to handle the printing of compound fields. *------------------------------------------------------------------------- */ static herr_t @@ -2306,6 +2310,11 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); ctx.size_last_dim = total_size[ctx.ndims - 1]; + if(info->cmpd_listv) + ctx.cmpd_listv = info->cmpd_listv; + else + ctx.cmpd_listv = NULL; + h5tools_display_simple_subset(stream, info, &ctx, dset, p_type, sset, f_space, total_size); /* Terminate the output */ @@ -2316,6 +2325,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset } CATCH + if(f_space >= 0 && H5Sclose(f_space) < 0) H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index b3e3dd2..17abbd5 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -192,6 +192,10 @@ typedef struct h5tools_dump_header_t { } h5tools_dump_header_t; +/* Forward declaration (see declaration in h5tools_str.c) */ +struct H5LD_memb_t; + + /* * Information about how to format output. */ @@ -327,12 +331,15 @@ typedef struct h5tool_format_t { * * end: a string to print after we reach the last element of * each compound type. prints out before the suf. + * + * listv: h5watch: vector containing info about the list of compound fields to be printed. */ const char *cmpd_name; const char *cmpd_sep; const char *cmpd_pre; const char *cmpd_suf; const char *cmpd_end; + const struct H5LD_memb_t **cmpd_listv; /* * Fields associated with vlen data types. @@ -499,12 +506,13 @@ typedef struct h5tools_context_t { hsize_t size_last_dim; /*the size of the last dimension, *needed so we can break after each *row */ - int indent_level; /*the number of times we need some + int indent_level; /*the number of times we need some *extra indentation */ int default_indent_level; /*this is used when the indent level gets changed */ hsize_t acc[H5S_MAX_RANK]; /* accumulator position */ hsize_t pos[H5S_MAX_RANK]; /* matrix position */ hsize_t sm_pos; /* current stripmine element position */ + struct H5LD_memb_t **cmpd_listv; /* h5watch: vector containing info about the list of compound fields to be printed */ } h5tools_context_t; typedef struct subset_d { diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 8c9960f..ae0646a 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -29,6 +29,15 @@ #include "h5tools_ref.h" #include "h5tools_str.h" /*function prototypes */ +/* Copied from hl/src/H5LDprivate.h */ +/* Info about the list of comma-separated compound fields */ +typedef struct H5LD_memb_t { + size_t tot_offset; + size_t last_tsize; + hid_t last_tid; + char **names; +} H5LD_memb_t; + /* * If REPEAT_VERBOSE is defined then character strings will be printed so * that repeated character sequences like "AAAAAAAAAA" are displayed as @@ -628,6 +637,10 @@ h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch) * * PVN, 28 March 2006 * added H5T_NATIVE_LDOUBLE case + * + * Vailin Choi; August 2010 + * Modified to handle printing of selected compound fields for h5watch. + * *------------------------------------------------------------------------- */ char * @@ -851,64 +864,121 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } } else if (H5Tget_class(type) == H5T_COMPOUND) { - unsigned j; - - nmembs = H5Tget_nmembers(type); - h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); + if(ctx->cmpd_listv) { /* there is */ + int save_indent_level; /* The indentation level */ + int i = 0, n = 0, x = 0; /* Local index variable */ + H5LD_memb_t **listv; /* Vector of information for */ + + listv = ctx->cmpd_listv; + ctx->cmpd_listv = NULL; + h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); + + /* + * Go through the vector containing info about the comma-separated list of + * compound fields and then members in each field: + * put in "{", "}", ",", member name and value accordingly. + */ + save_indent_level = ctx->indent_level; + for(n = 0; listv[n] != NULL; n++) { + if(n) + h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", " OPTIONAL_LINE_BREAK)); + + /* See notes for RPM 2000-10-31 below (copied) */ + if (ctx->indent_level >= 0 && str->len && str->s[str->len - 1] == '\n') { + + h5tools_str_append(str, OPT(info->line_pre, ""), ""); + + for (x = 0; x < ctx->indent_level + 1; x++) + h5tools_str_append(str, "%s", OPT(info->line_indent, "")); + } - for (j = 0; j < nmembs; j++) { - if (j) - h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", " OPTIONAL_LINE_BREAK)); + /* Process members of each field */ + for(i = 0; listv[n]->names[i] != NULL; i++) { + h5tools_str_append(str, OPT(info->cmpd_name, ""), listv[n]->names[i]); + if(i) { + ctx->indent_level++; + h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); + } + } + h5tools_str_sprint(str, info, container, listv[n]->last_tid, cp_vp + listv[n]->tot_offset, ctx); + if(ctx->indent_level >= 0) + for(x = ctx->indent_level; x >= 0; x--) + h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); + ctx->indent_level = save_indent_level; + } + + /* See notes for RPM 2000-10-31 below (copied) */ + h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); - /* RPM 2000-10-31 - * If the previous character is a line-feed (which is true when - * h5dump is running) then insert some white space for - * indentation. Be warned that column number calculations will be - * incorrect and that object indices at the beginning of the line - * will be missing (h5dump doesn't display them anyway). */ if (ctx->indent_level >= 0 && str->len && str->s[str->len - 1] == '\n') { - int x; h5tools_str_append(str, OPT(info->line_pre, ""), ""); - for (x = 0; x < ctx->indent_level + 1; x++) + for (x = 0; x < ctx->indent_level; x++) h5tools_str_append(str, "%s", OPT(info->line_indent, "")); } - /* The name */ - name = H5Tget_member_name(type, j); - h5tools_str_append(str, OPT(info->cmpd_name, ""), name); - free(name); - - /* The value */ - offset = H5Tget_member_offset(type, j); - memb = H5Tget_member_type(type, j); - - ctx->indent_level++; - h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx); - ctx->indent_level--; - - H5Tclose(memb); - } - - /* RPM 2000-10-31 - * If the previous character is a line feed (which is true when - * h5dump is running) then insert some white space for indentation. - * Be warned that column number calculations will be incorrect and - * that object indices at the beginning of the line will be missing - * (h5dump doesn't display them anyway). */ - h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); - - if (ctx->indent_level >= 0 && str->len && str->s[str->len - 1] == '\n') { - int x; - - h5tools_str_append(str, OPT(info->line_pre, ""), ""); - - for (x = 0; x < ctx->indent_level; x++) - h5tools_str_append(str, "%s", OPT(info->line_indent, "")); - } - - h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); + h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); + ctx->cmpd_listv = info->cmpd_listv; + } else { + unsigned j = 0; + + nmembs = H5Tget_nmembers(type); + h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); + + for (j = 0; j < nmembs; j++) { + if (j) + h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", " OPTIONAL_LINE_BREAK)); + + /* RPM 2000-10-31 + * If the previous character is a line-feed (which is true when + * h5dump is running) then insert some white space for + * indentation. Be warned that column number calculations will be + * incorrect and that object indices at the beginning of the line + * will be missing (h5dump doesn't display them anyway). */ + if (ctx->indent_level >= 0 && str->len && str->s[str->len - 1] == '\n') { + int x; + + h5tools_str_append(str, OPT(info->line_pre, ""), ""); + + for (x = 0; x < ctx->indent_level + 1; x++) + h5tools_str_append(str, "%s", OPT(info->line_indent, "")); + } + + /* The name */ + name = H5Tget_member_name(type, j); + h5tools_str_append(str, OPT(info->cmpd_name, ""), name); + free(name); + + /* The value */ + offset = H5Tget_member_offset(type, j); + memb = H5Tget_member_type(type, j); + + ctx->indent_level++; + h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx); + ctx->indent_level--; + + H5Tclose(memb); + } + + /* RPM 2000-10-31 + * If the previous character is a line feed (which is true when + * h5dump is running) then insert some white space for indentation. + * Be warned that column number calculations will be incorrect and + * that object indices at the beginning of the line will be missing + * (h5dump doesn't display them anyway). */ + h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); + + if (ctx->indent_level >= 0 && str->len && str->s[str->len - 1] == '\n') { + int x; + + h5tools_str_append(str, OPT(info->line_pre, ""), ""); + + for (x = 0; x < ctx->indent_level; x++) + h5tools_str_append(str, "%s", OPT(info->line_indent, "")); + } + h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); + } } else if (H5Tget_class(type) == H5T_ENUM) { char enum_name[1024]; -- cgit v0.12