summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-06-16 22:17:29 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-06-16 22:17:29 (GMT)
commitdb2c4c497abab139485dbf6797e56b1340e4577d (patch)
treef7dfb321a3643658ed24aaf776ec4c1e48bc76a3 /tools
parent55af47c47c3c0c7bc17266968f5e0e782189e819 (diff)
downloadhdf5-db2c4c497abab139485dbf6797e56b1340e4577d.zip
hdf5-db2c4c497abab139485dbf6797e56b1340e4577d.tar.gz
hdf5-db2c4c497abab139485dbf6797e56b1340e4577d.tar.bz2
[svn-r15221] Description:
Bring changes from trunk from the time the branch was created (r14280) up to the 1.8.0 release (r14525) back into the metadata journaling branch. 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 Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.in1
-rw-r--r--tools/h5copy/Makefile.in1
-rw-r--r--tools/h5copy/h5copy.c4
-rw-r--r--tools/h5diff/Makefile.in1
-rw-r--r--tools/h5diff/h5diff_common.c381
-rw-r--r--tools/h5diff/h5diffgentest.c74
-rw-r--r--tools/h5dump/Makefile.in1
-rw-r--r--tools/h5dump/h5dump.c54
-rw-r--r--tools/h5dump/h5dumpgentest.c2
-rw-r--r--tools/h5dump/testh5dump.sh.in17
-rw-r--r--tools/h5import/Makefile.am2
-rwxr-xr-xtools/h5import/Makefile.in7
-rw-r--r--tools/h5jam/Makefile.in1
-rw-r--r--tools/h5ls/Makefile.in1
-rw-r--r--tools/h5ls/h5ls.c524
-rwxr-xr-xtools/h5ls/testh5ls.sh57
-rw-r--r--tools/h5recover/Makefile.in1
-rwxr-xr-xtools/h5recover/enable_journaling.c4
-rw-r--r--tools/h5recover/h5recover.c4
-rw-r--r--tools/h5repack/Makefile.am4
-rw-r--r--tools/h5repack/Makefile.in12
-rw-r--r--tools/h5repack/h5repack.c789
-rw-r--r--tools/h5repack/h5repack.h68
-rwxr-xr-xtools/h5repack/h5repack.sh.in21
-rw-r--r--tools/h5repack/h5repack_copy.c482
-rw-r--r--tools/h5repack/h5repack_filters.c77
-rw-r--r--tools/h5repack/h5repack_list.c153
-rw-r--r--tools/h5repack/h5repack_main.c699
-rw-r--r--tools/h5repack/h5repack_opttable.c476
-rw-r--r--tools/h5repack/h5repack_parse.c1082
-rw-r--r--tools/h5repack/h5repack_refs.c2
-rw-r--r--tools/h5repack/h5repack_verify.c848
-rw-r--r--tools/h5repack/h5repacktst.c37
-rw-r--r--tools/h5stat/Makefile.in1
-rw-r--r--tools/h5stat/h5stat.c327
-rw-r--r--tools/h5stat/h5stat_gentest.c2
-rw-r--r--tools/h5stat/testfiles/h5stat_filters-file.ddl1
-rw-r--r--tools/h5stat/testfiles/h5stat_filters.ddl1
-rw-r--r--tools/h5stat/testfiles/h5stat_newgrat.ddl1
-rw-r--r--tools/h5stat/testfiles/h5stat_tsohm.ddl1
-rw-r--r--tools/lib/Makefile.in1
-rw-r--r--tools/lib/h5diff.c2
-rw-r--r--tools/lib/h5diff_array.c4130
-rw-r--r--tools/lib/h5tools.c155
-rw-r--r--tools/lib/h5tools_ref.c192
-rw-r--r--tools/lib/h5tools_utils.c186
-rw-r--r--tools/lib/h5tools_utils.h2
-rw-r--r--tools/lib/h5trav.c276
-rw-r--r--tools/lib/h5trav.h14
-rw-r--r--tools/misc/Makefile.in1
-rw-r--r--tools/misc/h5mkgrp.c4
-rw-r--r--tools/testfiles/h5copytst.out.ls163
-rw-r--r--tools/testfiles/h5diff_17.txt2
-rw-r--r--tools/testfiles/h5diff_basic1.h5bin8552 -> 9392 bytes
-rw-r--r--tools/testfiles/h5mkgrp_nested.ls3
-rw-r--r--tools/testfiles/h5mkgrp_nested_latest.ls4
-rw-r--r--tools/testfiles/h5mkgrp_nested_mult.ls3
-rw-r--r--tools/testfiles/h5mkgrp_nested_mult_latest.ls4
-rw-r--r--tools/testfiles/h5mkgrp_several.ls3
-rw-r--r--tools/testfiles/h5mkgrp_several_latest.ls4
-rw-r--r--tools/testfiles/h5mkgrp_single.ls3
-rw-r--r--tools/testfiles/h5mkgrp_single_latest.ls4
-rw-r--r--tools/testfiles/tall-2.ls1
-rw-r--r--tools/testfiles/tarray1.ls1
-rw-r--r--tools/testfiles/tattr2.ls143
-rw-r--r--tools/testfiles/tcomp-1.ls1
-rw-r--r--tools/testfiles/tdset-1.ls1
-rw-r--r--tools/testfiles/textlink-1.ls1
-rw-r--r--tools/testfiles/tgroup-1.ls40
-rw-r--r--tools/testfiles/tgroup-2.ls4
-rw-r--r--tools/testfiles/tindicessub1.ddl14
-rw-r--r--tools/testfiles/tindicessub2.ddl22
-rw-r--r--tools/testfiles/tindicessub3.ddl30
-rw-r--r--tools/testfiles/tindicessub4.ddl58
-rw-r--r--tools/testfiles/tloop-1.ls1
-rw-r--r--tools/testfiles/tnestcomp-1.ls1
-rw-r--r--tools/testfiles/tnofilename.ddl4
-rw-r--r--tools/testfiles/tsaf.ls1
-rw-r--r--tools/testfiles/tslink-1.ls1
-rw-r--r--tools/testfiles/tstr-1.ls1
-rw-r--r--tools/testfiles/tudlink-1.ls1
-rw-r--r--tools/testfiles/tvldtypes1.ls1
82 files changed, 5705 insertions, 5999 deletions
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 674b0af..8ed72c4 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -193,6 +193,7 @@ SET_MAKE = @SET_MAKE@
SHELL = /bin/sh
SIZE_T = @SIZE_T@
STATIC_SHARED = @STATIC_SHARED@
+STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
TESTPARALLEL = @TESTPARALLEL@
TIME = @TIME@
diff --git a/tools/h5copy/Makefile.in b/tools/h5copy/Makefile.in
index 9eb5425..f21e156 100644
--- a/tools/h5copy/Makefile.in
+++ b/tools/h5copy/Makefile.in
@@ -210,6 +210,7 @@ SET_MAKE = @SET_MAKE@
SHELL = /bin/sh
SIZE_T = @SIZE_T@
STATIC_SHARED = @STATIC_SHARED@
+STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
TESTPARALLEL = @TESTPARALLEL@
TIME = @TIME@
diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c
index cadb0d0..216b2bb 100644
--- a/tools/h5copy/h5copy.c
+++ b/tools/h5copy/h5copy.c
@@ -199,8 +199,8 @@ main (int argc, const char *argv[])
unsigned flag=0;
unsigned verbose=0;
unsigned parents=0;
- hid_t ocpl_id; /* Object copy property list */
- hid_t lcpl_id; /* Link creation property list */
+ hid_t ocpl_id = (-1); /* Object copy property list */
+ hid_t lcpl_id = (-1); /* Link creation property list */
char str_flag[20];
int opt;
diff --git a/tools/h5diff/Makefile.in b/tools/h5diff/Makefile.in
index 79c6ab6..92dbbe3 100644
--- a/tools/h5diff/Makefile.in
+++ b/tools/h5diff/Makefile.in
@@ -217,6 +217,7 @@ SET_MAKE = @SET_MAKE@
SHELL = /bin/sh
SIZE_T = @SIZE_T@
STATIC_SHARED = @STATIC_SHARED@
+STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
TESTPARALLEL = @TESTPARALLEL@
TIME = @TIME@
diff --git a/tools/h5diff/h5diff_common.c b/tools/h5diff/h5diff_common.c
index 802cc37..357bb32 100644
--- a/tools/h5diff/h5diff_common.c
+++ b/tools/h5diff/h5diff_common.c
@@ -52,175 +52,6 @@ static struct long_options l_opts[] = {
*
*-------------------------------------------------------------------------
*/
-#if 0
-#define OLD
-#endif
-
-#if defined (OLD)
-
-void parse_command_line(int argc,
- const char* argv[],
- const char** fname1,
- const char** fname2,
- const char** objname1,
- const char** objname2,
- diff_opt_t* options)
-{
- int i;
- const char *s = NULL;
-
- /* process the command-line */
- memset(options, 0, sizeof (diff_opt_t));
-
-/*-------------------------------------------------------------------------
- * initial check of command line options
- *-------------------------------------------------------------------------
- */
-
- if ( argv[1] && (strcmp("-V",argv[1])==0) )
- {
- print_version("h5diff");
- h5diff_exit(EXIT_SUCCESS);
-
- }
-
- if ( argc==2 && (strcmp("-h",argv[1])==0) )
- usage();
-
- if ( argc<3 )
- {
- usage();
- }
-
-/*-------------------------------------------------------------------------
- * file names are first
- *-------------------------------------------------------------------------
- */
- if ( argc>=3 )
- {
- *fname1 = argv[1];
- *fname2 = argv[2];
- }
-/*-------------------------------------------------------------------------
- * parse command line options
- *-------------------------------------------------------------------------
- */
- for (i=3; i<argc ; i++)
- {
- /* get the single-letter switches */
- if ( '-'==argv[i][0] )
- {
- for (s=argv[i]+1; *s; s++)
- {
- switch (*s) {
- default:
- printf("-%s is an invalid option\n", s );
- usage();
- break;
- case 'h':
- usage();
- break;
- case 'V':
- print_version("h5diff");
- h5diff_exit(EXIT_SUCCESS);
- case 'v':
- options->m_verbose = 1;
- break;
- case 'q':
- /* use quiet mode; supress the message "0 differences found" */
- options->m_quiet = 1;
- break;
- case 'r':
- options->m_report = 1;
- break;
- case 'd':
- /* if it is not another option */
- if ( i<argc-1 &&'-' != argv[i+1][0] )
- {
- options->d=1;
- if ( check_p_input(argv[i+1])==-1)
- {
- printf("<-d %s> is not a valid option\n", argv[i+1] );
- usage();
- }
- options->delta = atof(argv[i+1]);
- i++; /* go to next */
- }
- else
- {
- printf("Not a valid -d option\n");
- usage();
- }
- break;
- case 'p':
- if ( i<argc-1 &&'-' !=argv[i+1][0] )
- {
- options->p=1;
- if ( check_p_input(argv[i+1])==-1)
- {
- printf("<-p %s> is not a valid option\n", argv[i+1] );
- usage();
- }
- options->percent = atof(argv[i+1]);
- i++; /* go to next */
- }
- else
- {
- printf("Not a valid -p option\n");
- usage();
- }
- break;
- case 'n':
- if ( i<argc-1 && '-' !=argv[i+1][0] )
- {
- options->n=1;
- if ( check_n_input(argv[i+1])==-1)
- {
- printf("<-n %s> is not a valid option\n", argv[i+1] );
- usage();
- }
- options->count = atol(argv[i+1]);
- i++; /* go to next */
- }
- else
- {
- printf("Not a valid -n option\n");
- usage();
- }
- break;
- } /*switch*/
- } /*for*/
- } /*if*/
-
- else /* not single-letter switches */
-
- {
- /* check if it is not a -d, -p parameter */
- if ( '-'==argv[i-1][0] && ('d'==argv[i-1][1] ||'p'==argv[i-1][1] ))
- continue;
- else
- {
- if ( *objname1==NULL )
- *objname1 = argv[i];
- if ( *objname2==NULL )
- {
- /* check if we have a second object name */
- if ( i+1<argc && '-' !=argv[i+1][0] ) {
- /* yes */
- *objname2 = argv[i+1];
- i++; /* go to next */
- }
- else
- /* no */
- *objname2 = *objname1;
- } /*objname2*/
- } /*else*/
- } /*else*/
-
- }/*for*/
-}
-
-#else
void parse_command_line(int argc,
const char* argv[],
@@ -329,40 +160,37 @@ void parse_command_line(int argc,
}
-
-#endif
-
/*-------------------------------------------------------------------------
* Function: print_info
*
- * Purpose: print several information messages
+ * Purpose: print several information messages after h5diff call
*
*-------------------------------------------------------------------------
*/
-void print_info(diff_opt_t* options)
-{
- if (options->m_quiet || options->err_stat)
- return;
-
- if (options->cmn_objs==0)
- {
- printf("No common objects found. Files are not comparable.\n");
- if (!options->m_verbose)
- printf("Use -v for a list of objects.\n");
- }
-
- if (options->not_cmp==1)
+ void print_info(diff_opt_t* options)
{
- printf("--------------------------------\n");
- printf("Some objects are not comparable\n");
- printf("--------------------------------\n");
- if (!options->m_verbose)
- printf("Use -v for a list of objects.\n");
+ if (options->m_quiet || options->err_stat)
+ return;
+
+ if (options->cmn_objs==0)
+ {
+ printf("No common objects found. Files are not comparable.\n");
+ if (!options->m_verbose)
+ printf("Use -v for a list of objects.\n");
+ }
+
+ if (options->not_cmp==1)
+ {
+ printf("--------------------------------\n");
+ printf("Some objects are not comparable\n");
+ printf("--------------------------------\n");
+ if (!options->m_verbose)
+ printf("Use -v for a list of objects.\n");
+ }
+
}
-}
-
/*-------------------------------------------------------------------------
* Function: check_n_input
*
@@ -382,22 +210,22 @@ void print_info(diff_opt_t* options)
*/
int check_n_input( const char *str )
{
- unsigned i;
- char c;
-
- for ( i = 0; i < strlen(str); i++)
- {
- c = str[i];
- if ( i==0 )
- {
- if ( c < 49 || c > 57 ) /* ascii values between 1 and 9 */
- return -1;
- }
- else
- if ( c < 48 || c > 57 ) /* 0 also */
- return -1;
- }
- return 1;
+ unsigned i;
+ char c;
+
+ for ( i = 0; i < strlen(str); i++)
+ {
+ c = str[i];
+ if ( i==0 )
+ {
+ if ( c < 49 || c > 57 ) /* ascii values between 1 and 9 */
+ return -1;
+ }
+ else
+ if ( c < 48 || c > 57 ) /* 0 also */
+ return -1;
+ }
+ return 1;
}
/*-------------------------------------------------------------------------
@@ -417,20 +245,20 @@ int check_n_input( const char *str )
*/
int check_p_input( const char *str )
{
- double x;
-
- /*
- the atof return value on a hexadecimal input is different
- on some systems; we do a character check for this
- */
- if (strlen(str)>2 && str[0]=='0' && str[1]=='x')
- return -1;
-
- x=atof(str);
- if (x<=0)
- return -1;
-
- return 1;
+ double x;
+
+ /*
+ the atof return value on a hexadecimal input is different
+ on some systems; we do a character check for this
+ */
+ if (strlen(str)>2 && str[0]=='0' && str[1]=='x')
+ return -1;
+
+ x=atof(str);
+ if (x<=0)
+ return -1;
+
+ return 1;
}
/*-------------------------------------------------------------------------
@@ -450,20 +278,20 @@ int check_p_input( const char *str )
*/
int check_d_input( const char *str )
{
- double x;
-
- /*
- the atof return value on a hexadecimal input is different
- on some systems; we do a character check for this
- */
- if (strlen(str)>2 && str[0]=='0' && str[1]=='x')
- return -1;
-
- x=atof(str);
- if (x <=0)
- return -1;
-
- return 1;
+ double x;
+
+ /*
+ the atof return value on a hexadecimal input is different
+ on some systems; we do a character check for this
+ */
+ if (strlen(str)>2 && str[0]=='0' && str[1]=='x')
+ return -1;
+
+ x=atof(str);
+ if (x <=0)
+ return -1;
+
+ return 1;
}
/*-------------------------------------------------------------------------
@@ -476,68 +304,6 @@ int check_d_input( const char *str )
*-------------------------------------------------------------------------
*/
-#if defined (OLD)
-void usage(void)
-{
- printf("usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] \n");
- printf("\n");
- printf("file1 File name of the first HDF5 file\n");
- printf("file2 File name of the second HDF5 file\n");
- printf("[obj1] Name of an HDF5 object, in absolute path\n");
- printf("[obj2] Name of an HDF5 object, in absolute path\n");
- printf("[OPTIONS] are:\n");
- printf("[-h] Print out this information\n");
- printf("[-V] Print HDF5 library version number and exit\n");
- printf("[-r] Report mode. Print differences\n");
- printf("[-v] Verbose mode. Print differences, list of objects, warnings\n");
- printf("[-q] Quiet mode. Do not do output\n");
- printf("[-n count] Print difference up to count number\n");
- printf("[-d delta] Print difference when it is greater than limit delta\n");
- printf("[-p relative] Print difference when it is greater than a relative limit\n");
- printf("\n");
- printf("Items in [] are optional\n");
- printf("[obj1] and [obj2] are HDF5 objects (datasets, groups, datatypes or links)\n");
- printf("The 'count' value must be a positive integer\n");
- printf("The 'delta' and 'relative' values must be positive numbers\n");
- printf("The -d compare criteria is |a - b| > delta\n");
- printf("The -p compare criteria is |(b-a)/a| > relative\n");
- printf("\n");
- printf("h5diff has four modes of output:\n");
- printf(" Normal mode: print the number of differences found and where they occured\n");
- printf(" Report mode: print the above plus the differences\n");
- printf(" Verbose mode: print the above plus a list of objects and warnings\n");
- printf(" Quiet mode: do not print output (h5diff always returns an exit code of 1 when differences are found)\n");
- printf("\n");
- printf("Examples of use:\n");
- printf("\n");
- printf("1) h5diff file1 file2 /g1/dset1 /g1/dset2\n");
- printf("\n");
- printf(" Compares object '/g1/dset1' in file1 with '/g1/dset2' in file2\n");
- printf("\n");
- printf("2) h5diff file1 file2 /g1/dset1\n");
- printf("\n");
- printf(" Compares object '/g1/dset1' in both files\n");
- printf("\n");
- printf("3) h5diff file1 file2\n");
- printf("\n");
- printf(" Compares all objects in both files\n");
- printf("\n");
- printf("Note) file1 and file2 can be the same file. Use\n");
- printf("\n");
- printf(" h5diff file1 file1 /g1/dset1 /g1/dset2\n");
- printf("\n");
- printf(" to compare '/g1/dset1' and '/g1/dset2' in the same file\n");
- printf("\n");
- printf("If no objects are specified, h5diff only compares objects with the same ");
- printf("absolute path in both files. The compare criteria is: ");
- printf("1) datasets: numerical array differences 2) groups: name string difference ");
- printf("3) datatypes: the return value of H5Tequal 2) links: name string difference of the linked value\n");
-
-}
-
-
-#else
-
void usage(void)
{
printf("usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] \n");
@@ -610,7 +376,6 @@ void usage(void)
}
-#endif
/*-------------------------------------------------------------------------
* Function: h5diff_exit
@@ -631,14 +396,14 @@ void usage(void)
void h5diff_exit(int status)
{
#ifdef H5_HAVE_PARALLEL
- /* if in parallel mode, dismiss workers, close down MPI, then exit */
- if((g_nTasks > 1) && g_Parallel) {
- phdiff_dismiss_workers();
- MPI_Barrier(MPI_COMM_WORLD);
- }
- if(g_Parallel)
- MPI_Finalize();
+ /* if in parallel mode, dismiss workers, close down MPI, then exit */
+ if((g_nTasks > 1) && g_Parallel) {
+ phdiff_dismiss_workers();
+ MPI_Barrier(MPI_COMM_WORLD);
+ }
+ if(g_Parallel)
+ MPI_Finalize();
#endif
- exit(status);
+ exit(status);
}
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c
index 51e0a83..735dc0f 100644
--- a/tools/h5diff/h5diffgentest.c
+++ b/tools/h5diff/h5diffgentest.c
@@ -249,10 +249,12 @@ int test_basic(const char *fname1,
/*-------------------------------------------------------------------------
- * NaNs in floating point
+ * NaNs in H5T_NATIVE_FLOAT
*-------------------------------------------------------------------------
*/
{
+
+#if 1
float data15[6];
float data16[6];
@@ -272,10 +274,78 @@ 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
+ *-------------------------------------------------------------------------
+ */
+ {
+
+ double data17[6];
+ double data18[6];
+
+ data17[0] = sqrt( (double)-1 );
+ data17[1] = 1;
+ data17[2] = sqrt( (double)-1 );
+ data17[3] = 1;
+ data17[4] = 1;
+ data17[5] = 1;
+
+ data18[0] = (float) sqrt( (double)-1 );
+ data18[1] = (float) sqrt( (double)-1 );
+ data18[2] = 1;
+ data18[3] = 1;
+ data18[4] = 1;
+ data18[5] = 1;
+
+ write_dset(gid1,1,dims1,"fp17",H5T_NATIVE_DOUBLE,data17);
+ write_dset(gid1,1,dims1,"fp18",H5T_NATIVE_DOUBLE,data18);
}
+
+
+
/*-------------------------------------------------------------------------
* close
@@ -2385,7 +2455,7 @@ void gen_datareg(hid_t fid,
coord[3][0]=2; coord[3][1]=5;
coord[4][0]=1; coord[4][1]=7;
}
- H5Sselect_elements(sid1,H5S_SELECT_SET,5,(const hsize_t **)coord);
+ H5Sselect_elements(sid1,H5S_SELECT_SET,5,coord);
H5Sget_select_npoints(sid1);
/* store second dataset region */
diff --git a/tools/h5dump/Makefile.in b/tools/h5dump/Makefile.in
index 4bb4ad9..03f729b 100644
--- a/tools/h5dump/Makefile.in
+++ b/tools/h5dump/Makefile.in
@@ -215,6 +215,7 @@ SET_MAKE = @SET_MAKE@
SHELL = /bin/sh
SIZE_T = @SIZE_T@
STATIC_SHARED = @STATIC_SHARED@
+STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
TESTPARALLEL = @TESTPARALLEL@
TIME = @TIME@
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index c69c5d70..70d889f 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -610,7 +610,7 @@ usage(const char *prog)
fprintf(stdout, " OPTIONS\n");
fprintf(stdout, " -h, --help Print a usage message and exit\n");
fprintf(stdout, " -n, --contents Print a list of the file contents and exit\n");
- fprintf(stdout, " -B, --bootblock Print the content of the boot block\n");
+ fprintf(stdout, " -B, --superblock Print the content of the super block\n");
fprintf(stdout, " -H, --header Print the header only; no data is displayed\n");
fprintf(stdout, " -A, --onlyattr Print the header and value of attributes\n");
fprintf(stdout, " -i, --object-ids Print the object ids\n");
@@ -620,7 +620,7 @@ usage(const char *prog)
fprintf(stdout, " -a P, --attribute=P Print the specified attribute\n");
fprintf(stdout, " -d P, --dataset=P Print the specified dataset\n");
fprintf(stdout, " -y, --noindex Do not print array indices with the data\n");
- fprintf(stdout, " -p, --properties Print dataset filters, storage layout and fill value\n");
+ fprintf(stdout, " -p, --properties Print dataset filters, storage layout and fill value\n");
fprintf(stdout, " -f D, --filedriver=D Specify which driver to open the file with\n");
fprintf(stdout, " -g P, --group=P Print the specified group and all members\n");
fprintf(stdout, " -l P, --soft-link=P Print the value(s) of the specified soft link\n");
@@ -2756,7 +2756,7 @@ static void
dump_fcpl(hid_t fid)
{
hid_t fcpl; /* file creation property list ID */
- hid_t fapl; /* file access property list ID */
+ hid_t fapl; /* file access property list ID */
hsize_t userblock; /* userblock size retrieved from FCPL */
size_t off_size; /* size of offsets in the file */
size_t len_size; /* size of lengths in the file */
@@ -2764,7 +2764,7 @@ dump_fcpl(hid_t fid)
unsigned freelist; /* free list version # */
unsigned stab; /* symbol table entry version # */
unsigned shhdr; /* shared object header version # */
- hid_t fdriver; /* file driver */
+ hid_t fdriver; /* file driver */
char dname[32]; /* buffer to store driver name */
unsigned sym_lk; /* symbol table B-tree leaf 'K' value */
unsigned sym_ik; /* symbol table B-tree internal 'K' value */
@@ -2781,7 +2781,7 @@ dump_fcpl(hid_t fid)
fdriver=H5Pget_driver(fapl);
H5Pclose(fapl);
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* SUPER_BLOCK
*-------------------------------------------------------------------------
*/
@@ -3181,6 +3181,8 @@ parse_subset_params(char *dset)
* Tuesday, 9. January 2001
*
* Modifications:
+ * Pedro Vicente, Tuesday, January 15, 2008
+ * check for block overlap
*
*-------------------------------------------------------------------------
*/
@@ -3253,6 +3255,38 @@ handle_datasets(hid_t fid, char *dset, void *data)
}
}
+
+ /*-------------------------------------------------------------------------
+ * check for block overlap
+ *-------------------------------------------------------------------------
+ */
+
+ if(sset)
+ {
+ hid_t sid = H5Dget_space(dsetid);
+ unsigned int ndims = H5Sget_simple_extent_ndims(sid);
+ unsigned int i;
+
+ for ( i = 0; i < ndims; i++)
+ {
+ if ( sset->count[i] > 1 )
+ {
+
+ if ( sset->stride[i] < sset->block[i] )
+ {
+ error_msg(progname, "wrong subset selection; blocks overlap\n");
+ d_status = EXIT_FAILURE;
+ return;
+
+ }
+
+ }
+
+ }
+ H5Sclose(sid);
+
+ }
+
H5Oget_info(dsetid, &oinfo);
if(oinfo.rc > 1) {
obj_t *found_obj; /* Found object */
@@ -3952,7 +3986,7 @@ main(int argc, const char *argv[])
/* allocate and initialize internal data structure */
init_prefix(&prefix, prefix_len);
- /* find all objects that might be targets of a reference */
+ /* Prepare to find objects that might be targets of a reference */
fill_ref_path_table(fid);
if(doxml) {
@@ -4094,7 +4128,6 @@ done:
free_table(type_table);
HDfree(prefix);
- HDfree(info.prefix);
HDfree(fname);
/* To Do: clean up XML table */
@@ -5342,8 +5375,7 @@ xml_dump_group(hid_t gid, const char *name)
if(HDstrcmp(name, "/") == 0) {
isRoot = 1;
- tmp = HDmalloc(2);
- HDstrcpy(tmp, "/");
+ tmp = HDstrdup("/");
} else {
tmp = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
HDstrcpy(tmp, prefix);
@@ -5401,8 +5433,8 @@ xml_dump_group(hid_t gid, const char *name)
ptrstr = malloc(100);
t_objname = xml_escape_the_name(found_obj->objname);
par_name = xml_escape_the_name(par);
- xml_name_to_XID(par,parentxid,100,1);
- xml_name_to_XID(found_obj->objname,ptrstr,100,1);
+ xml_name_to_XID(found_obj->objname, ptrstr, 100, 1);
+ xml_name_to_XID(par, parentxid, 100, 1);
printf("<%sGroupPtr OBJ-XID=\"%s\" H5Path=\"%s\" "
"Parents=\"%s\" H5ParentPaths=\"%s\" />\n",
xmlnsprefix,
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index 516a740..b21a020 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -1812,7 +1812,7 @@ static void gent_datareg(void)
coord1[7][0]=9; coord1[7][1]=0;
coord1[8][0]=7; coord1[8][1]=1;
coord1[9][0]=3; coord1[9][1]=3;
- H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,(const hsize_t **)coord1);
+ H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,coord1);
H5Sget_select_npoints(sid2);
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index 3fc39f2..b7b8429 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -373,11 +373,18 @@ TOOLTEST tstring2.ddl -r -d str4 tstr3.h5
TOOLTEST tindicesyes.ddl taindices.h5
TOOLTEST tindicesno.ddl -y taindices.h5
-# array indices with subsetting
-TOOLTEST tindicessub1.ddl -d 1d -s 3 -c 40 taindices.h5
-TOOLTEST tindicessub2.ddl -d 2d -s 1,3 -c 6,4 taindices.h5
-TOOLTEST tindicessub3.ddl -d 3d -s 0,1,3 -c 2,6,4 taindices.h5
-TOOLTEST tindicessub4.ddl -d 4d -s 0,0,1,3 -c 2,2,6,4 taindices.h5
+########## array indices with subsetting
+# 1D case
+TOOLTEST tindicessub1.ddl -d 1d -s 1 -S 10 -c 2 -k 3 taindices.h5
+
+# 2D case
+TOOLTEST tindicessub2.ddl -d 2d -s 1,2 -S 3,3 -c 3,2 -k 2,2 taindices.h5
+
+# 3D case
+TOOLTEST tindicessub3.ddl -d 3d -s 0,1,2 -S 1,3,3 -c 2,2,2 -k 1,2,2 taindices.h5
+
+# 4D case
+TOOLTEST tindicessub4.ddl -d 4d -s 0,0,1,2 -c 2,2,3,2 -S 1,1,3,3 -k 1,1,2,2 taindices.h5
# tests for filters
diff --git a/tools/h5import/Makefile.am b/tools/h5import/Makefile.am
index aabc6c4..a88cb36 100644
--- a/tools/h5import/Makefile.am
+++ b/tools/h5import/Makefile.am
@@ -35,6 +35,6 @@ SCRIPT_DEPEND=h5import$(EXEEXT)
bin_PROGRAMS=h5import
# All programs depend on the main hdf5 library and the tools library
-LDADD=$(LIBHDF5) $(LIBH5TOOLS)
+LDADD=$(LIBH5TOOLS) $(LIBHDF5)
include $(top_srcdir)/config/conclude.am
diff --git a/tools/h5import/Makefile.in b/tools/h5import/Makefile.in
index 159e151..b67f45f 100755
--- a/tools/h5import/Makefile.in
+++ b/tools/h5import/Makefile.in
@@ -70,11 +70,11 @@ PROGRAMS = $(bin_PROGRAMS)
h5import_SOURCES = h5import.c
h5import_OBJECTS = h5import.$(OBJEXT)
h5import_LDADD = $(LDADD)
-h5import_DEPENDENCIES = $(LIBHDF5) $(LIBH5TOOLS)
+h5import_DEPENDENCIES = $(LIBH5TOOLS) $(LIBHDF5)
h5importtest_SOURCES = h5importtest.c
h5importtest_OBJECTS = h5importtest.$(OBJEXT)
h5importtest_LDADD = $(LDADD)
-h5importtest_DEPENDENCIES = $(LIBHDF5) $(LIBH5TOOLS)
+h5importtest_DEPENDENCIES = $(LIBH5TOOLS) $(LIBHDF5)
DEFAULT_INCLUDES = -I. -I$(top_builddir)/src@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/bin/depcomp
am__depfiles_maybe = depfiles
@@ -210,6 +210,7 @@ SET_MAKE = @SET_MAKE@
SHELL = /bin/sh
SIZE_T = @SIZE_T@
STATIC_SHARED = @STATIC_SHARED@
+STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
TESTPARALLEL = @TESTPARALLEL@
TIME = @TIME@
@@ -330,7 +331,7 @@ check_SCRIPT = h5importtestutil.sh
SCRIPT_DEPEND = h5import$(EXEEXT)
# All programs depend on the main hdf5 library and the tools library
-LDADD = $(LIBHDF5) $(LIBH5TOOLS)
+LDADD = $(LIBH5TOOLS) $(LIBHDF5)
# Automake needs to be taught how to build lib, progs, and tests targets.
# These will be filled in automatically for the most part (e.g.,
diff --git a/tools/h5jam/Makefile.in b/tools/h5jam/Makefile.in
index 83555b1..500029b 100644
--- a/tools/h5jam/Makefile.in
+++ b/tools/h5jam/Makefile.in
@@ -221,6 +221,7 @@ SET_MAKE = @SET_MAKE@
SHELL = /bin/sh
SIZE_T = @SIZE_T@
STATIC_SHARED = @STATIC_SHARED@
+STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
TESTPARALLEL = @TESTPARALLEL@
TIME = @TIME@
diff --git a/tools/h5ls/Makefile.in b/tools/h5ls/Makefile.in
index 605793a..ff0e8d5 100644
--- a/tools/h5ls/Makefile.in
+++ b/tools/h5ls/Makefile.in
@@ -204,6 +204,7 @@ SET_MAKE = @SET_MAKE@
SHELL = /bin/sh
SIZE_T = @SIZE_T@
STATIC_SHARED = @STATIC_SHARED@
+STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
TESTPARALLEL = @TESTPARALLEL@
TIME = @TIME@
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index 2c56cb5..80b45d8 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -27,6 +27,15 @@
#include "H5private.h"
#include "h5tools.h"
#include "h5tools_utils.h"
+#include "h5trav.h"
+
+#define NAME_BUF_SIZE 2048
+
+/* Struct to pass through to visitors */
+typedef struct {
+ hid_t fid; /* File ID */
+ const char *fname; /* Filename */
+}iter_t;
/* Command-line switches */
static int verbose_g = 0; /* lots of extra output */
@@ -43,21 +52,7 @@ static hbool_t show_errors_g = FALSE; /* print HDF5 error messages */
static hbool_t simple_output_g = FALSE; /* make output more machine-readable */
static hbool_t show_file_name_g = FALSE; /* show file name for full names */
static hbool_t no_line_wrap_g = FALSE; /* show data content without line wrap */
-
-/* Info to pass to the iteration functions */
-typedef struct iter_t {
- const char *container; /* full name of the container object */
-} iter_t;
-
-/* Table containing object id and object name */
-static struct {
- int nalloc; /* number of slots allocated */
- int nobjs; /* number of objects */
- struct {
- haddr_t id; /* object number */
- char *name; /* full object name */
- } *obj;
-} idtab_g;
+static hbool_t display_root_g = FALSE; /* show root group in output? */
/* Information about how to display each type of object */
static struct dispatch_t {
@@ -68,17 +63,13 @@ static struct dispatch_t {
herr_t (*list2)(hid_t obj, const char *name);
} dispatch_g[H5O_TYPE_NTYPES];
-#define DISPATCH(TYPE, NAME, OPEN, CLOSE, LIST1, LIST2) { \
+#define DISPATCH(TYPE, NAME, LIST1, LIST2) { \
dispatch_g[TYPE].name = (NAME); \
- dispatch_g[TYPE].open = (OPEN); \
- dispatch_g[TYPE].close = (CLOSE); \
dispatch_g[TYPE].list1 = (LIST1); \
dispatch_g[TYPE].list2 = (LIST2); \
}
-static herr_t list(hid_t group, const char *name, const H5L_info_t *linfo, void *cd);
static void display_type(hid_t type, int ind);
-static char *fix_name(const char *path, const char *base);
const char *progname="h5ls";
int d_status;
@@ -131,76 +122,6 @@ usage: %s [OPTIONS] [OBJECTS...]\n\
/*-------------------------------------------------------------------------
- * Function: sym_insert
- *
- * Purpose: Add a symbol to the table.
- *
- * Return: void
- *
- * Programmer: Robb Matzke
- * Thursday, January 21, 1999
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-sym_insert(const H5O_info_t *oi, const char *name)
-{
- int n;
-
- /* Don't add it if the link count is 1 because such an object can only
- * have one name. */
- if(oi->rc < 2)
- return;
-
- /* Extend the table */
- if(idtab_g.nobjs >= idtab_g.nalloc) {
- idtab_g.nalloc = MAX(256, 2*idtab_g.nalloc);
- idtab_g.obj = realloc(idtab_g.obj, idtab_g.nalloc*sizeof(idtab_g.obj[0]));
- } /* end if */
-
- /* Insert the entry */
- n = idtab_g.nobjs++;
- idtab_g.obj[n].id = oi->addr;
- idtab_g.obj[n].name = HDstrdup(name);
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: sym_lookup
- *
- * Purpose: Find another name for the specified object.
- *
- * Return: Success: Ptr to another name.
- *
- * Failure: NULL
- *
- * Programmer: Robb Matzke
- * Thursday, January 21, 1999
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static char *
-sym_lookup(const H5O_info_t *oi)
-{
- int n;
-
- /*only one name possible*/
- if(oi->rc < 2)
- return NULL;
-
- for(n = 0; n < idtab_g.nobjs; n++)
- if(idtab_g.obj[n].id == oi->addr)
- return idtab_g.obj[n].name;
-
- return NULL;
-}
-
-
-/*-------------------------------------------------------------------------
* Function: display_string
*
* Purpose: Print a string value by escaping unusual characters. If
@@ -278,6 +199,55 @@ display_string(FILE *stream, const char *s, hbool_t escape_spaces)
/*-------------------------------------------------------------------------
+ * Function: display_obj_name
+ *
+ * Purpose: Print an object name and another string.
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE, nothing printed
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 6, 2007
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+display_obj_name(FILE *stream, const iter_t *iter, const char *oname,
+ const char *s)
+{
+ static char fullname[NAME_BUF_SIZE]; /* Buffer for file and/or object name */
+ const char *name = fullname; /* Pointer to buffer for printing */
+ int n;
+
+ if(show_file_name_g)
+ sprintf(fullname, "%s/%s", iter->fname, oname);
+ else
+ name = oname;
+
+ /* Print the object name, either full name or base name */
+ if(fullname_g)
+ n = display_string(stream, name, TRUE);
+ else {
+ const char *last_sep; /* The location of the last group separator */
+
+ /* Find the last component of the path name */
+ if(NULL == (last_sep = HDstrrchr(name, '/')))
+ last_sep = name;
+ else {
+ last_sep++;
+ } /* end else */
+ n = display_string(stream, last_sep, TRUE);
+ } /* end else */
+ printf("%*s ", MAX(0, (24 - n)), s);
+
+ return TRUE;
+}
+
+
+/*-------------------------------------------------------------------------
* Function: display_native_type
*
* Purpose: Prints the name of a native C data type.
@@ -1326,7 +1296,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
void UNUSED *op_data)
{
hid_t attr, space, type, p_type;
- hsize_t size[64], nelmts = 1;
+ hsize_t size[H5S_MAX_RANK], nelmts = 1;
int ndims, i, n;
size_t need;
hsize_t temp_need;
@@ -1460,8 +1430,8 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
static herr_t
dataset_list1(hid_t dset)
{
- hsize_t cur_size[64]; /* current dataset dimensions */
- hsize_t max_size[64]; /* maximum dataset dimensions */
+ hsize_t cur_size[H5S_MAX_RANK]; /* current dataset dimensions */
+ hsize_t max_size[H5S_MAX_RANK]; /* maximum dataset dimensions */
hid_t space; /* data space */
int ndims; /* dimensionality */
H5S_class_t space_type; /* type of dataspace */
@@ -1524,7 +1494,6 @@ dataset_list2(hid_t dset, const char UNUSED *name)
off_t f_offset; /* offset in external file */
hsize_t f_size; /* bytes used in external file */
hsize_t total, used; /* total size or offset */
- hsize_t chsize[64]; /* chunk size in elements */
int ndims; /* dimensionality */
int n, max_len; /* max extern file name length */
double utilization; /* percent utilization of storage */
@@ -1537,6 +1506,8 @@ dataset_list2(hid_t dset, const char UNUSED *name)
/* Print information about chunked storage */
if (H5D_CHUNKED==H5Pget_layout(dcpl)) {
+ hsize_t chsize[64]; /* chunk size in elements */
+
ndims = H5Pget_chunk(dcpl, NELMTS(chsize), chsize/*out*/);
printf(" %-10s {", "Chunks:");
total = H5Tget_size(type);
@@ -1645,39 +1616,9 @@ dataset_list2(hid_t dset, const char UNUSED *name)
/*-------------------------------------------------------------------------
- * Function: group_list2
- *
- * Purpose: List information about a group which should appear after
- * information which is general to all objects.
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Thursday, January 21, 1999
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-group_list2(hid_t grp, const char *name)
-{
- iter_t iter;
-
- if (recursive_g) {
- iter.container = name;
- H5Literate(grp, H5_INDEX_NAME, H5_ITER_INC, NULL, list, &iter);
- }
- return 0;
-}
-
-
-/*-------------------------------------------------------------------------
* Function: datatype_list2
*
- * Purpose: List information about a data type which should appear after
+ * Purpose: List information about a datatype which should appear after
* information which is general to all objects.
*
* Return: Success: 0
@@ -1704,80 +1645,56 @@ datatype_list2(hid_t type, const char UNUSED *name)
/*-------------------------------------------------------------------------
- * Function: list
+ * Function: list_obj
*
- * Purpose: Prints the group member name.
+ * Purpose: Prints information about an object
*
* Return: Success: 0
*
* Failure: -1
*
- * Programmer: Robb Matzke
- * Monday, March 23, 1998
+ * Programmer: Quincey Koziol
+ * Tuesday, November 6, 2007
*
- * Modifications:
- * Robb Matzke, LLNL, 2003-06-06
- * If simple_output_g (set by `--simple') is turned on then
- * the modification time is printed as UTC instead of the
- * local timezone.
*-------------------------------------------------------------------------
*/
static herr_t
-list(hid_t group, const char *name, const H5L_info_t *linfo, void *_iter)
+list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void *_iter)
{
+ H5O_type_t obj_type = oinfo->type; /* Type of the object */
iter_t *iter = (iter_t*)_iter;
- char *fullname = NULL;
- int n;
- /* Print the object name, either full name or base name */
- fullname = fix_name(iter->container, name);
- if(fullname_g)
- n = display_string(stdout, fullname, TRUE);
- else
- n = display_string(stdout, name, TRUE);
- printf("%*s ", MAX(0, (24 - n)), "");
-
- /* Actions on objects */
- if(linfo->type == H5L_TYPE_HARD) {
- H5O_info_t oi;
- char *s;
- hid_t obj;
-
- /* Get object information */
- if(H5Oget_info_by_name(group, name, &oi, H5P_DEFAULT) < 0) {
- puts("**NOT FOUND**");
- return 0;
- } else if(oi.type < 0 || oi.type >= H5O_TYPE_NTYPES) {
- printf("Unknown type(%d)", (int)oi.type);
- oi.type = H5O_TYPE_UNKNOWN;
- }
- if(oi.type >= 0 && dispatch_g[oi.type].name)
- fputs(dispatch_g[oi.type].name, stdout);
-
- /* If the object has already been printed then just show the object ID
- * and return. */
- if((s = sym_lookup(&oi))) {
- printf(", same as ");
- display_string(stdout, s, TRUE);
- printf("\n");
- goto done;
- } /* end if */
- else
- sym_insert(&oi, fullname);
+ /* Print the link's name, either full name or base name */
+ display_obj_name(stdout, iter, name, "");
+
+ /* Check object information */
+ if(oinfo->type < 0 || oinfo->type >= H5O_TYPE_NTYPES) {
+ printf("Unknown type(%d)", (int)oinfo->type);
+ obj_type = H5O_TYPE_UNKNOWN;
+ }
+ if(obj_type >= 0 && dispatch_g[obj_type].name)
+ fputs(dispatch_g[obj_type].name, stdout);
+
+ /* Check if we've seen this object before */
+ if(first_seen) {
+ printf(", same as ");
+ display_string(stdout, first_seen, TRUE);
+ printf("\n");
+ } /* end if */
+ else {
+ hid_t obj = (-1); /* ID of object opened */
/* Open the object. Not all objects can be opened. If this is the case
* then return right away.
*/
- if(oi.type >= 0 &&
- (NULL == dispatch_g[oi.type].open ||
- (obj = (dispatch_g[oi.type].open)(group, name, H5P_DEFAULT)) < 0)) {
+ if(obj_type >= 0 && (obj = H5Oopen(iter->fid, name, H5P_DEFAULT)) < 0) {
printf(" *ERROR*\n");
goto done;
} /* end if */
/* List the first line of information for the object. */
- if(oi.type >= 0 && dispatch_g[oi.type].list1)
- (dispatch_g[oi.type].list1)(obj);
+ if(obj_type >= 0 && dispatch_g[obj_type].list1)
+ (dispatch_g[obj_type].list1)(obj);
putchar('\n');
/* Show detailed information about the object, beginning with information
@@ -1786,22 +1703,22 @@ list(hid_t group, const char *name, const H5L_info_t *linfo, void *_iter)
char comment[50];
/* Display attributes */
- if(oi.type >= 0)
+ if(obj_type >= 0)
H5Aiterate2(obj, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL);
/* Object location & reference count */
- printf(" %-10s %lu:"H5_PRINTF_HADDR_FMT"\n", "Location:", oi.fileno, oi.addr);
- printf(" %-10s %u\n", "Links:", (unsigned)oi.rc);
+ printf(" %-10s %lu:"H5_PRINTF_HADDR_FMT"\n", "Location:", oinfo->fileno, oinfo->addr);
+ printf(" %-10s %u\n", "Links:", (unsigned)oinfo->rc);
/* Modification time */
- if(oi.mtime > 0) {
+ if(oinfo->mtime > 0) {
char buf[256];
struct tm *tm;
if(simple_output_g)
- tm = HDgmtime(&(oi.mtime));
+ tm = HDgmtime(&(oinfo->mtime));
else
- tm = HDlocaltime(&(oi.mtime));
+ tm = HDlocaltime(&(oinfo->mtime));
if(tm) {
HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm);
printf(" %-10s %s\n", "Modified:", buf);
@@ -1810,7 +1727,7 @@ list(hid_t group, const char *name, const H5L_info_t *linfo, void *_iter)
/* Object comment */
comment[0] = '\0';
- H5Oget_comment_by_name(group, name, comment, sizeof(comment), H5P_DEFAULT);
+ H5Oget_comment(obj, comment, sizeof(comment));
HDstrcpy(comment + sizeof(comment) - 4, "...");
if(comment[0]) {
printf(" %-10s \"", "Comment:");
@@ -1820,118 +1737,91 @@ list(hid_t group, const char *name, const H5L_info_t *linfo, void *_iter)
} /* end if */
/* Detailed list for object */
- if(oi.type >= 0 && dispatch_g[oi.type].list2)
- (dispatch_g[oi.type].list2)(obj, fullname);
+ if(obj_type >= 0 && dispatch_g[obj_type].list2)
+ (dispatch_g[obj_type].list2)(obj, name);
/* Close the object. */
- if(oi.type >= 0 && dispatch_g[oi.type].close)
- (dispatch_g[oi.type].close)(obj);
- } /* end if */
- /* Actions on links */
- else {
- char *buf;
-
- HDfputs("-> ", stdout);
- switch(linfo->type) {
- case H5L_TYPE_SOFT:
- if((buf = HDmalloc(linfo->u.val_size)) == NULL)
- goto done;
-
- if(H5Lget_val(group, name, buf, linfo->u.val_size, H5P_DEFAULT) < 0) {
- HDfree(buf);
- goto done;
- } /* end if */
-
- HDfputs(buf, stdout);
- HDfree(buf);
- break;
-
- case H5L_TYPE_EXTERNAL:
- {
- const char *filename;
- const char *path;
-
- if((buf = HDmalloc(linfo->u.val_size)) == NULL)
- goto done;
-
- if(H5Lget_val(group, name, buf, linfo->u.val_size, H5P_DEFAULT) < 0) {
- HDfree(buf);
- goto done;
- } /* end if */
- if(H5Lunpack_elink_val(buf, linfo->u.val_size, NULL, &filename, &path) < 0) {
- HDfree(buf);
- goto done;
- } /* end if */
-
- HDfputs("file: ", stdout);
- HDfputs(filename, stdout);
- HDfputs(" path: ", stdout);
- HDfputs(path, stdout);
- }
- break;
-
- default:
- HDfputs("cannot follow UD links", stdout);
- break;
- } /* end switch */
- HDfputc('\n', stdout);
+ if(obj_type >= 0)
+ H5Oclose(obj);
} /* end else */
done:
- if(fullname)
- free(fullname);
return 0;
-} /* end list() */
+} /* end list_obj() */
/*-------------------------------------------------------------------------
- * Function: fix_name
+ * Function: list_lnk
*
- * Purpose: Returns a malloc'd buffer that contains the PATH and BASE
- * names separated by a single slash. It also removes duplicate
- * and trailing slashes.
+ * Purpose: Prints information about a link
*
- * Return: Success: Ptr to fixed name from malloc()
- *
- * Failure: NULL
+ * Return: Success: 0
*
- * Programmer: Robb Matzke
- * Thursday, January 21, 1999
+ * Failure: -1
*
- * Modifications:
+ * Programmer: Quincey Koziol
+ * Thursday, November 8, 2007
*
*-------------------------------------------------------------------------
*/
-static char *
-fix_name(const char *path, const char *base)
+static herr_t
+list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
{
- size_t n = (path ? HDstrlen(path) : 0) + (base ? HDstrlen(base) : 0) + 3;
- char *s = HDmalloc(n), prev='\0';
- size_t len = 0;
-
- if (path) {
- /* Path, followed by slash */
- for (/*void*/; *path; path++)
- if ('/'!=*path || '/'!=prev)
- prev = s[len++] = *path;
- if ('/' != prev)
- prev = s[len++] = '/';
- }
+ char *buf;
+ iter_t *iter = (iter_t*)_iter;
- if (base) {
- /* Base name w/o trailing slashes */
- const char *end = base + HDstrlen(base);
- while (end > base && '/' == end[-1])
- --end;
+ /* Print the link's name, either full name or base name */
+ display_obj_name(stdout, iter, name, "");
- for (/*void*/; base < end; base++)
- if ('/' != *base || '/' != prev)
- prev = s[len++] = *base;
- }
+ HDfputs("-> ", stdout);
+ switch(linfo->type) {
+ case H5L_TYPE_SOFT:
+ if((buf = HDmalloc(linfo->u.val_size)) == NULL)
+ goto done;
- s[len] = '\0';
- return s;
-}
+ if(H5Lget_val(iter->fid, name, buf, linfo->u.val_size, H5P_DEFAULT) < 0) {
+ HDfree(buf);
+ goto done;
+ } /* end if */
+
+ HDfputs(buf, stdout);
+ HDfree(buf);
+ break;
+
+ case H5L_TYPE_EXTERNAL:
+ {
+ const char *filename;
+ const char *path;
+
+ if((buf = HDmalloc(linfo->u.val_size)) == NULL)
+ goto done;
+
+ if(H5Lget_val(iter->fid, name, buf, linfo->u.val_size, H5P_DEFAULT) < 0) {
+ HDfree(buf);
+ goto done;
+ } /* end if */
+ if(H5Lunpack_elink_val(buf, linfo->u.val_size, NULL, &filename, &path) < 0) {
+ HDfree(buf);
+ goto done;
+ } /* end if */
+
+ HDfputs("file: ", stdout);
+ HDfputs(filename, stdout);
+ HDfputs(" path: ", stdout);
+ HDfputs(path, stdout);
+ HDfree(buf);
+ }
+ break;
+
+ default:
+ HDfputs("cannot follow UD links", stdout);
+ break;
+ } /* end switch */
+ HDfputc('\n', stdout);
+
+done:
+ return 0;
+} /* end list_lnk() */
/*-------------------------------------------------------------------------
@@ -2059,10 +1949,10 @@ leave(int ret)
int
main(int argc, const char *argv[])
{
- hid_t file = -1, root = -1;
+ hid_t file = -1;
char *fname = NULL, *oname = NULL, *x;
const char *s = NULL;
- char *rest, *container = NULL;
+ char *rest;
int argno;
static char root_name[] = "/";
char drivername[50];
@@ -2072,9 +1962,9 @@ main(int argc, const char *argv[])
h5tools_init();
/* Build object display table */
- DISPATCH(H5O_TYPE_GROUP, "Group", H5Gopen2, H5Gclose, NULL, group_list2);
- DISPATCH(H5O_TYPE_DATASET, "Dataset", H5Dopen2, H5Dclose, dataset_list1, dataset_list2);
- DISPATCH(H5O_TYPE_NAMED_DATATYPE, "Type", H5Topen2, H5Tclose, NULL, datatype_list2);
+ DISPATCH(H5O_TYPE_GROUP, "Group", NULL, NULL);
+ DISPATCH(H5O_TYPE_DATASET, "Dataset", dataset_list1, dataset_list2);
+ DISPATCH(H5O_TYPE_NAMED_DATATYPE, "Type", NULL, datatype_list2);
/* Default output width */
width_g = get_width();
@@ -2230,6 +2120,13 @@ main(int argc, const char *argv[])
leave(1);
} /* end if */
+ /* Check for conflicting arguments */
+ if(recursive_g && grp_literal_g) {
+ fprintf(stderr, "Error: 'recursive' option not compatible with 'group info' option!\n\n");
+ usage();
+ leave(1);
+ } /* end if */
+
/* Turn off HDF5's automatic error printing unless you're debugging h5ls */
if(!show_errors_g)
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
@@ -2249,7 +2146,6 @@ main(int argc, const char *argv[])
* doesn't exist). */
show_file_name_g = (argc-argno > 1); /*show file names if more than one*/
while(argno < argc) {
- H5O_info_t oi;
H5L_info_t li;
iter_t iter;
@@ -2281,24 +2177,21 @@ main(int argc, const char *argv[])
} /* end if */
if(oname)
oname++;
- if(!oname || !*oname)
+ if(!oname || !*oname) {
oname = root_name;
+ if(recursive_g)
+ display_root_g = TRUE;
+ } /* end if */
+
+ /* Remember the file information for later */
+ iter.fname = fname;
+ iter.fid = file;
/* Check for root group as object name */
if(HDstrcmp(oname, root_name)) {
/* Check the type of link given */
if(H5Lget_info(file, oname, &li, H5P_DEFAULT) < 0) {
- char *fullname = NULL;
- int n;
-
- fullname = fix_name(oname, "/");
- if(fullname_g)
- n = display_string(stdout, fullname, TRUE);
- else
- n = display_string(stdout, oname, TRUE);
- printf("%*s \n", MAX(0, (24 - n)), "**NOT FOUND**");
-
- HDfree(fullname);
+ display_obj_name(stdout, &iter, oname, "**NOT FOUND**");
leave(1);
} /* end if */
} /* end if */
@@ -2306,34 +2199,25 @@ main(int argc, const char *argv[])
li.type = H5L_TYPE_HARD;
/* Open the object and display it's information */
- if(li.type == H5L_TYPE_HARD && H5Oget_info_by_name(file, oname, &oi, H5P_DEFAULT) >= 0 && H5O_TYPE_GROUP == oi.type && !grp_literal_g) {
- /* Specified name is a group. List the complete contents of the group. */
- sym_insert(&oi, oname);
- iter.container = container = fix_name((show_file_name_g ? fname : ""), oname);
-
- /* list root attributes */
- if(verbose_g > 0) {
- if((root = H5Gopen2(file, "/", H5P_DEFAULT)) < 0)
- leave(1);
- H5Aiterate2(root, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL);
- if(H5Gclose(root) < 0)
- leave(1);
- } /* end if */
+ if(li.type == H5L_TYPE_HARD) {
+ H5O_info_t oi; /* Information for object */
- /* list */
- H5Literate_by_name(file, oname, H5_INDEX_NAME, H5_ITER_INC, NULL, list, &iter, H5P_DEFAULT);
- free(container);
- } else if((root = H5Gopen2(file, "/", H5P_DEFAULT)) < 0) {
- leave(1); /*major problem!*/
- } else {
- /* Specified name is a non-group object -- list that object. The
- * container for the object is everything up to the base name.
- */
- iter.container = show_file_name_g ? fname : "/";
- list(root, oname, &li, &iter);
- if(H5Gclose(root) < 0)
+ /* Retrieve info for object to list */
+ if(H5Oget_info_by_name(file, oname, &oi, H5P_DEFAULT) < 0) {
+ display_obj_name(stdout, &iter, oname, "**NOT FOUND**");
leave(1);
- }
+ } /* end if */
+
+ /* Check for group iteration */
+ if(H5O_TYPE_GROUP == oi.type && !grp_literal_g)
+ /* Specified name is a group. List the complete contents of the group. */
+ h5trav_visit(file, oname, display_root_g, recursive_g, list_obj, list_lnk, &iter);
+ else
+ /* Specified name is a non-group object -- list that object */
+ list_obj(oname, &oi, NULL, &iter);
+ } else
+ /* Specified name is not for object -- list that link */
+ list_lnk(oname, &li, &iter);
H5Fclose(file);
free(fname);
} /* end while */
diff --git a/tools/h5ls/testh5ls.sh b/tools/h5ls/testh5ls.sh
index ab36eb4..cef5730 100755
--- a/tools/h5ls/testh5ls.sh
+++ b/tools/h5ls/testh5ls.sh
@@ -49,6 +49,9 @@ TESTING() {
TOOLTEST() {
expect="$srcdir/../testfiles/$1"
actual="../testfiles/`basename $1 .ls`.out"
+ actual_err="../testfiles/`basename $1 .ls`.err"
+ shift
+ retvalexpect=$1
shift
# Run test.
@@ -61,10 +64,11 @@ TOOLTEST() {
echo "#############################"
cd $srcdir/../testfiles
$RUNSERIAL $H5LS_BIN "$@"
- ) 2>&1 |sed 's/Modified:.*/Modified: XXXX-XX-XX XX:XX:XX XXX/' >$actual
+ ) >$actual 2>$actual_err
exitcode=$?
- if [ $exitcode -ne 0 ]; then
+ cat $actual_err >> $actual
+ if [ $exitcode -ne $retvalexpect ]; then
echo "*FAILED*"
nerrors="`expr $nerrors + 1`"
if [ yes = "$verbose" ]; then
@@ -89,7 +93,7 @@ TOOLTEST() {
# Clean up output file
if test -z "$HDF5_NOCLEANUP"; then
- rm -f $actual
+ rm -f $actual $actual_err
fi
}
@@ -101,62 +105,65 @@ TOOLTEST() {
# Toss in a bunch of tests. Not sure if they are the right kinds.
# test the help syntax
-TOOLTEST help-1.ls -w80 -h
-TOOLTEST help-2.ls -w80 -help
-TOOLTEST help-3.ls -w80 -?
+TOOLTEST help-1.ls 0 -w80 -h
+TOOLTEST help-2.ls 0 -w80 -help
+TOOLTEST help-3.ls 0 -w80 -?
# test simple command
-TOOLTEST tall-1.ls -w80 tall.h5
-TOOLTEST tall-2.ls -w80 -r -d tall.h5
-TOOLTEST tgroup.ls -w80 tgroup.h5
+TOOLTEST tall-1.ls 0 -w80 tall.h5
+TOOLTEST tall-2.ls 0 -w80 -r -d tall.h5
+TOOLTEST tgroup.ls 0 -w80 tgroup.h5
# test for displaying groups
-TOOLTEST tgroup-1.ls -w80 -r -g tgroup.h5
+# The following combination of arguments is expected to return an error message
+# and return value 1
+TOOLTEST tgroup-1.ls 1 -w80 -r -g tgroup.h5
+TOOLTEST tgroup-2.ls 0 -w80 -g tgroup.h5/g1
# test for displaying simple space datasets
-TOOLTEST tdset-1.ls -w80 -r -d tdset.h5
+TOOLTEST tdset-1.ls 0 -w80 -r -d tdset.h5
# test for displaying soft links
-TOOLTEST tslink-1.ls -w80 -r tslink.h5
+TOOLTEST tslink-1.ls 0 -w80 -r tslink.h5
# test for displaying external and user-defined links
-TOOLTEST textlink-1.ls -w80 -r textlink.h5
-TOOLTEST tudlink-1.ls -w80 -r tudlink.h5
+TOOLTEST textlink-1.ls 0 -w80 -r textlink.h5
+TOOLTEST tudlink-1.ls 0 -w80 -r tudlink.h5
# tests for hard links
-TOOLTEST thlink-1.ls -w80 thlink.h5
+TOOLTEST thlink-1.ls 0 -w80 thlink.h5
# tests for compound data types
-TOOLTEST tcomp-1.ls -w80 -r -d tcompound.h5
+TOOLTEST tcomp-1.ls 0 -w80 -r -d tcompound.h5
#test for the nested compound type
-TOOLTEST tnestcomp-1.ls -w80 -r -d tnestedcomp.h5
+TOOLTEST tnestcomp-1.ls 0 -w80 -r -d tnestedcomp.h5
# test for loop detection
-TOOLTEST tloop-1.ls -w80 -r -d tloop.h5
+TOOLTEST tloop-1.ls 0 -w80 -r -d tloop.h5
# test for string
-TOOLTEST tstr-1.ls -w80 -r -d tstr.h5
+TOOLTEST tstr-1.ls 0 -w80 -r -d tstr.h5
# test test file created from lib SAF team
-TOOLTEST tsaf.ls -w80 -r -d tsaf.h5
+TOOLTEST tsaf.ls 0 -w80 -r -d tsaf.h5
# test for variable length data types
-TOOLTEST tvldtypes1.ls -w80 -r -d tvldtypes1.h5
+TOOLTEST tvldtypes1.ls 0 -w80 -r -d tvldtypes1.h5
# test for array data types
-TOOLTEST tarray1.ls -w80 -r -d tarray1.h5
+TOOLTEST tarray1.ls 0 -w80 -r -d tarray1.h5
# test for empty data
-TOOLTEST tempty.ls -w80 -d tempty.h5
+TOOLTEST tempty.ls 0 -w80 -d tempty.h5
# test for all dataset types written to attributes
# enable -S for avoiding printing NATIVE types
-TOOLTEST tattr2.ls -w80 -v -S tattr2.h5
+TOOLTEST tattr2.ls 0 -w80 -v -S tattr2.h5
# tests for error handling.
# test for non-existing file
-TOOLTEST nosuchfile.ls nosuchfile.h5
+TOOLTEST nosuchfile.ls 0 nosuchfile.h5
if test $nerrors -eq 0 ; then
echo "All h5ls tests passed."
diff --git a/tools/h5recover/Makefile.in b/tools/h5recover/Makefile.in
index 201ef85..74ce765 100644
--- a/tools/h5recover/Makefile.in
+++ b/tools/h5recover/Makefile.in
@@ -216,6 +216,7 @@ SET_MAKE = @SET_MAKE@
SHELL = /bin/sh
SIZE_T = @SIZE_T@
STATIC_SHARED = @STATIC_SHARED@
+STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
TESTPARALLEL = @TESTPARALLEL@
TIME = @TIME@
diff --git a/tools/h5recover/enable_journaling.c b/tools/h5recover/enable_journaling.c
index 84df3af..e4cd442 100755
--- a/tools/h5recover/enable_journaling.c
+++ b/tools/h5recover/enable_journaling.c
@@ -159,11 +159,11 @@ main (int ac, char **av)
H5Pclose(faccpl);
}
- dataset=H5Dopen(file, DATASETNAME, H5P_DEFAULT);
+ dataset=H5Dopen2(file, DATASETNAME, H5P_DEFAULT);
/* extend the dataset to 2NX rows. */
dimsf[0] = 2*NX;
dimsf[1] = NY;
- H5Dextend(dataset, dimsf);
+ H5Dset_extent(dataset, dimsf);
if (!pmode){
/* write data to new rows and crash */
diff --git a/tools/h5recover/h5recover.c b/tools/h5recover/h5recover.c
index 2b037be..0dfb421 100644
--- a/tools/h5recover/h5recover.c
+++ b/tools/h5recover/h5recover.c
@@ -621,7 +621,7 @@ main (int argc, const char *argv[])
pread(hdf5_fd, compare_buf, size, address);
/* do a quick string compare on two items */
- if (HDstrcmp(body, compare_buf) != 0) {
+ if (HDstrcmp((const char *)body, (const char *)compare_buf) != 0) {
error_msg(progname, "Entry incorrectly written into HDF5 file. Exiting.\n");
printf("Address %llx:\n", address);
printf(" -- from journal: %llx\n", body);
@@ -706,7 +706,7 @@ main (int argc, const char *argv[])
} /* end if */
/* obtain H5F_t pointer */
- if ((f = H5I_object(fid)) == -1) {
+ if (NULL == (f = H5I_object(fid))) {
error_msg(progname, "Could not obtain H5F_t pointer from file id");
leave( EXIT_FAILURE );
diff --git a/tools/h5repack/Makefile.am b/tools/h5repack/Makefile.am
index e053e83..f677de0 100644
--- a/tools/h5repack/Makefile.am
+++ b/tools/h5repack/Makefile.am
@@ -41,8 +41,8 @@ LDADD=$(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5)
# Source files
COMMON_SOURCES=h5repack.c h5repack_copy.c h5repack_filters.c \
- h5repack_list.c h5repack_opttable.c h5repack_parse.c h5repack_refs.c \
- h5repack_verify.c
+ h5repack_opttable.c h5repack_parse.c h5repack_refs.c \
+ h5repack_verify.c
h5repack_SOURCES=$(COMMON_SOURCES) h5repack_main.c
diff --git a/tools/h5repack/Makefile.in b/tools/h5repack/Makefile.in
index 1823f8b..97d3620 100644
--- a/tools/h5repack/Makefile.in
+++ b/tools/h5repack/Makefile.in
@@ -69,9 +69,9 @@ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
am__EXEEXT_1 = h5repacktst$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
am__objects_1 = h5repack.$(OBJEXT) h5repack_copy.$(OBJEXT) \
- h5repack_filters.$(OBJEXT) h5repack_list.$(OBJEXT) \
- h5repack_opttable.$(OBJEXT) h5repack_parse.$(OBJEXT) \
- h5repack_refs.$(OBJEXT) h5repack_verify.$(OBJEXT)
+ h5repack_filters.$(OBJEXT) h5repack_opttable.$(OBJEXT) \
+ h5repack_parse.$(OBJEXT) h5repack_refs.$(OBJEXT) \
+ h5repack_verify.$(OBJEXT)
am_h5repack_OBJECTS = $(am__objects_1) h5repack_main.$(OBJEXT)
h5repack_OBJECTS = $(am_h5repack_OBJECTS)
h5repack_LDADD = $(LDADD)
@@ -224,6 +224,7 @@ SET_MAKE = @SET_MAKE@
SHELL = /bin/sh
SIZE_T = @SIZE_T@
STATIC_SHARED = @STATIC_SHARED@
+STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
TESTPARALLEL = @TESTPARALLEL@
TIME = @TIME@
@@ -351,8 +352,8 @@ LDADD = $(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5)
# Source files
COMMON_SOURCES = h5repack.c h5repack_copy.c h5repack_filters.c \
- h5repack_list.c h5repack_opttable.c h5repack_parse.c h5repack_refs.c \
- h5repack_verify.c
+ h5repack_opttable.c h5repack_parse.c h5repack_refs.c \
+ h5repack_verify.c
h5repack_SOURCES = $(COMMON_SOURCES) h5repack_main.c
h5repacktst_SOURCES = $(COMMON_SOURCES) h5repacktst.c
@@ -470,7 +471,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repack.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repack_copy.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repack_filters.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repack_list.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repack_main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repack_opttable.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repack_parse.Po@am__quote@
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c
index 45409c4..954f3e7 100644
--- a/tools/h5repack/h5repack.c
+++ b/tools/h5repack/h5repack.c
@@ -15,9 +15,14 @@
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
+
+#include "H5private.h"
#include "h5repack.h"
+#include "h5tools.h"
#include "h5tools_utils.h"
+
extern char *progname;
@@ -28,25 +33,11 @@ extern char *progname;
*/
static int check_options(pack_opt_t *options);
+static int check_objects(const char* fname, pack_opt_t *options);
+static const char* get_sfilter (H5Z_filter_t filtn);
+static int have_request(pack_opt_t *options);
-/*-------------------------------------------------------------------------
- * Function: aux_initglb_filter
- *
- * Purpose: auxiliary function, initialize the options global filter
- *
- * Return: void
- *
- *-------------------------------------------------------------------------
- */
-static void aux_initglb_filter(pack_opt_t *options)
-{
- int k;
- options->filter_g.filtn = -1;
- for ( k=0; k<CDVALUES; k++)
- options->filter_g.cd_values[k] = -1;
-}
-
/*-------------------------------------------------------------------------
* Function: h5repack
@@ -71,20 +62,20 @@ int h5repack(const char* infile,
const char* outfile,
pack_opt_t *options)
{
- /* check input */
- if (check_options(options)<0)
- return -1;
-
- /* check for objects in input that are in the file */
- if (check_objects(infile,options) < 0)
- return -1;
-
- /* copy the objects */
- if (copy_objects(infile,outfile,options) < 0)
- return -1;
-
-
- return 0;
+ /* check input */
+ if (check_options(options)<0)
+ return -1;
+
+ /* check for objects in input that are in the file */
+ if (check_objects(infile,options) < 0)
+ return -1;
+
+ /* copy the objects */
+ if (copy_objects(infile,outfile,options) < 0)
+ return -1;
+
+
+ return 0;
}
@@ -102,10 +93,20 @@ int h5repack(const char* infile,
int h5repack_init (pack_opt_t *options,
int verbose)
{
- memset(options,0,sizeof(pack_opt_t));
- options->threshold = 1024;
- options->verbose = verbose;
- return (options_table_init(&(options->op_tbl)));
+ int k, n;
+ memset(options,0,sizeof(pack_opt_t));
+ options->threshold = 1024;
+ options->verbose = verbose;
+
+ for ( n = 0; n < H5_REPACK_MAX_NFILTERS; n++)
+ {
+ options->filter_g[n].filtn = -1;
+ options->filter_g[n].cd_nelmts = -1;
+ for ( k = 0; k < CD_VALUES; k++)
+ options->filter_g[n].cd_values[k] = -1;
+ }
+
+ return (options_table_init(&(options->op_tbl)));
}
/*-------------------------------------------------------------------------
@@ -118,7 +119,7 @@ int h5repack_init (pack_opt_t *options,
int h5repack_end (pack_opt_t *options)
{
- return options_table_free(options->op_tbl);
+ return options_table_free(options->op_tbl);
}
/*-------------------------------------------------------------------------
@@ -135,35 +136,43 @@ int h5repack_end (pack_opt_t *options)
int h5repack_addfilter(const char* str,
pack_opt_t *options)
{
- obj_list_t *obj_list=NULL; /*one object list for the -f and -c option entry */
- filter_info_t filt; /*filter info for the current -f option entry */
- int n_objs; /*number of objects in the current -f or -c option entry */
-
- if (options->all_filter==1){
- error_msg(progname, "invalid compression input: 'all' option is present \
- with other objects <%s>\n",str);
- return -1;
- }
-
- /* parse the -f option */
- obj_list=parse_filter(str,&n_objs,&filt,options);
- if (obj_list==NULL)
- {
- return -1;
- }
-
- if (options->all_filter==1)
- {
- /* if we are compressing all set the global filter type */
- aux_initglb_filter(options);
- options->filter_g=filt;
- }
-
- if (options->all_filter==0)
- options_add_filter(obj_list,n_objs,filt,options->op_tbl);
-
- free(obj_list);
- return 0;
+ obj_list_t *obj_list=NULL; /* one object list for the -f and -l option entry */
+ filter_info_t filter; /* filter info for the current -f option entry */
+ int n_objs; /* number of objects in the current -f or -l option entry */
+ int is_glb; /* is the filter global */
+
+
+
+ /* parse the -f option */
+ obj_list=parse_filter(str,&n_objs,&filter,options,&is_glb);
+ if (obj_list==NULL)
+ {
+ return -1;
+ }
+
+ /* if it applies to all objects */
+ if (is_glb)
+ {
+
+ int n;
+
+ n = options->n_filter_g++; /* increase # of global filters */
+
+ if (options->n_filter_g > H5_REPACK_MAX_NFILTERS)
+ {
+ error_msg(progname, "maximum number of filters exceeded for <%s>\n",str);
+ return -1;
+
+ }
+
+ options->filter_g[n] = filter;
+ }
+
+ else
+ options_add_filter(obj_list,n_objs,filter,options->op_tbl);
+
+ free(obj_list);
+ return 0;
}
@@ -181,55 +190,55 @@ int h5repack_addfilter(const char* str,
int h5repack_addlayout(const char* str,
pack_opt_t *options)
{
-
- obj_list_t *obj_list=NULL; /*one object list for the -t and -c option entry */
- int n_objs; /*number of objects in the current -t or -c option entry */
- pack_info_t pack; /*info about layout to extract from parse */
- int j;
-
- init_packobject(&pack);
-
- if (options->all_layout==1){
- error_msg(progname, "invalid layout input: 'all' option \
- is present with other objects <%s>\n",str);
- return -1;
- }
-
- /* parse the layout option */
- obj_list=parse_layout(str,&n_objs,&pack,options);
- if (obj_list==NULL)
- return -1;
-
- /* set global layout option */
- if (options->all_layout==1 )
- {
- options->layout_g=pack.layout;
- if (pack.layout==H5D_CHUNKED)
- {
- /* -2 means the NONE option, remove chunking
- and set the global layout to contiguous */
- if (pack.chunk.rank==-2)
- {
- options->layout_g = H5D_CONTIGUOUS;
- }
- /* otherwise set the global chunking type */
- else
- {
- options->chunk_g.rank=pack.chunk.rank;
- for (j = 0; j < pack.chunk.rank; j++)
- options->chunk_g.chunk_lengths[j] = pack.chunk.chunk_lengths[j];
- }
- }
- }
-
- if (options->all_layout==0)
- options_add_layout(obj_list,
- n_objs,
- &pack,
- options->op_tbl);
-
- free(obj_list);
- return 0;
+
+ obj_list_t *obj_list=NULL; /*one object list for the -t and -c option entry */
+ int n_objs; /*number of objects in the current -t or -c option entry */
+ pack_info_t pack; /*info about layout to extract from parse */
+ int j;
+
+ init_packobject(&pack);
+
+ if (options->all_layout==1){
+ error_msg(progname, "invalid layout input: 'all' option \
+ is present with other objects <%s>\n",str);
+ return -1;
+ }
+
+ /* parse the layout option */
+ obj_list=parse_layout(str,&n_objs,&pack,options);
+ if (obj_list==NULL)
+ return -1;
+
+ /* set global layout option */
+ if (options->all_layout==1 )
+ {
+ options->layout_g=pack.layout;
+ if (pack.layout==H5D_CHUNKED)
+ {
+ /* -2 means the NONE option, remove chunking
+ and set the global layout to contiguous */
+ if (pack.chunk.rank==-2)
+ {
+ options->layout_g = H5D_CONTIGUOUS;
+ }
+ /* otherwise set the global chunking type */
+ else
+ {
+ options->chunk_g.rank=pack.chunk.rank;
+ for (j = 0; j < pack.chunk.rank; j++)
+ options->chunk_g.chunk_lengths[j] = pack.chunk.chunk_lengths[j];
+ }
+ }
+ }
+
+ if (options->all_layout==0)
+ options_add_layout(obj_list,
+ n_objs,
+ &pack,
+ options->op_tbl);
+
+ free(obj_list);
+ return 0;
}
@@ -252,270 +261,285 @@ int h5repack_addlayout(const char* str,
*/
static int check_options(pack_opt_t *options)
{
- unsigned int i;
- int k, j, has_cp=0, has_ck=0;
- char slayout[30];
-
-/*-------------------------------------------------------------------------
- * objects to layout
- *-------------------------------------------------------------------------
- */
- if (options->verbose && have_request(options) /* only print if requested */)
- {
- printf("Objects to modify layout are...\n");
- if (options->all_layout==1) {
- switch (options->layout_g)
- {
- case H5D_COMPACT:
- strcpy(slayout,"compact");
- break;
- case H5D_CONTIGUOUS:
- strcpy(slayout,"contiguous");
- break;
- case H5D_CHUNKED:
- strcpy(slayout,"chunked");
- break;
- default:
- strcpy(slayout,"unknown");
- break;
- }
- printf(" Apply %s layout to all\n", slayout);
- if (H5D_CHUNKED==options->layout_g) {
- printf("with dimension [");
- for ( j = 0; j < options->chunk_g.rank; j++)
- printf("%d ",(int)options->chunk_g.chunk_lengths[j]);
- printf("]\n");
- }
- }
- }/* verbose */
-
- for ( i = 0; i < options->op_tbl->nelems; i++)
- {
- char* name=options->op_tbl->objs[i].path;
-
- if (options->op_tbl->objs[i].chunk.rank>0)
- {
- if (options->verbose){
- printf(" <%s> with chunk size ",name);
- for ( k = 0; k < options->op_tbl->objs[i].chunk.rank; k++)
- printf("%d ",(int)options->op_tbl->objs[i].chunk.chunk_lengths[k]);
- printf("\n");
- }
- has_ck=1;
- }
- else if (options->op_tbl->objs[i].chunk.rank==-2)
- {
- if (options->verbose)
- printf(" <%s> %s\n",name,"NONE (contigous)");
- has_ck=1;
- }
- }
-
- if (options->all_layout==1 && has_ck){
- error_msg(progname, "invalid chunking input: 'all' option\
- is present with other objects\n");
- return -1;
- }
-
-/*-------------------------------------------------------------------------
- * objects to filter
- *-------------------------------------------------------------------------
- */
-
- if (options->verbose && have_request(options) /* only print if requested */)
- {
- printf("Objects to apply filter are...\n");
- if (options->all_filter==1)
- {
- H5Z_filter_t filtn=options->filter_g.filtn;
- switch (filtn)
- {
- case H5Z_FILTER_NONE:
- printf(" Uncompress all\n");
- break;
- case H5Z_FILTER_SHUFFLE:
- case H5Z_FILTER_FLETCHER32:
- printf(" All with %s\n",get_sfilter(filtn));
- break;
- case H5Z_FILTER_SZIP:
- case H5Z_FILTER_DEFLATE:
- printf(" All with %s, parameter %d\n",
- get_sfilter(filtn),
- options->filter_g.cd_values[0]);
- break;
- };
- }
- } /* verbose */
-
- for ( i = 0; i < options->op_tbl->nelems; i++)
- {
- pack_info_t pack = options->op_tbl->objs[i];
- char* name = pack.path;
-
- for ( j=0; j<pack.nfilters; j++)
- {
- if (options->verbose)
- {
- printf(" <%s> with %s filter\n",
- name,
- get_sfilter(pack.filter[j].filtn));
- }
-
- has_cp=1;
-
- } /* j */
- } /* i */
-
- if (options->all_filter==1 && has_cp){
- error_msg(progname, "invalid compression input: 'all' option\
- is present with other objects\n");
- return -1;
- }
-
- /* check options for the latest format */
- if (options->grp_compact < 0) {
- error_msg(progname, "invalid maximum number of links to store as header messages\n");
- return -1;
- }
- if (options->grp_indexed < 0) {
- error_msg(progname, "invalid minimum number of links to store in the indexed format\n");
- return -1;
- }
- if (options->grp_indexed > options->grp_compact) {
- error_msg(progname, "minimum indexed size is greater than the maximum compact size\n");
- return -1;
- }
- for (i=0; i<8; i++) {
- if (options->msg_size[i]<0) {
- error_msg(progname, "invalid shared message size\n");
- return -1;
- }
- }
-
- return 0;
+ unsigned int i;
+ int k, j, has_cp=0, has_ck=0;
+ char slayout[30];
+
+ /*-------------------------------------------------------------------------
+ * objects to layout
+ *-------------------------------------------------------------------------
+ */
+ if (options->verbose && have_request(options) /* only print if requested */)
+ {
+ printf("Objects to modify layout are...\n");
+ if (options->all_layout==1) {
+ switch (options->layout_g)
+ {
+ case H5D_COMPACT:
+ strcpy(slayout,"compact");
+ break;
+ case H5D_CONTIGUOUS:
+ strcpy(slayout,"contiguous");
+ break;
+ case H5D_CHUNKED:
+ strcpy(slayout,"chunked");
+ break;
+ default:
+ strcpy(slayout,"unknown");
+ break;
+ }
+ printf(" Apply %s layout to all\n", slayout);
+ if (H5D_CHUNKED==options->layout_g) {
+ printf("with dimension [");
+ for ( j = 0; j < options->chunk_g.rank; j++)
+ printf("%d ",(int)options->chunk_g.chunk_lengths[j]);
+ printf("]\n");
+ }
+ }
+ }/* verbose */
+
+ for ( i = 0; i < options->op_tbl->nelems; i++)
+ {
+ char* name=options->op_tbl->objs[i].path;
+
+ if (options->op_tbl->objs[i].chunk.rank>0)
+ {
+ if (options->verbose){
+ printf(" <%s> with chunk size ",name);
+ for ( k = 0; k < options->op_tbl->objs[i].chunk.rank; k++)
+ printf("%d ",(int)options->op_tbl->objs[i].chunk.chunk_lengths[k]);
+ printf("\n");
+ }
+ has_ck=1;
+ }
+ else if (options->op_tbl->objs[i].chunk.rank==-2)
+ {
+ if (options->verbose)
+ printf(" <%s> %s\n",name,"NONE (contigous)");
+ has_ck=1;
+ }
+ }
+
+ if (options->all_layout==1 && has_ck){
+ error_msg(progname, "invalid chunking input: 'all' option\
+ is present with other objects\n");
+ return -1;
+ }
+
+ /*-------------------------------------------------------------------------
+ * objects to filter
+ *-------------------------------------------------------------------------
+ */
+
+ if (options->verbose && have_request(options) /* only print if requested */)
+ {
+ printf("Objects to apply filter are...\n");
+ if (options->all_filter==1)
+ {
+
+ for (k = 0; k < options->n_filter_g; k++ )
+ {
+ H5Z_filter_t filtn=options->filter_g[k].filtn;
+ switch (filtn)
+ {
+ case H5Z_FILTER_NONE:
+ printf(" Uncompress all\n");
+ break;
+ case H5Z_FILTER_SHUFFLE:
+ case H5Z_FILTER_FLETCHER32:
+ printf(" All with %s\n",get_sfilter(filtn));
+ break;
+ case H5Z_FILTER_SZIP:
+ case H5Z_FILTER_DEFLATE:
+ printf(" All with %s, parameter %d\n",
+ get_sfilter(filtn),
+ options->filter_g[k].cd_values[0]);
+ break;
+ } /* k */
+ };
+ }
+ } /* verbose */
+
+ for ( i = 0; i < options->op_tbl->nelems; i++)
+ {
+ pack_info_t pack = options->op_tbl->objs[i];
+ char* name = pack.path;
+
+ for ( j=0; j<pack.nfilters; j++)
+ {
+ if (options->verbose)
+ {
+ printf(" <%s> with %s filter\n",
+ name,
+ get_sfilter(pack.filter[j].filtn));
+ }
+
+ has_cp=1;
+
+ } /* j */
+ } /* i */
+
+ if (options->all_filter==1 && has_cp){
+ error_msg(progname, "invalid compression input: 'all' option\
+ is present with other objects\n");
+ return -1;
+ }
+
+ /* check options for the latest format */
+ if (options->grp_compact < 0) {
+ error_msg(progname, "invalid maximum number of links to store as header messages\n");
+ return -1;
+ }
+ if (options->grp_indexed < 0) {
+ error_msg(progname, "invalid minimum number of links to store in the indexed format\n");
+ return -1;
+ }
+ if (options->grp_indexed > options->grp_compact) {
+ error_msg(progname, "minimum indexed size is greater than the maximum compact size\n");
+ return -1;
+ }
+ for (i=0; i<8; i++) {
+ if (options->msg_size[i]<0) {
+ error_msg(progname, "invalid shared message size\n");
+ return -1;
+ }
+ }
+
+ return 0;
}
+
/*-------------------------------------------------------------------------
- * Function: read_info
+ * Function: check_objects
*
- * Purpose: read comp and chunk options from file
+ * Purpose: locate all HDF5 objects in the file and compare with user
+ * supplied list
*
- * Return: void, exit on error
+ * Return: 0, ok, -1 no
*
- * Programmer: pvn@ncsa.uiuc.edu
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
- * Date: September, 22, 2003
+ * Date: September, 23, 2003
*
*-------------------------------------------------------------------------
*/
-
-void read_info(const char *filename,
- pack_opt_t *options)
+static int check_objects(const char* fname,
+ pack_opt_t *options)
{
-
- char stype[10];
- char comp_info[1024];
- FILE *fp;
- char c;
- int i, rc=1;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char data_file[512]=""; /* buffer to hold name of existing file */
-
- /* compose the name of the file to open, using the srcdir, if appropriate */
- if (srcdir){
- strcpy(data_file,srcdir);
- strcat(data_file,"/");
- }
- strcat(data_file,filename);
-
-
- if ((fp = fopen(data_file, "r")) == (FILE *)NULL) {
- error_msg(progname, "cannot open options file %s\n", filename);
- exit(1);
- }
-
- /* cycle until end of file reached */
- while( 1 )
- {
- rc=fscanf(fp, "%s", stype);
- if (rc==-1)
- break;
-
- /*-------------------------------------------------------------------------
- * filter
- *-------------------------------------------------------------------------
- */
- if (strcmp(stype,"-f") == 0) {
-
- /* find begining of info */
- i=0; c='0';
- while( c!=' ' )
- {
- fscanf(fp, "%c", &c);
- if (feof(fp)) break;
- }
- c='0';
- /* go until end */
- while( c!=' ' )
- {
- fscanf(fp, "%c", &c);
- comp_info[i]=c;
- i++;
- if (feof(fp)) break;
- if (c==10 /*eol*/) break;
- }
- comp_info[i-1]='\0'; /*cut the last " */
-
- if (h5repack_addfilter(comp_info,options)==-1){
- error_msg(progname, "could not add compression option\n");
- exit(1);
- }
- }
- /*-------------------------------------------------------------------------
- * layout
- *-------------------------------------------------------------------------
- */
- else if (strcmp(stype,"-l") == 0) {
-
- /* find begining of info */
- i=0; c='0';
- while( c!=' ' )
- {
- fscanf(fp, "%c", &c);
- if (feof(fp)) break;
- }
- c='0';
- /* go until end */
- while( c!=' ' )
- {
- fscanf(fp, "%c", &c);
- comp_info[i]=c;
- i++;
- if (feof(fp)) break;
- if (c==10 /*eol*/) break;
- }
- comp_info[i-1]='\0'; /*cut the last " */
-
- if (h5repack_addlayout(comp_info,options)==-1){
- error_msg(progname, "could not add chunck option\n");
- exit(1);
- }
- }
- /*-------------------------------------------------------------------------
- * not valid
- *-------------------------------------------------------------------------
- */
- else {
- error_msg(progname, "bad file format for %s", filename);
- exit(1);
- }
- }
-
- fclose(fp);
- return;
+ hid_t fid;
+ unsigned int i;
+ trav_table_t *travt = NULL;
+
+ /* nothing to do */
+ if(options->op_tbl->nelems == 0)
+ return 0;
+
+ /*-------------------------------------------------------------------------
+ * open the file
+ *-------------------------------------------------------------------------
+ */
+ if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0){
+ printf("<%s>: %s\n", fname, H5FOPENERROR );
+ return -1;
+ }
+
+ /*-------------------------------------------------------------------------
+ * get the list of objects in the file
+ *-------------------------------------------------------------------------
+ */
+
+ /* init table */
+ trav_table_init(&travt);
+
+ /* get the list of objects in the file */
+ if(h5trav_gettable(fid, travt) < 0)
+ goto out;
+
+ /*-------------------------------------------------------------------------
+ * compare with user supplied list
+ *-------------------------------------------------------------------------
+ */
+
+ if(options->verbose)
+ printf("Opening file <%s>. Searching for objects to modify...\n", fname);
+
+ for(i = 0; i < options->op_tbl->nelems; i++) {
+ char* name=options->op_tbl->objs[i].path;
+ if(options->verbose)
+ printf(" <%s>",name);
+
+ /* the input object names are present in the file and are valid */
+ if(h5trav_getindext(name, travt) < 0) {
+ error_msg(progname, "%s Could not find <%s> in file <%s>. Exiting...\n",
+ (options->verbose?"\n":""),name,fname);
+ goto out;
+ }
+ if(options->verbose)
+ printf("...Found\n");
+
+ /* check for extra filter conditions */
+ switch(options->op_tbl->objs[i].filter->filtn) {
+ /* chunk size must be smaller than pixels per block */
+ case H5Z_FILTER_SZIP:
+ {
+ int j;
+ int csize = 1;
+ int ppb = options->op_tbl->objs[i].filter->cd_values[0];
+ hsize_t dims[H5S_MAX_RANK];
+ int rank;
+ hid_t did;
+ hid_t sid;
+
+ if(options->op_tbl->objs[i].chunk.rank > 0) {
+ rank = options->op_tbl->objs[i].chunk.rank;
+ for(j = 0; j < rank; j++)
+ csize *= (int)options->op_tbl->objs[i].chunk.chunk_lengths[j];
+ }
+ else {
+ if((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
+ goto out;
+ if((sid = H5Dget_space(did)) < 0)
+ goto out;
+ if((rank = H5Sget_simple_extent_ndims(sid)) < 0)
+ goto out;
+ HDmemset(dims, 0, sizeof dims);
+ if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
+ goto out;
+ for(j = 0; j < rank; j++)
+ csize *= (int)dims[j];
+ if(H5Sclose(sid) < 0)
+ goto out;
+ if(H5Dclose(did) < 0)
+ goto out;
+ }
+
+ if (csize < ppb ) {
+ printf(" <warning: SZIP settins, chunk size is smaller than pixels per block>\n");
+ goto out;
+ }
+ }
+ break;
+ }
+ } /* i */
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+ H5Fclose(fid);
+ trav_table_free(travt);
+ return 0;
+
+out:
+ H5Fclose(fid);
+ trav_table_free(travt);
+ return -1;
}
+
+
+
/*-------------------------------------------------------------------------
* Function: have_request
*
@@ -527,7 +551,7 @@ void read_info(const char *filename,
*
*-------------------------------------------------------------------------
*/
-int have_request(pack_opt_t *options)
+static int have_request(pack_opt_t *options)
{
if (options->all_filter || options->all_layout || options->op_tbl->nelems)
@@ -536,3 +560,38 @@ int have_request(pack_opt_t *options)
return 0;
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: get_sfilter
+ *
+ * Purpose: return the filter as a string name
+ *
+ * Return: name of filter, exit on error
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static const char* get_sfilter(H5Z_filter_t filtn)
+{
+ if (filtn==H5Z_FILTER_NONE)
+ return "NONE";
+ else if (filtn==H5Z_FILTER_DEFLATE)
+ return "GZIP";
+ else if (filtn==H5Z_FILTER_SZIP)
+ return "SZIP";
+ else if (filtn==H5Z_FILTER_SHUFFLE)
+ return "SHUFFLE";
+ else if (filtn==H5Z_FILTER_FLETCHER32)
+ return "FLETCHER32";
+ else if (filtn==H5Z_FILTER_NBIT)
+ return "NBIT";
+ else if (filtn==H5Z_FILTER_SCALEOFFSET)
+ return "SOFF";
+ else {
+ error_msg(progname, "input error in filter type\n");
+ exit(1);
+ }
+ return NULL;
+}
+
diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h
index d986cc0..baa888e 100644
--- a/tools/h5repack/h5repack.h
+++ b/tools/h5repack/h5repack.h
@@ -19,6 +19,8 @@
#include "hdf5.h"
#include "h5trav.h"
+#include "H5Zprivate.h" /* H5Z_COMMON_CD_VALUES */
+
#define H5FOPENERROR "unable to open file"
@@ -51,11 +53,13 @@ typedef struct {
H5Z_FILTER_SCALEOFFSET 6 , scaleoffset compression
*/
-#define CDVALUES 2
+/* #define CD_VALUES H5Z_COMMON_CD_VALUES */
+#define CD_VALUES 20
typedef struct {
- H5Z_filter_t filtn; /* filter identification number */
- int cd_values[CDVALUES]; /* filter client data values */
+ H5Z_filter_t filtn; /* filter identification number */
+ unsigned cd_values[CD_VALUES]; /* filter client data values */
+ size_t cd_nelmts; /* filter client number of values */
} filter_info_t;
/* chunk lengths along each dimension and rank */
@@ -96,7 +100,8 @@ typedef struct {
pack_opttbl_t *op_tbl; /*table with all -c and -f options */
int all_layout; /*apply the layout to all objects */
int all_filter; /*apply the filter to all objects */
- filter_info_t filter_g; /*global filter INFO for the ALL case */
+ filter_info_t filter_g[H5_REPACK_MAX_NFILTERS]; /*global filter array for the ALL case */
+ int n_filter_g; /*number of global filters */
chunk_info_t chunk_g; /*global chunk INFO for the ALL case */
H5D_layout_t layout_g; /*global layout information for the ALL case */
int verbose; /*verbose mode */
@@ -142,58 +147,38 @@ int h5repack_cmpdcpl (const char *fname1,
*/
-int check_objects(const char* fname,
- pack_opt_t *options);
+/*-------------------------------------------------------------------------
+ * copy module
+ *-------------------------------------------------------------------------
+ */
-int copy_objects(const char* fnamein,
- const char* fnameout,
- pack_opt_t *options);
+int copy_objects (const char* fnamein,
+ const char* fnameout,
+ pack_opt_t *options);
int do_copy_refobjs(hid_t fidin,
hid_t fidout,
trav_table_t *travt,
- pack_opt_t *options); /* repack options */
-
+ pack_opt_t *options);
-void read_info(const char *filename,pack_opt_t *options);
+/*-------------------------------------------------------------------------
+ * filters and verify module
+ *-------------------------------------------------------------------------
+ */
void init_packobject(pack_info_t *obj);
-int print_filters(hid_t dcpl_id);
-int have_request(pack_opt_t *options);
-
/*-------------------------------------------------------------------------
- * filters
+ * filters and copy module
*-------------------------------------------------------------------------
*/
int apply_filters(const char* name, /* object name from traverse list */
int rank, /* rank of dataset */
hsize_t *dims, /* dimensions of dataset */
- hid_t dcpl_id, /* (IN,OUT) dataset creation property list */
+ hid_t dcpl_id, /* dataset creation property list */
pack_opt_t *options, /* repack options */
- int *has_filter); /* (OUT) object NAME has a filter */
-
-int can_read(const char* name, /* object name from traverse list */
- hid_t dcpl_id, /* dataset creation property list */
- pack_opt_t *options); /* repack options */
-
-
-/*-------------------------------------------------------------------------
- * layout functions
- *-------------------------------------------------------------------------
- */
-
-int has_layout(hid_t dcpl_id,
- pack_info_t *obj);
-
-int layout_this(hid_t dcpl_id, /* DCPL from input object */
- const char* name, /* object name from traverse list */
- pack_opt_t *options, /* repack options */
- pack_info_t *pack /*OUT*/) /* object to apply layout */;
-
-int apply_layout(hid_t dcpl_id,
- pack_info_t *pack); /* info about object */
+ int *has_filter); /* (OUT) object NAME has a filter */
/*-------------------------------------------------------------------------
@@ -221,15 +206,14 @@ pack_info_t* options_get_object( const char *path,
obj_list_t* parse_filter(const char *str,
int *n_objs,
filter_info_t *filt,
- pack_opt_t *options);
+ pack_opt_t *options,
+ int *is_glb);
obj_list_t* parse_layout(const char *str,
int *n_objs,
pack_info_t *pack, /* info about object */
pack_opt_t *options);
-const char* get_sfilter (H5Z_filter_t filtn);
-int parse_number(char *str);
diff --git a/tools/h5repack/h5repack.sh.in b/tools/h5repack/h5repack.sh.in
index 9fce08a..2e411b0 100755
--- a/tools/h5repack/h5repack.sh.in
+++ b/tools/h5repack/h5repack.sh.in
@@ -36,7 +36,6 @@ H5DIFF_BIN=`pwd`/$H5DIFF # The path of the h5diff tool binary
H5DETECTSZIP=testh5repack_detect_szip # The tool name
H5DETECTSZIP_BIN=`pwd`/$H5DETECTSZIP # The path of the tool binary
-
INFO_FILE=../testfiles/info.h5repack
FILE0=h5repack_fill.h5
@@ -428,6 +427,26 @@ TOOLTEST $FILE4 -l dset_chunk:CHUNK=18x13
# Native option
TOOLTEST $FILE1 -n
+
+# long swtiches. use FILE4=h5repack_layout.h5 (no filters)
+
+arg="$FILE4 --layout CHUNK=20x10 --filter GZIP=1 --threshold=10 --native --latest --compact=8 --indexed=6 --ssize=8[:dtype]"
+if test $USE_FILTER_DEFLATE != "yes" ; then
+ SKIP $arg
+else
+ TOOLTEST $arg
+fi
+
+# several global filters
+
+arg="$FILE4 --filter GZIP=1 --filter SHUF"
+if test $USE_FILTER_DEFLATE != "yes" -o $USE_FILTER_SHUFFLE != "yes" ; then
+ SKIP $arg
+else
+ TOOLTEST $arg
+fi
+
+
if test $nerrors -eq 0 ; then
echo "All $H5REPACK tests passed."
fi
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 6ad97d7..01ccc21 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -29,10 +29,6 @@ extern char *progname;
*/
#define FORMAT_OBJ " %-27s %s\n" /* obj type, name */
#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */
-#define PER(A,B) { per = 0; \
- if (A!=0) \
- per = (double) fabs( (double)(B-A) / (double)A ); \
- }
#define USERBLOCK_XFER_SIZE 512 /* Size of buffer/# of bytes to xfer at a time when copying userblock */
/*-------------------------------------------------------------------------
@@ -134,23 +130,23 @@ int copy_objects(const char* fnamein,
if(options->msg_size[i] > 0) {
switch(i) {
case 0:
- mesg_type_flags[nindex] = H5O_MESG_SDSPACE_FLAG;
+ mesg_type_flags[nindex] = H5O_SHMESG_SDSPACE_FLAG;
break;
case 1:
- mesg_type_flags[nindex] = H5O_MESG_DTYPE_FLAG;
+ mesg_type_flags[nindex] = H5O_SHMESG_DTYPE_FLAG;
break;
case 2:
- mesg_type_flags[nindex] = H5O_MESG_FILL_FLAG;
+ mesg_type_flags[nindex] = H5O_SHMESG_FILL_FLAG;
break;
case 3:
- mesg_type_flags[nindex] = H5O_MESG_PLINE_FLAG;
+ mesg_type_flags[nindex] = H5O_SHMESG_PLINE_FLAG;
break;
case 4:
- mesg_type_flags[nindex] = H5O_MESG_ATTR_FLAG;
+ mesg_type_flags[nindex] = H5O_SHMESG_ATTR_FLAG;
break;
} /* end switch */
min_mesg_sizes[nindex] = (unsigned)options->msg_size[i];
@@ -180,7 +176,7 @@ int copy_objects(const char* fnamein,
goto out;
} /* end if */
- if(H5Pset_latest_format(fapl, TRUE) < 0) {
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
error_msg(progname, "Could not set property for using latest version of the format\n");
goto out;
} /* end if */
@@ -355,7 +351,6 @@ int do_copy_objects(hid_t fidin,
hsize_t dsize_out; /* output dataset size after filter */
int apply_s; /* flag for apply filter to small dataset sizes */
int apply_f; /* flag for apply filter to return error on H5Dcreate */
- double per; /* percent utilization of storage */
void *buf=NULL; /* buffer for raw data */
void *sm_buf=NULL; /* buffer for raw data */
int has_filter; /* current object has a filter */
@@ -369,7 +364,7 @@ int do_copy_objects(hid_t fidin,
if (options->verbose) {
printf("-----------------------------------------\n");
- printf(" Type Filter (Ratio) Name\n");
+ printf(" Type Filter (%%Savings) Name\n");
printf("-----------------------------------------\n");
}
@@ -437,9 +432,6 @@ int do_copy_objects(hid_t fidin,
*/
case H5TRAV_TYPE_DATASET:
- if (options->verbose)
- printf(FORMAT_OBJ,"dset",travt->objs[i].name );
-
has_filter = 0;
/* early detection of references */
@@ -534,7 +526,13 @@ int do_copy_objects(hid_t fidin,
H5E_BEGIN_TRY {
dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_out, H5P_DEFAULT);
} H5E_END_TRY;
- if(dset_out == FAIL) {
+
+ if(dset_out == FAIL)
+ {
+ if(options->verbose)
+ printf(" warning: could not create dataset <%s>. Applying original settings\n",
+ travt->objs[i].name);
+
if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
goto error;
apply_f = 0;
@@ -665,10 +663,20 @@ int do_copy_objects(hid_t fidin,
{
if (apply_s && apply_f)
{
+ double per=0;
+ hssize_t a, b;
+
/* get the storage size of the input dataset */
dsize_out=H5Dget_storage_size(dset_out);
- PER((hssize_t)dsize_in,(hssize_t)dsize_out);
- print_dataset_info(dcpl_out,travt->objs[i].name,per*100.0);
+
+ a = dsize_in; b = dsize_out;
+ if (a!=0)
+ per = (double) (b-a)/a;
+
+ per = -per;
+ per *=100;
+
+ print_dataset_info(dcpl_out,travt->objs[i].name,per);
}
else
print_dataset_info(dcpl_id,travt->objs[i].name,0.0);
@@ -769,6 +777,11 @@ int do_copy_objects(hid_t fidin,
if(H5Dclose(dset_out) < 0)
goto error;
+
+ if (options->verbose)
+ printf(FORMAT_OBJ,"dset",travt->objs[i].name );
+
+
} /* end do we have request for filter/chunking */
@@ -894,143 +907,143 @@ int copy_attr(hid_t loc_in,
pack_opt_t *options
)
{
- hid_t attr_id=-1; /* attr ID */
- hid_t attr_out=-1; /* attr ID */
- hid_t space_id=-1; /* space ID */
- hid_t ftype_id=-1; /* file type ID */
- hid_t wtype_id=-1; /* read/write type ID */
- size_t msize; /* size of type */
- void *buf=NULL; /* data buffer */
- hsize_t nelmts; /* number of elements in dataset */
- int rank; /* rank of dataset */
- hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
- char name[255];
- H5O_info_t oinfo; /* Object info */
- int j;
- unsigned u;
-
- if(H5Oget_info(loc_in, &oinfo) < 0)
- goto error;
-
-/*-------------------------------------------------------------------------
- * copy all attributes
- *-------------------------------------------------------------------------
- */
-
- for ( u = 0; u < (unsigned)oinfo.num_attrs; u++)
- {
-
- buf=NULL;
-
- /* open attribute */
- if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
-
- /* get name */
- if (H5Aget_name( attr_id, (size_t)255, name ) < 0)
- goto error;
-
- /* get the file datatype */
- if ((ftype_id = H5Aget_type( attr_id )) < 0 )
- goto error;
-
- /* get the dataspace handle */
- if ((space_id = H5Aget_space( attr_id )) < 0 )
- goto error;
-
- /* get dimensions */
- if ( (rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0 )
- goto error;
-
- nelmts=1;
- for (j=0; j<rank; j++)
- nelmts*=dims[j];
-
- if (options->use_native==1)
- wtype_id = h5tools_get_native_type(ftype_id);
- else
- wtype_id = H5Tcopy(ftype_id);
-
- if ((msize=H5Tget_size(wtype_id))==0)
- goto error;
-
-/*-------------------------------------------------------------------------
- * object references are a special case
- * we cannot just copy the buffers, but instead we recreate the reference
- * this is done on a second sweep of the file that just copies
- * the referenced objects
- *-------------------------------------------------------------------------
- */
-
- if (H5T_REFERENCE==H5Tget_class(wtype_id))
- {
- ;
- }
- else
- {
- /*-------------------------------------------------------------------------
- * read to memory
- *-------------------------------------------------------------------------
- */
-
- buf = (void *)HDmalloc((size_t)(nelmts * msize));
- if(buf == NULL) {
- error_msg(progname, "cannot read into memory\n" );
- goto error;
- }
- if(H5Aread(attr_id, wtype_id, buf) < 0)
- goto error;
-
+ hid_t attr_id=-1; /* attr ID */
+ hid_t attr_out=-1; /* attr ID */
+ hid_t space_id=-1; /* space ID */
+ hid_t ftype_id=-1; /* file type ID */
+ hid_t wtype_id=-1; /* read/write type ID */
+ size_t msize; /* size of type */
+ void *buf=NULL; /* data buffer */
+ hsize_t nelmts; /* number of elements in dataset */
+ int rank; /* rank of dataset */
+ hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
+ char name[255];
+ H5O_info_t oinfo; /* object info */
+ int j;
+ unsigned u;
+
+ if(H5Oget_info(loc_in, &oinfo) < 0)
+ goto error;
+
/*-------------------------------------------------------------------------
- * copy
+ * copy all attributes
*-------------------------------------------------------------------------
*/
-
- if((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
- if(H5Awrite(attr_out, wtype_id, buf) < 0)
- goto error;
-
- /*close*/
- if(H5Aclose(attr_out) < 0)
- goto error;
-
-
- if(buf)
- free(buf);
-
- } /*H5T_REFERENCE*/
-
-
- if(options->verbose)
- printf(FORMAT_OBJ_ATTR, "attr", name);
-
-/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
-
- if (H5Tclose(ftype_id) < 0) goto error;
- if (H5Tclose(wtype_id) < 0) goto error;
- if (H5Sclose(space_id) < 0) goto error;
- if (H5Aclose(attr_id) < 0) goto error;
-
- } /* u */
-
-
- return 0;
-
+
+ for ( u = 0; u < (unsigned)oinfo.num_attrs; u++)
+ {
+
+ buf=NULL;
+
+ /* open attribute */
+ if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* get name */
+ if (H5Aget_name( attr_id, (size_t)255, name ) < 0)
+ goto error;
+
+ /* get the file datatype */
+ if ((ftype_id = H5Aget_type( attr_id )) < 0 )
+ goto error;
+
+ /* get the dataspace handle */
+ if ((space_id = H5Aget_space( attr_id )) < 0 )
+ goto error;
+
+ /* get dimensions */
+ if ( (rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0 )
+ goto error;
+
+ nelmts=1;
+ for (j=0; j<rank; j++)
+ nelmts*=dims[j];
+
+ if (options->use_native==1)
+ wtype_id = h5tools_get_native_type(ftype_id);
+ else
+ wtype_id = H5Tcopy(ftype_id);
+
+ if ((msize=H5Tget_size(wtype_id))==0)
+ goto error;
+
+ /*-------------------------------------------------------------------------
+ * object references are a special case
+ * we cannot just copy the buffers, but instead we recreate the reference
+ * this is done on a second sweep of the file that just copies
+ * the referenced objects
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5T_REFERENCE==H5Tget_class(wtype_id))
+ {
+ ;
+ }
+ else
+ {
+ /*-------------------------------------------------------------------------
+ * read to memory
+ *-------------------------------------------------------------------------
+ */
+
+ buf = (void *)HDmalloc((size_t)(nelmts * msize));
+ if(buf == NULL) {
+ error_msg(progname, "cannot read into memory\n" );
+ goto error;
+ }
+ if(H5Aread(attr_id, wtype_id, buf) < 0)
+ goto error;
+
+ /*-------------------------------------------------------------------------
+ * copy
+ *-------------------------------------------------------------------------
+ */
+
+ if((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+ if(H5Awrite(attr_out, wtype_id, buf) < 0)
+ goto error;
+
+ /*close*/
+ if(H5Aclose(attr_out) < 0)
+ goto error;
+
+
+ if(buf)
+ free(buf);
+
+ } /*H5T_REFERENCE*/
+
+
+ if(options->verbose)
+ printf(FORMAT_OBJ_ATTR, "attr", name);
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5Tclose(ftype_id) < 0) goto error;
+ if (H5Tclose(wtype_id) < 0) goto error;
+ if (H5Sclose(space_id) < 0) goto error;
+ if (H5Aclose(attr_id) < 0) goto error;
+
+ } /* u */
+
+
+ return 0;
+
error:
- H5E_BEGIN_TRY {
- H5Tclose(ftype_id);
- H5Tclose(wtype_id);
- H5Sclose(space_id);
- H5Aclose(attr_id);
- H5Aclose(attr_out);
- if (buf)
- free(buf);
- } H5E_END_TRY;
- return -1;
+ H5E_BEGIN_TRY {
+ H5Tclose(ftype_id);
+ H5Tclose(wtype_id);
+ H5Sclose(space_id);
+ H5Aclose(attr_id);
+ H5Aclose(attr_out);
+ if (buf)
+ free(buf);
+ } H5E_END_TRY;
+ return -1;
}
@@ -1047,95 +1060,96 @@ static void print_dataset_info(hid_t dcpl_id,
char *objname,
double per)
{
- char strfilter[255];
+ char strfilter[255];
#if defined (PRINT_DEBUG )
- char temp[255];
+ char temp[255];
#endif
- int nfilters; /* number of filters */
- unsigned filt_flags; /* filter flags */
- H5Z_filter_t filtn; /* filter identification number */
- unsigned cd_values[20]; /* filter client data values */
- size_t cd_nelmts; /* filter client number of values */
- char f_objname[256]; /* filter objname */
- int i;
-
- strcpy(strfilter,"\0");
-
- /* get information about input filters */
- if((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
- return;
-
- for(i = 0; i < nfilters; i++) {
- cd_nelmts = NELMTS(cd_values);
-
- filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts,
- cd_values, sizeof(f_objname), f_objname, NULL);
-
- switch(filtn) {
- default:
- break;
-
- case H5Z_FILTER_DEFLATE:
- strcat(strfilter,"GZIP ");
-
+ int nfilters; /* number of filters */
+ unsigned filt_flags; /* filter flags */
+ H5Z_filter_t filtn; /* filter identification number */
+ unsigned cd_values[20]; /* filter client data values */
+ size_t cd_nelmts; /* filter client number of values */
+ char f_objname[256]; /* filter objname */
+ int i;
+
+
+ strcpy(strfilter,"\0");
+
+ /* get information about input filters */
+ if((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
+ return;
+
+ for(i = 0; i < nfilters; i++) {
+ cd_nelmts = NELMTS(cd_values);
+
+ filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts,
+ cd_values, sizeof(f_objname), f_objname, NULL);
+
+ switch(filtn) {
+ default:
+ break;
+
+ case H5Z_FILTER_DEFLATE:
+ strcat(strfilter,"GZIP ");
+
#if defined (PRINT_DEBUG)
- {
- unsigned level=cd_values[0];
- sprintf(temp,"(%d)",level);
- strcat(strfilter,temp);
- }
+ {
+ unsigned level=cd_values[0];
+ sprintf(temp,"(%d)",level);
+ strcat(strfilter,temp);
+ }
#endif
- break;
-
- case H5Z_FILTER_SZIP:
- strcat(strfilter,"SZIP ");
-
+ break;
+
+ case H5Z_FILTER_SZIP:
+ strcat(strfilter,"SZIP ");
+
#if defined (PRINT_DEBUG)
- {
- unsigned options_mask=cd_values[0]; /* from dcpl, not filt*/
- unsigned ppb=cd_values[1];
- sprintf(temp,"(%d,",ppb);
- strcat(strfilter,temp);
- if (options_mask & H5_SZIP_EC_OPTION_MASK)
- strcpy(temp,"EC) ");
- else if (options_mask & H5_SZIP_NN_OPTION_MASK)
- strcpy(temp,"NN) ");
- }
- strcat(strfilter,temp);
-
+ {
+ unsigned options_mask=cd_values[0]; /* from dcpl, not filt*/
+ unsigned ppb=cd_values[1];
+ sprintf(temp,"(%d,",ppb);
+ strcat(strfilter,temp);
+ if (options_mask & H5_SZIP_EC_OPTION_MASK)
+ strcpy(temp,"EC) ");
+ else if (options_mask & H5_SZIP_NN_OPTION_MASK)
+ strcpy(temp,"NN) ");
+ }
+ strcat(strfilter,temp);
+
#endif
-
- break;
-
- case H5Z_FILTER_SHUFFLE:
- strcat(strfilter,"SHUF ");
- break;
-
- case H5Z_FILTER_FLETCHER32:
- strcat(strfilter,"FLET ");
- break;
-
- case H5Z_FILTER_NBIT:
- strcat(strfilter,"NBIT ");
- break;
-
- case H5Z_FILTER_SCALEOFFSET:
- strcat(strfilter,"SCALEOFFSET ");
- break;
- } /* switch */
- }/*i*/
-
- if(*strfilter == '\0')
- printf(FORMAT_OBJ,"dset",objname );
- else
- {
- char str[255], temp[20];
- strcpy(str,"dset ");
- strcat(str,strfilter);
- sprintf(temp," (%.1f%%)",per);
- strcat(str,temp);
- printf(FORMAT_OBJ,str,objname);
- }
+
+ break;
+
+ case H5Z_FILTER_SHUFFLE:
+ strcat(strfilter,"SHUF ");
+ break;
+
+ case H5Z_FILTER_FLETCHER32:
+ strcat(strfilter,"FLET ");
+ break;
+
+ case H5Z_FILTER_NBIT:
+ strcat(strfilter,"NBIT ");
+ break;
+
+ case H5Z_FILTER_SCALEOFFSET:
+ strcat(strfilter,"SCALEOFFSET ");
+ break;
+ } /* switch */
+ }/*i*/
+
+ if(*strfilter == '\0')
+ printf(FORMAT_OBJ,"dset",objname );
+ else
+ {
+ char str[255], temp[20];
+ strcpy(str,"dset ");
+ strcat(str,strfilter);
+ sprintf(temp," (%.1f%%)",per);
+ strcat(str,temp);
+ printf(FORMAT_OBJ,str,objname);
+ }
}
/*-------------------------------------------------------------------------
diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c
index 0e7a557..98ef07e 100644
--- a/tools/h5repack/h5repack_filters.c
+++ b/tools/h5repack/h5repack_filters.c
@@ -122,7 +122,7 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
{
/* assign the global filter */
tmp.nfilters=1;
- tmp.filter[0]=options->filter_g;
+ tmp.filter[0]=options->filter_g[0];
} /* if all */
else
{
@@ -144,9 +144,12 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
if (options->all_filter)
{
- /* assign the global filter */
- tmp.nfilters=1;
- tmp.filter[0]=options->filter_g;
+ int k;
+
+ /* assign the global filters */
+ tmp.nfilters=options->n_filter_g;
+ for ( k = 0; k < options->n_filter_g; k++)
+ tmp.filter[k]=options->filter_g[k];
}
if (options->all_layout)
{
@@ -168,8 +171,7 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
*obj = tmp;
return 1;
-}
-
+}
/*-------------------------------------------------------------------------
@@ -191,7 +193,7 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
int apply_filters(const char* name, /* object name from traverse list */
int rank, /* rank of dataset */
hsize_t *dims, /* dimensions of dataset */
- hid_t dcpl_id, /* (IN,OUT) dataset creation property list */
+ hid_t dcpl_id, /* dataset creation property list */
pack_opt_t *options, /* repack options */
int *has_filter) /* (OUT) object NAME has a filter */
@@ -262,12 +264,12 @@ int apply_filters(const char* name, /* object name from traverse list */
/*-------------------------------------------------------------------------
* the type of filter and additional parameter
* type can be one of the filters
- * H5Z_FILTER_NONE 0, uncompress if compressed
- * H5Z_FILTER_DEFLATE 1 , deflation like gzip
- * H5Z_FILTER_SHUFFLE 2 , shuffle the data
- * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
- * H5Z_FILTER_SZIP 4 , szip compression
- * H5Z_FILTER_NBIT 5 , nbit compression
+ * H5Z_FILTER_NONE 0 , uncompress if compressed
+ * H5Z_FILTER_DEFLATE 1 , deflation like gzip
+ * H5Z_FILTER_SHUFFLE 2 , shuffle the data
+ * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
+ * H5Z_FILTER_SZIP 4 , szip compression
+ * H5Z_FILTER_NBIT 5 , nbit compression
* H5Z_FILTER_SCALEOFFSET 6 , scaleoffset compression
*-------------------------------------------------------------------------
*/
@@ -275,10 +277,10 @@ int apply_filters(const char* name, /* object name from traverse list */
if (obj.nfilters)
{
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* filters require CHUNK layout; if we do not have one define a default
*-------------------------------------------------------------------------
- */
+ */
if (obj.layout==-1)
{
obj.chunk.rank=rank;
@@ -412,48 +414,3 @@ int apply_filters(const char* name, /* object name from traverse list */
return 0;
}
-/*-------------------------------------------------------------------------
- * Function: print_filters
- *
- * Purpose: print the filters in DCPL
- *
- * Return: 0, ok, -1 no
- *
- *-------------------------------------------------------------------------
- */
-
-int print_filters(hid_t dcpl_id)
-{
- int nfilters; /* number of filters */
- unsigned filt_flags; /* filter flags */
- H5Z_filter_t filtn; /* filter identification number */
- unsigned cd_values[20]; /* filter client data values */
- size_t cd_nelmts; /* filter client number of values */
- size_t cd_num; /* filter client data counter */
- char f_name[256]; /* filter name */
- char s[64]; /* temporary string buffer */
- int i;
-
- /* get information about filters */
- if((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
- return -1;
-
- for(i = 0; i < nfilters; i++) {
- cd_nelmts = NELMTS(cd_values);
- filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts,
- cd_values, sizeof(f_name), f_name, NULL);
-
- f_name[sizeof(f_name)-1] = '\0';
- sprintf(s, "Filter-%d:", i);
- printf(" %-10s %s-%u %s {", s,
- f_name[0] ? f_name : "method",
- (unsigned)filtn,
- filt_flags & H5Z_FLAG_OPTIONAL?"OPT":"");
- for(cd_num = 0; cd_num < cd_nelmts; cd_num++)
- printf("%s%u", cd_num?", ":"", cd_values[cd_num]);
- printf("}\n");
- }
-
- return 0;
-}
-
diff --git a/tools/h5repack/h5repack_list.c b/tools/h5repack/h5repack_list.c
deleted file mode 100644
index 4e1e072..0000000
--- a/tools/h5repack/h5repack_list.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Copyright by The HDF Group. *
- * Copyright by the Board of Trustees of the University of Illinois. *
- * All rights reserved. *
- * *
- * This file is part of HDF5. The full HDF5 copyright notice, including *
- * terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include "h5repack.h"
-#include "H5private.h"
-#include "h5tools_utils.h"
-#include "h5diff.h"
-#include "h5tools.h"
-
-extern char *progname;
-
-/*-------------------------------------------------------------------------
- * Function: check_objects
- *
- * Purpose: locate all HDF5 objects in the file and compare with user
- * supplied list
- *
- * Return: 0, ok, -1 no
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September, 23, 2003
- *
- *-------------------------------------------------------------------------
- */
-int check_objects(const char* fname,
- pack_opt_t *options)
-{
- hid_t fid;
- unsigned int i;
- trav_table_t *travt = NULL;
-
- /* nothing to do */
- if(options->op_tbl->nelems == 0)
- return 0;
-
- /*-------------------------------------------------------------------------
- * open the file
- *-------------------------------------------------------------------------
- */
- if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0){
- printf("<%s>: %s\n", fname, H5FOPENERROR );
- return -1;
- }
-
- /*-------------------------------------------------------------------------
- * get the list of objects in the file
- *-------------------------------------------------------------------------
- */
-
- /* init table */
- trav_table_init(&travt);
-
- /* get the list of objects in the file */
- if(h5trav_gettable(fid, travt) < 0)
- goto out;
-
- /*-------------------------------------------------------------------------
- * compare with user supplied list
- *-------------------------------------------------------------------------
- */
-
- if(options->verbose)
- printf("Opening file <%s>. Searching for objects to modify...\n", fname);
-
- for(i = 0; i < options->op_tbl->nelems; i++) {
- char* name=options->op_tbl->objs[i].path;
- if(options->verbose)
- printf(" <%s>",name);
-
- /* the input object names are present in the file and are valid */
- if(h5trav_getindext(name, travt) < 0) {
- error_msg(progname, "%s Could not find <%s> in file <%s>. Exiting...\n",
- (options->verbose?"\n":""),name,fname);
- goto out;
- }
- if(options->verbose)
- printf("...Found\n");
-
- /* check for extra filter conditions */
- switch(options->op_tbl->objs[i].filter->filtn) {
- /* chunk size must be smaller than pixels per block */
- case H5Z_FILTER_SZIP:
- {
- int j;
- int csize = 1;
- int ppb = options->op_tbl->objs[i].filter->cd_values[0];
- hsize_t dims[H5S_MAX_RANK];
- int rank;
- hid_t did;
- hid_t sid;
-
- if(options->op_tbl->objs[i].chunk.rank > 0) {
- rank = options->op_tbl->objs[i].chunk.rank;
- for(j = 0; j < rank; j++)
- csize *= (int)options->op_tbl->objs[i].chunk.chunk_lengths[j];
- }
- else {
- if((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
- goto out;
- if((sid = H5Dget_space(did)) < 0)
- goto out;
- if((rank = H5Sget_simple_extent_ndims(sid)) < 0)
- goto out;
- HDmemset(dims, 0, sizeof dims);
- if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
- goto out;
- for(j = 0; j < rank; j++)
- csize *= (int)dims[j];
- if(H5Sclose(sid) < 0)
- goto out;
- if(H5Dclose(did) < 0)
- goto out;
- }
-
- if (csize < ppb ) {
- printf(" <warning: SZIP settins, chunk size is smaller than pixels per block>\n");
- goto out;
- }
- }
- break;
- }
- } /* i */
-
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- H5Fclose(fid);
- trav_table_free(travt);
- return 0;
-
-out:
- H5Fclose(fid);
- trav_table_free(travt);
- return -1;
-}
-
diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c
index 6f65bc9..17056c4 100644
--- a/tools/h5repack/h5repack_main.c
+++ b/tools/h5repack/h5repack_main.c
@@ -15,18 +15,16 @@
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
+
#include "h5tools_utils.h"
#include "h5repack.h"
-#if 0
-#define OLD
-#endif
-#if defined (OLD)
-static void usage(void);
-#else
static void usage(const char *prog);
-#endif
+static int parse_number(char *str);
+static void parse_command_line(int argc, const char* argv[], pack_opt_t* options);
+static void read_info(const char *filename,pack_opt_t *options);
/* module-scoped variables */
@@ -54,161 +52,199 @@ static struct long_options l_opts[] = {
{ NULL, 0, '\0' }
};
+
+
+
/*-------------------------------------------------------------------------
- * Function: parse_command_line
+ * Function: main
*
- * Purpose: parse command line input
+ * Purpose: h5repack main program
+ *
+ * Return: 1, error, 0, no error
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: May 9, 2003
+ *
+ * Comments:
+ *
+ * Modifications:
+ * July 2004: Introduced the extra EC or NN option for SZIP
+ * October 2006: Added a new switch -n, that allows to write the dataset
+ * using a native type. The default to write is the file type.
*
+ * Modification:
+ * Peter Cao, June 13, 2007
+ * Add "-L, --latest" option to pack a file with the latest file format
+ * PVN, November 19, 2007
+ * adopted the syntax h5repack [OPTIONS] file1 file2
+ * PVN, November 28, 2007
+ * added support for multiple global filters
*-------------------------------------------------------------------------
*/
-
-#if 0
-#define OLD
-#endif
-
-#if defined (OLD)
-
-
-void parse_command_line(int argc,
- const char* argv[],
- char** fname1,
- char** fname2,
- pack_opt_t* options)
+int main(int argc, char **argv)
{
+ char *infile = NULL;
+ char *outfile = NULL;
+ pack_opt_t options; /*the global options */
+ int ret;
- int i;
+ /* initialize options */
+ h5repack_init (&options,0);
+
+ parse_command_line(argc, argv, &options);
- if (argc<2)
+ if ( argv[ opt_ind ] != NULL && argv[ opt_ind + 1 ] != NULL )
{
- usage();
- exit(1);
+ infile = argv[ opt_ind ];
+ outfile = argv[ opt_ind + 1 ];
+
+ if ( strcmp( infile, outfile ) == 0 )
+ {
+ error_msg(progname, "file names cannot be the same\n");
+ usage(progname);
+ exit(EXIT_FAILURE);
+
+ }
}
- for ( i = 1; i < argc; i++)
+ else
{
- if (strcmp(argv[i], "-h") == 0) {
- usage();
- exit(0);
- }
- else if (strcmp(argv[i], "-V") == 0) {
- print_version(progname);
- exit(0);
- }
- else if (strcmp(argv[i], "-i") == 0) {
- *fname1 = argv[++i];
- }
- else if (strcmp(argv[i], "-o") == 0) {
- *fname2 = argv[++i];
- }
- else if (strcmp(argv[i], "-v") == 0) {
- options->verbose = 1;
- }
- else if (strcmp(argv[i], "-f") == 0) {
-
- /* add the -f filter option */
- if (h5repack_addfilter(argv[i+1], options)<0)
- {
- error_msg(progname, "in parsing filter\n");
- exit(1);
- }
-
- /* jump to next */
- ++i;
- }
- else if (strcmp(argv[i], "-l") == 0) {
-
- /* parse the -l layout option */
- if (h5repack_addlayout(argv[i+1], options)<0)
- {
- error_msg(progname, "in parsing layout\n");
- exit(1);
- }
-
- /* jump to next */
- ++i;
- }
-
- else if (strcmp(argv[i], "-m") == 0) {
- options->threshold = parse_number(argv[i+1]);
- if ((int)options->threshold==-1) {
- error_msg(progname, "invalid treshold size <%s>\n",argv[i+1]);
- exit(1);
- }
- ++i;
- }
-
- else if (strcmp(argv[i], "-e") == 0) {
- read_info(argv[++i], options);
- }
- else if (strcmp(argv[i], "-n") == 0) {
- options->use_native = 1;
- }
-
- else if ( (strcmp(argv[i], "-L") == 0) || (strcmp(argv[i], "--latest") == 0)) {
- options->latest = 1;
- }
-
- else if ( strncmp(argv[i], "-compact=", 9) == 0 ) {
- options->grp_compact = atoi(argv[i]+9);
- if (options->grp_compact>0)
- options->latest = 1; /* must use latest format */
- }
-
- else if ( strncmp(argv[i], "-indexed=", 9) == 0 ) {
- options->grp_indexed = atoi(argv[i]+9);
- if (options->grp_indexed>0)
- options->latest = 1; /* must use latest format */
- }
-
- else if ( strncmp(argv[i], "-ssize=", 7) == 0 ) {
- int idx = 0;
- int ssize = 0;
- char *msgPtr = strchr(argv[i]+7, ':');
- options->latest = 1; /* must use latest format */
- if (msgPtr == NULL) {
- ssize = atoi(argv[i]+7);
- for (idx=0; idx<5; idx++)
- options->msg_size[idx] = ssize;
- }
- else {
- char msgType[10];
- strcpy(msgType, msgPtr+1);
- msgPtr[0] = '\0';
- ssize = atoi(argv[i]+7);
- if (strcmp(msgType, "dspace") == 0) {
- options->msg_size[0] = ssize;
- }
- else if (strcmp(msgType, "dtype") == 0) {
- options->msg_size[1] = ssize;
- }
- else if (strcmp(msgType, "fill") == 0) {
- options->msg_size[2] = ssize;
- }
- else if (strcmp(msgType, "pline") == 0) {
- options->msg_size[3] = ssize;
- }
- else if (strcmp(msgType, "attr") == 0) {
- options->msg_size[4] = ssize;
- }
- }
- } /* else if ( strncmp(argv[i], "-ssize=", 7) == 0 ) */
-
- else if (argv[i][0] == '-') {
- error_msg(progname, " - is not a valid argument\n");
- usage();
- exit(1);
- }
-
- }
-
+ error_msg(progname, "file names missing\n");
+ usage(progname);
+ exit(EXIT_FAILURE);
+ }
+
+
+ /* pack it */
+ ret=h5repack(infile,outfile,&options);
+
+ /* free tables */
+ h5repack_end(&options);
+
+ if (ret==-1)
+ return 1;
+ else
+ return 0;
+}
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: usage
+ *
+ * Purpose: print usage
+ *
+ * Return: void
+ *
+ *-------------------------------------------------------------------------
+ */
+static void usage(const char *prog)
+{
+ printf("usage: %s [OPTIONS] file1 file2\n", prog);
+ printf(" file1 Input HDF5 File\n");
+ printf(" file2 Output HDF5 File\n");
+ printf(" OPTIONS\n");
+ printf(" -h, --help Print a usage message and exit\n");
+ printf(" -v, --verbose Verbose mode, print object information\n");
+ printf(" -V, --version Print version number and exit\n");
+ printf(" -n, --native Use a native HDF5 type when repacking\n");
+ printf(" -L, --latest Use latest version of file format\n");
+ printf(" -c L1, --compact=L1 Maximum number of links in header messages\n");
+ printf(" -i L2, --indexed=L2 Minimum number of links in the indexed format\n");
+ printf(" -s S[:F], --ssize=S[:F] Shared object header message minimum size\n");
+ printf(" -m T, --threshold=T Do not apply the filter to datasets smaller than T\n");
+ printf(" -e M, --file=M Name of file M with the -f and -l options\n");
+ printf(" -f FILT, --filter=FILT Filter type\n");
+ printf(" -l LAYT, --layout=LAYT Layout type\n");
+ printf("\n");
+
+ printf(" T - is an integer greater than 1, size of dataset in bytes \n");
+ printf(" M - is a filename.\n");
+ printf(" F - is the shared object header message type, any of <dspace|dtype|fill|\n");
+ printf(" pline|attr>. If F is not specified, S applies to all messages\n");
+
+ printf("\n");
+
+ printf(" FILT - is a string with the format:\n");
+ printf("\n");
+ printf(" <list of objects>:<name of filter>=<filter parameters>\n");
+ printf("\n");
+ printf(" <list of objects> is a comma separated list of object names, meaning apply\n");
+ printf(" compression only to those objects. If no names are specified, the filter\n");
+ printf(" is applied to all objects\n");
+ printf(" <name of filter> can be:\n");
+ printf(" GZIP, to apply the HDF5 GZIP filter (GZIP compression)\n");
+ printf(" SZIP, to apply the HDF5 SZIP filter (SZIP compression)\n");
+ printf(" SHUF, to apply the HDF5 shuffle filter\n");
+ printf(" FLET, to apply the HDF5 checksum filter\n");
+ printf(" NBIT, to apply the HDF5 NBIT filter (NBIT compression)\n");
+ printf(" SOFF, to apply the HDF5 Scale/Offset filter\n");
+ printf(" NONE, to remove all filters\n");
+ printf(" <filter parameters> is optional filter parameter information\n");
+ printf(" GZIP=<deflation level> from 1-9\n");
+ printf(" SZIP=<pixels per block,coding> pixels per block is a even number in\n");
+ printf(" 2-32 and coding method is either EC or NN\n");
+ printf(" SHUF (no parameter)\n");
+ printf(" FLET (no parameter)\n");
+ printf(" NBIT (no parameter)\n");
+ printf(" SOFF=<scale_factor,scale_type> scale_factor is an integer and scale_type\n");
+ printf(" is either IN or DS\n");
+ printf(" NONE (no parameter)\n");
+ printf("\n");
+ printf(" LAYT - is a string with the format:\n");
+ printf("\n");
+ printf(" <list of objects>:<layout type>=<layout parameters>\n");
+ printf("\n");
+ printf(" <list of objects> is a comma separated list of object names, meaning that\n");
+ printf(" layout information is supplied for those objects. If no names are\n");
+ printf(" specified, the layout type is applied to all objects\n");
+ printf(" <layout type> can be:\n");
+ printf(" CHUNK, to apply chunking layout\n");
+ printf(" COMPA, to apply compact layout\n");
+ printf(" CONTI, to apply continuous layout\n");
+ printf(" <layout parameters> is optional layout information\n");
+ printf(" CHUNK=DIM[xDIM...xDIM], the chunk size of each dimension\n");
+ printf(" COMPA (no parameter)\n");
+ printf(" CONTI (no parameter)\n");
+ printf("\n");
+ printf("Examples of use:\n");
+ printf("\n");
+ printf("1) h5repack -v -f GZIP=1 file1 file2\n");
+ printf("\n");
+ printf(" GZIP compression with level 1 to all objects\n");
+ printf("\n");
+ printf("2) h5repack -v -f A:SZIP=8,NN file1 file2\n");
+ printf("\n");
+ printf(" SZIP compression with 8 pixels per block and NN coding method to object A\n");
+ printf("\n");
+ printf("3) h5repack -v -l A,B:CHUNK=20x10 -f C,D,F:NONE file1 file2\n");
+ printf("\n");
+ printf(" Chunked layout, with a layout size of 20x10, to objects A and B\n");
+ printf(" and remove filters to objects C, D, F\n");
+ printf("\n");
+ printf("4) h5repack -L -c 10 -s 20:dtype file1 file2 \n");
+ printf("\n");
+ printf(" Using latest file format with maximum compact group size of 10 and\n");
+ printf(" and minimum shared datatype size of 20\n");
+ printf("\n");
+ printf("5) h5repack -f SHUF -f GZIP=1 file1 file2 \n");
+ printf("\n");
+ printf(" Add both filters SHUF and GZIP in this order to all datasets\n");
+ printf("\n");
}
-#else
-void parse_command_line(int argc,
- const char* argv[],
- pack_opt_t* options)
+/*-------------------------------------------------------------------------
+ * Function: parse_command_line
+ *
+ * Purpose: parse command line input
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static void parse_command_line(int argc, const char* argv[], pack_opt_t* options)
{
int opt;
@@ -336,275 +372,164 @@ void parse_command_line(int argc,
usage(progname);
exit(EXIT_FAILURE);
}
-
-
+
}
-
-#endif
-
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: parse_number
*
- * Purpose: h5repack main program
+ * Purpose: read a number from command line argument
*
- * Return: 1, error, 0, no error
+ * Return: number, -1 for FAIL
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
- * Date: May 9, 2003
+ * Date: September, 23, 2003
*
- * Comments:
- *
- * Modifications:
- * July 2004: Introduced the extra EC or NN option for SZIP
- * October 2006: Added a new switch -n, that allows to write the dataset
- * using a native type. The default to write is the file type.
- *
- * Modification:
- * Peter Cao, June 13, 2007
- * Add "-L, --latest" option to pack a file with the latest file format
- * PVN, November 19, 2007
- * adopted the syntax h5repack [OPTIONS] file1 file2
*-------------------------------------------------------------------------
*/
-int main(int argc, char **argv)
-{
- char *infile = NULL;
- char *outfile = NULL;
- pack_opt_t options; /*the global options */
- int ret;
-
- /* initialize options */
- h5repack_init (&options,0);
-#if defined (OLD)
-
- parse_command_line(argc, argv, &infile, &outfile, &options);
-
-
-#else
- parse_command_line(argc, argv, &options);
-
- if ( argv[ opt_ind ] != NULL && argv[ opt_ind + 1 ] != NULL )
- {
- infile = argv[ opt_ind ];
- outfile = argv[ opt_ind + 1 ];
- }
+int parse_number(char *str)
+{
+ unsigned i;
+ int n;
+ char c;
+ size_t len=strlen(str);
- else
+ for ( i=0; i<len; i++)
{
- error_msg(progname, "file names missing\n");
- usage(progname);
- exit(EXIT_FAILURE);
+ c = str[i];
+ if (!isdigit(c)){
+ return -1;
+ }
}
-
-#endif
-
- /* pack it */
- ret=h5repack(infile,outfile,&options);
-
- /* free tables */
- h5repack_end(&options);
-
- if (ret==-1)
- return 1;
- else
- return 0;
+ str[i]='\0';
+ n=atoi(str);
+ return n;
}
-
/*-------------------------------------------------------------------------
- * Function: usage
+ * Function: read_info
*
- * Purpose: print usage
+ * Purpose: read comp and chunk options from a file
*
- * Return: void
+ * Return: void, exit on error
+ *
+ * Programmer: pvn@ncsa.uiuc.edu
+ *
+ * Date: September, 22, 2003
*
*-------------------------------------------------------------------------
*/
-#if defined OLD
-static void usage(void)
+static
+void read_info(const char *filename,
+ pack_opt_t *options)
{
- printf("usage: h5repack [-h] [-v] [-V] [-n] [-L] [-c] [-i] [-s] [-m size] [-e file] [-f FILTER] [-l LAYOUT] file1 file2\n");
- printf("\n");
- printf("file1 Input HDF5 File\n");
- printf("file2 Output HDF5 File\n");
- printf("[-h] Print this message\n");
- printf("[-v] Verbose mode, print object information\n");
- printf("[-V] Print HDF5 version number and exit\n");
- printf("[-n] Use a native HDF5 type when repacking. Default is the file type\n");
- printf("[-L, --latest] Use latest version of file format to create groups, datasets and datatypes\n");
- printf("[-c <size>, --compact=<size>] Set the maximum number of links to store as header messages in a group\n");
- printf("[-i <size>, --indexed=<size>] Set the minimum number of links to store in the indexed format\n");
- printf("[-s, --ssize=<size>[:<dspace|dtype|fill|pline|attr>]] Set the shared object header message minimum size\n");
- printf("[-m size] Do not apply the filter to objects smaller than size\n");
- printf("[-e file] Name of file with the -f and -l options\n");
- printf("[-f FILTER] Filter type\n");
- printf("[-l LAYOUT] Layout type\n");
- printf("\n");
- printf("FILTER is a string with the format:\n");
- printf("\n");
- printf(" <list of objects>:<name of filter>=<filter parameters>\n");
- printf("\n");
- printf(" <list of objects> is a comma separated list of object names, meaning apply\n");
- printf(" compression only to those objects. If no names are specified, the filter\n");
- printf(" is applied to all objects\n");
- printf(" <name of filter> can be:\n");
- printf(" GZIP, to apply the HDF5 GZIP filter (GZIP compression)\n");
- printf(" SZIP, to apply the HDF5 SZIP filter (SZIP compression)\n");
- printf(" SHUF, to apply the HDF5 shuffle filter\n");
- printf(" FLET, to apply the HDF5 checksum filter\n");
- printf(" NBIT, to apply the HDF5 NBIT filter (NBIT compression)\n");
- printf(" SOFF, to apply the HDF5 Scale/Offset filter\n");
- printf(" NONE, to remove all filters\n");
- printf(" <filter parameters> is optional filter parameter information\n");
- printf(" GZIP=<deflation level> from 1-9\n");
- printf(" SZIP=<pixels per block,coding> pixels per block is a even number in\n");
- printf(" 2-32 and coding method is either EC or NN\n");
- printf(" SHUF (no parameter)\n");
- printf(" FLET (no parameter)\n");
- printf(" NBIT (no parameter)\n");
- printf(" SOFF=<scale_factor,scale_type> scale_factor is an integer and scale_type\n");
- printf(" is either IN or DS\n");
- printf(" NONE (no parameter)\n");
- printf("\n");
- printf("LAYOUT is a string with the format:\n");
- printf("\n");
- printf(" <list of objects>:<layout type>=<layout parameters>\n");
- printf("\n");
- printf(" <list of objects> is a comma separated list of object names, meaning that\n");
- printf(" layout information is supplied for those objects. If no names are\n");
- printf(" specified, the layout type is applied to all objects\n");
- printf(" <layout type> can be:\n");
- printf(" CHUNK, to apply chunking layout\n");
- printf(" COMPA, to apply compact layout\n");
- printf(" CONTI, to apply continuous layout\n");
- printf(" <layout parameters> is optional layout information\n");
- printf(" CHUNK=DIM[xDIM...xDIM], the chunk size of each dimension\n");
- printf(" COMPA (no parameter)\n");
- printf(" CONTI (no parameter)\n");
- printf("\n");
- printf("Examples of use:\n");
- printf("\n");
- printf("1) h5repack -v -i file1 -o file2 -f GZIP=1\n");
- printf("\n");
- printf(" GZIP compression with level 1 to all objects\n");
- printf("\n");
- printf("2) h5repack -v -i file1 -o file2 -f A:SZIP=8,NN\n");
- printf("\n");
- printf(" SZIP compression with 8 pixels per block and NN coding method to object A\n");
- printf("\n");
- printf("3) h5repack -v -i file1 -o file2 -l A,B:CHUNK=20x10 -f C,D,F:NONE\n");
- printf("\n");
- printf(" Chunked layout, with a layout size of 20x10, to objects A and B\n");
- printf(" and remove filters to objects C, D, F\n");
- printf("\n");
- printf("4) h5repack -L -compact=10 -ssize=20:dtype -i file1 -o file2 \n");
- printf("\n");
- printf(" Using latest file format with maximum compact group size fo 10 and minimum shared datatype size of 20\n");
- printf("\n");
-}
-
-#else
-
-static void usage(const char *prog)
-{
- printf("usage: %s [OPTIONS] file1 file2\n", prog);
- printf(" file1 Input HDF5 File\n");
- printf(" file2 Output HDF5 File\n");
- printf(" OPTIONS\n");
- printf(" -h, --help Print a usage message and exit\n");
- printf(" -v, --verbose Verbose mode, print object information\n");
- printf(" -V, --version Print version number and exit\n");
- printf(" -n, --native Use a native HDF5 type when repacking\n");
- printf(" -L, --latest Use latest version of file format\n");
- printf(" -c L1, --compact=L1 Maximum number of links in header messages\n");
- printf(" -i L2, --indexed=L2 Minimum number of links in the indexed format\n");
- printf(" -s S[:F], --ssize=S[:F] Shared object header message minimum size\n");
- printf(" -m T, --threshold=T Do not apply the filter to objects smaller than T\n");
- printf(" -e M, --file=M Name of file M with the -f and -l options\n");
- printf(" -f FILT, --filter=FILT Filter type\n");
- printf(" -l LAYT, --layout=LAYT Layout type\n");
-
- printf("\n");
-
- printf(" T - is an integer greater than 1\n");
- printf(" M - is a filename.\n");
- printf(" F - is the shared object header message type, any of\n");
- printf(" <dspace|dtype|fill|pline|attr>\n");
-
- printf("\n");
-
- printf(" FILT - is a string with the format:\n");
- printf("\n");
- printf(" <list of objects>:<name of filter>=<filter parameters>\n");
- printf("\n");
- printf(" <list of objects> is a comma separated list of object names, meaning apply\n");
- printf(" compression only to those objects. If no names are specified, the filter\n");
- printf(" is applied to all objects\n");
- printf(" <name of filter> can be:\n");
- printf(" GZIP, to apply the HDF5 GZIP filter (GZIP compression)\n");
- printf(" SZIP, to apply the HDF5 SZIP filter (SZIP compression)\n");
- printf(" SHUF, to apply the HDF5 shuffle filter\n");
- printf(" FLET, to apply the HDF5 checksum filter\n");
- printf(" NBIT, to apply the HDF5 NBIT filter (NBIT compression)\n");
- printf(" SOFF, to apply the HDF5 Scale/Offset filter\n");
- printf(" NONE, to remove all filters\n");
- printf(" <filter parameters> is optional filter parameter information\n");
- printf(" GZIP=<deflation level> from 1-9\n");
- printf(" SZIP=<pixels per block,coding> pixels per block is a even number in\n");
- printf(" 2-32 and coding method is either EC or NN\n");
- printf(" SHUF (no parameter)\n");
- printf(" FLET (no parameter)\n");
- printf(" NBIT (no parameter)\n");
- printf(" SOFF=<scale_factor,scale_type> scale_factor is an integer and scale_type\n");
- printf(" is either IN or DS\n");
- printf(" NONE (no parameter)\n");
- printf("\n");
- printf(" LAYT - is a string with the format:\n");
- printf("\n");
- printf(" <list of objects>:<layout type>=<layout parameters>\n");
- printf("\n");
- printf(" <list of objects> is a comma separated list of object names, meaning that\n");
- printf(" layout information is supplied for those objects. If no names are\n");
- printf(" specified, the layout type is applied to all objects\n");
- printf(" <layout type> can be:\n");
- printf(" CHUNK, to apply chunking layout\n");
- printf(" COMPA, to apply compact layout\n");
- printf(" CONTI, to apply continuous layout\n");
- printf(" <layout parameters> is optional layout information\n");
- printf(" CHUNK=DIM[xDIM...xDIM], the chunk size of each dimension\n");
- printf(" COMPA (no parameter)\n");
- printf(" CONTI (no parameter)\n");
- printf("\n");
- printf("Examples of use:\n");
- printf("\n");
- printf("1) h5repack -v -f GZIP=1 file1 file2\n");
- printf("\n");
- printf(" GZIP compression with level 1 to all objects\n");
- printf("\n");
- printf("2) h5repack -v -f A:SZIP=8,NN file1 file2\n");
- printf("\n");
- printf(" SZIP compression with 8 pixels per block and NN coding method to object A\n");
- printf("\n");
- printf("3) h5repack -v -l A,B:CHUNK=20x10 -f C,D,F:NONE file1 file2\n");
- printf("\n");
- printf(" Chunked layout, with a layout size of 20x10, to objects A and B\n");
- printf(" and remove filters to objects C, D, F\n");
- printf("\n");
- printf("4) h5repack -L -c 10 -s 20:dtype file1 file2 \n");
- printf("\n");
- printf(" Using latest file format with maximum compact group size of 10 and\n");
- printf(" and minimum shared datatype size of 20\n");
- printf("\n");
+
+ char stype[10];
+ char comp_info[1024];
+ FILE *fp;
+ char c;
+ int i, rc=1;
+ char *srcdir = getenv("srcdir"); /* the source directory */
+ char data_file[512]=""; /* buffer to hold name of existing file */
+
+ /* compose the name of the file to open, using the srcdir, if appropriate */
+ if (srcdir){
+ strcpy(data_file,srcdir);
+ strcat(data_file,"/");
+ }
+ strcat(data_file,filename);
+
+
+ if ((fp = fopen(data_file, "r")) == (FILE *)NULL) {
+ error_msg(progname, "cannot open options file %s\n", filename);
+ exit(1);
+ }
+
+ /* cycle until end of file reached */
+ while( 1 )
+ {
+ rc=fscanf(fp, "%s", stype);
+ if (rc==-1)
+ break;
+
+ /*-------------------------------------------------------------------------
+ * filter
+ *-------------------------------------------------------------------------
+ */
+ if (strcmp(stype,"-f") == 0) {
+
+ /* find begining of info */
+ i=0; c='0';
+ while( c!=' ' )
+ {
+ fscanf(fp, "%c", &c);
+ if (feof(fp)) break;
+ }
+ c='0';
+ /* go until end */
+ while( c!=' ' )
+ {
+ fscanf(fp, "%c", &c);
+ comp_info[i]=c;
+ i++;
+ if (feof(fp)) break;
+ if (c==10 /*eol*/) break;
+ }
+ comp_info[i-1]='\0'; /*cut the last " */
+
+ if (h5repack_addfilter(comp_info,options)==-1){
+ error_msg(progname, "could not add compression option\n");
+ exit(1);
+ }
+ }
+ /*-------------------------------------------------------------------------
+ * layout
+ *-------------------------------------------------------------------------
+ */
+ else if (strcmp(stype,"-l") == 0) {
+
+ /* find begining of info */
+ i=0; c='0';
+ while( c!=' ' )
+ {
+ fscanf(fp, "%c", &c);
+ if (feof(fp)) break;
+ }
+ c='0';
+ /* go until end */
+ while( c!=' ' )
+ {
+ fscanf(fp, "%c", &c);
+ comp_info[i]=c;
+ i++;
+ if (feof(fp)) break;
+ if (c==10 /*eol*/) break;
+ }
+ comp_info[i-1]='\0'; /*cut the last " */
+
+ if (h5repack_addlayout(comp_info,options)==-1){
+ error_msg(progname, "could not add chunck option\n");
+ exit(1);
+ }
+ }
+ /*-------------------------------------------------------------------------
+ * not valid
+ *-------------------------------------------------------------------------
+ */
+ else {
+ error_msg(progname, "bad file format for %s", filename);
+ exit(1);
+ }
+ }
+
+ fclose(fp);
+ return;
}
-
-#endif
-
diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c
index 8492885..4fd450d 100644
--- a/tools/h5repack/h5repack_opttable.c
+++ b/tools/h5repack/h5repack_opttable.c
@@ -32,19 +32,19 @@ extern char *progname;
void init_packobject(pack_info_t *obj)
{
- int j, k;
-
- strcpy(obj->path,"\0");
- for ( j=0; j<H5_REPACK_MAX_NFILTERS; j++)
- {
- obj->filter[j].filtn = -1;
- for ( k=0; k<CDVALUES; k++)
- obj->filter[j].cd_values[k] = -1;
- }
- obj->chunk.rank = -1;
- obj->refobj_id = -1;
- obj->layout = H5D_LAYOUT_ERROR;
- obj->nfilters = 0;
+ int j, k;
+
+ strcpy(obj->path,"\0");
+ for ( j=0; j<H5_REPACK_MAX_NFILTERS; j++)
+ {
+ obj->filter[j].filtn = -1;
+ for ( k=0; k<CD_VALUES; k++)
+ obj->filter[j].cd_values[k] = -1;
+ }
+ obj->chunk.rank = -1;
+ obj->refobj_id = -1;
+ obj->layout = H5D_LAYOUT_ERROR;
+ obj->nfilters = 0;
}
/*-------------------------------------------------------------------------
@@ -61,15 +61,15 @@ static void aux_tblinsert_filter(pack_opttbl_t *table,
unsigned int I,
filter_info_t filt)
{
- if (table->objs[ I ].nfilters<H5_REPACK_MAX_NFILTERS)
- {
- table->objs[ I ].filter[ table->objs[ I ].nfilters++ ] = filt;
- }
- else
- {
- error_msg(progname, "cannot insert the filter in this object.\
- Maximum capacity exceeded\n");
- }
+ if (table->objs[ I ].nfilters<H5_REPACK_MAX_NFILTERS)
+ {
+ table->objs[ I ].filter[ table->objs[ I ].nfilters++ ] = filt;
+ }
+ else
+ {
+ error_msg(progname, "cannot insert the filter in this object.\
+ Maximum capacity exceeded\n");
+ }
}
/*-------------------------------------------------------------------------
@@ -86,26 +86,26 @@ static void aux_tblinsert_layout(pack_opttbl_t *table,
unsigned int I,
pack_info_t *pack)
{
- int k;
-
- table->objs[I].layout = pack->layout;
- if (H5D_CHUNKED==pack->layout)
- {
- /* -2 means the NONE option, remove chunking
- and set the layout to contiguous */
- if (pack->chunk.rank==-2)
- {
- table->objs[I].layout = H5D_CONTIGUOUS;
- table->objs[I].chunk.rank = -2;
- }
- /* otherwise set the chunking type */
- else
- {
- table->objs[I].chunk.rank = pack->chunk.rank;
- for (k = 0; k < pack->chunk.rank; k++)
- table->objs[I].chunk.chunk_lengths[k] = pack->chunk.chunk_lengths[k];
- }
- }
+ int k;
+
+ table->objs[I].layout = pack->layout;
+ if (H5D_CHUNKED==pack->layout)
+ {
+ /* -2 means the NONE option, remove chunking
+ and set the layout to contiguous */
+ if (pack->chunk.rank==-2)
+ {
+ table->objs[I].layout = H5D_CONTIGUOUS;
+ table->objs[I].chunk.rank = -2;
+ }
+ /* otherwise set the chunking type */
+ else
+ {
+ table->objs[I].chunk.rank = pack->chunk.rank;
+ for (k = 0; k < pack->chunk.rank; k++)
+ table->objs[I].chunk.chunk_lengths[k] = pack->chunk.chunk_lengths[k];
+ }
+ }
}
@@ -121,19 +121,19 @@ static void aux_tblinsert_layout(pack_opttbl_t *table,
static int aux_inctable(pack_opttbl_t *table, int n_objs )
{
- unsigned int i;
-
- table->size += n_objs;
- table->objs = (pack_info_t*)realloc(table->objs, table->size * sizeof(pack_info_t));
- if (table->objs==NULL) {
- error_msg(progname, "not enough memory for options table\n");
- return -1;
- }
- for (i = table->nelems; i < table->size; i++)
- {
- init_packobject(&table->objs[i]);
- }
- return 0;
+ unsigned int i;
+
+ table->size += n_objs;
+ table->objs = (pack_info_t*)realloc(table->objs, table->size * sizeof(pack_info_t));
+ if (table->objs==NULL) {
+ error_msg(progname, "not enough memory for options table\n");
+ return -1;
+ }
+ for (i = table->nelems; i < table->size; i++)
+ {
+ init_packobject(&table->objs[i]);
+ }
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -148,28 +148,28 @@ static int aux_inctable(pack_opttbl_t *table, int n_objs )
int options_table_init( pack_opttbl_t **tbl )
{
- unsigned int i;
- pack_opttbl_t* table = (pack_opttbl_t*) malloc(sizeof(pack_opttbl_t));
- if (table==NULL) {
- error_msg(progname, "not enough memory for options table\n");
- return -1;
- }
-
- table->size = 30;
- table->nelems = 0;
- table->objs = (pack_info_t*) malloc(table->size * sizeof(pack_info_t));
- if (table->objs==NULL) {
- error_msg(progname, "not enough memory for options table\n");
- return -1;
- }
-
- for ( i=0; i<table->size; i++)
- {
- init_packobject(&table->objs[i]);
- }
-
- *tbl = table;
- return 0;
+ unsigned int i;
+ pack_opttbl_t* table = (pack_opttbl_t*) malloc(sizeof(pack_opttbl_t));
+ if (table==NULL) {
+ error_msg(progname, "not enough memory for options table\n");
+ return -1;
+ }
+
+ table->size = 30;
+ table->nelems = 0;
+ table->objs = (pack_info_t*) malloc(table->size * sizeof(pack_info_t));
+ if (table->objs==NULL) {
+ error_msg(progname, "not enough memory for options table\n");
+ return -1;
+ }
+
+ for ( i=0; i<table->size; i++)
+ {
+ init_packobject(&table->objs[i]);
+ }
+
+ *tbl = table;
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -184,9 +184,9 @@ int options_table_init( pack_opttbl_t **tbl )
int options_table_free( pack_opttbl_t *table )
{
- free(table->objs);
- free(table);
- return 0;
+ free(table->objs);
+ free(table);
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -205,85 +205,85 @@ int options_add_layout( obj_list_t *obj_list,
pack_info_t *pack,
pack_opttbl_t *table )
{
- unsigned int i, I;
- int j, added=0, found=0;
-
- /* increase the size of the collection by N_OBJS if necessary */
- if (table->nelems+n_objs >= table->size)
- {
- if (aux_inctable(table,n_objs)<0)
- return -1;
- }
-
- /* search if this object is already in the table; "path" is the key */
- if (table->nelems>0)
- {
- /* go tru the supplied list of names */
- for (j = 0; j < n_objs; j++)
- {
- /* linear table search */
- for (i = 0; i < table->nelems; i++)
- {
- /*already on the table */
- if (strcmp(obj_list[j].obj,table->objs[i].path)==0)
+ unsigned int i, I;
+ int j, added=0, found=0;
+
+ /* increase the size of the collection by N_OBJS if necessary */
+ if (table->nelems+n_objs >= table->size)
{
- /* already chunk info inserted for this one; exit */
- if (table->objs[i].chunk.rank>0)
- {
- error_msg(progname, "chunk information already inserted for <%s>\n",obj_list[j].obj);
- exit(1);
- }
- /* insert the layout info */
- else
- {
- aux_tblinsert_layout(table,i,pack);
- found=1;
- break;
- }
- } /* if */
- } /* i */
-
- if (found==0)
- {
- /* keep the grow in a temp var */
- I = table->nelems + added;
- added++;
- strcpy(table->objs[I].path,obj_list[j].obj);
- aux_tblinsert_layout(table,I,pack);
+ if (aux_inctable(table,n_objs)<0)
+ return -1;
}
- /* cases where we have an already inserted name but there is a new name also
- example:
- -f dset1:GZIP=1 -l dset1,dset2:CHUNK=20x20
- dset1 is already inserted, but dset2 must also be
- */
- else if (found==1 && strcmp(obj_list[j].obj,table->objs[i].path)!=0)
- {
- /* keep the grow in a temp var */
- I = table->nelems + added;
- added++;
- strcpy(table->objs[I].path,obj_list[j].obj);
- aux_tblinsert_layout(table,I,pack);
- }
- } /* j */
- }
-
- /* first time insertion */
- else
- {
- /* go tru the supplied list of names */
- for (j = 0; j < n_objs; j++)
- {
- I = table->nelems + added;
- added++;
- strcpy(table->objs[I].path,obj_list[j].obj);
- aux_tblinsert_layout(table,I,pack);
-
- }
- }
-
- table->nelems+= added;
-
- return 0;
+
+ /* search if this object is already in the table; "path" is the key */
+ if (table->nelems>0)
+ {
+ /* go tru the supplied list of names */
+ for (j = 0; j < n_objs; j++)
+ {
+ /* linear table search */
+ for (i = 0; i < table->nelems; i++)
+ {
+ /*already on the table */
+ if (strcmp(obj_list[j].obj,table->objs[i].path)==0)
+ {
+ /* already chunk info inserted for this one; exit */
+ if (table->objs[i].chunk.rank>0)
+ {
+ error_msg(progname, "chunk information already inserted for <%s>\n",obj_list[j].obj);
+ exit(1);
+ }
+ /* insert the layout info */
+ else
+ {
+ aux_tblinsert_layout(table,i,pack);
+ found=1;
+ break;
+ }
+ } /* if */
+ } /* i */
+
+ if (found==0)
+ {
+ /* keep the grow in a temp var */
+ I = table->nelems + added;
+ added++;
+ strcpy(table->objs[I].path,obj_list[j].obj);
+ aux_tblinsert_layout(table,I,pack);
+ }
+ /* cases where we have an already inserted name but there is a new name also
+ example:
+ -f dset1:GZIP=1 -l dset1,dset2:CHUNK=20x20
+ dset1 is already inserted, but dset2 must also be
+ */
+ else if (found==1 && strcmp(obj_list[j].obj,table->objs[i].path)!=0)
+ {
+ /* keep the grow in a temp var */
+ I = table->nelems + added;
+ added++;
+ strcpy(table->objs[I].path,obj_list[j].obj);
+ aux_tblinsert_layout(table,I,pack);
+ }
+ } /* j */
+ }
+
+ /* first time insertion */
+ else
+ {
+ /* go tru the supplied list of names */
+ for (j = 0; j < n_objs; j++)
+ {
+ I = table->nelems + added;
+ added++;
+ strcpy(table->objs[I].path,obj_list[j].obj);
+ aux_tblinsert_layout(table,I,pack);
+
+ }
+ }
+
+ table->nelems+= added;
+
+ return 0;
}
@@ -303,76 +303,76 @@ int options_add_filter(obj_list_t *obj_list,
filter_info_t filt,
pack_opttbl_t *table )
{
-
- unsigned int i, I;
- int j, added=0, found=0;
-
- /* increase the size of the collection by N_OBJS if necessary */
- if (table->nelems+n_objs >= table->size)
- {
- if (aux_inctable(table,n_objs)<0)
- return -1;
- }
-
- /* search if this object is already in the table; "path" is the key */
- if (table->nelems>0)
- {
- /* go tru the supplied list of names */
- for (j = 0; j < n_objs; j++)
- {
- /* linear table search */
- for (i = 0; i < table->nelems; i++)
- {
- /*already on the table */
- if (strcmp(obj_list[j].obj,table->objs[i].path)==0)
+
+ unsigned int i, I;
+ int j, added=0, found=0;
+
+ /* increase the size of the collection by N_OBJS if necessary */
+ if (table->nelems+n_objs >= table->size)
{
- /* insert */
- aux_tblinsert_filter(table,i,filt);
- found=1;
- break;
- } /* if */
- } /* i */
-
- if (found==0)
- {
- /* keep the grow in a temp var */
- I = table->nelems + added;
- added++;
- strcpy(table->objs[I].path,obj_list[j].obj);
- aux_tblinsert_filter(table,I,filt);
- }
- /* cases where we have an already inserted name but there is a new name also
- example:
- -l dset1:CHUNK=20x20 -f dset1,dset2:GZIP=1
- dset1 is already inserted, but dset2 must also be
- */
- else if (found==1 && strcmp(obj_list[j].obj,table->objs[i].path)!=0)
- {
- /* keep the grow in a temp var */
- I = table->nelems + added;
- added++;
- strcpy(table->objs[I].path,obj_list[j].obj);
- aux_tblinsert_filter(table,I,filt);
- }
- } /* j */
- }
-
- /* first time insertion */
- else
- {
- /* go tru the supplied list of names */
- for (j = 0; j < n_objs; j++)
- {
- I = table->nelems + added;
- added++;
- strcpy(table->objs[I].path,obj_list[j].obj);
- aux_tblinsert_filter(table,I,filt);
- }
- }
-
- table->nelems+= added;
-
- return 0;
+ if (aux_inctable(table,n_objs)<0)
+ return -1;
+ }
+
+ /* search if this object is already in the table; "path" is the key */
+ if (table->nelems>0)
+ {
+ /* go tru the supplied list of names */
+ for (j = 0; j < n_objs; j++)
+ {
+ /* linear table search */
+ for (i = 0; i < table->nelems; i++)
+ {
+ /*already on the table */
+ if (strcmp(obj_list[j].obj,table->objs[i].path)==0)
+ {
+ /* insert */
+ aux_tblinsert_filter(table,i,filt);
+ found=1;
+ break;
+ } /* if */
+ } /* i */
+
+ if (found==0)
+ {
+ /* keep the grow in a temp var */
+ I = table->nelems + added;
+ added++;
+ strcpy(table->objs[I].path,obj_list[j].obj);
+ aux_tblinsert_filter(table,I,filt);
+ }
+ /* cases where we have an already inserted name but there is a new name also
+ example:
+ -l dset1:CHUNK=20x20 -f dset1,dset2:GZIP=1
+ dset1 is already inserted, but dset2 must also be
+ */
+ else if (found==1 && strcmp(obj_list[j].obj,table->objs[i].path)!=0)
+ {
+ /* keep the grow in a temp var */
+ I = table->nelems + added;
+ added++;
+ strcpy(table->objs[I].path,obj_list[j].obj);
+ aux_tblinsert_filter(table,I,filt);
+ }
+ } /* j */
+ }
+
+ /* first time insertion */
+ else
+ {
+ /* go tru the supplied list of names */
+ for (j = 0; j < n_objs; j++)
+ {
+ I = table->nelems + added;
+ added++;
+ strcpy(table->objs[I].path,obj_list[j].obj);
+ aux_tblinsert_filter(table,I,filt);
+ }
+ }
+
+ table->nelems+= added;
+
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -388,18 +388,18 @@ int options_add_filter(obj_list_t *obj_list,
pack_info_t* options_get_object( const char *path,
pack_opttbl_t *table )
{
- unsigned int i;
-
- for ( i = 0; i < table->nelems; i++)
- {
- /* found it */
- if (strcmp(table->objs[i].path,path)==0)
- {
- return (&table->objs[i]);
- }
- }
-
- return NULL;
+ unsigned int i;
+
+ for ( i = 0; i < table->nelems; i++)
+ {
+ /* found it */
+ if (strcmp(table->objs[i].path,path)==0)
+ {
+ return (&table->objs[i]);
+ }
+ }
+
+ return NULL;
}
diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c
index cf78cac..2475068 100644
--- a/tools/h5repack/h5repack_parse.c
+++ b/tools/h5repack/h5repack_parse.c
@@ -17,6 +17,7 @@
#include <string.h>
#include <stdio.h>
#include <ctype.h>
+
#include "h5repack.h"
#include "h5tools_utils.h"
@@ -53,407 +54,418 @@ extern char *progname;
obj_list_t* parse_filter(const char *str,
int *n_objs,
filter_info_t *filt,
- pack_opt_t *options)
+ pack_opt_t *options,
+ int *is_glb)
{
- unsigned i, u;
- char c;
- size_t len=strlen(str);
- int j, m, n, k, l, end_obj=-1, no_param=0;
- char sobj[MAX_NC_NAME];
- char scomp[10];
- char stype[5];
- char smask[3];
- obj_list_t* obj_list=NULL;
- unsigned pixels_per_block;
-
-#if defined(PARSE_DEBUG)
- fprintf(stderr,"%s\n",str);
-#endif
-
- /* initialize compression info */
- memset(filt,0,sizeof(filter_info_t));
-
- /* check for the end of object list and number of objects */
- for ( i=0, n=0; i<len; i++)
- {
- c = str[i];
- if ( c==':' )
- {
- end_obj=i;
- }
- if ( c==',' )
- {
- n++;
- }
- }
-
- if (end_obj==-1) { /* missing : */
- /* apply to all objects */
- options->all_filter=1;
- }
-
- n++;
- obj_list=malloc(n*sizeof(obj_list_t));
- if (obj_list==NULL)
- {
- error_msg(progname, "could not allocate object list\n");
- return NULL;
- }
- *n_objs=n;
-
- /* get object list */
- for ( j=0, k=0, n=0; j<end_obj; j++,k++)
- {
- c = str[j];
- sobj[k]=c;
- if ( c==',' || j==end_obj-1)
- {
- if ( c==',') sobj[k]='\0'; else sobj[k+1]='\0';
- strcpy(obj_list[n].obj,sobj);
- memset(sobj,0,sizeof(sobj));
- n++;
- k=-1;
- }
- }
- /* nothing after : */
- if (end_obj+1==(int)len)
- {
- if (obj_list) free(obj_list);
- error_msg(progname, "input Error: Invalid compression type in <%s>\n",str);
- exit(1);
- }
-
-
- /* get filter additional parameters */
- m=0;
- for ( i=end_obj+1, k=0, j=0; i<len; i++,k++)
- {
- c = str[i];
- scomp[k]=c;
- if ( c=='=' || i==len-1)
- {
- if ( c=='=') { /*one more parameter */
- scomp[k]='\0'; /*cut space */
-
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP
- * szip has the format SZIP=<pixels per block,coding>
- * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN'
- * example SZIP=8,NN
- *-------------------------------------------------------------------------
- */
- if (strcmp(scomp,"SZIP")==0)
+ unsigned i, u;
+ char c;
+ size_t len=strlen(str);
+ int j, m, n, k, l, end_obj=-1, no_param=0;
+ char sobj[MAX_NC_NAME];
+ char scomp[10];
+ char stype[5];
+ char smask[3];
+ obj_list_t* obj_list=NULL;
+ unsigned pixels_per_block;
+
+
+ /* initialize compression info */
+ memset(filt,0,sizeof(filter_info_t));
+ *is_glb = 0;
+
+ /* check for the end of object list and number of objects */
+ for ( i = 0, n = 0; i < len; i++)
{
- l=-1; /* mask index check */
- for ( m=0,u=i+1; u<len; u++,m++)
- {
- if (str[u]==',')
- {
- stype[m]='\0'; /* end digit of szip */
- l=0; /* start EC or NN search */
- u++; /* skip ',' */
- }
- c = str[u];
- if (!isdigit(c) && l==-1){
- if (obj_list) free(obj_list);
- error_msg(progname, "compression parameter not digit in <%s>\n",str);
- exit(1);
- }
- if (l==-1)
- stype[m]=c;
- else
- {
- smask[l]=c;
- l++;
- if (l==2)
- {
- smask[l]='\0';
- i=len-1; /* end */
- (*n_objs)--; /* we counted an extra ',' */
- if (strcmp(smask,"NN")==0)
- filt->cd_values[j++]=H5_SZIP_NN_OPTION_MASK;
- else if (strcmp(smask,"EC")==0)
- filt->cd_values[j++]=H5_SZIP_EC_OPTION_MASK;
- else
+ c = str[i];
+ if ( c==':' )
{
- error_msg(progname, "szip mask must be 'NN' or 'EC' \n");
- exit(1);
+ end_obj=i;
}
-
- }
- }
-
- } /* u */
- } /*if */
-
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET
- * scaleoffset has the format SOFF=<scale_factor,scale_type>
- * scale_type can be
- * integer datatype, H5Z_SO_INT (IN)
- * float datatype using D-scaling method, H5Z_SO_FLOAT_DSCALE (DS)
- * float datatype using E-scaling method, H5Z_SO_FLOAT_ESCALE (ES) , not yet implemented
- * for integer datatypes, scale_factor denotes Minimum Bits
- * for float datatypes, scale_factor denotes decimal scale factor
- * examples
- * SOFF=31,IN
- * SOFF=3,DF
- *-------------------------------------------------------------------------
- */
-
- else if (strcmp(scomp,"SOFF")==0)
+ if ( c==',' )
+ {
+ n++;
+ }
+ }
+
+ if (end_obj==-1) /* missing : */
+ {
+ /* apply to all objects */
+ options->all_filter=1;
+ *is_glb = 1;
+ }
+
+ n++;
+ obj_list = malloc(n*sizeof(obj_list_t));
+ if (obj_list==NULL)
{
- l=-1; /* mask index check */
- for ( m=0,u=i+1; u<len; u++,m++)
- {
- if (str[u]==',')
- {
- stype[m]='\0'; /* end digit */
- l=0; /* start 'IN' , 'DS', or 'ES' search */
- u++; /* skip ',' */
- }
- c = str[u];
- if (!isdigit(c) && l==-1){
- if (obj_list) free(obj_list);
- error_msg(progname, "compression parameter is not a digit in <%s>\n",str);
- exit(1);
- }
- if (l==-1)
- stype[m]=c;
- else
- {
- smask[l]=c;
- l++;
- if (l==2)
- {
- smask[l]='\0';
- i=len-1; /* end */
- (*n_objs)--; /* we counted an extra ',' */
- if (strcmp(smask,"IN")==0)
- filt->cd_values[j++]=H5Z_SO_INT;
- else if (strcmp(smask,"DS")==H5Z_SO_FLOAT_DSCALE)
- filt->cd_values[j++]=H5Z_SO_FLOAT_DSCALE;
- else
+ error_msg(progname, "could not allocate object list\n");
+ return NULL;
+ }
+ *n_objs=n;
+
+ /* get object list */
+ for ( j = 0, k = 0, n = 0; j < end_obj; j++, k++)
+ {
+ c = str[j];
+ sobj[k] = c;
+ if ( c==',' || j==end_obj-1)
{
- error_msg(progname, "scale type must be 'IN' or 'DS' \n");
- exit(1);
+ if ( c==',') sobj[k]='\0'; else sobj[k+1]='\0';
+ strcpy(obj_list[n].obj,sobj);
+ memset(sobj,0,sizeof(sobj));
+ n++;
+ k=-1;
}
-
- }
- }
-
- } /* u */
- } /*if */
-
-
-/*-------------------------------------------------------------------------
- * all other filters
- *-------------------------------------------------------------------------
- */
-
- else
+ }
+ /* nothing after : */
+ if (end_obj+1==(int)len)
{
- /* here we could have 1 or 2 digits */
- for ( m=0,u=i+1; u<len; u++,m++)
- {
- c = str[u];
- if (!isdigit(c)){
- if (obj_list) free(obj_list);
- error_msg(progname, "compression parameter is not a digit in <%s>\n",str);
- exit(1);
- }
- stype[m]=c;
- } /* u */
-
- stype[m]='\0';
- } /*if */
-
-
-
- filt->cd_values[j++]=atoi(stype);
- i+=m; /* jump */
+ if (obj_list) free(obj_list);
+ error_msg(progname, "input Error: Invalid compression type in <%s>\n",str);
+ exit(1);
+ }
+
+
+ /* get filter additional parameters */
+ m=0;
+ for ( i=end_obj+1, k=0, j=0; i<len; i++,k++)
+ {
+ c = str[i];
+ scomp[k]=c;
+ if ( c=='=' || i==len-1)
+ {
+ if ( c=='=') /*one more parameter */
+ {
+ scomp[k]='\0'; /*cut space */
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP
+ * szip has the format SZIP=<pixels per block,coding>
+ * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN'
+ * example SZIP=8,NN
+ *-------------------------------------------------------------------------
+ */
+ if (strcmp(scomp,"SZIP")==0)
+ {
+ l=-1; /* mask index check */
+ for ( m=0,u=i+1; u<len; u++,m++)
+ {
+ if (str[u]==',')
+ {
+ stype[m]='\0'; /* end digit of szip */
+ l=0; /* start EC or NN search */
+ u++; /* skip ',' */
+ }
+ c = str[u];
+ if (!isdigit(c) && l==-1){
+ if (obj_list) free(obj_list);
+ error_msg(progname, "compression parameter not digit in <%s>\n",str);
+ exit(1);
+ }
+ if (l==-1)
+ stype[m]=c;
+ else
+ {
+ smask[l]=c;
+ l++;
+ if (l==2)
+ {
+ smask[l]='\0';
+ i=len-1; /* end */
+ (*n_objs)--; /* we counted an extra ',' */
+ if (strcmp(smask,"NN")==0)
+ filt->cd_values[j++]=H5_SZIP_NN_OPTION_MASK;
+ else if (strcmp(smask,"EC")==0)
+ filt->cd_values[j++]=H5_SZIP_EC_OPTION_MASK;
+ else
+ {
+ error_msg(progname, "szip mask must be 'NN' or 'EC' \n");
+ exit(1);
+ }
+
+
+ }
+ }
+
+ } /* u */
+ } /*if */
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SCALEOFFSET
+ * scaleoffset has the format SOFF=<scale_factor,scale_type>
+ * scale_type can be
+ * integer datatype, H5Z_SO_INT (IN)
+ * float datatype using D-scaling method, H5Z_SO_FLOAT_DSCALE (DS)
+ * float datatype using E-scaling method, H5Z_SO_FLOAT_ESCALE (ES) , not yet implemented
+ * for integer datatypes, scale_factor denotes Minimum Bits
+ * for float datatypes, scale_factor denotes decimal scale factor
+ * examples
+ * SOFF=31,IN
+ * SOFF=3,DF
+ *-------------------------------------------------------------------------
+ */
+
+ else if (strcmp(scomp,"SOFF")==0)
+ {
+ l=-1; /* mask index check */
+ for ( m=0,u=i+1; u<len; u++,m++)
+ {
+ if (str[u]==',')
+ {
+ stype[m]='\0'; /* end digit */
+ l=0; /* start 'IN' , 'DS', or 'ES' search */
+ u++; /* skip ',' */
+ }
+ c = str[u];
+ if (!isdigit(c) && l==-1){
+ if (obj_list) free(obj_list);
+ error_msg(progname, "compression parameter is not a digit in <%s>\n",str);
+ exit(1);
+ }
+ if (l==-1)
+ stype[m]=c;
+ else
+ {
+ smask[l]=c;
+ l++;
+ if (l==2)
+ {
+ smask[l]='\0';
+ i=len-1; /* end */
+ (*n_objs)--; /* we counted an extra ',' */
+ if (strcmp(smask,"IN")==0)
+ filt->cd_values[j++]=H5Z_SO_INT;
+ else if (strcmp(smask,"DS")==H5Z_SO_FLOAT_DSCALE)
+ filt->cd_values[j++]=H5Z_SO_FLOAT_DSCALE;
+ else
+ {
+ error_msg(progname, "scale type must be 'IN' or 'DS' \n");
+ exit(1);
+ }
+
+ }
+ }
+
+ } /* u */
+ } /*if */
+
+
+ /*-------------------------------------------------------------------------
+ * all other filters
+ *-------------------------------------------------------------------------
+ */
+
+ else
+ {
+ /* here we could have 1 or 2 digits */
+ for ( m=0,u=i+1; u<len; u++,m++)
+ {
+ c = str[u];
+ if (!isdigit(c)){
+ if (obj_list) free(obj_list);
+ error_msg(progname, "compression parameter is not a digit in <%s>\n",str);
+ exit(1);
+ }
+ stype[m]=c;
+ } /* u */
+
+ stype[m]='\0';
+ } /*if */
+
+
+
+ filt->cd_values[j++]=atoi(stype);
+ i+=m; /* jump */
}
- else if (i==len-1) { /*no more parameters */
- scomp[k+1]='\0';
- no_param=1;
+ else if (i==len-1)
+ { /*no more parameters */
+ scomp[k+1]='\0';
+ no_param=1;
}
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_NONE
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * translate from string to filter symbol
+ *-------------------------------------------------------------------------
+ */
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_NONE
+ *-------------------------------------------------------------------------
+ */
if (strcmp(scomp,"NONE")==0)
- filt->filtn=H5Z_FILTER_NONE;
-
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE
- *-------------------------------------------------------------------------
- */
+ {
+ filt->filtn=H5Z_FILTER_NONE;
+ filt->cd_nelmts = 0;
+ }
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_DEFLATE
+ *-------------------------------------------------------------------------
+ */
else if (strcmp(scomp,"GZIP")==0)
{
- filt->filtn=H5Z_FILTER_DEFLATE;
- if (no_param) { /*no more parameters, GZIP must have parameter */
- if (obj_list) free(obj_list);
- error_msg(progname, "missing compression parameter in <%s>\n",str);
- exit(1);
- }
+ filt->filtn=H5Z_FILTER_DEFLATE;
+ filt->cd_nelmts = 1;
+ if (no_param)
+ { /*no more parameters, GZIP must have parameter */
+ if (obj_list) free(obj_list);
+ error_msg(progname, "missing compression parameter in <%s>\n",str);
+ exit(1);
+ }
}
-
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP
- *-------------------------------------------------------------------------
- */
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP
+ *-------------------------------------------------------------------------
+ */
else if (strcmp(scomp,"SZIP")==0)
{
- filt->filtn=H5Z_FILTER_SZIP;
- if (no_param) { /*no more parameters, SZIP must have parameter */
- if (obj_list) free(obj_list);
- error_msg(progname, "missing compression parameter in <%s>\n",str);
- exit(1);
- }
+ filt->filtn=H5Z_FILTER_SZIP;
+ filt->cd_nelmts = 2;
+ if (no_param)
+ { /*no more parameters, SZIP must have parameter */
+ if (obj_list) free(obj_list);
+ error_msg(progname, "missing compression parameter in <%s>\n",str);
+ exit(1);
+ }
}
-
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_SHUFFLE
- *-------------------------------------------------------------------------
- */
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SHUFFLE
+ *-------------------------------------------------------------------------
+ */
else if (strcmp(scomp,"SHUF")==0)
{
- filt->filtn=H5Z_FILTER_SHUFFLE;
- if (m>0){ /*shuffle does not have parameter */
- if (obj_list) free(obj_list);
- error_msg(progname, "extra parameter in SHUF <%s>\n",str);
- exit(1);
- }
+ filt->filtn=H5Z_FILTER_SHUFFLE;
+ filt->cd_nelmts = 0;
+ if (m>0)
+ { /*shuffle does not have parameter */
+ if (obj_list) free(obj_list);
+ error_msg(progname, "extra parameter in SHUF <%s>\n",str);
+ exit(1);
+ }
}
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_FLETCHER32
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_FLETCHER32
+ *-------------------------------------------------------------------------
+ */
else if (strcmp(scomp,"FLET")==0)
{
- filt->filtn=H5Z_FILTER_FLETCHER32;
- if (m>0){ /*shuffle does not have parameter */
- if (obj_list) free(obj_list);
- error_msg(progname, "extra parameter in FLET <%s>\n",str);
- exit(1);
- }
+ filt->filtn=H5Z_FILTER_FLETCHER32;
+ filt->cd_nelmts = 0;
+ if (m>0)
+ { /*shuffle does not have parameter */
+ if (obj_list) free(obj_list);
+ error_msg(progname, "extra parameter in FLET <%s>\n",str);
+ exit(1);
+ }
}
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_NBIT
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_NBIT
+ *-------------------------------------------------------------------------
+ */
else if (strcmp(scomp,"NBIT")==0)
{
- filt->filtn=H5Z_FILTER_NBIT;
- if (m>0){ /*nbit does not have parameter */
- if (obj_list) free(obj_list);
- error_msg(progname, "extra parameter in NBIT <%s>\n",str);
- exit(1);
- }
+ filt->filtn=H5Z_FILTER_NBIT;
+ filt->cd_nelmts = 0;
+ if (m>0)
+ { /*nbit does not have parameter */
+ if (obj_list) free(obj_list);
+ error_msg(progname, "extra parameter in NBIT <%s>\n",str);
+ exit(1);
+ }
}
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SCALEOFFSET
+ *-------------------------------------------------------------------------
+ */
else if (strcmp(scomp,"SOFF")==0)
{
- filt->filtn=H5Z_FILTER_SCALEOFFSET;
- if (no_param) { /*no more parameters, SOFF must have parameter */
- if (obj_list) free(obj_list);
- error_msg(progname, "missing compression parameter in <%s>\n",str);
- exit(1);
- }
+ filt->filtn=H5Z_FILTER_SCALEOFFSET;
+ filt->cd_nelmts = 2;
+ if (no_param)
+ { /*no more parameters, SOFF must have parameter */
+ if (obj_list) free(obj_list);
+ error_msg(progname, "missing compression parameter in <%s>\n",str);
+ exit(1);
+ }
}
else {
- if (obj_list) free(obj_list);
- error_msg(progname, "invalid filter type in <%s>\n",str);
- exit(1);
+ if (obj_list) free(obj_list);
+ error_msg(progname, "invalid filter type in <%s>\n",str);
+ exit(1);
}
}
} /*i*/
+
+ /*-------------------------------------------------------------------------
+ * check valid parameters
+ *-------------------------------------------------------------------------
+ */
+
+ switch (filt->filtn)
+ {
-/*-------------------------------------------------------------------------
- * check valid parameters
- *-------------------------------------------------------------------------
- */
-
- switch (filt->filtn)
- {
-
- case H5Z_FILTER_DEFLATE:
- if (filt->cd_values[0]<0 || filt->cd_values[0]>9 ){
- if (obj_list) free(obj_list);
- error_msg(progname, "invalid compression parameter in <%s>\n",str);
- exit(1);
- }
- break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_DEFLATE
+ *-------------------------------------------------------------------------
+ */
+
+ case H5Z_FILTER_DEFLATE:
+ if (filt->cd_values[0]<0 || filt->cd_values[0]>9 )
+ {
+ if (obj_list) free(obj_list);
+ error_msg(progname, "invalid compression parameter in <%s>\n",str);
+ exit(1);
+ }
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP
+ *-------------------------------------------------------------------------
+ */
+
+ case H5Z_FILTER_SZIP:
+ pixels_per_block=filt->cd_values[0];
+ if ((pixels_per_block%2)==1)
+ {
+ if (obj_list) free(obj_list);
+ error_msg(progname, "pixels_per_block is not even in <%s>\n",str);
+ exit(1);
+ }
+ if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK)
+ {
+ if (obj_list) free(obj_list);
+ error_msg(progname, "pixels_per_block is too large in <%s>\n",str);
+ exit(1);
+ }
+ if ( (strcmp(smask,"NN")!=0) && (strcmp(smask,"EC")!=0) )
+ {
+ if (obj_list) free(obj_list);
+ error_msg(progname, "szip mask must be 'NN' or 'EC' \n");
+ exit(1);
+ }
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SCALEOFFSET
+ *-------------------------------------------------------------------------
+ */
- case H5Z_FILTER_SZIP:
- pixels_per_block=filt->cd_values[0];
- if ((pixels_per_block%2)==1) {
- if (obj_list) free(obj_list);
- error_msg(progname, "pixels_per_block is not even in <%s>\n",str);
- exit(1);
- }
- if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK) {
- if (obj_list) free(obj_list);
- error_msg(progname, "pixels_per_block is too large in <%s>\n",str);
- exit(1);
- }
- if ( (strcmp(smask,"NN")!=0) && (strcmp(smask,"EC")!=0) ) {
- if (obj_list) free(obj_list);
- error_msg(progname, "szip mask must be 'NN' or 'EC' \n");
- exit(1);
- }
- break;
- case H5Z_FILTER_SCALEOFFSET:
- if (filt->cd_values[0]<0 ){
- if (obj_list) free(obj_list);
- error_msg(progname, "invalid compression parameter in <%s>\n",str);
- exit(1);
- }
- break;
- };
-
- return obj_list;
+ case H5Z_FILTER_SCALEOFFSET:
+ if (filt->cd_values[0]<0 )
+ {
+ if (obj_list) free(obj_list);
+ error_msg(progname, "invalid compression parameter in <%s>\n",str);
+ exit(1);
+ }
+ break;
+ };
+
+ return obj_list;
}
-/*-------------------------------------------------------------------------
- * Function: get_sfilter
- *
- * Purpose: return the filter as a string name
- *
- * Return: name of filter, exit on error
- *
- *-------------------------------------------------------------------------
- */
-
-const char* get_sfilter(H5Z_filter_t filtn)
-{
- if (filtn==H5Z_FILTER_NONE)
- return "NONE";
- else if (filtn==H5Z_FILTER_DEFLATE)
- return "GZIP";
- else if (filtn==H5Z_FILTER_SZIP)
- return "SZIP";
- else if (filtn==H5Z_FILTER_SHUFFLE)
- return "SHUFFLE";
- else if (filtn==H5Z_FILTER_FLETCHER32)
- return "FLETCHER32";
- else if (filtn==H5Z_FILTER_NBIT)
- return "NBIT";
- else if (filtn==H5Z_FILTER_SCALEOFFSET)
- return "SOFF";
- else {
- error_msg(progname, "input error in filter type\n");
- exit(1);
- }
- return NULL;
-}
-
/*-------------------------------------------------------------------------
* Function: parse_layout
@@ -481,205 +493,171 @@ obj_list_t* parse_layout(const char *str,
pack_info_t *pack, /* info about layout needed */
pack_opt_t *options)
{
- obj_list_t* obj_list=NULL;
- unsigned i;
- char c;
- size_t len=strlen(str);
- int j, n, k, end_obj=-1, c_index;
- char sobj[MAX_NC_NAME];
- char sdim[10];
- char slayout[10];
-
-
- memset(sdim, '\0', sizeof(sdim));
- memset(sobj, '\0', sizeof(sobj));
- memset(slayout, '\0', sizeof(slayout));
-
- /* check for the end of object list and number of objects */
- for ( i=0, n=0; i<len; i++)
- {
- c = str[i];
- if ( c==':' )
- {
- end_obj=i;
- }
- if ( c==',' )
- {
- n++;
- }
- }
-
- if (end_obj==-1) { /* missing : chunk all */
- options->all_layout=1;
- }
-
- n++;
- obj_list=malloc(n*sizeof(obj_list_t));
- if (obj_list==NULL)
- {
- error_msg(progname, "could not allocate object list\n");
- return NULL;
- }
- *n_objs=n;
-
- /* get object list */
- for ( j=0, k=0, n=0; j<end_obj; j++,k++)
- {
- c = str[j];
- sobj[k]=c;
- if ( c==',' || j==end_obj-1)
- {
- if ( c==',') sobj[k]='\0'; else sobj[k+1]='\0';
- strcpy(obj_list[n].obj,sobj);
- memset(sobj,0,sizeof(sobj));
- n++;
- k=-1;
- }
- }
-
- /* nothing after : */
- if (end_obj+1==(int)len)
- {
- if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, no characters after : in <%s>\n",str);
- exit(1);
- }
-
- /* get layout info */
- for ( j=end_obj+1, n=0; n<=5; j++,n++)
- {
- if (n==5)
- {
- slayout[n]='\0'; /*cut string */
- if (strcmp(slayout,"COMPA")==0)
- pack->layout=H5D_COMPACT;
- else if (strcmp(slayout,"CONTI")==0)
- pack->layout=H5D_CONTIGUOUS;
- else if (strcmp(slayout,"CHUNK")==0)
- pack->layout=H5D_CHUNKED;
- else {
- error_msg(progname, "in parse layout, not a valid layout in <%s>\n",str);
- exit(1);
- }
- }
- else
- {
- c = str[j];
- slayout[n]=c;
- }
- } /* j */
-
-
- if ( pack->layout==H5D_CHUNKED )
- {
-
-/*-------------------------------------------------------------------------
- * get chunk info
- *-------------------------------------------------------------------------
- */
- k=0;
-
- if (j>(int)len)
- {
- if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, <%s> Chunk dimensions missing\n",str);
- exit(1);
- }
-
- for ( i=j, c_index=0; i<len; i++)
- {
- c = str[i];
- sdim[k]=c;
- k++; /*increment sdim index */
-
- if (!isdigit(c) && c!='x'
- && c!='N' && c!='O' && c!='N' && c!='E'
- ){
- if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, <%s> Not a valid character in <%s>\n",
- sdim,str);
- exit(1);
+ obj_list_t* obj_list=NULL;
+ unsigned i;
+ char c;
+ size_t len=strlen(str);
+ int j, n, k, end_obj=-1, c_index;
+ char sobj[MAX_NC_NAME];
+ char sdim[10];
+ char slayout[10];
+
+
+ memset(sdim, '\0', sizeof(sdim));
+ memset(sobj, '\0', sizeof(sobj));
+ memset(slayout, '\0', sizeof(slayout));
+
+ /* check for the end of object list and number of objects */
+ for ( i=0, n=0; i<len; i++)
+ {
+ c = str[i];
+ if ( c==':' )
+ {
+ end_obj=i;
+ }
+ if ( c==',' )
+ {
+ n++;
+ }
}
-
- if ( c=='x' || i==len-1)
+
+ if (end_obj==-1) { /* missing : chunk all */
+ options->all_layout=1;
+ }
+
+ n++;
+ obj_list=malloc(n*sizeof(obj_list_t));
+ if (obj_list==NULL)
+ {
+ error_msg(progname, "could not allocate object list\n");
+ return NULL;
+ }
+ *n_objs=n;
+
+ /* get object list */
+ for ( j=0, k=0, n=0; j<end_obj; j++,k++)
+ {
+ c = str[j];
+ sobj[k]=c;
+ if ( c==',' || j==end_obj-1)
+ {
+ if ( c==',') sobj[k]='\0'; else sobj[k+1]='\0';
+ strcpy(obj_list[n].obj,sobj);
+ memset(sobj,0,sizeof(sobj));
+ n++;
+ k=-1;
+ }
+ }
+
+ /* nothing after : */
+ if (end_obj+1==(int)len)
{
- if ( c=='x') {
- sdim[k-1]='\0';
- k=0;
- pack->chunk.chunk_lengths[c_index]=atoi(sdim);
- if (pack->chunk.chunk_lengths[c_index]==0) {
- if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, <%s> conversion to number in <%s>\n",
- sdim,str);
- exit(1);
- }
- c_index++;
- }
- else if (i==len-1) { /*no more parameters */
- sdim[k]='\0';
- k=0;
- if (strcmp(sdim,"NONE")==0)
- {
- pack->chunk.rank=-2;
- }
- else
- {
- pack->chunk.chunk_lengths[c_index]=atoi(sdim);
- if (pack->chunk.chunk_lengths[c_index]==0){
if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, <%s> conversion to number in <%s>\n",
- sdim,str);
+ error_msg(progname, "in parse layout, no characters after : in <%s>\n",str);
exit(1);
- }
- pack->chunk.rank=c_index+1;
- }
- } /*if */
- } /*if c=='x' || i==len-1 */
- } /*i*/
-
-
- } /*H5D_CHUNKED*/
-
-
- return obj_list;
+ }
+
+ /* get layout info */
+ for ( j=end_obj+1, n=0; n<=5; j++,n++)
+ {
+ if (n==5)
+ {
+ slayout[n]='\0'; /*cut string */
+ if (strcmp(slayout,"COMPA")==0)
+ pack->layout=H5D_COMPACT;
+ else if (strcmp(slayout,"CONTI")==0)
+ pack->layout=H5D_CONTIGUOUS;
+ else if (strcmp(slayout,"CHUNK")==0)
+ pack->layout=H5D_CHUNKED;
+ else {
+ error_msg(progname, "in parse layout, not a valid layout in <%s>\n",str);
+ exit(1);
+ }
+ }
+ else
+ {
+ c = str[j];
+ slayout[n]=c;
+ }
+ } /* j */
+
+
+ if ( pack->layout==H5D_CHUNKED )
+ {
+
+ /*-------------------------------------------------------------------------
+ * get chunk info
+ *-------------------------------------------------------------------------
+ */
+ k=0;
+
+ if (j>(int)len)
+ {
+ if (obj_list) free(obj_list);
+ error_msg(progname, "in parse layout, <%s> Chunk dimensions missing\n",str);
+ exit(1);
+ }
+
+ for ( i=j, c_index=0; i<len; i++)
+ {
+ c = str[i];
+ sdim[k]=c;
+ k++; /*increment sdim index */
+
+ if (!isdigit(c) && c!='x'
+ && c!='N' && c!='O' && c!='N' && c!='E'
+ ){
+ if (obj_list) free(obj_list);
+ error_msg(progname, "in parse layout, <%s> Not a valid character in <%s>\n",
+ sdim,str);
+ exit(1);
+ }
+
+ if ( c=='x' || i==len-1)
+ {
+ if ( c=='x') {
+ sdim[k-1]='\0';
+ k=0;
+ pack->chunk.chunk_lengths[c_index]=atoi(sdim);
+ if (pack->chunk.chunk_lengths[c_index]==0) {
+ if (obj_list) free(obj_list);
+ error_msg(progname, "in parse layout, <%s> conversion to number in <%s>\n",
+ sdim,str);
+ exit(1);
+ }
+ c_index++;
+ }
+ else if (i==len-1) { /*no more parameters */
+ sdim[k]='\0';
+ k=0;
+ if (strcmp(sdim,"NONE")==0)
+ {
+ pack->chunk.rank=-2;
+ }
+ else
+ {
+ pack->chunk.chunk_lengths[c_index]=atoi(sdim);
+ if (pack->chunk.chunk_lengths[c_index]==0){
+ if (obj_list) free(obj_list);
+ error_msg(progname, "in parse layout, <%s> conversion to number in <%s>\n",
+ sdim,str);
+ exit(1);
+ }
+ pack->chunk.rank=c_index+1;
+ }
+ } /*if */
+ } /*if c=='x' || i==len-1 */
+ } /*i*/
+
+
+ } /*H5D_CHUNKED*/
+
+
+ return obj_list;
}
-/*-------------------------------------------------------------------------
- * Function: parse_number
- *
- * Purpose: read a number from command line argument
- *
- * Return: number, -1 for FAIL
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September, 23, 2003
- *
- *-------------------------------------------------------------------------
- */
-
-
-int parse_number(char *str)
-{
- unsigned i;
- int n;
- char c;
- size_t len=strlen(str);
-
- for ( i=0; i<len; i++)
- {
- c = str[i];
- if (!isdigit(c)){
- return -1;
- }
- }
- str[i]='\0';
- n=atoi(str);
- return n;
-}
-
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c
index 64d1990..85af317 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -31,7 +31,7 @@
static const char* MapIdToName(hid_t refobj_id,trav_table_t *travt);
static int copy_refs_attr(hid_t loc_in, hid_t loc_out, pack_opt_t *options,
- trav_table_t *travt, hid_t fidout);
+ trav_table_t *travt, hid_t fidout);
/*-------------------------------------------------------------------------
* Function: do_copy_refobjs
diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c
index 995aca1..465fdbf 100644
--- a/tools/h5repack/h5repack_verify.c
+++ b/tools/h5repack/h5repack_verify.c
@@ -18,59 +18,202 @@
#include "h5tools_utils.h"
extern char *progname;
+static int has_layout(hid_t pid, pack_info_t *obj);
+static int has_filters(hid_t pid, hid_t tid, unsigned nfilters, filter_info_t *filter);
/*-------------------------------------------------------------------------
- * Function: has_filter
+ * Function: h5repack_verify
*
- * Purpose: verify if a filter is present in the property list DCPL_ID
+ * Purpose: verify if filters and layout in the input file match the output file
*
- * Return: 1 has, 0 does not, -1 error
+ * Return:
+ * 1 match
+ * 0 do not match
+ * -1 error
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Pedro Vicente, pvn@hdfgroup.org
*
* Date: December 19, 2003
+ * Modified: December, 19, 2007 (exactly 4 years later :-) )
+ * Separate into 3 cases
+ * 1) no filter input, get all datasets and compare DCPLs. TO DO
+ * 2) filter input on selected datasets, get each one trough OBJ and match
+ * 3) filter input on all datasets, get all objects and match
*
*-------------------------------------------------------------------------
*/
-static int
-has_filter(hid_t dcpl_id, H5Z_filter_t filtnin)
+int h5repack_verify(const char *fname,
+ pack_opt_t *options)
{
- int nfilters; /* number of filters */
- unsigned filt_flags; /* filter flags */
- H5Z_filter_t filtn; /* filter identification number */
- unsigned cd_values[20]; /* filter client data values */
- size_t cd_nelmts; /* filter client number of values */
- char f_name[256]; /* filter name */
- int have = 0; /* flag, filter is present */
- int i; /* index */
-
- /* if no information about the input filter is requested return exit */
- if(filtnin == -1)
- return 1;
-
- /* get information about filters */
- if((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
- return -1;
-
- /* if we do not have filters and the requested filter is NONE, return 1 */
- if(!nfilters && filtnin == H5Z_FILTER_NONE)
- return 1;
-
- for(i = 0; i < nfilters; i++) {
- cd_nelmts = NELMTS(cd_values);
- filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts,
- cd_values, sizeof(f_name), f_name, NULL);
-
- if(filtnin == filtn)
- have = 1;
- }
-
- return have;
+ hid_t fid; /* file ID */
+ hid_t did; /* dataset ID */
+ hid_t pid; /* dataset creation property list ID */
+ hid_t sid; /* space ID */
+ hid_t tid; /* type ID */
+ unsigned int i;
+ trav_table_t *travt = NULL;
+ int ok = 1;
+
+ /* open the file */
+ if((fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 )
+ return -1;
+
+ for(i = 0; i < options->op_tbl->nelems; i++)
+ {
+ char* name = options->op_tbl->objs[i].path;
+ pack_info_t *obj = &options->op_tbl->objs[i];
+
+ /*-------------------------------------------------------------------------
+ * open
+ *-------------------------------------------------------------------------
+ */
+ if((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
+ goto error;
+ if((sid = H5Dget_space(did)) < 0)
+ goto error;
+ if((pid = H5Dget_create_plist(did)) < 0)
+ goto error;
+ if((tid = H5Dget_type(did)) < 0)
+ goto error;
+
+ /*-------------------------------------------------------------------------
+ * filter check
+ *-------------------------------------------------------------------------
+ */
+ if(has_filters(pid, tid, obj->nfilters, obj->filter) <= 0)
+ ok = 0;
+
+
+ /*-------------------------------------------------------------------------
+ * layout check
+ *-------------------------------------------------------------------------
+ */
+ if((obj->layout != -1) && (has_layout(pid, obj) == 0))
+ ok = 0;
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if(H5Pclose(pid) < 0)
+ goto error;
+ if (H5Sclose(sid) < 0)
+ goto error;
+ if (H5Dclose(did) < 0)
+ goto error;
+ if (H5Tclose(tid) < 0)
+ goto error;
+
+ }
+
+
+ /*-------------------------------------------------------------------------
+ * check for the "all" objects option
+ *-------------------------------------------------------------------------
+ */
+
+ if(options->all_filter == 1 || options->all_layout == 1)
+ {
+
+ /* init table */
+ trav_table_init(&travt);
+
+ /* get the list of objects in the file */
+ if(h5trav_gettable(fid, travt) < 0)
+ goto error;
+
+ for(i = 0; i < travt->nobjs; i++)
+ {
+ char *name = travt->objs[i].name;
+
+ if(travt->objs[i].type == H5TRAV_TYPE_DATASET)
+ {
+
+ /*-------------------------------------------------------------------------
+ * open
+ *-------------------------------------------------------------------------
+ */
+ if((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
+ goto error;
+ if((sid = H5Dget_space(did)) < 0)
+ goto error;
+ if((pid = H5Dget_create_plist(did)) < 0)
+ goto error;
+ if((tid = H5Dget_type(did)) < 0)
+ goto error;
+
+ /*-------------------------------------------------------------------------
+ * filter check
+ *-------------------------------------------------------------------------
+ */
+ if(options->all_filter == 1)
+ {
+
+ if(has_filters(pid, tid, options->n_filter_g, options->filter_g) <= 0)
+ ok = 0;
+ }
+
+ /*-------------------------------------------------------------------------
+ * layout check
+ *-------------------------------------------------------------------------
+ */
+ if(options->all_layout == 1)
+ {
+ pack_info_t pack;
+ init_packobject(&pack);
+ pack.layout = options->layout_g;
+ pack.chunk = options->chunk_g;
+ if(has_layout(pid, &pack) == 0)
+ ok = 0;
+ }
+
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Pclose(pid) < 0)
+ goto error;
+ if (H5Sclose(sid) < 0)
+ goto error;
+ if (H5Dclose(did) < 0)
+ goto error;
+ if (H5Tclose(tid) < 0)
+ goto error;
+ } /* if */
+
+ } /* i */
+
+ /* free table */
+ trav_table_free(travt);
+ }
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5Fclose(fid) < 0)
+ return -1;
+
+ return ok;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(pid);
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Fclose(fid);
+ if (travt)
+ trav_table_free(travt);
+ } H5E_END_TRY;
+ return -1;
}
+
/*-------------------------------------------------------------------------
* Function: has_layout
*
@@ -89,358 +232,341 @@ has_filter(hid_t dcpl_id, H5Z_filter_t filtnin)
*-------------------------------------------------------------------------
*/
-int has_layout(hid_t dcpl_id,
+int has_layout(hid_t pid,
pack_info_t *obj)
{
- hsize_t chsize[64]; /* chunk size in elements */
- H5D_layout_t layout; /* layout */
- int nfilters; /* number of filters */
- int rank; /* rank */
- int i; /* index */
-
- /* if no information about the input layout is requested return exit */
- if (obj==NULL)
- return 1;
-
- /* check if we have filters in the input object */
- if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
- return -1;
-
- /* a non chunked layout was requested on a filtered object; avoid the test */
- if (nfilters && obj->layout!=H5D_CHUNKED)
- return 1;
-
- /* get layout */
- if ((layout = H5Pget_layout(dcpl_id)) < 0)
- return -1;
-
- if (obj->layout != layout)
- return 0;
-
- if (layout==H5D_CHUNKED)
- {
- if ((rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize/*out*/)) < 0)
- return -1;
- if (obj->chunk.rank != rank)
- return 0;
- for ( i=0; i<rank; i++)
- if (chsize[i] != obj->chunk.chunk_lengths[i])
- return 0;
- }
-
- return 1;
+ hsize_t chsize[64]; /* chunk size in elements */
+ H5D_layout_t layout; /* layout */
+ int nfilters; /* number of filters */
+ int rank; /* rank */
+ int i; /* index */
+
+ /* if no information about the input layout is requested return exit */
+ if (obj==NULL)
+ return 1;
+
+ /* check if we have filters in the input object */
+ if ((nfilters = H5Pget_nfilters(pid)) < 0)
+ return -1;
+
+ /* a non chunked layout was requested on a filtered object; avoid the test */
+ if (nfilters && obj->layout!=H5D_CHUNKED)
+ return 1;
+
+ /* get layout */
+ if ((layout = H5Pget_layout(pid)) < 0)
+ return -1;
+
+ if (obj->layout != layout)
+ return 0;
+
+ if (layout==H5D_CHUNKED)
+ {
+ if ((rank = H5Pget_chunk(pid,NELMTS(chsize),chsize/*out*/)) < 0)
+ return -1;
+ if (obj->chunk.rank != rank)
+ return 0;
+ for ( i=0; i<rank; i++)
+ if (chsize[i] != obj->chunk.chunk_lengths[i])
+ return 0;
+ }
+
+ return 1;
}
-
/*-------------------------------------------------------------------------
- * Function: h5repack_verify
+ * Function: h5repack_cmpdcpl
*
- * Purpose: verify if the filters specified in the options list are
- * present on the OUTPUT file
+ * Purpose: compare 2 files for identical property lists of all objects
*
- * Return: 1=filter present, 0=filter not present, -1=error
+ * Return: 1=identical, 0=not identical, -1=error
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
- * Date: December 19, 2003
+ * Date: December 31, 2003
*
*-------------------------------------------------------------------------
*/
-int h5repack_verify(const char *fname,
- pack_opt_t *options)
+int h5repack_cmpdcpl(const char *fname1,
+ const char *fname2)
{
- hid_t fid; /* file ID */
- hid_t dset_id = -1; /* dataset ID */
- hid_t dcpl_id = -1; /* dataset creation property list ID */
- hid_t space_id = -1; /* space ID */
- int ret = 1;
- unsigned int i;
- int j;
- trav_table_t *travt = NULL;
-
- /* open the file */
- if((fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 )
- return -1;
-
- for(i = 0; i < options->op_tbl->nelems; i++) {
- char* name = options->op_tbl->objs[i].path;
- pack_info_t *obj = &options->op_tbl->objs[i];
-
-/*-------------------------------------------------------------------------
- * open
- *-------------------------------------------------------------------------
- */
- if((dset_id = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
- goto error;
- if((space_id = H5Dget_space(dset_id)) < 0)
- goto error;
- if((dcpl_id = H5Dget_create_plist(dset_id)) < 0)
- goto error;
-
-/*-------------------------------------------------------------------------
- * filter check
- *-------------------------------------------------------------------------
- */
- for(j = 0; j < obj->nfilters; j++) {
- if(has_filter(dcpl_id, obj->filter[j].filtn) == 0)
- ret = 0;
- }
-
-/*-------------------------------------------------------------------------
- * layout check
- *-------------------------------------------------------------------------
- */
- if((obj->layout != -1) && (has_layout(dcpl_id, obj) == 0))
- ret = 0;
-
-/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Pclose(dcpl_id) < 0)
- goto error;
- if (H5Sclose(space_id) < 0)
- goto error;
- if (H5Dclose(dset_id) < 0)
- goto error;
-
- }
-
-
-/*-------------------------------------------------------------------------
- * check for the "all" objects option
- *-------------------------------------------------------------------------
- */
-
- if(options->all_filter == 1 || options->all_layout == 1) {
-
- /* init table */
- trav_table_init(&travt);
-
- /* get the list of objects in the file */
- if(h5trav_gettable(fid, travt) < 0)
- goto error;
-
- for(i = 0; i < travt->nobjs; i++) {
- char *name = travt->objs[i].name;
-
- if(travt->objs[i].type == H5TRAV_TYPE_DATASET) {
-
- /*-------------------------------------------------------------------------
- * open
- *-------------------------------------------------------------------------
- */
- if((dset_id = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
- goto error;
- if((space_id = H5Dget_space(dset_id)) < 0)
- goto error;
- if((dcpl_id = H5Dget_create_plist(dset_id)) < 0)
- goto error;
-
- /*-------------------------------------------------------------------------
- * filter check
- *-------------------------------------------------------------------------
- */
- if(options->all_filter == 1)
- if(has_filter(dcpl_id, options->filter_g.filtn) == 0)
- ret = 0;
-
- /*-------------------------------------------------------------------------
- * layout check
- *-------------------------------------------------------------------------
- */
- if(options->all_layout == 1) {
- pack_info_t pack;
- init_packobject(&pack);
- pack.layout = options->layout_g;
- pack.chunk = options->chunk_g;
- if(has_layout(dcpl_id, &pack) == 0)
- ret = 0;
- }
-
-
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if (H5Pclose(dcpl_id) < 0)
- goto error;
- if (H5Sclose(space_id) < 0)
- goto error;
- if (H5Dclose(dset_id) < 0)
- goto error;
- } /* if */
-
- } /* i */
-
- /* free table */
- trav_table_free(travt);
- }
-
-/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
-
- if (H5Fclose(fid) < 0)
- return -1;
-
- return ret;
-
+ hid_t fid1=-1; /* file ID */
+ hid_t fid2=-1; /* file ID */
+ hid_t dset1=-1; /* dataset ID */
+ hid_t dset2=-1; /* dataset ID */
+ hid_t dcpl1=-1; /* dataset creation property list ID */
+ hid_t dcpl2=-1; /* dataset creation property list ID */
+ trav_table_t *travt1=NULL;
+ trav_table_t *travt2=NULL;
+ int ret=1;
+ unsigned int i;
+
+ /*-------------------------------------------------------------------------
+ * open the files
+ *-------------------------------------------------------------------------
+ */
+
+ /* disable error reporting */
+ H5E_BEGIN_TRY
+ {
+
+ /* Open the files */
+ if ((fid1=H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
+ {
+ error_msg(progname, "<%s>: %s\n", fname1, H5FOPENERROR );
+ return -1;
+ }
+ if ((fid2=H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
+ {
+ error_msg(progname, "<%s>: %s\n", fname2, H5FOPENERROR );
+ H5Fclose(fid1);
+ return -1;
+ }
+ /* enable error reporting */
+ } H5E_END_TRY;
+
+ /*-------------------------------------------------------------------------
+ * get file table list of objects
+ *-------------------------------------------------------------------------
+ */
+ trav_table_init(&travt1);
+ trav_table_init(&travt2);
+ if(h5trav_gettable(fid1, travt1) < 0)
+ goto error;
+ if(h5trav_gettable(fid2, travt2) < 0)
+ goto error;
+
+
+ /*-------------------------------------------------------------------------
+ * traverse the suppplied object list
+ *-------------------------------------------------------------------------
+ */
+
+ for(i = 0; i < travt1->nobjs; i++)
+ {
+ if(travt1->objs[i].type == H5TRAV_TYPE_DATASET)
+ {
+ if((dset1 = H5Dopen2(fid1, travt1->objs[i].name, H5P_DEFAULT)) < 0)
+ goto error;
+ if((dset2 = H5Dopen2(fid2, travt1->objs[i].name, H5P_DEFAULT)) < 0)
+ goto error;
+ if((dcpl1 = H5Dget_create_plist(dset1)) < 0)
+ goto error;
+ if((dcpl2 = H5Dget_create_plist(dset2)) < 0)
+ goto error;
+
+ /*-------------------------------------------------------------------------
+ * compare the property lists
+ *-------------------------------------------------------------------------
+ */
+ if((ret = H5Pequal(dcpl1, dcpl2)) < 0)
+ goto error;
+
+ if(ret == 0)
+ {
+ error_msg(progname, "property lists for <%s> are different\n",travt1->objs[i].name);
+ goto error;
+ }
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if(H5Pclose(dcpl1) < 0)
+ goto error;
+ if(H5Pclose(dcpl2) < 0)
+ goto error;
+ if(H5Dclose(dset1) < 0)
+ goto error;
+ if(H5Dclose(dset2) < 0)
+ goto error;
+ } /*if*/
+ } /*i*/
+
+ /*-------------------------------------------------------------------------
+ * free
+ *-------------------------------------------------------------------------
+ */
+
+ trav_table_free(travt1);
+ trav_table_free(travt2);
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+
+ H5Fclose(fid1);
+ H5Fclose(fid2);
+ return ret;
+
+ /*-------------------------------------------------------------------------
+ * error
+ *-------------------------------------------------------------------------
+ */
+
error:
- H5E_BEGIN_TRY {
- H5Pclose(dcpl_id);
- H5Sclose(space_id);
- H5Dclose(dset_id);
- H5Fclose(fid);
- if (travt)
- trav_table_free(travt);
- } H5E_END_TRY;
- return -1;
+ H5E_BEGIN_TRY
+ {
+ H5Pclose(dcpl1);
+ H5Pclose(dcpl2);
+ H5Dclose(dset1);
+ H5Dclose(dset2);
+ H5Fclose(fid1);
+ H5Fclose(fid2);
+ trav_table_free(travt1);
+ trav_table_free(travt2);
+ } H5E_END_TRY;
+ return -1;
+
}
-
/*-------------------------------------------------------------------------
- * Function: h5repack_cmpdcpl
+ * Function: has_filters
*
- * Purpose: compare 2 files for identical property lists of all objects
+ * Purpose: verify if all requested filters in the array FILTER obtained
+ * from user input are present in the property list PID obtained from
+ * the output file
*
- * Return: 1=identical, 0=not identical, -1=error
+ * Return:
+ * 1 match
+ * 0 do not match
+ * -1 error
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Pedro Vicente, pvn@hdfgroup.org
*
- * Date: December 31, 2003
+ * Date: December 21, 2007
*
*-------------------------------------------------------------------------
*/
-int h5repack_cmpdcpl(const char *fname1,
- const char *fname2)
+static int has_filters(hid_t pid, hid_t tid, unsigned nfilters, filter_info_t *filter)
{
- hid_t fid1=-1; /* file ID */
- hid_t fid2=-1; /* file ID */
- hid_t dset1=-1; /* dataset ID */
- hid_t dset2=-1; /* dataset ID */
- hid_t dcpl1=-1; /* dataset creation property list ID */
- hid_t dcpl2=-1; /* dataset creation property list ID */
- trav_table_t *travt1=NULL;
- trav_table_t *travt2=NULL;
- int ret=1;
- unsigned int i;
-
-/*-------------------------------------------------------------------------
- * open the files first; if they are not valid, no point in continuing
- *-------------------------------------------------------------------------
- */
-
- /* disable error reporting */
- H5E_BEGIN_TRY {
-
- /* Open the files */
- if ((fid1=H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
- {
- error_msg(progname, "<%s>: %s\n", fname1, H5FOPENERROR );
- return -1;
- }
- if ((fid2=H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
- {
- error_msg(progname, "<%s>: %s\n", fname2, H5FOPENERROR );
- H5Fclose(fid1);
- return -1;
- }
- /* enable error reporting */
- } H5E_END_TRY;
-
-/*-------------------------------------------------------------------------
- * get file table list of objects
- *-------------------------------------------------------------------------
- */
- trav_table_init(&travt1);
- trav_table_init(&travt2);
- if(h5trav_gettable(fid1, travt1) < 0)
- goto error;
- if(h5trav_gettable(fid2, travt2) < 0)
- goto error;
-
-
-/*-------------------------------------------------------------------------
- * traverse the suppplied object list
- *-------------------------------------------------------------------------
- */
-
- for(i = 0; i < travt1->nobjs; i++) {
- if(travt1->objs[i].type == H5TRAV_TYPE_DATASET) {
- if((dset1 = H5Dopen2(fid1, travt1->objs[i].name, H5P_DEFAULT)) < 0)
- goto error;
- if((dset2 = H5Dopen2(fid2, travt1->objs[i].name, H5P_DEFAULT)) < 0)
- goto error;
- if((dcpl1 = H5Dget_create_plist(dset1)) < 0)
- goto error;
- if((dcpl2 = H5Dget_create_plist(dset2)) < 0)
- goto error;
-
-/*-------------------------------------------------------------------------
- * compare the property lists
- *-------------------------------------------------------------------------
- */
- if((ret = H5Pequal(dcpl1, dcpl2)) < 0)
- goto error;
-
- if(ret == 0) {
- error_msg(progname, "property lists for <%s> are different\n",travt1->objs[i].name);
- goto error;
- }
-
-/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Pclose(dcpl1) < 0)
- goto error;
- if(H5Pclose(dcpl2) < 0)
- goto error;
- if(H5Dclose(dset1) < 0)
- goto error;
- if(H5Dclose(dset2) < 0)
- goto error;
- } /*if*/
- } /*i*/
-
-/*-------------------------------------------------------------------------
- * free
- *-------------------------------------------------------------------------
- */
-
- trav_table_free(travt1);
- trav_table_free(travt2);
-
-/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
-
- H5Fclose(fid1);
- H5Fclose(fid2);
- return ret;
-
-/*-------------------------------------------------------------------------
- * error
- *-------------------------------------------------------------------------
- */
-
-error:
- H5E_BEGIN_TRY {
- H5Pclose(dcpl1);
- H5Pclose(dcpl2);
- H5Dclose(dset1);
- H5Dclose(dset2);
- H5Fclose(fid1);
- H5Fclose(fid2);
- trav_table_free(travt1);
- trav_table_free(travt2);
- } H5E_END_TRY;
- return -1;
+ unsigned nfilters_dcpl; /* number of filters in DCPL*/
+ unsigned filt_flags; /* filter flags */
+ H5Z_filter_t filtn; /* filter identification number */
+ unsigned cd_values[20]; /* filter client data values */
+ size_t cd_nelmts; /* filter client number of values */
+ char f_name[256]; /* filter name */
+ size_t size; /* type size */
+ unsigned i, j; /* index */
+
+ /* get information about filters */
+ if((nfilters_dcpl = H5Pget_nfilters(pid)) < 0)
+ return -1;
+
+ /* if we do not have filters and the requested filter is NONE, return 1 */
+ if(!nfilters_dcpl &&
+ nfilters == 1 &&
+ filter[0].filtn == H5Z_FILTER_NONE )
+ return 1;
+
+ /* else the numbers of filters must match */
+ if (nfilters_dcpl != nfilters )
+ return 0;
+
+ /*-------------------------------------------------------------------------
+ * build a list with DCPL filters
+ *-------------------------------------------------------------------------
+ */
+
+ for( i = 0; i < nfilters_dcpl; i++)
+ {
+ cd_nelmts = NELMTS(cd_values);
+ filtn = H5Pget_filter2(pid, i, &filt_flags, &cd_nelmts,
+ cd_values, sizeof(f_name), f_name, NULL);
+
+ /* filter ID */
+ if (filtn != filter[i].filtn)
+ return 0;
+
+ /* compare client data values. some filters do return local values */
+ switch (filtn)
+ {
+
+ case H5Z_FILTER_SHUFFLE:
+
+ /* 1 private client value is returned by DCPL */
+ if ( cd_nelmts != H5Z_SHUFFLE_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SHUFFLE_USER_NPARMS )
+ return 0;
+
+ /* get dataset's type size */
+ if((size = H5Tget_size(tid)) <= 0)
+ return -1;
+
+ /* the private client value holds the dataset's type size */
+ if ( size != cd_values[0] )
+ return 0;
+
+
+ break;
+
+ case H5Z_FILTER_SZIP:
+
+ /* 4 private client values are returned by DCPL */
+ if ( cd_nelmts != H5Z_SZIP_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SZIP_USER_NPARMS )
+ return 0;
+
+ /* "User" parameter for pixels-per-block (index 1) */
+ if ( cd_values[H5Z_SZIP_PARM_PPB] != filter[i].cd_values[H5Z_SZIP_PARM_PPB] )
+ return 0;
+
+
+ break;
+
+ case H5Z_FILTER_NBIT:
+
+ /* only client data values number of values checked */
+ if ( H5Z_NBIT_USER_NPARMS != filter[i].cd_nelmts)
+ return 0;
+
+
+
+ break;
+
+ case H5Z_FILTER_SCALEOFFSET:
+
+ /* only client data values checked */
+ for( j = 0; j < H5Z_SCALEOFFSET_USER_NPARMS; j++)
+ {
+ if (cd_values[j] != filter[i].cd_values[j])
+ {
+ return 0;
+ }
+
+ }
+
+
+ break;
+
+ /* for these filters values must match, no local values set in DCPL */
+ case H5Z_FILTER_FLETCHER32:
+ case H5Z_FILTER_DEFLATE:
+
+ if ( cd_nelmts != filter[i].cd_nelmts)
+ return 0;
+
+ for( j = 0; j < cd_nelmts; j++)
+ {
+ if (cd_values[j] != filter[i].cd_values[j])
+ {
+ return 0;
+ }
+
+ }
+
+
+
+ break;
+
+
+
+ } /* switch */
+ }
+
+ return 1;
}
+
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c
index 0e99d4f..99448c4 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -896,6 +896,8 @@ if (szip_can_encode) {
GOERROR;
if (h5repack_verify(FNAME7OUT,&pack_options)<=0)
GOERROR;
+ if (h5repack_cmpdcpl(FNAME7,FNAME7OUT)<=0)
+ GOERROR;
if (h5repack_end (&pack_options) < 0)
GOERROR;
@@ -1097,6 +1099,7 @@ if (szip_can_encode) {
SKIPPED();
#endif
+
TESTING(" adding nbit filter");
#ifdef H5_HAVE_FILTER_NBIT
@@ -1117,6 +1120,8 @@ if (szip_can_encode) {
#else
SKIPPED();
#endif
+
+
TESTING(" copy of scaleoffset filter");
#ifdef H5_HAVE_FILTER_SCALEOFFSET
@@ -1179,6 +1184,8 @@ if (szip_can_encode) {
SKIPPED();
#endif
+
+
/*-------------------------------------------------------------------------
* file with all filters
* dset_all
@@ -1355,6 +1362,36 @@ if (szip_can_encode) {
/*-------------------------------------------------------------------------
+ * test several global filters
+ *-------------------------------------------------------------------------
+ */
+
+ TESTING(" several global filters");
+
+#if defined (H5_HAVE_FILTER_DEFLATE) && defined (H5_HAVE_FILTER_SHUFFLE)
+
+ if (h5repack_init (&pack_options, 0) < 0)
+ GOERROR;
+ if (h5repack_addfilter("GZIP=1",&pack_options) < 0)
+ GOERROR;
+ if (h5repack_addfilter("SHUF",&pack_options) < 0)
+ GOERROR;
+ if (h5repack(FNAME11,FNAME11OUT,&pack_options) < 0)
+ GOERROR;
+ if (h5diff(FNAME11,FNAME11OUT,NULL,NULL,&diff_options) >0)
+ GOERROR;
+ if (h5repack_verify(FNAME11OUT,&pack_options)<=0)
+ GOERROR;
+ if (h5repack_end (&pack_options) < 0)
+ GOERROR;
+
+ PASSED();
+#else
+ SKIPPED();
+#endif
+
+
+/*-------------------------------------------------------------------------
* clean temporary test files
*-------------------------------------------------------------------------
*/
diff --git a/tools/h5stat/Makefile.in b/tools/h5stat/Makefile.in
index 33a3060..28106c4 100644
--- a/tools/h5stat/Makefile.in
+++ b/tools/h5stat/Makefile.in
@@ -213,6 +213,7 @@ SET_MAKE = @SET_MAKE@
SHELL = /bin/sh
SIZE_T = @SIZE_T@
STATIC_SHARED = @STATIC_SHARED@
+STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
TESTPARALLEL = @TESTPARALLEL@
TIME = @TIME@
diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c
index c69d801..f03efd7 100644
--- a/tools/h5stat/h5stat.c
+++ b/tools/h5stat/h5stat.c
@@ -47,8 +47,7 @@ typedef struct ohdr_info_t {
/* Info to pass to the iteration functions */
typedef struct iter_t {
- const char *container; /* Full name of the container object */
- unsigned long curr_depth; /* Current depth of hierarchy */
+ hid_t fid; /* File ID */
unsigned long uniq_groups; /* Number of unique groups */
unsigned long uniq_dsets; /* Number of unique datasets */
@@ -56,7 +55,6 @@ typedef struct iter_t {
unsigned long uniq_links; /* Number of unique links */
unsigned long uniq_others; /* Number of other unique objects */
- unsigned long max_depth; /* Maximum depth of hierarchy */
unsigned long max_links; /* Maximum # of links to an object */
hsize_t max_fanout; /* Maximum fanout from a group */
unsigned long num_small_groups[SIZE_SMALL_GROUPS]; /* Size of small groups tracked */
@@ -95,16 +93,6 @@ typedef struct iter_t {
} iter_t;
-/* Table containing object id and object name */
-static struct {
- int nalloc; /* number of slots allocated */
- int nobjs; /* number of objects */
- struct {
- haddr_t id; /* object number */
- char *name; /* full object name */
- } *obj;
-} idtab_g;
-
const char *progname = "h5stat";
int d_status = EXIT_SUCCESS;
static int display_all = TRUE;
@@ -260,123 +248,6 @@ ceil_log10(unsigned long x)
/*-------------------------------------------------------------------------
- * Function: sym_insert
- *
- * Purpose: Add a symbol to the table.
- *
- * Return: void
- *
- * Programmer: Robb Matzke
- * Thursday, January 21, 1999
- *
- *-------------------------------------------------------------------------
- */
-static void
-sym_insert(H5O_info_t *oi, const char *name)
-{
- /* Don't add it if the link count is 1 because such an object can only
- * have one name. */
- if(oi->rc > 1) {
- int n;
-
- /* Extend the table */
- if(idtab_g.nobjs >= idtab_g.nalloc) {
- idtab_g.nalloc = MAX(256, 2 * idtab_g.nalloc);
- idtab_g.obj = realloc(idtab_g.obj, idtab_g.nalloc * sizeof(idtab_g.obj[0]));
- } /* end if */
-
- /* Insert the entry */
- n = idtab_g.nobjs++;
- idtab_g.obj[n].id = oi->addr;
- idtab_g.obj[n].name = strdup(name);
- } /* end if */
-} /* end sym_insert() */
-
-
-/*-------------------------------------------------------------------------
- * Function: sym_lookup
- *
- * Purpose: Find another name for the specified object.
- *
- * Return: Success: Ptr to another name.
- *
- * Failure: NULL
- *
- * Programmer: Robb Matzke
- * Thursday, January 21, 1999
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static char *
-sym_lookup(H5O_info_t *oi)
-{
- int n;
-
- /*only one name possible*/
- if(oi->rc < 2)
- return NULL;
-
- for(n = 0; n < idtab_g.nobjs; n++)
- if(idtab_g.obj[n].id == oi->addr)
- return idtab_g.obj[n].name;
-
- return NULL;
-} /* end sym_lookup() */
-
-
-/*-------------------------------------------------------------------------
- * Function: fix_name
- *
- * Purpose: Returns a malloc'd buffer that contains the PATH and BASE
- * names separated by a single slash. It also removes duplicate
- * and trailing slashes.
- *
- * Return: Success: Ptr to fixed name from malloc()
- *
- * Failure: NULL
- *
- * Programmer: Robb Matzke
- * Thursday, January 21, 1999
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static char *
-fix_name(const char *path, const char *base)
-{
- size_t n = (path ? strlen(path) : 0) + (base ? strlen(base) : 0) + 3;
- char *s = malloc(n), prev='\0';
- size_t len = 0;
-
- if (path) {
- /* Path, followed by slash */
- for (/*void*/; *path; path++)
- if ('/'!=*path || '/'!=prev)
- prev = s[len++] = *path;
- if ('/' != prev)
- prev = s[len++] = '/';
- }
-
- if (base) {
- /* Base name w/o trailing slashes */
- const char *end = base + strlen(base);
- while (end > base && '/' == end[-1])
- --end;
-
- for (/*void*/; base < end; base++)
- if ('/' != *base || '/' != prev)
- prev = s[len++] = *base;
- }
-
- s[len] = '\0';
- return s;
-}
-
-
-/*-------------------------------------------------------------------------
* Function: attribute_stats
*
* Purpose: Gather statistics about attributes on an object
@@ -453,25 +324,21 @@ attribute_stats(iter_t *iter, const H5O_info_t *oi)
*-------------------------------------------------------------------------
*/
static herr_t
-group_stats(hid_t group, const char *name, const char *fullname,
- const H5O_info_t *oi, H5L_iterate_t walk, iter_t *iter)
+group_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
{
- const char *last_container;
H5G_info_t ginfo; /* Group information */
unsigned bin; /* "bin" the number of objects falls in */
herr_t ret;
/* Gather statistics about this type of object */
iter->uniq_groups++;
- if(iter->curr_depth > iter->max_depth)
- iter->max_depth = iter->curr_depth;
/* Get object header information */
iter->group_ohdr_info.total_size += oi->hdr.space.total;
iter->group_ohdr_info.free_size += oi->hdr.space.free;
/* Get group information */
- ret = H5Gget_info_by_name(group, name, &ginfo, H5P_DEFAULT);
+ ret = H5Gget_info_by_name(iter->fid, name, &ginfo, H5P_DEFAULT);
assert(ret >= 0);
/* Update link stats */
@@ -506,18 +373,6 @@ group_stats(hid_t group, const char *name, const char *fullname,
ret = attribute_stats(iter, oi);
assert(ret >= 0);
- /* Update current container info */
- last_container = iter->container;
- iter->container = fullname;
- iter->curr_depth++;
-
- /* Recursively descend into current group's objects */
- H5Literate_by_name(group, name, H5_INDEX_NAME, H5_ITER_INC, NULL, walk, iter, H5P_DEFAULT);
-
- /* Revert current container info */
- iter->container = last_container;
- iter->curr_depth--;
-
return 0;
} /* end group_stats() */
@@ -549,7 +404,7 @@ group_stats(hid_t group, const char *name, const char *fullname,
*-------------------------------------------------------------------------
*/
static herr_t
-dataset_stats(hid_t group, const char *name, const H5O_info_t *oi, iter_t *iter)
+dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
{
unsigned bin; /* "bin" the number of objects falls in */
hid_t did; /* Dataset ID */
@@ -575,7 +430,7 @@ dataset_stats(hid_t group, const char *name, const H5O_info_t *oi, iter_t *iter)
iter->dset_ohdr_info.total_size += oi->hdr.space.total;
iter->dset_ohdr_info.free_size += oi->hdr.space.free;
- did = H5Dopen2(group, name, H5P_DEFAULT);
+ did = H5Dopen2(iter->fid, name, H5P_DEFAULT);
assert(did > 0);
/* Update dataset metadata info */
@@ -710,89 +565,90 @@ dataset_stats(hid_t group, const char *name, const H5O_info_t *oi, iter_t *iter)
/*-------------------------------------------------------------------------
- * Function: walk
+ * Function: obj_stats
*
- * Purpose: Gather statistics about the file
+ * Purpose: Gather statistics about an object
*
* Return: Success: 0
- * Failure: -1
*
- * Programmer: Quincey Koziol
- * Tuesday, August 16, 2005
+ * Failure: -1
*
- * Modifications:
+ * Programmer: Quincey Koziol
+ * Tuesday, November 6, 2007
*
*-------------------------------------------------------------------------
*/
static herr_t
-walk(hid_t group, const char *name, const H5L_info_t *linfo, void *_iter)
+obj_stats(const char *path, const H5O_info_t *oi, const char *already_visited,
+ void *_iter)
{
iter_t *iter = (iter_t *)_iter;
- char *fullname = NULL;
- herr_t ret; /* Generic return value */
-
- if(!linfo || linfo->type == H5L_TYPE_HARD) {
- H5O_info_t oi;
- char *s;
-
- /* Get object information */
- ret = H5Oget_info_by_name(group, name, &oi, H5P_DEFAULT);
- assert(ret >= 0);
-
- /* If the object has already been printed then just show the object ID
- * and return. */
- if((s = sym_lookup(&oi))) {
- printf("%s same as %s\n", name, s);
- } else {
- /* Get the full object name */
- fullname = fix_name(iter->container, name);
- sym_insert(&oi, fullname);
-
- /* Gather some statistics about the object */
- if(oi.rc > iter->max_links)
- iter->max_links = oi.rc;
-
- switch(oi.type) {
- case H5O_TYPE_GROUP:
- group_stats(group, name, fullname, &oi, walk, iter);
- break;
-
- case H5O_TYPE_DATASET:
- dataset_stats(group, name, &oi, iter);
- break;
-
- case H5O_TYPE_NAMED_DATATYPE:
- /* Gather statistics about this type of object */
- iter->uniq_types++;
- break;
-
- default:
- /* Gather statistics about this type of object */
- iter->uniq_others++;
- break;
- } /* end switch */
- }
- } /* end if */
- else {
- switch(linfo->type) {
- case H5L_TYPE_SOFT:
- case H5L_TYPE_EXTERNAL:
- /* Gather statistics about links and UD links */
- iter->uniq_links++;
+
+ /* If the object has already been seen then just return */
+ if(NULL == already_visited) {
+ /* Gather some general statistics about the object */
+ if(oi->rc > iter->max_links)
+ iter->max_links = oi->rc;
+
+ switch(oi->type) {
+ case H5O_TYPE_GROUP:
+ group_stats(iter, path, oi);
+ break;
+
+ case H5O_TYPE_DATASET:
+ dataset_stats(iter, path, oi);
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ /* Gather statistics about this type of object */
+ iter->uniq_types++;
break;
default:
/* Gather statistics about this type of object */
iter->uniq_others++;
break;
- } /* end switch() */
- } /* end else */
+ } /* end switch */
+ } /* end if */
- if(fullname)
- free(fullname);
+ return 0;
+} /* end obj_stats() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: lnk_stats
+ *
+ * Purpose: Gather statistics about a link
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 6, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+lnk_stats(const char UNUSED *path, const H5L_info_t *li, void *_iter)
+{
+ iter_t *iter = (iter_t *)_iter;
+
+ switch(li->type) {
+ case H5L_TYPE_SOFT:
+ case H5L_TYPE_EXTERNAL:
+ /* Gather statistics about links and UD links */
+ iter->uniq_links++;
+ break;
+
+ default:
+ /* Gather statistics about this type of object */
+ iter->uniq_others++;
+ break;
+ } /* end switch() */
return 0;
-}
+} /* end lnk_stats() */
/*-------------------------------------------------------------------------
@@ -915,13 +771,13 @@ parse_command_line(int argc, const char *argv[])
*-------------------------------------------------------------------------
*/
static herr_t
-iter_init(iter_t *iter)
+iter_init(iter_t *iter, hid_t fid)
{
/* Clear everything to zeros */
- memset(iter, 0, sizeof(*iter));
+ HDmemset(iter, 0, sizeof(*iter));
- /* Initialize non-zero information */
- iter->container = "/";
+ /* Set the file ID for later use in callbacks */
+ iter->fid = fid;
return 0;
}
@@ -953,7 +809,6 @@ print_file_info(const iter_t *iter)
printf("\t# of unique links: %lu\n", iter->uniq_links);
printf("\t# of unique other: %lu\n", iter->uniq_others);
printf("\tMax. # of links to object: %lu\n", iter->max_links);
- printf("\tMax. depth of hierarchy: %lu\n", iter->max_depth);
HDfprintf(stdout, "\tMax. # of objects in group: %Hu\n", iter->max_fanout);
return 0;
@@ -1318,8 +1173,6 @@ main(int argc, const char *argv[])
const char *fname = NULL;
hid_t fid;
struct handler_t *hand;
- char root[] = "/";
- int i;
H5F_info_t finfo;
@@ -1329,25 +1182,23 @@ main(int argc, const char *argv[])
/* Initialize h5tools lib */
h5tools_init();
hand = parse_command_line (argc, argv);
- if (!hand) {
+ if(!hand) {
error_msg(progname, "unable to parse command line arguments \n");
leave(EXIT_FAILURE);
- }
+ } /* end if */
fname = argv[opt_ind];
- if(!display_object)
- hand[0].obj = root;
printf("Filename: %s\n", fname);
fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT);
- if (fid < 0) {
+ if(fid < 0) {
error_msg(progname, "unable to open file \"%s\"\n", fname);
leave(EXIT_FAILURE);
- }
+ } /* end if */
/* Initialize iter structure */
- iter_init(&iter);
+ iter_init(&iter, fid);
/* Get storge info for SOHM's btree/list/heap and superblock extension */
if(H5Fget_info(fid, &finfo) < 0)
@@ -1357,15 +1208,23 @@ main(int argc, const char *argv[])
iter.SM_hdr_storage_size = finfo.sohm.hdr_size;
iter.SM_index_storage_size = finfo.sohm.msgs_info.index_size;
iter.SM_heap_storage_size = finfo.sohm.msgs_info.heap_size;
- }
+ } /* end else */
/* Walk the objects or all file */
- i = 0;
- while(hand[i].obj) {
- walk(fid, hand[i].obj, NULL, &iter);
- print_statistics(hand[i].obj, &iter);
- i++;
- } /* end while */
+ if(display_object) {
+ unsigned u;
+
+ u = 0;
+ while(hand[u].obj) {
+ h5trav_visit(fid, hand[u].obj, TRUE, TRUE, obj_stats, lnk_stats, &iter);
+ print_statistics(hand[u].obj, &iter);
+ u++;
+ } /* end while */
+ } /* end if */
+ else {
+ h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter);
+ print_statistics("/", &iter);
+ } /* end else */
free(hand);
diff --git a/tools/h5stat/h5stat_gentest.c b/tools/h5stat/h5stat_gentest.c
index 22396b6..28d20ce 100644
--- a/tools/h5stat/h5stat_gentest.c
+++ b/tools/h5stat/h5stat_gentest.c
@@ -46,7 +46,7 @@ static void gen_file(void)
char attrname[30];
fapl = H5Pcreate(H5P_FILE_ACCESS);
- ret = H5Pset_latest_format(fapl, 1);
+ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
/* Create dataset */
file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
diff --git a/tools/h5stat/testfiles/h5stat_filters-file.ddl b/tools/h5stat/testfiles/h5stat_filters-file.ddl
index c6aeef0..7b8f47f 100644
--- a/tools/h5stat/testfiles/h5stat_filters-file.ddl
+++ b/tools/h5stat/testfiles/h5stat_filters-file.ddl
@@ -9,5 +9,4 @@ File information
# of unique links: 0
# of unique other: 0
Max. # of links to object: 1
- Max. depth of hierarchy: 0
Max. # of objects in group: 16
diff --git a/tools/h5stat/testfiles/h5stat_filters.ddl b/tools/h5stat/testfiles/h5stat_filters.ddl
index 4dd6aee..df2e304 100644
--- a/tools/h5stat/testfiles/h5stat_filters.ddl
+++ b/tools/h5stat/testfiles/h5stat_filters.ddl
@@ -9,7 +9,6 @@ File information
# of unique links: 0
# of unique other: 0
Max. # of links to object: 1
- Max. depth of hierarchy: 0
Max. # of objects in group: 16
Object header size: (total/unused)
Groups: 48/8
diff --git a/tools/h5stat/testfiles/h5stat_newgrat.ddl b/tools/h5stat/testfiles/h5stat_newgrat.ddl
index 228d565..6881ca9 100644
--- a/tools/h5stat/testfiles/h5stat_newgrat.ddl
+++ b/tools/h5stat/testfiles/h5stat_newgrat.ddl
@@ -9,7 +9,6 @@ File information
# of unique links: 0
# of unique other: 0
Max. # of links to object: 1
- Max. depth of hierarchy: 1
Max. # of objects in group: 351
Object header size: (total/unused)
Groups: 51597/32292
diff --git a/tools/h5stat/testfiles/h5stat_tsohm.ddl b/tools/h5stat/testfiles/h5stat_tsohm.ddl
index 572965e..15a058e 100644
--- a/tools/h5stat/testfiles/h5stat_tsohm.ddl
+++ b/tools/h5stat/testfiles/h5stat_tsohm.ddl
@@ -9,7 +9,6 @@ File information
# of unique links: 0
# of unique other: 0
Max. # of links to object: 1
- Max. depth of hierarchy: 0
Max. # of objects in group: 2
Object header size: (total/unused)
Groups: 51/2
diff --git a/tools/lib/Makefile.in b/tools/lib/Makefile.in
index 8de1275..ab8643d 100644
--- a/tools/lib/Makefile.in
+++ b/tools/lib/Makefile.in
@@ -209,6 +209,7 @@ SET_MAKE = @SET_MAKE@
SHELL = /bin/sh
SIZE_T = @SIZE_T@
STATIC_SHARED = @STATIC_SHARED@
+STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
TESTPARALLEL = @TESTPARALLEL@
TIME = @TIME@
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index 4a6a8cd..4f4074f 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -810,7 +810,7 @@ hsize_t diff(hid_t file1_id,
/*-------------------------------------------------------------------------
* non verbose, check first if we have differences by enabling quiet mode
* so that printing is off, and compare again if differences found,
- * disabling quite mode
+ * disabling quiet mode
*-------------------------------------------------------------------------
*/
else {
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 75b773a..008b6b9 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -21,6 +21,12 @@
#include <sys/timeb.h>
#include <time.h>
+#if 0
+#define H5DIFF_DO_TIME
+#endif
+#if 1
+#define H5DIFF_DO_NAN
+#endif
/*-------------------------------------------------------------------------
* printf formatting
@@ -61,8 +67,6 @@
#define H5DIFF_FLT_EPSILON .00001
#define H5DIFF_DBL_EPSILON .000000001
-static hbool_t equal_float(float value, float expected);
-static hbool_t equal_double(double value, double expected);
/*-------------------------------------------------------------------------
* -p relative error formula
@@ -126,8 +130,13 @@ static hbool_t all_zero(const void *_mem, size_t size);
static int ull2float(unsigned long_long ull_value, float *f_value);
static hsize_t character_compare(unsigned char *mem1,unsigned char *mem2,hsize_t i,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
static hsize_t character_compare_opt(unsigned char *mem1,unsigned char *mem2,hsize_t i,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
+static hbool_t equal_float(float value, float expected);
+static hbool_t equal_double(double value, double expected);
-
+/*-------------------------------------------------------------------------
+ * NaN detection
+ *-------------------------------------------------------------------------
+ */
typedef enum dtype_t
{
FLT_FLOAT, FLT_DOUBLE,
@@ -154,7 +163,7 @@ static int my_isnan(dtype_t type, void *val);
static
int print_data(diff_opt_t *options)
{
- return ( (options->m_report || options->m_verbose) && !options->m_quiet)?1:0;
+ return ( (options->m_report || options->m_verbose) && !options->m_quiet)?1:0;
}
/*-------------------------------------------------------------------------
@@ -253,170 +262,135 @@ hsize_t diff_array( void *_mem1,
hid_t container1_id,
hid_t container2_id) /* dataset where the reference came from*/
{
- hsize_t nfound=0; /* number of differences found */
- size_t size; /* size of datum */
- unsigned char *mem1 = (unsigned char*)_mem1;
- unsigned char *mem2 = (unsigned char*)_mem2;
- unsigned char *tmp1;
- unsigned char *tmp2;
- hsize_t acc[32]; /* accumulator position */
- hsize_t pos[32]; /* matrix position */
- int ph=1; /* print header */
- hsize_t i;
- int j;
-
-
- /* get the size. */
- size = H5Tget_size( m_type );
-
- acc[rank-1]=1;
- for(j=(rank-2); j>=0; j--)
- {
- acc[j]=acc[j+1]*dims[j+1];
- }
- for ( j = 0; j < rank; j++)
- pos[j]=0;
-
- if(H5Tis_variable_str(m_type))
- {
- tmp1 = ((unsigned char**)mem1)[0];
- tmp2 = ((unsigned char**)mem2)[0];
- nfound+=diff_datum(
- tmp1,
- tmp2,
- m_type,
- (hsize_t)0,
- rank,
- dims,
- acc,
- pos,
- options,
- name1,
- name2,
- container1_id,
- container2_id,
- &ph);
- }
-
- else
- {
- switch (H5Tget_class(m_type))
- {
- default:
- assert(0);
- break;
-
- /*-------------------------------------------------------------------------
- * float and integer atomic types
- *-------------------------------------------------------------------------
- */
-
- case H5T_FLOAT:
-
- if (H5Tequal(m_type, H5T_NATIVE_FLOAT))
- {
-
-#if defined (H5DIFF_DO_TIME)
- int time;
-
- #if defined (WIN32)
- struct _timeb *tbstart = malloc(sizeof(struct _timeb));
- struct _timeb *tbstop = malloc(sizeof(struct _timeb));
- _ftime( tbstart);
- #else
- struct timeb *tbstart = malloc(sizeof(struct timeb));
- struct timeb *tbstop = malloc(sizeof(struct timeb));
- ftime( tbstart);
- #endif
-
-#endif
-
-
-
- nfound=diff_float(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
-
-
-#if defined (H5DIFF_DO_TIME)
-
- #if defined (WIN32)
- _ftime( tbstop );
- #else
- ftime( tbstop );
- #endif
-
- time = tbstop->time - tbstart->time;
- printf(" TIME = %d\n", time );
-
-#endif
-
- }
- else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE))
- nfound=diff_double(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- break;
-
- case H5T_INTEGER:
-
- if (H5Tequal(m_type, H5T_NATIVE_SCHAR))
- nfound=diff_schar(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_UCHAR))
- nfound=diff_uchar(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_SHORT))
- nfound=diff_short(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_USHORT))
- nfound=diff_ushort(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_INT))
- nfound=diff_int(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_UINT))
- nfound=diff_uint(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_LONG))
- nfound=diff_long(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_ULONG))
- nfound=diff_ulong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_LLONG))
- nfound=diff_llong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_ULLONG))
- nfound=diff_ullong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
-
- break;
-
- /*-------------------------------------------------------------------------
- * Other types than float and integer
- *-------------------------------------------------------------------------
- */
-
- case H5T_COMPOUND:
- case H5T_STRING:
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- case H5T_ENUM:
- case H5T_ARRAY:
- case H5T_VLEN:
- case H5T_REFERENCE:
-
- for ( i = 0; i < nelmts; i++)
- {
- nfound+=diff_datum(
- mem1 + i * size,
- mem2 + i * size, /* offset */
- m_type,
- i,
- rank,
- dims,
- acc,
- pos,
- options,
- name1,
- name2,
- container1_id,
- container2_id,
- &ph);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* i */
- } /* switch */
- } /* else */
-
- return nfound;
+ hsize_t nfound=0; /* number of differences found */
+ size_t size; /* size of datum */
+ unsigned char *mem1 = (unsigned char*)_mem1;
+ unsigned char *mem2 = (unsigned char*)_mem2;
+ unsigned char *tmp1;
+ unsigned char *tmp2;
+ hsize_t acc[32]; /* accumulator position */
+ hsize_t pos[32]; /* matrix position */
+ int ph=1; /* print header */
+ hsize_t i;
+ int j;
+
+
+ /* get the size. */
+ size = H5Tget_size( m_type );
+
+ acc[rank-1]=1;
+ for(j=(rank-2); j>=0; j--)
+ {
+ acc[j]=acc[j+1]*dims[j+1];
+ }
+ for ( j = 0; j < rank; j++)
+ pos[j]=0;
+
+ if(H5Tis_variable_str(m_type))
+ {
+ tmp1 = ((unsigned char**)mem1)[0];
+ tmp2 = ((unsigned char**)mem2)[0];
+ nfound+=diff_datum(
+ tmp1,
+ tmp2,
+ m_type,
+ (hsize_t)0,
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ name1,
+ name2,
+ container1_id,
+ container2_id,
+ &ph);
+ }
+
+ else
+ {
+ switch (H5Tget_class(m_type))
+ {
+ default:
+ assert(0);
+ break;
+
+ /*-------------------------------------------------------------------------
+ * float and integer atomic types
+ *-------------------------------------------------------------------------
+ */
+
+ case H5T_FLOAT:
+
+ if (H5Tequal(m_type, H5T_NATIVE_FLOAT))
+ nfound=diff_float(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE))
+ nfound=diff_double(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ break;
+
+ case H5T_INTEGER:
+
+ if (H5Tequal(m_type, H5T_NATIVE_SCHAR))
+ nfound=diff_schar(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_UCHAR))
+ nfound=diff_uchar(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_SHORT))
+ nfound=diff_short(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_USHORT))
+ nfound=diff_ushort(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_INT))
+ nfound=diff_int(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_UINT))
+ nfound=diff_uint(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_LONG))
+ nfound=diff_long(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_ULONG))
+ nfound=diff_ulong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_LLONG))
+ nfound=diff_llong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_ULLONG))
+ nfound=diff_ullong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * Other types than float and integer
+ *-------------------------------------------------------------------------
+ */
+
+ case H5T_COMPOUND:
+ case H5T_STRING:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ case H5T_ENUM:
+ case H5T_ARRAY:
+ case H5T_VLEN:
+ case H5T_REFERENCE:
+
+ for ( i = 0; i < nelmts; i++)
+ {
+ nfound+=diff_datum(
+ mem1 + i * size,
+ mem2 + i * size, /* offset */
+ m_type,
+ i,
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ name1,
+ name2,
+ container1_id,
+ container2_id,
+ &ph);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* i */
+ } /* switch */
+ } /* else */
+
+ return nfound;
}
/*-------------------------------------------------------------------------
@@ -472,1640 +446,1778 @@ hsize_t diff_datum(void *_mem1,
hid_t container2_id, /*where the reference came from*/
int *ph) /*print header */
{
- unsigned char *mem1 = (unsigned char*)_mem1;
- unsigned char *mem2 = (unsigned char*)_mem2;
- unsigned u;
- hid_t memb_type;
- size_t type_size;
- size_t offset;
- int nmembs;
- int j;
- hsize_t nelmts;
- size_t size=0;
- int iszero1;
- int iszero2;
- hid_t obj1_id;
- hid_t obj2_id;
- hsize_t nfound=0; /* differences found */
- int ret=0; /* check return error */
- float f1, f2;
- double per;
- int both_zero;
-
- type_size = H5Tget_size( m_type );
-
- switch (H5Tget_class(m_type))
- {
- default:
- assert(0);
- break;
- case H5T_TIME:
- assert(0);
- break;
-
- /*-------------------------------------------------------------------------
- * H5T_COMPOUND
- *-------------------------------------------------------------------------
- */
- case H5T_COMPOUND:
- nmembs = H5Tget_nmembers(m_type);
- for (j = 0; j < nmembs; j++)
- {
- offset = H5Tget_member_offset(m_type, (unsigned)j);
- memb_type = H5Tget_member_type(m_type, (unsigned)j);
- nfound+=diff_datum(
- mem1+offset,
- mem2+offset,
- memb_type,
- i,
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph);
- H5Tclose(memb_type);
- }
- break;
-
- /*-------------------------------------------------------------------------
- * H5T_STRING
- *-------------------------------------------------------------------------
- */
- case H5T_STRING:
- {
-
- H5T_str_t pad;
- char *s;
-
- if(H5Tis_variable_str(m_type))
- {
- /* mem1 is the pointer into the struct where a `char*' is stored. So we have
- * to dereference the pointer to get the `char*' to pass to HDstrlen(). */
- s = *(char**)mem1;
- if(s!=NULL)
- size = HDstrlen(s);
- }
- else
- {
- s = (char *)mem1;
- size = H5Tget_size(m_type);
- }
-
- pad = H5Tget_strpad(m_type);
-
- /* check for NULL pointer for string */
- if(s!=NULL)
- for (u=0; u<size && (s[u] || pad!=H5T_STR_NULLTERM); u++)
- nfound+=character_compare(
- mem1 + u,
- mem2 + u, /* offset */
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
-
- }
- break;
-
- /*-------------------------------------------------------------------------
- * H5T_BITFIELD
- *-------------------------------------------------------------------------
- */
- case H5T_BITFIELD:
- {
- /* byte-by-byte comparison */
- for (u=0; u<type_size; u++)
- nfound+=character_compare_opt(
- mem1 + u,
- mem2 + u, /* offset */
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
-
- }
- break;
-
- /*-------------------------------------------------------------------------
- * H5T_OPAQUE
- *-------------------------------------------------------------------------
- */
- case H5T_OPAQUE:
-
- /* byte-by-byte comparison */
- for (u=0; u<type_size; u++)
- nfound+=character_compare_opt(
- mem1 + u,
- mem2 + u, /* offset */
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
-
- break;
+ unsigned char *mem1 = (unsigned char*)_mem1;
+ unsigned char *mem2 = (unsigned char*)_mem2;
+ unsigned u;
+ hid_t memb_type;
+ size_t type_size;
+ size_t offset;
+ int nmembs;
+ int j;
+ hsize_t nelmts;
+ size_t size=0;
+ int iszero1;
+ int iszero2;
+ hid_t obj1_id;
+ hid_t obj2_id;
+ hsize_t nfound=0; /* differences found */
+ int ret=0; /* check return error */
+ float f1, f2;
+ double per;
+ int both_zero;
+
+ type_size = H5Tget_size( m_type );
+
+ switch (H5Tget_class(m_type))
+ {
+ default:
+ assert(0);
+ break;
+ case H5T_TIME:
+ assert(0);
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5T_COMPOUND
+ *-------------------------------------------------------------------------
+ */
+ case H5T_COMPOUND:
+ nmembs = H5Tget_nmembers(m_type);
- /*-------------------------------------------------------------------------
- * H5T_ENUM
- *-------------------------------------------------------------------------
- */
- case H5T_ENUM:
+ for (j = 0; j < nmembs; j++)
+ {
+ offset = H5Tget_member_offset(m_type, (unsigned)j);
+ memb_type = H5Tget_member_type(m_type, (unsigned)j);
+ nfound+=diff_datum(
+ mem1+offset,
+ mem2+offset,
+ memb_type,
+ i,
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ container1_id,
+ container2_id,
+ ph);
+ H5Tclose(memb_type);
+ }
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5T_STRING
+ *-------------------------------------------------------------------------
+ */
+ case H5T_STRING:
- /* For enumeration types we compare the names instead of the
+ {
+
+ H5T_str_t pad;
+ char *s;
+
+ if(H5Tis_variable_str(m_type))
+ {
+ /* mem1 is the pointer into the struct where a `char*' is stored. So we have
+ * to dereference the pointer to get the `char*' to pass to HDstrlen(). */
+ s = *(char**)mem1;
+ if(s!=NULL)
+ size = HDstrlen(s);
+ }
+ else
+ {
+ s = (char *)mem1;
+ size = H5Tget_size(m_type);
+ }
+
+ pad = H5Tget_strpad(m_type);
+
+ /* check for NULL pointer for string */
+ if(s!=NULL)
+ {
+ for (u=0; u<size && (s[u] || pad!=H5T_STR_NULLTERM); u++)
+ nfound+=character_compare(
+ mem1 + u,
+ mem2 + u, /* offset */
+ i, /* index position */
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ ph);
+ }
+
+ }
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5T_BITFIELD
+ *-------------------------------------------------------------------------
+ */
+ case H5T_BITFIELD:
+
+ /* byte-by-byte comparison */
+ for (u=0; u<type_size; u++)
+ nfound+=character_compare_opt(
+ mem1 + u,
+ mem2 + u, /* offset */
+ i, /* index position */
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ ph);
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5T_OPAQUE
+ *-------------------------------------------------------------------------
+ */
+ case H5T_OPAQUE:
+
+ /* byte-by-byte comparison */
+ for (u=0; u<type_size; u++)
+ nfound+=character_compare_opt(
+ mem1 + u,
+ mem2 + u, /* offset */
+ i, /* index position */
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ ph);
+
+ break;
+
+
+ /*-------------------------------------------------------------------------
+ * H5T_ENUM
+ *-------------------------------------------------------------------------
+ */
+ case H5T_ENUM:
+
+ /* For enumeration types we compare the names instead of the
integer values. For each pair of elements being
compared, we convert both bit patterns to their corresponding
enumeration constant and do a string comparison
- */
-
- {
- char enum_name1[1024];
- char enum_name2[1024];
-
- /* disable error reporting */
- H5E_BEGIN_TRY {
-
- if ((H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1) >= 0) &&
- (H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2) >= 0))
- {
- if (HDstrcmp(enum_name1,enum_name2)!=0)
- {
- nfound=1;
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(S_FORMAT,enum_name1,enum_name2);
- }
- }
- else
- {
- for (u=0; u<type_size; u++)
- nfound+=character_compare_opt(
- mem1 + u,
- mem2 + u, /* offset */
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
- }
- }
- /* enable error reporting */
- } H5E_END_TRY;
- }
-
-
- break;
-
- /*-------------------------------------------------------------------------
- * H5T_ARRAY
- *-------------------------------------------------------------------------
- */
- case H5T_ARRAY:
- {
- hsize_t adims[H5S_MAX_RANK];
- hsize_t ndims;
- /* get the array's base datatype for each element */
- memb_type = H5Tget_super(m_type);
- size = H5Tget_size(memb_type);
- ndims = H5Tget_array_ndims(m_type);
- H5Tget_array_dims2(m_type, adims);
- assert(ndims >= 1 && ndims <= H5S_MAX_RANK);
-
- /* calculate the number of array elements */
- for (u = 0, nelmts = 1; u <ndims; u++)
- nelmts *= adims[u];
- for (u = 0; u < nelmts; u++)
- nfound+=diff_datum(
- mem1 + u * size,
- mem2 + u * size, /* offset */
- memb_type,
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph);
- H5Tclose(memb_type);
- }
- break;
-
- /*-------------------------------------------------------------------------
- * H5T_VLEN
- *-------------------------------------------------------------------------
- */
-
- case H5T_VLEN:
-
- /* get the VL sequences's base datatype for each element */
- memb_type = H5Tget_super(m_type);
- size = H5Tget_size(memb_type);
-
- /* get the number of sequence elements */
- nelmts = ((hvl_t *)mem1)->len;
-
- for (j = 0; j < (int)nelmts; j++)
- nfound+=diff_datum(
- ((char *)(((hvl_t *)mem1)->p)) + j * size,
- ((char *)(((hvl_t *)mem2)->p)) + j * size, /* offset */
- memb_type,
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph);
-
- H5Tclose(memb_type);
-
- break;
-
-
- case H5T_REFERENCE:
-
- iszero1=all_zero(_mem1, H5Tget_size(m_type));
- iszero2=all_zero(_mem2, H5Tget_size(m_type));
- if (iszero1 != iszero2)
- {
- return 1;
- }
- else if (!iszero1 && !iszero2)
- {
-
- /*-------------------------------------------------------------------------
- * H5T_STD_REF_DSETREG
- * Dataset region reference
- *-------------------------------------------------------------------------
- */
-
- if (H5Tequal(m_type, H5T_STD_REF_DSETREG))
- {
- hid_t region1_id;
- hid_t region2_id;
-
- if ((obj1_id = H5Rdereference(container1_id, H5R_DATASET_REGION, _mem1))<0)
- ret= -1;
- if ((obj2_id = H5Rdereference(container2_id, H5R_DATASET_REGION, _mem2))<0)
- ret= -1;
- if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1))<0)
- ret= -1;
- if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2))<0)
- ret= -1;
-
- if (ret==-1) {
- options->err_stat=1;
- return 0;
- }
-
- nfound = diff_region(obj1_id,obj2_id,region1_id,region2_id,options);
-
- H5Oclose(obj1_id);
- H5Oclose(obj2_id);
- H5Sclose(region1_id);
- H5Sclose(region2_id);
-
- }/*dataset reference*/
-
-
- /*-------------------------------------------------------------------------
- * H5T_STD_REF_OBJ
- * Object references. get the type and OID of the referenced object
- *-------------------------------------------------------------------------
- */
- else if (H5Tequal(m_type, H5T_STD_REF_OBJ))
- {
- H5O_type_t obj1_type;
- H5O_type_t obj2_type;
-
- if(H5Rget_obj_type2(container1_id, H5R_OBJECT, _mem1, &obj1_type) < 0)
- ret = -1;
- if(H5Rget_obj_type2(container2_id, H5R_OBJECT, _mem2, &obj2_type) < 0)
- ret = -1;
- if(ret == -1) {
- options->err_stat = 1;
- return 0;
- } /* end if */
-
- /* check object type */
- if(obj1_type != obj2_type)
- {
- parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2);
- options->not_cmp = 1;
- return 0;
- }
-
- if((obj1_id = H5Rdereference(container1_id, H5R_OBJECT, _mem1)) < 0)
- ret = -1;
- if((obj2_id = H5Rdereference(container2_id, H5R_OBJECT, _mem2)) < 0)
- ret = -1;
- if(ret == -1) {
- options->err_stat = 1;
- return 0;
- } /* end if */
-
- /* compare */
- if(obj1_type == H5O_TYPE_DATASET)
- nfound = diff_datasetid(obj1_id,
- obj2_id,
- NULL,
- NULL,
- options);
- else {
- parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>",
- obj1, obj2);
- options->not_cmp = 1;
- }
-
- H5Oclose(obj1_id);
- H5Oclose(obj2_id);
-
- }/*object reference*/
-
- }/*is zero*/
-
-
- break;
-
-
- case H5T_INTEGER:
-
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_SCHAR
- *-------------------------------------------------------------------------
- */
- if (H5Tequal(m_type, H5T_NATIVE_SCHAR))
- {
- char temp1_char;
- char temp2_char;
- assert(type_size==sizeof(char));
- memcpy(&temp1_char, mem1, sizeof(char));
- memcpy(&temp2_char, mem2, sizeof(char));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_char-temp2_char) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_char,temp2_char);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_char,temp2_char,ABS(temp1_char-temp2_char),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER(temp1_char,temp2_char);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_char-temp2_char) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_char,temp2_char,ABS(temp1_char-temp2_char),per);
- }
- nfound++;
- }
- }
- else if (temp1_char != temp2_char)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
-
- } /*H5T_NATIVE_SCHAR*/
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_UCHAR
- *-------------------------------------------------------------------------
- */
- else if (H5Tequal(m_type, H5T_NATIVE_UCHAR))
- {
- unsigned char temp1_uchar;
- unsigned char temp2_uchar;
- assert(type_size==sizeof(unsigned char));
-
- memcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- memcpy(&temp2_uchar, mem2, sizeof(unsigned char));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_uchar,temp2_uchar) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar),per);
- }
- nfound++;
- }
- }
- else if (temp1_uchar != temp2_uchar)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
-
- } /*H5T_NATIVE_UCHAR*/
-
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_SHORT
- *-------------------------------------------------------------------------
- */
-
- else if (H5Tequal(m_type, H5T_NATIVE_SHORT))
- {
- short temp1_short;
- short temp2_short;
- assert(type_size==sizeof(short));
-
- memcpy(&temp1_short, mem1, sizeof(short));
- memcpy(&temp2_short, mem2, sizeof(short));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_short-temp2_short) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_short,temp2_short);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_short,temp2_short,ABS(temp1_short-temp2_short),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER(temp1_short,temp2_short);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_short-temp2_short) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_short,temp2_short,ABS(temp1_short-temp2_short),per);
- }
- nfound++;
- }
- }
- else if (temp1_short != temp2_short)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
-
-
- } /*H5T_NATIVE_SHORT*/
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_USHORT
- *-------------------------------------------------------------------------
- */
-
- else if (H5Tequal(m_type, H5T_NATIVE_USHORT))
- {
- unsigned short temp1_ushort;
- unsigned short temp2_ushort;
- assert(type_size==sizeof(short));
-
- memcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- memcpy(&temp2_ushort, mem2, sizeof(unsigned short));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_ushort,temp2_ushort) > options->delta)
- {
-
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,
- PDIFF(temp1_ushort,temp2_ushort));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ushort,temp2_ushort) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort),per);
- }
- nfound++;
- }
- }
- else if (temp1_ushort != temp2_ushort)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
- } /*H5T_NATIVE_USHORT*/
-
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_INT
- *-------------------------------------------------------------------------
- */
-
- else if (H5Tequal(m_type, H5T_NATIVE_INT))
- {
- int temp1_int;
- int temp2_int;
- assert(type_size==sizeof(int));
-
- memcpy(&temp1_int, mem1, sizeof(int));
- memcpy(&temp2_int, mem2, sizeof(int));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_int-temp2_int) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_int,temp2_int);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_int,temp2_int,ABS(temp1_int-temp2_int),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER(temp1_int,temp2_int);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_int-temp2_int) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_int,temp2_int,ABS(temp1_int-temp2_int),per);
- }
- nfound++;
- }
- }
- else if (temp1_int != temp2_int)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
- } /*H5T_NATIVE_INT*/
-
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_UINT
- *-------------------------------------------------------------------------
- */
-
- else if (H5Tequal(m_type, H5T_NATIVE_UINT))
- {
- unsigned int temp1_uint;
- unsigned int temp2_uint;
- assert(type_size==sizeof(int));
-
- memcpy(&temp1_uint, mem1, sizeof(unsigned int));
- memcpy(&temp2_uint, mem2, sizeof(unsigned int));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_uint,temp2_uint) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(UI_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed int,temp1_uint,temp2_uint);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER_UNSIGN(signed int,temp1_uint,temp2_uint);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_uint,temp2_uint) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint),per);
- }
- nfound++;
- }
- }
- else if (temp1_uint != temp2_uint)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(UI_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- nfound++;
- }
- } /*H5T_NATIVE_UINT*/
+ */
+
+ {
+ char enum_name1[1024];
+ char enum_name2[1024];
+
+ /* disable error reporting */
+ H5E_BEGIN_TRY {
+
+ if ((H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1) >= 0) &&
+ (H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2) >= 0))
+ {
+ if (HDstrcmp(enum_name1,enum_name2)!=0)
+ {
+ nfound=1;
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(S_FORMAT,enum_name1,enum_name2);
+ }
+ }
+ else
+ {
+ for (u=0; u<type_size; u++)
+ nfound+=character_compare_opt(
+ mem1 + u,
+ mem2 + u, /* offset */
+ i, /* index position */
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ ph);
+ }
+ }
+ /* enable error reporting */
+ } H5E_END_TRY;
+ }
+
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5T_ARRAY
+ *-------------------------------------------------------------------------
+ */
+ case H5T_ARRAY:
+ {
+ hsize_t adims[H5S_MAX_RANK];
+ hsize_t ndims;
+ /* get the array's base datatype for each element */
+ memb_type = H5Tget_super(m_type);
+ size = H5Tget_size(memb_type);
+ ndims = H5Tget_array_ndims(m_type);
+ H5Tget_array_dims2(m_type, adims);
+ assert(ndims >= 1 && ndims <= H5S_MAX_RANK);
+
+ /* calculate the number of array elements */
+ for (u = 0, nelmts = 1; u <ndims; u++)
+ nelmts *= adims[u];
+ for (u = 0; u < nelmts; u++)
+ nfound+=diff_datum(
+ mem1 + u * size,
+ mem2 + u * size, /* offset */
+ memb_type,
+ i, /* index position */
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ container1_id,
+ container2_id,
+ ph);
+ H5Tclose(memb_type);
+ }
+ break;
+
+
+
+ /*-------------------------------------------------------------------------
+ * H5T_REFERENCE
+ *-------------------------------------------------------------------------
+ */
+
+ case H5T_REFERENCE:
+
+ iszero1=all_zero(_mem1, H5Tget_size(m_type));
+ iszero2=all_zero(_mem2, H5Tget_size(m_type));
+ if (iszero1 != iszero2)
+ {
+ return 1;
+ }
+ else if (!iszero1 && !iszero2)
+ {
+
+ /*-------------------------------------------------------------------------
+ * H5T_STD_REF_DSETREG
+ * Dataset region reference
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5Tequal(m_type, H5T_STD_REF_DSETREG))
+ {
+ hid_t region1_id;
+ hid_t region2_id;
+
+ if ((obj1_id = H5Rdereference(container1_id, H5R_DATASET_REGION, _mem1))<0)
+ ret= -1;
+ if ((obj2_id = H5Rdereference(container2_id, H5R_DATASET_REGION, _mem2))<0)
+ ret= -1;
+ if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1))<0)
+ ret= -1;
+ if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2))<0)
+ ret= -1;
+
+ if (ret==-1) {
+ options->err_stat=1;
+ return 0;
+ }
+
+ nfound = diff_region(obj1_id,obj2_id,region1_id,region2_id,options);
+
+ H5Oclose(obj1_id);
+ H5Oclose(obj2_id);
+ H5Sclose(region1_id);
+ H5Sclose(region2_id);
+
+ }/*dataset reference*/
+
+
+ /*-------------------------------------------------------------------------
+ * H5T_STD_REF_OBJ
+ * Object references. get the type and OID of the referenced object
+ *-------------------------------------------------------------------------
+ */
+ else if (H5Tequal(m_type, H5T_STD_REF_OBJ))
+ {
+ H5O_type_t obj1_type;
+ H5O_type_t obj2_type;
+
+ if(H5Rget_obj_type2(container1_id, H5R_OBJECT, _mem1, &obj1_type) < 0)
+ ret = -1;
+ if(H5Rget_obj_type2(container2_id, H5R_OBJECT, _mem2, &obj2_type) < 0)
+ ret = -1;
+ if(ret == -1) {
+ options->err_stat = 1;
+ return 0;
+ } /* end if */
+
+ /* check object type */
+ if(obj1_type != obj2_type)
+ {
+ parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2);
+ options->not_cmp = 1;
+ return 0;
+ }
+
+ if((obj1_id = H5Rdereference(container1_id, H5R_OBJECT, _mem1)) < 0)
+ ret = -1;
+ if((obj2_id = H5Rdereference(container2_id, H5R_OBJECT, _mem2)) < 0)
+ ret = -1;
+ if(ret == -1) {
+ options->err_stat = 1;
+ return 0;
+ } /* end if */
+
+ /* compare */
+ if(obj1_type == H5O_TYPE_DATASET)
+ nfound = diff_datasetid(obj1_id,
+ obj2_id,
+ NULL,
+ NULL,
+ options);
+ else {
+ parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>",
+ obj1, obj2);
+ options->not_cmp = 1;
+ }
+
+ H5Oclose(obj1_id);
+ H5Oclose(obj2_id);
+
+ }/*object reference*/
+
+ }/*is zero*/
+
+
+ break;
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_LONG
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5T_VLEN
+ *-------------------------------------------------------------------------
+ */
+
+ case H5T_VLEN:
+
+ /* get the VL sequences's base datatype for each element */
+ memb_type = H5Tget_super(m_type);
+ size = H5Tget_size(memb_type);
+
+ /* get the number of sequence elements */
+ nelmts = ((hvl_t *)mem1)->len;
+
+ for (j = 0; j < (int)nelmts; j++)
+ nfound+=diff_datum(
+ ((char *)(((hvl_t *)mem1)->p)) + j * size,
+ ((char *)(((hvl_t *)mem2)->p)) + j * size, /* offset */
+ memb_type,
+ i, /* index position */
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ container1_id,
+ container2_id,
+ ph);
+
+ H5Tclose(memb_type);
+
+ break;
+
- else if (H5Tequal(m_type, H5T_NATIVE_LONG))
- {
- long temp1_long;
- long temp2_long;
- assert(type_size==sizeof(long));
-
- memcpy(&temp1_long, mem1, sizeof(long));
- memcpy(&temp2_long, mem2, sizeof(long));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_long-temp2_long) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_long,temp2_long);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,
- ABS(temp1_long-temp2_long));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P,temp1_long,temp2_long,ABS(temp1_long-temp2_long),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER(temp1_long,temp2_long);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_long-temp2_long) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P,temp1_long,temp2_long,
- ABS(temp1_long-temp2_long),
- per);
- }
- nfound++;
- }
- }
- else if (temp1_long != temp2_long)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
- }
- nfound++;
- }
- } /*H5T_NATIVE_LONG*/
+
+ /*-------------------------------------------------------------------------
+ * H5T_INTEGER
+ *-------------------------------------------------------------------------
+ */
+
+ case H5T_INTEGER:
+
+
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_SCHAR
+ *-------------------------------------------------------------------------
+ */
+ if (H5Tequal(m_type, H5T_NATIVE_SCHAR))
+ {
+ char temp1_char;
+ char temp2_char;
+ assert(type_size==sizeof(char));
+ memcpy(&temp1_char, mem1, sizeof(char));
+ memcpy(&temp2_char, mem2, sizeof(char));
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ if (ABS(temp1_char-temp2_char) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ PER(temp1_char,temp2_char);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_char,temp2_char,ABS(temp1_char-temp2_char),per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ PER(temp1_char,temp2_char);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent && ABS(temp1_char-temp2_char) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_char,temp2_char,ABS(temp1_char-temp2_char),per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_char != temp2_char)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
+ }
+ nfound++;
+ }
+
+ } /*H5T_NATIVE_SCHAR*/
+
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_UCHAR
+ *-------------------------------------------------------------------------
+ */
+ else if (H5Tequal(m_type, H5T_NATIVE_UCHAR))
+ {
+ unsigned char temp1_uchar;
+ unsigned char temp2_uchar;
+ assert(type_size==sizeof(unsigned char));
+
+ memcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ memcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ if ( PDIFF(temp1_uchar,temp2_uchar) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar),per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar),per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_uchar != temp2_uchar)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ }
+ nfound++;
+ }
+
+ } /*H5T_NATIVE_UCHAR*/
+
+
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_SHORT
+ *-------------------------------------------------------------------------
+ */
+
+ else if (H5Tequal(m_type, H5T_NATIVE_SHORT))
+ {
+ short temp1_short;
+ short temp2_short;
+ assert(type_size==sizeof(short));
+
+ memcpy(&temp1_short, mem1, sizeof(short));
+ memcpy(&temp2_short, mem2, sizeof(short));
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ if (ABS(temp1_short-temp2_short) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ PER(temp1_short,temp2_short);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_short,temp2_short,ABS(temp1_short-temp2_short),per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ PER(temp1_short,temp2_short);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent && ABS(temp1_short-temp2_short) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_short,temp2_short,ABS(temp1_short-temp2_short),per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_short != temp2_short)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
+ }
+ nfound++;
+ }
+
+
+ } /*H5T_NATIVE_SHORT*/
+
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_USHORT
+ *-------------------------------------------------------------------------
+ */
+
+ else if (H5Tequal(m_type, H5T_NATIVE_USHORT))
+ {
+ unsigned short temp1_ushort;
+ unsigned short temp2_ushort;
+ assert(type_size==sizeof(short));
+
+ memcpy(&temp1_ushort, mem1, sizeof(unsigned short));
+ memcpy(&temp2_ushort, mem2, sizeof(unsigned short));
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ if ( PDIFF(temp1_ushort,temp2_ushort) > options->delta)
+ {
+
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,
+ PDIFF(temp1_ushort,temp2_ushort));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort),per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent && PDIFF(temp1_ushort,temp2_ushort) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort),per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_ushort != temp2_ushort)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
+ }
+ nfound++;
+ }
+ } /*H5T_NATIVE_USHORT*/
+
+
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_INT
+ *-------------------------------------------------------------------------
+ */
+
+ else if (H5Tequal(m_type, H5T_NATIVE_INT))
+ {
+ int temp1_int;
+ int temp2_int;
+ assert(type_size==sizeof(int));
+
+ memcpy(&temp1_int, mem1, sizeof(int));
+ memcpy(&temp2_int, mem2, sizeof(int));
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ if (ABS(temp1_int-temp2_int) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ PER(temp1_int,temp2_int);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_int,temp2_int,ABS(temp1_int-temp2_int),per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ PER(temp1_int,temp2_int);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent && ABS(temp1_int-temp2_int) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_int,temp2_int,ABS(temp1_int-temp2_int),per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_int != temp2_int)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
+ }
+ nfound++;
+ }
+ } /*H5T_NATIVE_INT*/
+
+
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_UINT
+ *-------------------------------------------------------------------------
+ */
+
+ else if (H5Tequal(m_type, H5T_NATIVE_UINT))
+ {
+ unsigned int temp1_uint;
+ unsigned int temp2_uint;
+ assert(type_size==sizeof(int));
+
+ memcpy(&temp1_uint, mem1, sizeof(unsigned int));
+ memcpy(&temp2_uint, mem2, sizeof(unsigned int));
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ if ( PDIFF(temp1_uint,temp2_uint) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(UI_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ PER_UNSIGN(signed int,temp1_uint,temp2_uint);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint),per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ PER_UNSIGN(signed int,temp1_uint,temp2_uint);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent && PDIFF(temp1_uint,temp2_uint) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint),per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_uint != temp2_uint)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(UI_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ }
+ nfound++;
+ }
+ } /*H5T_NATIVE_UINT*/
+
+
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_LONG
+ *-------------------------------------------------------------------------
+ */
+
+ else if (H5Tequal(m_type, H5T_NATIVE_LONG))
+ {
+ long temp1_long;
+ long temp2_long;
+ assert(type_size==sizeof(long));
+
+ memcpy(&temp1_long, mem1, sizeof(long));
+ memcpy(&temp2_long, mem2, sizeof(long));
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ if (ABS(temp1_long-temp2_long) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ PER(temp1_long,temp2_long);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,
+ ABS(temp1_long-temp2_long));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT_P,temp1_long,temp2_long,ABS(temp1_long-temp2_long),per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ PER(temp1_long,temp2_long);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent && ABS(temp1_long-temp2_long) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT_P,temp1_long,temp2_long,
+ ABS(temp1_long-temp2_long),
+ per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_long != temp2_long)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
+ }
+ nfound++;
+ }
+ } /*H5T_NATIVE_LONG*/
+
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_ULONG
+ *-------------------------------------------------------------------------
+ */
+
+ else if (H5Tequal(m_type, H5T_NATIVE_ULONG))
+ {
+ unsigned long temp1_ulong;
+ unsigned long temp2_ulong;
+ assert(type_size==sizeof(unsigned long));
+
+ memcpy(&temp1_ulong, mem1, sizeof(unsigned long));
+ memcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ if ( PDIFF(temp1_ulong,temp2_ulong) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULI_FORMAT_P,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong),per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent && PDIFF(temp1_ulong,temp2_ulong) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULI_FORMAT_P,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong),per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_ulong != temp2_ulong)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
+ }
+ nfound++;
+ }
+
+
+ } /*H5T_NATIVE_ULONG*/
+
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_LLONG
+ *-------------------------------------------------------------------------
+ */
+
+ else if (H5Tequal(m_type, H5T_NATIVE_LLONG))
+ {
+ long_long temp1_llong;
+ long_long temp2_llong;
+ assert(type_size==sizeof(long_long));
+
+ memcpy(&temp1_llong, mem1, sizeof(long_long));
+ memcpy(&temp2_llong, mem2, sizeof(long_long));
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ if (ABS(temp1_llong-temp2_llong) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ PER(temp1_llong,temp2_llong);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ PER(temp1_llong,temp2_llong);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent && ABS(temp1_llong-temp2_llong) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_llong != temp2_llong)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
+ }
+ nfound++;
+ }
+
+ } /*H5T_NATIVE_LLONG*/
+
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_ULLONG
+ *-------------------------------------------------------------------------
+ */
+
+ else if (H5Tequal(m_type, H5T_NATIVE_ULLONG))
+ {
+ unsigned long_long temp1_ullong;
+ unsigned long_long temp2_ullong;
+ assert(type_size==sizeof(unsigned long_long));
+
+ memcpy(&temp1_ullong, mem1, sizeof(unsigned long_long));
+ memcpy(&temp2_ullong, mem2, sizeof(unsigned long_long));
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ if ( PDIFF(temp1_ullong,temp2_ullong) > (unsigned long_long)options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ ull2float(temp1_ullong,&f1);
+ ull2float(temp2_ullong,&f2);
+ PER(f1,f2);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent )
+ {
+
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ ull2float(temp1_ullong,&f1);
+ ull2float(temp2_ullong,&f2);
+ PER(f1,f2);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long_long)options->delta )
+ {
+
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+
+ parallel_print(SPACES);
+ parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_ullong != temp2_ullong)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
+ }
+ nfound++;
+ }
+
+ } /*H5T_NATIVE_ULLONG*/
+
+
+ break; /* H5T_INTEGER class */
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_ULONG
- *-------------------------------------------------------------------------
- */
+
+ /*-------------------------------------------------------------------------
+ * H5T_FLOAT
+ *-------------------------------------------------------------------------
+ */
+
+ case H5T_FLOAT:
+
+
+
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_FLOAT
+ *-------------------------------------------------------------------------
+ */
+ if (H5Tequal(m_type, H5T_NATIVE_FLOAT))
+ {
+ float temp1_float;
+ float temp2_float;
+ int isnan1;
+ int isnan2;
- else if (H5Tequal(m_type, H5T_NATIVE_ULONG))
- {
- unsigned long temp1_ulong;
- unsigned long temp2_ulong;
- assert(type_size==sizeof(unsigned long));
-
- memcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- memcpy(&temp2_ulong, mem2, sizeof(unsigned long));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_ulong,temp2_ulong) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ulong,temp2_ulong) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong),per);
- }
- nfound++;
- }
- }
- else if (temp1_ulong != temp2_ulong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- nfound++;
- }
-
-
- } /*H5T_NATIVE_ULONG*/
+ assert(type_size==sizeof(float));
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_LLONG
- *-------------------------------------------------------------------------
- */
+ memcpy(&temp1_float, mem1, sizeof(float));
+ memcpy(&temp2_float, mem2, sizeof(float));
- else if (H5Tequal(m_type, H5T_NATIVE_LLONG))
- {
- long_long temp1_llong;
- long_long temp2_llong;
- assert(type_size==sizeof(long_long));
-
- memcpy(&temp1_llong, mem1, sizeof(long_long));
- memcpy(&temp2_llong, mem2, sizeof(long_long));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_llong-temp2_llong) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_llong,temp2_llong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER(temp1_llong,temp2_llong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_llong-temp2_llong) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
- }
- nfound++;
- }
- }
- else if (temp1_llong != temp2_llong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
-
- } /*H5T_NATIVE_LLONG*/
+ /* logic for detecting NaNs is different with options -d, -p and no options */
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_ULLONG
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
+ if (options->d && !options->p)
+ {
+
+
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
+ isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
+
+ if ( !isnan1 && !isnan2)
+ {
+
+ if (ABS(temp1_float-temp2_float) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ }
+ nfound++;
+ }
+
+ } /* NaN */
+ }
+ /*-------------------------------------------------------------------------
+ * !-d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (!options->d && options->p)
+ {
+
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
+ isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
+
+ if ( !isnan1 && !isnan2)
+ {
+
+ PER(temp1_float,temp2_float);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent && ABS(temp1_float-temp2_float) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P,temp1_float,temp2_float,
+ ABS(temp1_float-temp2_float),
+ ABS(1-temp2_float/temp1_float));
+ }
+ nfound++;
+ }
+
+ } /* NaN */
+ }
- else if (H5Tequal(m_type, H5T_NATIVE_ULLONG))
- {
- unsigned long_long temp1_ullong;
- unsigned long_long temp2_ullong;
- assert(type_size==sizeof(unsigned long_long));
-
- memcpy(&temp1_ullong, mem1, sizeof(unsigned long_long));
- memcpy(&temp2_ullong, mem2, sizeof(unsigned long_long));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_ullong,temp2_ullong) > (unsigned long_long)options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- ull2float(temp1_ullong,&f1);
- ull2float(temp2_ullong,&f2);
- PER(f1,f2);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
-
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- ull2float(temp1_ullong,&f1);
- ull2float(temp2_ullong,&f2);
- PER(f1,f2);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long_long)options->delta )
- {
-
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
-
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
- }
- nfound++;
- }
- }
- else if (temp1_ullong != temp2_ullong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
+ /*-------------------------------------------------------------------------
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
+
+ else if ( options->d && options->p)
+ {
+
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
+ isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
+
+ if ( !isnan1 && !isnan2)
+ {
+
+ PER(temp1_float,temp2_float);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,
+ ABS(temp1_float-temp2_float));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P,temp1_float,temp2_float,
+ ABS(temp1_float-temp2_float),
+ ABS(1-temp2_float/temp1_float));
+ }
+ nfound++;
+ }
+
+ } /* NaN */
+ }
+
+ /*-------------------------------------------------------------------------
+ * no -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (equal_float(temp1_float,temp2_float)==FALSE)
+ {
+
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ }
+ nfound++;
+ }
+ } /*H5T_NATIVE_FLOAT*/
- } /*H5T_NATIVE_ULLONG*/
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_DOUBLE
+ *-------------------------------------------------------------------------
+ */
+
+ else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE))
+ {
+ double temp1_double;
+ double temp2_double;
+ int isnan1;
+ int isnan2;
- break; /* H5T_INTEGER class */
+ assert(type_size==sizeof(double));
+
+ memcpy(&temp1_double, mem1, sizeof(double));
+ memcpy(&temp2_double, mem2, sizeof(double));
- case H5T_FLOAT:
+ /* logic for detecting NaNs is different with options -d, -p and no options */
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_FLOAT
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
+ if (options->d && !options->p)
+ {
- if (H5Tequal(m_type, H5T_NATIVE_FLOAT))
- {
- float temp1_float;
- float temp2_float;
- assert(type_size==sizeof(float));
- memcpy(&temp1_float, mem1, sizeof(float));
- memcpy(&temp2_float, mem2, sizeof(float));
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_float-temp2_float) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- PER(temp1_float,temp2_float);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_float-temp2_float) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float),
- ABS(1-temp2_float/temp1_float));
- }
- nfound++;
- }
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- PER(temp1_float,temp2_float);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float),
- ABS(1-temp2_float/temp1_float));
- }
- nfound++;
- }
- }
-
- else if (equal_float(temp1_float,temp2_float)==FALSE)
- {
-
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
- }
- nfound++;
- }
-
- } /*H5T_NATIVE_FLOAT*/
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_DOUBLE
- *-------------------------------------------------------------------------
- */
-
- else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE))
- {
- double temp1_double;
- double temp2_double;
- assert(type_size==sizeof(double));
-
- memcpy(&temp1_double, mem1, sizeof(double));
- memcpy(&temp2_double, mem2, sizeof(double));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_double-temp2_double) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
- }
- nfound++;
- }
- }
-
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- options->not_cmp=1;
- nfound++;
- }
-
- else
-
- if ( per > options->percent &&
- ABS(temp1_double-temp2_double) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
- }
- nfound++;
- }
- }
-
- else if (equal_double(temp1_double,temp2_double)==FALSE)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
- } /*H5T_NATIVE_DOUBLE*/
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
+
+ if ( !isnan1 && !isnan2)
+ {
+
+ if (ABS(temp1_double-temp2_double) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
+ }
+ nfound++;
+ }
+
+ } /* NaN */
+ }
+ /*-------------------------------------------------------------------------
+ * !-d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (!options->d && options->p)
+ {
- break; /* H5T_FLOAT class */
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
+
+ if ( !isnan1 && !isnan2)
+ {
+
+ PER(temp1_double,temp2_double);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
+ ABS(temp1_double-temp2_double));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P,temp1_double,temp2_double,
+ ABS(temp1_double-temp2_double),
+ ABS(1-temp2_double/temp1_double));
+ }
+ nfound++;
+ }
+
+ } /* NaN */
+ }
+
+ /*-------------------------------------------------------------------------
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if ( options->d && options->p)
+ {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
+
+ if ( !isnan1 && !isnan2)
+ {
+
+ PER(temp1_double,temp2_double);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
+ ABS(temp1_double-temp2_double));
+ }
+ options->not_cmp=1;
+ nfound++;
+ }
+
+ else
+
+ if ( per > options->percent &&
+ ABS(temp1_double-temp2_double) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P,temp1_double,temp2_double,
+ ABS(temp1_double-temp2_double),
+ ABS(1-temp2_double/temp1_double));
+ }
+ nfound++;
+ }
+
+ } /* NaN */
+ }
+
+ /*-------------------------------------------------------------------------
+ * no -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (equal_double(temp1_double,temp2_double)==FALSE)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
+ }
+ nfound++;
+ }
+ } /*H5T_NATIVE_DOUBLE*/
+
+
+ break; /* H5T_FLOAT class */
+
} /* switch */
-
+
return nfound;
}
@@ -2143,17 +2255,17 @@ static hbool_t all_zero(const void *_mem, size_t size)
static
void print_region_block(int i, hsize_t *ptdata, int ndims)
{
- int j;
-
- parallel_print(" ");
- for (j = 0; j < ndims; j++)
- parallel_print("%s%lu", j ? "," : " (",
- (unsigned long)ptdata[i * 2 * ndims + j]);
- for (j = 0; j < ndims; j++)
- parallel_print("%s%lu", j ? "," : ")-(",
- (unsigned long)ptdata[i * 2 * ndims + j + ndims]);
- parallel_print(")");
-
+ int j;
+
+ parallel_print(" ");
+ for (j = 0; j < ndims; j++)
+ parallel_print("%s%lu", j ? "," : " (",
+ (unsigned long)ptdata[i * 2 * ndims + j]);
+ for (j = 0; j < ndims; j++)
+ parallel_print("%s%lu", j ? "," : ")-(",
+ (unsigned long)ptdata[i * 2 * ndims + j + ndims]);
+ parallel_print(")");
+
}
@@ -2170,14 +2282,14 @@ void print_region_block(int i, hsize_t *ptdata, int ndims)
static
void print_points(int i, hsize_t *ptdata, int ndims)
{
- int j;
-
- parallel_print(" ");
- for (j = 0; j < ndims; j++)
- parallel_print("%s%lu", j ? "," : "(",
- (unsigned long)(ptdata[i * ndims + j]));
- parallel_print(")");
-
+ int j;
+
+ parallel_print(" ");
+ for (j = 0; j < ndims; j++)
+ parallel_print("%s%lu", j ? "," : "(",
+ (unsigned long)(ptdata[i * ndims + j]));
+ parallel_print(")");
+
}
/*-------------------------------------------------------------------------
@@ -2383,25 +2495,25 @@ hsize_t character_compare(unsigned char *mem1,
const char *obj2,
int *ph)
{
- hsize_t nfound=0; /* differences found */
- unsigned char temp1_uchar;
- unsigned char temp2_uchar;
-
- memcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- memcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- if (temp1_uchar != temp2_uchar)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(C_FORMAT,temp1_uchar,temp2_uchar);
- }
- nfound++;
- }
-
- return nfound;
+ hsize_t nfound=0; /* differences found */
+ unsigned char temp1_uchar;
+ unsigned char temp2_uchar;
+
+ memcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ memcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+
+ if (temp1_uchar != temp2_uchar)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(C_FORMAT,temp1_uchar,temp2_uchar);
+ }
+ nfound++;
+ }
+
+ return nfound;
}
@@ -2427,73 +2539,73 @@ hsize_t character_compare_opt(unsigned char *mem1,
const char *obj2,
int *ph)
{
- hsize_t nfound=0; /* differences found */
- unsigned char temp1_uchar;
- unsigned char temp2_uchar;
- double per;
- int both_zero;
+ hsize_t nfound=0; /* differences found */
+ unsigned char temp1_uchar;
+ unsigned char temp2_uchar;
+ double per;
+ int both_zero;
+
+ memcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ memcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+
+ /* -d and !-p */
+
+ if (options->d && !options->p)
+ {
+ if ( PDIFF(temp1_uchar,temp2_uchar) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar),per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
+ if ( per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar),per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_uchar != temp2_uchar)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ }
+ nfound++;
+ }
+
+ return nfound;
- memcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- memcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- /* -d and !-p */
-
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_uchar,temp2_uchar) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
- if ( per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar),per);
- }
- nfound++;
- }
- }
- else if (temp1_uchar != temp2_uchar)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
-
- return nfound;
-
}
@@ -2526,34 +2638,53 @@ hsize_t diff_float(unsigned char *mem1,
hsize_t i;
double per;
int both_zero;
+ int isnan1;
+ int isnan2;
-
- /* -d and !-p */
+
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
+
if (options->d && !options->p)
{
for ( i = 0; i < nelmts; i++)
{
memcpy(&temp1_float, mem1, sizeof(float));
memcpy(&temp2_float, mem2, sizeof(float));
-
- if (ABS(temp1_float-temp2_float) > options->delta)
- {
- if ( print_data(options) )
+
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
+ isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
+
+ if ( !isnan1 && !isnan2)
+ {
+ if (ABS(temp1_float-temp2_float) > options->delta)
{
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ }
+ nfound++;
}
- nfound++;
- }
+ } /* NaN */
mem1+=sizeof(float);
mem2+=sizeof(float);
if (options->n && nfound>=options->count)
return nfound;
- }
+ } /* i */
}
-
- /* !-d and -p */
+
+ /*-------------------------------------------------------------------------
+ * !-d and -p
+ *-------------------------------------------------------------------------
+ */
else if (!options->d && options->p)
{
for ( i = 0; i < nelmts; i++)
@@ -2561,43 +2692,57 @@ hsize_t diff_float(unsigned char *mem1,
memcpy(&temp1_float, mem1, sizeof(float));
memcpy(&temp2_float, mem2, sizeof(float));
- PER(temp1_float,temp2_float);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float));
- }
- options->not_cmp=1;
- nfound++;
- }
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
+ isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
- else
+ if ( !isnan1 && !isnan2)
+ {
- if ( per > options->percent )
+ PER(temp1_float,temp2_float);
+
+ if (not_comparable && !both_zero) /* not comparable */
{
if ( print_data(options) )
{
print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float),
- ABS(1-temp2_float/temp1_float));
+ parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,
+ ABS(temp1_float-temp2_float));
}
+ options->not_cmp=1;
nfound++;
}
- mem1+=sizeof(float);
- mem2+=sizeof(float);
- if (options->n && nfound>=options->count)
- return nfound;
- }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P,temp1_float,temp2_float,
+ ABS(temp1_float-temp2_float),
+ ABS(1-temp2_float/temp1_float));
+ }
+ nfound++;
+ }
+ } /* NaN */
+ mem1+=sizeof(float);
+ mem2+=sizeof(float);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* i */
}
- /* -d and -p */
+ /*-------------------------------------------------------------------------
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
else if ( options->d && options->p)
{
@@ -2606,43 +2751,75 @@ hsize_t diff_float(unsigned char *mem1,
memcpy(&temp1_float, mem1, sizeof(float));
memcpy(&temp2_float, mem2, sizeof(float));
- PER(temp1_float,temp2_float);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float));
- }
- options->not_cmp=1;
- nfound++;
- }
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
+ isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
- else
+ if ( !isnan1 && !isnan2)
+ {
- if ( per > options->percent && ABS(temp1_float-temp2_float) > options->delta )
+ PER(temp1_float,temp2_float);
+
+ if (not_comparable && !both_zero) /* not comparable */
{
if ( print_data(options) )
{
print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float),
- ABS(1-temp2_float/temp1_float));
+ parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,
+ ABS(temp1_float-temp2_float));
}
+ options->not_cmp=1;
nfound++;
}
- mem1+=sizeof(float);
- mem2+=sizeof(float);
- if (options->n && nfound>=options->count)
- return nfound;
- }
+
+ else
+
+ if ( per > options->percent && ABS(temp1_float-temp2_float) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P,temp1_float,temp2_float,
+ ABS(temp1_float-temp2_float),
+ ABS(1-temp2_float/temp1_float));
+ }
+ nfound++;
+ }
+
+ } /* NaN */
+ mem1+=sizeof(float);
+ mem2+=sizeof(float);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* i */
}
+
+ /*-------------------------------------------------------------------------
+ * no -d and -p
+ *-------------------------------------------------------------------------
+ */
else
{
+
+#if defined (H5DIFF_DO_TIME)
+ int time;
+
+ #if defined (WIN32)
+ struct _timeb *tbstart = malloc(sizeof(struct _timeb));
+ struct _timeb *tbstop = malloc(sizeof(struct _timeb));
+ _ftime( tbstart);
+ #else
+ struct timeb *tbstart = malloc(sizeof(struct timeb));
+ struct timeb *tbstop = malloc(sizeof(struct timeb));
+ ftime( tbstart);
+ #endif
+
+#endif
for ( i = 0; i < nelmts; i++)
{
@@ -2665,7 +2842,24 @@ hsize_t diff_float(unsigned char *mem1,
mem2+=sizeof(float);
if (options->n && nfound>=options->count)
return nfound;
+
} /* nelmts */
+
+
+
+#if defined (H5DIFF_DO_TIME)
+
+ #if defined (WIN32)
+ _ftime( tbstop );
+ #else
+ ftime( tbstop );
+ #endif
+
+ time = tbstop->time - tbstart->time;
+ printf(" TIME = %d sec\n", time );
+
+#endif
+
}
@@ -4705,7 +4899,7 @@ error:
/*-------------------------------------------------------------------------
- * Function: equal_float, equal_double
+ * Function: equal_double
*
* Purpose: use a relative error formula to deal with floating point
* uncertainty
@@ -4714,18 +4908,50 @@ error:
* October 24, 2006
*
* Modifications:
+ * 8/1/2007. handle NaNs
*
*-------------------------------------------------------------------------
*/
-
-
-
static
hbool_t equal_double(double value, double expected)
{
int both_zero;
int is_zero;
+#if defined (H5DIFF_DO_NAN)
+
+/*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ int isnan1 = my_isnan(FLT_DOUBLE,&value);
+ int isnan2 = my_isnan(FLT_DOUBLE,&expected);
+
+ /*-------------------------------------------------------------------------
+ * we consider NaN == NaN to be true
+ *-------------------------------------------------------------------------
+ */
+ if ( isnan1 && isnan2 )
+ {
+ return TRUE;
+ }
+
+ /*-------------------------------------------------------------------------
+ * one is a NaN, do not compare but assume difference
+ *-------------------------------------------------------------------------
+ */
+ if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) )
+ {
+ return FALSE;
+ }
+
+ /*-------------------------------------------------------------------------
+ * both are not NaNs, compare
+ *-------------------------------------------------------------------------
+ */
+
+#endif
+
BOTH_ZERO(value,expected)
if (both_zero)
return TRUE;
@@ -4741,8 +4967,6 @@ hbool_t equal_double(double value, double expected)
}
-
-
/*-------------------------------------------------------------------------
* Function: equal_float
*
@@ -4763,6 +4987,8 @@ hbool_t equal_float(float value, float expected)
int both_zero;
int is_zero;
+#if defined (H5DIFF_DO_NAN)
+
/*-------------------------------------------------------------------------
* detect NaNs
*-------------------------------------------------------------------------
@@ -4770,8 +4996,6 @@ hbool_t equal_float(float value, float expected)
int isnan1 = my_isnan(FLT_FLOAT,&value);
int isnan2 = my_isnan(FLT_FLOAT,&expected);
-
-
/*-------------------------------------------------------------------------
* we consider NaN == NaN to be true
*-------------------------------------------------------------------------
@@ -4794,6 +5018,8 @@ hbool_t equal_float(float value, float expected)
* both are not NaNs, compare
*-------------------------------------------------------------------------
*/
+
+#endif
BOTH_ZERO(value,expected)
if (both_zero)
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 3d8c871..6fc09d7 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -30,6 +30,7 @@
#include "h5tools_utils.h"
#include "H5private.h"
+#define SANITY_CHECK
#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z))
@@ -612,7 +613,7 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
}
/*
- * We need to break after each row of a dimension---> we should
+ * We need to break after each row_counter of a dimension---> we should
* break at the end of the each last dimension well that is the
* way the dumper did it before
*/
@@ -706,28 +707,40 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
* Chapter: H5Tools Library
* Purpose: Dump out a subset of a dataset.
* Description:
- * Select a hyperslab from the dataset DSET using the parameters
- * specified in SSET. Dump this out to STREAM.
+ *
+ * Select a hyperslab from the dataset DSET using the parameters
+ * specified in SSET. Dump this out to STREAM.
+ *
+ * Hyperslabs select "count" blocks of size "block", spaced "stride" elements
+ * from each other, starting at coordinate "start".
+ *
* Return:
* On success, return SUCCEED. Otherwise, the function returns FAIL.
- * Programmer:
- * Bill Wendling, Wednesday, 07. March 2001
- * Modifications:
- * Pedro Vicente, 12 December 2006
- * Add information to print array indices from the element position
- * The algorythm used is
+ *
+ * Original programmer:
+ * Bill Wendling, Wednesday, March 07, 2001
+ *
+ * Rewritten with modified algorithm by:
+ * Pedro Vicente, Wednesday, January 16, 2008, contributions from Quincey Koziol
+ *
+ * Algorithm
+ *
+ * In a inner loop, the parameters from SSET are translated into temporary
+ * variables so that 1 row is printed at a time (getting the coordinate indices
+ * at each row).
+ * We define the stride, count and block to be 1 in the row dimension to achieve
+ * this and advance until all points are printed.
+ * An outer loop for cases where dimensionality is greater than 2D is made.
+ * In each iteration, the 2D block is displayed in the inner loop. The remaining
+ * slower dimensions above the first 2 are incremented one at a time in the outer loop
+ *
+ * The element position is obtained from the matrix according to:
* Given an index I(z,y,x) its position from the beginning of an array
* of sizes A(size_z, size_y,size_x) is given by
* Position of I(z,y,x) = index_z * size_y * size_x
* + index_y * size_x
* + index_x
- *
- * Pedro Vicente, Quincey Koziol, 4 January 2007
- * Introduced an outer loop for cases where dimensionality is greater
- * than 2D. In each iteration a 2D block is displayed by rows in a inner
- * loop. The remainning slower dimensions above the first 2 are incremented
- * one at a time in the outer loop
- *
+ *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -755,13 +768,21 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
hid_t sm_space; /* stripmine data space */
hsize_t count; /* hyperslab count */
hsize_t outer_count; /* offset count */
- unsigned int row_dim; /* index of row dimension */
+ unsigned int row_dim; /* index of row_counter dimension */
int current_outer_dim; /* dimension for start */
hsize_t temp_start[H5S_MAX_RANK];/* temporary start inside offset count loop */
hsize_t max_start[H5S_MAX_RANK]; /* maximum start inside offset count loop */
hsize_t temp_count[H5S_MAX_RANK];/* temporary count inside offset count loop */
-
- int reset_dim;
+ hsize_t temp_block[H5S_MAX_RANK];/* temporary block size used in loop */
+ hsize_t temp_stride[H5S_MAX_RANK];/* temporary stride size used in loop */
+ int reset_dim;
+ hsize_t size_row_block; /* size for blocks along rows */
+
+#if defined (SANITY_CHECK)
+ hsize_t total_points = 1; /* to print */
+ hsize_t printed_points = 0; /* printed */
+#endif
+
ret = FAIL; /* be pessimistic */
f_space = H5Dget_space(dset);
@@ -799,17 +820,32 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
outer_count = 1;
if (ctx.ndims > 2)
for (i = 0; i < (size_t)ctx.ndims - 2; i++)
- outer_count *= sset->count[ i ];
+ {
+ /* consider block size */
+ outer_count = outer_count * sset->count[ i ] * sset->block[ i ];
+
+ }
if(ctx.ndims>0)
init_acc_pos(&ctx,total_size);
+ /* calculate total number of points to print */
+#if defined (SANITY_CHECK)
+ for (i = 0; i < (size_t)ctx.ndims; i++)
+ {
+ total_points *= sset->count[ i ] * sset->block[ i ];;
+ }
+#endif
+
+
/* initialize temporary start, count and maximum start */
for (i = 0; i < (size_t)ctx.ndims; i++)
{
temp_start[ i ] = sset->start[ i ];
temp_count[ i ] = sset->count[ i ];
+ temp_block[ i ] = sset->block[ i ];
+ temp_stride[ i ] = sset->stride[ i ];
max_start[ i ] = 0;
}
@@ -828,29 +864,69 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
for (n = 0; n < outer_count; n++)
{
+ hsize_t row_counter = 0;
+
/* number of read iterations in inner loop, read by rows, to match 2D display */
if (ctx.ndims > 1)
{
- count = sset->count[ row_dim ];
- temp_count[ row_dim ] = 1;
+
+ /* count is the number of iterations to display all the rows,
+ the block size count times */
+ count = sset->count[ row_dim ] * sset->block[ row_dim ];
+
+ /* always 1 row_counter at a time, that is a block of size 1, 1 time */
+ temp_count[ row_dim ] = 1;
+ temp_block[ row_dim ] = 1;
+
+ /* advance 1 row_counter at a time */
+ if (sset->block[ row_dim ] > 1 )
+ temp_stride[ row_dim ] = 1;
+
+
}
/* for the 1D case */
else
{
count = 1;
}
-
+
+ size_row_block = sset->block[ row_dim ];
+
+
/* display loop */
- for (; count > 0; temp_start[ row_dim ] += sset->stride[ row_dim ],
- count--)
- {
+ for (; count > 0;
+ temp_start[ row_dim ] += temp_stride[ row_dim ],
+ count--)
+ {
+
+
+ /* jump rows if size of block exceeded
+ cases where block > 1 only and stride > block */
+ if ( size_row_block > 1 &&
+ row_counter == size_row_block &&
+ sset->stride[ row_dim ] > sset->block[ row_dim ]
+ )
+ {
+
+ hsize_t increase_rows = sset->stride[ row_dim ] -
+ sset->block[ row_dim ];
+
+ temp_start[ row_dim ] += increase_rows;
+
+ row_counter = 0;
+
+ }
+
+ row_counter++;
+
+
/* calculate the potential number of elements we're going to print */
H5Sselect_hyperslab(f_space, H5S_SELECT_SET,
temp_start,
- sset->stride,
+ temp_stride,
temp_count,
- sset->block);
+ temp_block);
sm_nelmts = H5Sget_select_npoints(f_space);
if (sm_nelmts == 0) {
@@ -920,6 +996,13 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
ctx.need_prefix = 1;
ctx.continuation++;
+
+
+#if defined (SANITY_CHECK)
+ printed_points += sm_nelmts;
+#endif
+
+
} /* count */
if (ctx.ndims > 2)
@@ -930,8 +1013,9 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
/* set start to original from current_outer_dim up */
for (i = current_outer_dim + 1; i < ctx.ndims; i++)
{
- temp_start[ i ] = sset->start[ i ];
+ temp_start[ i ] = sset->start[ i ];
}
+
/* increment start dimension */
do
@@ -941,6 +1025,11 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
if (temp_start[ current_outer_dim ] >= max_start[ current_outer_dim ])
{
temp_start[ current_outer_dim ] = sset->start[ current_outer_dim ];
+
+ /* consider block */
+ if ( sset->block[ current_outer_dim ] > 1 )
+ temp_start[ current_outer_dim ]++;
+
current_outer_dim--;
reset_dim = 1;
}
@@ -951,6 +1040,11 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
} /* outer_count */
+#if defined (SANITY_CHECK)
+ assert( printed_points == total_points );
+#endif
+
+
/* Terminate the output */
if (ctx.cur_column) {
fputs(OPT(info->line_suf, ""), stream);
@@ -1459,9 +1553,6 @@ int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem)
static
int render_bin_output(FILE *stream, hid_t tid, void *_mem)
{
-#if 0
- #define DEBUG_H5DUMP_BIN 1
-#endif
unsigned char *mem = (unsigned char*)_mem;
size_t size; /* datum size */
float tempfloat;
diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c
index 123065b..de1e2c3 100644
--- a/tools/lib/h5tools_ref.c
+++ b/tools/lib/h5tools_ref.c
@@ -20,6 +20,7 @@
#include "H5SLprivate.h"
#include "h5tools.h"
#include "h5tools_utils.h"
+#include "h5trav.h"
/*
@@ -42,15 +43,12 @@ typedef struct {
} ref_path_node_t;
static H5SL_t *ref_path_table = NULL; /* the "table" (implemented with a skip list) */
-static hid_t thefile;
+static hid_t thefile = (-1);
extern char *progname;
extern int d_status;
static int ref_path_table_put(const char *, haddr_t objno);
-static hbool_t ref_path_table_find(haddr_t objno);
-static herr_t fill_ref_path_table_cb(hid_t group, const char *obj_name,
- const H5L_info_t *linfo, void *op_data);
/*-------------------------------------------------------------------------
* Function: free_ref_path_info
@@ -77,6 +75,61 @@ free_ref_path_info(void *item, void UNUSED *key, void UNUSED *operator_data/*in,
}
/*-------------------------------------------------------------------------
+ * Function: init_ref_path_cb
+ *
+ * Purpose: Called by interator to create references for
+ * all objects and enter them in the table.
+ *
+ * Return: Error status.
+ *
+ * Programmer: REMcG
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+init_ref_path_cb(const char *obj_name, const H5O_info_t *oinfo,
+ const char *already_seen, void UNUSED *_udata)
+{
+ /* Check if the object is already in the path table */
+ if(NULL == already_seen) {
+ /* Insert the object into the path table */
+ ref_path_table_put(obj_name, oinfo->addr);
+ } /* end if */
+
+ return 0;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: init_ref_path_table
+ *
+ * Purpose: Initalize the reference path table
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Quincey Koziol
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+init_ref_path_table(void)
+{
+ /* Sanity check */
+ HDassert(thefile > 0);
+
+ /* Create skip list to store reference path information */
+ if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16))==NULL)
+ return (-1);
+
+ /* Iterate over objects in this file */
+ if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL) < 0) {
+ error_msg(progname, "unable to construct reference path table\n");
+ d_status = EXIT_FAILURE;
+ } /* end if */
+
+ return(0);
+}
+
+/*-------------------------------------------------------------------------
* Function: term_ref_path_table
*
* Purpose: Terminate the reference path table
@@ -137,39 +190,11 @@ ref_path_table_lookup(const char *thepath)
if(H5Oget_info_by_name(thefile, thepath, &oi, H5P_DEFAULT) < 0)
return HADDR_UNDEF;
- /* All existing objects in the file had better be in the table */
- HDassert(ref_path_table_find(oi.addr));
-
/* Return OID */
return(oi.addr);
}
/*-------------------------------------------------------------------------
- * Function: ref_path_table_find
- *
- * Purpose: Looks up a table entry given a object number.
- * Used during construction of the table.
- *
- * Return: TRUE/FALSE on success, can't fail
- *
- * Programmer: Quincey Koziol
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static hbool_t
-ref_path_table_find(haddr_t objno)
-{
- HDassert(ref_path_table);
-
- if(H5SL_search(ref_path_table, &objno) == NULL)
- return FALSE;
- else
- return TRUE;
-}
-
-/*-------------------------------------------------------------------------
* Function: ref_path_table_put
*
* Purpose: Enter the 'obj' with 'path' in the table (assumes its not
@@ -200,7 +225,7 @@ ref_path_table_put(const char *path, haddr_t objno)
return(-1);
new_node->objno = objno;
- new_node->path = path;
+ new_node->path = HDstrdup(path);
return(H5SL_insert(ref_path_table, new_node, &(new_node->objno)));
}
@@ -237,17 +262,17 @@ get_fake_xid (void) {
haddr_t
ref_path_table_gen_fake(const char *path)
{
- const char *dup_path;
haddr_t fake_objno;
- if((dup_path = HDstrdup(path)) == NULL)
- return HADDR_UNDEF;
-
/* Generate fake ID for string */
fake_objno = get_fake_xid();
- /* Insert "fake" object into table (takes ownership of path) */
- ref_path_table_put(dup_path, fake_objno);
+ /* Create ref path table, if it hasn't already been created */
+ if(ref_path_table == NULL)
+ init_ref_path_table();
+
+ /* Insert "fake" object into table */
+ ref_path_table_put(path, fake_objno);
return(fake_objno);
}
@@ -271,74 +296,19 @@ lookup_ref_path(haddr_t ref)
ref_path_node_t *node;
/* Be safer for h5ls */
- if(!ref_path_table)
+ if(thefile < 0)
return(NULL);
+ /* Create ref path table, if it hasn't already been created */
+ if(ref_path_table == NULL)
+ init_ref_path_table();
+
node = H5SL_search(ref_path_table, &ref);
return(node ? node->path : NULL);
}
/*-------------------------------------------------------------------------
- * Function: fill_ref_path_table_cb
- *
- * Purpose: Called by interator to create references for
- * all objects and enter them in the table.
- *
- * Return: Error status.
- *
- * Programmer: REMcG
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-fill_ref_path_table_cb(hid_t group, const char *obj_name, const H5L_info_t *linfo,
- void *op_data)
-{
- if(linfo->type == H5L_TYPE_HARD) {
- H5O_info_t oinfo;
-
- H5Oget_info_by_name(group, obj_name, &oinfo, H5P_DEFAULT);
-
- /* Check if the object is already in the path table */
- if(!ref_path_table_find(oinfo.addr)) {
- const char *obj_prefix = (const char *)op_data;
- size_t tmp_len;
- char *thepath;
-
- /* Compute length for this object's path */
- tmp_len = HDstrlen(obj_prefix) + HDstrlen(obj_name) + 2;
-
- /* Allocate room for the path for this object */
- if((thepath = (char *)HDmalloc(tmp_len)) == NULL)
- return FAIL;
-
- /* Build the name for this object */
- HDstrcpy(thepath, obj_prefix);
- HDstrcat(thepath, "/");
- HDstrcat(thepath, obj_name);
-
- /* Insert the object into the path table (takes ownership of the path) */
- ref_path_table_put(thepath, oinfo.addr);
-
- if(oinfo.type == H5O_TYPE_GROUP) {
- /* Iterate over objects in this group, using this group's
- * name as their prefix
- */
- if(H5Literate_by_name(group, obj_name, H5_INDEX_NAME, H5_ITER_INC, NULL, fill_ref_path_table_cb, thepath, H5P_DEFAULT) < 0) {
- error_msg(progname, "unable to dump group \"%s\"\n", thepath);
- d_status = EXIT_FAILURE;
- } /* end if */
- } /* end if */
- } /* end if */
- } /* end if */
-
- return 0;
-}
-
-/*-------------------------------------------------------------------------
* Function: fill_ref_path_table
*
* Purpose: Called by interator to create references for
@@ -348,37 +318,15 @@ fill_ref_path_table_cb(hid_t group, const char *obj_name, const H5L_info_t *linf
*
* Programmer: REMcG
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
fill_ref_path_table(hid_t fid)
{
- H5O_info_t oinfo;
- char *root_path;
-
/* Set file ID for later queries (XXX: this should be fixed) */
thefile = fid;
- /* Create skip list to store reference path information */
- if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16))==NULL)
- return (-1);
-
- /* Build the name for root group */
- root_path = HDstrdup("/");
-
- /* Get info for root group */
- H5Oget_info_by_name(fid, root_path, &oinfo, H5P_DEFAULT);
-
- /* Insert the root group into the path table (takes ownership of path) */
- ref_path_table_put(root_path, oinfo.addr);
-
- /* Iterate over objects in this file */
- if(H5Literate(fid, H5_INDEX_NAME, H5_ITER_INC, NULL, fill_ref_path_table_cb, (void *)"") < 0) {
- error_msg(progname, "unable to dump root group\n");
- d_status = EXIT_FAILURE;
- } /* end if */
+ /* Defer creating the ref path table until it's needed */
return 0;
}
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index cb38e7a..512a3fb 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -30,6 +30,7 @@
#include "h5tools_utils.h"
#include "H5private.h"
+#include "h5trav.h"
/* global variables */
int nCols = 80;
@@ -44,10 +45,7 @@ static void init_table(table_t **tbl);
#ifdef H5DUMP_DEBUG
static void dump_table(char* tablename, table_t *table);
#endif /* H5DUMP_DEBUG */
-static void add_obj(table_t *table, haddr_t objno, char *objname, hbool_t recorded);
-static char * build_obj_path_name(const char *prefix, const char *name);
-static herr_t find_objs_cb(hid_t group, const char *name, const H5L_info_t *info,
- void *op_data);
+static void add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t recorded);
/*-------------------------------------------------------------------------
@@ -428,44 +426,15 @@ search_obj(table_t *table, haddr_t objno)
{
unsigned u;
- for (u = 0; u < table->nobjs; u++)
- if (table->objs[u].objno == objno)
- return &(table->objs[u]);
+ for(u = 0; u < table->nobjs; u++)
+ if(table->objs[u].objno == objno)
+ return &(table->objs[u]);
return NULL;
}
/*-------------------------------------------------------------------------
- * Function: build_obj_path_name
- *
- * Purpose: Allocate space & build path name from prefix & name
- *
- * Return: Success: SUCCEED
- *
- * Failure: FAIL
- *
- * Programmer: Quincey Koziol
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static char *
-build_obj_path_name(const char *prefix, const char *name)
-{
- char *path;
-
- path = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
- HDstrcpy(path, prefix);
- HDstrcat(path,"/");
- HDstrcat(path,name); /* absolute name of the data set */
-
- return(path);
-} /* end build_obj_path_name() */
-
-
-/*-------------------------------------------------------------------------
* Function: find_objs_cb
*
* Purpose: Callback to find objects, committed types and store them in tables
@@ -481,90 +450,65 @@ build_obj_path_name(const char *prefix, const char *name)
*-------------------------------------------------------------------------
*/
static herr_t
-find_objs_cb(hid_t group, const char *name, const H5L_info_t UNUSED *linfo, void *op_data)
+find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen,
+ void *op_data)
{
- H5O_info_t oinfo;
find_objs_t *info = (find_objs_t*)op_data;
herr_t ret_value = 0;
- if(H5Oget_info_by_name(group, name, &oinfo, H5P_DEFAULT) < 0)
- ; /* keep going */
- else {
- switch(oinfo.type) {
- char *tmp;
- size_t tmp_len;
-
- case H5O_TYPE_GROUP:
- if(search_obj(info->group_table, oinfo.addr) == NULL) {
- char *old_prefix;
+ switch(oinfo->type) {
+ case H5O_TYPE_GROUP:
+ if(NULL == already_seen)
+ add_obj(info->group_table, oinfo->addr, name, TRUE);
+ break;
- tmp = build_obj_path_name(info->prefix, name);
- add_obj(info->group_table, oinfo.addr, tmp, TRUE);
+ case H5O_TYPE_DATASET:
+ if(NULL == already_seen) {
+ hid_t dset;
- old_prefix = info->prefix;
- tmp_len = HDstrlen(tmp);
- info->prefix = HDmalloc(tmp_len+1);
- HDstrcpy(info->prefix, tmp);
+ /* Add the dataset to the list of objects */
+ add_obj(info->dset_table, oinfo->addr, name, TRUE);
- if(H5Literate_by_name(group, name, H5_INDEX_NAME, H5_ITER_INC, NULL, find_objs_cb, (void *)info, H5P_DEFAULT) < 0)
- ret_value = FAIL;
+ /* Check for a dataset that uses a named datatype */
+ if((dset = H5Dopen2(info->fid, name, H5P_DEFAULT)) >= 0) {
+ hid_t type = H5Dget_type(dset);
- info->prefix = old_prefix;
- } /* end if */
- break;
-
- case H5O_TYPE_DATASET:
- if(search_obj(info->dset_table, oinfo.addr) == NULL) {
- hid_t dset;
-
- tmp = build_obj_path_name(info->prefix, name);
- add_obj(info->dset_table, oinfo.addr, tmp, TRUE);
-
- if((dset = H5Dopen2(group, name, H5P_DEFAULT)) >= 0) {
- hid_t type;
+ if(H5Tcommitted(type) > 0) {
+ H5O_info_t type_oinfo;
- type = H5Dget_type(dset);
-
- if(H5Tcommitted(type) > 0) {
- H5Oget_info(type, &oinfo);
- if(search_obj(info->type_table, oinfo.addr) == NULL) {
- char *type_name = HDstrdup(tmp);
-
- add_obj(info->type_table, oinfo.addr, type_name, FALSE);
- } /* end if */
- } /* end if */
-
- H5Tclose(type);
- H5Dclose(dset);
+ H5Oget_info(type, &type_oinfo);
+ if(search_obj(info->type_table, type_oinfo.addr) == NULL)
+ add_obj(info->type_table, type_oinfo.addr, name, FALSE);
} /* end if */
- else
- ret_value = FAIL;
- } /* end if */
- break;
- case H5O_TYPE_NAMED_DATATYPE:
- {
- obj_t *found_obj;
-
- tmp = build_obj_path_name(info->prefix, name);
- if((found_obj = search_obj(info->type_table, oinfo.addr)) == NULL)
- add_obj(info->type_table, oinfo.addr, tmp, TRUE);
- else {
- /* Use latest version of name */
- HDfree(found_obj->objname);
- found_obj->objname = HDstrdup(tmp);
-
- /* Mark named datatype as having valid name */
- found_obj->recorded = TRUE;
- } /* end else */
- break;
- }
-
- default:
- /* Ignore links, etc. */
- break;
+ H5Tclose(type);
+ H5Dclose(dset);
+ } /* end if */
+ else
+ ret_value = FAIL;
+ } /* end if */
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ {
+ obj_t *found_obj;
+
+ if((found_obj = search_obj(info->type_table, oinfo->addr)) == NULL)
+ add_obj(info->type_table, oinfo->addr, name, TRUE);
+ else {
+ /* Use latest version of name */
+ HDfree(found_obj->objname);
+ found_obj->objname = HDstrdup(name);
+
+ /* Mark named datatype as having valid name */
+ found_obj->recorded = TRUE;
+ } /* end else */
+ break;
}
- } /* end else */
+
+ default:
+ break;
+ } /* end switch */
return ret_value;
}
@@ -589,31 +533,19 @@ herr_t
init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
table_t **dset_table, table_t **type_table)
{
- H5O_info_t oinfo;
-
/* Initialize the tables */
init_table(group_table);
init_table(dset_table);
init_table(type_table);
/* Init the find_objs_t */
- info->prefix = HDcalloc(1, 1);
+ info->fid = fid;
info->group_table = *group_table;
info->type_table = *type_table;
info->dset_table = *dset_table;
- /* add the root group as an object, it may have hard links to it */
- if(H5Oget_info(fid, &oinfo) < 0)
- return FAIL;
- else {
- /* call with an empty string, it appends '/' group separator */
- char *tmp = build_obj_path_name(info->prefix, "");
-
- add_obj(info->group_table, oinfo.addr, tmp, TRUE);
- } /* end else */
-
/* Find all shared objects */
- return(H5Literate(fid, H5_INDEX_NAME, H5_ITER_INC, NULL, find_objs_cb, (void *)info));
+ return(h5trav_visit(fid, "/", TRUE, TRUE, find_objs_cb, NULL, info));
}
@@ -632,22 +564,22 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
*-------------------------------------------------------------------------
*/
static void
-add_obj(table_t *table, haddr_t objno, char *objname, hbool_t record)
+add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t record)
{
unsigned u;
/* See if we need to make table larger */
- if (table->nobjs == table->size) {
+ if(table->nobjs == table->size) {
table->size *= 2;
- table->objs = HDrealloc(table->objs, table->size * sizeof(obj_t));
- }
+ table->objs = HDrealloc(table->objs, table->size * sizeof(table->objs[0]));
+ } /* end if */
/* Increment number of objects in table */
u = table->nobjs++;
/* Set information about object */
table->objs[u].objno = objno;
- table->objs[u].objname = objname;
+ table->objs[u].objname = HDstrdup(objname);
table->objs[u].recorded = record;
table->objs[u].displayed = 0;
}
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index e604e5a..e7b175c 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -95,7 +95,7 @@ typedef struct table_t {
/*this struct stores the information that is passed to the find_objs function*/
typedef struct find_objs_t {
- char *prefix;
+ hid_t fid;
table_t *group_table;
table_t *type_table;
table_t *dset_table;
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index 97de021..14ced60 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -24,24 +24,25 @@
typedef struct trav_addr_t {
size_t nalloc;
size_t nused;
- haddr_t *addrs;
+ struct {
+ haddr_t addr;
+ char *path;
+ } *objs;
} trav_addr_t;
typedef struct {
- herr_t (*visit_obj)(const char *path_name, const H5O_info_t *oinfo, hbool_t already_visited, void *udata);
- herr_t (*visit_lnk)(const char *path_name, const H5L_info_t *linfo, void *udata);
+ h5trav_obj_func_t visit_obj; /* Callback for visiting objects */
+ h5trav_lnk_func_t visit_lnk; /* Callback for visiting links */
void *udata; /* User data to pass to callbacks */
} trav_visitor_t;
typedef struct {
trav_addr_t *seen; /* List of addresses seen already */
- const char *curr_path; /* Current path to parent group */
const trav_visitor_t *visitor; /* Information for visiting each link/object */
} trav_ud_traverse_t;
typedef struct {
hid_t fid; /* File ID being traversed */
- trav_table_t *table; /* Table for tracking name of objects with >1 hard link */
} trav_print_udata_t;
/*-------------------------------------------------------------------------
@@ -52,10 +53,8 @@ static void trav_table_add(trav_table_t *table,
const char *objname,
const H5O_info_t *oinfo);
-static size_t trav_table_search(const trav_table_t *table, haddr_t objno);
-
static void trav_table_addlink(trav_table_t *table,
- size_t j /* the object index */,
+ haddr_t objno,
const char *path);
/*-------------------------------------------------------------------------
@@ -78,19 +77,20 @@ static void trav_table_addlink(trav_table_t *table,
*-------------------------------------------------------------------------
*/
static void
-trav_addr_add(trav_addr_t *visited, haddr_t addr)
+trav_addr_add(trav_addr_t *visited, haddr_t addr, const char *path)
{
size_t idx; /* Index of address to use */
/* Allocate space if necessary */
if(visited->nused == visited->nalloc) {
visited->nalloc = MAX(1, visited->nalloc * 2);;
- visited->addrs = (haddr_t *)HDrealloc(visited->addrs, visited->nalloc * sizeof(haddr_t));
+ visited->objs = HDrealloc(visited->objs, visited->nalloc * sizeof(visited->objs[0]));
} /* end if */
/* Append it */
idx = visited->nused++;
- visited->addrs[idx] = addr;
+ visited->objs[idx].addr = addr;
+ visited->objs[idx].path = HDstrdup(path);
} /* end trav_addr_add() */
@@ -107,7 +107,7 @@ trav_addr_add(trav_addr_t *visited, haddr_t addr)
*
*-------------------------------------------------------------------------
*/
-static hbool_t
+static const char *
trav_addr_visited(trav_addr_t *visited, haddr_t addr)
{
size_t u; /* Local index variable */
@@ -115,11 +115,11 @@ trav_addr_visited(trav_addr_t *visited, haddr_t addr)
/* Look for address */
for(u = 0; u < visited->nused; u++)
/* Check for address already in array */
- if(visited->addrs[u] == addr)
- return(TRUE);
+ if(visited->objs[u].addr == addr)
+ return(visited->objs[u].path);
/* Didn't find address */
- return(FALSE);
+ return(NULL);
} /* end trav_addr_visited() */
@@ -135,68 +135,44 @@ trav_addr_visited(trav_addr_t *visited, haddr_t addr)
*-------------------------------------------------------------------------
*/
static herr_t
-traverse_cb(hid_t loc_id, const char *link_name, const H5L_info_t *linfo,
+traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
void *_udata)
{
trav_ud_traverse_t *udata = (trav_ud_traverse_t *)_udata; /* User data */
- hbool_t is_group = FALSE; /* If the object is a group */
- hbool_t already_visited = FALSE; /* Whether the link/object was already visited */
- char *link_path; /* Full path name of a link */
+ char *full_name;
+ const char *already_visited = NULL; /* Whether the link/object was already visited */
- /* Construct the full path name of this link */
- link_path = (char*)HDmalloc(HDstrlen(udata->curr_path) + HDstrlen(link_name) + 2);
- HDassert(link_path);
- HDstrcpy(link_path, udata->curr_path);
- HDstrcat(link_path, "/");
- HDstrcat(link_path, link_name);
+ /* Create the full path name for the link */
+ full_name = HDmalloc(HDstrlen(path) + 2);
+ *full_name = '/';
+ HDstrcpy(full_name + 1, path);
/* Perform the correct action for different types of links */
if(linfo->type == H5L_TYPE_HARD) {
H5O_info_t oinfo;
/* Get information about the object */
- if(H5Oget_info_by_name(loc_id, link_name, &oinfo, H5P_DEFAULT) < 0)
+ if(H5Oget_info_by_name(loc_id, path, &oinfo, H5P_DEFAULT) < 0)
return(H5_ITER_ERROR);
/* If the object has multiple links, add it to the list of addresses
* already visited, if it isn't there already
*/
- if(oinfo.rc > 1) {
- already_visited = trav_addr_visited(udata->seen, oinfo.addr);
- if(!already_visited)
- trav_addr_add(udata->seen, oinfo.addr);
- } /* end if */
-
- /* Check if object is a group, for later */
- is_group = (oinfo.type == H5O_TYPE_GROUP) ? TRUE : FALSE;
+ if(oinfo.rc > 1)
+ if(NULL == (already_visited = trav_addr_visited(udata->seen, oinfo.addr)))
+ trav_addr_add(udata->seen, oinfo.addr, full_name);
/* Make 'visit object' callback */
if(udata->visitor->visit_obj)
- (*udata->visitor->visit_obj)(link_path, &oinfo, already_visited, udata->visitor->udata);
+ (*udata->visitor->visit_obj)(full_name, &oinfo, already_visited, udata->visitor->udata);
} /* end if */
else {
/* Make 'visit link' callback */
if(udata->visitor->visit_lnk)
- (*udata->visitor->visit_lnk)(link_path, linfo, udata->visitor->udata);
+ (*udata->visitor->visit_lnk)(full_name, linfo, udata->visitor->udata);
} /* end else */
- /* Check for group that we haven't visited yet & recurse */
- if(is_group && !already_visited) {
- const char *prev_path = udata->curr_path; /* Previous path to link's parent group */
-
- /* Set current path to this object */
- udata->curr_path = link_path;
-
- /* Iterate over all links in group object */
- if(H5Literate_by_name(loc_id, link_name, H5_INDEX_NAME, H5_ITER_INC, NULL, traverse_cb, udata, H5P_DEFAULT) < 0)
- return(H5_ITER_ERROR);
-
- /* Restore path in udata */
- udata->curr_path = prev_path;
- } /* end if */
-
- /* Free path name for current link/object */
- HDfree(link_path);
+ HDfree(full_name);
return(H5_ITER_CONT);
} /* end traverse_cb() */
@@ -217,39 +193,58 @@ traverse_cb(hid_t loc_id, const char *link_name, const H5L_info_t *linfo,
*-------------------------------------------------------------------------
*/
static int
-traverse(hid_t file_id, const trav_visitor_t *visitor)
+traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
+ hbool_t recurse, const trav_visitor_t *visitor)
{
- H5O_info_t oinfo; /* Object info for root group */
- trav_addr_t seen; /* List of addresses seen */
- trav_ud_traverse_t udata; /* User data for iteration callback */
+ H5O_info_t oinfo; /* Object info for starting group */
- /* Get info for root group */
- if(H5Oget_info(file_id, &oinfo) < 0)
+ /* Get info for starting object */
+ if(H5Oget_info_by_name(file_id, grp_name, &oinfo, H5P_DEFAULT) < 0)
return -1;
- /* Visit the root group of the file */
- (*visitor->visit_obj)("/", &oinfo, FALSE, visitor->udata);
+ /* Visit the starting object */
+ if(visit_start && visitor->visit_obj)
+ (*visitor->visit_obj)(grp_name, &oinfo, NULL, visitor->udata);
- /* Init addresses seen */
- seen.nused = seen.nalloc = 0;
- seen.addrs = NULL;
+ /* Go visiting, if the object is a group */
+ if(oinfo.type == H5O_TYPE_GROUP) {
+ trav_addr_t seen; /* List of addresses seen */
+ trav_ud_traverse_t udata; /* User data for iteration callback */
- /* Check for multiple links to root group */
- if(oinfo.rc > 1)
- trav_addr_add(&seen, oinfo.addr);
+ /* Init addresses seen */
+ seen.nused = seen.nalloc = 0;
+ seen.objs = NULL;
- /* Set up user data structure */
- udata.seen = &seen;
- udata.curr_path = "";
- udata.visitor = visitor;
+ /* Check for multiple links to top group */
+ if(oinfo.rc > 1)
+ trav_addr_add(&seen, oinfo.addr, grp_name);
- /* Iterate over all links in root group */
- if(H5Literate(file_id, H5_INDEX_NAME, H5_ITER_INC, NULL, traverse_cb, &udata) < 0)
- return -1;
+ /* Set up user data structure */
+ udata.seen = &seen;
+ udata.visitor = visitor;
- /* Free visited addresses table */
- if(seen.addrs)
- HDfree(seen.addrs);
+ /* Check for iteration of links vs. visiting all links recursively */
+ if(recurse) {
+ /* Visit all links in group, recursively */
+ if(H5Lvisit_by_name(file_id, grp_name, H5_INDEX_NAME, H5_ITER_INC, traverse_cb, &udata, H5P_DEFAULT) < 0)
+ return -1;
+ } /* end if */
+ else {
+ /* Iterate over links in group */
+ if(H5Literate_by_name(file_id, grp_name, H5_INDEX_NAME, H5_ITER_INC, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0)
+ return -1;
+ } /* end else */
+
+ /* Free visited addresses table */
+ if(seen.objs) {
+ size_t u; /* Local index variable */
+
+ /* Free paths to objects */
+ for(u = 0; u < seen.nused; u++)
+ HDfree(seen.objs[u].path);
+ HDfree(seen.objs);
+ } /* end if */
+ } /* end if */
return 0;
}
@@ -301,7 +296,7 @@ trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type)
*/
static int
trav_info_visit_obj(const char *path, const H5O_info_t *oinfo,
- hbool_t UNUSED already_visited, void *udata)
+ const char UNUSED *already_visited, void *udata)
{
/* Add the object to the 'info' struct */
/* (object types map directly to "traversal" types) */
@@ -359,7 +354,7 @@ h5trav_getinfo(hid_t file_id, trav_info_t *info)
info_visitor.udata = info;
/* Traverse all objects in the file, visiting each object & link */
- if(traverse(file_id, &info_visitor) < 0)
+ if(traverse(file_id, "/", TRUE, TRUE, &info_visitor) < 0)
return -1;
return 0;
@@ -470,24 +465,17 @@ trav_info_free(trav_info_t *info)
*/
static int
trav_table_visit_obj(const char *path, const H5O_info_t *oinfo,
- hbool_t already_visited, void *udata)
+ const char *already_visited, void *udata)
{
trav_table_t *table = (trav_table_t *)udata;
/* Check if we've already seen this object */
- if(!already_visited)
+ if(NULL == already_visited)
/* add object to table */
trav_table_add(table, path, oinfo);
- else {
- size_t found; /* Index of original object seen */
-
- /* Look for object in existing table */
- found = trav_table_search(table, oinfo->addr);
- HDassert(found < table->nobjs);
-
+ else
/* Add alias for object to table */
- trav_table_addlink(table, found, path);
- } /* end else */
+ trav_table_addlink(table, oinfo->addr, path);
return(0);
} /* end trav_table_visit_obj() */
@@ -541,7 +529,7 @@ h5trav_gettable(hid_t fid, trav_table_t *table)
table_visitor.udata = table;
/* Traverse all objects in the file, visiting each object & link */
- if(traverse(fid, &table_visitor) < 0)
+ if(traverse(fid, "/", TRUE, TRUE, &table_visitor) < 0)
return -1;
return 0;
}
@@ -670,25 +658,33 @@ trav_table_add(trav_table_t *table,
*/
static void
-trav_table_addlink(trav_table_t *table,
- size_t j /* the object index */,
- const char *path)
+trav_table_addlink(trav_table_t *table, haddr_t objno, const char *path)
{
- size_t new;
+ size_t i; /* Local index variable */
- /* already inserted */
- if(HDstrcmp(table->objs[j].name, path) == 0)
- return;
+ for(i = 0; i < table->nobjs; i++) {
+ if(table->objs[i].objno == objno) {
+ size_t n;
- /* allocate space if necessary */
- if(table->objs[j].nlinks == (unsigned)table->objs[j].sizelinks) {
- table->objs[j].sizelinks = MAX(1, table->objs[j].sizelinks * 2);
- table->objs[j].links = (trav_link_t*)HDrealloc(table->objs[j].links, table->objs[j].sizelinks * sizeof(trav_link_t));
- } /* end if */
+ /* already inserted? */
+ if(HDstrcmp(table->objs[i].name, path) == 0)
+ return;
+
+ /* allocate space if necessary */
+ if(table->objs[i].nlinks == (unsigned)table->objs[i].sizelinks) {
+ table->objs[i].sizelinks = MAX(1, table->objs[i].sizelinks * 2);
+ table->objs[i].links = (trav_link_t*)HDrealloc(table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t));
+ } /* end if */
- /* insert it */
- new = table->objs[j].nlinks++;
- table->objs[j].links[new].new_name = (char *)HDstrdup(path);
+ /* insert it */
+ n = table->objs[i].nlinks++;
+ table->objs[i].links[n].new_name = (char *)HDstrdup(path);
+
+ return;
+ } /* end for */
+ } /* end for */
+
+ HDassert(0 && "object not in table?!?");
}
@@ -809,10 +805,8 @@ void trav_table_free( trav_table_t *table )
*/
static int
trav_print_visit_obj(const char *path, const H5O_info_t *oinfo,
- hbool_t already_visited, void *udata)
+ const char *already_visited, void UNUSED *udata)
{
- trav_print_udata_t *print_udata = (trav_print_udata_t *)udata;
-
/* Print the name of the object */
/* (no new-line, so that objects that we've encountered before can print
* the name of the original object)
@@ -836,26 +830,12 @@ trav_print_visit_obj(const char *path, const H5O_info_t *oinfo,
} /* end switch */
/* Check if we've already seen this object */
- if(!already_visited) {
+ if(NULL == already_visited)
/* Finish printing line about object */
printf("\n");
-
- /* Check if we will encounter another hard link to this object */
- if(oinfo->rc > 1) {
- /* Add object to table */
- trav_table_add(print_udata->table, path, oinfo);
- } /* end if */
- } /* end if */
- else {
- size_t found; /* Index of original object seen */
-
- /* Locate object in table */
- found = trav_table_search(print_udata->table, oinfo->addr);
- HDassert(found < print_udata->table->nobjs);
-
- /* Print the link's destination */
- printf(" -> %s\n", print_udata->table->objs[found].name);
- } /* end else */
+ else
+ /* Print the link's original name */
+ printf(" -> %s\n", already_visited);
return(0);
} /* end trav_print_visit_obj() */
@@ -938,16 +918,11 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
int
h5trav_print(hid_t fid)
{
- trav_table_t *table = NULL; /* Table for objects w/multiple hard links */
trav_print_udata_t print_udata; /* User data for traversal */
trav_visitor_t print_visitor; /* Visitor structure for printing objects */
- /* Initialize the table */
- trav_table_init(&table);
-
/* Init user data for printing */
print_udata.fid = fid;
- print_udata.table = table;
/* Init visitor structure */
print_visitor.visit_obj = trav_print_visit_obj;
@@ -955,11 +930,42 @@ h5trav_print(hid_t fid)
print_visitor.udata = &print_udata;
/* Traverse all objects in the file, visiting each object & link */
- if(traverse(fid, &print_visitor) < 0)
+ if(traverse(fid, "/", TRUE, TRUE, &print_visitor) < 0)
return -1;
- /* Free table */
- trav_table_free(table);
+ return 0;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5trav_visit
+ *
+ * Purpose: Generic traversal routine for visiting objects and links
+ *
+ * Return: 0, -1 on error
+ *
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
+ *
+ * Date: November 6, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+
+int
+h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start,
+ hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk,
+ void *udata)
+{
+ trav_visitor_t visitor; /* Visitor structure for objects */
+
+ /* Init visitor structure */
+ visitor.visit_obj = visit_obj;
+ visitor.visit_lnk = visit_lnk;
+ visitor.udata = udata;
+
+ /* Traverse all objects in the file, visiting each object & link */
+ if(traverse(fid, grp_name, visit_start, recurse, &visitor) < 0)
+ return -1;
return 0;
}
diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h
index 05bc3cb..5c07331 100644
--- a/tools/lib/h5trav.h
+++ b/tools/lib/h5trav.h
@@ -18,6 +18,12 @@
#include "hdf5.h"
+/* Typedefs for visiting objects */
+typedef herr_t (*h5trav_obj_func_t)(const char *path_name, const H5O_info_t *oinfo,
+ const char *first_seen, void *udata);
+typedef herr_t (*h5trav_lnk_func_t)(const char *path_name, const H5L_info_t *linfo,
+ void *udata);
+
/*-------------------------------------------------------------------------
* public enum to specify type of an object
* the TYPE can be:
@@ -101,6 +107,14 @@ extern "C" {
#endif
/*-------------------------------------------------------------------------
+ * "h5trav general" public functions
+ *-------------------------------------------------------------------------
+ */
+int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start,
+ hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk,
+ void *udata);
+
+/*-------------------------------------------------------------------------
* "h5trav info" public functions
*-------------------------------------------------------------------------
*/
diff --git a/tools/misc/Makefile.in b/tools/misc/Makefile.in
index 44d54c0..0644f5d 100644
--- a/tools/misc/Makefile.in
+++ b/tools/misc/Makefile.in
@@ -228,6 +228,7 @@ SET_MAKE = @SET_MAKE@
SHELL = /bin/sh
SIZE_T = @SIZE_T@
STATIC_SHARED = @STATIC_SHARED@
+STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
TESTPARALLEL = @TESTPARALLEL@
TIME = @TIME@
diff --git a/tools/misc/h5mkgrp.c b/tools/misc/h5mkgrp.c
index c39d07b..fbb6163 100644
--- a/tools/misc/h5mkgrp.c
+++ b/tools/misc/h5mkgrp.c
@@ -233,8 +233,8 @@ main(int argc, const char *argv[])
/* Check for creating groups with new format version */
if(params.latest) {
- /* Set the "use the latest version of the format flag */
- if(H5Pset_latest_format(fapl_id, TRUE) < 0) {
+ /* Set the "use the latest version of the format" bounds */
+ if(H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
error_msg(progname, "Could not set property for using latest version of the format\n");
leave(EXIT_FAILURE);
} /* end if */
diff --git a/tools/testfiles/h5copytst.out.ls b/tools/testfiles/h5copytst.out.ls
index c4d1778..9cad76f 100644
--- a/tools/testfiles/h5copytst.out.ls
+++ b/tools/testfiles/h5copytst.out.ls
@@ -2,58 +2,61 @@
Expected output for 'h5ls ../testfiles/h5copytst.out.h5'
#############################
Opened "../testfiles/h5copytst.out.h5" with sec2 driver.
+/ Group
+ Location: 1:96
+ Links: 1
/A Group
- Location: 1:90344
+ Location: 1:89936
Links: 1
/A/B1 Group
- Location: 1:91048
+ Location: 1:90640
Links: 1
/A/B1/simple Dataset {6/6}
- Location: 1:90216
+ Location: 1:89808
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/A/B2 Group
- Location: 1:94584
+ Location: 1:94176
Links: 1
/A/B2/simple2 Dataset {6/6}
- Location: 1:94456
+ Location: 1:94048
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/C Group
- Location: 1:97792
+ Location: 1:97384
Links: 1
/C/D Group
- Location: 1:98496
+ Location: 1:98088
Links: 1
/C/D/simple Dataset {6/6}
- Location: 1:97664
+ Location: 1:97256
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/E Group
- Location: 1:103920
+ Location: 1:112000
Links: 1
/E/F Group
- Location: 1:103960
+ Location: 1:112704
Links: 1
/E/F/grp_dsets Group
- Location: 1:100608
+ Location: 1:100200
Links: 1
/E/F/grp_dsets/chunk Dataset {6/6}
- Location: 1:102744
+ Location: 1:104384
Links: 1
Chunks: {2} 8 bytes
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/E/F/grp_dsets/compact Dataset {6/6}
- Location: 1:103200
+ Location: 1:104840
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/E/F/grp_dsets/compound Dataset {2/2}
- Location: 1:103336
+ Location: 1:104976
Links: 1
Storage: <details removed for portability>
Type: struct {
@@ -61,60 +64,60 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver.
"str2" +20 20-byte null-terminated ASCII string
} 40 bytes
/E/F/grp_dsets/compressed Dataset {6/6}
- Location: 1:103552
+ Location: 1:107288
Links: 1
Chunks: {2} 8 bytes
Storage: <details removed for portability>
Filter-0: deflate-1 OPT {1}
Type: 32-bit little-endian integer
/E/F/grp_dsets/named_vl Dataset {2/2}
- Location: 1:103768
+ Location: 1:111600
Links: 1
Storage: <details removed for portability>
- Type: shared-1:103720 variable length of
+ Type: shared-1:107456 variable length of
32-bit little-endian integer
/E/F/grp_dsets/nested_vl Dataset {2/2}
- Location: 1:112240
+ Location: 1:111728
Links: 1
Storage: <details removed for portability>
Type: variable length of
variable length of
32-bit little-endian integer
/E/F/grp_dsets/simple Dataset {6/6}
- Location: 1:112384
+ Location: 1:111872
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/E/F/grp_dsets/vl Type
- Location: 1:103720
+ Location: 1:107456
Links: 2
- Type: shared-1:103720 variable length of
+ Type: shared-1:107456 variable length of
32-bit little-endian integer
/G Group
- Location: 1:128176
+ Location: 1:127648
Links: 1
/G/H Group
- Location: 1:128880
+ Location: 1:128352
Links: 1
/G/H/grp_nested Group
- Location: 1:115160
+ Location: 1:114728
Links: 1
/G/H/grp_nested/grp_dsets Group
- Location: 1:115952
+ Location: 1:115520
Links: 1
/G/H/grp_nested/grp_dsets/chunk Dataset {6/6}
- Location: 1:118088
+ Location: 1:119704
Links: 1
Chunks: {2} 8 bytes
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/G/H/grp_nested/grp_dsets/compact Dataset {6/6}
- Location: 1:120688
+ Location: 1:120160
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/G/H/grp_nested/grp_dsets/compound Dataset {2/2}
- Location: 1:120824
+ Location: 1:120296
Links: 1
Storage: <details removed for portability>
Type: struct {
@@ -122,34 +125,34 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver.
"str2" +20 20-byte null-terminated ASCII string
} 40 bytes
/G/H/grp_nested/grp_dsets/compressed Dataset {6/6}
- Location: 1:123136
+ Location: 1:122608
Links: 1
Chunks: {2} 8 bytes
Storage: <details removed for portability>
Filter-0: deflate-1 OPT {1}
Type: 32-bit little-endian integer
/G/H/grp_nested/grp_dsets/named_vl Dataset {2/2}
- Location: 1:127448
+ Location: 1:126920
Links: 1
Storage: <details removed for portability>
- Type: shared-1:123304 variable length of
+ Type: shared-1:122776 variable length of
32-bit little-endian integer
/G/H/grp_nested/grp_dsets/nested_vl Dataset {2/2}
- Location: 1:127576
+ Location: 1:127048
Links: 1
Storage: <details removed for portability>
Type: variable length of
variable length of
32-bit little-endian integer
/G/H/grp_nested/grp_dsets/simple Dataset {6/6}
- Location: 1:127720
+ Location: 1:127192
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/G/H/grp_nested/grp_dsets/vl Type
- Location: 1:123304
+ Location: 1:122776
Links: 2
- Type: shared-1:123304 variable length of
+ Type: shared-1:122776 variable length of
32-bit little-endian integer
/chunk Dataset {6/6}
Location: 1:6216
@@ -181,18 +184,18 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver.
Location: 1:33760
Links: 1
/grp_dsets/chunk Dataset {6/6}
- Location: 1:35896
+ Location: 1:37944
Links: 1
Chunks: {2} 8 bytes
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/grp_dsets/compact Dataset {6/6}
- Location: 1:36352
+ Location: 1:38400
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/grp_dsets/compound Dataset {2/2}
- Location: 1:36488
+ Location: 1:38536
Links: 1
Storage: <details removed for portability>
Type: struct {
@@ -200,62 +203,62 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver.
"str2" +20 20-byte null-terminated ASCII string
} 40 bytes
/grp_dsets/compressed Dataset {6/6}
- Location: 1:36704
+ Location: 1:40848
Links: 1
Chunks: {2} 8 bytes
Storage: <details removed for portability>
Filter-0: deflate-1 OPT {1}
Type: 32-bit little-endian integer
/grp_dsets/named_vl Dataset {2/2}
- Location: 1:36920
+ Location: 1:45160
Links: 1
Storage: <details removed for portability>
- Type: shared-1:36872 variable length of
+ Type: shared-1:41016 variable length of
32-bit little-endian integer
/grp_dsets/nested_vl Dataset {2/2}
- Location: 1:45392
+ Location: 1:45288
Links: 1
Storage: <details removed for portability>
Type: variable length of
variable length of
32-bit little-endian integer
/grp_dsets/simple Dataset {6/6}
- Location: 1:45536
+ Location: 1:45432
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/grp_dsets/simple_group Dataset {6/6}
- Location: 1:61744
+ Location: 1:61544
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/grp_dsets/vl Type
- Location: 1:36872
+ Location: 1:41016
Links: 2
- Type: shared-1:36872 variable length of
+ Type: shared-1:41016 variable length of
32-bit little-endian integer
/grp_empty Group
Location: 1:32968
Links: 1
/grp_nested Group
- Location: 1:46328
+ Location: 1:46224
Links: 1
/grp_nested/grp_dsets Group
- Location: 1:47120
+ Location: 1:47016
Links: 1
/grp_nested/grp_dsets/chunk Dataset {6/6}
- Location: 1:49256
+ Location: 1:51200
Links: 1
Chunks: {2} 8 bytes
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/grp_nested/grp_dsets/compact Dataset {6/6}
- Location: 1:51856
+ Location: 1:51656
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/grp_nested/grp_dsets/compound Dataset {2/2}
- Location: 1:51992
+ Location: 1:51792
Links: 1
Storage: <details removed for portability>
Type: struct {
@@ -263,51 +266,51 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver.
"str2" +20 20-byte null-terminated ASCII string
} 40 bytes
/grp_nested/grp_dsets/compressed Dataset {6/6}
- Location: 1:54304
+ Location: 1:54104
Links: 1
Chunks: {2} 8 bytes
Storage: <details removed for portability>
Filter-0: deflate-1 OPT {1}
Type: 32-bit little-endian integer
/grp_nested/grp_dsets/named_vl Dataset {2/2}
- Location: 1:58616
+ Location: 1:58416
Links: 1
Storage: <details removed for portability>
- Type: shared-1:54472 variable length of
+ Type: shared-1:54272 variable length of
32-bit little-endian integer
/grp_nested/grp_dsets/nested_vl Dataset {2/2}
- Location: 1:58744
+ Location: 1:58544
Links: 1
Storage: <details removed for portability>
Type: variable length of
variable length of
32-bit little-endian integer
/grp_nested/grp_dsets/simple Dataset {6/6}
- Location: 1:58888
+ Location: 1:58688
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/grp_nested/grp_dsets/vl Type
- Location: 1:54472
+ Location: 1:54272
Links: 2
- Type: shared-1:54472 variable length of
+ Type: shared-1:54272 variable length of
32-bit little-endian integer
/grp_rename Group
- Location: 1:62952
+ Location: 1:62752
Links: 1
/grp_rename/chunk Dataset {6/6}
- Location: 1:65088
+ Location: 1:66936
Links: 1
Chunks: {2} 8 bytes
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/grp_rename/compact Dataset {6/6}
- Location: 1:65544
+ Location: 1:67392
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/grp_rename/compound Dataset {2/2}
- Location: 1:65680
+ Location: 1:67528
Links: 1
Storage: <details removed for portability>
Type: struct {
@@ -315,28 +318,28 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver.
"str2" +20 20-byte null-terminated ASCII string
} 40 bytes
/grp_rename/compressed Dataset {6/6}
- Location: 1:65896
+ Location: 1:69840
Links: 1
Chunks: {2} 8 bytes
Storage: <details removed for portability>
Filter-0: deflate-1 OPT {1}
Type: 32-bit little-endian integer
/grp_rename/grp_dsets Group
- Location: 1:75936
+ Location: 1:75632
Links: 1
/grp_rename/grp_dsets/chunk Dataset {6/6}
- Location: 1:78072
+ Location: 1:79816
Links: 1
Chunks: {2} 8 bytes
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/grp_rename/grp_dsets/compact Dataset {6/6}
- Location: 1:78528
+ Location: 1:80272
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/grp_rename/grp_dsets/compound Dataset {2/2}
- Location: 1:78664
+ Location: 1:80408
Links: 1
Storage: <details removed for portability>
Type: struct {
@@ -344,57 +347,57 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver.
"str2" +20 20-byte null-terminated ASCII string
} 40 bytes
/grp_rename/grp_dsets/compressed Dataset {6/6}
- Location: 1:78880
+ Location: 1:82720
Links: 1
Chunks: {2} 8 bytes
Storage: <details removed for portability>
Filter-0: deflate-1 OPT {1}
Type: 32-bit little-endian integer
/grp_rename/grp_dsets/named_vl Dataset {2/2}
- Location: 1:79096
+ Location: 1:87032
Links: 1
Storage: <details removed for portability>
- Type: shared-1:79048 variable length of
+ Type: shared-1:82888 variable length of
32-bit little-endian integer
/grp_rename/grp_dsets/nested_vl Dataset {2/2}
- Location: 1:87568
+ Location: 1:87160
Links: 1
Storage: <details removed for portability>
Type: variable length of
variable length of
32-bit little-endian integer
/grp_rename/grp_dsets/simple Dataset {6/6}
- Location: 1:87712
+ Location: 1:87304
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/grp_rename/grp_dsets/vl Type
- Location: 1:79048
+ Location: 1:82888
Links: 2
- Type: shared-1:79048 variable length of
+ Type: shared-1:82888 variable length of
32-bit little-endian integer
/grp_rename/named_vl Dataset {2/2}
- Location: 1:66112
+ Location: 1:74152
Links: 1
Storage: <details removed for portability>
- Type: shared-1:66064 variable length of
+ Type: shared-1:70008 variable length of
32-bit little-endian integer
/grp_rename/nested_vl Dataset {2/2}
- Location: 1:74584
+ Location: 1:74280
Links: 1
Storage: <details removed for portability>
Type: variable length of
variable length of
32-bit little-endian integer
/grp_rename/simple Dataset {6/6}
- Location: 1:74728
+ Location: 1:74424
Links: 1
Storage: <details removed for portability>
Type: 32-bit little-endian integer
/grp_rename/vl Type
- Location: 1:66064
+ Location: 1:70008
Links: 2
- Type: shared-1:66064 variable length of
+ Type: shared-1:70008 variable length of
32-bit little-endian integer
/named_vl Dataset {2/2}
Location: 1:13104
diff --git a/tools/testfiles/h5diff_17.txt b/tools/testfiles/h5diff_17.txt
index 0f17c6d..1d93779 100644
--- a/tools/testfiles/h5diff_17.txt
+++ b/tools/testfiles/h5diff_17.txt
@@ -21,6 +21,8 @@ file1 file2
x /g1/fp1
x /g1/fp15
x /g1/fp16
+ x /g1/fp17
+ x /g1/fp18
x /g1/fp2
x /g2
diff --git a/tools/testfiles/h5diff_basic1.h5 b/tools/testfiles/h5diff_basic1.h5
index e672d65..389e2b3 100644
--- a/tools/testfiles/h5diff_basic1.h5
+++ b/tools/testfiles/h5diff_basic1.h5
Binary files differ
diff --git a/tools/testfiles/h5mkgrp_nested.ls b/tools/testfiles/h5mkgrp_nested.ls
index 2b9fb25..472656d 100644
--- a/tools/testfiles/h5mkgrp_nested.ls
+++ b/tools/testfiles/h5mkgrp_nested.ls
@@ -2,6 +2,9 @@
Expected output for 'h5ls ../testfiles/h5mkgrp_nested.h5'
#############################
Opened "../testfiles/h5mkgrp_nested.h5" with sec2 driver.
+/ Group
+ Location: 1:96
+ Links: 1
/one Group
Location: 1:800
Links: 1
diff --git a/tools/testfiles/h5mkgrp_nested_latest.ls b/tools/testfiles/h5mkgrp_nested_latest.ls
index f0bab6f..c00292d 100644
--- a/tools/testfiles/h5mkgrp_nested_latest.ls
+++ b/tools/testfiles/h5mkgrp_nested_latest.ls
@@ -2,6 +2,10 @@
Expected output for 'h5ls ../testfiles/h5mkgrp_nested_latest.h5'
#############################
Opened "../testfiles/h5mkgrp_nested_latest.h5" with sec2 driver.
+/ Group
+ Location: 1:48
+ Links: 1
+ Modified: XXXX-XX-XX XX:XX:XX XXX
/one Group
Location: 1:195
Links: 1
diff --git a/tools/testfiles/h5mkgrp_nested_mult.ls b/tools/testfiles/h5mkgrp_nested_mult.ls
index 4fccd83..6a22ffd 100644
--- a/tools/testfiles/h5mkgrp_nested_mult.ls
+++ b/tools/testfiles/h5mkgrp_nested_mult.ls
@@ -2,6 +2,9 @@
Expected output for 'h5ls ../testfiles/h5mkgrp_nested_mult.h5'
#############################
Opened "../testfiles/h5mkgrp_nested_mult.h5" with sec2 driver.
+/ Group
+ Location: 1:96
+ Links: 1
/one Group
Location: 1:800
Links: 1
diff --git a/tools/testfiles/h5mkgrp_nested_mult_latest.ls b/tools/testfiles/h5mkgrp_nested_mult_latest.ls
index 7835050..0b19ff9 100644
--- a/tools/testfiles/h5mkgrp_nested_mult_latest.ls
+++ b/tools/testfiles/h5mkgrp_nested_mult_latest.ls
@@ -2,6 +2,10 @@
Expected output for 'h5ls ../testfiles/h5mkgrp_nested_mult_latest.h5'
#############################
Opened "../testfiles/h5mkgrp_nested_mult_latest.h5" with sec2 driver.
+/ Group
+ Location: 1:48
+ Links: 1
+ Modified: XXXX-XX-XX XX:XX:XX XXX
/one Group
Location: 1:195
Links: 1
diff --git a/tools/testfiles/h5mkgrp_several.ls b/tools/testfiles/h5mkgrp_several.ls
index dcbe3eb..bbf5c92 100644
--- a/tools/testfiles/h5mkgrp_several.ls
+++ b/tools/testfiles/h5mkgrp_several.ls
@@ -2,6 +2,9 @@
Expected output for 'h5ls ../testfiles/h5mkgrp_several.h5'
#############################
Opened "../testfiles/h5mkgrp_several.h5" with sec2 driver.
+/ Group
+ Location: 1:96
+ Links: 1
/one Group
Location: 1:800
Links: 1
diff --git a/tools/testfiles/h5mkgrp_several_latest.ls b/tools/testfiles/h5mkgrp_several_latest.ls
index c59107e..a3b5224 100644
--- a/tools/testfiles/h5mkgrp_several_latest.ls
+++ b/tools/testfiles/h5mkgrp_several_latest.ls
@@ -2,6 +2,10 @@
Expected output for 'h5ls ../testfiles/h5mkgrp_several_latest.h5'
#############################
Opened "../testfiles/h5mkgrp_several_latest.h5" with sec2 driver.
+/ Group
+ Location: 1:48
+ Links: 1
+ Modified: XXXX-XX-XX XX:XX:XX XXX
/one Group
Location: 1:195
Links: 1
diff --git a/tools/testfiles/h5mkgrp_single.ls b/tools/testfiles/h5mkgrp_single.ls
index 1f7e828..e9932f7 100644
--- a/tools/testfiles/h5mkgrp_single.ls
+++ b/tools/testfiles/h5mkgrp_single.ls
@@ -2,6 +2,9 @@
Expected output for 'h5ls ../testfiles/h5mkgrp_single.h5'
#############################
Opened "../testfiles/h5mkgrp_single.h5" with sec2 driver.
+/ Group
+ Location: 1:96
+ Links: 1
/single Group
Location: 1:800
Links: 1
diff --git a/tools/testfiles/h5mkgrp_single_latest.ls b/tools/testfiles/h5mkgrp_single_latest.ls
index 7f5ee72..b6e6ea4 100644
--- a/tools/testfiles/h5mkgrp_single_latest.ls
+++ b/tools/testfiles/h5mkgrp_single_latest.ls
@@ -2,6 +2,10 @@
Expected output for 'h5ls ../testfiles/h5mkgrp_single_latest.h5'
#############################
Opened "../testfiles/h5mkgrp_single_latest.h5" with sec2 driver.
+/ Group
+ Location: 1:48
+ Links: 1
+ Modified: XXXX-XX-XX XX:XX:XX XXX
/latest Group
Location: 1:195
Links: 1
diff --git a/tools/testfiles/tall-2.ls b/tools/testfiles/tall-2.ls
index 5513214..2e4cd37 100644
--- a/tools/testfiles/tall-2.ls
+++ b/tools/testfiles/tall-2.ls
@@ -1,6 +1,7 @@
#############################
output for 'h5ls -w80 -r -d tall.h5'
#############################
+/ Group
/g1 Group
/g1/g1.1 Group
/g1/g1.1/dset1.1.1 Dataset {10, 10}
diff --git a/tools/testfiles/tarray1.ls b/tools/testfiles/tarray1.ls
index 83a51a8..60c002d 100644
--- a/tools/testfiles/tarray1.ls
+++ b/tools/testfiles/tarray1.ls
@@ -1,6 +1,7 @@
#############################
output for 'h5ls -w80 -r -d tarray1.h5'
#############################
+/ Group
/Dataset1 Dataset {4}
Data:
(0) [0,1,2,3], [10,11,12,13], [20,21,22,23], [30,31,32,33]
diff --git a/tools/testfiles/tattr2.ls b/tools/testfiles/tattr2.ls
index 88b24cd..0448868 100644
--- a/tools/testfiles/tattr2.ls
+++ b/tools/testfiles/tattr2.ls
@@ -2,149 +2,6 @@
output for 'h5ls -w80 -v -S tattr2.h5'
#############################
Opened "tattr2.h5" with sec2 driver.
- Attribute: array {2}
- Type: [3] 32-bit little-endian integer
- Data: [1,2,3], [4,5,6]
- Attribute: array2D {3, 2}
- Type: [3] 32-bit little-endian integer
- Data:
- (0,0) [1,2,3], [4,5,6], [7,8,9], [10,11,12], [13,14,15], [16,17,18]
- Attribute: array3D {4, 3, 2}
- Type: [3] 32-bit little-endian integer
- Data:
- (0,0,0) [1,2,3], [4,5,6], [7,8,9], [10,11,12], [13,14,15],
- (0,2,1) [16,17,18], [19,20,21], [22,23,24], [25,26,27], [28,29,30],
- (1,2,0) [31,32,33], [34,35,36], [37,38,39], [40,41,42], [43,44,45],
- (2,1,1) [46,47,48], [49,50,51], [52,53,54], [55,56,57], [58,59,60],
- (3,1,0) [61,62,63], [64,65,66], [67,68,69], [70,71,72]
- Attribute: bitfield {2}
- Type: 8-bit bitfield
- Data: 0x01, 0x02
- Attribute: bitfield2D {3, 2}
- Type: 8-bit bitfield
- Data:
- (0,0) 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
- Attribute: bitfield3D {4, 3, 2}
- Type: 8-bit bitfield
- Data:
- (0,0,0) 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
- (1,2,0) 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14,
- (3,1,0) 0x15, 0x16, 0x17, 0x18
- Attribute: compound {2}
- Type: struct {
- "a" +0 8-bit integer
- "b" +4 IEEE 64-bit little-endian float
- } 12 bytes
- Data: {1, 2}, {3, 4}
- Attribute: compound2D {3, 2}
- Type: struct {
- "a" +0 8-bit integer
- "b" +4 IEEE 64-bit little-endian float
- } 12 bytes
- Data:
- (0,0) {1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}
- Attribute: compound3D {4, 3, 2}
- Type: struct {
- "a" +0 8-bit integer
- "b" +4 IEEE 64-bit little-endian float
- } 12 bytes
- Data:
- (0,0,0) {1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}, {13,
- (1,0,0) 14}, {15, 16}, {17, 18}, {19, 20}, {21, 22}, {23, 24},
- (2,0,0) {25, 26}, {27, 28}, {29, 30}, {31, 32}, {33, 34}, {35, 36},
- (3,0,0) {37, 38}, {39, 40}, {41, 42}, {43, 44}, {45, 46}, {47, 48}
- Attribute: enum {2}
- Type: enum 32-bit little-endian integer {
- RED = 0
- GREEN = 1
- }
- Data: RED, RED
- Attribute: enum2D {3, 2}
- Type: enum 32-bit little-endian integer {
- RED = 0
- GREEN = 1
- }
- Data:
- (0,0) RED, RED, RED, RED, RED, RED
- Attribute: enum3D {4, 3, 2}
- Type: enum 32-bit little-endian integer {
- RED = 0
- GREEN = 1
- }
- Data:
- (0,0,0) RED, RED, RED, RED, RED, RED, RED, RED, RED, RED, RED, RED,
- (2,0,0) RED, RED, RED, RED, RED, RED, RED, RED, RED, RED, RED, RED
- Attribute: float {2}
- Type: IEEE 32-bit little-endian float
- Data: 1, 2
- Attribute: float2D {3, 2}
- Type: IEEE 32-bit little-endian float
- Data:
- (0,0) 1, 2, 3, 4, 5, 6
- Attribute: float3D {4, 3, 2}
- Type: IEEE 32-bit little-endian float
- Data:
- (0,0,0) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- (2,2,1) 18, 19, 20, 21, 22, 23, 24
- Attribute: integer {2}
- Type: 32-bit little-endian integer
- Data: 1, 2
- Attribute: integer2D {3, 2}
- Type: 32-bit little-endian integer
- Data:
- (0,0) 1, 2, 3, 4, 5, 6
- Attribute: integer3D {4, 3, 2}
- Type: 32-bit little-endian integer
- Data:
- (0,0,0) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- (2,2,1) 18, 19, 20, 21, 22, 23, 24
- Attribute: opaque {2}
- Type: 1-byte opaque type
- (tag = "1-byte opaque type")
- Data: 0x01, 0x02
- Attribute: opaque2D {3, 2}
- Type: 1-byte opaque type
- (tag = "1-byte opaque type")
- Data:
- (0,0) 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
- Attribute: opaque3D {4, 3, 2}
- Type: 1-byte opaque type
- (tag = "1-byte opaque type")
- Data:
- (0,0,0) 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
- (1,2,0) 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14,
- (3,1,0) 0x15, 0x16, 0x17, 0x18
- Attribute: string {2}
- Type: 2-byte null-terminated ASCII string
- Data: "ab", "de"
- Attribute: string2D {3, 2}
- Type: 2-byte null-terminated ASCII string
- Data:
- (0,0) "ab", "cd", "ef", "gh", "ij", "kl"
- Attribute: string3D {4, 3, 2}
- Type: 2-byte null-terminated ASCII string
- Data:
- (0,0,0) "ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu",
- (1,2,0) "vw", "xz", "AB", "CD", "EF", "GH", "IJ", "KL", "MN", "PQ",
- (3,1,0) "RS", "TU", "VW", "XZ"
- Attribute: vlen {2}
- Type: variable length of
- 32-bit little-endian integer
- Data: (1), (2,3)
- Attribute: vlen2D {3, 2}
- Type: variable length of
- 32-bit little-endian integer
- Data:
- (0,0) (0), (1), (2,3), (4,5), (6,7,8), (9,10,11)
- Attribute: vlen3D {4, 3, 2}
- Type: variable length of
- 32-bit little-endian integer
- Data:
- (0,0,0) (0), (1), (2), (3), (4), (5), (6,7), (8,9), (10,11),
- (1,1,1) (12,13), (14,15), (16,17), (18,19,20), (21,22,23),
- (2,1,0) (24,25,26), (27,28,29), (30,31,32), (33,34,35),
- (3,0,0) (36,37,38,39), (40,41,42,43), (44,45,46,47), (48,49,50,51),
- (3,2,0) (52,53,54,55), (56,57,58,59)
dset Dataset {2/2}
Attribute: array {2}
Type: [3] 32-bit little-endian integer
diff --git a/tools/testfiles/tcomp-1.ls b/tools/testfiles/tcomp-1.ls
index 599fe68..9cfb47d 100644
--- a/tools/testfiles/tcomp-1.ls
+++ b/tools/testfiles/tcomp-1.ls
@@ -1,6 +1,7 @@
#############################
output for 'h5ls -w80 -r -d tcompound.h5'
#############################
+/ Group
/dset1 Dataset {5}
Data:
(0) {0, 0, 1}, {1, 1, 0.5}, {2, 4, 0.333333333333333}, {3, 9, 0.25},
diff --git a/tools/testfiles/tdset-1.ls b/tools/testfiles/tdset-1.ls
index 6853429..b6e4671 100644
--- a/tools/testfiles/tdset-1.ls
+++ b/tools/testfiles/tdset-1.ls
@@ -1,6 +1,7 @@
#############################
output for 'h5ls -w80 -r -d tdset.h5'
#############################
+/ Group
/dset1 Dataset {10, 20}
Data:
(0,0) 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
diff --git a/tools/testfiles/textlink-1.ls b/tools/testfiles/textlink-1.ls
index f92786b..87be5a7 100644
--- a/tools/testfiles/textlink-1.ls
+++ b/tools/testfiles/textlink-1.ls
@@ -1,5 +1,6 @@
#############################
output for 'h5ls -w80 -r textlink.h5'
#############################
+/ Group
/extlink1 -> file: filename path: objname
/extlink2 -> file: anotherfile path: anotherobj
diff --git a/tools/testfiles/tgroup-1.ls b/tools/testfiles/tgroup-1.ls
index 62ebe70..0ca929d 100644
--- a/tools/testfiles/tgroup-1.ls
+++ b/tools/testfiles/tgroup-1.ls
@@ -1,17 +1,29 @@
#############################
output for 'h5ls -w80 -r -g tgroup.h5'
#############################
-/ Group
-/g1 Group
-/g1/g1.1 Group
-/g1/g1.2 Group
-/g2 Group
-/g2/g2.1 Group
-/g2/g2.1/g2.1.1 Group
-/g2/g2.1/g2.1.2 Group
-/g2/g2.1/g2.1.3 Group
-/g3 Group
-/g3/g3.1 Group
-/g3/g3.2 Group
-/g3/g3.3 Group
-/g3/g3.4 Group
+Error: 'recursive' option not compatible with 'group info' option!
+
+usage: h5ls [OPTIONS] [OBJECTS...]
+ OPTIONS
+ -h, -?, --help Print a usage message and exit
+ -a, --address Print addresses for raw data
+ -d, --data Print the values of datasets
+ -e, --errors Show all HDF5 error reporting
+ -f, --full Print full path names instead of base names
+ -g, --group Show information about a group, not its contents
+ -l, --label Label members of compound datasets
+ -r, --recursive List all groups recursively, avoiding cycles
+ -s, --string Print 1-byte integer datasets as ASCII
+ -S, --simple Use a machine-readable output format
+ -wN, --width=N Set the number of columns of output
+ -v, --verbose Generate more verbose output
+ -V, --version Print version number and exit
+ --vfd=DRIVER Use the specified virtual file driver
+ -x, --hexdump Show raw data in hexadecimal format
+
+ OBJECTS
+ Each object consists of an HDF5 file name optionally followed by a
+ slash and an object name within the file (if no object is specified
+ within the file then the contents of the root group are displayed).
+ The file name may include a printf(3C) integer format such as
+ "%05d" to open a file family.
diff --git a/tools/testfiles/tgroup-2.ls b/tools/testfiles/tgroup-2.ls
new file mode 100644
index 0000000..0817d93
--- /dev/null
+++ b/tools/testfiles/tgroup-2.ls
@@ -0,0 +1,4 @@
+#############################
+ output for 'h5ls -w80 -g tgroup.h5/g1'
+#############################
+g1 Group
diff --git a/tools/testfiles/tindicessub1.ddl b/tools/testfiles/tindicessub1.ddl
index 6195a78..0173fb5 100644
--- a/tools/testfiles/tindicessub1.ddl
+++ b/tools/testfiles/tindicessub1.ddl
@@ -1,19 +1,17 @@
#############################
-Expected output for 'h5dump -d 1d -s 3 -c 40 taindices.h5'
+Expected output for 'h5dump -d 1d -s 1 -S 10 -c 2 -k 3 taindices.h5'
#############################
HDF5 "taindices.h5" {
DATASET "1d" {
DATATYPE H5T_STD_I32LE
DATASPACE SIMPLE { ( 100 ) / ( 100 ) }
SUBSET {
- START ( 3 );
- STRIDE ( 1 );
- COUNT ( 40 );
- BLOCK ( 1 );
+ START ( 1 );
+ STRIDE ( 10 );
+ COUNT ( 2 );
+ BLOCK ( 3 );
DATA {
- (3): 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
- (21): 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
- (37): 37, 38, 39, 40, 41, 42
+ (1): 1, 2, 3, 11, 12, 13
}
}
}
diff --git a/tools/testfiles/tindicessub2.ddl b/tools/testfiles/tindicessub2.ddl
index 9fc987c..7b70d12 100644
--- a/tools/testfiles/tindicessub2.ddl
+++ b/tools/testfiles/tindicessub2.ddl
@@ -1,22 +1,22 @@
#############################
-Expected output for 'h5dump -d 2d -s 1,3 -c 6,4 taindices.h5'
+Expected output for 'h5dump -d 2d -s 1,2 -S 3,3 -c 3,2 -k 2,2 taindices.h5'
#############################
HDF5 "taindices.h5" {
DATASET "2d" {
DATATYPE H5T_STD_I32LE
DATASPACE SIMPLE { ( 10, 10 ) / ( 10, 10 ) }
SUBSET {
- START ( 1, 3 );
- STRIDE ( 1, 1 );
- COUNT ( 6, 4 );
- BLOCK ( 1, 1 );
+ START ( 1, 2 );
+ STRIDE ( 3, 3 );
+ COUNT ( 3, 2 );
+ BLOCK ( 2, 2 );
DATA {
- (1,3): 13, 14, 15, 16,
- (2,3): 23, 24, 25, 26,
- (3,3): 33, 34, 35, 36,
- (4,3): 43, 44, 45, 46,
- (5,3): 53, 54, 55, 56,
- (6,3): 63, 64, 65, 66
+ (1,2): 12, 13, 15, 16,
+ (2,2): 22, 23, 25, 26,
+ (4,2): 42, 43, 45, 46,
+ (5,2): 52, 53, 55, 56,
+ (7,2): 72, 73, 75, 76,
+ (8,2): 82, 83, 85, 86
}
}
}
diff --git a/tools/testfiles/tindicessub3.ddl b/tools/testfiles/tindicessub3.ddl
index ba86242..fde8e82 100644
--- a/tools/testfiles/tindicessub3.ddl
+++ b/tools/testfiles/tindicessub3.ddl
@@ -1,28 +1,24 @@
#############################
-Expected output for 'h5dump -d 3d -s 0,1,3 -c 2,6,4 taindices.h5'
+Expected output for 'h5dump -d 3d -s 0,1,2 -S 1,3,3 -c 2,2,2 -k 1,2,2 taindices.h5'
#############################
HDF5 "taindices.h5" {
DATASET "3d" {
DATATYPE H5T_STD_I32LE
DATASPACE SIMPLE { ( 2, 10, 10 ) / ( 2, 10, 10 ) }
SUBSET {
- START ( 0, 1, 3 );
- STRIDE ( 1, 1, 1 );
- COUNT ( 2, 6, 4 );
- BLOCK ( 1, 1, 1 );
+ START ( 0, 1, 2 );
+ STRIDE ( 1, 3, 3 );
+ COUNT ( 2, 2, 2 );
+ BLOCK ( 1, 2, 2 );
DATA {
- (0,1,3): 13, 14, 15, 16,
- (0,2,3): 23, 24, 25, 26,
- (0,3,3): 33, 34, 35, 36,
- (0,4,3): 43, 44, 45, 46,
- (0,5,3): 53, 54, 55, 56,
- (0,6,3): 63, 64, 65, 66
- (1,1,3): 113, 114, 115, 116,
- (1,2,3): 123, 124, 125, 126,
- (1,3,3): 133, 134, 135, 136,
- (1,4,3): 143, 144, 145, 146,
- (1,5,3): 153, 154, 155, 156,
- (1,6,3): 163, 164, 165, 166
+ (0,1,2): 12, 13, 15, 16,
+ (0,2,2): 22, 23, 25, 26,
+ (0,4,2): 42, 43, 45, 46,
+ (0,5,2): 52, 53, 55, 56
+ (1,1,2): 112, 113, 115, 116,
+ (1,2,2): 122, 123, 125, 126,
+ (1,4,2): 142, 143, 145, 146,
+ (1,5,2): 152, 153, 155, 156
}
}
}
diff --git a/tools/testfiles/tindicessub4.ddl b/tools/testfiles/tindicessub4.ddl
index 99fca01..a57bee6 100644
--- a/tools/testfiles/tindicessub4.ddl
+++ b/tools/testfiles/tindicessub4.ddl
@@ -1,40 +1,40 @@
#############################
-Expected output for 'h5dump -d 4d -s 0,0,1,3 -c 2,2,6,4 taindices.h5'
+Expected output for 'h5dump -d 4d -s 0,0,1,2 -c 2,2,3,2 -S 1,1,3,3 -k 1,1,2,2 taindices.h5'
#############################
HDF5 "taindices.h5" {
DATASET "4d" {
DATATYPE H5T_STD_I32LE
DATASPACE SIMPLE { ( 2, 2, 10, 10 ) / ( 2, 2, 10, 10 ) }
SUBSET {
- START ( 0, 0, 1, 3 );
- STRIDE ( 1, 1, 1, 1 );
- COUNT ( 2, 2, 6, 4 );
- BLOCK ( 1, 1, 1, 1 );
+ START ( 0, 0, 1, 2 );
+ STRIDE ( 1, 1, 3, 3 );
+ COUNT ( 2, 2, 3, 2 );
+ BLOCK ( 1, 1, 2, 2 );
DATA {
- (0,0,1,3): 13, 14, 15, 16,
- (0,0,2,3): 23, 24, 25, 26,
- (0,0,3,3): 33, 34, 35, 36,
- (0,0,4,3): 43, 44, 45, 46,
- (0,0,5,3): 53, 54, 55, 56,
- (0,0,6,3): 63, 64, 65, 66
- (0,1,1,3): 113, 114, 115, 116,
- (0,1,2,3): 123, 124, 125, 126,
- (0,1,3,3): 133, 134, 135, 136,
- (0,1,4,3): 143, 144, 145, 146,
- (0,1,5,3): 153, 154, 155, 156,
- (0,1,6,3): 163, 164, 165, 166
- (1,0,1,3): 213, 214, 215, 216,
- (1,0,2,3): 223, 224, 225, 226,
- (1,0,3,3): 233, 234, 235, 236,
- (1,0,4,3): 243, 244, 245, 246,
- (1,0,5,3): 253, 254, 255, 256,
- (1,0,6,3): 263, 264, 265, 266
- (1,1,1,3): 313, 314, 315, 316,
- (1,1,2,3): 323, 324, 325, 326,
- (1,1,3,3): 333, 334, 335, 336,
- (1,1,4,3): 343, 344, 345, 346,
- (1,1,5,3): 353, 354, 355, 356,
- (1,1,6,3): 363, 364, 365, 366
+ (0,0,1,2): 12, 13, 15, 16,
+ (0,0,2,2): 22, 23, 25, 26,
+ (0,0,4,2): 42, 43, 45, 46,
+ (0,0,5,2): 52, 53, 55, 56,
+ (0,0,7,2): 72, 73, 75, 76,
+ (0,0,8,2): 82, 83, 85, 86
+ (0,1,1,2): 112, 113, 115, 116,
+ (0,1,2,2): 122, 123, 125, 126,
+ (0,1,4,2): 142, 143, 145, 146,
+ (0,1,5,2): 152, 153, 155, 156,
+ (0,1,7,2): 172, 173, 175, 176,
+ (0,1,8,2): 182, 183, 185, 186
+ (1,0,1,2): 212, 213, 215, 216,
+ (1,0,2,2): 222, 223, 225, 226,
+ (1,0,4,2): 242, 243, 245, 246,
+ (1,0,5,2): 252, 253, 255, 256,
+ (1,0,7,2): 272, 273, 275, 276,
+ (1,0,8,2): 282, 283, 285, 286
+ (1,1,1,2): 312, 313, 315, 316,
+ (1,1,2,2): 322, 323, 325, 326,
+ (1,1,4,2): 342, 343, 345, 346,
+ (1,1,5,2): 352, 353, 355, 356,
+ (1,1,7,2): 372, 373, 375, 376,
+ (1,1,8,2): 382, 383, 385, 386
}
}
}
diff --git a/tools/testfiles/tloop-1.ls b/tools/testfiles/tloop-1.ls
index b9631b7..22cb6c7 100644
--- a/tools/testfiles/tloop-1.ls
+++ b/tools/testfiles/tloop-1.ls
@@ -1,6 +1,7 @@
#############################
output for 'h5ls -w80 -r -d tloop.h5'
#############################
+/ Group
/g1 Group
/g1/g1.1 Group
/g1/g1.1/g2.1 Group, same as /g1
diff --git a/tools/testfiles/tnestcomp-1.ls b/tools/testfiles/tnestcomp-1.ls
index eef41ef..9dc193d 100644
--- a/tools/testfiles/tnestcomp-1.ls
+++ b/tools/testfiles/tnestcomp-1.ls
@@ -1,6 +1,7 @@
#############################
output for 'h5ls -w80 -r -d tnestedcomp.h5'
#############################
+/ Group
/ArrayOfStructures Dataset {10}
Data:
(0) {0, 0, 1, {"A", [-100,100]}}, {1, 1, 0.5, {"B", [-100,100]}},
diff --git a/tools/testfiles/tnofilename.ddl b/tools/testfiles/tnofilename.ddl
index bae9f79..b7b802b 100644
--- a/tools/testfiles/tnofilename.ddl
+++ b/tools/testfiles/tnofilename.ddl
@@ -5,7 +5,7 @@ usage: h5dump [OPTIONS] file
OPTIONS
-h, --help Print a usage message and exit
-n, --contents Print a list of the file contents and exit
- -B, --bootblock Print the content of the boot block
+ -B, --superblock Print the content of the super block
-H, --header Print the header only; no data is displayed
-A, --onlyattr Print the header and value of attributes
-i, --object-ids Print the object ids
@@ -15,7 +15,7 @@ usage: h5dump [OPTIONS] file
-a P, --attribute=P Print the specified attribute
-d P, --dataset=P Print the specified dataset
-y, --noindex Do not print array indices with the data
- -p, --properties Print dataset filters, storage layout and fill value
+ -p, --properties Print dataset filters, storage layout and fill value
-f D, --filedriver=D Specify which driver to open the file with
-g P, --group=P Print the specified group and all members
-l P, --soft-link=P Print the value(s) of the specified soft link
diff --git a/tools/testfiles/tsaf.ls b/tools/testfiles/tsaf.ls
index 8efc0f2..96d4811 100644
--- a/tools/testfiles/tsaf.ls
+++ b/tools/testfiles/tsaf.ls
@@ -1,6 +1,7 @@
#############################
output for 'h5ls -w80 -r -d tsaf.h5'
#############################
+/ Group
/.DSL_METADATA Dataset {5919/Inf}
Data:
(0) 47, 32, 67, 79, 78, 84, 65, 73, 78, 69, 82, 10, 47, 46, 97, 116,
diff --git a/tools/testfiles/tslink-1.ls b/tools/testfiles/tslink-1.ls
index 05b9bca..4c16958 100644
--- a/tools/testfiles/tslink-1.ls
+++ b/tools/testfiles/tslink-1.ls
@@ -1,5 +1,6 @@
#############################
output for 'h5ls -w80 -r tslink.h5'
#############################
+/ Group
/slink1 -> somevalue
/slink2 -> linkvalue
diff --git a/tools/testfiles/tstr-1.ls b/tools/testfiles/tstr-1.ls
index 1961fd4..8a223cc 100644
--- a/tools/testfiles/tstr-1.ls
+++ b/tools/testfiles/tstr-1.ls
@@ -1,6 +1,7 @@
#############################
output for 'h5ls -w80 -r -d tstr.h5'
#############################
+/ Group
/comp1 Dataset {3, 6}
Data:
(0,0) {[0,1,4,9,16,25,36,49,64,81,1,4,9,16,25,36,49,64,81,100,4,9,16,
diff --git a/tools/testfiles/tudlink-1.ls b/tools/testfiles/tudlink-1.ls
index e83fce7..b8578ce 100644
--- a/tools/testfiles/tudlink-1.ls
+++ b/tools/testfiles/tudlink-1.ls
@@ -1,5 +1,6 @@
#############################
output for 'h5ls -w80 -r tudlink.h5'
#############################
+/ Group
/udlink1 -> cannot follow UD links
/udlink2 -> cannot follow UD links
diff --git a/tools/testfiles/tvldtypes1.ls b/tools/testfiles/tvldtypes1.ls
index cf1688e..4c4c162 100644
--- a/tools/testfiles/tvldtypes1.ls
+++ b/tools/testfiles/tvldtypes1.ls
@@ -1,6 +1,7 @@
#############################
output for 'h5ls -w80 -r -d tvldtypes1.h5'
#############################
+/ Group
/Dataset1.0 Dataset {4}
Data:
(0) (0), (10,11), (20,21,22), (30,31,32,33)