summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorPeter Cao <xcao@hdfgroup.org>2007-07-13 18:18:48 (GMT)
committerPeter Cao <xcao@hdfgroup.org>2007-07-13 18:18:48 (GMT)
commit2b89d6d73c71d4bd7d90bb8b564992fd8f8b4628 (patch)
treeb6dccd2f6eff0305f3f19a335347259d63bc17fc /tools
parentb566d21649d3286ace6aed1eaf73d5e3ade24f6a (diff)
downloadhdf5-2b89d6d73c71d4bd7d90bb8b564992fd8f8b4628.zip
hdf5-2b89d6d73c71d4bd7d90bb8b564992fd8f8b4628.tar.gz
hdf5-2b89d6d73c71d4bd7d90bb8b564992fd8f8b4628.tar.bz2
[svn-r13975] Add --latest, -compact=<size>, ... options to use the lastest file format.
Add test for the options to the daily test.
Diffstat (limited to 'tools')
-rw-r--r--tools/h5repack/h5repack.c25
-rw-r--r--tools/h5repack/h5repack.h5
-rw-r--r--tools/h5repack/h5repack_copy.c97
-rw-r--r--tools/h5repack/h5repack_main.c64
-rw-r--r--tools/h5repack/h5repacktst.c25
5 files changed, 210 insertions, 6 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c
index 2449c36..45409c4 100644
--- a/tools/h5repack/h5repack.c
+++ b/tools/h5repack/h5repack.c
@@ -243,6 +243,10 @@ 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
*
*-------------------------------------------------------------------------
*/
@@ -368,6 +372,25 @@ static int check_options(pack_opt_t *options)
return -1;
}
+ /* check options for the latest format */
+ if (options->grp_compact < 0) {
+ error_msg(progname, "invalid maximum number of links to store as header messages\n");
+ return -1;
+ }
+ if (options->grp_indexed < 0) {
+ error_msg(progname, "invalid minimum number of links to store in the indexed format\n");
+ return -1;
+ }
+ if (options->grp_indexed > options->grp_compact) {
+ error_msg(progname, "minimum indexed size is greater than the maximum compact size\n");
+ return -1;
+ }
+ for (i=0; i<8; i++) {
+ if (options->msg_size[i]<0) {
+ error_msg(progname, "invalid shared message size\n");
+ return -1;
+ }
+ }
return 0;
}
@@ -512,4 +535,4 @@ int have_request(pack_opt_t *options)
return 0;
-} \ No newline at end of file
+}
diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h
index 3fa23d3..f8f642b 100644
--- a/tools/h5repack/h5repack.h
+++ b/tools/h5repack/h5repack.h
@@ -102,6 +102,11 @@ typedef struct {
int verbose; /*verbose mode */
hsize_t threshold; /*minimum size to compress, in bytes */
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]; /* Minumum size of shared messages: dataspace,
+ datatype, fill value, filter pipleline, attribute */
} pack_opt_t;
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index bb9fea3..bbb8d1c 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -54,6 +54,9 @@ static int copy_attr(hid_t loc_in,hid_t loc_out,pack_opt_t *options);
*
* Date: October, 23, 2003
*
+ * Modification:
+ * Peter Cao, June 13, 2007
+ * Add "-L, --latest" and other options to pack a file with the latest file format
*-------------------------------------------------------------------------
*/
@@ -64,6 +67,8 @@ int copy_objects(const char* fnamein,
hid_t fidin;
hid_t fidout=-1;
trav_table_t *travt=NULL;
+ hid_t fapl=H5P_DEFAULT; /* File access property list ID */
+ hid_t fcpl=H5P_DEFAULT; /* File creation property list ID */
/*-------------------------------------------------------------------------
* open the files
@@ -73,7 +78,66 @@ int copy_objects(const char* fnamein,
error_msg(progname, "<%s>: %s\n", fnamein, H5FOPENERROR );
goto out;
}
- if ((fidout=H5Fcreate(fnameout,H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0 ){
+
+ if (options->latest) {
+ unsigned i=0, nindex=0, mesg_type_flags[5], min_mesg_sizes[5];
+
+ /* Create file creation property list */
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0){
+ error_msg(progname, "fail to create a file creation property list\n");
+ goto out;
+ }
+
+ /* 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) {
+ error_msg(progname, "fail to adjust group creation parameters for root group\n");
+ goto out;
+ }
+
+ for (i=0; i<5; i++) {
+ if (options->msg_size[i]>0) {
+ switch (i) {
+ case 0: mesg_type_flags[nindex]=H5O_MESG_SDSPACE_FLAG; break;
+ case 1: mesg_type_flags[nindex]=H5O_MESG_DTYPE_FLAG; break;
+ case 2: mesg_type_flags[nindex]=H5O_MESG_FILL_FLAG; break;
+ case 3: mesg_type_flags[nindex]=H5O_MESG_PLINE_FLAG; break;
+ case 4: mesg_type_flags[nindex]=H5O_MESG_ATTR_FLAG; break;
+ }
+ min_mesg_sizes[nindex] = (unsigned)options->msg_size[i];
+
+ nindex++;
+ }
+ }
+
+ if (nindex>0) {
+ nindex++; /* add one for default size */
+ 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;
+ }
+ /* msg_size[0]=dataspace, 1=datatype, 2=file value, 3=filter pipleline, 4=attribute */
+ 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;
+ }
+ }
+ } /* if (nindex>0) */
+
+ /* Create file access property list */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ error_msg(progname, "Could not create file access property list\n");
+ goto out;
+ } /* end if */
+
+ if(H5Pset_latest_format(fapl, TRUE) < 0) {
+ error_msg(progname, "Could not set property for using latest version of the format\n");
+ goto out;
+ } /* end if */
+ }
+
+ if ((fidout=H5Fcreate(fnameout,H5F_ACC_TRUNC, fcpl, fapl))<0 ){
error_msg(progname, "<%s>: Could not create file\n", fnameout );
goto out;
}
@@ -116,6 +180,12 @@ int copy_objects(const char* fnamein,
*-------------------------------------------------------------------------
*/
+ if (fapl>0)
+ H5Pclose(fapl);
+
+ if (fcpl>0)
+ H5Pclose(fcpl);
+
H5Fclose(fidin);
H5Fclose(fidout);
return 0;
@@ -127,6 +197,8 @@ int copy_objects(const char* fnamein,
out:
H5E_BEGIN_TRY {
+ H5Pclose(fapl);
+ H5Pclose(fcpl);
H5Fclose(fidin);
H5Fclose(fidout);
} H5E_END_TRY;
@@ -213,6 +285,7 @@ int do_copy_objects(hid_t fidin,
hid_t grp_out=-1; /* group ID */
hid_t dset_in=-1; /* read dataset ID */
hid_t dset_out=-1; /* write dataset ID */
+ hid_t gcpl_id=-1; /* group creation property list */
hid_t type_in=-1; /* named type ID */
hid_t type_out=-1; /* named type ID */
hid_t dcpl_id=-1; /* dataset creation property list ID */
@@ -261,8 +334,21 @@ int do_copy_objects(hid_t fidin,
if (options->verbose)
printf(FORMAT_OBJ,"group",travt->objs[i].name );
- if ((grp_out=H5Gcreate(fidout,travt->objs[i].name, 0))<0)
- goto error;
+ if (options->grp_compact>0 || options->grp_indexed>0) {
+ /* Set up group creation property list */
+ if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0)
+ goto error;
+
+ if(H5Pset_link_phase_change(gcpl_id, (unsigned)options->grp_compact, (unsigned)options->grp_indexed) < 0)
+ goto error;
+
+ if((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0)
+ goto error;
+ }
+ else {
+ if ((grp_out=H5Gcreate(fidout,travt->objs[i].name, 0))<0)
+ goto error;
+ }
if((grp_in = H5Gopen (fidin,travt->objs[i].name))<0)
goto error;
@@ -274,6 +360,10 @@ int do_copy_objects(hid_t fidin,
if (copy_attr(grp_in,grp_out,options)<0)
goto error;
+ if (gcpl_id>0) {
+ if (H5Pclose(gcpl_id)<0)
+ goto error;
+ }
if (H5Gclose(grp_out)<0)
goto error;
if (H5Gclose(grp_in)<0)
@@ -729,6 +819,7 @@ error:
H5Gclose(grp_in);
H5Gclose(grp_out);
H5Pclose(dcpl_id);
+ H5Pclose(gcpl_id);
H5Sclose(f_space_id);
H5Dclose(dset_in);
H5Dclose(dset_out);
diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c
index 95bcb23..7f9c720 100644
--- a/tools/h5repack/h5repack_main.c
+++ b/tools/h5repack/h5repack_main.c
@@ -43,6 +43,10 @@ void usage(void)
printf("[-h] Print this message\n");
printf("[-v] Verbose mode\n");
printf("[-n] Use a native HDF5 type when repacking. Default is the file type\n");
+ printf("[-L, --latest] Use latest version of file format to create groups, datasets and datatypes\n");
+ printf("[-compact=<size>] Set the maximum number of links to store as header messages in a group\n");
+ printf("[-indexed=<size>] Set the minimum number of links to store in the indexed format\n");
+ printf("[-ssize=<size>[:<dspace|dtype|fill|pline|attr>]] Set the shared object header message minimum size\n");
printf("[-m size] Do not apply the filter to objects smaller than size\n");
printf("[-e file] Name of file with the -f and -l options\n");
printf("[-f FILTER] Filter type\n");
@@ -105,6 +109,10 @@ void usage(void)
printf(" Chunked layout, with a layout size of 20x10, to objects A and B\n");
printf(" and remove filters to objects C, D, F\n");
printf("\n");
+ printf("4) h5repack -L -compact=10 -ssize=20:dtype -i file1 -o file2 \n");
+ printf("\n");
+ printf(" Using latest file format with maximum compact group size fo 10 and minimum shared datatype size of 20\n");
+ printf("\n");
}
/*-------------------------------------------------------------------------
@@ -125,10 +133,11 @@ void usage(void)
* October 2006: Added a new switch -n, that allows to write the dataset
* using a native type. The default to write is the file type.
*
+ * Modification:
+ * Peter Cao, June 13, 2007
+ * Add "-L, --latest" option to pack a file with the latest file format
*-------------------------------------------------------------------------
*/
-
-
int main(int argc, char **argv)
{
char *infile = NULL;
@@ -151,6 +160,7 @@ int main(int argc, char **argv)
usage();
exit(0);
}
+
if (strcmp(argv[i], "-i") == 0) {
infile = argv[++i];
}
@@ -201,11 +211,61 @@ int main(int argc, char **argv)
options.use_native = 1;
}
+ else if ( (strcmp(argv[i], "-L") == 0) || (strcmp(argv[i], "--latest") == 0)) {
+ options.latest = 1;
+ }
+
+ else if ( strncmp(argv[i], "-compact=", 9) == 0 ) {
+ options.grp_compact = atoi(argv[i]+9);
+ if (options.grp_compact>0)
+ options.latest = 1; /* must use latest format */
+ }
+
+ else if ( strncmp(argv[i], "-indexed=", 9) == 0 ) {
+ options.grp_indexed = atoi(argv[i]+9);
+ if (options.grp_indexed>0)
+ options.latest = 1; /* must use latest format */
+ }
+
+ else if ( strncmp(argv[i], "-ssize=", 7) == 0 ) {
+ int idx = 0;
+ int ssize = 0;
+ char *msgPtr = strchr(argv[i]+7, ':');
+ options.latest = 1; /* must use latest format */
+ if (msgPtr == NULL) {
+ ssize = atoi(argv[i]+7);
+ for (idx=0; idx<5; idx++)
+ options.msg_size[idx] = ssize;
+ }
+ else {
+ char msgType[10];
+ strcpy(msgType, msgPtr+1);
+ msgPtr[0] = '\0';
+ ssize = atoi(argv[i]+7);
+ if (strcmp(msgType, "dspace") == 0) {
+ options.msg_size[0] = ssize;
+ }
+ else if (strcmp(msgType, "dtype") == 0) {
+ options.msg_size[1] = ssize;
+ }
+ else if (strcmp(msgType, "fill") == 0) {
+ options.msg_size[2] = ssize;
+ }
+ else if (strcmp(msgType, "pline") == 0) {
+ options.msg_size[3] = ssize;
+ }
+ else if (strcmp(msgType, "attr") == 0) {
+ options.msg_size[4] = ssize;
+ }
+ }
+ } /* else if ( strncmp(argv[i], "-ssize=", 7) == 0 ) */
+
else if (argv[i][0] == '-') {
error_msg(progname, " - is not a valid argument\n");
usage();
exit(1);
}
+
}
if (infile == NULL || outfile == NULL)
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c
index 6d1888c..93d9b23 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -1301,6 +1301,31 @@ if (szip_can_encode) {
GOERROR;
PASSED();
+/*-------------------------------------------------------------------------
+ * test --latest options
+ *-------------------------------------------------------------------------
+ */
+ TESTING(" latest file format options");
+ if (h5repack_init (&pack_options, 0)<0)
+ GOERROR;
+ pack_options.latest=1;
+ pack_options.grp_compact=10;
+ pack_options.grp_indexed=5;
+ pack_options.msg_size[0] = 10;
+ pack_options.msg_size[1] = 20;
+ pack_options.msg_size[2] = 30;
+ pack_options.msg_size[3] = 40;
+ pack_options.msg_size[4] = 50;
+ if (h5repack(FNAME1,FNAME1OUT,&pack_options) < 0)
+ GOERROR;
+ if (h5diff(FNAME1,FNAME1OUT,NULL,NULL,&diff_options) > 0)
+ GOERROR;
+ if (h5repack_verify(FNAME1OUT,&pack_options)<=0)
+ GOERROR;
+ if (h5repack_end (&pack_options)<0)
+ GOERROR;
+ PASSED();
+
/*-------------------------------------------------------------------------
* clean temporary test files