summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2004-01-08 15:53:32 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2004-01-08 15:53:32 (GMT)
commitbe7ebb248fbe7d887b44b4aecbfe80f2517d53b1 (patch)
treedf693260fe94f6a8d47968d4cbac66a9476ba841 /tools
parentfeaa5bb9d54017961e325f4bc2c366fc023c2443 (diff)
downloadhdf5-be7ebb248fbe7d887b44b4aecbfe80f2517d53b1.zip
hdf5-be7ebb248fbe7d887b44b4aecbfe80f2517d53b1.tar.gz
hdf5-be7ebb248fbe7d887b44b4aecbfe80f2517d53b1.tar.bz2
[svn-r8040] Purpose:
bug fix, code improvment Description: fixed a bug in the parse of chunking function added some auxiliary functions to avoid repeated parts of the code in several places Solution: Platforms tested: linux solaris AIX Misc. update:
Diffstat (limited to 'tools')
-rw-r--r--tools/h5repack/h5repack.c4
-rw-r--r--tools/h5repack/h5repack.h4
-rw-r--r--tools/h5repack/h5repack_copy.c11
-rw-r--r--tools/h5repack/h5repack_filters.c80
-rw-r--r--tools/h5repack/h5repack_main.c8
-rw-r--r--tools/h5repack/h5repack_opttable.c34
-rw-r--r--tools/h5repack/h5repack_parse.c8
-rw-r--r--tools/h5repack/h5repack_verify.c1
8 files changed, 119 insertions, 31 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c
index 147b6db..a6a6989 100644
--- a/tools/h5repack/h5repack.c
+++ b/tools/h5repack/h5repack.c
@@ -178,8 +178,10 @@ int h5repack_addlayout(const char* str,
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 */
- int j;
pack_info_t pack; /*info about layout to extract from parse */
+ int j;
+
+ init_packobject(&pack);
if (options->all_layout==1){
printf("Error: Invalid layout input: all option \
diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h
index 965219e..0b82aea 100644
--- a/tools/h5repack/h5repack.h
+++ b/tools/h5repack/h5repack.h
@@ -175,6 +175,10 @@ int do_copy_refobjs_inattr(hid_t loc_in,
void read_info(const char *filename,pack_opt_t *options);
void close_obj(H5G_obj_t obj_type, hid_t obj_id);
+void init_packobject(pack_info_t *obj);
+int print_filters(hid_t dcpl_id);
+
+
/*-------------------------------------------------------------------------
* filters
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 2d6752b..3ca7c11 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -231,6 +231,9 @@ int do_copy_file(hid_t fidin,
if ((msize=H5Tget_size(mtype_id))==0)
goto error;
+ if (options->verbose)
+ print_filters(dcpl_id);
+
/*-------------------------------------------------------------------------
* object references are a special case
@@ -243,6 +246,7 @@ int do_copy_file(hid_t fidin,
/* the information about the object to be filtered/"layouted" */
pack_info_t obj;
+ init_packobject(&obj);
/* get the storage size of the input dataset */
dsize_in=H5Dget_storage_size(dset_in);
@@ -278,6 +282,13 @@ int do_copy_file(hid_t fidin,
*/
if (filter_this(travt->objs[i].name,options,&obj))
{
+ /* filters require CHUNK layout; if we do not have one define a default */
+ if (obj.chunk.rank==0)
+ {
+ obj.chunk.rank=rank;
+ for (j=0; j<rank; j++)
+ obj.chunk.chunk_lengths[j] = dims[j] / 2;
+ }
if (apply_filters(dcpl_id,H5Tget_size(mtype_id),options,&obj)<0)
continue;
}
diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c
index e245c35..ebb65e1 100644
--- a/tools/h5repack/h5repack_filters.c
+++ b/tools/h5repack/h5repack_filters.c
@@ -29,13 +29,6 @@
static void aux_objinsert_filter(pack_info_t *obj,
filter_info_t filt)
{
- int j;
-
- for ( j=0; j<H5_REPACK_MAX_NFILTERS; j++)
- {
- obj->filter[j].filtn = -1;
- }
-
obj->nfilters=1;
obj->filter[0]=filt;
@@ -101,6 +94,62 @@ int filter_this(const char* name, /* object name from traverse list */
}
+/*-------------------------------------------------------------------------
+ * Function: print_filters
+ *
+ * Purpose: print the filters in DCPL
+ *
+ * Return: 0, ok, -1 no
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: December 19, 2003
+ *
+ *-------------------------------------------------------------------------
+ */
+
+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/file 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_filter(dcpl_id,
+ i,
+ &filt_flags,
+ &cd_nelmts,
+ cd_values,
+ sizeof(f_name),
+ f_name);
+
+ 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;
+}
+
/*-------------------------------------------------------------------------
* Function: apply_filters
@@ -127,9 +176,7 @@ int apply_filters(hid_t dcpl_id,
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/file name */
- char s[64]; /* temporary string buffer */
int i, j;
unsigned aggression; /* the deflate level */
unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK;
@@ -149,23 +196,8 @@ int apply_filters(hid_t dcpl_id,
cd_values,
sizeof(f_name),
f_name);
-
- if (options->verbose)
- {
- 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");
- }
}
-
/*
the type of filter and additional parameter
type can be one of the filters
diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c
index bfa8366..0c02894 100644
--- a/tools/h5repack/h5repack_main.c
+++ b/tools/h5repack/h5repack_main.c
@@ -22,8 +22,8 @@ static void usage(void);
/*
Examples of use:
--v -i file1.h5 -o file2.h5 -t "dataset:GZIP 6" -c "dataset:2x2"
--v -i file1.h5 -o file2.h5 -t "GZIP 6"
+-v -i file1.h5 -o file2.h5 -f "dataset:GZIP 6" -l "dataset:2x2"
+-v -i file1.h5 -o file2.h5 -f "GZIP 6"
*/
@@ -48,7 +48,7 @@ int main(int argc, char **argv)
else if (strcmp(argv[i], "-v") == 0) {
options.verbose = 1;
}
- else if (strcmp(argv[i], "-t") == 0) {
+ else if (strcmp(argv[i], "-f") == 0) {
/* add the -t option */
h5repack_addfilter(argv[i+1],&options);
@@ -56,7 +56,7 @@ int main(int argc, char **argv)
/* jump to next */
++i;
}
- else if (strcmp(argv[i], "-c") == 0) {
+ else if (strcmp(argv[i], "-l") == 0) {
/* parse the -c option */
h5repack_addlayout(argv[i+1],&options);
diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c
index 9449556..fa7fd11 100644
--- a/tools/h5repack/h5repack_opttable.c
+++ b/tools/h5repack/h5repack_opttable.c
@@ -17,6 +17,36 @@
#include "h5repack.h"
+
+/*-------------------------------------------------------------------------
+ * Function: init_packobject
+ *
+ * Purpose: initialize a pack_info_t structure
+ *
+ * Return: void
+ *
+ *-------------------------------------------------------------------------
+ */
+
+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 = -1;
+ obj->nfilters = 0;
+
+
+}
+
/*-------------------------------------------------------------------------
* Function: aux_tblinsert_filter
*
@@ -28,8 +58,8 @@
*/
static void aux_tblinsert_filter(pack_opttbl_t *table,
- int I,
- filter_info_t filt)
+ int I,
+ filter_info_t filt)
{
if (table->objs[ I ].nfilters<H5_REPACK_MAX_NFILTERS)
{
diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c
index 0364206..0f1e0d2 100644
--- a/tools/h5repack/h5repack_parse.c
+++ b/tools/h5repack/h5repack_parse.c
@@ -399,6 +399,14 @@ obj_list_t* parse_layout(const char *str,
*-------------------------------------------------------------------------
*/
k=0;
+
+ if (j>(int)len)
+ {
+ if (obj_list) free(obj_list);
+ printf("Parse layout error: <%s> Chunk dimensions missing\n",str);
+ exit(1);
+ }
+
for ( i=j, c_index=0; i<len; i++)
{
c = str[i];
diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c
index dc33206..1cdca59 100644
--- a/tools/h5repack/h5repack_verify.c
+++ b/tools/h5repack/h5repack_verify.c
@@ -259,6 +259,7 @@ int h5repack_verify(const char *fname,
*/
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)