diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2008-09-16 15:52:51 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2008-09-16 15:52:51 (GMT) |
commit | bdd7d59902483885dd8b883f3b2393e77383e5e8 (patch) | |
tree | aaf20ab132d057b95b3c016d50fc22b77719084b /tools/h5repack | |
parent | 8bc0d5ed9019a681e1ea20c24264415d01c1cf2a (diff) | |
download | hdf5-bdd7d59902483885dd8b883f3b2393e77383e5e8.zip hdf5-bdd7d59902483885dd8b883f3b2393e77383e5e8.tar.gz hdf5-bdd7d59902483885dd8b883f3b2393e77383e5e8.tar.bz2 |
[svn-r15628] Description:
Remove trailing whitespace from C/C++ source files, with the following
script:
foreach f (*.[ch] *.cpp)
sed 's/[[:blank:]]*$//' $f > sed.out && mv sed.out $f
end
Tested on:
Mac OS X/32 10.5.5 (amazon)
No need for h5committest, just whitespace changes...
Diffstat (limited to 'tools/h5repack')
-rw-r--r-- | tools/h5repack/h5repack.c | 102 | ||||
-rw-r--r-- | tools/h5repack/h5repack.h | 6 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 300 | ||||
-rw-r--r-- | tools/h5repack/h5repack_filters.c | 94 | ||||
-rw-r--r-- | tools/h5repack/h5repack_main.c | 204 | ||||
-rw-r--r-- | tools/h5repack/h5repack_opttable.c | 44 | ||||
-rw-r--r-- | tools/h5repack/h5repack_parse.c | 122 | ||||
-rw-r--r-- | tools/h5repack/h5repack_refs.c | 4 | ||||
-rw-r--r-- | tools/h5repack/h5repack_verify.c | 206 | ||||
-rw-r--r-- | tools/h5repack/h5repacktst.c | 66 |
10 files changed, 574 insertions, 574 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index 91ade4f..eabdb6c 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -65,16 +65,16 @@ int h5repack(const char* infile, /* 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; } @@ -97,7 +97,7 @@ int h5repack_init (pack_opt_t *options, memset(options,0,sizeof(pack_opt_t)); options->min_comp = 1024; options->verbose = verbose; - + for ( n = 0; n < H5_REPACK_MAX_NFILTERS; n++) { options->filter_g[n].filtn = -1; @@ -105,7 +105,7 @@ int h5repack_init (pack_opt_t *options, for ( k = 0; k < CD_VALUES; k++) options->filter_g[n].cd_values[k] = -1; } - + return (options_table_init(&(options->op_tbl))); } @@ -141,36 +141,36 @@ int h5repack_addfilter(const char* str, 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; } @@ -190,25 +190,25 @@ 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 ) { @@ -230,13 +230,13 @@ int h5repack_addlayout(const char* str, } } } - + if (options->all_layout==0) options_add_layout(obj_list, n_objs, &pack, options->op_tbl); - + free(obj_list); return 0; } @@ -252,7 +252,7 @@ int h5repack_addlayout(const char* str, * Programmer: pvn@ncsa.uiuc.edu * * Date: September, 22, 2003 - * + * * Modification: * Peter Cao, July 9, 2007 * Add "-L, --latest" and other options to pack a file with the latest file format @@ -264,7 +264,7 @@ 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 *------------------------------------------------------------------------- @@ -297,11 +297,11 @@ static int check_options(pack_opt_t *options) } } }/* 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){ @@ -319,24 +319,24 @@ static int check_options(pack_opt_t *options) 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; @@ -359,12 +359,12 @@ static int check_options(pack_opt_t *options) }; } } /* 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) @@ -373,12 +373,12 @@ static int check_options(pack_opt_t *options) 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"); @@ -420,7 +420,7 @@ static int check_options(pack_opt_t *options) options->ublock_filename); return -1; } - + if ( options->ublock_filename == NULL && options->ublock_size != 0 ) { error_msg(progname, "file name missing for user block\n", @@ -433,13 +433,13 @@ static int check_options(pack_opt_t *options) * verify alignment options; threshold is zero default but alignment not *--------------------------------------------------------------------------------- */ - + if ( options->alignment == 0 && options->threshold != 0 ) { error_msg(progname, "alignment for H5Pset_alignment missing\n"); return -1; } - + return 0; } @@ -464,11 +464,11 @@ static int check_objects(const char* fname, 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 *------------------------------------------------------------------------- @@ -477,32 +477,32 @@ static int check_objects(const char* fname, 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", @@ -524,7 +524,7 @@ static int check_objects(const char* fname, 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++) @@ -547,7 +547,7 @@ static int check_objects(const char* fname, if(H5Dclose(did) < 0) goto out; } - + if (csize < ppb ) { printf(" <warning: SZIP settins, chunk size is smaller than pixels per block>\n"); goto out; @@ -556,7 +556,7 @@ static int check_objects(const char* fname, break; } } /* i */ - + /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- @@ -564,7 +564,7 @@ static int check_objects(const char* fname, H5Fclose(fid); trav_table_free(travt); return 0; - + out: H5Fclose(fid); trav_table_free(travt); diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index a7b3fd9..a77a670 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -102,11 +102,11 @@ typedef struct { H5D_layout_t layout_g; /*global layout information for the ALL case */ int verbose; /*verbose mode */ hsize_t min_comp; /*minimum size to compress, in bytes */ - int use_native; /*use a native type in write */ + int use_native; /*use a native type in write */ int latest; /*pack file with the latest file format */ int grp_compact; /* Set the maximum number of links to store as header messages in the group */ int grp_indexed; /* Set the minimum number of links to store in the indexed format */ - int msg_size[8]; /* Minimum size of shared messages: dataspace, + int msg_size[8]; /* Minimum size of shared messages: dataspace, datatype, fill value, filter pipleline, attribute */ const char *ublock_filename; /* user block file name */ int ublock_size; /* user block size */ @@ -159,7 +159,7 @@ int copy_objects (const char* fnamein, int do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, - pack_opt_t *options); + pack_opt_t *options); /*------------------------------------------------------------------------- * filters and verify module diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 7f43ad0..b0d475f 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -187,11 +187,11 @@ int copy_objects(const char* fnamein, } /* end if */ } /* end if */ } /* end if */ - - -#if defined (H5REPACK_DEBUG) + + +#if defined (H5REPACK_DEBUG) print_user_block(fnamein,fidin); #endif @@ -207,35 +207,35 @@ int copy_objects(const char* fnamein, if(fcpl != H5P_DEFAULT) { /* set user block size */ - if(H5Pset_userblock(fcpl, options->ublock_size) < 0) + if(H5Pset_userblock(fcpl, options->ublock_size) < 0) { error_msg(progname, "failed to set userblock size\n"); goto out; - } - + } + } - + else { - + /* create a file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { error_msg(progname, "fail to create a file creation property list\n"); goto out; - } - + } + /* set user block size */ - if(H5Pset_userblock(fcpl, options->ublock_size) < 0) + if(H5Pset_userblock(fcpl, options->ublock_size) < 0) { error_msg(progname, "failed to set userblock size\n"); goto out; - } - + } + } - - - + + + } @@ -244,39 +244,39 @@ int copy_objects(const char* fnamein, *------------------------------------------------------------------------- */ - + if ( options->alignment > 0 ) { /* either use the FCPL already created or create a new one */ if (fapl != H5P_DEFAULT) { - + if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) { error_msg(progname, "failed to set alignment\n"); goto out; } - + } - + else { - + /* create a file access property list */ - if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { error_msg(progname, "Could not create file access property list\n"); goto out; - } - + } + if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) { error_msg(progname, "failed to set alignment\n"); goto out; } - - } - + + } + } @@ -285,28 +285,28 @@ int copy_objects(const char* fnamein, *------------------------------------------------------------------------- */ - + if(options->verbose) printf("Making file <%s>...\n",fnameout); - - - if((fidout = H5Fcreate(fnameout,H5F_ACC_TRUNC, fcpl, fapl)) < 0) + + + if((fidout = H5Fcreate(fnameout,H5F_ACC_TRUNC, fcpl, fapl)) < 0) { error_msg(progname, "<%s>: Could not create file\n", fnameout ); goto out; } /* end if */ - + /*------------------------------------------------------------------------- * write a new user block if requested *------------------------------------------------------------------------- */ if ( options->ublock_size > 0 ) - { + { copy_user_block( options->ublock_filename, fnameout, options->ublock_size); } - + /* init table */ trav_table_init(&travt); @@ -387,7 +387,7 @@ out: * * Date: October, 23, 2003 * - * Modifications: + * Modifications: * * July 2004: Introduced the extra EC or NN option for SZIP * @@ -399,47 +399,47 @@ out: * October 2006: Read by hyperslabs for big datasets. * * A threshold of H5TOOLS_MALLOCSIZE (128 MB) is the limit upon which I/O hyperslab is done - * i.e., if the memory needed to read a dataset is greater than this limit, - * then hyperslab I/O is done instead of one operation I/O + * i.e., if the memory needed to read a dataset is greater than this limit, + * then hyperslab I/O is done instead of one operation I/O * For each dataset, the memory needed is calculated according to * * memory needed = number of elements * size of each element * - * if the memory needed is lower than H5TOOLS_MALLOCSIZE, then the following operations + * if the memory needed is lower than H5TOOLS_MALLOCSIZE, then the following operations * are done * * H5Dread( input_dataset1 ) * H5Dread( input_dataset2 ) * - * with all elements in the datasets selected. If the memory needed is greater than + * with all elements in the datasets selected. If the memory needed is greater than * H5TOOLS_MALLOCSIZE, then the following operations are done instead: * - * a strip mine is defined for each dimension k (a strip mine is defined as a + * a strip mine is defined for each dimension k (a strip mine is defined as a * hyperslab whose size is memory manageable) according to the formula * * (1) strip_mine_size[k ] = MIN(dimension[k ], H5TOOLS_BUFSIZE / size of memory type) * - * where H5TOOLS_BUFSIZE is a constant currently defined as 1MB. This formula assures - * that for small datasets (small relative to the H5TOOLS_BUFSIZE constant), the strip - * mine size k is simply defined as its dimension k, but for larger datasets the + * where H5TOOLS_BUFSIZE is a constant currently defined as 1MB. This formula assures + * that for small datasets (small relative to the H5TOOLS_BUFSIZE constant), the strip + * mine size k is simply defined as its dimension k, but for larger datasets the * hyperslab size is still memory manageable. - * a cycle is done until the number of elements in the dataset is reached. In each - * iteration, two parameters are defined for the function H5Sselect_hyperslab, + * a cycle is done until the number of elements in the dataset is reached. In each + * iteration, two parameters are defined for the function H5Sselect_hyperslab, * the start and size of each hyperslab, according to * * (2) hyperslab_size [k] = MIN(dimension[k] - hyperslab_offset[k], strip_mine_size [k]) * - * where hyperslab_offset [k] is initially set to zero, and later incremented in - * hyperslab_size[k] offsets. The reason for the operation + * where hyperslab_offset [k] is initially set to zero, and later incremented in + * hyperslab_size[k] offsets. The reason for the operation * * dimension[k] - hyperslab_offset[k] * - * in (2) is that, when using the strip mine size, it assures that the "remaining" part + * in (2) is that, when using the strip mine size, it assures that the "remaining" part * of the dataset that does not fill an entire strip mine is processed. * - * November 2006: Use H5Ocopy in the copy of objects. The logic for using - * H5Ocopy or not is if a change of filters or layout is requested by the user - * then use read/write else use H5Ocopy. + * November 2006: Use H5Ocopy in the copy of objects. The logic for using + * H5Ocopy or not is if a change of filters or layout is requested by the user + * then use read/write else use H5Ocopy. * * May, 1, 2008: Add a printing of the compression ratio of old size / new size * @@ -518,7 +518,7 @@ int do_copy_objects(hid_t fidin, goto error; if((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) - goto error; + goto error; } else { if((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -565,7 +565,7 @@ int do_copy_objects(hid_t fidin, goto error; if(H5Dclose(dset_in) < 0) goto error; - + /*------------------------------------------------------------------------- * check if we should use H5Ocopy or not @@ -599,11 +599,11 @@ int do_copy_objects(hid_t fidin, if(options->use_native == 1) wtype_id = h5tools_get_native_type(ftype_id); else - wtype_id = H5Tcopy(ftype_id); + wtype_id = H5Tcopy(ftype_id); if((msize = H5Tget_size(wtype_id)) == 0) goto error; - + /*------------------------------------------------------------------------- * check if the dataset creation property list has filters that * are not registered in the current configuration @@ -647,7 +647,7 @@ int do_copy_objects(hid_t fidin, 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", @@ -674,7 +674,7 @@ int do_copy_objects(hid_t fidin, goto error; if (H5Dwrite(dset_out,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0) goto error; - } + } else /* possibly not enough memory, read/write by hyperslabs */ { @@ -695,7 +695,7 @@ int do_copy_objects(hid_t fidin, hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */ hsize_t hs_nelmts; /*elements in request */ hsize_t zero[8]; /*vector of zeros */ - int k; + int k; /* check if we have VL data in the dataset's datatype */ if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE) @@ -721,12 +721,12 @@ int do_copy_objects(hid_t fidin, memset(hs_offset, 0, sizeof hs_offset); memset(zero, 0, sizeof zero); - for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) + for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) { /* calculate the hyperslab size */ - if (rank > 0) + if (rank > 0) { - for (k = 0, hs_nelmts = 1; k < rank; k++) + for (k = 0, hs_nelmts = 1; k < rank; k++) { hs_size[k] = MIN(dims[k] - hs_offset[k], sm_size[k]); hs_nelmts *= hs_size[k]; @@ -736,8 +736,8 @@ int do_copy_objects(hid_t fidin, goto error; if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0) goto error; - } - else + } + else { H5Sselect_all(f_space_id); H5Sselect_all(sm_space); @@ -745,9 +745,9 @@ int do_copy_objects(hid_t fidin, } /* rank */ /* read/write */ - if (H5Dread(dset_in, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0) + if (H5Dread(dset_in, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0) goto error; - if (H5Dwrite(dset_out, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0) + if (H5Dwrite(dset_out, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0) goto error; /* reclaim any VL memory, if necessary */ @@ -755,7 +755,7 @@ int do_copy_objects(hid_t fidin, H5Dvlen_reclaim(wtype_id, sm_space, H5P_DEFAULT, sm_buf); /* calculate the next hyperslab offset */ - for (k = rank, carry = 1; k > 0 && carry; --k) + for (k = rank, carry = 1; k > 0 && carry; --k) { hs_offset[k - 1] += hs_size[k - 1]; if (hs_offset[k - 1] == dims[k - 1]) @@ -779,7 +779,7 @@ int do_copy_objects(hid_t fidin, * amount of compression used *------------------------------------------------------------------------- */ - if (options->verbose) + if (options->verbose) { double ratio=0; @@ -796,13 +796,13 @@ int do_copy_objects(hid_t fidin, a = dsize_in; b = dsize_out; if (b!=0) ratio = (double) a / (double) b; - + print_dataset_info(dcpl_out,travt->objs[i].name,ratio,1); } else print_dataset_info(dcpl_id,travt->objs[i].name,ratio,0); - /* print a message that the filter was not applied + /* print a message that the filter was not applied (in case there was a filter) */ if ( has_filter && apply_s == 0 ) @@ -853,16 +853,16 @@ int do_copy_objects(hid_t fidin, * we do not have request for filter/chunking use H5Ocopy instead *------------------------------------------------------------------------- */ - else + else { hid_t pid; /* create property to pass copy options */ - if ( (pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) + if ( (pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) goto error; /* set options for object copy */ - if(H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0) + if(H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0) goto error; /*------------------------------------------------------------------------- @@ -875,7 +875,7 @@ int do_copy_objects(hid_t fidin, fidout, /* Destination file or group identifier */ travt->objs[i].name, /* Name of the destination object */ pid, /* Properties which apply to the copy */ - H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */ + H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */ goto error; /* close property */ @@ -901,7 +901,7 @@ int do_copy_objects(hid_t fidin, if (options->verbose) printf(FORMAT_OBJ,"dset",travt->objs[i].name ); - + } /* end do we have request for filter/chunking */ @@ -938,7 +938,7 @@ int do_copy_objects(hid_t fidin, if(H5Tclose(type_out) < 0) goto error; - + break; @@ -1042,52 +1042,52 @@ int copy_attr(hid_t loc_in, 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); - + 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 @@ -1095,18 +1095,18 @@ int copy_attr(hid_t loc_in, * the referenced objects *------------------------------------------------------------------------- */ - + if (H5T_REFERENCE==H5Tget_class(wtype_id)) { ; } - else + else { /*------------------------------------------------------------------------- * read to memory *------------------------------------------------------------------------- */ - + buf = (void *)HDmalloc((size_t)(nelmts * msize)); if(buf == NULL) { error_msg(progname, "cannot read into memory\n" ); @@ -1114,46 +1114,46 @@ int copy_attr(hid_t loc_in, } 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); @@ -1193,27 +1193,27 @@ static void print_dataset_info(hid_t dcpl_id, 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]; @@ -1222,10 +1222,10 @@ static void print_dataset_info(hid_t dcpl_id, } #endif break; - + case H5Z_FILTER_SZIP: strcat(strfilter,"SZIP "); - + #if defined (PRINT_DEBUG) { unsigned options_mask=cd_values[0]; /* from dcpl, not filt*/ @@ -1238,29 +1238,29 @@ static void print_dataset_info(hid_t dcpl_id, 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(!pr) printf(FORMAT_OBJ,"dset",objname ); else @@ -1275,13 +1275,13 @@ static void print_dataset_info(hid_t dcpl_id, } /*------------------------------------------------------------------------- - * Function: copy_user_block + * Function: copy_user_block * * Purpose: copy user block from one file to another * * Return: 0, ok, -1 no * - * Programmer: Peter Cao + * Programmer: Peter Cao * * Date: October, 25, 2007 * @@ -1355,25 +1355,25 @@ done: if(outfid > 0) HDclose(outfid); - return status; + return status; } /*------------------------------------------------------------------------- - * Function: print_user_block + * Function: print_user_block * * Purpose: print user block * * Return: 0, ok, -1 no * - * Programmer: Pedro Vicente + * Programmer: Pedro Vicente * * Date: August, 20, 2008 * *------------------------------------------------------------------------- */ -static +static void print_user_block(const char *filename, hid_t fid) { int fh; /* file handle */ @@ -1382,35 +1382,35 @@ void print_user_block(const char *filename, hid_t fid) hid_t fcpl; /* file creation property list ID for HDF5 file */ int i; - /* get user block size */ - if(( fcpl = H5Fget_create_plist(fid)) < 0) + /* get user block size */ + if(( fcpl = H5Fget_create_plist(fid)) < 0) { error_msg(progname, "failed to retrieve file creation property list\n"); goto done; - } - - if(H5Pget_userblock(fcpl, &ub_size) < 0) + } + + if(H5Pget_userblock(fcpl, &ub_size) < 0) { error_msg(progname, "failed to retrieve userblock size\n"); goto done; - } - - if(H5Pclose(fcpl) < 0) + } + + if(H5Pclose(fcpl) < 0) { error_msg(progname, "failed to close property list\n"); goto done; - } - + } + /* open file */ - if((fh = HDopen(filename, O_RDONLY, 0)) < 0) + if((fh = HDopen(filename, O_RDONLY, 0)) < 0) { goto done; } - + size = ub_size; /* read file */ - while(size > 0) + while(size > 0) { ssize_t nread; /* # of bytes read */ char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */ @@ -1421,7 +1421,7 @@ void print_user_block(const char *filename, hid_t fid) else nread = HDread(fh, rbuf, (size_t)size); - for(i = 0; i < nread; i++) + for(i = 0; i < nread; i++) { printf("%c ", rbuf[i]); @@ -1429,20 +1429,20 @@ void print_user_block(const char *filename, hid_t fid) } printf("\n"); - if(nread < 0) + if(nread < 0) { goto done; - } + } + - /* update size of userblock left to transfer */ size -= nread; - } + } done: if(fh > 0) HDclose(fh); - - return; + + return; } diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index 98ef07e..cd4693e 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -41,10 +41,10 @@ int aux_find_obj(const char* name, /* object name from traverse list */ *obj = options->op_tbl->objs[i]; return i; } - + pdest = strstr(name,options->op_tbl->objs[i].path); result = (int)(pdest - name); - + /* found at position 1, meaning without '/' */ if( pdest != NULL && result==1 ) { @@ -72,19 +72,19 @@ int aux_assign_obj(const char* name, /* object name from traverse lis pack_opt_t *options, /* repack options */ pack_info_t *obj /*OUT*/) /* info about object to filter */ { - + int idx, i; pack_info_t tmp; - + init_packobject(&tmp); - + idx = aux_find_obj(name,options,&tmp); - + /* name was on input */ if (idx>=0) { - - + + /* applying to all objects */ if (options->all_layout) { @@ -114,9 +114,9 @@ int aux_assign_obj(const char* name, /* object name from traverse lis default: break; }/*switch*/ - + } - + /* applying to all objects */ if (options->all_filter) { @@ -132,16 +132,16 @@ int aux_assign_obj(const char* name, /* object name from traverse lis tmp.filter[i] = options->op_tbl->objs[idx].filter[i]; } } - - + + } /* if idx */ - - + + /* no input name */ - + else { - + if (options->all_filter) { int k; @@ -167,11 +167,11 @@ int aux_assign_obj(const char* name, /* object name from traverse lis }/*switch*/ } } - + *obj = tmp; return 1; - -} + +} /*------------------------------------------------------------------------- @@ -206,40 +206,40 @@ int apply_filters(const char* name, /* object name from traverse list */ pack_info_t obj; *has_filter = 0; - + if (rank==0) /* scalar dataset, do not apply */ return 0; - + /*------------------------------------------------------------------------- * initialize the assigment object *------------------------------------------------------------------------- */ init_packobject(&obj); - + /*------------------------------------------------------------------------- * find options *------------------------------------------------------------------------- */ if (aux_assign_obj(name,options,&obj)==0) return 0; - + /* get information about input filters */ if ((nfilters = H5Pget_nfilters(dcpl_id))<0) return -1; - + /*------------------------------------------------------------------------- * check if we have filters in the pipeline * we want to replace them with the input filters * only remove if we are inserting new ones *------------------------------------------------------------------------- */ - if (nfilters && obj.nfilters ) + if (nfilters && obj.nfilters ) { *has_filter = 1; if (H5Premove_filter(dcpl_id,H5Z_FILTER_ALL)<0) return -1; } - + /*------------------------------------------------------------------------- * check if there is an existent chunk * read it only if there is not a requested layout @@ -249,7 +249,7 @@ int apply_filters(const char* name, /* object name from traverse list */ { if ((layout = H5Pget_layout(dcpl_id))<0) return -1; - + if (layout==H5D_CHUNKED) { if ((rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize/*out*/))<0) @@ -260,7 +260,7 @@ int apply_filters(const char* name, /* object name from traverse list */ obj.chunk.chunk_lengths[i] = chsize[i]; } } - + /*------------------------------------------------------------------------- * the type of filter and additional parameter * type can be one of the filters @@ -273,10 +273,10 @@ int apply_filters(const char* name, /* object name from traverse list */ * H5Z_FILTER_SCALEOFFSET 6 , scaleoffset compression *------------------------------------------------------------------------- */ - + if (obj.nfilters) { - + /*------------------------------------------------------------------------- * filters require CHUNK layout; if we do not have one define a default *------------------------------------------------------------------------- @@ -287,14 +287,14 @@ int apply_filters(const char* name, /* object name from traverse list */ for (i=0; i<rank; i++) obj.chunk.chunk_lengths[i] = dims[i]; } - + for ( i=0; i<obj.nfilters; i++) { switch (obj.filter[i].filtn) { default: break; - + /*------------------------------------------------------------------------- * H5Z_FILTER_DEFLATE 1 , deflation like gzip *------------------------------------------------------------------------- @@ -302,7 +302,7 @@ int apply_filters(const char* name, /* object name from traverse list */ case H5Z_FILTER_DEFLATE: { unsigned aggression; /* the deflate level */ - + aggression = obj.filter[i].cd_values[0]; /* set up for deflated data */ if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0) @@ -311,7 +311,7 @@ int apply_filters(const char* name, /* object name from traverse list */ return -1; } break; - + /*------------------------------------------------------------------------- * H5Z_FILTER_SZIP 4 , szip compression *------------------------------------------------------------------------- @@ -320,19 +320,19 @@ int apply_filters(const char* name, /* object name from traverse list */ { unsigned options_mask; unsigned pixels_per_block; - + options_mask = obj.filter[i].cd_values[0]; pixels_per_block = obj.filter[i].cd_values[1]; - + /* 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,options_mask,pixels_per_block)<0) return -1; - + } break; - + /*------------------------------------------------------------------------- * H5Z_FILTER_SHUFFLE 2 , shuffle the data *------------------------------------------------------------------------- @@ -343,7 +343,7 @@ int apply_filters(const char* name, /* object name from traverse list */ if (H5Pset_shuffle(dcpl_id)<0) return -1; break; - + /*------------------------------------------------------------------------- * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC *------------------------------------------------------------------------- @@ -368,15 +368,15 @@ int apply_filters(const char* name, /* object name from traverse list */ * H5Z_FILTER_SCALEOFFSET , scale+offset compression *------------------------------------------------------------------------- */ - + case H5Z_FILTER_SCALEOFFSET: { H5Z_SO_scale_type_t scale_type; int scale_factor; - + scale_type = obj.filter[i].cd_values[0]; scale_factor = obj.filter[i].cd_values[1]; - + if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0) return -1; if (H5Pset_scaleoffset(dcpl_id,scale_type,scale_factor)<0) @@ -385,21 +385,21 @@ int apply_filters(const char* name, /* object name from traverse list */ break; } /* switch */ }/*i*/ - + } /*obj.nfilters*/ - + /*------------------------------------------------------------------------- * layout *------------------------------------------------------------------------- */ - + if (obj.layout>=0) { /* a layout was defined */ if (H5Pset_layout(dcpl_id, obj.layout)<0) return -1; - + if (H5D_CHUNKED==obj.layout) { /* set up chunk */ if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0) return -1; @@ -408,7 +408,7 @@ int apply_filters(const char* name, /* object name from traverse list */ if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY)<0) return -1; } - + } return 0; diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index f457f23..a2f4b14 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_main.c @@ -74,9 +74,9 @@ static struct long_options l_opts[] = { * * Comments: * - * Modifications: + * 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 + * 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: @@ -87,11 +87,11 @@ static struct long_options l_opts[] = { * PVN, November 28, 2007 * added support for multiple global filters * PVN, May 16, 2008 - * added backward compatibility for -i infile -o outfile + * added backward compatibility for -i infile -o outfile * PVN, August 20, 2008 * add a user block to repacked file (switches -u -b) * PVN, August 28, 2008 - * add options to set alignment (H5Pset_alignment) (switches -t -a) + * add options to set alignment (H5Pset_alignment) (switches -t -a) *------------------------------------------------------------------------- */ int main(int argc, char **argv) @@ -101,15 +101,15 @@ int main(int argc, char **argv) pack_opt_t options; /*the global options */ int ret=-1; int i; - + /* initialize options */ h5repack_init (&options,0); /* detect -i or -o for file names */ for ( i = 1; i < argc; i++) { - - if (strcmp(argv[i], "-i") == 0) + + if (strcmp(argv[i], "-i") == 0) { has_i_o = 1; } @@ -121,104 +121,104 @@ int main(int argc, char **argv) if (has_i_o) { - + for ( i = 1; i < argc; i++) { - if (strcmp(argv[i], "-h") == 0) + if (strcmp(argv[i], "-h") == 0) { usage(progname); exit(0); } - if (strcmp(argv[i], "-i") == 0) + if (strcmp(argv[i], "-i") == 0) { infile = argv[++i]; } - else if (strcmp(argv[i], "-o") == 0) + else if (strcmp(argv[i], "-o") == 0) { outfile = argv[++i]; } - else if (strcmp(argv[i], "-v") == 0) + else if (strcmp(argv[i], "-v") == 0) { options.verbose = 1; } - else if (strcmp(argv[i], "-f") == 0) + 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) + 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) + + else if (strcmp(argv[i], "-m") == 0) { options.min_comp = parse_number(argv[i+1]); - if ((int)options.min_comp<=0) + if ((int)options.min_comp<=0) { error_msg(progname, "invalid minimum compress size <%s>\n",argv[i+1]); exit(1); } ++i; } - - else if (strcmp(argv[i], "-e") == 0) + + else if (strcmp(argv[i], "-e") == 0) { read_info(argv[++i],&options); } - else if (strcmp(argv[i], "-n") == 0) + else if (strcmp(argv[i], "-n") == 0) { options.use_native = 1; } - else if (strcmp(argv[i], "-L") == 0) + else if (strcmp(argv[i], "-L") == 0) { options.latest = 1; } - else if (strcmp(argv[i], "-c") == 0) + else if (strcmp(argv[i], "-c") == 0) { options.grp_compact = atoi( argv[++i] ); if (options.grp_compact>0) - options.latest = 1; /* must use latest format */ + options.latest = 1; /* must use latest format */ } - else if (strcmp(argv[i], "-d") == 0) + else if (strcmp(argv[i], "-d") == 0) { options.grp_indexed = atoi( argv[++i] ); if (options.grp_indexed>0) - options.latest = 1; /* must use latest format */ + options.latest = 1; /* must use latest format */ } - else if (strcmp(argv[i], "-s") == 0) + else if (strcmp(argv[i], "-s") == 0) { - + char *s = argv[++i]; int idx = 0; int ssize = 0; char *msgPtr = strchr( s, ':'); options.latest = 1; /* must use latest format */ - if (msgPtr == NULL) + if (msgPtr == NULL) { ssize = atoi( s ); for (idx=0; idx<5; idx++) - options.msg_size[idx] = ssize; + options.msg_size[idx] = ssize; } - else + else { char msgType[10]; strcpy(msgType, msgPtr+1); @@ -239,66 +239,66 @@ int main(int argc, char **argv) else if (strncmp(msgType, "attr",4) == 0) { options.msg_size[4] = ssize; } - } - + } + } - - + + else if (argv[i][0] == '-') { error_msg(progname, " - is not a valid argument\n"); usage(progname); exit(1); } } - + if (infile == NULL || outfile == NULL) { error_msg(progname, "file names missing\n"); usage(progname); exit(1); } - + } - + else - + { - + parse_command_line(argc, argv, &options); - - - - if ( argv[ opt_ind ] != NULL && argv[ opt_ind + 1 ] != NULL ) + + + + if ( argv[ opt_ind ] != NULL && argv[ opt_ind + 1 ] != NULL ) { 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); - + } } - + else { 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 @@ -338,7 +338,7 @@ static void usage(const char *prog) printf(" -a A, --alignment=A Alignment value for H5Pset_alignment\n"); printf(" -f FILT, --filter=FILT Filter type\n"); printf(" -l LAYT, --layout=LAYT Layout type\n"); - + printf("\n"); printf(" M - is an integer greater than 1, size of dataset in bytes \n"); @@ -432,13 +432,13 @@ static void usage(const char *prog) static void parse_command_line(int argc, const char* argv[], pack_opt_t* options) { - + int opt; - + /* parse command line options */ - while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch ((char)opt) + switch ((char)opt) { case 'h': usage(progname); @@ -450,7 +450,7 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options options->verbose = 1; break; case 'f': - + /* parse the -f filter option */ if (h5repack_addfilter( opt_arg, options)<0) { @@ -459,7 +459,7 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options } break; case 'l': - + /* parse the -l layout option */ if (h5repack_addlayout( opt_arg, options)<0) { @@ -467,18 +467,18 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options exit(EXIT_FAILURE); } break; - + case 'm': options->min_comp = parse_number( opt_arg ); - if ((int)options->min_comp<=0) + if ((int)options->min_comp<=0) { error_msg(progname, "invalid minimum compress size <%s>\n", opt_arg ); exit(EXIT_FAILURE); } break; - + case 'e': read_info( opt_arg, options); break; @@ -486,19 +486,19 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options case 'n': options->use_native = 1; break; - + case 'L': - options->latest = 1; + options->latest = 1; break; - + case 'c': options->grp_compact = atoi( opt_arg ); if (options->grp_compact>0) options->latest = 1; /* must use latest format */ break; - - + + case 'd': options->grp_indexed = atoi( opt_arg ); @@ -509,18 +509,18 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options case 's': { - + int idx = 0; int ssize = 0; char *msgPtr = strchr( opt_arg, ':'); options->latest = 1; /* must use latest format */ - if (msgPtr == NULL) + if (msgPtr == NULL) { ssize = atoi( opt_arg ); for (idx=0; idx<5; idx++) - options->msg_size[idx] = ssize; + options->msg_size[idx] = ssize; } - else + else { char msgType[10]; strcpy(msgType, msgPtr+1); @@ -541,26 +541,26 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options else if (strncmp(msgType, "attr", 4) == 0) { options->msg_size[4] = ssize; } - } + } } - + break; - + case 'u': - + options->ublock_filename = opt_arg; break; - + case 'b': - + options->ublock_size = atoi( opt_arg ); break; case 't': - + options->threshold = atoi( opt_arg ); - if ( options->threshold < 0 ) + if ( options->threshold < 0 ) { error_msg(progname, "invalid threshold size\n", opt_arg ); exit(EXIT_FAILURE); @@ -568,9 +568,9 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options break; case 'a': - + options->alignment = atoi( opt_arg ); - if ( options->alignment < 1 ) + if ( options->alignment < 1 ) { error_msg(progname, "invalid alignment size\n", opt_arg ); exit(EXIT_FAILURE); @@ -578,21 +578,21 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options break; } /* switch */ - - + + } /* while */ - + /* check for file names to be processed */ - if (argc <= opt_ind || argv[ opt_ind + 1 ] == NULL) + if (argc <= opt_ind || argv[ opt_ind + 1 ] == NULL) { error_msg(progname, "missing file names\n"); usage(progname); exit(EXIT_FAILURE); } - - - + + + } /*------------------------------------------------------------------------- @@ -616,7 +616,7 @@ int parse_number(char *str) int n; char c; size_t len=strlen(str); - + for ( i=0; i<len; i++) { c = str[i]; @@ -648,7 +648,7 @@ static void read_info(const char *filename, pack_opt_t *options) { - + char stype[10]; char comp_info[1024]; FILE *fp; @@ -656,33 +656,33 @@ void read_info(const char *filename, 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!=' ' ) @@ -701,7 +701,7 @@ void read_info(const char *filename, 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); @@ -712,7 +712,7 @@ void read_info(const char *filename, *------------------------------------------------------------------------- */ else if (strcmp(stype,"-l") == 0) { - + /* find begining of info */ i=0; c='0'; while( c!=' ' ) @@ -731,7 +731,7 @@ void read_info(const char *filename, 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); @@ -746,7 +746,7 @@ void read_info(const char *filename, exit(1); } } - + fclose(fp); return; } diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c index 4fd450d..bdcae02 100644 --- a/tools/h5repack/h5repack_opttable.c +++ b/tools/h5repack/h5repack_opttable.c @@ -33,7 +33,7 @@ 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++) { @@ -87,7 +87,7 @@ static void aux_tblinsert_layout(pack_opttbl_t *table, pack_info_t *pack) { int k; - + table->objs[I].layout = pack->layout; if (H5D_CHUNKED==pack->layout) { @@ -122,7 +122,7 @@ 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) { @@ -154,7 +154,7 @@ int options_table_init( pack_opttbl_t **tbl ) 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)); @@ -162,12 +162,12 @@ int options_table_init( pack_opttbl_t **tbl ) 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; } @@ -207,14 +207,14 @@ int options_add_layout( obj_list_t *obj_list, { 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) { @@ -242,7 +242,7 @@ int options_add_layout( obj_list_t *obj_list, } } /* if */ } /* i */ - + if (found==0) { /* keep the grow in a temp var */ @@ -266,7 +266,7 @@ int options_add_layout( obj_list_t *obj_list, } } /* j */ } - + /* first time insertion */ else { @@ -277,12 +277,12 @@ int options_add_layout( obj_list_t *obj_list, added++; strcpy(table->objs[I].path,obj_list[j].obj); aux_tblinsert_layout(table,I,pack); - + } } - + table->nelems+= added; - + return 0; } @@ -303,17 +303,17 @@ 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) { @@ -332,7 +332,7 @@ int options_add_filter(obj_list_t *obj_list, break; } /* if */ } /* i */ - + if (found==0) { /* keep the grow in a temp var */ @@ -356,7 +356,7 @@ int options_add_filter(obj_list_t *obj_list, } } /* j */ } - + /* first time insertion */ else { @@ -369,9 +369,9 @@ int options_add_filter(obj_list_t *obj_list, aux_tblinsert_filter(table,I,filt); } } - + table->nelems+= added; - + return 0; } @@ -389,7 +389,7 @@ 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 */ @@ -398,7 +398,7 @@ pack_info_t* options_get_object( const char *path, return (&table->objs[i]); } } - + return NULL; } diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c index 2475068..f7188bf 100644 --- a/tools/h5repack/h5repack_parse.c +++ b/tools/h5repack/h5repack_parse.c @@ -67,12 +67,12 @@ obj_list_t* parse_filter(const char *str, 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++) { @@ -86,14 +86,14 @@ obj_list_t* parse_filter(const char *str, 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) @@ -102,7 +102,7 @@ obj_list_t* parse_filter(const char *str, return NULL; } *n_objs=n; - + /* get object list */ for ( j = 0, k = 0, n = 0; j < end_obj; j++, k++) { @@ -124,8 +124,8 @@ obj_list_t* parse_filter(const char *str, 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++) @@ -135,9 +135,9 @@ obj_list_t* parse_filter(const char *str, 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> @@ -182,14 +182,14 @@ obj_list_t* parse_filter(const char *str, 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> @@ -204,7 +204,7 @@ obj_list_t* parse_filter(const char *str, * SOFF=3,DF *------------------------------------------------------------------------- */ - + else if (strcmp(scomp,"SOFF")==0) { l=-1; /* mask index check */ @@ -242,19 +242,19 @@ obj_list_t* parse_filter(const char *str, 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 */ @@ -268,16 +268,16 @@ obj_list_t* parse_filter(const char *str, } stype[m]=c; } /* u */ - + stype[m]='\0'; } /*if */ - - - + + + filt->cd_values[j++]=atoi(stype); i+=m; /* jump */ } - else if (i==len-1) + else if (i==len-1) { /*no more parameters */ scomp[k+1]='\0'; no_param=1; @@ -287,7 +287,7 @@ obj_list_t* parse_filter(const char *str, * translate from string to filter symbol *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * H5Z_FILTER_NONE *------------------------------------------------------------------------- @@ -297,7 +297,7 @@ obj_list_t* parse_filter(const char *str, filt->filtn=H5Z_FILTER_NONE; filt->cd_nelmts = 0; } - + /*------------------------------------------------------------------------- * H5Z_FILTER_DEFLATE *------------------------------------------------------------------------- @@ -306,14 +306,14 @@ obj_list_t* parse_filter(const char *str, { filt->filtn=H5Z_FILTER_DEFLATE; filt->cd_nelmts = 1; - if (no_param) + 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 *------------------------------------------------------------------------- @@ -322,14 +322,14 @@ obj_list_t* parse_filter(const char *str, { filt->filtn=H5Z_FILTER_SZIP; filt->cd_nelmts = 2; - if (no_param) + 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 *------------------------------------------------------------------------- @@ -383,7 +383,7 @@ obj_list_t* parse_filter(const char *str, { filt->filtn=H5Z_FILTER_SCALEOFFSET; filt->cd_nelmts = 2; - if (no_param) + 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); @@ -397,12 +397,12 @@ obj_list_t* parse_filter(const char *str, } } } /*i*/ - + /*------------------------------------------------------------------------- * check valid parameters *------------------------------------------------------------------------- */ - + switch (filt->filtn) { @@ -410,7 +410,7 @@ obj_list_t* parse_filter(const char *str, * H5Z_FILTER_DEFLATE *------------------------------------------------------------------------- */ - + case H5Z_FILTER_DEFLATE: if (filt->cd_values[0]<0 || filt->cd_values[0]>9 ) { @@ -419,27 +419,27 @@ obj_list_t* parse_filter(const char *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 ((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 (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 ( (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"); @@ -461,7 +461,7 @@ obj_list_t* parse_filter(const char *str, } break; }; - + return obj_list; } @@ -501,12 +501,12 @@ obj_list_t* parse_layout(const char *str, 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++) { @@ -520,11 +520,11 @@ obj_list_t* parse_layout(const char *str, 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) @@ -533,7 +533,7 @@ obj_list_t* parse_layout(const char *str, return NULL; } *n_objs=n; - + /* get object list */ for ( j=0, k=0, n=0; j<end_obj; j++,k++) { @@ -548,7 +548,7 @@ obj_list_t* parse_layout(const char *str, k=-1; } } - + /* nothing after : */ if (end_obj+1==(int)len) { @@ -556,7 +556,7 @@ obj_list_t* parse_layout(const char *str, 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++) { @@ -580,30 +580,30 @@ obj_list_t* parse_layout(const char *str, 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' ){ @@ -612,7 +612,7 @@ obj_list_t* parse_layout(const char *str, sdim,str); exit(1); } - + if ( c=='x' || i==len-1) { if ( c=='x') { @@ -648,11 +648,11 @@ obj_list_t* parse_layout(const char *str, } /*if */ } /*if c=='x' || i==len-1 */ } /*i*/ - - + + } /*H5D_CHUNKED*/ - - + + return obj_list; } diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c index b0428bf..af29e87 100644 --- a/tools/h5repack/h5repack_refs.c +++ b/tools/h5repack/h5repack_refs.c @@ -193,7 +193,7 @@ int do_copy_refobjs(hid_t fidin, goto error; if(options->verbose) { - + printf(FORMAT_OBJ,"dset",travt->objs[i].name ); printf("object <%s> object reference created to <%s>\n", travt->objs[i].name, @@ -276,7 +276,7 @@ int do_copy_refobjs(hid_t fidin, goto error; if(options->verbose) { - + printf(FORMAT_OBJ,"dset",travt->objs[i].name ); printf("object <%s> region reference created to <%s>\n", travt->objs[i].name, diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c index 465fdbf..fed4499 100644 --- a/tools/h5repack/h5repack_verify.c +++ b/tools/h5repack/h5repack_verify.c @@ -27,7 +27,7 @@ static int has_filters(hid_t pid, hid_t tid, unsigned nfilters, filter_info_t *f * * Purpose: verify if filters and layout in the input file match the output file * - * Return: + * Return: * 1 match * 0 do not match * -1 error @@ -39,7 +39,7 @@ static int has_filters(hid_t pid, hid_t tid, unsigned nfilters, filter_info_t *f * 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 + * 3) filter input on all datasets, get all objects and match * *------------------------------------------------------------------------- */ @@ -55,16 +55,16 @@ int h5repack_verify(const char *fname, 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++) + + 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 *------------------------------------------------------------------------- @@ -77,7 +77,7 @@ int h5repack_verify(const char *fname, goto error; if((tid = H5Dget_type(did)) < 0) goto error; - + /*------------------------------------------------------------------------- * filter check *------------------------------------------------------------------------- @@ -85,14 +85,14 @@ int h5repack_verify(const char *fname, 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 *------------------------------------------------------------------------- @@ -105,32 +105,32 @@ int h5repack_verify(const char *fname, goto error; if (H5Tclose(tid) < 0) goto error; - + } - - + + /*------------------------------------------------------------------------- * check for the "all" objects option *------------------------------------------------------------------------- */ - - if(options->all_filter == 1 || options->all_layout == 1) + + 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++) + + for(i = 0; i < travt->nobjs; i++) { char *name = travt->objs[i].name; - - if(travt->objs[i].type == H5TRAV_TYPE_DATASET) + + if(travt->objs[i].type == H5TRAV_TYPE_DATASET) { - + /*------------------------------------------------------------------------- * open *------------------------------------------------------------------------- @@ -143,23 +143,23 @@ int h5repack_verify(const char *fname, 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) + if(options->all_layout == 1) { pack_info_t pack; init_packobject(&pack); @@ -168,8 +168,8 @@ int h5repack_verify(const char *fname, if(has_layout(pid, &pack) == 0) ok = 0; } - - + + /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- @@ -183,23 +183,23 @@ int h5repack_verify(const char *fname, 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); @@ -240,26 +240,26 @@ int has_layout(hid_t pid, 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) @@ -270,7 +270,7 @@ int has_layout(hid_t pid, if (chsize[i] != obj->chunk.chunk_lengths[i]) return 0; } - + return 1; } @@ -301,16 +301,16 @@ int h5repack_cmpdcpl(const char *fname1, trav_table_t *travt2=NULL; int ret=1; unsigned int i; - + /*------------------------------------------------------------------------- - * open the files + * open the files *------------------------------------------------------------------------- */ - + /* disable error reporting */ - H5E_BEGIN_TRY + H5E_BEGIN_TRY { - + /* Open the files */ if ((fid1=H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 ) { @@ -325,7 +325,7 @@ int h5repack_cmpdcpl(const char *fname1, } /* enable error reporting */ } H5E_END_TRY; - + /*------------------------------------------------------------------------- * get file table list of objects *------------------------------------------------------------------------- @@ -336,16 +336,16 @@ int h5repack_cmpdcpl(const char *fname1, goto error; if(h5trav_gettable(fid2, travt2) < 0) goto error; - - + + /*------------------------------------------------------------------------- * traverse the suppplied object list *------------------------------------------------------------------------- */ - - for(i = 0; i < travt1->nobjs; i++) + + for(i = 0; i < travt1->nobjs; i++) { - if(travt1->objs[i].type == H5TRAV_TYPE_DATASET) + if(travt1->objs[i].type == H5TRAV_TYPE_DATASET) { if((dset1 = H5Dopen2(fid1, travt1->objs[i].name, H5P_DEFAULT)) < 0) goto error; @@ -355,20 +355,20 @@ int h5repack_cmpdcpl(const char *fname1, 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) + + if(ret == 0) { error_msg(progname, "property lists for <%s> are different\n",travt1->objs[i].name); goto error; } - + /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- @@ -383,31 +383,31 @@ int h5repack_cmpdcpl(const char *fname1, 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 + H5E_BEGIN_TRY { H5Pclose(dcpl1); H5Pclose(dcpl2); @@ -419,7 +419,7 @@ error: trav_table_free(travt2); } H5E_END_TRY; return -1; - + } @@ -430,7 +430,7 @@ error: * from user input are present in the property list PID obtained from * the output file * - * Return: + * Return: * 1 match * 0 do not match * -1 error @@ -452,14 +452,14 @@ static int has_filters(hid_t pid, hid_t tid, unsigned nfilters, filter_info_t *f 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 && + if(!nfilters_dcpl && + nfilters == 1 && filter[0].filtn == H5Z_FILTER_NONE ) return 1; @@ -472,12 +472,12 @@ static int has_filters(hid_t pid, hid_t tid, unsigned nfilters, filter_info_t *f *------------------------------------------------------------------------- */ - for( i = 0; i < nfilters_dcpl; i++) + 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; @@ -485,24 +485,24 @@ static int has_filters(hid_t pid, hid_t tid, unsigned nfilters, filter_info_t *f /* 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 */ @@ -512,61 +512,61 @@ static int has_filters(hid_t pid, hid_t tid, unsigned nfilters, filter_info_t *f /* "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++) + for( j = 0; j < H5Z_SCALEOFFSET_USER_NPARMS; j++) { if (cd_values[j] != filter[i].cd_values[j]) { - return 0; + 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++) + + for( j = 0; j < cd_nelmts; j++) { if (cd_values[j] != filter[i].cd_values[j]) { - return 0; + return 0; } - + } - - - + + + break; - - - + + + } /* switch */ } - + return 1; } diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index 75af4f1..1bb9db3 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -882,11 +882,11 @@ if (szip_can_encode) { /*------------------------------------------------------------------------- * the following tests assume the input files have filters - * FNAME7 - * FNAME8 - * FNAME9 - * FNAME10 - * FNAME11 + * FNAME7 + * FNAME8 + * FNAME9 + * FNAME10 + * FNAME11 *------------------------------------------------------------------------- */ @@ -1343,7 +1343,7 @@ if (szip_can_encode) { PASSED(); /*------------------------------------------------------------------------- - * test --latest options + * test --latest options *------------------------------------------------------------------------- */ TESTING(" latest file format options"); @@ -1375,7 +1375,7 @@ if (szip_can_encode) { TESTING(" several global filters"); -#if defined (H5_HAVE_FILTER_DEFLATE) && defined (H5_HAVE_FILTER_SHUFFLE) +#if defined (H5_HAVE_FILTER_DEFLATE) && defined (H5_HAVE_FILTER_SHUFFLE) if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -1412,7 +1412,7 @@ if (szip_can_encode) { /* add the options for a user block size and user block filename */ pack_options.ublock_size = USERBLOCK_SIZE; pack_options.ublock_filename = FNAME_UB; - + if(h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) GOERROR; if(h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) @@ -1445,14 +1445,14 @@ if (szip_can_encode) { /* add the options for aligment */ pack_options.alignment = 1; pack_options.threshold = 1; - + if(h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) GOERROR; if(h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) GOERROR; if(h5repack_verify(FNAME8OUT, &pack_options) <= 0) GOERROR; - + /* verify aligment */ { @@ -1460,7 +1460,7 @@ if (szip_can_encode) { hsize_t alignment; hid_t fapl; hid_t fid; - + if (( fid = H5Fopen(FNAME8OUT, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 ) GOERROR; if ((fapl = H5Fget_access_plist(fid)) < 0) @@ -1475,13 +1475,13 @@ if (szip_can_encode) { GOERROR; if (H5Fclose(fid) < 0) GOERROR; - + } if(h5repack_end(&pack_options) < 0) GOERROR; - + PASSED(); #else @@ -1498,12 +1498,12 @@ if (szip_can_encode) { */ { hid_t fapl; - + /* setup */ h5_reset(); fapl = h5_fileaccess(); - h5_cleanup(H5REPACK_FILENAMES, fapl); - + h5_cleanup(H5REPACK_FILENAMES, fapl); + } puts("All h5repack tests passed."); @@ -1699,7 +1699,7 @@ int make_testfiles(void) goto out; /*------------------------------------------------------------------------- - * create a userblock file + * create a userblock file *------------------------------------------------------------------------- */ if(make_userblock_file() < 0) @@ -2247,7 +2247,7 @@ int make_nbit(hid_t loc_id) #endif /*------------------------------------------------------------------------- - * close + * close *------------------------------------------------------------------------- */ if(H5Sclose(sid) < 0) @@ -2780,7 +2780,7 @@ out: } /*------------------------------------------------------------------------- - * Function: make_big + * Function: make_big * * Purpose: used in test read by hyperslabs. Creates a 128MB dataset. * Only 1 1024Kb hyperslab is written. @@ -2808,7 +2808,7 @@ int make_big(hid_t loc_id) hs_start[0] = 0; hs_size[0] = 1024; - /* create */ + /* create */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; if(H5Pset_fill_value(dcpl, H5T_NATIVE_SCHAR, &fillvalue) < 0) @@ -2819,19 +2819,19 @@ int make_big(hid_t loc_id) goto out; if((did = H5Dcreate2(loc_id, "dset", H5T_NATIVE_SCHAR, f_sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto out; - if((m_sid = H5Screate_simple(1, hs_size, hs_size)) < 0) + if((m_sid = H5Screate_simple(1, hs_size, hs_size)) < 0) goto out; - if((tid = H5Dget_type(did)) < 0) + if((tid = H5Dget_type(did)) < 0) goto out; if((size = H5Tget_size(tid))<=0) goto out; - + /* initialize buffer to 0 */ buf=(signed char *) calloc( nelmts, size); - - if (H5Sselect_hyperslab (f_sid,H5S_SELECT_SET,hs_start,NULL,hs_size, NULL) < 0) + + if (H5Sselect_hyperslab (f_sid,H5S_SELECT_SET,hs_start,NULL,hs_size, NULL) < 0) goto out; - if (H5Dwrite (did,H5T_NATIVE_SCHAR,m_sid,f_sid,H5P_DEFAULT,buf) < 0) + if (H5Dwrite (did,H5T_NATIVE_SCHAR,m_sid,f_sid,H5P_DEFAULT,buf) < 0) goto out; free(buf); @@ -2862,7 +2862,7 @@ out: /*------------------------------------------------------------------------- - * Function: make_external + * Function: make_external * * Purpose: create a external dataset * @@ -2881,11 +2881,11 @@ int make_external(hid_t loc_id) cur_size[0] = max_size[0] = 2; size = max_size[0] * sizeof(int); - - /* create */ + + /* create */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_external(dcpl, H5REPACK_EXTFILE, (off_t)0, size) < 0) + if(H5Pset_external(dcpl, H5REPACK_EXTFILE, (off_t)0, size) < 0) goto out; if((sid = H5Screate_simple(1,cur_size, max_size)) < 0) goto out; @@ -3081,12 +3081,12 @@ make_userblock_file(void) return 0; out: - + if(fd > 0) HDclose(fd); return -1; -} +} /*------------------------------------------------------------------------- * Function: write_dset_in @@ -4901,5 +4901,5 @@ out: return -1; } - + |