diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-09-22 21:24:22 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-09-22 21:24:22 (GMT) |
commit | 299ebc0d7f73620b7f9c793da9dbdd21e2df94f9 (patch) | |
tree | 4fd0656a8b976b42faee1534caa9c0913752ca15 /tools/h5repack | |
parent | 926cfe52cc14c735e53709e8b8dc3bfc4d0f8dd8 (diff) | |
download | hdf5-299ebc0d7f73620b7f9c793da9dbdd21e2df94f9.zip hdf5-299ebc0d7f73620b7f9c793da9dbdd21e2df94f9.tar.gz hdf5-299ebc0d7f73620b7f9c793da9dbdd21e2df94f9.tar.bz2 |
[svn-r15680]
Formatted code
Tested: windows, linux
Diffstat (limited to 'tools/h5repack')
-rw-r--r-- | tools/h5repack/h5repack.c | 12 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 96 | ||||
-rw-r--r-- | tools/h5repack/h5repack_main.c | 8 |
3 files changed, 74 insertions, 42 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index 38740e9..92db049 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -483,7 +483,8 @@ static int check_objects(const char* fname, * open the file *------------------------------------------------------------------------- */ - if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0){ + if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0) + { printf("<%s>: %s\n", fname, H5FOPENERROR ); return -1; } @@ -508,13 +509,15 @@ static int check_objects(const char* fname, if(options->verbose) printf("Opening file <%s>. Searching for objects to modify...\n", fname); - 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; if(options->verbose) printf(" <%s>",name); /* the input object names are present in the file and are valid */ - if(h5trav_getindext(name, travt) < 0) { + if(h5trav_getindext(name, travt) < 0) + { error_msg(progname, "%s Could not find <%s> in file <%s>. Exiting...\n", (options->verbose?"\n":""),name,fname); goto out; @@ -523,7 +526,8 @@ static int check_objects(const char* fname, printf("...Found\n"); /* check for extra filter conditions */ - switch(options->op_tbl->objs[i].filter->filtn) { + switch(options->op_tbl->objs[i].filter->filtn) + { /* chunk size must be smaller than pixels per block */ case H5Z_FILTER_SZIP: { diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index a49b2f7..92f8321 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -76,15 +76,16 @@ int copy_objects(const char* fnamein, hid_t fidin; hid_t fidout = -1; trav_table_t *travt = NULL; - hsize_t ub_size = 0; /* Size of user block */ - hid_t fapl = H5P_DEFAULT; /* File access property list ID */ - hid_t fcpl = H5P_DEFAULT; /* File creation property list ID */ + hsize_t ub_size = 0; /* size of user block */ + hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */ + hid_t fapl = H5P_DEFAULT; /* file access property list ID */ /*------------------------------------------------------------------------- - * open the files + * open input file *------------------------------------------------------------------------- */ - if((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { + if((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) + { error_msg(progname, "<%s>: %s\n", fnamein, H5FOPENERROR ); goto out; } @@ -92,50 +93,63 @@ int copy_objects(const char* fnamein, /* get user block size */ { hid_t fcpl_in; /* file creation property list ID for input file */ - - if((fcpl_in = H5Fget_create_plist(fidin)) < 0) { + + if((fcpl_in = H5Fget_create_plist(fidin)) < 0) + { error_msg(progname, "failed to retrieve file creation property list\n"); goto out; - } /* end if */ - - if(H5Pget_userblock(fcpl_in, &ub_size) < 0) { + } + + if(H5Pget_userblock(fcpl_in, &ub_size) < 0) + { error_msg(progname, "failed to retrieve userblock size\n"); goto out; - } /* end if */ - - if(H5Pclose(fcpl_in) < 0) { + } + + if(H5Pclose(fcpl_in) < 0) + { error_msg(progname, "failed to close property list\n"); goto out; - } /* end if */ - } /* end block */ + } + } /* Check if we need to create a non-default file creation property list */ - if(options->latest || ub_size > 0) { + if(options->latest || ub_size > 0) + { /* Create 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; - } /* end if */ + } if(ub_size > 0) - if(H5Pset_userblock(fcpl, ub_size) < 0) { + { + if(H5Pset_userblock(fcpl, ub_size) < 0) + { error_msg(progname, "failed to set non-default userblock size\n"); goto out; - } /* end if */ + } + } - if(options->latest) { + if(options->latest) + { unsigned i = 0, nindex = 0, mesg_type_flags[5], min_mesg_sizes[5]; /* Adjust group creation parameters for root group */ /* (So that it is created in "dense storage" form) */ - if(H5Pset_link_phase_change(fcpl, (unsigned)options->grp_compact, (unsigned)options->grp_indexed) < 0) { + if(H5Pset_link_phase_change(fcpl, (unsigned)options->grp_compact, (unsigned)options->grp_indexed) < 0) + { error_msg(progname, "fail to adjust group creation parameters for root group\n"); goto out; - } /* end if */ + } - for(i = 0; i < 5; i++) { - if(options->msg_size[i] > 0) { - switch(i) { + for(i = 0; i < 5; i++) + { + if(options->msg_size[i] > 0) + { + switch(i) + { case 0: mesg_type_flags[nindex] = H5O_SHMESG_SDSPACE_FLAG; break; @@ -162,14 +176,17 @@ int copy_objects(const char* fnamein, } /* end if */ } /* end for */ - if(nindex > 0) { - if(H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0) { + if(nindex > 0) + { + if(H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0) + { error_msg(progname, "fail to set the number of shared object header message indexes\n"); goto out; - } /* end if */ + } /* msg_size[0]=dataspace, 1=datatype, 2=file value, 3=filter pipleline, 4=attribute */ - for(i = 0; i < (nindex - 1); i++) { + for(i = 0; i < (nindex - 1); i++) + { if(H5Pset_shared_mesg_index(fcpl, i, mesg_type_flags[i], min_mesg_sizes[i]) < 0) { error_msg(progname, "fail to configure the specified shared object header message index\n"); goto out; @@ -178,12 +195,14 @@ int copy_objects(const char* fnamein, } /* if (nindex>0) */ /* Create 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; } /* end if */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + { error_msg(progname, "Could not set property for using latest version of the format\n"); goto out; } /* end if */ @@ -249,7 +268,7 @@ int copy_objects(const char* fnamein, if ( options->alignment > 0 ) { - /* either use the FCPL already created or create a new one */ + /* either use the FAPL already created or create a new one */ if (fapl != H5P_DEFAULT) { @@ -313,7 +332,10 @@ int copy_objects(const char* fnamein, } } - + /*------------------------------------------------------------------------- + * get list of objects + *------------------------------------------------------------------------- + */ /* init table */ trav_table_init(&travt); @@ -326,7 +348,8 @@ int copy_objects(const char* fnamein, * do the copy *------------------------------------------------------------------------- */ - if(do_copy_objects(fidin, fidout, travt, options) < 0) { + if(do_copy_objects(fidin, fidout, travt, options) < 0) + { error_msg(progname, "<%s>: Could not copy data to: %s\n", fnamein, fnameout); goto out; } /* end if */ @@ -383,7 +406,8 @@ int copy_objects(const char* fnamein, */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(fcpl); H5Fclose(fidin); diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index 1ec8e88..7846abe 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_main.c @@ -95,8 +95,8 @@ static struct long_options l_opts[] = { */ int main(int argc, const char **argv) { - const char *infile = NULL; - const char *outfile = NULL; + const char *infile = NULL; + const char *outfile = NULL; pack_opt_t options; /*the global options */ int ret=-1; int i; @@ -325,16 +325,20 @@ static void usage(const char *prog) printf(" -v, --verbose Verbose mode, print object information\n"); printf(" -V, --version Print version number and exit\n"); printf(" -n, --native Use a native HDF5 type when repacking\n"); + printf(" -L, --latest Use latest version of file format\n"); printf(" -c L1, --compact=L1 Maximum number of links in header messages\n"); printf(" -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); printf(" -s S[:F], --ssize=S[:F] Shared object header message minimum size\n"); + printf(" -m M, --minimum=M Do not apply the filter to datasets smaller than M\n"); printf(" -e E, --file=E Name of file E with the -f and -l options\n"); + printf(" -u U, --ublock=U Name of file U with user block data to be added\n"); printf(" -b B, --block=B Size of user block to be added\n"); printf(" -t T, --threshold=T Threshold value for H5Pset_alignment\n"); 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"); |