diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2016-04-18 20:41:28 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2016-04-18 20:41:28 (GMT) |
commit | 5103dc8315bc1d5de746031655b9102934e7cd8d (patch) | |
tree | cdb811ea9f4d02a6fe3e481b7eb16573ca9e6e1d /tools/h5format_convert/h5format_convert.c | |
parent | 3bbe21ce7bbd8246600c0099e64e644501f5a806 (diff) | |
download | hdf5-5103dc8315bc1d5de746031655b9102934e7cd8d.zip hdf5-5103dc8315bc1d5de746031655b9102934e7cd8d.tar.gz hdf5-5103dc8315bc1d5de746031655b9102934e7cd8d.tar.bz2 |
[svn-r29733] HDFFV-9756: Verified H5Dint.c patch works for H5Repack, also reworked VDS tests for H5Repack.
HDFFV-9766: Added h5format_convert to CMake. Reworked tests to allow parallel testing with CMake.
HDFFV-9770: Added h5watch to CMake.
Tested: CMake and autotools on loacl linux.
Diffstat (limited to 'tools/h5format_convert/h5format_convert.c')
-rw-r--r-- | tools/h5format_convert/h5format_convert.c | 356 |
1 files changed, 178 insertions, 178 deletions
diff --git a/tools/h5format_convert/h5format_convert.c b/tools/h5format_convert/h5format_convert.c index 105ac5d..2d7b721 100644 --- a/tools/h5format_convert/h5format_convert.c +++ b/tools/h5format_convert/h5format_convert.c @@ -20,7 +20,7 @@ /* * We include the private header file so we can get to the uniform - * programming environment it declares. + * programming environment it declares. * HDF5 API functions (except for H5G_basename()) */ #include "H5private.h" @@ -44,13 +44,13 @@ static int verbose_g = 0; static const char *s_opts = "hVvd:n"; static struct long_options l_opts[] = { { "help", no_arg, 'h' }, - { "hel", no_arg, 'h'}, - { "he", no_arg, 'h'}, + { "hel", no_arg, 'h'}, + { "he", no_arg, 'h'}, { "version", no_arg, 'V' }, - { "version", no_arg, 'V' }, - { "versio", no_arg, 'V' }, - { "versi", no_arg, 'V' }, - { "vers", no_arg, 'V' }, + { "version", no_arg, 'V' }, + { "versio", no_arg, 'V' }, + { "versi", no_arg, 'V' }, + { "vers", no_arg, 'V' }, { "verbose", no_arg, 'v' }, { "verbos", no_arg, 'v' }, { "verbo", no_arg, 'v' }, @@ -75,33 +75,33 @@ static struct long_options l_opts[] = { * *------------------------------------------------------------------------- */ -static void usage(const char *prog) +static void usage(const char *prog) { - printf("usage: %s [OPTIONS] file_name\n", prog); - printf(" OPTIONS\n"); - printf(" -h, --help Print a usage message and exit\n"); - printf(" -V, --version Print version number and exit\n"); - printf(" -v, --verbose Turn on verbose mode\n"); - printf(" -d dname, --dname=dataset_name Pathname for the dataset\n"); - printf(" -n, --noop Perform all the steps except the actual conversion\n"); - printf("\n"); - printf("Examples of use:\n"); - printf("\n"); - printf("h5format_convert -d /group/dataset file_name\n"); - printf(" Convert the dataset </group/dataset> in the HDF5 file <file_name>:\n"); - printf(" a. chunked dataset: convert the chunk indexing type to version 1 B-tree\n"); - printf(" b. compact/contiguous dataset: downgrade the layout version to 3\n"); - printf(" c. virtual dataset: no action\n"); - printf("\n"); - printf("h5format_convert file_name\n"); - printf(" Convert all datasets in the HDF5 file <file_name>:\n"); - printf(" a. chunked dataset: convert the chunk indexing type to version 1 B-tree\n"); - printf(" b. compact/contiguous dataset: downgrade the layout version to 3\n"); - printf(" c. virtual dataset: no action\n"); - printf("\n"); - printf("h5format_convert -n -d /group/dataset file_name\n"); - printf(" Go through all the steps except the actual conversion when \n"); - printf(" converting the dataset </group/dataset> in the HDF5 file <file_name>.\n"); + printf("usage: %s [OPTIONS] file_name\n", prog); + printf(" OPTIONS\n"); + printf(" -h, --help Print a usage message and exit\n"); + printf(" -V, --version Print version number and exit\n"); + printf(" -v, --verbose Turn on verbose mode\n"); + printf(" -d dname, --dname=dataset_name Pathname for the dataset\n"); + printf(" -n, --noop Perform all the steps except the actual conversion\n"); + printf("\n"); + printf("Examples of use:\n"); + printf("\n"); + printf("h5format_convert -d /group/dataset file_name\n"); + printf(" Convert the dataset </group/dataset> in the HDF5 file <file_name>:\n"); + printf(" a. chunked dataset: convert the chunk indexing type to version 1 B-tree\n"); + printf(" b. compact/contiguous dataset: downgrade the layout version to 3\n"); + printf(" c. virtual dataset: no action\n"); + printf("\n"); + printf("h5format_convert file_name\n"); + printf(" Convert all datasets in the HDF5 file <file_name>:\n"); + printf(" a. chunked dataset: convert the chunk indexing type to version 1 B-tree\n"); + printf(" b. compact/contiguous dataset: downgrade the layout version to 3\n"); + printf(" c. virtual dataset: no action\n"); + printf("\n"); + printf("h5format_convert -n -d /group/dataset file_name\n"); + printf(" Go through all the steps except the actual conversion when \n"); + printf(" converting the dataset </group/dataset> in the HDF5 file <file_name>.\n"); } /* usage() */ /*------------------------------------------------------------------------- @@ -110,68 +110,68 @@ static void usage(const char *prog) * Purpose: parse command line input * * Return: Success: 0 - * Failure: 1 + * Failure: 1 * *------------------------------------------------------------------------- */ static int -parse_command_line(int argc, const char **argv) +parse_command_line(int argc, const char **argv) { int opt; /* no arguments */ if (argc == 1) { usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); goto error; } /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch((char) opt) { - case 'h': - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_SUCCESS); - goto error; - - case 'V': - print_version(h5tools_getprogname()); - h5tools_setstatus(EXIT_SUCCESS); - goto error; - - case 'v': - verbose_g = TRUE; - break; - - case 'd': /* -d dname */ - if(opt_arg != NULL && *opt_arg) - /* if(opt_arg != NULL)*/ - dname_g = HDstrdup(opt_arg); - if(dname_g == NULL) { - h5tools_setstatus(EXIT_FAILURE); - error_msg("No dataset name\n", opt_arg); - usage(h5tools_getprogname()); - goto error; - } - dset_g = TRUE; - break; - - case 'n': /* -n */ - noop_g = TRUE; - break; - - default: - h5tools_setstatus(EXIT_FAILURE); - usage(h5tools_getprogname()); - goto error; - break; - } /* switch */ + switch((char) opt) { + case 'h': + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); + goto error; + + case 'V': + print_version(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); + goto error; + + case 'v': + verbose_g = TRUE; + break; + + case 'd': /* -d dname */ + if(opt_arg != NULL && *opt_arg) + /* if(opt_arg != NULL)*/ + dname_g = HDstrdup(opt_arg); + if(dname_g == NULL) { + h5tools_setstatus(EXIT_FAILURE); + error_msg("No dataset name\n", opt_arg); + usage(h5tools_getprogname()); + goto error; + } + dset_g = TRUE; + break; + + case 'n': /* -n */ + noop_g = TRUE; + break; + + default: + h5tools_setstatus(EXIT_FAILURE); + usage(h5tools_getprogname()); + goto error; + break; + } /* switch */ } /* while */ if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); goto error; } @@ -205,17 +205,17 @@ leave(int ret) * Function: convert() * * Purpose: To downgrade a dataset's indexing type or layout version: - * For chunked: - * Downgrade the chunk indexing type to version 1 B-tree - * If type is already version 1 B-tree, no further action - * For compact/contiguous: - * Downgrade the layout version from 4 to 3 - * If version is already <= 3, no further action - * For virtual: - * No further action + * For chunked: + * Downgrade the chunk indexing type to version 1 B-tree + * If type is already version 1 B-tree, no further action + * For compact/contiguous: + * Downgrade the layout version from 4 to 3 + * If version is already <= 3, no further action + * For virtual: + * No further action * * Return: Success: 0 - * Failure: 1 + * Failure: 1 * *------------------------------------------------------------------------- */ @@ -229,114 +229,114 @@ convert(hid_t fid, const char *dname) /* Open the dataset */ if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) { - error_msg("unable to open dataset \"%s\"\n", dname); - h5tools_setstatus(EXIT_FAILURE); - goto error; + error_msg("unable to open dataset \"%s\"\n", dname); + h5tools_setstatus(EXIT_FAILURE); + goto error; } else if(verbose_g) - printf("Open the dataset\n"); + printf("Open the dataset\n"); /* Get the dataset's creation property list */ if((dcpl = H5Dget_create_plist(did)) < 0) { - error_msg("unable to get the dataset creation property list\n"); - h5tools_setstatus(EXIT_FAILURE); - goto error; + error_msg("unable to get the dataset creation property list\n"); + h5tools_setstatus(EXIT_FAILURE); + goto error; } /* Get the dataset's layout */ if((layout_type = H5Pget_layout(dcpl)) < 0) { - error_msg("unable to get the dataset layout type\n"); - h5tools_setstatus(EXIT_FAILURE); - goto error; + error_msg("unable to get the dataset layout type\n"); + h5tools_setstatus(EXIT_FAILURE); + goto error; } else if(verbose_g) - printf("Retrieve the dataset's layout\n"); + printf("Retrieve the dataset's layout\n"); switch(layout_type) { - case H5D_CHUNKED: - if(verbose_g) - printf("Dataset is a chunked dataset\n"); - - /* Get the dataset's chunk indexing type */ - if(H5Dget_chunk_index_type(did, &idx_type) < 0) { - error_msg("unable to get the chunk indexing type for \"%s\"\n", dname); - h5tools_setstatus(EXIT_FAILURE); - goto error; - } else if(verbose_g) - printf("Retrieve the dataset's chunk indexing type\n"); - - if(idx_type == H5D_CHUNK_IDX_BTREE) { - if(verbose_g) - printf("Dataset's chunk indexing type is already version 1 B-tree: no further action\n"); - h5tools_setstatus(EXIT_SUCCESS); - goto done; - } else if (verbose_g) - printf("Dataset's chunk indexing type is not version 1 B-tree\n"); - break; - - case H5D_CONTIGUOUS: - if(verbose_g) - printf("Dataset is a contiguous dataset: downgrade layout version as needed\n"); - break; + case H5D_CHUNKED: + if(verbose_g) + printf("Dataset is a chunked dataset\n"); + + /* Get the dataset's chunk indexing type */ + if(H5Dget_chunk_index_type(did, &idx_type) < 0) { + error_msg("unable to get the chunk indexing type for \"%s\"\n", dname); + h5tools_setstatus(EXIT_FAILURE); + goto error; + } else if(verbose_g) + printf("Retrieve the dataset's chunk indexing type\n"); + + if(idx_type == H5D_CHUNK_IDX_BTREE) { + if(verbose_g) + printf("Dataset's chunk indexing type is already version 1 B-tree: no further action\n"); + h5tools_setstatus(EXIT_SUCCESS); + goto done; + } else if (verbose_g) + printf("Dataset's chunk indexing type is not version 1 B-tree\n"); + break; + + case H5D_CONTIGUOUS: + if(verbose_g) + printf("Dataset is a contiguous dataset: downgrade layout version as needed\n"); + break; case H5D_COMPACT: - if(verbose_g) - printf("Dataset is a compact dataset: downgrade layout version as needed\n"); - break; + if(verbose_g) + printf("Dataset is a compact dataset: downgrade layout version as needed\n"); + break; case H5D_VIRTUAL: - if(verbose_g) - printf("No further action for virtual dataset\n"); - goto done; + if(verbose_g) + printf("No further action for virtual dataset\n"); + goto done; - default: - error_msg("unknown layout type for \"%s\"\n", dname); - h5tools_setstatus(EXIT_FAILURE); - goto error; + default: + error_msg("unknown layout type for \"%s\"\n", dname); + h5tools_setstatus(EXIT_FAILURE); + goto error; } /* end switch */ /* No further action if it is a noop */ if(noop_g) { - if(verbose_g) - printf("Not converting the dataset\n"); - h5tools_setstatus(EXIT_SUCCESS); - goto done; + if(verbose_g) + printf("Not converting the dataset\n"); + h5tools_setstatus(EXIT_SUCCESS); + goto done; } if(verbose_g) - printf("Converting the dataset...\n"); + printf("Converting the dataset...\n"); /* Downgrade the dataset */ if(H5Dformat_convert(did) < 0) { - error_msg("unable to downgrade dataset for \"%s\"\n", dname); - h5tools_setstatus(EXIT_FAILURE); - goto error; + error_msg("unable to downgrade dataset for \"%s\"\n", dname); + h5tools_setstatus(EXIT_FAILURE); + goto error; } else if(verbose_g) - printf("Done\n"); + printf("Done\n"); done: /* Close the dataset */ if(H5Dclose(did) < 0) { error_msg("unable to close dataset \"%s\"\n", dname); h5tools_setstatus(EXIT_FAILURE); - goto error; + goto error; } else if(verbose_g) - printf("Close the dataset\n"); - + printf("Close the dataset\n"); + /* Close the dataset creation property list */ if(H5Pclose(dcpl) < 0) { error_msg("unable to close dataset creation property list\n"); h5tools_setstatus(EXIT_FAILURE); - goto error; + goto error; } else if(verbose_g) - printf("Close the dataset creation property list\n"); + printf("Close the dataset creation property list\n"); return(0); error: if(verbose_g) - printf("Error encountered\n"); + printf("Error encountered\n"); H5E_BEGIN_TRY { H5Pclose(dcpl); @@ -351,10 +351,10 @@ error: * Function: convert_dsets_cb() * * Purpose: The callback routine from the traversal to convert the - * chunk indexing type of the dataset object. + * chunk indexing type of the dataset object. * * Return: Success: 0 - * Failure: 1 + * Failure: 1 *------------------------------------------------------------------------- */ static int @@ -366,11 +366,11 @@ convert_dsets_cb(const char *path, const H5O_info_t *oi, const char *already_vis if(NULL == already_visited) { if(oi->type == H5O_TYPE_DATASET) { - if(verbose_g) - printf("Going to process dataset:%s...\n", path); - if(convert(fid, path) < 0) - goto error; - } + if(verbose_g) + printf("Going to process dataset:%s...\n", path); + if(convert(fid, path) < 0) + goto error; + } } /* end if */ @@ -386,10 +386,10 @@ error: * Function: main * * Purpose: To convert the chunk indexing type of a dataset in a file to - * version 1 B-tree. + * version 1 B-tree. * * Return: Success: 0 - * Failure: 1 + * Failure: 1 * *------------------------------------------------------------------------- */ @@ -412,31 +412,31 @@ main(int argc, const char *argv[]) /* Parse command line options */ if(parse_command_line(argc, argv) < 0) - goto done; + goto done; else if(verbose_g) - printf("Process command line options\n"); + printf("Process command line options\n"); if(noop_g && verbose_g) - printf("It is noop...\n"); + printf("It is noop...\n"); /* Open the HDF5 file */ if((fid = h5tools_fopen(fname_g, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0)) < 0) { - error_msg("unable to open file \"%s\"\n", fname_g); - h5tools_setstatus(EXIT_FAILURE); - goto done; + error_msg("unable to open file \"%s\"\n", fname_g); + h5tools_setstatus(EXIT_FAILURE); + goto done; } else if(verbose_g) - printf("Open the file %s\n", fname_g); + printf("Open the file %s\n", fname_g); if(dset_g) { /* Convert a specified dataset in the file */ - if(verbose_g) - printf("Going to process dataset: %s...\n", dname_g); - if(convert(fid, dname_g) < 0) - goto done; + if(verbose_g) + printf("Going to process dataset: %s...\n", dname_g); + if(convert(fid, dname_g) < 0) + goto done; } else { /* Convert all datasets in the file */ - if(verbose_g) - printf("Processing all datasets in the file...\n"); - if(h5trav_visit(fid, "/", TRUE, TRUE, convert_dsets_cb, NULL, &fid) < 0) - goto done; + if(verbose_g) + printf("Processing all datasets in the file...\n"); + if(h5trav_visit(fid, "/", TRUE, TRUE, convert_dsets_cb, NULL, &fid) < 0) + goto done; } if(verbose_g) { @@ -458,18 +458,18 @@ main(int argc, const char *argv[]) done: /* Close the file */ if(fid >= 0) { - if(H5Fclose(fid) < 0) { - error_msg("unable to close file \"%s\"\n", fname_g); - h5tools_setstatus(EXIT_FAILURE); - } else if(verbose_g) - printf("Close the file\n"); - } + if(H5Fclose(fid) < 0) { + error_msg("unable to close file \"%s\"\n", fname_g); + h5tools_setstatus(EXIT_FAILURE); + } else if(verbose_g) + printf("Close the file\n"); + } if(fname_g) - HDfree(fname_g); + HDfree(fname_g); if(dname_g) - HDfree(dname_g); - + HDfree(dname_g); + H5Eset_auto2(H5E_DEFAULT, func, edata); leave(h5tools_getstatus()); |