diff options
Diffstat (limited to 'hl/tools/h5watch')
-rw-r--r-- | hl/tools/h5watch/extend_dset.c | 292 | ||||
-rw-r--r-- | hl/tools/h5watch/h5watch.c | 556 | ||||
-rw-r--r-- | hl/tools/h5watch/h5watchgentest.c | 275 | ||||
-rw-r--r-- | hl/tools/h5watch/swmr_check_compat_vfd.c | 8 |
4 files changed, 565 insertions, 566 deletions
diff --git a/hl/tools/h5watch/extend_dset.c b/hl/tools/h5watch/extend_dset.c index 6b59ea1..8677601 100644 --- a/hl/tools/h5watch/extend_dset.c +++ b/hl/tools/h5watch/extend_dset.c @@ -16,18 +16,18 @@ /* * Extending datasets in WATCH.h5 generated by h5watchgentest.c */ -#define DSET_ONE "DSET_ONE" -#define DSET_TWO "DSET_TWO" -#define DSET_CMPD "DSET_CMPD" -#define DSET_CMPD_ESC "DSET_CMPD_ESC" -#define DSET_CMPD_TWO "DSET_CMPD_TWO" -#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" +#define DSET_ONE "DSET_ONE" +#define DSET_TWO "DSET_TWO" +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" +#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" #define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" /* The message sent by this process (extend_dset) to the test script to start "h5watch" */ -#define WRITER_MESSAGE "writer_message" +#define WRITER_MESSAGE "writer_message" /* The message received from the test script to start extending dataset */ -#define READER_MESSAGE "reader_message" +#define READER_MESSAGE "reader_message" /* Size of data buffer */ #define TEST_BUF_SIZE 100 @@ -35,7 +35,6 @@ static herr_t extend_dset_two(const char *file, char *dname, int action1, int action2); static herr_t extend_dset_one(const char *file, char *dname, int action); - /* Data structures for datasets with compound data type */ typedef struct sub22_t { int a; @@ -44,9 +43,9 @@ typedef struct sub22_t { } sub22_t; typedef struct sub2_t { - int a; + int a; sub22_t b; - int c; + int c; } sub2_t; typedef struct sub4_t { @@ -55,7 +54,7 @@ typedef struct sub4_t { } sub4_t; typedef struct set_t { - int field1; + int field1; sub2_t field2; double field3; sub4_t field4; @@ -72,67 +71,67 @@ typedef struct set_t { static herr_t extend_dset_two(const char *file, char *dname, int action1, int action2) { - hid_t fid = -1; /* file id */ - hid_t fapl = -1; /* file access property list id */ - hid_t did = -1; /* dataset id */ - hid_t sid = -1; /* dataspace id */ - hid_t dtid = -1; /* dataset's datatype id */ - int ndims; /* # of dimension sizes */ - unsigned i; /* local index variable */ - hsize_t ext_dims[2]; /* new dimension sizes after extension */ - hsize_t cur_dims[2]; /* current dimension sizes */ - size_t dtype_size; /* size of the dataset's datatype */ - unsigned num_elmts; /* number of elements in the dataset */ - int *ibuf = NULL; /* buffer for storing retrieved elements (integer) */ - set_t *cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */ + hid_t fid = -1; /* file id */ + hid_t fapl = -1; /* file access property list id */ + hid_t did = -1; /* dataset id */ + hid_t sid = -1; /* dataspace id */ + hid_t dtid = -1; /* dataset's datatype id */ + int ndims; /* # of dimension sizes */ + unsigned i; /* local index variable */ + hsize_t ext_dims[2]; /* new dimension sizes after extension */ + hsize_t cur_dims[2]; /* current dimension sizes */ + size_t dtype_size; /* size of the dataset's datatype */ + unsigned num_elmts; /* number of elements in the dataset */ + int * ibuf = NULL; /* buffer for storing retrieved elements (integer) */ + set_t * cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */ /* Allocate memory */ - if(NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int)))) + if (NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int)))) goto error; - if(NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t)))) + if (NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t)))) goto error; /* Create a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Open the file and dataset with SWMR write */ - if((fid = H5Fopen(file, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(file, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) goto error; - if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) goto error; /* Send message to the test script to start "h5watch" */ h5_send_message(WRITER_MESSAGE, NULL, NULL); - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto error; - if((ndims = H5Sget_simple_extent_ndims(sid)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(sid)) < 0) goto error; /* Get the size of the dataset's datatype */ - if((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0) + if ((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0) goto error; /* Get the dataset's data type */ - if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) goto error; /* Wait for message from the test script to start extending dataset */ - if(h5_wait_message(READER_MESSAGE) < 0) + if (h5_wait_message(READER_MESSAGE) < 0) goto error; /* sleep to emulate about 2 seconds of application operation */ HDsleep(2); /* Get current dimension sizes */ - if(H5LDget_dset_dims(did, cur_dims) < 0) + if (H5LDget_dset_dims(did, cur_dims) < 0) goto error; /* Set up the new extended dimension sizes */ @@ -140,68 +139,74 @@ extend_dset_two(const char *file, char *dname, int action1, int action2) ext_dims[1] = cur_dims[1] + (hsize_t)action2; /* Extend the dataset */ - if(H5Dset_extent(did, ext_dims) < 0) + if (H5Dset_extent(did, ext_dims) < 0) goto error; num_elmts = 1; - for(i = 0; i < (unsigned)ndims; i++) + for (i = 0; i < (unsigned)ndims; i++) num_elmts *= (unsigned)ext_dims[i]; /* Compound type */ - if(!HDstrcmp(dname, DSET_CMPD_TWO)) { + if (!HDstrcmp(dname, DSET_CMPD_TWO)) { HDmemset(cbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); - for(i = 0; i < num_elmts; i++) { - cbuf[i].field1 = action1; - cbuf[i].field2.a = action1; - cbuf[i].field2.c = action1; + for (i = 0; i < num_elmts; i++) { + cbuf[i].field1 = action1; + cbuf[i].field2.a = action1; + cbuf[i].field2.c = action1; cbuf[i].field2.b.a = action1; cbuf[i].field2.b.b = action1; cbuf[i].field2.b.c = action1; - cbuf[i].field3 = action1; - cbuf[i].field4.a = action1; - cbuf[i].field4.b = action1; + cbuf[i].field3 = action1; + cbuf[i].field4.a = action1; + cbuf[i].field4.b = action1; } /* end for */ - /* Write to the dataset */ - if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) + /* Write to the dataset */ + if (H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) goto error; - - } else { /* Integer type */ + } + else { /* Integer type */ HDmemset(ibuf, 0, TEST_BUF_SIZE * sizeof(int)); - for(i = 0; i < num_elmts; i++) + for (i = 0; i < num_elmts; i++) ibuf[i] = action1; /* Write to the dataset */ - if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) + if (H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) goto error; } /* end if-else */ - if(H5Dflush(did) < 0) + if (H5Dflush(did) < 0) goto error; /* Closing */ - if(H5Tclose(dtid) < 0) goto error; - if(H5Dclose(did) < 0) goto error; - if(H5Pclose(fapl) < 0) goto error; - if(H5Fclose(fid) < 0) goto error; + if (H5Tclose(dtid) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; + if (H5Pclose(fapl) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; - if(ibuf) HDfree(ibuf); - if(cbuf) HDfree(cbuf); + if (ibuf) + HDfree(ibuf); + if (cbuf) + HDfree(cbuf); return SUCCEED; error: H5E_BEGIN_TRY - H5Tclose(dtid); - H5Dclose(did); - H5Pclose(fapl); - H5Fclose(fid); + H5Tclose(dtid); + H5Dclose(did); + H5Pclose(fapl); + H5Fclose(fid); H5E_END_TRY - if(ibuf) + if (ibuf) HDfree(ibuf); - if(cbuf) + if (cbuf) HDfree(cbuf); return FAIL; @@ -219,98 +224,98 @@ error: static herr_t extend_dset_one(const char *file, char *dname, int action) { - hid_t fid = -1; /* file id */ - hid_t fapl = -1; /* file access property list id */ - hid_t did = -1; /* dataset id */ - hid_t dtid = -1; /* dataset's datatype id */ - hid_t sid = -1; /* dataspace id */ - hid_t mid = -1; /* memory space id */ - int i; /* local index variable */ - hsize_t cur_dims[1]; /* current dimension sizes */ - hsize_t ext_dims[1]; /* new dimension sizes after extension */ - hsize_t offset[1]; /* starting offsets of appended data */ - hsize_t count[1]; /* dimension sizes of appended data */ - size_t dtype_size; /* size of the dataset's datatype */ - int *ibuf = NULL; /* buffer for storing retrieved elements (integer) */ - set_t *cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */ + hid_t fid = -1; /* file id */ + hid_t fapl = -1; /* file access property list id */ + hid_t did = -1; /* dataset id */ + hid_t dtid = -1; /* dataset's datatype id */ + hid_t sid = -1; /* dataspace id */ + hid_t mid = -1; /* memory space id */ + int i; /* local index variable */ + hsize_t cur_dims[1]; /* current dimension sizes */ + hsize_t ext_dims[1]; /* new dimension sizes after extension */ + hsize_t offset[1]; /* starting offsets of appended data */ + hsize_t count[1]; /* dimension sizes of appended data */ + size_t dtype_size; /* size of the dataset's datatype */ + int * ibuf = NULL; /* buffer for storing retrieved elements (integer) */ + set_t * cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */ /* Allocate memory */ - if(NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int)))) + if (NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int)))) goto error; - if(NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t)))) + if (NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t)))) goto error; /* Create a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Open the file and dataset with SWMR write */ - if((fid = H5Fopen(file, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(file, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) goto error; /* Send message to the test script to start "h5watch" */ h5_send_message(WRITER_MESSAGE, NULL, NULL); - if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) goto error; /* Get size of the dataset's datatype */ - if((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0) + if ((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0) goto error; /* Get dataset's datatype */ - if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) goto error; /* Wait for message from the test script to start extending dataset */ - if(h5_wait_message(READER_MESSAGE) < 0) + if (h5_wait_message(READER_MESSAGE) < 0) goto error; /* sleep to emulate about 2 seconds of application operation */ HDsleep(2); /* Get current dimension sizes */ - if(H5LDget_dset_dims(did, cur_dims) < 0) + if (H5LDget_dset_dims(did, cur_dims) < 0) goto error; /* Set up the new extended dimension sizes */ ext_dims[0] = cur_dims[0] + (hsize_t)action; /* Extend the dataset */ - if(H5Dset_extent(did, ext_dims) < 0) + if (H5Dset_extent(did, ext_dims) < 0) goto error; /* Write to the new appended region of the dataset */ - if(action > 0) { + if (action > 0) { /* Select the extended region */ offset[0] = cur_dims[0]; - count[0] = (hsize_t)action; - if((sid = H5Dget_space(did)) < 0) + count[0] = (hsize_t)action; + if ((sid = H5Dget_space(did)) < 0) goto error; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto error; /* Set up memory space and get dataset's datatype */ - if((mid = H5Screate_simple(1, count, NULL)) < 0) + if ((mid = H5Screate_simple(1, count, NULL)) < 0) goto error; /* Initialize data for the extended region of the dataset */ /* Compound type */ - if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { HDmemset(cbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); - for(i = 0; i < action; i++) { - cbuf[i].field1 = i + 1; - cbuf[i].field2.a = i + 2; + for (i = 0; i < action; i++) { + cbuf[i].field1 = i + 1; + cbuf[i].field2.a = i + 2; cbuf[i].field2.b.a = i + 2; cbuf[i].field2.b.b = i + 2; cbuf[i].field2.b.c = i + 2; - cbuf[i].field2.c = i + 2; + cbuf[i].field2.c = i + 2; cbuf[i].field3 = i + 3; @@ -319,57 +324,65 @@ extend_dset_one(const char *file, char *dname, int action) } /* end for */ /* Write to the extended region of the dataset */ - if(H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, cbuf) < 0) + if (H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, cbuf) < 0) goto error; - } else { /* Integer type */ + } + else { /* Integer type */ HDmemset(ibuf, 0, TEST_BUF_SIZE * sizeof(int)); - for(i = 0; i < action; i++) + for (i = 0; i < action; i++) ibuf[i] = (int)i; /* Write to the extended region of the dataset */ - if(H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, ibuf) < 0) + if (H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, ibuf) < 0) goto error; } /* end if-else */ /* Closing */ - if(H5Sclose(sid) < 0) goto error; - if(H5Sclose(mid) < 0) goto error; + if (H5Sclose(sid) < 0) + goto error; + if (H5Sclose(mid) < 0) + goto error; } /* end if */ - if(H5Dflush(did) < 0) + if (H5Dflush(did) < 0) goto error; /* Closing */ - if(H5Tclose(dtid) < 0) goto error; - if(H5Dclose(did) < 0) goto error; - if(H5Pclose(fapl) < 0) goto error; - if(H5Fclose(fid) < 0) goto error; + if (H5Tclose(dtid) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; + if (H5Pclose(fapl) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; - if(ibuf) HDfree(ibuf); - if(cbuf) HDfree(cbuf); + if (ibuf) + HDfree(ibuf); + if (cbuf) + HDfree(cbuf); return SUCCEED; error: H5E_BEGIN_TRY - H5Sclose(sid); - H5Sclose(mid); - H5Tclose(dtid); - H5Dclose(did); - H5Pclose(fapl); - H5Fclose(fid); + H5Sclose(sid); + H5Sclose(mid); + H5Tclose(dtid); + H5Dclose(did); + H5Pclose(fapl); + H5Fclose(fid); H5E_END_TRY - if(ibuf) + if (ibuf) HDfree(ibuf); - if(cbuf) + if (cbuf) HDfree(cbuf); return FAIL; } /* end extend_dset_one() */ - /* *********************************************************************** * @@ -383,32 +396,33 @@ main(int argc, const char *argv[]) { char *dname = NULL; char *fname = NULL; - int action1, action2; + int action1, action2; - if(argc != 5) { + if (argc != 5) { HDfprintf(stderr, "Should have file name, dataset name, and the extended amount...\n"); goto error; } /* end if */ /* Get the dataset name to be extended */ - fname = HDstrdup(argv[1]); - dname = HDstrdup(argv[2]); + fname = HDstrdup(argv[1]); + dname = HDstrdup(argv[2]); action1 = HDatoi(argv[3]); action2 = HDatoi(argv[4]); - if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { - if(extend_dset_one(fname, dname, action1) < 0) + if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + if (extend_dset_one(fname, dname, action1) < 0) goto error; - } else if(!HDstrcmp(dname, DSET_ONE) || - !HDstrcmp(dname, DSET_ALLOC_LATE) || - !HDstrcmp(dname, DSET_ALLOC_EARLY)) { - if(extend_dset_one(fname, dname, action1) < 0) + } + else if (!HDstrcmp(dname, DSET_ONE) || !HDstrcmp(dname, DSET_ALLOC_LATE) || + !HDstrcmp(dname, DSET_ALLOC_EARLY)) { + if (extend_dset_one(fname, dname, action1) < 0) goto error; - } else if(!HDstrcmp(dname, DSET_TWO) || - !HDstrcmp(dname, DSET_CMPD_TWO)) { - if(extend_dset_two(fname, dname, action1, action2) < 0) + } + else if (!HDstrcmp(dname, DSET_TWO) || !HDstrcmp(dname, DSET_CMPD_TWO)) { + if (extend_dset_two(fname, dname, action1, action2) < 0) goto error; - } else { + } + else { HDfprintf(stdout, "Dataset cannot be extended...\n"); goto error; } /* end if-else */ @@ -416,9 +430,9 @@ main(int argc, const char *argv[]) HDexit(EXIT_SUCCESS); error: - if(dname) + if (dname) HDfree(dname); - if(fname) + if (fname) HDfree(fname); HDexit(EXIT_FAILURE); } /* end main() */ diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c index 56f9b63..0190545 100644 --- a/hl/tools/h5watch/h5watch.c +++ b/hl/tools/h5watch/h5watch.c @@ -18,10 +18,9 @@ /* * Note: This tool used private routine */ -#define PROGRAMNAME "h5watch" /* Name of tool */ -#define FIELD_SEP "," /* nested field separator */ -#define DEFAULT_RETRY 50 /* number of times to try opening the file */ - +#define PROGRAMNAME "h5watch" /* Name of tool */ +#define FIELD_SEP "," /* nested field separator */ +#define DEFAULT_RETRY 50 /* number of times to try opening the file */ /* * Note:(see comments in hl/src/H5LDprivate.h) @@ -29,80 +28,57 @@ * This tool uses H5LD_memb_t data structure declared in H5LDprivate.h */ -const char *progname = "h5watch"; /* tool name */ -static char *g_list_of_fields = NULL; /* command line input for "list_of_fields" */ -static char *g_dup_fields = NULL; /* copy of "list_of_fields" */ -static H5LD_memb_t **g_listv = NULL; /* vector info for "list_of_fields" */ +const char * progname = "h5watch"; /* tool name */ +static char * g_list_of_fields = NULL; /* command line input for "list_of_fields" */ +static char * g_dup_fields = NULL; /* copy of "list_of_fields" */ +static H5LD_memb_t **g_listv = NULL; /* vector info for "list_of_fields" */ -static hbool_t g_monitor_size_only = FALSE; /* monitor changes in dataset dimension sizes */ -static unsigned g_polling_interval = 1; /* polling interval to check appended data */ +static hbool_t g_monitor_size_only = FALSE; /* monitor changes in dataset dimension sizes */ +static unsigned g_polling_interval = 1; /* polling interval to check appended data */ -static hbool_t g_label = FALSE; /* label compound values */ -static int g_display_width = 80; /* output width in characters */ -static hbool_t g_simple_output = FALSE; /* make output more machine-readable */ -static unsigned g_retry = DEFAULT_RETRY; /* # of times to try opening the file if somehow file is unstable */ -static hbool_t g_display_hex = FALSE; /* display data in hexadecimal format : LATER */ -static hbool_t g_user_interrupt = FALSE; /* Flag to indicate that user interrupted execution */ +static hbool_t g_label = FALSE; /* label compound values */ +static int g_display_width = 80; /* output width in characters */ +static hbool_t g_simple_output = FALSE; /* make output more machine-readable */ +static unsigned g_retry = DEFAULT_RETRY; /* # of times to try opening the file if somehow file is unstable */ +static hbool_t g_display_hex = FALSE; /* display data in hexadecimal format : LATER */ +static hbool_t g_user_interrupt = FALSE; /* Flag to indicate that user interrupted execution */ static herr_t doprint(hid_t did, hsize_t *start, hsize_t *block, int rank); -static herr_t slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, - hsize_t *start, hsize_t *block, int rank, int subrank); +static herr_t slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsize_t *block, + int rank, int subrank); static herr_t monitor_dataset(hid_t fid, char *dsetname); static herr_t process_cmpd_fields(hid_t fid, char *dsetname); static herr_t check_dataset(hid_t fid, char *dsetname); -static void leave(int ret); -static void usage(const char *prog); -static void parse_command_line(int argc, const char *argv[]); - +static void leave(int ret); +static void usage(const char *prog); +static void parse_command_line(int argc, const char *argv[]); /* * Command-line options: The user can only specify long-named parameters. * The long-named ones can be partially spelled. When * adding more, make sure that they don't clash with each other. */ -static const char *s_opts ="?"; -static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "hel", no_arg, 'h' }, - { "dim", no_arg, 'd' }, - { "di", no_arg, 'd' }, - { "label", no_arg, 'l' }, - { "labe", no_arg, 'l' }, - { "lab", no_arg, 'l' }, - { "la", no_arg, 'l' }, - { "simple", no_arg, 'S' }, - { "simpl", no_arg, 'S' }, - { "simp", no_arg, 'S' }, - { "sim", no_arg, 'S' }, - { "si", no_arg, 'S' }, - { "hexdump", no_arg, 'x' }, - { "hexdum", no_arg, 'x' }, - { "hexdu", no_arg, 'x' }, - { "hexd", no_arg, 'x' }, - { "hex", no_arg, 'x' }, - { "width", require_arg, 'w' }, - { "widt", require_arg, 'w' }, - { "wid", require_arg, 'w' }, - { "wi", require_arg, 'w' }, - { "polling", require_arg, 'p' }, - { "pollin", require_arg, 'p' }, - { "polli", require_arg, 'p' }, - { "poll", require_arg, 'p' }, - { "pol", require_arg, 'p' }, - { "po", require_arg, 'p' }, - { "fields", require_arg, 'f' }, - { "field", require_arg, 'f' }, - { "fiel", require_arg, 'f' }, - { "fie", require_arg, 'f' }, - { "fi", require_arg, 'f' }, - { "version", no_arg, 'V' }, - { "versio", no_arg, 'V' }, - { "versi", no_arg, 'V' }, - { "vers", no_arg, 'V' }, - { "ver", no_arg, 'V' }, - { "ve", no_arg, 'V' }, - { NULL, 0, '\0' } -}; +static const char * s_opts = "?"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, {"hel", no_arg, 'h'}, + {"dim", no_arg, 'd'}, {"di", no_arg, 'd'}, + {"label", no_arg, 'l'}, {"labe", no_arg, 'l'}, + {"lab", no_arg, 'l'}, {"la", no_arg, 'l'}, + {"simple", no_arg, 'S'}, {"simpl", no_arg, 'S'}, + {"simp", no_arg, 'S'}, {"sim", no_arg, 'S'}, + {"si", no_arg, 'S'}, {"hexdump", no_arg, 'x'}, + {"hexdum", no_arg, 'x'}, {"hexdu", no_arg, 'x'}, + {"hexd", no_arg, 'x'}, {"hex", no_arg, 'x'}, + {"width", require_arg, 'w'}, {"widt", require_arg, 'w'}, + {"wid", require_arg, 'w'}, {"wi", require_arg, 'w'}, + {"polling", require_arg, 'p'}, {"pollin", require_arg, 'p'}, + {"polli", require_arg, 'p'}, {"poll", require_arg, 'p'}, + {"pol", require_arg, 'p'}, {"po", require_arg, 'p'}, + {"fields", require_arg, 'f'}, {"field", require_arg, 'f'}, + {"fiel", require_arg, 'f'}, {"fie", require_arg, 'f'}, + {"fi", require_arg, 'f'}, {"version", no_arg, 'V'}, + {"versio", no_arg, 'V'}, {"versi", no_arg, 'V'}, + {"vers", no_arg, 'V'}, {"ver", no_arg, 'V'}, + {"ve", no_arg, 'V'}, {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: doprint() @@ -121,29 +97,29 @@ static struct long_options l_opts[] = { static herr_t doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) { - h5tools_context_t ctx; /* print context */ - h5tool_format_t info; /* Format info for the tools library */ - static char fmt_double[16], fmt_float[16]; /* Format info */ - struct subset_t subset; /* Subsetting info */ - hsize_t ss_start[H5S_MAX_RANK]; /* Info for hyperslab */ - hsize_t ss_stride[H5S_MAX_RANK]; /* Info for hyperslab */ - hsize_t ss_block[H5S_MAX_RANK]; /* Info for hyperslab */ - hsize_t ss_count[H5S_MAX_RANK]; /* Info for hyperslab */ - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t info; /* Format info for the tools library */ + static char fmt_double[16], fmt_float[16]; /* Format info */ + struct subset_t subset; /* Subsetting info */ + hsize_t ss_start[H5S_MAX_RANK]; /* Info for hyperslab */ + hsize_t ss_stride[H5S_MAX_RANK]; /* Info for hyperslab */ + hsize_t ss_block[H5S_MAX_RANK]; /* Info for hyperslab */ + hsize_t ss_count[H5S_MAX_RANK]; /* Info for hyperslab */ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ /* Subsetting information for the tools library printing routines */ - subset.start.data = ss_start; + subset.start.data = ss_start; subset.stride.data = ss_stride; - subset.block.data = ss_block; - subset.count.data = ss_count; + subset.block.data = ss_block; + subset.count.data = ss_count; /* Initialize subsetting information */ - for(i = 0; i < rank; i++) { + for (i = 0; i < rank; i++) { subset.stride.data[i] = 1; - subset.count.data[i] = 1; - subset.start.data[i] = start[i]; - subset.block.data[i] = block[i]; + subset.count.data[i] = 1; + subset.start.data[i] = start[i]; + subset.block.data[i] = block[i]; } /* end for */ HDmemset(&ctx, 0, sizeof(ctx)); @@ -152,13 +128,13 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) /* Set to all default values and then override */ HDmemset(&info, 0, sizeof info); - if(g_simple_output) { - info.idx_fmt = ""; - info.line_ncols = 65535; /*something big*/ - info.line_per_line = 1; + if (g_simple_output) { + info.idx_fmt = ""; + info.line_ncols = 65535; /*something big*/ + info.line_per_line = 1; info.line_multi_new = 0; - info.line_pre = " "; - info.line_cont = " "; + info.line_pre = " "; + info.line_cont = " "; info.arr_pre = ""; info.arr_suf = ""; @@ -169,18 +145,18 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) info.cmpd_sep = " "; /* The "fields" selected by the user */ - info.cmpd_listv = (const struct H5LD_memb_t * const *)g_listv; + info.cmpd_listv = (const struct H5LD_memb_t *const *)g_listv; - if(g_label) + if (g_label) info.cmpd_name = "%s="; - info.elmt_suf1 = " "; + info.elmt_suf1 = " "; info.str_locale = ESCAPE_HTML; - - } else { + } + else { info.idx_fmt = "(%s)"; - if(!g_display_width) { - info.line_ncols = 65535; + if (!g_display_width) { + info.line_ncols = 65535; info.line_per_line = 1; } /* end if */ else @@ -189,11 +165,11 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) info.line_multi_new = 1; /* The "fields" selected by the user */ - info.cmpd_listv = (const struct H5LD_memb_t * const *)g_listv; - if(g_label) + info.cmpd_listv = (const struct H5LD_memb_t *const *)g_listv; + if (g_label) info.cmpd_name = "%s="; - info.line_pre = " %s "; - info.line_cont = " %s "; + info.line_pre = " %s "; + info.line_cont = " %s "; info.str_repeat = 8; } /* end else */ @@ -203,25 +179,25 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) sprintf(fmt_double, "%%1.%dg", DBL_DIG); info.fmt_double = fmt_double; - info.dset_format = "DSET-%s "; + info.dset_format = "DSET-%s "; info.dset_hidefileno = 0; - info.obj_format = "-%lu:%" PRIuHADDR; + info.obj_format = "-%lu:%" PRIuHADDR; info.obj_hidefileno = 0; info.dset_blockformat_pre = "%sBlk%lu: "; - info.dset_ptformat_pre = "%sPt%lu: "; + info.dset_ptformat_pre = "%sPt%lu: "; info.line_indent = ""; - if(g_display_hex) { + if (g_display_hex) { /* Print all data in hexadecimal format if the `-x' or `--hexdump' * command line switch was given. */ info.raw = TRUE; } /* end if */ /* Print the values. */ - if((ret_value = h5tools_dump_dset(stdout, &info, &ctx, did)) < 0) + if ((ret_value = h5tools_dump_dset(stdout, &info, &ctx, did)) < 0) error_msg("unable to print data\n"); HDfprintf(stdout, "\n"); @@ -251,25 +227,26 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) *------------------------------------------------------------------------- */ static herr_t -slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsize_t *block, int rank, int subrank) +slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsize_t *block, int rank, + int subrank) { - int i; /* Local index variable */ - int ind; /* Index for the current rank */ + int i; /* Local index variable */ + int ind; /* Index for the current rank */ herr_t ret_value = SUCCEED; /* Return value */ ind = rank - subrank; - if((subrank - 1) > 0) { + if ((subrank - 1) > 0) { /* continue onto the next dimension */ - for (i = 0; i < (hssize_t)MIN(prev_dims[ind], cur_dims[ind]); i++){ + for (i = 0; i < (hssize_t)MIN(prev_dims[ind], cur_dims[ind]); i++) { start[ind] = (hsize_t)i; - if((ret_value = slicendump(did, prev_dims, cur_dims, start, block, rank, subrank-1)) < 0) + if ((ret_value = slicendump(did, prev_dims, cur_dims, start, block, rank, subrank - 1)) < 0) goto done; } /* end for */ - } /* end if */ + } /* end if */ /* this dimension remains the same or shrinking */ - if(cur_dims[ind] <= prev_dims[ind]) + if (cur_dims[ind] <= prev_dims[ind]) goto done; /* select first the slice for the faster changing dimension */ @@ -277,7 +254,7 @@ slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsi start[ind] = prev_dims[ind]; block[ind] = cur_dims[ind] - prev_dims[ind]; - for(i = ind + 1; i < rank; i++){ + for (i = ind + 1; i < rank; i++) { start[i] = 0; block[i] = cur_dims[i]; } /* end for */ @@ -289,7 +266,6 @@ done: return ret_value; } /* end slicendump() */ - /*------------------------------------------------------------------------- * Function: monitor_dataset * @@ -309,30 +285,30 @@ done: static herr_t monitor_dataset(hid_t fid, char *dsetname) { - hid_t did; /* dataset id */ - hid_t sid; /* dataspace id */ - int ndims; /* # of dimensions in the dataspace */ - int i, u; /* local index variable */ - hsize_t prev_dims[H5S_MAX_RANK]; /* current dataspace dimensions */ - hsize_t cur_dims[H5S_MAX_RANK]; /* previous dataspace dimensions */ - herr_t ret_value = SUCCEED; /* return value */ + hid_t did; /* dataset id */ + hid_t sid; /* dataspace id */ + int ndims; /* # of dimensions in the dataspace */ + int i, u; /* local index variable */ + hsize_t prev_dims[H5S_MAX_RANK]; /* current dataspace dimensions */ + hsize_t cur_dims[H5S_MAX_RANK]; /* previous dataspace dimensions */ + herr_t ret_value = SUCCEED; /* return value */ HDfprintf(stdout, "Monitoring dataset %s...\n", dsetname); /* Open the dataset for minitoring */ - if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { + if ((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { error_msg("error in opening dataset \"%s\"\n", dsetname); ret_value = FAIL; goto done; } - if((sid = H5Dget_space(did)) < 0) { + if ((sid = H5Dget_space(did)) < 0) { error_msg("error in getting dataspace id for dataset \"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Get the dataset's dimension sizes */ - if((ndims = H5Sget_simple_extent_dims(sid, prev_dims, NULL)) < 0) { + if ((ndims = H5Sget_simple_extent_dims(sid, prev_dims, NULL)) < 0) { error_msg("unable to get dimensions sizes for \"%s\"\n", dsetname); ret_value = FAIL; goto done; @@ -340,58 +316,60 @@ monitor_dataset(hid_t fid, char *dsetname) HDfflush(stdout); /* Loop until an error occurs or the user interrupts execution */ - while(!g_user_interrupt) { + while (!g_user_interrupt) { /* Refreshes the dataset */ - if(H5Drefresh(did) < 0) { + if (H5Drefresh(did) < 0) { ret_value = FAIL; goto done; } /* Get the dataset's current dimension sizes */ - if(H5LDget_dset_dims(did, cur_dims) < 0) { + if (H5LDget_dset_dims(did, cur_dims) < 0) { error_msg("unable to get dimension sizes for \"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Check the dimension sizes */ - for(i = 0; i < ndims; i++) - if(cur_dims[i] != prev_dims[i]) + for (i = 0; i < ndims; i++) + if (cur_dims[i] != prev_dims[i]) break; /* at least one dimension has changed */ - if(i != ndims) { + if (i != ndims) { /* Printing changes in dimension sizes */ - for(u = 0; u < ndims; u++) { - HDfprintf(stdout, "dimension %d: %" PRIuHSIZE "->%" PRIuHSIZE "", u, prev_dims[u], cur_dims[u]); - if(cur_dims[u] > prev_dims[u]) + for (u = 0; u < ndims; u++) { + HDfprintf(stdout, "dimension %d: %" PRIuHSIZE "->%" PRIuHSIZE "", u, prev_dims[u], + cur_dims[u]); + if (cur_dims[u] > prev_dims[u]) HDfprintf(stdout, " (increases)\n"); - else if(cur_dims[u] < prev_dims[u]) + else if (cur_dims[u] < prev_dims[u]) HDfprintf(stdout, " (decreases)\n"); else HDfprintf(stdout, " (unchanged)\n"); } /* Printing elements appended to the dataset if there is */ - if(!g_monitor_size_only) { + if (!g_monitor_size_only) { /* See if at least one dimension size has increased */ - for(u = 0; u < ndims; u++) { - int j; + for (u = 0; u < ndims; u++) { + int j; hsize_t start[H5S_MAX_RANK]; hsize_t block[H5S_MAX_RANK]; /* Print the new appended data to the dataset */ - if(cur_dims[u] > prev_dims[u]) { + if (cur_dims[u] > prev_dims[u]) { HDfprintf(stdout, " Data:\n"); - for(j = 0; j < ndims; j++) { + for (j = 0; j < ndims; j++) { start[j] = 0; block[j] = 1; } - if((ret_value = slicendump(did, prev_dims, cur_dims, start, block, ndims, ndims)) < 0) + if ((ret_value = slicendump(did, prev_dims, cur_dims, start, block, ndims, ndims)) < + 0) goto done; break; } @@ -412,10 +390,10 @@ monitor_dataset(hid_t fid, char *dsetname) done: /* Closing */ H5E_BEGIN_TRY - H5Dclose(did); + H5Dclose(did); H5E_END_TRY - return(ret_value); + return (ret_value); } /* monitor_dataset() */ /*------------------------------------------------------------------------- @@ -433,53 +411,53 @@ done: static herr_t process_cmpd_fields(hid_t fid, char *dsetname) { - hid_t did=-1; /* dataset id */ - hid_t dtid=-1, tid=-1; /* dataset's data type id */ + hid_t did = -1; /* dataset id */ + hid_t dtid = -1, tid = -1; /* dataset's data type id */ size_t len; /* number of comma-separated fields in "g_list_of_fields" */ herr_t ret_value = SUCCEED; /* Return value */ HDassert(g_list_of_fields && *g_list_of_fields); /* Open the dataset */ - if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { + if ((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { error_msg("error in opening dataset \"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Get the dataset's datatype */ - if(((dtid = H5Dget_type(did)) < 0) || (tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0) { + if (((dtid = H5Dget_type(did)) < 0) || (tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0) { error_msg("error in getting dataset's datatype\n"); ret_value = FAIL; goto done; } /* Check to make sure that the dataset's datatype is compound type */ - if(H5Tget_class(dtid) != H5T_COMPOUND) { + if (H5Tget_class(dtid) != H5T_COMPOUND) { error_msg("dataset should be compound type for <list_of_fields>\n"); ret_value = FAIL; goto done; } /* Make a copy of "g_list_of_fields" */ - if((g_dup_fields = HDstrdup(g_list_of_fields)) == NULL) { + if ((g_dup_fields = HDstrdup(g_list_of_fields)) == NULL) { error_msg("error in duplicating g_list_of_fields\n"); ret_value = FAIL; goto done; } /* Estimate the number of comma-separated fields in "g_list of_fields" */ - len = HDstrlen(g_list_of_fields)/2 + 2; + len = HDstrlen(g_list_of_fields) / 2 + 2; /* Allocate memory for a list vector of H5LD_memb_t structures to store "g_list_of_fields" info */ - if((g_listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))) == NULL) { + if ((g_listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))) == NULL) { error_msg("error in allocating memory for H5LD_memb_t\n"); ret_value = FAIL; goto done; } /* Process and store info for "g_listv" */ - if(H5LD_construct_vector(g_dup_fields, g_listv, tid) < 0) { + if (H5LD_construct_vector(g_dup_fields, g_listv, tid) < 0) { error_msg("error in processing <list_of_fields>\n"); ret_value = FAIL; goto done; @@ -489,14 +467,13 @@ process_cmpd_fields(hid_t fid, char *dsetname) done: /* Closing */ H5E_BEGIN_TRY - H5Tclose(dtid); - H5Tclose(tid); - H5Dclose(did); + H5Tclose(dtid); + H5Tclose(tid); + H5Dclose(did); H5E_END_TRY - return(ret_value); + return (ret_value); } /* process_cmpd_fields() */ - /*------------------------------------------------------------------------- * Function: check_dataset * @@ -513,44 +490,44 @@ done: static herr_t check_dataset(hid_t fid, char *dsetname) { - hid_t did=-1; /* Dataset id */ - hid_t dcp=-1; /* Dataset creation property */ - hid_t sid=-1; /* Dataset's dataspace id */ - int ndims; /* # of dimensions in the dataspace */ - unsigned u; /* Local index variable */ - hsize_t cur_dims[H5S_MAX_RANK]; /* size of dataspace dimensions */ - hsize_t max_dims[H5S_MAX_RANK]; /* maximum size of dataspace dimensions */ - hbool_t unlim_max_dims = FALSE; /* whether dataset has unlimited or max. dimension setting */ - void *edata; - H5E_auto2_t func; - H5D_layout_t layout; - herr_t ret_value = SUCCEED; /* Return value */ + hid_t did = -1; /* Dataset id */ + hid_t dcp = -1; /* Dataset creation property */ + hid_t sid = -1; /* Dataset's dataspace id */ + int ndims; /* # of dimensions in the dataspace */ + unsigned u; /* Local index variable */ + hsize_t cur_dims[H5S_MAX_RANK]; /* size of dataspace dimensions */ + hsize_t max_dims[H5S_MAX_RANK]; /* maximum size of dataspace dimensions */ + hbool_t unlim_max_dims = FALSE; /* whether dataset has unlimited or max. dimension setting */ + void * edata; + H5E_auto2_t func; + H5D_layout_t layout; + herr_t ret_value = SUCCEED; /* Return value */ /* Disable error reporting */ H5Eget_auto2(H5E_DEFAULT, &func, &edata); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* Open the dataset */ - if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { + if ((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { error_msg("unable to open dataset \"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Get dataset's creation property list */ - if((dcp = H5Dget_create_plist(did)) < 0) { + if ((dcp = H5Dget_create_plist(did)) < 0) { error_msg("unable to get dataset's creation property list \"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Query dataset's layout; the layout should be chunked or virtual */ - if((layout = H5Pget_layout(dcp)) < 0) { + if ((layout = H5Pget_layout(dcp)) < 0) { error_msg("unable to get dataset layout \"%s\"\n", dsetname); ret_value = FAIL; goto done; } - if(layout != H5D_CHUNKED && layout != H5D_VIRTUAL) { + if (layout != H5D_CHUNKED && layout != H5D_VIRTUAL) { error_msg("\"%s\" should be a chunked or virtual dataset\n", dsetname); ret_value = FAIL; goto done; @@ -560,27 +537,27 @@ check_dataset(hid_t fid, char *dsetname) HDmemset(max_dims, 0, sizeof max_dims); /* Get dataset's dataspace */ - if((sid = H5Dget_space(did)) < 0) { + if ((sid = H5Dget_space(did)) < 0) { error_msg("can't get dataset's dataspace\"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Get dimension size of dataset's dataspace */ - if((ndims = H5Sget_simple_extent_dims(sid, cur_dims, max_dims)) < 0) { + if ((ndims = H5Sget_simple_extent_dims(sid, cur_dims, max_dims)) < 0) { error_msg("can't get dataspace dimensions for dataset \"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Check whether dataset has unlimited dimension or max. dimension setting */ - for(u = 0; u < (unsigned)ndims; u++) - if(max_dims[u] == H5S_UNLIMITED || cur_dims[u] != max_dims[u]) { - unlim_max_dims = TRUE; - break; - } + for (u = 0; u < (unsigned)ndims; u++) + if (max_dims[u] == H5S_UNLIMITED || cur_dims[u] != max_dims[u]) { + unlim_max_dims = TRUE; + break; + } - if(!unlim_max_dims) { + if (!unlim_max_dims) { error_msg("\"%s\" should have unlimited or max. dimension setting\n", dsetname); ret_value = FAIL; } @@ -590,15 +567,14 @@ done: /* Closing */ H5E_BEGIN_TRY - H5Sclose(sid); - H5Pclose(dcp); - H5Dclose(did); + H5Sclose(sid); + H5Pclose(dcp); + H5Dclose(did); H5E_END_TRY - return(ret_value); + return (ret_value); } /* check_dataset() */ - /*------------------------------------------------------------------------- * Function: leave * @@ -619,7 +595,6 @@ leave(int ret) exit(ret); } - /*------------------------------------------------------------------------- * Function: usage * @@ -647,10 +622,12 @@ usage(const char *prog) HDfprintf(stdout, " A value of 0 sets the number of columns to the\n"); HDfprintf(stdout, " maximum (65535). The default width is 80 columns.\n"); HDfprintf(stdout, " --polling=N Set the polling interval to N (in seconds) when the\n"); - HDfprintf(stdout, " dataset will be checked for appended data. The default\n"); + HDfprintf(stdout, + " dataset will be checked for appended data. The default\n"); HDfprintf(stdout, " polling interval is 1.\n"); HDfprintf(stdout, " --fields=<list_of_fields>\n"); - HDfprintf(stdout, " Display data for the fields specified in <list_of_fields>\n"); + HDfprintf(stdout, + " Display data for the fields specified in <list_of_fields>\n"); HDfprintf(stdout, " for a compound data type. <list_of_fields> can be\n"); HDfprintf(stdout, " specified as follows:\n"); HDfprintf(stdout, " 1) A comma-separated list of field names in a\n"); @@ -660,7 +637,8 @@ usage(const char *prog) HDfprintf(stdout, " 2) A single field name in a compound data type.\n"); HDfprintf(stdout, " Can use this option multiple times.\n"); HDfprintf(stdout, " Note that backslash is the escape character to avoid\n"); - HDfprintf(stdout, " characters in field names that conflict with the tool's\n"); + HDfprintf(stdout, + " characters in field names that conflict with the tool's\n"); HDfprintf(stdout, " separators.\n"); HDfprintf(stdout, "\n"); HDfprintf(stdout, " OBJECT is specified as [<filename>/<path_to_dataset>/<dsetname>]\n"); @@ -669,11 +647,11 @@ usage(const char *prog) HDfprintf(stdout, " <path_to_dataset> Path separated by slashes to the specified dataset\n"); HDfprintf(stdout, " <dsetname> Name of the dataset\n"); HDfprintf(stdout, "\n"); - HDfprintf(stdout, " User can end the h5watch process by ctrl-C (SIGINT) or kill the process (SIGTERM).\n"); + HDfprintf(stdout, + " User can end the h5watch process by ctrl-C (SIGINT) or kill the process (SIGTERM).\n"); } /* usage() */ - /*------------------------------------------------------------------------- * Function: parse_command_line * @@ -689,10 +667,10 @@ usage(const char *prog) static void parse_command_line(int argc, const char *argv[]) { - int opt; /* Command line option */ + int opt; /* Command line option */ int tmp; - /* no arguments */ + /* no arguments */ if (argc == 1) { usage(h5tools_getprogname()); leave(EXIT_FAILURE); @@ -701,80 +679,77 @@ parse_command_line(int argc, const char *argv[]) /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { - case '?': - case 'h': /* --help */ - usage(h5tools_getprogname()); - leave(EXIT_SUCCESS); - break; - - case 'V': /* --version */ - print_version(progname); - leave(EXIT_SUCCESS); - break; - - case 'w': /* --width=N */ - g_display_width = (int)HDstrtol(opt_arg, NULL, 0); - if(g_display_width < 0) { + case '?': + case 'h': /* --help */ usage(h5tools_getprogname()); - leave(EXIT_FAILURE); - } - break; + leave(EXIT_SUCCESS); + break; - case 'd': /* --dim */ - g_monitor_size_only = TRUE; - break; + case 'V': /* --version */ + print_version(progname); + leave(EXIT_SUCCESS); + break; - case 'S': /* --simple */ - g_simple_output = TRUE; - break; + case 'w': /* --width=N */ + g_display_width = (int)HDstrtol(opt_arg, NULL, 0); + if (g_display_width < 0) { + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); + } + break; - case 'l': /* --label */ - g_label = TRUE; - break; + case 'd': /* --dim */ + g_monitor_size_only = TRUE; + break; - case 'p': /* --polling=N */ - /* g_polling_interval = HDstrtod(opt_arg, NULL); */ - if((tmp = (int)HDstrtol(opt_arg, NULL, 10)) <= 0) { - usage(h5tools_getprogname()); - leave(EXIT_FAILURE); - } - g_polling_interval = (unsigned)tmp; - break; + case 'S': /* --simple */ + g_simple_output = TRUE; + break; + + case 'l': /* --label */ + g_label = TRUE; + break; - case 'f': /* --fields=<list_of_fields> */ - if(g_list_of_fields == NULL) { - if((g_list_of_fields = HDstrdup(opt_arg)) == NULL) { - error_msg("memory allocation failed (file %s:line %d)\n", - __FILE__, __LINE__); + case 'p': /* --polling=N */ + /* g_polling_interval = HDstrtod(opt_arg, NULL); */ + if ((tmp = (int)HDstrtol(opt_arg, NULL, 10)) <= 0) { + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } - } else { - char *str; + g_polling_interval = (unsigned)tmp; + break; - if((str = HDstrdup(opt_arg)) == NULL) { - error_msg("memory allocation failed (file %s:line %d)\n", - __FILE__, __LINE__); - leave(EXIT_FAILURE); + case 'f': /* --fields=<list_of_fields> */ + if (g_list_of_fields == NULL) { + if ((g_list_of_fields = HDstrdup(opt_arg)) == NULL) { + error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); + leave(EXIT_FAILURE); + } } - if((g_list_of_fields = (char *)HDrealloc(g_list_of_fields, HDstrlen(g_list_of_fields) + HDstrlen(str) + 2)) == NULL) { - error_msg("memory allocation failed (file %s:line %d)\n", - __FILE__, __LINE__); - leave(EXIT_FAILURE); + else { + char *str; + if ((str = HDstrdup(opt_arg)) == NULL) { + error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); + leave(EXIT_FAILURE); + } + if ((g_list_of_fields = (char *)HDrealloc( + g_list_of_fields, HDstrlen(g_list_of_fields) + HDstrlen(str) + 2)) == NULL) { + error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); + leave(EXIT_FAILURE); + } + HDstrcat(g_list_of_fields, FIELD_SEP); + HDstrcat(g_list_of_fields, str); } - HDstrcat(g_list_of_fields, FIELD_SEP); - HDstrcat(g_list_of_fields, str); - } - break; + break; - default: - usage(h5tools_getprogname()); - leave(EXIT_FAILURE); + default: + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); } } - /* check for object to be processed */ if (argc <= opt_ind) { error_msg("missing dataset name\n"); @@ -783,7 +758,6 @@ parse_command_line(int argc, const char *argv[]) } } /* parse_command_line() */ - /*------------------------------------------------------------------------- * Function: catch_signal * @@ -796,13 +770,13 @@ parse_command_line(int argc, const char *argv[]) * *------------------------------------------------------------------------- */ -static void catch_signal(int H5_ATTR_UNUSED signo) +static void +catch_signal(int H5_ATTR_UNUSED signo) { /* Set the flag to get out of the main loop */ g_user_interrupt = TRUE; } /* catch_signal() */ - /*------------------------------------------------------------------------- * Function: main * @@ -818,12 +792,12 @@ static void catch_signal(int H5_ATTR_UNUSED signo) int main(int argc, const char *argv[]) { - char drivername[50]; /* VFD name */ - char *fname = NULL; /* File name */ - char *dname = NULL; /* Dataset name */ - char *x; /* Temporary string pointer */ - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ + char drivername[50]; /* VFD name */ + char *fname = NULL; /* File name */ + char *dname = NULL; /* Dataset name */ + char *x; /* Temporary string pointer */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ /* Set up tool name and exit status */ h5tools_setprogname(PROGRAMNAME); @@ -833,13 +807,13 @@ main(int argc, const char *argv[]) h5tools_init(); /* To exit from h5watch for SIGTERM signal */ - if(HDsignal(SIGTERM, catch_signal) == SIG_ERR) { + if (HDsignal(SIGTERM, catch_signal) == SIG_ERR) { error_msg("An error occurred while setting a signal handler.\n"); leave(EXIT_FAILURE); } /* To exit from h5watch for SIGINT signal */ - if(HDsignal(SIGINT, catch_signal) == SIG_ERR) { + if (HDsignal(SIGINT, catch_signal) == SIG_ERR) { error_msg("An error occurred while setting a signal handler.\n"); leave(EXIT_FAILURE); } @@ -847,7 +821,7 @@ main(int argc, const char *argv[]) /* parse command line options */ parse_command_line(argc, argv); - if(argc <= opt_ind) { + if (argc <= opt_ind) { error_msg("missing dataset name\n"); usage(h5tools_getprogname()); leave(EXIT_FAILURE); @@ -871,60 +845,61 @@ main(int argc, const char *argv[]) * then there must have been something wrong with the file (perhaps it * doesn't exist). */ - if((fname = HDstrdup(argv[opt_ind])) == NULL) { + if ((fname = HDstrdup(argv[opt_ind])) == NULL) { error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); goto done; } /* Create a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { h5tools_setstatus(EXIT_FAILURE); goto done; } /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { h5tools_setstatus(EXIT_FAILURE); goto done; } do { - while(fname && *fname) { - fid = h5tools_fopen(fname, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl, FALSE, drivername, sizeof drivername); + while (fname && *fname) { + fid = h5tools_fopen(fname, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl, FALSE, drivername, + sizeof drivername); - if(fid >= 0) { + if (fid >= 0) { HDfprintf(stdout, "Opened \"%s\" with %s driver.\n", fname, drivername); break; /*success*/ - } /* end if */ + } /* end if */ /* Shorten the file name; lengthen the object name */ - x = dname; + x = dname; dname = HDstrrchr(fname, '/'); - if(x) + if (x) *x = '/'; - if(!dname) + if (!dname) break; *dname = '\0'; } /* end while */ - /* Try opening the file again if somehow unstable */ - } while(g_retry-- > 0 && fid == FAIL); + /* Try opening the file again if somehow unstable */ + } while (g_retry-- > 0 && fid == FAIL); - if(fid < 0) { + if (fid < 0) { error_msg("unable to open file \"%s\"\n", fname); h5tools_setstatus(EXIT_FAILURE); goto done; } - if(!dname) { + if (!dname) { error_msg("no dataset specified\n"); h5tools_setstatus(EXIT_FAILURE); goto done; } else { *dname = '/'; - x = dname; - if((dname = HDstrdup(dname)) == NULL) { + x = dname; + if ((dname = HDstrdup(dname)) == NULL) { error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -932,13 +907,13 @@ main(int argc, const char *argv[]) else { *x = '\0'; /* Validate dataset */ - if(check_dataset(fid, dname) < 0) { + if (check_dataset(fid, dname) < 0) { h5tools_setstatus(EXIT_FAILURE); goto done; } /* Validate input "fields" */ - else if(g_list_of_fields && *g_list_of_fields) { - if(process_cmpd_fields(fid, dname) < 0) { + else if (g_list_of_fields && *g_list_of_fields) { + if (process_cmpd_fields(fid, dname) < 0) { h5tools_setstatus(EXIT_FAILURE); goto done; } @@ -947,33 +922,33 @@ main(int argc, const char *argv[]) } /* If everything is fine, start monitoring the datset */ - if(h5tools_getstatus() != EXIT_FAILURE) - if(monitor_dataset(fid, dname) < 0) + if (h5tools_getstatus() != EXIT_FAILURE) + if (monitor_dataset(fid, dname) < 0) h5tools_setstatus(EXIT_FAILURE); done: /* Free spaces */ - if(fname) + if (fname) HDfree(fname); - if(dname) + if (dname) HDfree(dname); - if(g_list_of_fields) + if (g_list_of_fields) HDfree(g_list_of_fields); - if(g_listv) { + if (g_listv) { H5LD_clean_vector(g_listv); HDfree(g_listv); } - if(g_dup_fields) + if (g_dup_fields) HDfree(g_dup_fields); /* Close the file access property list */ - if(fapl >= 0 && H5Pclose(fapl) < 0) { + if (fapl >= 0 && H5Pclose(fapl) < 0) { error_msg("unable to close file access property list\n"); h5tools_setstatus(EXIT_FAILURE); } /* Close the file */ - if(fid >= 0 && H5Fclose(fid) < 0) { + if (fid >= 0 && H5Fclose(fid) < 0) { error_msg("unable to close file\n"); h5tools_setstatus(EXIT_FAILURE); } @@ -981,4 +956,3 @@ done: /* exit */ leave(h5tools_getstatus()); } /* main() */ - diff --git a/hl/tools/h5watch/h5watchgentest.c b/hl/tools/h5watch/h5watchgentest.c index 19c9876..255ad41 100644 --- a/hl/tools/h5watch/h5watchgentest.c +++ b/hl/tools/h5watch/h5watchgentest.c @@ -33,26 +33,26 @@ * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR */ -#define ONE_DIMS0 10 -#define MAX_ONE_DIMS0 100 +#define ONE_DIMS0 10 +#define MAX_ONE_DIMS0 100 -#define DSET_ONE "DSET_ONE" -#define DSET_NONE "DSET_NONE" -#define DSET_NOMAX "DSET_NOMAX" -#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" +#define DSET_ONE "DSET_ONE" +#define DSET_NONE "DSET_NONE" +#define DSET_NOMAX "DSET_NOMAX" +#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" #define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" -#define DSET_CMPD "DSET_CMPD" -#define DSET_CMPD_ESC "DSET_CMPD_ESC" +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" -#define TWO_DIMS0 4 -#define TWO_DIMS1 10 -#define MAX_TWO_DIMS0 60 -#define MAX_TWO_DIMS1 100 +#define TWO_DIMS0 4 +#define TWO_DIMS1 10 +#define MAX_TWO_DIMS0 60 +#define MAX_TWO_DIMS1 100 -#define DSET_TWO "DSET_TWO" -#define DSET_CMPD_TWO "DSET_CMPD_TWO" +#define DSET_TWO "DSET_TWO" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" -#define CHUNK_SIZE 2 +#define CHUNK_SIZE 2 #define FILE "WATCH.h5" @@ -64,9 +64,9 @@ typedef struct sub22_t { } sub22_t; typedef struct sub2_t { - int a; + int a; sub22_t b; - int c; + int c; } sub2_t; typedef struct sub4_t { @@ -75,7 +75,7 @@ typedef struct sub4_t { } sub4_t; typedef struct set_t { - int field1; + int field1; sub2_t field2; double field3; sub4_t field4; @@ -90,58 +90,63 @@ typedef struct set_t { ************************************************************************************** */ static herr_t -generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, hsize_t *maxdims, hid_t dtid, void *data) +generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, hsize_t *maxdims, hid_t dtid, + void *data) { - hid_t dcpl=-1; /* Dataset creation property */ - hid_t did=-1; /* Dataset id */ - hid_t sid=-1; /* Dataspace id */ - int i; /* Local index variable */ - hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */ + hid_t dcpl = -1; /* Dataset creation property */ + hid_t did = -1; /* Dataset id */ + hid_t sid = -1; /* Dataspace id */ + int i; /* Local index variable */ + hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */ /* Create the dataspace */ - if((sid = H5Screate_simple(ndims, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(ndims, dims, maxdims)) < 0) goto done; /* Set up dataset's creation properties */ - if(!HDstrcmp(dname, DSET_NONE)) + if (!HDstrcmp(dname, DSET_NONE)) dcpl = H5P_DEFAULT; else { - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto done; - for(i = 0; i < ndims; i++) + for (i = 0; i < ndims; i++) chunk_dims[i] = CHUNK_SIZE; - if(H5Pset_chunk(dcpl, ndims, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, ndims, chunk_dims) < 0) goto done; } /* end else */ - if(!HDstrcmp(dname, DSET_ALLOC_LATE)) { - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) + if (!HDstrcmp(dname, DSET_ALLOC_LATE)) { + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) goto done; - } else if(!HDstrcmp(dname, DSET_ALLOC_EARLY)) { - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + } + else if (!HDstrcmp(dname, DSET_ALLOC_EARLY)) { + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) goto done; } /* end if-else */ /* Create the dataset */ - if((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto done; /* Write to the dataset */ - if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto done; /* Closing */ - if(H5Pclose(dcpl) < 0) goto done; - if(H5Sclose(sid) < 0) goto done; - if(H5Dclose(did) < 0) goto done; + if (H5Pclose(dcpl) < 0) + goto done; + if (H5Sclose(sid) < 0) + goto done; + if (H5Dclose(did) < 0) + goto done; return SUCCEED; done: H5E_BEGIN_TRY - H5Sclose(sid); - H5Pclose(dcpl); - H5Dclose(did); + H5Sclose(sid); + H5Pclose(dcpl); + H5Dclose(did); H5E_END_TRY return FAIL; @@ -150,49 +155,49 @@ done: int main(void) { - hid_t fid=-1; /* File id */ - hid_t fapl=-1; /* File access property list id */ - hsize_t cur_dims[1]; /* Dimension sizes */ - hsize_t max_dims[1]; /* Maximum dimension sizes */ - hsize_t cur2_dims[2]; /* Current dimension sizes */ - hsize_t max2_dims[2]; /* Maximum dimension sizes */ - hid_t set_tid=-1, esc_set_tid=-1; /* Compound type id */ - hid_t sub22_tid=-1; /* Compound type id */ - hid_t sub2_tid=-1, esc_sub2_tid=-1; /* Compound type id */ - hid_t sub4_tid=-1, esc_sub4_tid=-1; /* Compound type id */ - int one_data[ONE_DIMS0]; /* Buffer for data */ - int two_data[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data */ - set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */ - set_t two_cbuf[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data with compound type */ - int i; /* Local index variable */ + hid_t fid = -1; /* File id */ + hid_t fapl = -1; /* File access property list id */ + hsize_t cur_dims[1]; /* Dimension sizes */ + hsize_t max_dims[1]; /* Maximum dimension sizes */ + hsize_t cur2_dims[2]; /* Current dimension sizes */ + hsize_t max2_dims[2]; /* Maximum dimension sizes */ + hid_t set_tid = -1, esc_set_tid = -1; /* Compound type id */ + hid_t sub22_tid = -1; /* Compound type id */ + hid_t sub2_tid = -1, esc_sub2_tid = -1; /* Compound type id */ + hid_t sub4_tid = -1, esc_sub4_tid = -1; /* Compound type id */ + int one_data[ONE_DIMS0]; /* Buffer for data */ + int two_data[TWO_DIMS0 * TWO_DIMS1]; /* Buffer for data */ + set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */ + set_t two_cbuf[TWO_DIMS0 * TWO_DIMS1]; /* Buffer for data with compound type */ + int i; /* Local index variable */ /* Create a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) HDexit(EXIT_FAILURE); /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) HDexit(EXIT_FAILURE); /* Create a file with the latest format */ - if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) HDexit(EXIT_FAILURE); /* Initialization for one-dimensional dataset */ cur_dims[0] = ONE_DIMS0; max_dims[0] = MAX_ONE_DIMS0; - for(i = 0; i < ONE_DIMS0; i++) + for (i = 0; i < ONE_DIMS0; i++) one_data[i] = i; /* Generate DSET_ONE, DSET_NONE, DSET_NOMAX, DSET_ALLOC_LATE, DSET_EARLY */ - if(generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + if (generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) goto done; - if(generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + if (generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) goto done; - if(generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + if (generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) goto done; - if(generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + if (generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) goto done; - if(generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + if (generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) goto done; /* Initialization for two-dimensional dataset */ @@ -201,98 +206,98 @@ main(void) max2_dims[0] = MAX_TWO_DIMS0; max2_dims[1] = MAX_TWO_DIMS1; - for(i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) + for (i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) two_data[i] = i; /* Generate DSET_TWO */ - if(generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0) + if (generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0) goto done; /* Initialization for one-dimensional compound typed dataset */ cur_dims[0] = ONE_DIMS0; max_dims[0] = MAX_ONE_DIMS0; - for(i = 0; i < ONE_DIMS0; i++) { - one_cbuf[i].field1 = 1; - one_cbuf[i].field2.a = 2; - one_cbuf[i].field2.c = 4; + for (i = 0; i < ONE_DIMS0; i++) { + one_cbuf[i].field1 = 1; + one_cbuf[i].field2.a = 2; + one_cbuf[i].field2.c = 4; one_cbuf[i].field2.b.a = 20; one_cbuf[i].field2.b.b = 40; one_cbuf[i].field2.b.c = 80; - one_cbuf[i].field3 = 3.0F; - one_cbuf[i].field4.a = 4; - one_cbuf[i].field4.b = 8; + one_cbuf[i].field3 = 3.0F; + one_cbuf[i].field4.a = 4; + one_cbuf[i].field4.b = 8; } /* end for */ /* Create the compound type */ - if((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0) + if ((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0) goto done; - if(H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0) goto done; - if((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + if ((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) goto done; - if(H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0) + if (H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0) goto done; - if(H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) goto done; - if((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + if ((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) goto done; - if(H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) goto done; - if((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + if ((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) goto done; - if(H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + if (H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0) + if (H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0) goto done; - if(H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + if (H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) goto done; - if(H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0) + if (H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0) goto done; /* Create the compound type with escape/separator characters */ - if((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + if ((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) goto done; - if(H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + if (H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0) + if (H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0) goto done; - if(H5Tinsert(esc_sub2_tid, "\\K", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + if (H5Tinsert(esc_sub2_tid, "\\K", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) goto done; - if((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + if ((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) goto done; - if(H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + if (H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + if (H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) goto done; - if((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + if ((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) goto done; - if(H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + if (H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0) + if (H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0) goto done; - if(H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + if (H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) goto done; - if(H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0) + if (H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0) goto done; /* Generate DSET_CMPD, DSET_CMPD_ESC */ - if(generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0) + if (generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0) goto done; - if(generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0) + if (generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0) goto done; /* Initialization for two-dimensional compound typed dataset */ @@ -301,48 +306,56 @@ main(void) max2_dims[0] = MAX_TWO_DIMS0; max2_dims[0] = MAX_TWO_DIMS1; - for(i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) { - two_cbuf[i].field1 = 1; - two_cbuf[i].field2.a = 2; - two_cbuf[i].field2.c = 4; + for (i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) { + two_cbuf[i].field1 = 1; + two_cbuf[i].field2.a = 2; + two_cbuf[i].field2.c = 4; two_cbuf[i].field2.b.a = 20; two_cbuf[i].field2.b.b = 40; two_cbuf[i].field2.b.c = 80; - two_cbuf[i].field3 = 3.0F; - two_cbuf[i].field4.a = 4; - two_cbuf[i].field4.b = 8; + two_cbuf[i].field3 = 3.0F; + two_cbuf[i].field4.a = 4; + two_cbuf[i].field4.b = 8; } /* end for */ /* Generate DSET_CMPD_TWO */ - if(generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0) + if (generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0) goto done; /* Closing */ - if(H5Tclose(sub22_tid) < 0) goto done; - if(H5Tclose(sub2_tid) < 0) goto done; - if(H5Tclose(sub4_tid) < 0) goto done; - if(H5Tclose(set_tid) < 0) goto done; - if(H5Tclose(esc_sub2_tid) < 0) goto done; - if(H5Tclose(esc_sub4_tid) < 0) goto done; - if(H5Tclose(esc_set_tid) < 0) goto done; - if(H5Pclose(fapl) < 0) goto done; - if(H5Fclose(fid) < 0) goto done; + if (H5Tclose(sub22_tid) < 0) + goto done; + if (H5Tclose(sub2_tid) < 0) + goto done; + if (H5Tclose(sub4_tid) < 0) + goto done; + if (H5Tclose(set_tid) < 0) + goto done; + if (H5Tclose(esc_sub2_tid) < 0) + goto done; + if (H5Tclose(esc_sub4_tid) < 0) + goto done; + if (H5Tclose(esc_set_tid) < 0) + goto done; + if (H5Pclose(fapl) < 0) + goto done; + if (H5Fclose(fid) < 0) + goto done; HDexit(EXIT_SUCCESS); done: H5E_BEGIN_TRY - H5Tclose(sub22_tid); - H5Tclose(sub2_tid); - H5Tclose(sub4_tid); - H5Tclose(set_tid); - H5Tclose(esc_sub2_tid); - H5Tclose(esc_sub4_tid); - H5Tclose(esc_set_tid); - H5Pclose(fapl); - H5Fclose(fid); + H5Tclose(sub22_tid); + H5Tclose(sub2_tid); + H5Tclose(sub4_tid); + H5Tclose(set_tid); + H5Tclose(esc_sub2_tid); + H5Tclose(esc_sub4_tid); + H5Tclose(esc_set_tid); + H5Pclose(fapl); + H5Fclose(fid); H5E_END_TRY HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/hl/tools/h5watch/swmr_check_compat_vfd.c b/hl/tools/h5watch/swmr_check_compat_vfd.c index 608f4a8..fb1c903 100644 --- a/hl/tools/h5watch/swmr_check_compat_vfd.c +++ b/hl/tools/h5watch/swmr_check_compat_vfd.c @@ -22,11 +22,10 @@ #include "H5private.h" /* This file needs to access the file driver testing code */ -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ #define H5FD_TESTING -#include "H5FDpkg.h" /* File drivers */ +#include "H5FDpkg.h" /* File drivers */ - /*------------------------------------------------------------------------- * Function: main * @@ -48,10 +47,9 @@ main(void) driver = HDgetenv("HDF5_DRIVER"); - if(H5FD__supports_swmr_test(driver)) + if (H5FD__supports_swmr_test(driver)) return EXIT_SUCCESS; else return EXIT_FAILURE; } /* end main() */ - |