From 8a75f17670000b64440890e710b2f9053d2ae31e Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 18 Jun 2008 13:20:31 -0500 Subject: [svn-r15232] Description: Bring back revisions 14700:14800 from the trunk Tested on: FreeBSD/32 6.2 (duty) in debug mode FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Mac OS X/32 10.5.2 (amazon) in debug mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode --- README.txt | 2 +- bin/runtest | 38 +- config/lt_vers.am | 2 +- configure | 47 +- configure.in | 22 +- release_docs/RELEASE.txt | 10 +- src/H5Adeprec.c | 2 + src/H5B2int.c | 6 +- src/H5F.c | 41 +- src/H5FScache.c | 4 +- src/H5FSsection.c | 4 +- src/H5Fpkg.h | 1 + src/H5Fprivate.h | 3 + src/H5HFhdr.c | 2 +- src/H5HFiblock.c | 10 +- src/H5HFpkg.h | 2 +- src/H5HFstat.c | 9 +- src/H5Lexternal.c | 200 +++- src/H5Odtype.c | 19 +- src/H5Vprivate.h | 20 + src/H5config.h.in | 3 + src/H5private.h | 46 + src/H5public.h | 4 +- src/H5system.c | 98 ++ src/Makefile.in | 2 +- test/Makefile.am | 3 +- test/Makefile.in | 4 +- test/dtypes.c | 108 ++- test/links.c | 902 +++++++++++++++++- test/objcopy.c | 2 +- test/tattr.c | 4 + tools/h5diff/h5diffgentest.c | 109 +-- tools/h5dump/h5dumpgentest.c | 38 +- tools/h5dump/testh5dump.sh.in | 3 +- tools/h5stat/h5stat_gentest.c | 2 +- tools/h5stat/testfiles/h5stat_newgrat.ddl | 20 +- tools/h5stat/testfiles/h5stat_newgrat.h5 | Bin 72236 -> 6363055 bytes tools/lib/h5diff.c | 217 +++-- tools/lib/h5diff_dset.c | 1369 ++++++++++++++------------- tools/lib/h5diff_util.c | 268 +++--- tools/lib/h5tools.c | 42 +- tools/testfiles/tbin4.ddl | 2 +- tools/testfiles/tbinary.h5 | Bin 806144 -> 2144 bytes windows/tools/h5dump/testh5dump.bat | 5 +- windows/tools/h5repack/h5repack.vcproj | 4 +- windows_vnet/tools/h5repack/h5repack.vcproj | 2 +- 46 files changed, 2567 insertions(+), 1134 deletions(-) diff --git a/README.txt b/README.txt index c18745d..4941476 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.0 currently under development +HDF5 version 1.9.2 currently under development Please refer to the release_docs/INSTALL file for installation instructions. ------------------------------------------------------------------------------ diff --git a/bin/runtest b/bin/runtest index 34386e4..4356db3 100755 --- a/bin/runtest +++ b/bin/runtest @@ -419,6 +419,34 @@ RUNSNAPTEST() fi } +TIMELIMIT_PARSE() +{ + # Function returns timeparam for timekeeper via standard out - + # any debug statements should be 'echo "Debug string" >&2' or timekeeper + # will declare timeparam to be non-numeric and ignore it. + while read x y ; do + # Scan for entry for this weekday. + xd=`echo $x | cut -f1 -d/` + if [ "$xd" = ${WEEKDAY} ]; then + # strip away the weekday/ part. + timeparam=`echo $x | cut -f2 -d/` + break + fi + case "$x" in + '' | '#'*) + # blank or comment lines. Continue. + ;; + ???/*) + # Ignore any entry not of this weekday. + ;; + *) + timeparam="$x" + ;; + esac + done + echo $timeparam + return +} # configuration parsing. # Taking configuration from input. @@ -561,7 +589,7 @@ errcode=0 # error code of the whole test skiptest=no # if test is skipped CC_SAVED="$CC" # CC & PATH maybe changed within a test. PATH_SAVED=$PATH # These save the original values. -timelimit=300 # time limit (minutes) for the timekeeper +timelimit=300 # default time limit (minutes) for the timekeeper ################################# # Parse options @@ -847,7 +875,7 @@ if [ -n "$TESTHOST" -a $HOSTNAME != "$TESTHOST" ]; then cd ${SNAPYARD}/log # Fork off timekeeper if concurrent tests will be used. if [ -n "$SRCDIR" ]; then - timelimit=`grep -v '^#' $TIMELIMIT` + timelimit=`TIMELIMIT_PARSE < $TIMELIMIT` ($SNAPYARD/current/bin/timekeeper $timelimit > $TIMEKEEPERLOG 2>&1 &) PRINT " Fork off timekeeper $timelimit" fi @@ -872,10 +900,10 @@ if [ -n "$TESTHOST" -a $HOSTNAME != "$TESTHOST" ]; then # launch concurrent tests only if srcdir is used if [ -n "$SRCDIR" ]; then - $CMD & + $CMD || REPORT_ERR "****FAILED ${h}: Abnormal exit from runtest****" && PRINT_BLANK & echo $! > PID.${h}_${CONFIGNAME} else - $CMD + $CMD || REPORT_ERR "****FAILED ${h}: Abnormal exit from runtest****" && PRINT_BLANK fi ;; NoRemoteCommand) @@ -899,7 +927,7 @@ if [ -n "$TESTHOST" -a $HOSTNAME != "$TESTHOST" ]; then TMP_OUTPUT="#${h}_${CONFIGNAME}.out" cat $TMP_OUTPUT # Verify test script did complete by checking the last lines - (tail -2 $TMP_OUTPUT | grep -s 'Grand total' > /dev/null 2>&1) || + (tail -5 $TMP_OUTPUT | grep -s 'Grand total' > /dev/null 2>&1) || (REPORT_ERR "****FAILED ${h}: snaptest did not complete****" && PRINT_BLANK) rm -f $TMP_OUTPUT PID.${h}_${CONFIGNAME} diff --git a/config/lt_vers.am b/config/lt_vers.am index f824437..a1e2d8b 100644 --- a/config/lt_vers.am +++ b/config/lt_vers.am @@ -17,7 +17,7 @@ # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 5 -LT_VERS_REVISION = 1 +LT_VERS_REVISION = 3 LT_VERS_AGE = 0 ## If the API changes *at all*, increment LT_VERS_INTERFACE and diff --git a/configure b/configure index c2913f3..699b5ae 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.in Id: configure.in 14547 2008-02-11 20:09:52Z epourmal . +# From configure.in Id: configure.in 14789 2008-04-02 18:29:17Z vchoi . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for HDF5 1.9.0. +# Generated by GNU Autoconf 2.61 for HDF5 1.9.2. # # Report bugs to . # @@ -729,8 +729,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='HDF5' PACKAGE_TARNAME='hdf5' -PACKAGE_VERSION='1.9.0' -PACKAGE_STRING='HDF5 1.9.0' +PACKAGE_VERSION='1.9.2' +PACKAGE_STRING='HDF5 1.9.2' PACKAGE_BUGREPORT='help@hdfgroup.org' ac_unique_file="src/H5.c" @@ -1478,7 +1478,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures HDF5 1.9.0 to adapt to many kinds of systems. +\`configure' configures HDF5 1.9.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1548,7 +1548,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of HDF5 1.9.0:";; + short | recursive ) echo "Configuration of HDF5 1.9.2:";; esac cat <<\_ACEOF @@ -1731,7 +1731,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -HDF5 configure 1.9.0 +HDF5 configure 1.9.2 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1745,7 +1745,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by HDF5 $as_me 1.9.0, which was +It was created by HDF5 $as_me 1.9.2, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -2440,7 +2440,7 @@ fi # Define the identity of the package. PACKAGE='hdf5' - VERSION='1.9.0' + VERSION='1.9.2' cat >>confdefs.h <<_ACEOF @@ -45712,7 +45712,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: checking for global timezone variable" >&5 echo $ECHO_N "checking for global timezone variable... $ECHO_C" >&6; } -case "'uname'" in +case "`uname`" in CYGWIN*) { echo "$as_me:$LINENO: result: disabled in CYGWIN" >&5 echo "${ECHO_T}disabled in CYGWIN" >&6; } @@ -50802,6 +50802,29 @@ else echo "${ECHO_T}false" >&6; } fi +{ echo "$as_me:$LINENO: checking if the machine has window style path name" >&5 +echo $ECHO_N "checking if the machine has window style path name... $ECHO_C" >&6; } +if test "${hdf5_have_window_path+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + hdf5_have_window_path=no +fi + + +if test ${hdf5_have_window_path} = "yes"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WINDOW_PATH 1 +_ACEOF + + { echo "$as_me:$LINENO: result: true" >&5 +echo "${ECHO_T}true" >&6; } +else + { echo "$as_me:$LINENO: result: false" >&5 +echo "${ECHO_T}false" >&6; } +fi + + { echo "$as_me:$LINENO: checking if converting from long double to integers is accurate" >&5 echo $ECHO_N "checking if converting from long double to integers is accurate... $ECHO_C" >&6; } @@ -52689,7 +52712,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by HDF5 $as_me 1.9.0, which was +This file was extended by HDF5 $as_me 1.9.2, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -52742,7 +52765,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -HDF5 config.status 1.9.0 +HDF5 config.status 1.9.2 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.in b/configure.in index 9f79411..26c9044 100644 --- a/configure.in +++ b/configure.in @@ -26,7 +26,7 @@ dnl dnl NOTE: Don't forget to change the version number here when we do a dnl release!!! dnl -AC_INIT([HDF5], [1.9.0], [help@hdfgroup.org]) +AC_INIT([HDF5], [1.9.2], [help@hdfgroup.org]) AC_CONFIG_SRCDIR([src/H5.c]) AM_CONFIG_HEADER([src/H5config.h]) @@ -1729,7 +1729,7 @@ AC_MSG_RESULT([no])) dnl Check whether the global variable `timezone' is defined. AC_MSG_CHECKING([for global timezone variable]) -case "'uname'" in +case "`uname`" in CYGWIN*) AC_MSG_RESULT([disabled in CYGWIN]) ;; @@ -2814,6 +2814,24 @@ else AC_MSG_RESULT([false]) fi +dnl ---------------------------------------------------------------------- +dnl Set the flag to indicate that the machine has window style pathname, +dnl that is, "drive-letter:\" (e.g. "C:") or "drive-letter:/" (e.g. "C:/"). +dnl (This flag should be _unset_ for all machines, except for Windows, where +dnl it's set in the custom Windows H5pubconf.h file) +dnl +AC_MSG_CHECKING([if the machine has window style path name]) +AC_CACHE_VAL([hdf5_have_window_path], [hdf5_have_window_path=no]) + +if test ${hdf5_have_window_path} = "yes"; then + AC_DEFINE([HAVE_WINDOW_PATH], [1], + [Define if your system has window style path name.]) + AC_MSG_RESULT([true]) +else + AC_MSG_RESULT([false]) +fi + + dnl ----------------------------------------------------------------------- dnl Set flag to indicate that the machine can handle conversion from dnl long double to integers accurately. This flag should be set "yes" for diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 98513df..e5f4539 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.0 currently under development +HDF5 version 1.9.2 currently under development ================================================================================ @@ -70,6 +70,14 @@ Bug Fixes since HDF5-1.8.0 release Library ------- + - Fixed possible file corruption bug when encoding datatype + descriptions for compound datatypes whose size was between + 256 & 511 bytes and the file was opened with the "use the + latest format" property enabled (with H5Pset_libver_bounds). + (QAK - 2008/03/13) + - Fixed bug in H5Aget_num_attrs() routine to handle invalid location + ID correctly. (QAK - 2008/03/11) + Configuration ------------- diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index f2c63e9..197679c 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -313,6 +313,8 @@ H5Aget_num_attrs(hid_t loc_id) H5TRACE1("Is", "i", loc_id); /* check arguments */ + if(H5I_BADID == H5I_get_type(loc_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad location ID") if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(NULL == (obj = H5I_object(loc_id))) diff --git a/src/H5B2int.c b/src/H5B2int.c index 2625c63..eae1291 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -203,7 +203,7 @@ HDmemset(shared->page, 0, shared->node_size); /* Compute size to store # of records in each node */ /* (uses leaf # of records because its the largest) */ - shared->max_nrec_size = (H5V_log2_gen((uint64_t)shared->node_info[0].max_nrec) + 7) / 8; + shared->max_nrec_size = H5V_limit_enc_size((uint64_t)shared->node_info[0].max_nrec); HDassert(shared->max_nrec_size <= H5B2_SIZEOF_RECORDS_PER_NODE); /* Initialize internal node info */ @@ -217,7 +217,7 @@ HDmemset(shared->page, 0, shared->node_size); shared->node_info[u].cum_max_nrec = ((shared->node_info[u].max_nrec + 1) * shared->node_info[u - 1].cum_max_nrec) + shared->node_info[u].max_nrec; - shared->node_info[u].cum_max_nrec_size = (H5V_log2_gen((uint64_t)shared->node_info[u].cum_max_nrec) + 7) / 8; + shared->node_info[u].cum_max_nrec_size = H5V_limit_enc_size((uint64_t)shared->node_info[u].cum_max_nrec); if((shared->node_info[u].nat_rec_fac = H5FL_fac_init(shared->type->nrec_size * shared->node_info[u].max_nrec)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") @@ -576,7 +576,7 @@ H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_t *bt2, unsigned *bt2_flags_ptr) shared->node_info[shared->depth].merge_nrec = (shared->node_info[shared->depth].max_nrec * shared->merge_percent) / 100; shared->node_info[shared->depth].cum_max_nrec = ((shared->node_info[shared->depth].max_nrec + 1) * shared->node_info[shared->depth - 1].cum_max_nrec) + shared->node_info[shared->depth].max_nrec; - shared->node_info[shared->depth].cum_max_nrec_size = (H5V_log2_gen((uint64_t)shared->node_info[shared->depth].cum_max_nrec) + 7) / 8; + shared->node_info[shared->depth].cum_max_nrec_size = H5V_limit_enc_size((uint64_t)shared->node_info[shared->depth].cum_max_nrec); if((shared->node_info[shared->depth].nat_rec_fac = H5FL_fac_init(shared->type->nrec_size * shared->node_info[shared->depth].max_nrec)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") if((shared->node_info[shared->depth].node_ptr_fac = H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (shared->node_info[shared->depth].max_nrec + 1))) == NULL) diff --git a/src/H5F.c b/src/H5F.c index b1171bd..0b3ebfd 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -990,6 +990,9 @@ done: * Programmer: Robb Matzke * matzke@llnl.gov * Jul 18 1997 + * Modifications: + * Vailin Choi, April 2, 2008 + * Free f->extpath * *------------------------------------------------------------------------- */ @@ -1091,6 +1094,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) /* Free the non-shared part of the file */ f->name = H5MM_xfree(f->name); + f->extpath = H5MM_xfree(f->extpath); f->mtab.child = H5MM_xfree(f->mtab.child); f->mtab.nalloc = 0; if(H5FO_top_dest(f) < 0) @@ -1101,6 +1105,8 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_dest() */ + + /*------------------------------------------------------------------------- * Function: H5F_open @@ -1180,6 +1186,9 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) * Modified H5F_flush call to take one flag instead of * multiple Boolean flags. * + * Vailin Choi, 2008-04-02 + * To formulate path for later searching of target file for external link + * via H5_build_extpath(). *------------------------------------------------------------------------- */ H5F_t * @@ -1376,6 +1385,10 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match") } /* end if */ + /* formulate the absolute path for later search of target file for external link */ + if (H5_build_extpath(name, &file->extpath) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build extpath") + /* Success */ ret_value = file; @@ -2175,6 +2188,33 @@ H5F_get_intent(const H5F_t *f) /*------------------------------------------------------------------------- + * Function: H5F_get_extpath + * + * Purpose: Retrieve the file's 'extpath' flags + * This is used by H5L_extern_traverse() to retrieve the main file's location + * when searching the target file. + * + * Return: 'extpath' on success/abort on failure (shouldn't fail) + * + * Programmer: Vailin Choi, April 2, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +char * +H5F_get_extpath(const H5F_t *f) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_extpath) + + HDassert(f); + + FUNC_LEAVE_NOAPI(f->extpath) +} /* end H5F_get_extpath() */ + + +/*------------------------------------------------------------------------- * Function: H5F_sizeof_addr * * Purpose: Quick and dirty routine to retrieve the size of the file's size_t @@ -3664,4 +3704,3 @@ H5Fget_info(hid_t obj_id, H5F_info_t *finfo) done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_info() */ - diff --git a/src/H5FScache.c b/src/H5FScache.c index 74a9aab..8ad9631 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -606,7 +606,7 @@ HDfprintf(stderr, "%s: fspace->addr = %a, fs_addr = %a\n", FUNC, fspace->addr, f unsigned sect_cnt_size; /* The size of the section size counts */ /* Compute the size of the section counts */ - sect_cnt_size = MAX(1, (H5V_log2_gen(fspace->serial_sect_count) + 7) / 8); + sect_cnt_size = H5V_limit_enc_size((uint64_t)fspace->serial_sect_count); #ifdef QAK HDfprintf(stderr, "%s: sect_cnt_size = %u\n", FUNC, sect_cnt_size); HDfprintf(stderr, "%s: fspace->sect_len_size = %u\n", FUNC, fspace->sect_len_size); @@ -905,7 +905,7 @@ HDfprintf(stderr, "%s: sinfo->fspace->addr = %a\n", FUNC, sinfo->fspace->addr); /* Set up user data for iterator */ udata.sinfo = sinfo; udata.p = &p; - udata.sect_cnt_size = MAX(1, (H5V_log2_gen(sinfo->fspace->serial_sect_count) + 7) / 8); + udata.sect_cnt_size = H5V_limit_enc_size((uint64_t)sinfo->fspace->serial_sect_count); #ifdef QAK HDfprintf(stderr, "%s: udata.sect_cnt_size = %u\n", FUNC, udata.sect_cnt_size); #endif /* QAK */ diff --git a/src/H5FSsection.c b/src/H5FSsection.c index c589aa0..34da067 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -147,7 +147,7 @@ H5FS_sinfo_new(H5F_t *f, H5FS_t *fspace) sinfo->nbins = H5V_log2_gen(fspace->max_sect_size); sinfo->sect_prefix_size = H5FS_SINFO_PREFIX_SIZE(f); sinfo->sect_off_size = (fspace->max_sect_addr + 7) / 8; - sinfo->sect_len_size = (H5V_log2_gen(fspace->max_sect_size) + 7) / 8; + sinfo->sect_len_size = H5V_limit_enc_size((uint64_t)fspace->max_sect_size); sinfo->fspace = fspace; #ifdef QAK HDfprintf(stderr, "%s: sinfo->nbins = %u\n", FUNC, sinfo->nbins); @@ -1300,7 +1300,7 @@ HDfprintf(stderr, "%s: fspace->sinfo->serial_size_count = %Zu\n", FUNC, fspace-> HDfprintf(stderr, "%s: fspace->sinfo->serial_size_count = %Zu\n", FUNC, fspace->sinfo->serial_size_count); HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", FUNC, fspace->serial_sect_count); #endif /* QAK */ - sect_buf_size += fspace->sinfo->serial_size_count * MAX(1, ((H5V_log2_gen(fspace->serial_sect_count) + 7) / 8)); + sect_buf_size += fspace->sinfo->serial_size_count * H5V_limit_enc_size((uint64_t)fspace->serial_sect_count); /* Size for each differently sized serializable section */ sect_buf_size += fspace->sinfo->serial_size_count * fspace->sinfo->sect_len_size; diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index bea0579..2e34e64 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -149,6 +149,7 @@ typedef struct H5F_mtab_t { struct H5F_t { unsigned intent; /* The flags passed to H5F_open()*/ char *name; /* Name used to open file */ + char *extpath; /* Path for searching target external link file */ H5F_file_t *shared; /* The shared file info */ unsigned nopen_objs; /* Number of open object headers*/ H5FO_t *obj_count; /* # of time each object is opened through top file structure */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index b61773a..cd97758 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -265,6 +265,7 @@ typedef struct H5F_t H5F_t; #define H5F_GC_REF(F) ((F)->shared->gc_ref) #define H5F_USE_LATEST_FORMAT(F) ((F)->shared->latest_format) #define H5F_INTENT(F) ((F)->intent) +#define H5F_EXTPATH(F) ((F)->extpath) #define H5F_GET_FC_DEGREE(F) ((F)->shared->fc_degree) #define H5F_STORE_MSG_CRT_IDX(F) ((F)->shared->store_msg_crt_idx) #define H5F_GET_FILENO(F,FILENUM) ((FILENUM) = (F)->shared->lf->fileno) @@ -284,6 +285,7 @@ typedef struct H5F_t H5F_t; #define H5F_GC_REF(F) (H5F_gc_ref(F)) #define H5F_USE_LATEST_FORMAT(F) (H5F_use_latest_format(F)) #define H5F_INTENT(F) (H5F_get_intent(F)) +#define H5F_EXTPATH(F) (H5F_get_extpath(F)) #define H5F_GET_FC_DEGREE(F) (H5F_get_fc_degree(F)) #define H5F_STORE_MSG_CRT_IDX(F) (H5F_store_msg_crt_idx(F)) #define H5F_GET_FILENO(F,FILENUM) (H5F_get_filenum((F), &(FILENUM))) @@ -423,6 +425,7 @@ H5_DLL herr_t H5F_try_close(H5F_t *f); H5_DLL hid_t H5F_get_driver_id(const H5F_t *f); H5_DLL hid_t H5F_get_access_plist(H5F_t *f); H5_DLL unsigned H5F_get_intent(const H5F_t *f); +H5_DLL char *H5F_get_extpath(const H5F_t *f); H5_DLL herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum); H5_DLL hid_t H5F_get_id(H5F_t *file); H5_DLL unsigned H5F_get_obj_count(const H5F_t *f, unsigned types); diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index c1b856b..60d5002 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -225,7 +225,7 @@ H5HF_hdr_finish_init_phase1(H5HF_hdr_t *hdr) /* Set the size of heap IDs */ hdr->heap_len_size = MIN(hdr->man_dtable.max_dir_blk_off_size, - ((H5V_log2_gen((uint64_t)hdr->max_man_size) + 7) / 8)); + H5V_limit_enc_size((uint64_t)hdr->max_man_size)); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c index 70133aa..7fedc48 100644 --- a/src/H5HFiblock.c +++ b/src/H5HFiblock.c @@ -1591,7 +1591,7 @@ done: */ herr_t H5HF_man_iblock_size(H5F_t *f, hid_t dxpl_id, H5HF_hdr_t *hdr, haddr_t iblock_addr, - unsigned nrows, hsize_t *heap_size) + unsigned nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, hsize_t *heap_size) { H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ hbool_t did_protect; /* Whether we protected the indirect block or not */ @@ -1608,7 +1608,7 @@ H5HF_man_iblock_size(H5F_t *f, hid_t dxpl_id, H5HF_hdr_t *hdr, haddr_t iblock_ad HDassert(heap_size); /* Protect the indirect block */ - if(NULL == (iblock = H5HF_man_iblock_protect(hdr, dxpl_id, iblock_addr, nrows, NULL, 0, FALSE, H5AC_READ, &did_protect))) + if(NULL == (iblock = H5HF_man_iblock_protect(hdr, dxpl_id, iblock_addr, nrows, par_iblock, par_entry, FALSE, H5AC_READ, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap indirect block") /* Accumulate size of this indirect block */ @@ -1624,13 +1624,14 @@ H5HF_man_iblock_size(H5F_t *f, hid_t dxpl_id, H5HF_hdr_t *hdr, haddr_t iblock_ad entry = hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width; first_row_bits = H5V_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size) + H5V_log2_of2(hdr->man_dtable.cparam.width); - num_indirect_rows = (H5V_log2_gen(hdr->man_dtable.row_block_size[u]) - first_row_bits) + 1; + num_indirect_rows = + (H5V_log2_gen(hdr->man_dtable.row_block_size[hdr->man_dtable.max_direct_rows]) - first_row_bits) + 1; for(u = hdr->man_dtable.max_direct_rows; u < iblock->nrows; u++, num_indirect_rows++) { size_t v; /* Local index variable */ for(v = 0; v < hdr->man_dtable.cparam.width; v++, entry++) if(H5F_addr_defined(iblock->ents[entry].addr)) - if(H5HF_man_iblock_size(f, dxpl_id, hdr, iblock->ents[entry].addr, num_indirect_rows, heap_size) < 0) + if(H5HF_man_iblock_size(f, dxpl_id, hdr, iblock->ents[entry].addr, num_indirect_rows, iblock, entry, heap_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to get fractal heap storage info for indirect block") } /* end for */ } /* end if */ @@ -1639,6 +1640,7 @@ done: /* Release the indirect block */ if(iblock && H5HF_man_iblock_unprotect(iblock, dxpl_id, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + iblock = NULL; FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iblock_size() */ diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index 702ce08..fd332e5 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -601,7 +601,7 @@ H5_DLL herr_t H5HF_man_iblock_delete(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t iblock_addr, unsigned iblock_nrows, H5HF_indirect_t *par_iblock, unsigned par_entry); H5_DLL herr_t H5HF_man_iblock_size(H5F_t *f, hid_t dxpl_id, H5HF_hdr_t *hdr, - haddr_t iblock_addr, unsigned nrows, hsize_t *heap_size/*out*/); + haddr_t iblock_addr, unsigned nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, hsize_t *heap_size/*out*/); /* Direct block routines */ H5_DLL herr_t H5HF_man_dblock_new(H5HF_hdr_t *fh, hid_t dxpl_id, size_t request, diff --git a/src/H5HFstat.c b/src/H5HFstat.c index 2e3e189..d151b47 100644 --- a/src/H5HFstat.c +++ b/src/H5HFstat.c @@ -128,6 +128,7 @@ H5HF_size(const H5HF_t *fh, hid_t dxpl_id, hsize_t *heap_size) { H5HF_hdr_t *hdr; /* Fractal heap header */ herr_t ret_value = SUCCEED; /* Return value */ + hsize_t meta_size = 0; /* free space storage size */ FUNC_ENTER_NOAPI(H5HF_size, FAIL) @@ -147,7 +148,7 @@ H5HF_size(const H5HF_t *fh, hid_t dxpl_id, hsize_t *heap_size) /* Check for indirect blocks for managed objects */ if(H5F_addr_defined(hdr->man_dtable.table_addr) && hdr->man_dtable.curr_root_rows != 0) - if(H5HF_man_iblock_size(hdr->f, dxpl_id, hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, heap_size) < 0) + if(H5HF_man_iblock_size(hdr->f, dxpl_id, hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, NULL, 0, heap_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get fractal heap storage info for indirect block") /* Get B-tree storage for huge objects in fractal heap */ @@ -172,9 +173,11 @@ H5HF_size(const H5HF_t *fh, hid_t dxpl_id, hsize_t *heap_size) } /* end if */ /* Get storage for free-space tracking info */ - if(H5F_addr_defined(hdr->fs_addr)) - if(H5HF_space_size(hdr, dxpl_id, heap_size) < 0) + if(H5F_addr_defined(hdr->fs_addr)) { + if(H5HF_space_size(hdr, dxpl_id, &meta_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info") + *heap_size += meta_size; + } done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 70ed4b3..b83d088 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -77,6 +77,81 @@ H5L_init_extern_interface(void) } /* H5L_init_extern_interface() */ + +/*-------------------------------------------------------------------------- + * Function: H5L_getenv_prefix_name -- + * + * Purpose: Get the first pathname in the list of pathnames stored in ENV_PREFIX, + * which is separated by the environment delimiter. + * ENV_PREFIX is modified to point to the remaining pathnames + * in the list. + * + * Return: A pointer to a pathname + * + * Programmer: Vailin Choi, April 2, 2008 + * +--------------------------------------------------------------------------*/ +static char * +H5L_getenv_prefix_name(char **env_prefix/*in,out*/) +{ + char *retptr=NULL; + char *strret=NULL; + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5L_getenv_prefix_name) + + strret = HDstrchr(*env_prefix, COLON_SEPC); + if (strret == NULL) { + retptr = *env_prefix; + *env_prefix = strret; + } else { + retptr = *env_prefix; + *env_prefix = strret + 1; + *strret = '\0'; + } + return(retptr); + FUNC_LEAVE_NOAPI(retptr) +} + + +/*-------------------------------------------------------------------------- + * Function: H5L_build_name + * + * Purpose: Prepend PREFIX to FILE_NAME and store in FULL_NAME + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi, April 2, 2008 + * +--------------------------------------------------------------------------*/ +static herr_t +H5L_build_name(char *prefix, char *file_name, char **full_name/*out*/) +{ + size_t prefix_len; /* length of prefix */ + size_t fname_len; /* Length of external link file name */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5L_build_name) + + prefix_len = HDstrlen(prefix); + fname_len = HDstrlen(file_name); + + /* Allocate a buffer to hold the filename + prefix + possibly the delimiter + terminating null byte */ + if(NULL == (*full_name = H5MM_malloc(prefix_len + fname_len + 2))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate filename buffer") + + /* Copy the prefix into the buffer */ + HDstrcpy(*full_name, prefix); + if (!CHECK_DELIMITER(prefix[prefix_len-1])) + HDstrcat(*full_name, DIR_SEPS); + + /* Add the external link's filename to the prefix supplied */ + HDstrcat(*full_name, file_name); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5L_build_name() */ + + /*------------------------------------------------------------------------- * Function: H5L_extern_traverse * @@ -93,6 +168,10 @@ H5L_init_extern_interface(void) * * Programmer: James Laird * Monday, July 10, 2006 + * Modifications: + * Vailin Choi, April 2, 2008 + * Add handling to search for the target file + * See description in RM: H5Lcreate_external * *------------------------------------------------------------------------- */ @@ -115,6 +194,11 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, hid_t ext_obj = -1; /* ID for external link's object */ hid_t ret_value; /* Return value */ + char *tempname=NULL, *ptr=NULL, *extpath=NULL; + char *env_prefix=NULL, *tmp_env_prefix=NULL; + char *out_prefix_name=NULL, *pp=NULL; + + FUNC_ENTER_NOAPI(H5L_extern_traverse, FAIL) /* Sanity checks */ @@ -136,28 +220,6 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* Get the current prefix */ - if(H5P_get(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external link prefix") - - /* Check for prefix being set, if so, prepend it to the filename */ - if(my_prefix) { - size_t prefix_len = HDstrlen(my_prefix); - - /* Allocate a buffer to hold the filename plus prefix */ - if(NULL == (full_name = H5MM_malloc(prefix_len + fname_len + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate filename buffer") - - /* Copy the prefix into the buffer */ - HDstrcpy(full_name, my_prefix); - - /* Add the external link's filename to the prefix supplied */ - HDstrcat(full_name, (const char *)p); - - /* Point to name w/prefix */ - file_name = full_name; - } /* end if */ - /* Get the location for the group holding the external link */ if(H5G_loc(cur_group, &loc) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get object location") @@ -184,10 +246,92 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") } /* end if */ - /* Open the external file */ - /* (extra work with file intent to mask off inappropriate flags) */ - if(NULL == (ext_file = H5F_open(file_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, FAIL, "unable to open external file") + /* + * Start searching for the target file + */ + if ((tempname=H5MM_strdup(file_name)) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* target file_name is an absolute pathname: see RM for detailed description */ + if (CHECK_ABSOLUTE(file_name) || CHECK_ABS_PATH(file_name)) { + if(NULL == (ext_file = H5F_open(file_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), + H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) { + H5E_clear_stack(NULL); + /* get last component of file_name */ + GET_LAST_DELIMITER(file_name, ptr) + HDassert(ptr); + HDstrcpy(tempname, ++ptr); + } + } else if (CHECK_ABS_DRIVE(file_name)) { + if(NULL == (ext_file = H5F_open(file_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), + H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) { + H5E_clear_stack(NULL); + /* strip ":" */ + HDstrcpy(tempname, &file_name[2]); + } + } + + /* try searching from paths set in the environment variable */ + if ((ext_file == NULL) && (env_prefix=HDgetenv("HDF5_EXT_PREFIX"))) { + + tmp_env_prefix = H5MM_strdup(env_prefix); + pp = tmp_env_prefix; + + while ((tmp_env_prefix) && (*tmp_env_prefix)) { + out_prefix_name = H5L_getenv_prefix_name(&tmp_env_prefix/*in,out*/); + if ((out_prefix_name) && (*out_prefix_name)) { + + if (H5L_build_name(out_prefix_name, tempname, &full_name/*out*/) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") + + ext_file = H5F_open(full_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), + H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id); + if (full_name) + H5MM_xfree(full_name); + if (ext_file != NULL) + break; + H5E_clear_stack(NULL); + } + } /* end while */ + if (pp) + H5MM_xfree(pp); + } + + /* try searching from property list */ + if (ext_file == NULL) { + if(H5P_get(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external link prefix") + if (my_prefix) { + if (H5L_build_name(my_prefix, tempname, &full_name/*out*/) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") + if ((ext_file=H5F_open(full_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), + H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)) == NULL) + H5E_clear_stack(NULL); + if (full_name) + H5MM_xfree(full_name); + } + } + + /* try searching from main file's "extpath":see description in H5F_open() & H5_build_extpath() */ + if ((ext_file == NULL) && (extpath=H5F_EXTPATH(loc.oloc->file))) { + if (H5L_build_name(extpath, tempname, &full_name/*out*/) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") + if ((ext_file = H5F_open(full_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), + H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)) == NULL) + H5E_clear_stack(NULL); + if (full_name) + H5MM_xfree(full_name); + } + + /* try the relative file_name stored in tempname */ + if (ext_file == NULL) { + if ((ext_file=H5F_open(tempname, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), + H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)) == NULL) + HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, FAIL, "unable to open external file") + } + + if (tempname) + H5MM_xfree(tempname); /* Increment the number of open objects, to hold the file open */ H5F_incr_nopen_objs(ext_file); @@ -220,10 +364,6 @@ done: if(ext_file && H5F_try_close(ext_file) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTCLOSEFILE, FAIL, "problem closing external file") - /* Free full_name if it's been allocated */ - if(full_name) - H5MM_xfree(full_name); - /* Close object if it's open and something failed */ if(ret_value < 0 && ext_obj >= 0 && H5I_dec_ref(ext_obj) < 0) HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for external object") diff --git a/src/H5Odtype.c b/src/H5Odtype.c index ac07edf..ba343bc 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -232,10 +232,11 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) case H5T_COMPOUND: { unsigned offset_nbytes; /* Size needed to encode member offsets */ + size_t max_memb_pos = 0; /* Maximum member covered, so far */ unsigned j; /* Compute the # of bytes required to store a member offset */ - offset_nbytes = (H5V_log2_gen((uint64_t)dt->shared->size) + 7) / 8; + offset_nbytes = H5V_limit_enc_size((uint64_t)dt->shared->size); /* * Compound datatypes... @@ -336,6 +337,18 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) /* Set the field datatype (finally :-) */ dt->shared->u.compnd.memb[i].type = temp_type; + /* Check if this field overlaps with a prior field */ + /* (probably indicates that the file is corrupt) */ + if(i > 0 && dt->shared->u.compnd.memb[i].offset < max_memb_pos) { + for(j = 0; j < i; j++) + if(dt->shared->u.compnd.memb[i].offset >= dt->shared->u.compnd.memb[j].offset + && dt->shared->u.compnd.memb[i].offset < (dt->shared->u.compnd.memb[j].offset + dt->shared->u.compnd.memb[j].size)) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "member overlaps with previous member") + } /* end if */ + + /* Update the maximum member position covered */ + max_memb_pos = MAX(max_memb_pos, (dt->shared->u.compnd.memb[i].offset + dt->shared->u.compnd.memb[i].size)); + /* Check if the datatype stayed packed */ if(dt->shared->u.compnd.packed) { /* Check if the member type is packed */ @@ -734,7 +747,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) unsigned offset_nbytes; /* Size needed to encode member offsets */ /* Compute the # of bytes required to store a member offset */ - offset_nbytes = (H5V_log2_gen((uint64_t)dt->shared->size) + 7) / 8; + offset_nbytes = H5V_limit_enc_size((uint64_t)dt->shared->size); /* * Compound datatypes... @@ -1097,7 +1110,7 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) unsigned offset_nbytes; /* Size needed to encode member offsets */ /* Compute the # of bytes required to store a member offset */ - offset_nbytes = (H5V_log2_gen((uint64_t)dt->shared->size) + 7) / 8; + offset_nbytes = H5V_limit_enc_size((uint64_t)dt->shared->size); /* Compute the total size needed to encode compound datatype */ for(u = 0; u < dt->shared->u.compnd.nmembs; u++) { diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h index 94b3699..b92266c 100644 --- a/src/H5Vprivate.h +++ b/src/H5Vprivate.h @@ -410,5 +410,25 @@ H5V_log2_of2(uint32_t n) return(MultiplyDeBruijnBitPosition[(n * (uint32_t)0x077CB531UL) >> 27]); } /* H5V_log2_of2() */ + +/*------------------------------------------------------------------------- + * Function: H5V_limit_enc_size + * + * Purpose: Determine the # of bytes needed to encode values within a + * range from 0 to a given limit + * + * Return: Number of bytes needed + * + * Programmer: Quincey Koziol + * Thursday, March 13, 2008 + * + *------------------------------------------------------------------------- + */ +static H5_inline unsigned UNUSED +H5V_limit_enc_size(uint64_t limit) +{ + return (H5V_log2_gen(limit) / 8) + 1; +} /* end H5V_limit_enc_size() */ + #endif /* H5Vprivate_H */ diff --git a/src/H5config.h.in b/src/H5config.h.in index 5c767ef..77a3b23 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -368,6 +368,9 @@ /* Define to 1 if you have the `waitpid' function. */ #undef HAVE_WAITPID +/* Define if your system has window style path name. */ +#undef HAVE_WINDOW_PATH + /* Define to 1 if you have the header file. */ #undef HAVE_WINSOCK_H diff --git a/src/H5private.h b/src/H5private.h index 343e652..e739ffa 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -638,9 +638,18 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F) #define HDgetc(F) getc(F) #define HDgetchar() getchar() +#ifdef _WIN32 +#define HDgetcwd(S,Z) _getcwd(S,Z) +#define HDgetdcwd(D,S,Z) _getdcwd(D,S,Z) +#define HDgetdrive() _getdrive() +#else #define HDgetcwd(S,Z) getcwd(S,Z) +#define HDgetdcwd(D,S,Z) getcwd(S,Z) +#define HDgetdrive() 0 +#endif #define HDgetegid() getegid() #define HDgetenv(S) getenv(S) +#define HDputenv(S) putenv(S) #define HDgeteuid() geteuid() #define HDgetgid() getgid() #define HDgetgrgid(G) getgrgid(G) @@ -911,6 +920,43 @@ extern char *strdup(const char *s); #endif /* _WIN32 */ +#ifdef H5_HAVE_WINDOW_PATH + +/* directory delimiter for Windows: slash and backslash are acceptable on Windows */ +#define DIR_SLASH_SEPC '/' +#define DIR_SEPC '\\' +#define DIR_SEPS "\\" +#define CHECK_DELIMITER(SS) ((SS == DIR_SEPC)||(SS == DIR_SLASH_SEPC)) +#define CHECK_ABSOLUTE(NAME) (((isalpha(NAME[0])) && (NAME[1] == ':') && CHECK_DELIMITER(NAME[2])) +#define CHECK_ABS_DRIVE(NAME) ((isalpha(NAME[0])) && (NAME[1] == ':')) +#define CHECK_ABS_PATH(NAME) (CHECK_DELIMITER(NAME[0])) + +#define GET_LAST_DELIMITER(NAME, ptr) { \ + char *slash, *backslash; \ + slash = strrchr(NAME, DIR_SLASH_SEPC); \ + backslash = strrchr(NAME, DIR_SEPC); \ + if (backslash > slash) \ + (ptr = backslash); \ + else \ + (ptr = slash); \ +} + + +#else + +#define DIR_SEPC '/' +#define DIR_SEPS "/" +#define CHECK_DELIMITER(SS) (SS == DIR_SEPC) +#define CHECK_ABSOLUTE(NAME) (CHECK_DELIMITER(*NAME)) +#define CHECK_ABS_DRIVE(NAME) (0) +#define CHECK_ABS_PATH(NAME) (0) +#define GET_LAST_DELIMITER(NAME, ptr) ptr = strrchr(NAME, DIR_SEPC); + +#endif + +#define COLON_SEPC ':' +H5_DLL herr_t H5_build_extpath(const char *, char **/*out*/); + /* * These macros check whether debugging has been requested for a certain diff --git a/src/H5public.h b/src/H5public.h index 47f5e69..657af0d 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -71,10 +71,10 @@ extern "C" { /* Version numbers */ #define H5_VERS_MAJOR 1 /* For major interface/format changes */ #define H5_VERS_MINOR 9 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 0 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_RELEASE 2 /* For tweaks, bug-fixes, or development */ #define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */ /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.9.0" /* Full version string */ +#define H5_VERS_INFO "HDF5 library version: 1.9.2" /* Full version string */ #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE) diff --git a/src/H5system.c b/src/H5system.c index 5eae11d..4a49d71 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -35,6 +35,8 @@ #include "H5private.h" /* Generic Functions */ #include "H5Fprivate.h" /* File access */ #include "H5MMprivate.h" /* Memory management */ +#include "H5Eprivate.h" + /****************/ @@ -578,4 +580,100 @@ HDremove_all(const char *fname) } #endif + +/* + *------------------------------------------------------------------------- + * + * Function: H5_build_extpath + * + * Purpose: To build the path for later searching of target file for external link. + * This path can be either: + * 1. The absolute path of NAME + * or + * 2. The current working directory + relative path of NAME + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * April 2, 2008 + *------------------------------------------------------------------------- + */ +#define MAX_PATH_LEN 1024 + +herr_t +H5_build_extpath(const char *name, char **extpath/*out*/) +{ + char *full_path=NULL, *ptr=NULL; + char *retcwd=NULL, *cwdpath=NULL, *new_name=NULL; + int drive; + size_t cwdlen, path_len; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5_build_extpath) + + *extpath = NULL; + + /* + * Unix: name[0] is a "/" + * Windows: name[0-2] is ":\" or ":/" + */ + if (CHECK_ABSOLUTE(name)) { + if ((full_path=H5MM_strdup(name)) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + } else { /* relative pathname */ + if ((cwdpath=H5MM_malloc(MAX_PATH_LEN)) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + if ((new_name=H5MM_strdup(name)) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* + * Windows: name[0-1] is ":" + * Get current working directory on the drive specified in NAME + * Unix: does not apply + */ + if (CHECK_ABS_DRIVE(name)) { + drive = name[0] - 'A' + 1; + retcwd = HDgetdcwd(drive, cwdpath, MAX_PATH_LEN); + HDstrcpy(new_name, &name[2]); + /* + * Windows: name[0] is a '/' or '\' + * Get current drive + * Unix: does not apply + */ + } else if (CHECK_ABS_PATH(name) && (drive=HDgetdrive())) { + sprintf(cwdpath, "%c:%c", (drive+'A'-1), name[0]); + retcwd = cwdpath; + HDstrcpy(new_name, &name[1]); + } else /* totally relative for both Unix and Windows: get current working directory */ + retcwd = HDgetcwd(cwdpath, MAX_PATH_LEN); + + if (retcwd != NULL) { + cwdlen = HDstrlen(cwdpath); + HDassert(cwdlen); + path_len = cwdlen + HDstrlen(new_name) + 2; + if ((full_path=H5MM_malloc(path_len)) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + HDstrcpy(full_path, cwdpath); + if (!CHECK_DELIMITER(cwdpath[cwdlen-1])) + HDstrcat(full_path, DIR_SEPS); + HDstrcat(full_path, new_name); + } + } + + /* strip out the last component (the file name itself) from the path */ + if (full_path) { + GET_LAST_DELIMITER(full_path, ptr) + HDassert(ptr); + *++ptr = '\0'; + *extpath = full_path; + } +done: + if (cwdpath) + H5MM_xfree(cwdpath); + if (new_name) + H5MM_xfree(new_name); + FUNC_LEAVE_NOAPI(ret_value) +} /* H5_build_extpath() */ diff --git a/src/Makefile.in b/src/Makefile.in index 26f6e78..51a4d9e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -385,7 +385,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 5 -LT_VERS_REVISION = 1 +LT_VERS_REVISION = 3 LT_VERS_AGE = 0 H5detect_CFLAGS = -g diff --git a/test/Makefile.am b/test/Makefile.am index 054877d..526086b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -105,7 +105,8 @@ flush2.chkexe_: flush1.chkexe_ CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 extend.h5 istore.h5\ tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 stab.h5 \ extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 dt_arith[1-2]\ - links.h5 links[0-6]*.h5 big.data big[0-9][0-9][0-9][0-9][0-9].h5 \ + links.h5 links[0-6]*.h5 extlinks[0-9].h5 tmp \ + big.data big[0-9][0-9][0-9][0-9][0-9].h5 \ stdio.h5 sec2.h5 dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 \ tselect.h5 mtime.h5 unlink.h5 unicode.h5 coord.h5 \ fillval_[0-9].h5 fillval.raw mount_[0-9].h5 testmeta.h5 ttime.h5 \ diff --git a/test/Makefile.in b/test/Makefile.in index 1cda554..0b5a001 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -610,8 +610,8 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog cmpd_dset.h5 \ compact_dataset.h5 dataset.h5 extend.h5 istore.h5 \ tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 stab.h5 \ extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 \ - dt_arith[1-2] links.h5 links[0-6]*.h5 big.data \ - big[0-9][0-9][0-9][0-9][0-9].h5 stdio.h5 sec2.h5 \ + dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-9].h5 tmp \ + big.data big[0-9][0-9][0-9][0-9][0-9].h5 stdio.h5 sec2.h5 \ dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 tselect.h5 mtime.h5 \ unlink.h5 unicode.h5 coord.h5 fillval_[0-9].h5 fillval.raw \ mount_[0-9].h5 testmeta.h5 ttime.h5 trefer[1-3].h5 tvltypes.h5 \ diff --git a/test/dtypes.c b/test/dtypes.c index 0388003..6707d2e 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -90,6 +90,10 @@ typedef enum dtype_t { /* Constant for size of conversion buffer for int <-> float exception test */ #define CONVERT_SIZE 4 +/* Constants for compound_13 test */ +#define COMPOUND13_ARRAY_SIZE 256 +#define COMPOUND13_ATTR_NAME "attr" + /* Count opaque conversions */ static int num_opaque_conversions_g = 0; @@ -2174,6 +2178,107 @@ test_compound_12(void) /*------------------------------------------------------------------------- + * Function: test_compound_12 + * + * Purpose: Tests compound datatypes whose size is at the boundary for + * needing 2 bytes for the datatype size and "use the latest + * format" flag is enabled so that the size of the offsets uses + * the smallest # of bytes possible. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Quincey Koziol + * Thursday, March 13, 2008 + * + *------------------------------------------------------------------------- + */ +static int +test_compound_13(void) +{ + struct s1 { + unsigned char x[COMPOUND13_ARRAY_SIZE + 1]; + float y; + }; + struct s1 data_out, data_in; + hid_t fileid, grpid, typeid, array1_tid, spaceid, attid; + hid_t fapl_id; + hsize_t dims[1] = {COMPOUND13_ARRAY_SIZE + 1}; + char filename[1024]; + unsigned u; + + TESTING("compound datatypes of boundary size with latest format"); + + /* Create some phony data. */ + for(u = 0; u < COMPOUND13_ARRAY_SIZE + 1; u++) + data_out.x[u] = u; + data_out.y = 99.99; + + /* Set latest_format in access propertly list to enable the latest + * compound datatype format. + */ + if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR + if(H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR + + /* Open file and get root group. */ + h5_fixname(FILENAME[4], H5P_DEFAULT, filename, sizeof filename); + if((fileid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) FAIL_STACK_ERROR + if((grpid = H5Gopen2(fileid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Create a compound type. */ + if((typeid = H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0) FAIL_STACK_ERROR + if((array1_tid = H5Tarray_create2(H5T_NATIVE_UCHAR, 1, dims)) < 0) FAIL_STACK_ERROR + if(H5Tinsert(typeid, "x", HOFFSET(struct s1, x), array1_tid) < 0) FAIL_STACK_ERROR + if(H5Tinsert(typeid, "y", HOFFSET(struct s1, y), H5T_NATIVE_FLOAT) < 0) FAIL_STACK_ERROR + + /* Create a space. */ + if((spaceid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR + + /* Create an attribute of this compound type. */ + if((attid = H5Acreate2(grpid, COMPOUND13_ATTR_NAME, typeid, spaceid, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Write some data. */ + if(H5Awrite(attid, typeid, &data_out) < 0) FAIL_STACK_ERROR + + /* Release all resources. */ + if(H5Aclose(attid) < 0) FAIL_STACK_ERROR + if(H5Tclose(array1_tid) < 0) FAIL_STACK_ERROR + if(H5Tclose(typeid) < 0) FAIL_STACK_ERROR + if(H5Sclose(spaceid) < 0) FAIL_STACK_ERROR + if(H5Gclose(grpid) < 0) FAIL_STACK_ERROR + if(H5Fclose(fileid) < 0) FAIL_STACK_ERROR + if(H5Pclose(fapl_id) < 0) FAIL_STACK_ERROR + + /* Now open the file and read it. */ + if((fileid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if((grpid = H5Gopen2(fileid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if((attid = H5Aopen(grpid, COMPOUND13_ATTR_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if((typeid = H5Aget_type(attid)) < 0) FAIL_STACK_ERROR + if(H5Tget_class(typeid) != H5T_COMPOUND) FAIL_STACK_ERROR + if(HOFFSET(struct s1, x) != H5Tget_member_offset(typeid, 0)) TEST_ERROR + if(HOFFSET(struct s1, y) != H5Tget_member_offset(typeid, 1)) TEST_ERROR + if(H5Aread(attid, typeid, &data_in) < 0) FAIL_STACK_ERROR + + /* Check the data. */ + for (u = 0; u < COMPOUND13_ARRAY_SIZE + 1; u++) + if(data_out.x[u] != data_in.x[u]) TEST_ERROR + if(data_out.y != data_in.y) TEST_ERROR + + /* Release all resources. */ + if(H5Aclose(attid) < 0) FAIL_STACK_ERROR + if(H5Tclose(typeid) < 0) FAIL_STACK_ERROR + if(H5Gclose(grpid) < 0) FAIL_STACK_ERROR + if(H5Fclose(fileid) < 0) FAIL_STACK_ERROR + + PASSED(); + return 0; + +error: + return 1; +} /* end test_compound_13() */ + + +/*------------------------------------------------------------------------- * Function: test_query * * Purpose: Tests query functions of compound and enumeration types. @@ -4703,7 +4808,7 @@ test_deprec(hid_t fapl) /* Create an array datatype with an atomic base type */ /* (dimension permutations allowed, but not stored) */ - if((type = H5Tarray_create1(H5T_NATIVE_INT, rank, dims, perm)) < 0) + if((type = H5Tarray_create1(H5T_NATIVE_INT, (int)rank, dims, perm)) < 0) FAIL_STACK_ERROR /* Make certain that the correct classes can be detected */ @@ -4862,6 +4967,7 @@ main(void) nerrors += test_compound_10(); nerrors += test_compound_11(); nerrors += test_compound_12(); + nerrors += test_compound_13(); nerrors += test_conv_enum_1(); nerrors += test_conv_enum_2(); nerrors += test_conv_bitfield(); diff --git a/test/links.c b/test/links.c index 1bff4c6..f940bb1 100644 --- a/test/links.c +++ b/test/links.c @@ -40,15 +40,38 @@ const char *FILENAME[] = { "links1", "links2", "links3", - "links4a", - "links4b", - "links4c", - "links4d", - "links5", - "links6", + "links4a", /* 4 */ + "links4b", /* 5 */ + "links4c", /* 6 */ + "links4d", /* 7 */ + "links5", /* 8 */ + "links6", /* 9 */ + "links7", /* 10 */ + "links8", /* 11 */ + "extlinks0", /* 12: main files */ + "tmp/extlinks0", /* 13: */ + "extlinks1", /* 14: target files */ + "tmp/extlinks1", /* 15: */ + "extlinks2", /* 16: */ + "tmp/extlinks2", /* 17: */ + "extlinks3", /* 18: */ + "tmp/extlinks3", /* 19: */ + "extlinks4", /* 20: */ + "tmp/extlinks4", /* 21: */ + "extlinks5", /* 22: */ + "tmp/extlinks6", /* 23: */ + "extlinks7", /* 24: */ + "tmp/extlinks7", /* 25: */ + "tmp/extlinks8", /* 26: */ + "extlinks9", /* 27: */ + "tmp/extlinks9", /* 28: */ NULL }; +#define TMPDIR "tmp" +/* do not do check_all_closed() for "ext*" files and "tmp/ext*" */ +#define EXTSTOP 12 + #define LINK_BUF_SIZE 1024 #define NAME_BUF_SIZE 1024 #define MAX_NAME_LEN ((64*1024)+1024) @@ -2552,6 +2575,851 @@ external_link_dangling(hid_t fapl, hbool_t new_format) return -1; } /* end external_link_dangling() */ + + +/*------------------------------------------------------------------------- + * Function: external_link_env: test 1 + * + * Purpose: 1. Create target file in tmp directory ("tmp/extlinks1") + * 2. Create main file in current directory ("extlinks0") +* 3. Create external link to target file ("extlinks1") + * 4. Set up environment variable "HDF5_EXT_PREFIX" to be ".:tmp" + * Should be able to access the target file in tmp directory through searching + * the pathnames set in HDF5_EXT_PREFIX + * + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * Feb. 20, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_env(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char *envval=NULL; + static char *new_env = "HDF5_EXT_PREFIX=.:tmp"; + static char *env_var = "HDF5_EXT_PREFIX"; + static envstring[NAME_BUF_SIZE]; + + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via environment variable (w/new group format)") + else + TESTING("external links via environment variable") + + + /* set up name for main file:"extlinks0" */ + h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); + /* set up name for external linked target file: "extlinks1" */ + h5_fixname(FILENAME[14], fapl, filename2, sizeof filename2); + + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + + /* set up name for target file: "tmp/extlinks1" */ + h5_fixname(FILENAME[15], fapl, filename3, sizeof filename3); + + /* Create the target file */ + if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* get original value for the HDF library environment variable for external link if set */ + envval = HDgetenv(env_var); + if (HDputenv(new_env) < 0) + TEST_ERROR + + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + /* restore value for the environment variable as needed */ + if ((envval != NULL) && (*envval)) { + sprintf(envstring, "%s=%s", env_var, envval); + if (HDputenv(envstring) < 0) + TEST_ERROR + } + + /* should be able to find the target file from pathnames set via environment variable */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in tmp directory."); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_env() */ + + +/*------------------------------------------------------------------------- + * Function: external_link_prefix: test 2 + * + * Purpose: 1. Create the target file in tmp directory ("tmp/extlinks2") + * 2. Create the main file in current directory ("extlinks0") +* 3. Create external link to target file ("extlinks2") + * 4. Set up external link prefix via H5Pset_elink_prefix() to be "tmp" + * Should be able to access the target file in tmp directory via the prefix set + * by H5Pset_elink_prefix() + * + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * Feb 19, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_prefix(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + hid_t gapl_id = (-1); + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via H5Pset_elink_prefix()(w/new group format)") + else + TESTING("external links via H5Pset_elink_prefix()") + + /* set up name for main file: "extlinks0" */ + h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); + /* set up name for external linked target file: "extlinks2" */ + h5_fixname(FILENAME[16], fapl, filename2, sizeof filename2); + + /* create tmp directory and get current working directory path */ + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + + /* set up name for target file: "tmp/extlinks2" */ + h5_fixname(FILENAME[17], fapl, filename3, sizeof filename3); + + /* Create the target file */ + if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file (without the absolute path) */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* set up prefix for external link */ + if((gapl_id = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR + if(H5Pset_elink_prefix(gapl_id, TMPDIR) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", gapl_id); + } H5E_END_TRY; + + /* should be able to find the target file from pathnames set via H5Pset_elink_prefix() */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in tmp directory."); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_prefix() */ + + +/*------------------------------------------------------------------------- + * Function: external_link_abs_mainpath: test 3 + * + * Purpose: 1. Create target file in tmp directory ("tmp/extlinks3") + * 2. Create main file (with absolute pathname) in tmp directory ("/CWD/tmp/extlinks0") + * 3. Create external link to target file without absolute path ("extlinks3") + * Should be able to access the target file via the main file's + * absolute pathname ("/CWD/tmp") + * + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * Feb 19, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_abs_mainpath(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via main file's absolute path (w/new group format)") + else + TESTING("external links via main file's absolute path") + + /* set up name for external linked target file: "extlinks3" */ + h5_fixname(FILENAME[18], fapl, filename2, sizeof filename2); + /* set up name for target file: "tmp/extlinks3" */ + h5_fixname(FILENAME[19], fapl, filename3, sizeof filename3); + + /* create tmp directory and get current working directory path */ + if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)) + TEST_ERROR + + /* set up name for main file: "/CWD/tmp/extlinks0" */ + HDstrcpy(tmpname, cwdpath); + HDstrcat(tmpname, "/"); + HDstrcat(tmpname, FILENAME[13]); + h5_fixname(tmpname, fapl, filename1, sizeof filename1); + + /* Create the target file */ + if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + /* should be able to find the target file from absolute path set for main file */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in tmp directory."); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_abs_mainpath() */ + + +/*------------------------------------------------------------------------- + * Function: external_link_rel_mainpath: test 4 + * + * Purpose: 1. Create target file in tmp directory ("tmp/extlinks4") + * Purpose: 2. Create main file (with relative pathname) in tmp directory ("tmp/extlinks0") + * 3. Create external link to target file without the absolute pathname ("extlinks4") + * Should be able to access the target file via the main file's + * CWD+relative path ("/CWD/tmp") + * + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * Feb 19, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_rel_mainpath(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via main file's CWD + relative path(w/new group format)") + else + TESTING("external links via main file's CWD + relative path") + + /* set up name for external linked target file: "extlinks4" */ + h5_fixname(FILENAME[20], fapl, filename2, sizeof filename2); + + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + + /* set up name for main file: "tmp/extlinks0" */ + h5_fixname(FILENAME[13], fapl, filename1, sizeof filename1); + /* set up name for target file: "tmp/extlinks4" */ + h5_fixname(FILENAME[21], fapl, filename3, sizeof filename3); + + /* Create the target file */ + if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + /* should be able to find the target file from the main file's relative pathname */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in current working directory"); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_rel_mainpath() */ + +/*------------------------------------------------------------------------- + * Function: external_link_cwd: test 5 + * + * Purpose: 1. Create main file (with absolute path) in tmp directory ("/CWD/tmp/extlinks0") + * 2. Create target file in current working directory ("extlinks5") + * 3. Create external link to target file (without the absolute path) ("extlinks5") + * Should be able to access the target file in the current working directory + * + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * Feb 19, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_cwd(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + + if(new_format) + TESTING("external links via current working directory(w/new group format)") + else + TESTING("external links via current working directory") + + /* set up name for external linked target file: "extlinks5" */ + /* set up name for target file: "extlinks5" */ + h5_fixname(FILENAME[22], fapl, filename2, sizeof filename2); + + if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)) + TEST_ERROR + + /* set up name for main file: "/CWD/tmp/extlinks0" */ + HDstrcpy(tmpname, cwdpath); + HDstrcat(tmpname, "/"); + HDstrcat(tmpname, FILENAME[13]); + h5_fixname(tmpname, fapl, filename1, sizeof filename1); + + /* Create the target file */ + if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + /* should be able to find the target file from the current working directory */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in current working directory"); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_cwd() */ + + +/*------------------------------------------------------------------------- + * Function: external_link_abstar: test 6 + * + * Purpose: 1. Create target file in tmp directory (with absolute path) ("tmp/extlinks6") + * 2. Create main file in current directory ("extlinks0") + * 3. Create external link to target file (with absolute path) ("/CWD/tmp/extlinks6") + * Should be able to access the target file (with absolute path) directly + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * Feb. 20, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_abstar(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via target's absolute path (w/new group format)") + else + TESTING("external links via target's absolute path") + + /* set up name for main file: "extlinks0" */ + h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); + + /* create tmp directory and get current working directory path */ + if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)) + TEST_ERROR + + /* set up name for external linked target file: "/CWD/tmp/extlinks6" */ + HDstrcpy(tmpname, cwdpath); + HDstrcat(tmpname, "/"); + HDstrcat(tmpname, FILENAME[23]); + h5_fixname(tmpname, fapl, filename2, sizeof filename2); + + /* set up name for target file: "tmp/extlinks6" */ + h5_fixname(FILENAME[23], fapl, filename3, sizeof filename3); + + /* Create the target file */ + if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + /* should be able to find the target file with abolute path */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in tmp directory."); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_abstar() */ + +/*------------------------------------------------------------------------- + * Function: external_link_abstar_cur: test 7 + * + * Purpose: 1. Create target file in current working directory "extlinks7" + * 2. Create main file in current working directory "extlinks0" + * 3. Create external link to target file (with absolute path + * that does not exist in that directory) ("/CWD/tmp/extlinks7") + * Should be able to access the target file via the main file's CWD. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * Feb. 20, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_abstar_cur(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via main file's CWD (w/new group format)") + else + TESTING("external links via main file's CWD") + + /* set up name for main file: "extlinks0" */ + h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); + + /* set up name for target file name: "extlinks7" */ + h5_fixname(FILENAME[24], fapl, filename3, sizeof filename3); + + /* create tmp directory and get current working directory path */ + if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)) + TEST_ERROR + + /* set up name for external linked target file: "/CWD/tmp/extlinks7" */ + HDstrcpy(tmpname, cwdpath); + HDstrcat(tmpname, "/"); + HDstrcat(tmpname, FILENAME[25]); + h5_fixname(tmpname, fapl, filename2, sizeof filename2); + + /* Create the target file */ + if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + /* should be able to find the target file from main file's current working directory */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in current working directory."); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_abstar_cur() */ + + +/*------------------------------------------------------------------------- + * Function: external_link_reltar: test 8 + * + * Purpose: 1. Create target file in tmp directory ("tmp/extlinks8") + * 2. Create main file in current working directory ("extlinks0") + * 3. Create external link to target file with relative path ("tmp/extlinks8") + * Should be able to access the target file via the main file's + * relative pathname (CWD + relative path of targetfile: "/CWD/tmp/extlinks8") + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * Feb. 20, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_reltar(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via main file's CWD + target's relative path(w/new group format)") + else + TESTING("external links via main file's CWD + target's relative path") + + /* set up name for main file: "extlinks0" */ + h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); + + /* create tmp directory */ + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + + /* set up name for target file name: "tmp/extlinks8" */ + /* set up name for external linked target file: "tmp/extlinks8" */ + h5_fixname(FILENAME[26], fapl, filename2, sizeof filename2); + + /* Create the target file */ + if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + /* + * Should be able to find the target file from: + * main file's current working directory + pathname of external linked targetfile + */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in tmp directory."); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_reltar() */ + +/*------------------------------------------------------------------------- + * Function: external_link_chdir: test 9 + * + * Purpose: 1. Create target file in tmp directory ("tmp/extlinks9") + * 2. Create main file in current working directory ("extlinks0") + * 3. chdir "tmp" + * 3. Create external link to target file ("extlinks9") + * Should be able to access the target file in current working directory + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * Feb. 20, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_chdir(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via chdir and found in current working directory (w/new group format)") + else + TESTING("external links via chdir and found in current working directory") + + /* set up name for main file: "extlinks0" */ + h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); + /* set up name for external linked target file ("extlinks9") */ + h5_fixname(FILENAME[27], fapl, filename2, sizeof filename2); + + /* create tmp directory */ + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + + /* set up name for target file name ("tmp/extlinks9") */ + h5_fixname(FILENAME[28], fapl, filename3, sizeof filename3); + + /* Create the target file */ + if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + + if (HDchdir(TMPDIR) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + if (HDchdir("..") < 0) TEST_ERROR + + /* + * Should be able to find the target file from: + * main file's current working directory + pathname of external linked targetfile + */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in tmp directory."); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_chdir() */ /*------------------------------------------------------------------------- * Function: external_link_recursive @@ -5284,7 +6152,7 @@ linkinfo(hid_t fapl, hbool_t new_format) *------------------------------------------------------------------------- */ static int -check_all_closed(hid_t fapl, hbool_t new_format) +check_all_closed(hid_t fapl, hbool_t new_format, int stopat) { hid_t fid=-1; char filename[NAME_BUF_SIZE]; @@ -5300,7 +6168,7 @@ check_all_closed(hid_t fapl, hbool_t new_format) * To check this, try to create every file used in this test. If * a file is already open, creating it will fail. */ - for(x=0; FILENAME[x] != NULL; x++) + for(x=0; FILENAME[x] != NULL && x < stopat; x++) { h5_fixname(FILENAME[x], fapl, filename, sizeof filename); @@ -10225,6 +11093,8 @@ main(void) my_fapl = fapl; /* General tests... (on both old & new format groups */ + + nerrors += mklinks(my_fapl, new_format) < 0 ? 1 : 0; nerrors += cklinks(my_fapl, new_format) < 0 ? 1 : 0; nerrors += new_links(my_fapl, new_format) < 0 ? 1 : 0; @@ -10263,6 +11133,17 @@ main(void) nerrors += external_link_endian(my_fapl, new_format) < 0 ? 1 : 0; nerrors += external_link_strong(my_fapl, new_format) < 0 ? 1 : 0; + /* tests for external link */ + nerrors += external_link_env(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_prefix(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_abs_mainpath(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_rel_mainpath(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_cwd(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_abstar(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_abstar_cur(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_reltar(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_chdir(my_fapl, new_format) < 0 ? 1 : 0; + /* These tests assume that external links are a form of UD links, * so assume that everything that passed for external links * above has already been tested for UD links. @@ -10284,7 +11165,8 @@ main(void) nerrors += obj_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0; /* Keep this test last, it's testing files that are used above */ - nerrors += check_all_closed(my_fapl, new_format) < 0 ? 1 : 0; + /* do not do this for files used by external link tests */ + nerrors += check_all_closed(my_fapl, new_format, EXTSTOP) < 0 ? 1 : 0; } /* end for */ /* New group revision feature tests */ @@ -10324,6 +11206,8 @@ main(void) } printf("All link tests passed.\n"); h5_cleanup(FILENAME, fapl); + /* clean up tmp directory created by external link tests */ + HDrmdir(TMPDIR); } else puts("All link tests skipped - Incompatible with current Virtual File Driver"); diff --git a/test/objcopy.c b/test/objcopy.c index 5fdbdba..2196794 100755 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -273,7 +273,7 @@ error: H5Sclose(sid_ref); H5Dclose(did1); H5Dclose(did2); - H5Pclose(aid); + H5Aclose(aid); } H5E_END_TRY; return(-1); diff --git a/test/tattr.c b/test/tattr.c index d448397..12350c3 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -3303,6 +3303,10 @@ test_attr_deprec(hid_t fcpl, hid_t fapl) CHECK(dataset, FAIL, "H5Dopen2"); + /* Get number of attributes with bad ID */ + ret = H5Aget_num_attrs(-1); + VERIFY(ret, FAIL, "H5Aget_num_attrs"); + /* Get number of attributes */ ret = H5Aget_num_attrs(dataset); VERIFY(ret, 1, "H5Aget_num_attrs"); diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index 2a95ce0..2fd6fa6 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -254,7 +254,6 @@ int test_basic(const char *fname1, */ { -#if 1 float data15[6]; float data16[6]; @@ -274,48 +273,9 @@ int test_basic(const char *fname1, write_dset(gid1,1,dims1,"fp15",H5T_NATIVE_FLOAT,data15); write_dset(gid1,1,dims1,"fp16",H5T_NATIVE_FLOAT,data16); -#else - -#define NU_ELMTS 1000000 - - hsize_t i; - - hsize_t dims2[1] = { NU_ELMTS }; - - float *data15 = malloc (NU_ELMTS * sizeof(float) ); - float *data16 = malloc (NU_ELMTS * sizeof(float) ); - - data15[0] = (float) sqrt( (double)-1 ); - data15[1] = 1; - data15[2] = (float) sqrt( (double)-1 ); - data15[3] = 1; - data15[4] = 1; - data15[5] = 1; - - data16[0] = (float) sqrt( (double)-1 ); - data16[1] = (float) sqrt( (double)-1 ); - data16[2] = 1; - data16[3] = 1; - data16[4] = 1; - data16[5] = 1; - - for ( i = 6; i < NU_ELMTS; i++ ) - { - data15[i] = /*data15[0];*/ 2; - data16[i] = 1; - } - - write_dset(gid1,1,dims2,"fp15",H5T_NATIVE_FLOAT,data15); - write_dset(gid1,1,dims2,"fp16",H5T_NATIVE_FLOAT,data16); - - free( data15 ); - free( data16 ); -#endif } - - /*------------------------------------------------------------------------- * NaNs in H5T_NATIVE_DOUBLE *------------------------------------------------------------------------- @@ -343,9 +303,7 @@ int test_basic(const char *fname1, write_dset(gid1,1,dims1,"fp18",H5T_NATIVE_DOUBLE,data18); } - - - + /*------------------------------------------------------------------------- * close @@ -772,13 +730,13 @@ int test_datasets(const char *file, write_dset_in(gid,"/dset",fid,make_diffs); - /* Close */ + /* close */ status = H5Dclose(did); assert(status >= 0); status = H5Gclose(gid); assert(status >= 0); - /* Close file */ + /* close file */ status = H5Fclose(fid); assert(status >= 0); return status; @@ -2655,31 +2613,35 @@ int write_attr(hid_t loc_id, hid_t tid, void *buf) { - hid_t aid; - hid_t sid; - - /* create a space */ - if((sid = H5Screate_simple(rank, dims, NULL)) < 0) - goto out; - - /* create the attribute */ - if((aid = H5Acreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* write */ - if(buf) - if(H5Awrite(aid, tid, buf) < 0) - goto out; - - /* close */ - H5Aclose(aid); - H5Sclose(sid); - - return SUCCEED; - + hid_t aid=-1; + hid_t sid=-1; + + /* create a space */ + if((sid = H5Screate_simple(rank, dims, NULL)) < 0) + goto out; + + /* create the attribute */ + if((aid = H5Acreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + + /* write */ + if(buf) + { + if(H5Awrite(aid, tid, buf) < 0) + goto out; + } + + /* close */ + H5Aclose(aid); + H5Sclose(sid); + + return SUCCEED; + out: - - return FAIL; + + H5Aclose(aid); + H5Sclose(sid); + return FAIL; } /*------------------------------------------------------------------------- @@ -2697,8 +2659,8 @@ int write_dset( hid_t loc_id, hid_t tid, void *buf ) { - hid_t did; - hid_t sid; + hid_t did=-1; + hid_t sid=-1; /* create a space */ if((sid = H5Screate_simple(rank, dims, NULL)) < 0) @@ -2710,8 +2672,10 @@ int write_dset( hid_t loc_id, /* write */ if(buf) + { if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; + } /* close */ H5Dclose(did); @@ -2720,6 +2684,9 @@ int write_dset( hid_t loc_id, return SUCCEED; out: + + H5Dclose(did); + H5Sclose(sid); return FAIL; } diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index b21a020..4070425 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -5542,8 +5542,7 @@ error: * Contains: * 1) an integer dataset * 2) a float dataset - * 3) an array dataset - * 4) a large double dataset + * 4) a double dataset * *------------------------------------------------------------------------- */ @@ -5551,64 +5550,43 @@ static void gent_binary(void) { hid_t fid, sid, did, tid; - hsize_t dims[1] = {6}; - hsize_t dimarray[1] = {2}; - hsize_t dimsl[1] = {100000}; + hsize_t dims[1] = {6}; int ibuf[6] = {1,2,3,4,5,6}; float fbuf[6] = {1,2,3,4,5,6}; - int abuf[2][6] = {{1,2,3,4,5,6},{7,8,9,10,11,12}}; /* array */ - double *dbuf=NULL; + double dbuf[6] = {1,2,3,4,5,6}; fid = H5Fcreate(FILE55, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); /*------------------------------------------------------------------------- * integer *------------------------------------------------------------------------- */ - sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate2(fid, "integer", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf); H5Dclose(did); - H5Sclose(sid); /*------------------------------------------------------------------------- * float *------------------------------------------------------------------------- */ - sid = H5Screate_simple(1, dims, NULL); did = H5Dcreate2(fid, "float", H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, fbuf); H5Dclose(did); - H5Sclose(sid); - -/*------------------------------------------------------------------------- - * array - *------------------------------------------------------------------------- - */ - tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dims); - sid = H5Screate_simple(1, dimarray, NULL); - did = H5Dcreate2(fid, "array", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, abuf); - H5Dclose(did); - H5Tclose(tid); - H5Sclose(sid); /*------------------------------------------------------------------------- * double *------------------------------------------------------------------------- */ - sid = H5Screate_simple(1, dimsl, NULL); did = H5Dcreate2(fid, "double", H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - dbuf = calloc(100000, sizeof(double)); - if(dbuf != NULL) { - H5Dwrite(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); - free(dbuf); - } + H5Dwrite(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); H5Dclose(did); - H5Sclose(sid); + /* close */ + H5Sclose(sid); H5Fclose(fid); } diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index b7b8429..1a8c18a 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -325,8 +325,7 @@ TOOLTEST tall-2B.ddl -A -r tall.h5 TOOLTEST tall-4s.ddl --dataset=/g1/g1.1/dset1.1.1 --start=1,1 --stride=2,3 --count=3,2 --block=1,1 tall.h5 TOOLTEST tall-5s.ddl -d "/g1/g1.1/dset1.1.2[0;2;10;]" tall.h5 TOOLTEST tdset-3s.ddl -d "/dset1[1,1;;;]" tdset.h5 -# block -# TOOLTEST tdset2-1s.ddl -d "/dset1[;3,2;4,4;1,4]" tdset2.h5 + # test printing characters in ASCII instead of decimal TOOLTEST tchar1.ddl -r tchar.h5 diff --git a/tools/h5stat/h5stat_gentest.c b/tools/h5stat/h5stat_gentest.c index 28d20ce..ef644d8 100644 --- a/tools/h5stat/h5stat_gentest.c +++ b/tools/h5stat/h5stat_gentest.c @@ -29,7 +29,7 @@ #define DATASET_NAME "DATASET_NAME" #define GROUP_NAME "GROUP" #define ATTR_NAME "ATTR" -#define NUM_GRPS 350 +#define NUM_GRPS 35000 #define NUM_ATTRS 100 /* diff --git a/tools/h5stat/testfiles/h5stat_newgrat.ddl b/tools/h5stat/testfiles/h5stat_newgrat.ddl index 6881ca9..d704f00 100644 --- a/tools/h5stat/testfiles/h5stat_newgrat.ddl +++ b/tools/h5stat/testfiles/h5stat_newgrat.ddl @@ -3,20 +3,20 @@ Expected output for 'h5stat h5stat_newgrat.h5' ############################# Filename: h5stat_newgrat.h5 File information - # of unique groups: 351 + # of unique groups: 35001 # of unique datasets: 1 # of unique named dataypes: 0 # of unique links: 0 # of unique other: 0 Max. # of links to object: 1 - Max. # of objects in group: 351 + Max. # of objects in group: 35001 Object header size: (total/unused) - Groups: 51597/32292 + Groups: 5145147/3220092 Datasets: 414/312 Storage information: Groups: - B-tree/List: 5158 - Heap: 7643 + B-tree/List: 470054 + Heap: 739128 Attributes: B-tree/List: 2598 Heap: 4442 @@ -28,12 +28,12 @@ Storage information: Heap: 0 Superblock extension: 0 Small groups: - # of groups of size 0: 350 - Total # of small groups: 350 + # of groups of size 0: 35000 + Total # of small groups: 35000 Group bins: - # of groups of size 0: 350 - # of groups of size 100 - 999: 1 - Total # of groups: 351 + # of groups of size 0: 35000 + # of groups of size 10000 - 99999: 1 + Total # of groups: 35001 Dataset dimension information: Max. rank of datasets: 0 Dataset ranks: diff --git a/tools/h5stat/testfiles/h5stat_newgrat.h5 b/tools/h5stat/testfiles/h5stat_newgrat.h5 index cab98bb..8083122 100644 Binary files a/tools/h5stat/testfiles/h5stat_newgrat.h5 and b/tools/h5stat/testfiles/h5stat_newgrat.h5 differ diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 4f4074f..9d64e44 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -47,7 +47,7 @@ int print_objname (diff_opt_t * options, hsize_t nfound) { - return ((options->m_verbose || nfound) && !options->m_quiet) ? 1 : 0; + return ((options->m_verbose || nfound) && !options->m_quiet) ? 1 : 0; } /*------------------------------------------------------------------------- @@ -186,15 +186,17 @@ hsize_t h5diff(const char *fname1, const char *objname2, diff_opt_t *options) { - trav_info_t *info1; - trav_info_t *info2; - hid_t file1_id = (-1), file2_id = (-1); + trav_info_t *info1=NULL; + trav_info_t *info2=NULL; + hid_t file1_id = (-1); + hid_t file2_id = (-1); char filenames[2][1024]; hsize_t nfound = 0; HDmemset(filenames, 0, 1024 * 2); - if(options->m_quiet && (options->m_verbose || options->m_report)) { + if(options->m_quiet && (options->m_verbose || options->m_report)) + { printf("Error: -q (quiet mode) cannot be added to verbose or report modes\n"); options->err_stat=1; return 0; @@ -206,9 +208,11 @@ hsize_t h5diff(const char *fname1, */ /* disable error reporting */ - H5E_BEGIN_TRY { - /* Open the files */ - if((file1_id = H5Fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { + H5E_BEGIN_TRY + { + /* open the files */ + if((file1_id = H5Fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + { printf("h5diff: <%s>: unable to open file\n", fname1); options->err_stat = 1; @@ -219,7 +223,8 @@ hsize_t h5diff(const char *fname1, #endif goto out; } /* end if */ - if((file2_id = H5Fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { + if((file2_id = H5Fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + { printf("h5diff: <%s>: unable to open file\n", fname2); options->err_stat = 1; @@ -255,11 +260,12 @@ hsize_t h5diff(const char *fname1, goto out; } /* end if */ - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * object name was supplied *------------------------------------------------------------------------- */ - if(objname1) { + if( objname1 ) + { #ifdef H5_HAVE_PARALLEL if(g_Parallel) /* Let tasks know that they won't be needed */ @@ -267,22 +273,31 @@ hsize_t h5diff(const char *fname1, #endif assert(objname2); options->cmn_objs = 1; /* eliminate warning */ - nfound = diff_compare(file1_id, fname1, objname1, info1, - file2_id, fname2, objname2, info2, + nfound = diff_compare(file1_id, + fname1, + objname1, + info1, + file2_id, + fname2, + objname2, + info2, options); } /* end if */ - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * compare all *------------------------------------------------------------------------- */ - else { + else + { #ifdef H5_HAVE_PARALLEL - if(g_Parallel) { + if(g_Parallel) + { int i; - if((HDstrlen(fname1) > 1024) || (HDstrlen(fname2) > 1024)) { + if((HDstrlen(fname1) > 1024) || (HDstrlen(fname2) > 1024)) + { fprintf(stderr, "The parallel diff only supports path names up to 1024 characters\n"); MPI_Abort(MPI_COMM_WORLD, 0); } /* end if */ @@ -295,7 +310,12 @@ hsize_t h5diff(const char *fname1, MPI_Send(filenames, (1024 * 2), MPI_CHAR, i, MPI_TAG_PARALLEL, MPI_COMM_WORLD); } /* end if */ #endif - nfound = diff_match(file1_id, info1, file2_id, info2, options); + + nfound = diff_match(file1_id, + info1, + file2_id, + info2, + options); } /* end else */ trav_info_free(info1); @@ -303,7 +323,8 @@ hsize_t h5diff(const char *fname1, out: /* close */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file1_id); H5Fclose(file2_id); } H5E_END_TRY; @@ -332,22 +353,23 @@ out: *------------------------------------------------------------------------- */ hsize_t diff_match(hid_t file1_id, - trav_info_t * info1, - hid_t file2_id, - trav_info_t * info2, - diff_opt_t * options) + trav_info_t *info1, + hid_t file2_id, + trav_info_t *info2, + diff_opt_t *options) { trav_table_t *table = NULL; - size_t curr1, curr2; - unsigned infile[2]; - hsize_t nfound = 0; - unsigned i; + size_t curr1; + size_t curr2; + unsigned infile[2]; + hsize_t nfound = 0; + unsigned i; /*------------------------------------------------------------------------- * build the list *------------------------------------------------------------------------- */ - trav_table_init(&table); + trav_table_init( &table ); curr1 = 0; curr2 = 0; @@ -393,11 +415,12 @@ hsize_t diff_match(hid_t file1_id, curr2++; } /* end while */ - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * print the list *------------------------------------------------------------------------- */ - if(options->m_verbose) { + if(options->m_verbose) + { printf("\n"); printf("file1 file2\n"); printf("---------------------------------------\n"); @@ -702,59 +725,64 @@ hsize_t diff_match(hid_t file1_id, *------------------------------------------------------------------------- */ -hsize_t diff_compare (hid_t file1_id, - const char *file1_name, - const char *obj1_name, - trav_info_t * info1, - hid_t file2_id, - const char *file2_name, - const char *obj2_name, - trav_info_t * info2, - diff_opt_t * options) +hsize_t diff_compare(hid_t file1_id, + const char *file1_name, + const char *obj1_name, + trav_info_t *info1, + hid_t file2_id, + const char *file2_name, + const char *obj2_name, + trav_info_t *info2, + diff_opt_t *options) { - int f1 = 0, f2 = 0; - hsize_t nfound = 0; - - ssize_t i = h5trav_getindex (info1, obj1_name); - ssize_t j = h5trav_getindex (info2, obj2_name); - - if (i == -1) - { - parallel_print ("Object <%s> could not be found in <%s>\n", obj1_name, - file1_name); - f1 = 1; - } - if (j == -1) - { - parallel_print ("Object <%s> could not be found in <%s>\n", obj2_name, - file2_name); - f2 = 1; - } - if (f1 || f2) - { - options->err_stat = 1; - return 0; - } - - /* use the name with "/" first, as obtained by iterator function */ - obj1_name = info1->paths[i].path; - obj2_name = info2->paths[j].path; - - /* objects are not the same type */ - if (info1->paths[i].type != info2->paths[j].type) - { - if (options->m_verbose) - parallel_print("Comparison not possible: <%s> is of type %s and <%s> is of type %s\n", - obj1_name, get_type(info1->paths[i].type), obj2_name, - get_type(info2->paths[j].type)); - options->not_cmp=1; - return 0; - } - - nfound = - diff (file1_id, obj1_name, file2_id, obj2_name, options, info1->paths[i].type); - - return nfound; + int f1 = 0; + int f2 = 0; + hsize_t nfound = 0; + + ssize_t i = h5trav_getindex (info1, obj1_name); + ssize_t j = h5trav_getindex (info2, obj2_name); + + if (i == -1) + { + parallel_print ("Object <%s> could not be found in <%s>\n", obj1_name, + file1_name); + f1 = 1; + } + if (j == -1) + { + parallel_print ("Object <%s> could not be found in <%s>\n", obj2_name, + file2_name); + f2 = 1; + } + if (f1 || f2) + { + options->err_stat = 1; + return 0; + } + + /* use the name with "/" first, as obtained by iterator function */ + obj1_name = info1->paths[i].path; + obj2_name = info2->paths[j].path; + + /* objects are not the same type */ + if (info1->paths[i].type != info2->paths[j].type) + { + if (options->m_verbose) + parallel_print("Comparison not possible: <%s> is of type %s and <%s> is of type %s\n", + obj1_name, get_type(info1->paths[i].type), obj2_name, + get_type(info2->paths[j].type)); + options->not_cmp=1; + return 0; + } + + nfound = diff(file1_id, + obj1_name, + file2_id, + obj2_name, + options, + info1->paths[i].type); + + return nfound; } @@ -784,14 +812,15 @@ hsize_t diff(hid_t file1_id, diff_opt_t * options, h5trav_type_t type) { - hid_t type1_id = (-1); - hid_t type2_id = (-1); - hid_t grp1_id = (-1); - hid_t grp2_id = (-1); - int ret; + hid_t type1_id = (-1); + hid_t type2_id = (-1); + hid_t grp1_id = (-1); + hid_t grp2_id = (-1); + int ret; hsize_t nfound = 0; - switch(type) { + switch(type) + { /*------------------------------------------------------------------------- * H5TRAV_TYPE_DATASET *------------------------------------------------------------------------- @@ -801,7 +830,8 @@ hsize_t diff(hid_t file1_id, * verbose, always print name *------------------------------------------------------------------------- */ - if(options->m_verbose) { + if(options->m_verbose) + { if(print_objname(options, (hsize_t)1)) do_print_objname("dataset", path1, path2); nfound = diff_dataset(file1_id, file2_id, path1, path2, options); @@ -813,15 +843,18 @@ hsize_t diff(hid_t file1_id, * disabling quiet mode *------------------------------------------------------------------------- */ - else { - if(options->m_quiet == 0) { + else + { + if(options->m_quiet == 0) + { /* shut up temporarily */ options->m_quiet = 1; nfound = diff_dataset(file1_id, file2_id, path1, path2, options); /* print again */ options->m_quiet = 0; - if(nfound) { + if(nfound) + { if(print_objname(options,nfound)) do_print_objname("dataset", path1, path2); nfound = diff_dataset(file1_id, file2_id, path1, path2, options); diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index ea833db..3f4e6a3 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -19,33 +19,6 @@ #include "h5tools.h" /*------------------------------------------------------------------------- - * Function: print_size - * - * Purpose: print dimensions - * - *------------------------------------------------------------------------- - */ -#if defined (H5DIFF_DEBUG) -static void -print_size (int rank, hsize_t *dims) -{ - int i; - - parallel_print("[" ); - for ( i = 0; i < rank-1; i++) - { - parallel_print("%"H5_PRINTF_LL_WIDTH"u", (unsigned long_long)dims[i]); - parallel_print("x"); - } - parallel_print("%"H5_PRINTF_LL_WIDTH"u", (unsigned long_long)dims[rank-1]); - parallel_print("]\n" ); - -} -#endif /* H5DIFF_DEBUG */ - - - -/*------------------------------------------------------------------------- * Function: diff_dataset * * Purpose: check for comparable datasets and read into a compatible @@ -65,79 +38,85 @@ hsize_t diff_dataset( hid_t file1_id, const char *obj2_name, diff_opt_t *options) { - hid_t did1 = -1; - hid_t did2 = -1; - hid_t dcpl1 = -1; - hid_t dcpl2 = -1; - hsize_t nfound = 0; - -/*------------------------------------------------------------------------- - * open the handles - *------------------------------------------------------------------------- - */ - /* disable error reporting */ - H5E_BEGIN_TRY { - /* Open the datasets */ - if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) { - printf("Cannot open dataset <%s>\n", obj1_name); - goto error; - } - if((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0) { - printf("Cannot open dataset <%s>\n", obj2_name); - goto error; - } - /* enable error reporting */ - } H5E_END_TRY; - - - if((dcpl1 = H5Dget_create_plist(did1)) < 0) - goto error; - if((dcpl2 = H5Dget_create_plist(did2)) < 0) - goto error; - -/*------------------------------------------------------------------------- - * check if the dataset creation property list has filters that - * are not registered in the current configuration - * 1) the external filters GZIP and SZIP might not be available - * 2) the internal filters might be turned off - *------------------------------------------------------------------------- - */ - if ((h5tools_canreadf((options->m_verbose?obj1_name:NULL),dcpl1)==1) && - (h5tools_canreadf((options->m_verbose?obj2_name:NULL),dcpl2)==1)) - { - nfound=diff_datasetid(did1, - did2, - obj1_name, - obj2_name, - options); - } -/*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - /* disable error reporting */ - H5E_BEGIN_TRY { - H5Pclose(dcpl1); - H5Pclose(dcpl2); - H5Dclose(did1); - H5Dclose(did2); - /* enable error reporting */ - } H5E_END_TRY; - - return nfound; - + hid_t did1 = -1; + hid_t did2 = -1; + hid_t dcpl1 = -1; + hid_t dcpl2 = -1; + hsize_t nfound = 0; + + /*------------------------------------------------------------------------- + * open the handles + *------------------------------------------------------------------------- + */ + /* disable error reporting */ + H5E_BEGIN_TRY + { + /* open the datasets */ + if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) + { + printf("Cannot open dataset <%s>\n", obj1_name); + goto error; + } + + if((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0) + { + printf("Cannot open dataset <%s>\n", obj2_name); + goto error; + } + /* enable error reporting */ + } H5E_END_TRY; + + + if ((dcpl1 = H5Dget_create_plist(did1)) < 0) + goto error; + if ((dcpl2 = H5Dget_create_plist(did2)) < 0) + goto error; + + /*------------------------------------------------------------------------- + * check if the dataset creation property list has filters that + * are not registered in the current configuration + * 1) the external filters GZIP and SZIP might not be available + * 2) the internal filters might be turned off + *------------------------------------------------------------------------- + */ + if ((h5tools_canreadf((options->m_verbose?obj1_name:NULL),dcpl1)==1) && + (h5tools_canreadf((options->m_verbose?obj2_name:NULL),dcpl2)==1)) + { + nfound=diff_datasetid(did1, + did2, + obj1_name, + obj2_name, + options); + } + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + /* disable error reporting */ + H5E_BEGIN_TRY + { + H5Pclose(dcpl1); + H5Pclose(dcpl2); + H5Dclose(did1); + H5Dclose(did2); + /* enable error reporting */ + } H5E_END_TRY; + + return nfound; + error: - options->err_stat=1; - /* disable error reporting */ - H5E_BEGIN_TRY { - H5Pclose(dcpl1); - H5Pclose(dcpl2); - H5Dclose(did1); - H5Dclose(did2); - /* enable error reporting */ - } H5E_END_TRY; - - return nfound; + options->err_stat=1; + /* disable error reporting */ + H5E_BEGIN_TRY + { + H5Pclose(dcpl1); + H5Pclose(dcpl2); + H5Dclose(did1); + H5Dclose(did2); + /* enable error reporting */ + } H5E_END_TRY; + + return nfound; } /*------------------------------------------------------------------------- @@ -154,7 +133,6 @@ error: * * Modifications: * - * * October 2006: Read by hyperslabs for big datasets. * * A threshold of H5TOOLS_MALLOCSIZE (128 MB) is the limit upon which I/O hyperslab is done @@ -204,448 +182,456 @@ hsize_t diff_datasetid( hid_t did1, const char *obj2_name, diff_opt_t *options) { - hid_t sid1=-1; - hid_t sid2=-1; - hid_t f_tid1=-1; - hid_t f_tid2=-1; - hid_t m_tid1=-1; - hid_t m_tid2=-1; - size_t m_size1; - size_t m_size2; - H5T_sign_t sign1; - H5T_sign_t sign2; - int rank1; - int rank2; - hsize_t nelmts1; - hsize_t nelmts2; - hsize_t dims1[H5S_MAX_RANK]; - hsize_t dims2[H5S_MAX_RANK]; - hsize_t maxdim1[H5S_MAX_RANK]; - hsize_t maxdim2[H5S_MAX_RANK]; - const char *name1=NULL; /* relative names */ - const char *name2=NULL; - hsize_t storage_size1; - hsize_t storage_size2; - hsize_t nfound=0; /* number of differences found */ - int cmp=1; /* do diff or not */ - void *buf1=NULL; - void *buf2=NULL; - void *sm_buf1=NULL; - void *sm_buf2=NULL; - size_t need; /* bytes needed for malloc */ - int i; - - /* Get the dataspace handle */ - if ( (sid1 = H5Dget_space(did1)) < 0 ) - goto error; - - /* Get rank */ - if ( (rank1 = H5Sget_simple_extent_ndims(sid1)) < 0 ) - goto error; - - /* Get the dataspace handle */ - if ( (sid2 = H5Dget_space(did2)) < 0 ) - goto error; - - /* Get rank */ - if ( (rank2 = H5Sget_simple_extent_ndims(sid2)) < 0 ) - goto error; - - /* Get dimensions */ - if ( H5Sget_simple_extent_dims(sid1,dims1,maxdim1) < 0 ) - goto error; - - /* Get dimensions */ - if ( H5Sget_simple_extent_dims(sid2,dims2,maxdim2) < 0 ) - goto error; - -/*------------------------------------------------------------------------- - * Get the file data type - *------------------------------------------------------------------------- - */ - - /* Get the data type */ - if ( (f_tid1 = H5Dget_type(did1)) < 0 ) - goto error; - - /* Get the data type */ - if ( (f_tid2 = H5Dget_type(did2)) < 0 ) - goto error; - -/*------------------------------------------------------------------------- - * check for empty datasets - *------------------------------------------------------------------------- - */ - - storage_size1=H5Dget_storage_size(did1); - storage_size2=H5Dget_storage_size(did2); - - if (storage_size1==0 || storage_size2==0) - { - if (options->m_verbose && obj1_name && obj2_name) - parallel_print("<%s> or <%s> are empty datasets\n", obj1_name, obj2_name); - cmp=0; - options->not_cmp=1; - } - -/*------------------------------------------------------------------------- - * check for comparable TYPE and SPACE - *------------------------------------------------------------------------- - */ - - if (diff_can_type(f_tid1, - f_tid2, - rank1, - rank2, - dims1, - dims2, - maxdim1, - maxdim2, - obj1_name, - obj2_name, - options)!=1) - { - cmp=0; - options->not_cmp=1; - } - -/*------------------------------------------------------------------------- - * memory type and sizes - *------------------------------------------------------------------------- - */ - if ((m_tid1=h5tools_get_native_type(f_tid1)) < 0) - goto error; - - if ((m_tid2=h5tools_get_native_type(f_tid2)) < 0) - goto error; - - m_size1 = H5Tget_size( m_tid1 ); - m_size2 = H5Tget_size( m_tid2 ); - -/*------------------------------------------------------------------------- - * check for different signed/unsigned types - *------------------------------------------------------------------------- - */ - - sign1=H5Tget_sign(m_tid1); - sign2=H5Tget_sign(m_tid2); - if ( sign1 != sign2 ) - { - if (options->m_verbose && obj1_name) { - parallel_print("Comparison not supported: <%s> has sign %s ", obj1_name, get_sign(sign1)); - parallel_print("and <%s> has sign %s\n", obj2_name, get_sign(sign2)); + hid_t sid1=-1; + hid_t sid2=-1; + hid_t f_tid1=-1; + hid_t f_tid2=-1; + hid_t m_tid1=-1; + hid_t m_tid2=-1; + size_t m_size1; + size_t m_size2; + H5T_sign_t sign1; + H5T_sign_t sign2; + int rank1; + int rank2; + hsize_t nelmts1; + hsize_t nelmts2; + hsize_t dims1[H5S_MAX_RANK]; + hsize_t dims2[H5S_MAX_RANK]; + hsize_t maxdim1[H5S_MAX_RANK]; + hsize_t maxdim2[H5S_MAX_RANK]; + const char *name1=NULL; /* relative names */ + const char *name2=NULL; + hsize_t storage_size1; + hsize_t storage_size2; + hsize_t nfound=0; /* number of differences found */ + int cmp=1; /* do diff or not */ + void *buf1=NULL; + void *buf2=NULL; + void *sm_buf1=NULL; + void *sm_buf2=NULL; + size_t need; /* bytes needed for malloc */ + int i; + + /* get the dataspace handle */ + if ( (sid1 = H5Dget_space(did1)) < 0 ) + goto error; + + /* get rank */ + if ( (rank1 = H5Sget_simple_extent_ndims(sid1)) < 0 ) + goto error; + + /* get the dataspace handle */ + if ( (sid2 = H5Dget_space(did2)) < 0 ) + goto error; + + /* get rank */ + if ( (rank2 = H5Sget_simple_extent_ndims(sid2)) < 0 ) + goto error; + + /* get dimensions */ + if ( H5Sget_simple_extent_dims(sid1,dims1,maxdim1) < 0 ) + goto error; + + /* get dimensions */ + if ( H5Sget_simple_extent_dims(sid2,dims2,maxdim2) < 0 ) + goto error; + + /*------------------------------------------------------------------------- + * get the file data type + *------------------------------------------------------------------------- + */ + + /* get the data type */ + if ( (f_tid1 = H5Dget_type(did1)) < 0 ) + goto error; + + /* get the data type */ + if ( (f_tid2 = H5Dget_type(did2)) < 0 ) + goto error; + + /*------------------------------------------------------------------------- + * check for empty datasets + *------------------------------------------------------------------------- + */ + + storage_size1=H5Dget_storage_size(did1); + storage_size2=H5Dget_storage_size(did2); + if (storage_size1<0 || storage_size2<0) + goto error; + + if (storage_size1==0 || storage_size2==0) + { + if (options->m_verbose && obj1_name && obj2_name) + parallel_print("<%s> or <%s> are empty datasets\n", obj1_name, obj2_name); + cmp=0; + options->not_cmp=1; + } + + /*------------------------------------------------------------------------- + * check for comparable TYPE and SPACE + *------------------------------------------------------------------------- + */ + + if (diff_can_type(f_tid1, + f_tid2, + rank1, + rank2, + dims1, + dims2, + maxdim1, + maxdim2, + obj1_name, + obj2_name, + options)!=1) + { + cmp=0; + options->not_cmp=1; + } + + /*------------------------------------------------------------------------- + * memory type and sizes + *------------------------------------------------------------------------- + */ + if ((m_tid1=h5tools_get_native_type(f_tid1)) < 0) + goto error; + + if ((m_tid2=h5tools_get_native_type(f_tid2)) < 0) + goto error; + + m_size1 = H5Tget_size( m_tid1 ); + m_size2 = H5Tget_size( m_tid2 ); + + /*------------------------------------------------------------------------- + * check for different signed/unsigned types + *------------------------------------------------------------------------- + */ + + sign1=H5Tget_sign(m_tid1); + sign2=H5Tget_sign(m_tid2); + if ( sign1 != sign2 ) + { + if (options->m_verbose && obj1_name) + { + parallel_print("Comparison not supported: <%s> has sign %s ", obj1_name, get_sign(sign1)); + parallel_print("and <%s> has sign %s\n", obj2_name, get_sign(sign2)); + } + + cmp=0; + options->not_cmp=1; + } + + /*------------------------------------------------------------------------- + * only attempt to compare if possible + *------------------------------------------------------------------------- + */ + if (cmp) + { + + /*------------------------------------------------------------------------- + * get number of elements + *------------------------------------------------------------------------- + */ + nelmts1 = 1; + for (i = 0; i < rank1; i++) + { + nelmts1 *= dims1[i]; + } + + nelmts2 = 1; + for (i = 0; i < rank2; i++) + { + nelmts2 *= dims2[i]; + } + + assert(nelmts1==nelmts2); + + /*------------------------------------------------------------------------- + * "upgrade" the smaller memory size + *------------------------------------------------------------------------- + */ + + if ( m_size1 != m_size2 ) + { + if ( m_size1 < m_size2 ) + { + H5Tclose(m_tid1); + + if ((m_tid1=h5tools_get_native_type(f_tid2)) < 0) + goto error; + + m_size1 = H5Tget_size( m_tid1 ); + } + else + { + H5Tclose(m_tid2); + + if ((m_tid2=h5tools_get_native_type(f_tid1)) < 0) + goto error; + + m_size2 = H5Tget_size( m_tid2 ); + } + } + assert(m_size1==m_size2); + + /* print names */ + if (obj1_name) { + name1=diff_basename(obj1_name); + } + if (obj2_name) { + name2=diff_basename(obj2_name); + } + + + /*------------------------------------------------------------------------- + * read/compare + *------------------------------------------------------------------------- + */ + + need = (size_t)(nelmts1*m_size1); /* bytes needed */ + if ( need < H5TOOLS_MALLOCSIZE) + { + buf1 = HDmalloc(need); + buf2 = HDmalloc(need); + } + + if ( buf1!=NULL && buf2!=NULL) + { + if ( H5Dread(did1,m_tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf1) < 0 ) + goto error; + if ( H5Dread(did2,m_tid2,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf2) < 0 ) + goto error; + + /* array diff */ + nfound = diff_array(buf1, + buf2, + nelmts1, + (hsize_t)0, + rank1, + dims1, + options, + name1, + name2, + m_tid1, + did1, + did2); + } + + else /* possibly not enough memory, read/compare by hyperslabs */ + + { + size_t p_type_nbytes = m_size1; /*size of memory type */ + hsize_t p_nelmts = nelmts1; /*total selected elmts */ + hsize_t elmtno; /*counter */ + int carry; /*counter carry value */ + unsigned int vl_data = 0; /*contains VL datatypes */ + + /* stripmine info */ + hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ + hsize_t sm_nbytes; /*bytes per stripmine */ + hsize_t sm_nelmts; /*elements per stripmine*/ + hid_t sm_space; /*stripmine data space */ + + /* hyperslab info */ + hsize_t hs_offset[H5S_MAX_RANK]; /*starting offset */ + hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */ + hsize_t hs_nelmts; /*elements in request */ + hsize_t zero[8]; /*vector of zeros */ + + /* check if we have VL data in the dataset's datatype */ + if (H5Tdetect_class(m_tid1, H5T_VLEN) == TRUE) + vl_data = TRUE; + + /* + * determine the strip mine size and allocate a buffer. The strip mine is + * a hyperslab whose size is manageable. + */ + sm_nbytes = p_type_nbytes; + + for (i = rank1; i > 0; --i) + { + sm_size[i - 1] = MIN(dims1[i - 1], H5TOOLS_BUFSIZE / sm_nbytes); + sm_nbytes *= sm_size[i - 1]; + assert(sm_nbytes > 0); + } + + sm_buf1 = malloc((size_t)sm_nbytes); + sm_buf2 = malloc((size_t)sm_nbytes); + + sm_nelmts = sm_nbytes / p_type_nbytes; + sm_space = H5Screate_simple(1, &sm_nelmts, NULL); + + /* the stripmine loop */ + memset(hs_offset, 0, sizeof hs_offset); + memset(zero, 0, sizeof zero); + + for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) + { + /* calculate the hyperslab size */ + if (rank1 > 0) + { + for (i = 0, hs_nelmts = 1; i < rank1; i++) + { + hs_size[i] = MIN(dims1[i] - hs_offset[i], sm_size[i]); + hs_nelmts *= hs_size[i]; + } + if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) + goto error; + if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) + goto error; + if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0) + goto error; + } + else + { + H5Sselect_all(sid1); + H5Sselect_all(sid2); + H5Sselect_all(sm_space); + hs_nelmts = 1; + } /* rank */ + + if ( H5Dread(did1,m_tid1,sm_space,sid1,H5P_DEFAULT,sm_buf1) < 0 ) + goto error; + if ( H5Dread(did2,m_tid2,sm_space,sid2,H5P_DEFAULT,sm_buf2) < 0 ) + goto error; + + /* get array differences. in the case of hyperslab read, increment the + number of differences found in each hyperslab and pass the + position at the beggining for printing + */ + nfound += diff_array(sm_buf1, + sm_buf2, + hs_nelmts, + elmtno, + rank1, + dims1, + options, + name1, + name2, + m_tid1, + did1, + did2); + + /* reclaim any VL memory, if necessary */ + if(vl_data) + { + H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf1); + H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf2); + } + + /* calculate the next hyperslab offset */ + for (i = rank1, carry = 1; i > 0 && carry; --i) + { + hs_offset[i - 1] += hs_size[i - 1]; + if (hs_offset[i - 1] == dims1[i - 1]) + hs_offset[i - 1] = 0; + else + carry = 0; + } /* i */ + } /* elmtno */ + + H5Sclose(sm_space); + /* free */ + if (sm_buf1!=NULL) + { + free(sm_buf1); + sm_buf1=NULL; + } + if (sm_buf2!=NULL) + { + free(sm_buf2); + sm_buf2=NULL; + } + + } /* hyperslab read */ + }/*cmp*/ + + /*------------------------------------------------------------------------- + * compare attributes + * the if condition refers to cases when the dataset is a referenced object + *------------------------------------------------------------------------- + */ + + if (obj1_name) + nfound += diff_attr(did1,did2,obj1_name,obj2_name,options); + + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + + /* free */ + if (buf1!=NULL) + { + free(buf1); + buf1=NULL; } - - cmp=0; - options->not_cmp=1; - } - -/*------------------------------------------------------------------------- - * only attempt to compare if possible - *------------------------------------------------------------------------- - */ - if (cmp) - { - -/*------------------------------------------------------------------------- - * get number of elements - *------------------------------------------------------------------------- - */ - nelmts1 = 1; - for (i = 0; i < rank1; i++) - { - nelmts1 *= dims1[i]; - } - - nelmts2 = 1; - for (i = 0; i < rank2; i++) - { - nelmts2 *= dims2[i]; - } - - assert(nelmts1==nelmts2); - -/*------------------------------------------------------------------------- - * "upgrade" the smaller memory size - *------------------------------------------------------------------------- - */ - - if ( m_size1 != m_size2 ) - { - if ( m_size1 < m_size2 ) + if (buf2!=NULL) { - H5Tclose(m_tid1); - - if ((m_tid1=h5tools_get_native_type(f_tid2)) < 0) - goto error; - - m_size1 = H5Tget_size( m_tid1 ); + free(buf2); + buf2=NULL; } - else + if (sm_buf1!=NULL) { - H5Tclose(m_tid2); - - if ((m_tid2=h5tools_get_native_type(f_tid1)) < 0) - goto error; - - m_size2 = H5Tget_size( m_tid2 ); + free(sm_buf1); + sm_buf1=NULL; } - } - assert(m_size1==m_size2); - - /* print names */ - if (obj1_name) { - name1=diff_basename(obj1_name); - } - if (obj2_name) { - name2=diff_basename(obj2_name); - } - - -/*------------------------------------------------------------------------- - * read/compare - *------------------------------------------------------------------------- - */ - - need = (size_t)(nelmts1*m_size1); /* bytes needed */ - if ( need < H5TOOLS_MALLOCSIZE) - { - buf1 = HDmalloc(need); - buf2 = HDmalloc(need); - } - - if ( buf1!=NULL && buf2!=NULL) - { - if ( H5Dread(did1,m_tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf1) < 0 ) - goto error; - if ( H5Dread(did2,m_tid2,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf2) < 0 ) - goto error; - - /* array diff */ - nfound = diff_array(buf1, - buf2, - nelmts1, - (hsize_t)0, - rank1, - dims1, - options, - name1, - name2, - m_tid1, - did1, - did2); - } - - else /* possibly not enough memory, read/compare by hyperslabs */ - - { - size_t p_type_nbytes = m_size1; /*size of memory type */ - hsize_t p_nelmts = nelmts1; /*total selected elmts */ - hsize_t elmtno; /*counter */ - int carry; /*counter carry value */ - unsigned int vl_data = 0; /*contains VL datatypes */ - - /* stripmine info */ - hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ - hsize_t sm_nbytes; /*bytes per stripmine */ - hsize_t sm_nelmts; /*elements per stripmine*/ - hid_t sm_space; /*stripmine data space */ - - /* hyperslab info */ - hsize_t hs_offset[H5S_MAX_RANK]; /*starting offset */ - hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */ - hsize_t hs_nelmts; /*elements in request */ - hsize_t zero[8]; /*vector of zeros */ - - /* check if we have VL data in the dataset's datatype */ - if (H5Tdetect_class(m_tid1, H5T_VLEN) == TRUE) - vl_data = TRUE; - - /* - * determine the strip mine size and allocate a buffer. The strip mine is - * a hyperslab whose size is manageable. - */ - sm_nbytes = p_type_nbytes; - - for (i = rank1; i > 0; --i) { - sm_size[i - 1] = MIN(dims1[i - 1], H5TOOLS_BUFSIZE / sm_nbytes); - sm_nbytes *= sm_size[i - 1]; - assert(sm_nbytes > 0); + if (sm_buf2!=NULL) + { + free(sm_buf2); + sm_buf2=NULL; } - sm_buf1 = malloc((size_t)sm_nbytes); - sm_buf2 = malloc((size_t)sm_nbytes); + H5E_BEGIN_TRY + { + H5Sclose(sid1); + H5Sclose(sid2); + H5Tclose(f_tid1); + H5Tclose(f_tid2); + H5Tclose(m_tid1); + H5Tclose(m_tid2); + } H5E_END_TRY; - sm_nelmts = sm_nbytes / p_type_nbytes; - sm_space = H5Screate_simple(1, &sm_nelmts, NULL); + return nfound; - /* the stripmine loop */ - memset(hs_offset, 0, sizeof hs_offset); - memset(zero, 0, sizeof zero); - - for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) - { - /* calculate the hyperslab size */ - if (rank1 > 0) - { - for (i = 0, hs_nelmts = 1; i < rank1; i++) - { - hs_size[i] = MIN(dims1[i] - hs_offset[i], sm_size[i]); - hs_nelmts *= hs_size[i]; - } - if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) - goto error; - if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) - goto error; - if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0) - goto error; - } - else - { - H5Sselect_all(sid1); - H5Sselect_all(sid2); - H5Sselect_all(sm_space); - hs_nelmts = 1; - } /* rank */ - - if ( H5Dread(did1,m_tid1,sm_space,sid1,H5P_DEFAULT,sm_buf1) < 0 ) - goto error; - if ( H5Dread(did2,m_tid2,sm_space,sid2,H5P_DEFAULT,sm_buf2) < 0 ) - goto error; - - /* get array differences. in the case of hyperslab read, increment the number of differences - found in each hyperslab and pass the position at the beggining for printing */ - nfound += diff_array(sm_buf1, - sm_buf2, - hs_nelmts, - elmtno, - rank1, - dims1, - options, - name1, - name2, - m_tid1, - did1, - did2); - - /* reclaim any VL memory, if necessary */ - if(vl_data) - { - H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf1); - H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf2); - } - - /* calculate the next hyperslab offset */ - for (i = rank1, carry = 1; i > 0 && carry; --i) - { - hs_offset[i - 1] += hs_size[i - 1]; - if (hs_offset[i - 1] == dims1[i - 1]) - hs_offset[i - 1] = 0; - else - carry = 0; - } /* i */ - } /* elmtno */ +error: + options->err_stat=1; - H5Sclose(sm_space); /* free */ + if (buf1!=NULL) + { + free(buf1); + buf1=NULL; + } + if (buf2!=NULL) + { + free(buf2); + buf2=NULL; + } if (sm_buf1!=NULL) { - free(sm_buf1); - sm_buf1=NULL; + free(sm_buf1); + sm_buf1=NULL; } if (sm_buf2!=NULL) { - free(sm_buf2); - sm_buf2=NULL; + free(sm_buf2); + sm_buf2=NULL; } - } /* hyperslab read */ - }/*cmp*/ - -/*------------------------------------------------------------------------- - * compare attributes - * the if condition refers to cases when the dataset is a referenced object - *------------------------------------------------------------------------- - */ - - if (obj1_name) - nfound += diff_attr(did1,did2,obj1_name,obj2_name,options); - -/*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - - /* free */ - if (buf1!=NULL) - { - free(buf1); - buf1=NULL; - } - if (buf2!=NULL) - { - free(buf2); - buf2=NULL; - } - if (sm_buf1!=NULL) - { - free(sm_buf1); - sm_buf1=NULL; - } - if (sm_buf2!=NULL) - { - free(sm_buf2); - sm_buf2=NULL; - } - - H5E_BEGIN_TRY { - H5Sclose(sid1); - H5Sclose(sid2); - H5Tclose(f_tid1); - H5Tclose(f_tid2); - H5Tclose(m_tid1); - H5Tclose(m_tid2); - } H5E_END_TRY; - - return nfound; - -error: - options->err_stat=1; - - /* free */ - if (buf1!=NULL) - { - free(buf1); - buf1=NULL; - } - if (buf2!=NULL) - { - free(buf2); - buf2=NULL; - } - if (sm_buf1!=NULL) - { - free(sm_buf1); - sm_buf1=NULL; - } - if (sm_buf2!=NULL) - { - free(sm_buf2); - sm_buf2=NULL; - } - - /* disable error reporting */ - H5E_BEGIN_TRY { - H5Sclose(sid1); - H5Sclose(sid2); - H5Tclose(f_tid1); - H5Tclose(f_tid2); - H5Tclose(m_tid1); - H5Tclose(m_tid2); - /* enable error reporting */ - } H5E_END_TRY; - - return nfound; + /* disable error reporting */ + H5E_BEGIN_TRY + { + H5Sclose(sid1); + H5Sclose(sid2); + H5Tclose(f_tid1); + H5Tclose(f_tid2); + H5Tclose(m_tid1); + H5Tclose(m_tid2); + /* enable error reporting */ + } H5E_END_TRY; + + return nfound; } /*------------------------------------------------------------------------- @@ -677,163 +663,164 @@ int diff_can_type( hid_t f_tid1, /* file data type */ const char *obj2_name, diff_opt_t *options ) { - - - H5T_class_t tclass1; - H5T_class_t tclass2; - int maxdim_diff=0; /* maximum dimensions are different */ - int dim_diff=0; /* current dimensions are different */ - int i; - -/*------------------------------------------------------------------------- - * check for the same class - *------------------------------------------------------------------------- - */ - - if ((tclass1=H5Tget_class(f_tid1)) < 0) - return -1; - - if ((tclass2=H5Tget_class(f_tid2)) < 0) - return -1; - - if ( tclass1 != tclass2 ) - { - if (options->m_verbose && obj1_name) { - printf("Comparison not possible: <%s> is of class %s and <%s> is of class %s\n", - obj1_name, get_class(tclass1), - obj2_name, get_class(tclass2) ); - } - return 0; - } - -/*------------------------------------------------------------------------- - * check for non supported classes - *------------------------------------------------------------------------- - */ - - assert(tclass1==tclass2); - switch (tclass1) - { - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_COMPOUND: - case H5T_STRING: - case H5T_ARRAY: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_VLEN: - case H5T_REFERENCE: - - break; - - default: /*H5T_TIME */ - if (options->m_verbose && obj1_name ) - printf("Comparison not supported: <%s> and <%s> are of class %s\n", - obj1_name,obj2_name,get_class(tclass2) ); - return 0; - } - -/*------------------------------------------------------------------------- - * check for equal file datatype; warning only - *------------------------------------------------------------------------- - */ - - if ( (H5Tequal(f_tid1, f_tid2)==0) && options->m_verbose && obj1_name) - { - printf("Warning: different storage datatype\n"); - printf("<%s> has file datatype ", obj1_name); - print_type(f_tid1); - printf("\n"); - printf("<%s> has file datatype ", obj2_name); - print_type(f_tid2); - printf("\n"); - } - -/*------------------------------------------------------------------------- - * check for the same rank - *------------------------------------------------------------------------- - */ - - if ( rank1 != rank2 ) - { - if (options->m_verbose && obj1_name) { - printf("Comparison not supported: <%s> has rank %d, dimensions ", obj1_name, rank1); - print_dimensions(rank1,dims1); - printf(", max dimensions "); - print_dimensions(rank1,maxdim1); - printf("\n" ); - printf("<%s> has rank %d, dimensions ", obj2_name, rank2); - print_dimensions(rank2,dims2); - printf(", max dimensions "); - print_dimensions(rank2,maxdim2); - } - return 0; - } - -/*------------------------------------------------------------------------- - * check for different dimensions - *------------------------------------------------------------------------- - */ - - assert(rank1==rank2); - for ( i=0; im_verbose && obj1_name) { - printf("Comparison not supported: <%s> has rank %d, dimensions ", obj1_name, rank1); - print_dimensions(rank1,dims1); - if (maxdim1 && maxdim2) { - printf(", max dimensions "); - print_dimensions(rank1,maxdim1); - printf("\n" ); - printf("<%s> has rank %d, dimensions ", obj2_name, rank2); - print_dimensions(rank2,dims2); - printf(", max dimensions "); - print_dimensions(rank2,maxdim2); - } - } - return 0; - } - -/*------------------------------------------------------------------------- - * maximum dimensions; just give a warning - *------------------------------------------------------------------------- - */ - if (maxdim1 && maxdim2 && maxdim_diff==1 && obj1_name ) - { - if (options->m_verbose) { - printf( "Warning: different maximum dimensions\n"); - printf("<%s> has max dimensions ", obj1_name); - print_dimensions(rank1,maxdim1); - printf("\n"); - printf("<%s> has max dimensions ", obj2_name); - print_dimensions(rank2,maxdim2); - printf("\n"); - } - } - - return 1; + H5T_class_t tclass1; + H5T_class_t tclass2; + int maxdim_diff=0; /* maximum dimensions are different */ + int dim_diff=0; /* current dimensions are different */ + int i; + + /*------------------------------------------------------------------------- + * check for the same class + *------------------------------------------------------------------------- + */ + + if ((tclass1=H5Tget_class(f_tid1)) < 0) + return -1; + + if ((tclass2=H5Tget_class(f_tid2)) < 0) + return -1; + + if ( tclass1 != tclass2 ) + { + if (options->m_verbose && obj1_name) + { + printf("Comparison not possible: <%s> is of class %s and <%s> is of class %s\n", + obj1_name, get_class(tclass1), + obj2_name, get_class(tclass2) ); + } + return 0; + } + + /*------------------------------------------------------------------------- + * check for non supported classes + *------------------------------------------------------------------------- + */ + + assert(tclass1==tclass2); + switch (tclass1) + { + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_COMPOUND: + case H5T_STRING: + case H5T_ARRAY: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_REFERENCE: + + break; + + default: /*H5T_TIME */ + if (options->m_verbose && obj1_name ) + printf("Comparison not supported: <%s> and <%s> are of class %s\n", + obj1_name,obj2_name,get_class(tclass2) ); + return 0; + } + + /*------------------------------------------------------------------------- + * check for equal file datatype; warning only + *------------------------------------------------------------------------- + */ + + if ( (H5Tequal(f_tid1, f_tid2)==0) && options->m_verbose && obj1_name) + { + printf("Warning: different storage datatype\n"); + printf("<%s> has file datatype ", obj1_name); + print_type(f_tid1); + printf("\n"); + printf("<%s> has file datatype ", obj2_name); + print_type(f_tid2); + printf("\n"); + } + + /*------------------------------------------------------------------------- + * check for the same rank + *------------------------------------------------------------------------- + */ + + if ( rank1 != rank2 ) + { + if (options->m_verbose && obj1_name) + { + printf("Comparison not supported: <%s> has rank %d, dimensions ", obj1_name, rank1); + print_dimensions(rank1,dims1); + printf(", max dimensions "); + print_dimensions(rank1,maxdim1); + printf("\n" ); + printf("<%s> has rank %d, dimensions ", obj2_name, rank2); + print_dimensions(rank2,dims2); + printf(", max dimensions "); + print_dimensions(rank2,maxdim2); + } + return 0; + } + + /*------------------------------------------------------------------------- + * check for different dimensions + *------------------------------------------------------------------------- + */ + + assert(rank1==rank2); + for ( i=0; im_verbose && obj1_name) + { + printf("Comparison not supported: <%s> has rank %d, dimensions ", obj1_name, rank1); + print_dimensions(rank1,dims1); + if (maxdim1 && maxdim2) + { + printf(", max dimensions "); + print_dimensions(rank1,maxdim1); + printf("\n" ); + printf("<%s> has rank %d, dimensions ", obj2_name, rank2); + print_dimensions(rank2,dims2); + printf(", max dimensions "); + print_dimensions(rank2,maxdim2); + } + } + return 0; + } + + /*------------------------------------------------------------------------- + * maximum dimensions; just give a warning + *------------------------------------------------------------------------- + */ + if (maxdim1 && maxdim2 && maxdim_diff==1 && obj1_name ) + { + if (options->m_verbose) + { + printf( "Warning: different maximum dimensions\n"); + printf("<%s> has max dimensions ", obj1_name); + print_dimensions(rank1,maxdim1); + printf("\n"); + printf("<%s> has max dimensions ", obj2_name); + print_dimensions(rank2,maxdim2); + printf("\n"); + } + } + + return 1; } - - /*------------------------------------------------------------------------- * Function: print_sizes * @@ -887,3 +874,29 @@ void print_sizes( const char *obj1, printf("\n"); } #endif /* H5DIFF_DEBUG */ + +/*------------------------------------------------------------------------- + * Function: print_size + * + * Purpose: print dimensions + * + *------------------------------------------------------------------------- + */ +#if defined (H5DIFF_DEBUG) +static void +print_size (int rank, hsize_t *dims) +{ + int i; + + parallel_print("[" ); + for ( i = 0; i < rank-1; i++) + { + parallel_print("%"H5_PRINTF_LL_WIDTH"u", (unsigned long_long)dims[i]); + parallel_print("x"); + } + parallel_print("%"H5_PRINTF_LL_WIDTH"u", (unsigned long_long)dims[rank-1]); + parallel_print("]\n" ); + +} +#endif /* H5DIFF_DEBUG */ + diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c index 9e9c556..4cddbfb 100644 --- a/tools/lib/h5diff_util.c +++ b/tools/lib/h5diff_util.c @@ -131,91 +131,91 @@ print_dimensions (int rank, hsize_t *dims) */ void print_type(hid_t type) { - switch (H5Tget_class(type)) - { - default: - return; - case H5T_INTEGER: - if (H5Tequal(type, H5T_STD_I8BE)) { - printf("H5T_STD_I8BE"); - } else if (H5Tequal(type, H5T_STD_I8LE)) { - printf("H5T_STD_I8LE"); - } else if (H5Tequal(type, H5T_STD_I16BE)) { - printf("H5T_STD_I16BE"); - } else if (H5Tequal(type, H5T_STD_I16LE)) { - printf("H5T_STD_I16LE"); - } else if (H5Tequal(type, H5T_STD_I32BE)) { - printf("H5T_STD_I32BE"); - } else if (H5Tequal(type, H5T_STD_I32LE)) { - printf("H5T_STD_I32LE"); - } else if (H5Tequal(type, H5T_STD_I64BE)) { - printf("H5T_STD_I64BE"); - } else if (H5Tequal(type, H5T_STD_I64LE)) { - printf("H5T_STD_I64LE"); - } else if (H5Tequal(type, H5T_STD_U8BE)) { - printf("H5T_STD_U8BE"); - } else if (H5Tequal(type, H5T_STD_U8LE)) { - printf("H5T_STD_U8LE"); - } else if (H5Tequal(type, H5T_STD_U16BE)) { - printf("H5T_STD_U16BE"); - } else if (H5Tequal(type, H5T_STD_U16LE)) { - printf("H5T_STD_U16LE"); - } else if (H5Tequal(type, H5T_STD_U32BE)) { - printf("H5T_STD_U32BE"); - } else if (H5Tequal(type, H5T_STD_U32LE)) { - printf("H5T_STD_U32LE"); - } else if (H5Tequal(type, H5T_STD_U64BE)) { - printf("H5T_STD_U64BE"); - } else if (H5Tequal(type, H5T_STD_U64LE)) { - printf("H5T_STD_U64LE"); - } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { - printf("H5T_NATIVE_SCHAR"); - } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { - printf("H5T_NATIVE_UCHAR"); - } else if (H5Tequal(type, H5T_NATIVE_SHORT)) { - printf("H5T_NATIVE_SHORT"); - } else if (H5Tequal(type, H5T_NATIVE_USHORT)) { - printf("H5T_NATIVE_USHORT"); - } else if (H5Tequal(type, H5T_NATIVE_INT)) { - printf("H5T_NATIVE_INT"); - } else if (H5Tequal(type, H5T_NATIVE_UINT)) { - printf("H5T_NATIVE_UINT"); - } else if (H5Tequal(type, H5T_NATIVE_LONG)) { - printf("H5T_NATIVE_LONG"); - } else if (H5Tequal(type, H5T_NATIVE_ULONG)) { - printf("H5T_NATIVE_ULONG"); - } else if (H5Tequal(type, H5T_NATIVE_LLONG)) { - printf("H5T_NATIVE_LLONG"); - } else if (H5Tequal(type, H5T_NATIVE_ULLONG)) { - printf("H5T_NATIVE_ULLONG"); - } else { - printf("undefined integer"); - } - break; - - case H5T_FLOAT: - if (H5Tequal(type, H5T_IEEE_F32BE)) { - printf("H5T_IEEE_F32BE"); - } else if (H5Tequal(type, H5T_IEEE_F32LE)) { - printf("H5T_IEEE_F32LE"); - } else if (H5Tequal(type, H5T_IEEE_F64BE)) { - printf("H5T_IEEE_F64BE"); - } else if (H5Tequal(type, H5T_IEEE_F64LE)) { - printf("H5T_IEEE_F64LE"); - } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) { - printf("H5T_NATIVE_FLOAT"); - } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { - printf("H5T_NATIVE_DOUBLE"); + switch (H5Tget_class(type)) + { + default: + return; + case H5T_INTEGER: + if (H5Tequal(type, H5T_STD_I8BE)) { + printf("H5T_STD_I8BE"); + } else if (H5Tequal(type, H5T_STD_I8LE)) { + printf("H5T_STD_I8LE"); + } else if (H5Tequal(type, H5T_STD_I16BE)) { + printf("H5T_STD_I16BE"); + } else if (H5Tequal(type, H5T_STD_I16LE)) { + printf("H5T_STD_I16LE"); + } else if (H5Tequal(type, H5T_STD_I32BE)) { + printf("H5T_STD_I32BE"); + } else if (H5Tequal(type, H5T_STD_I32LE)) { + printf("H5T_STD_I32LE"); + } else if (H5Tequal(type, H5T_STD_I64BE)) { + printf("H5T_STD_I64BE"); + } else if (H5Tequal(type, H5T_STD_I64LE)) { + printf("H5T_STD_I64LE"); + } else if (H5Tequal(type, H5T_STD_U8BE)) { + printf("H5T_STD_U8BE"); + } else if (H5Tequal(type, H5T_STD_U8LE)) { + printf("H5T_STD_U8LE"); + } else if (H5Tequal(type, H5T_STD_U16BE)) { + printf("H5T_STD_U16BE"); + } else if (H5Tequal(type, H5T_STD_U16LE)) { + printf("H5T_STD_U16LE"); + } else if (H5Tequal(type, H5T_STD_U32BE)) { + printf("H5T_STD_U32BE"); + } else if (H5Tequal(type, H5T_STD_U32LE)) { + printf("H5T_STD_U32LE"); + } else if (H5Tequal(type, H5T_STD_U64BE)) { + printf("H5T_STD_U64BE"); + } else if (H5Tequal(type, H5T_STD_U64LE)) { + printf("H5T_STD_U64LE"); + } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { + printf("H5T_NATIVE_SCHAR"); + } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { + printf("H5T_NATIVE_UCHAR"); + } else if (H5Tequal(type, H5T_NATIVE_SHORT)) { + printf("H5T_NATIVE_SHORT"); + } else if (H5Tequal(type, H5T_NATIVE_USHORT)) { + printf("H5T_NATIVE_USHORT"); + } else if (H5Tequal(type, H5T_NATIVE_INT)) { + printf("H5T_NATIVE_INT"); + } else if (H5Tequal(type, H5T_NATIVE_UINT)) { + printf("H5T_NATIVE_UINT"); + } else if (H5Tequal(type, H5T_NATIVE_LONG)) { + printf("H5T_NATIVE_LONG"); + } else if (H5Tequal(type, H5T_NATIVE_ULONG)) { + printf("H5T_NATIVE_ULONG"); + } else if (H5Tequal(type, H5T_NATIVE_LLONG)) { + printf("H5T_NATIVE_LLONG"); + } else if (H5Tequal(type, H5T_NATIVE_ULLONG)) { + printf("H5T_NATIVE_ULLONG"); + } else { + printf("undefined integer"); + } + break; + + case H5T_FLOAT: + if (H5Tequal(type, H5T_IEEE_F32BE)) { + printf("H5T_IEEE_F32BE"); + } else if (H5Tequal(type, H5T_IEEE_F32LE)) { + printf("H5T_IEEE_F32LE"); + } else if (H5Tequal(type, H5T_IEEE_F64BE)) { + printf("H5T_IEEE_F64BE"); + } else if (H5Tequal(type, H5T_IEEE_F64LE)) { + printf("H5T_IEEE_F64LE"); + } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) { + printf("H5T_NATIVE_FLOAT"); + } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { + printf("H5T_NATIVE_DOUBLE"); #if H5_SIZEOF_LONG_DOUBLE !=0 - } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) { - printf("H5T_NATIVE_LDOUBLE"); + } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) { + printf("H5T_NATIVE_LDOUBLE"); #endif - } else { - printf("undefined float"); - } - break; - - }/*switch*/ + } else { + printf("undefined float"); + } + break; + + }/*switch*/ } /*------------------------------------------------------------------------- @@ -232,21 +232,21 @@ void print_type(hid_t type) const char* diff_basename(const char *name) { - size_t i; - - if (name==NULL) - return NULL; - - /* Find the end of the base name */ - i = strlen(name); - while (i>0 && '/'==name[i-1]) - --i; - - /* Skip backward over base name */ - while (i>0 && '/'!=name[i-1]) - --i; - - return(name+i); + size_t i; + + if (name==NULL) + return NULL; + + /* Find the end of the base name */ + i = strlen(name); + while (i>0 && '/'==name[i-1]) + --i; + + /* Skip backward over base name */ + while (i>0 && '/'!=name[i-1]) + --i; + + return(name+i); } /*------------------------------------------------------------------------- @@ -295,15 +295,15 @@ get_type(h5trav_type_t type) const char* get_sign(H5T_sign_t sign) { - switch (sign) - { - default: - return("H5T_SGN_ERROR"); - case H5T_SGN_NONE: - return("H5T_SGN_NONE"); - case H5T_SGN_2: - return("H5T_SGN_2"); - } + switch (sign) + { + default: + return("H5T_SGN_ERROR"); + case H5T_SGN_NONE: + return("H5T_SGN_NONE"); + case H5T_SGN_2: + return("H5T_SGN_2"); + } } @@ -321,33 +321,33 @@ get_sign(H5T_sign_t sign) const char* get_class(H5T_class_t tclass) { - switch (tclass) - { - default: - return("Invalid class"); - case H5T_TIME: - return("H5T_TIME"); - case H5T_INTEGER: - return("H5T_INTEGER"); - case H5T_FLOAT: - return("H5T_FLOAT"); - case H5T_STRING: - return("H5T_STRING"); - case H5T_BITFIELD: - return("H5T_BITFIELD"); - case H5T_OPAQUE: - return("H5T_OPAQUE"); - case H5T_COMPOUND: - return("H5T_COMPOUND"); - case H5T_REFERENCE: - return("H5T_REFERENCE"); - case H5T_ENUM: - return("H5T_ENUM"); - case H5T_VLEN: - return("H5T_VLEN"); - case H5T_ARRAY: - return("H5T_ARRAY"); - } + switch (tclass) + { + default: + return("Invalid class"); + case H5T_TIME: + return("H5T_TIME"); + case H5T_INTEGER: + return("H5T_INTEGER"); + case H5T_FLOAT: + return("H5T_FLOAT"); + case H5T_STRING: + return("H5T_STRING"); + case H5T_BITFIELD: + return("H5T_BITFIELD"); + case H5T_OPAQUE: + return("H5T_OPAQUE"); + case H5T_COMPOUND: + return("H5T_COMPOUND"); + case H5T_REFERENCE: + return("H5T_REFERENCE"); + case H5T_ENUM: + return("H5T_ENUM"); + case H5T_VLEN: + return("H5T_VLEN"); + case H5T_ARRAY: + return("H5T_ARRAY"); + } } /*------------------------------------------------------------------------- diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 6fc09d7..120d433 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -538,29 +538,31 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai hsize_t nelmts, hid_t type, void *_mem) { unsigned char *mem = (unsigned char*)_mem; - hsize_t i; /*element counter */ - char *s, *section; /*a section of output */ - int secnum; /*section sequence number */ - size_t size; /*size of each datum */ - size_t ncols = 80; /*available output width */ - h5tools_str_t buffer; /*string into which to render */ - int multiline; /*datum was multiline */ - hsize_t curr_pos; /* total data element position */ - int elmt_counter = 0;/*counts the # elements printed. - *I (ptl?) needed something that - *isn't going to get reset when a new - *line is formed. I'm going to use - *this var to count elements and - *break after we see a number equal - *to the ctx->size_last_dim. */ + hsize_t i; /*element counter */ + char *s; + char *section; /*a section of output */ + int secnum; /*section sequence number */ + size_t size; /*size of each datum */ + size_t ncols = 80; /*available output width */ + h5tools_str_t buffer; /*string into which to render */ + int multiline; /*datum was multiline */ + hsize_t curr_pos; /* total data element position */ + int elmt_counter = 0;/*counts the # elements printed. + *I (ptl?) needed something that + *isn't going to get reset when a new + *line is formed. I'm going to use + *this var to count elements and + *break after we see a number equal + *to the ctx->size_last_dim. */ /* binary dump */ - if(bin_output) { + if(bin_output) + { do_bin_output(stream, nelmts, type, _mem); - bin_output = 0; } /* end if */ - else { - /* Setup */ + else + { + /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); size = H5Tget_size(type); @@ -613,7 +615,7 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai } /* - * We need to break after each row_counter of a dimension---> we should + * We need to break after each row of a dimension---> we should * break at the end of the each last dimension well that is the * way the dumper did it before */ diff --git a/tools/testfiles/tbin4.ddl b/tools/testfiles/tbin4.ddl index 89849e4..78a6cd2 100644 --- a/tools/testfiles/tbin4.ddl +++ b/tools/testfiles/tbin4.ddl @@ -1,7 +1,7 @@ HDF5 "tbinary.h5" { DATASET "double" { DATATYPE H5T_IEEE_F64LE - DATASPACE SIMPLE { ( 100000 ) / ( 100000 ) } + DATASPACE SIMPLE { ( 6 ) / ( 6 ) } DATA { } } diff --git a/tools/testfiles/tbinary.h5 b/tools/testfiles/tbinary.h5 index 691b008..adc5b15 100644 Binary files a/tools/testfiles/tbinary.h5 and b/tools/testfiles/tbinary.h5 differ diff --git a/windows/tools/h5dump/testh5dump.bat b/windows/tools/h5dump/testh5dump.bat index f26a5d9..9f202c5 100644 --- a/windows/tools/h5dump/testh5dump.bat +++ b/windows/tools/h5dump/testh5dump.bat @@ -16,7 +16,7 @@ rem rem Tests for the h5dump tool rem rem Created: Scott Wegner, 8/23/07 -rem Modified: Scott Wegner, 8/27/07 +rem Modified: Scott Wegner, 3/10/08 rem setlocal enabledelayedexpansion @@ -405,8 +405,7 @@ rem ############################################################################ call :tooltest tall-4s.ddl --dataset=/g1/g1.1/dset1.1.1 --start=1,1 --stride=2,3 --count=3,2 --block=1,1 tall.h5 call :tooltest tall-5s.ddl -d "/g1/g1.1/dset1.1.2[0;2;10;]" tall.h5 call :tooltest tdset-3s.ddl -d "/dset1[1,1;;;]" tdset.h5 - rem block - rem call :tooltest tdset2-1s.ddl -d "/dset1[;3,2;4,4;1,4]" tdset2.h5 + rem test printing characters in ASCII instead of decimal call :tooltest tchar1.ddl -r tchar.h5 diff --git a/windows/tools/h5repack/h5repack.vcproj b/windows/tools/h5repack/h5repack.vcproj index 9896209..802e797 100644 --- a/windows/tools/h5repack/h5repack.vcproj +++ b/windows/tools/h5repack/h5repack.vcproj @@ -263,7 +263,7 @@ OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="1" SuppressStartupBanner="true" - AdditionalLibraryDirectories="D:\szip\all\lib\Debug" + AdditionalLibraryDirectories="" IgnoreDefaultLibraryNames="libc.lib" GenerateDebugInformation="true" ProgramDatabaseFile=".\../../../tools/h5repack/Debug/h5repack.pdb" @@ -358,7 +358,7 @@ OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="1" SuppressStartupBanner="true" - AdditionalLibraryDirectories="D:\szip\all\lib\Debug" + AdditionalLibraryDirectories="" IgnoreDefaultLibraryNames="libc.lib" GenerateDebugInformation="true" ProgramDatabaseFile=".\../../../tools/h5repack/Debug/h5repack.pdb" diff --git a/windows_vnet/tools/h5repack/h5repack.vcproj b/windows_vnet/tools/h5repack/h5repack.vcproj index 12522bb..60568b1 100644 --- a/windows_vnet/tools/h5repack/h5repack.vcproj +++ b/windows_vnet/tools/h5repack/h5repack.vcproj @@ -105,7 +105,7 @@ OutputFile=".\../../../tools/h5repack/Debug/h5repack.exe" LinkIncremental="1" SuppressStartupBanner="TRUE" - AdditionalLibraryDirectories="D:\szip\all\lib\Debug" + AdditionalLibraryDirectories="" IgnoreDefaultLibraryNames="libc.lib" GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\../../../tools/h5repack/Debug/h5repack.pdb" -- cgit v0.12