diff options
-rw-r--r-- | tools/h5repack/h5repack.c | 27 | ||||
-rw-r--r-- | tools/h5repack/h5repack.h | 3 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 73 | ||||
-rw-r--r-- | tools/h5repack/h5repack_filters.c | 9 | ||||
-rw-r--r-- | tools/h5repack/h5repack_list.c | 5 | ||||
-rw-r--r-- | tools/h5repack/h5repack_main.c | 6 | ||||
-rw-r--r-- | tools/h5repack/h5repack_opttable.c | 72 | ||||
-rw-r--r-- | tools/h5repack/h5repack_parse.c | 1 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_main.c | 4 |
9 files changed, 147 insertions, 53 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index 56a046f..7ba5a6c 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -243,7 +243,6 @@ static int check_options(pack_opt_t *options) */ if (options->verbose) { - printf("\n"); printf("Objects to modify layout are...\n"); if (options->all_layout==1) { printf(" Apply layout to all\n "); @@ -291,20 +290,22 @@ static int check_options(pack_opt_t *options) if (options->verbose) { - printf("Objects to filter are...\n"); + 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 %s\n",get_sfilter(filtn)); + printf(" Uncompress all\n"); break; - case H5Z_FILTER_SZIP: - printf(" Compress all with %s compression\n",get_sfilter(filtn)); + 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("\tCompress all with %s compression, parameter %d\n", + printf(" All with %s, parameter %d\n", get_sfilter(filtn), options->filter_g.cd_values[0]); break; @@ -321,21 +322,22 @@ static int check_options(pack_opt_t *options) { if (options->verbose) { - printf(" <%s> with %s filter%s", + printf(" <%s> with %s filter\n", name, - get_sfilter(pack.filter[j].filtn), - (i==options->op_tbl->nelems-1)? "" : "\n"); + get_sfilter(pack.filter[j].filtn)); } has_cp=1; - + +#if defined (CHECK_SZIP) + /*check for invalid combination of options */ switch (pack.filter[j].filtn) { default: break; case H5Z_FILTER_SZIP: - + szip_pixels_per_block=pack.filter[j].cd_values[0]; /* check szip parameters */ @@ -364,6 +366,9 @@ static int check_options(pack_opt_t *options) break; } /* switch */ + +#endif + } /* j */ } /* i */ diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index fd7e03d..db89534 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -21,6 +21,9 @@ #include "h5diff.h" #include "h5tools.h" +#define CHECK_SZIP + + #define H5FOPENERROR "unable to open file" #define PFORMAT "%-7s %-7s %-7s\n" /*chunk info, compression info, name*/ diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index e3f89a3..870f3c7 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -45,27 +45,18 @@ int copy_objects(const char* fnamein, * open the files *------------------------------------------------------------------------- */ - - /* disable error reporting */ - H5E_BEGIN_TRY { - - /* Open the files */ if ((fidin=H5Fopen(fnamein,H5F_ACC_RDONLY,H5P_DEFAULT))<0 ){ printf("h5repack: <%s>: %s\n", fnamein, H5FOPENERROR ); - exit(1); + goto out; } if ((fidout=H5Fcreate(fnameout,H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0 ){ printf("h5repack: <%s>: Could not create file\n", fnameout ); - exit(1); + goto out; } - /* enable error reporting */ - } H5E_END_TRY; - if (options->verbose) printf("Making file <%s>...\n",fnameout); - /* init table */ trav_table_init(&travt); @@ -111,15 +102,56 @@ int copy_objects(const char* fnamein, out: H5E_BEGIN_TRY { - H5Fclose(fidin); - H5Fclose(fidout); - trav_table_free(travt); + H5Fclose(fidin); + H5Fclose(fidout); } H5E_END_TRY; + if (travt) + trav_table_free(travt); return -1; } +/*------------------------------------------------------------------------- + * Function: print_obj + * + * Purpose: print name and filters of an object + * + *------------------------------------------------------------------------- + */ + + +void print_obj(pack_info_t *obj, char *name) +{ + char str[26]; /*5x5+1*/ + int i; + + strcpy(str,"\0"); + + for ( i=0; i<obj->nfilters; i++) + { + switch (obj->filter[i].filtn) + { + default: + break; + case H5Z_FILTER_DEFLATE: + strcat(str,"GZIP "); + break; + case H5Z_FILTER_SZIP: + strcat(str,"SZIP "); + break; + case H5Z_FILTER_SHUFFLE: + strcat(str,"SHUF "); + break; + case H5Z_FILTER_FLETCHER32: + strcat(str,"FLET "); + break; + } /* switch */ + }/*i*/ + + printf(" %-10s %s %s\n", "dataset",str,name ); + +} /*------------------------------------------------------------------------- @@ -162,6 +194,7 @@ int do_copy_objects(hid_t fidin, hsize_t dsize_out; /* output dataset size after filter */ #endif /* LATER */ int i, j; + int wrote=0; /*------------------------------------------------------------------------- * copy the suppplied object list @@ -208,9 +241,6 @@ int do_copy_objects(hid_t fidin, *------------------------------------------------------------------------- */ case H5G_DATASET: - if (options->verbose) - printf(" %-10s %s\n", "dataset",travt->objs[i].name ); - if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0) goto error; if ((space_id=H5Dget_space(dset_in))<0) @@ -314,6 +344,7 @@ int do_copy_objects(hid_t fidin, if (dsize_in && nelmts) { if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) goto error; + wrote=1; } /*------------------------------------------------------------------------- * copy attrs @@ -337,6 +368,11 @@ int do_copy_objects(hid_t fidin, if (buf) free(buf); + + if (options->verbose && wrote) + print_obj(&obj,travt->objs[i].name ); + + }/*H5T_STD_REF_OBJ*/ }/*can_read*/ @@ -630,3 +666,6 @@ error: return -1; } + + + diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index c8b9b5d..96390cf 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -206,6 +206,8 @@ int apply_filters(const char* name, /* object name from traverse list */ */ case H5Z_FILTER_SZIP: szip_pixels_per_block=obj->filter[i].cd_values[0]; + +#if defined (CHECK_SZIP) /* check szip parameters */ if (check_szip(type_id, obj->chunk.rank, @@ -214,17 +216,24 @@ int apply_filters(const char* name, /* object name from traverse list */ &szip_pixels_per_block, options)==1) { +#endif + /* set up for szip data */ if(H5Pset_chunk(dcpl_id,obj->chunk.rank,obj->chunk.chunk_lengths)<0) return -1; if (H5Pset_szip(dcpl_id, szip_options_mask, szip_pixels_per_block)<0) return -1; + +#if defined (CHECK_SZIP) } else { if (options->verbose) printf("Warning: SZIP filter cannot be applied to <%s>\n",name); } +#endif + + break; /*------------------------------------------------------------------------- diff --git a/tools/h5repack/h5repack_list.c b/tools/h5repack/h5repack_list.c index 18e844e..d3a84e1 100644 --- a/tools/h5repack/h5repack_list.c +++ b/tools/h5repack/h5repack_list.c @@ -77,7 +77,6 @@ int check_objects(const char* fname, if (options->verbose) { - printf("\n"); printf("Opening file <%s>. Searching for objects to modify...\n",fname); } @@ -90,8 +89,8 @@ int check_objects(const char* fname, /* the input object names are present in the file and are valid */ if (h5trav_getindext(name,travt)<0) { - printf("\nError: Could not find <%s> in file <%s>. Exiting...\n", - name,fname); + printf("%sError: Could not find <%s> in file <%s>. Exiting...\n", + (options->verbose?"\n":""),name,fname); goto out; } if (options->verbose) diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index cc3f6ea..810d30f 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_main.c @@ -45,7 +45,8 @@ int main(int argc, char **argv) else if (strcmp(argv[i], "-f") == 0) { /* add the -f filter option */ - h5repack_addfilter(argv[i+1],&options); + if (h5repack_addfilter(argv[i+1],&options)<0) + exit(1); /* jump to next */ ++i; @@ -53,7 +54,8 @@ int main(int argc, char **argv) else if (strcmp(argv[i], "-l") == 0) { /* parse the -l layout option */ - h5repack_addlayout(argv[i+1],&options); + if (h5repack_addlayout(argv[i+1],&options)<0) + exit(1); /* jump to next */ ++i; diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c index 45dfac5..71cf1a8 100644 --- a/tools/h5repack/h5repack_opttable.c +++ b/tools/h5repack/h5repack_opttable.c @@ -72,6 +72,30 @@ static void aux_tblinsert_filter(pack_opttbl_t *table, } } +/*------------------------------------------------------------------------- + * Function: aux_tblinsert_layout + * + * Purpose: auxiliary function, inserts the layout in object OBJS[ I ] + * + * Return: void + * + *------------------------------------------------------------------------- + */ + +static void aux_tblinsert_layout(pack_opttbl_t *table, + int I, + pack_info_t *pack) +{ + int k; + + table->objs[I].layout = pack->layout; + if (H5D_CHUNKED==pack->layout) { + 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]; + } +} + /*------------------------------------------------------------------------- * Function: aux_inctable @@ -189,7 +213,7 @@ int options_add_layout( obj_list_t *obj_list, pack_info_t *pack, pack_opttbl_t *table ) { - int i, j, k, I, added=0, found=0; + int i, j, I, added=0, found=0; /* increase the size of the collection by N_OBJS if necessary */ if (table->nelems+n_objs >= table->size) @@ -219,12 +243,7 @@ int options_add_layout( obj_list_t *obj_list, /* insert the layout info */ else { - table->objs[i].layout = pack->layout; - if (H5D_CHUNKED==pack->layout) { - 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]; - } + aux_tblinsert_layout(table,i,pack); found=1; break; } @@ -237,12 +256,20 @@ int options_add_layout( obj_list_t *obj_list, I = table->nelems + added; added++; strcpy(table->objs[I].path,obj_list[j].obj); - table->objs[I].layout = pack->layout; - if (H5D_CHUNKED==pack->layout) { - 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]; + 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 */ } @@ -256,12 +283,8 @@ int options_add_layout( obj_list_t *obj_list, I = table->nelems + added; added++; strcpy(table->objs[I].path,obj_list[j].obj); - table->objs[I].layout = pack->layout; - if (H5D_CHUNKED==pack->layout) { - 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]; - } + aux_tblinsert_layout(table,I,pack); + } } @@ -324,6 +347,19 @@ int options_add_filter(obj_list_t *obj_list, 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 */ } diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c index 9efeeb3..96f7bce 100644 --- a/tools/h5repack/h5repack_parse.c +++ b/tools/h5repack/h5repack_parse.c @@ -385,6 +385,7 @@ obj_list_t* parse_layout(const char *str, pack->layout=H5D_CHUNKED; else { printf("Parse layout error: Not a valid layout in <%s>\n",str); + exit(1); } } else diff --git a/tools/h5repack/testh5repack_main.c b/tools/h5repack/testh5repack_main.c index ec29557..1a85bc5 100644 --- a/tools/h5repack/testh5repack_main.c +++ b/tools/h5repack/testh5repack_main.c @@ -29,7 +29,7 @@ * Return: Success: zero * Failure: non-zero * - * Programmer: <pvn@ncsa.uiuc.edu> + * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> * January, 6, 2004 * *------------------------------------------------------------------------- @@ -178,7 +178,7 @@ int main (void) if (h5repack_init (&pack_options, 0)<0) TEST_ERROR; - if (h5repack_addfilter("GZIP=9",&pack_options)<0) + if (h5repack_addfilter("GZIP=1",&pack_options)<0) TEST_ERROR; if (h5repack_addlayout("CHUNK=20x10",&pack_options)<0) TEST_ERROR; |