diff options
Diffstat (limited to 'tools/lib/h5tools.c')
-rw-r--r-- | tools/lib/h5tools.c | 128 |
1 files changed, 55 insertions, 73 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 8eaa805..7a184e6 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -430,8 +430,8 @@ h5tools_set_error_file(const char *fname, int is_bin) static hid_t h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) { - H5TOOLS_ERR_INIT(int, SUCCEED) - hid_t new_fapl = -1; /* Copy of file access property list passed in, or new property list */ + hid_t new_fapl = -1; /* Copy of file access property list passed in, or new property list */ + herr_t ret_value = SUCCEED; /* Make a copy of the FAPL, for the file open call to use, eventually */ if (fapl == H5P_DEFAULT) { @@ -479,7 +479,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_multi failed"); if(drivernum) - *drivernum = MULTI_IDX; + *drivernum = MULTI_IDX; } #ifdef H5_HAVE_PARALLEL else if(!HDstrcmp(driver, drivernames[MPIO_IDX])) { @@ -730,7 +730,6 @@ void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hsize_t elmtno, int secnum) { - H5TOOLS_ERR_INIT(int, SUCCEED) h5tools_str_t prefix; h5tools_str_t str; /*temporary for indentation */ size_t templength = 0; @@ -742,7 +741,6 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, if (!ctx->need_prefix) return; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); HDmemset(&prefix, 0, sizeof(h5tools_str_t)); @@ -812,7 +810,6 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_str_close(&str); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); } /*------------------------------------------------------------------------- @@ -928,7 +925,6 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter) { - H5TOOLS_ERR_INIT(hbool_t, TRUE) hbool_t dimension_break = TRUE; char *s = NULL; char *section = NULL; /* a section of output */ @@ -938,7 +934,6 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, if (stream == NULL) return dimension_break; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter need_prefix=%d", ctx->need_prefix); H5TOOLS_DEBUG("elmt_counter=%ld - local_elmt_counter=%ld", elmt_counter, local_elmt_counter); @@ -1067,7 +1062,6 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, ctx->prev_multiline = multiline; H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return dimension_break; } @@ -1102,14 +1096,12 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter) { - H5TOOLS_ERR_INIT(hbool_t, TRUE) hbool_t dimension_break = TRUE; char *s = NULL; char *section = NULL; /* a section of output */ int secnum; /* section sequence number */ int multiline; /* datum was multiline */ - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); H5TOOLS_DEBUG("elmt_counter=%ld - local_elmt_counter=%ld", elmt_counter, local_elmt_counter); @@ -1221,7 +1213,6 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, ctx->prev_multiline = multiline; H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return dimension_break; } @@ -1237,11 +1228,9 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) { - H5TOOLS_ERR_INIT(int, SUCCEED) int i; unsigned j; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); if(ctx->ndims > 0) { @@ -1255,7 +1244,6 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) } H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); } /*------------------------------------------------------------------------- @@ -1270,19 +1258,19 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts) { - H5TOOLS_ERR_INIT(int, SUCCEED) - unsigned char *mem = (unsigned char*)_mem; - size_t size; /* datum size */ - hsize_t block_index; - H5T_class_t type_class; + unsigned char *mem = (unsigned char*)_mem; + size_t size; /* datum size */ + hsize_t block_index; + H5T_class_t type_class; + hbool_t past_catch = FALSE; + int ret_value = 0; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); if((size = H5Tget_size(tid)) == 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + H5TOOLS_THROW((-1), "H5Tget_size failed"); if((type_class = H5Tget_class(tid)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed"); + H5TOOLS_THROW((-1), "H5Tget_class failed"); switch (type_class) { case H5T_INTEGER: @@ -1303,7 +1291,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t bytes_wrote = HDfwrite(mem, 1, bytes_in, stream); if(bytes_wrote != bytes_in || (0 == bytes_wrote && HDferror(stream))) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); + H5TOOLS_THROW((-1), "fwrite failed"); block_index -= (hsize_t)bytes_wrote; mem = mem + bytes_wrote; @@ -1327,7 +1315,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t if (s != NULL) size = HDstrlen(s); else - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "NULL string"); + H5TOOLS_THROW((-1), "NULL string"); } else { s = (char *) mem; @@ -1335,7 +1323,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char)); if (1 != HDfwrite(&tempuchar, sizeof(unsigned char), 1, stream)) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); + H5TOOLS_THROW((-1), "fwrite failed"); } /* i */ } /* for (block_index = 0; block_index < block_nelmts; block_index++) */ } @@ -1347,7 +1335,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t H5TOOLS_DEBUG("H5T_COMPOUND"); if((snmembs = H5Tget_nmembers(tid)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers of compound failed"); + H5TOOLS_THROW((-1), "H5Tget_nmembers of compound failed"); nmembs = (unsigned)snmembs; for (block_index = 0; block_index < block_nelmts; block_index++) { @@ -1363,7 +1351,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t if (render_bin_output(stream, container, memb, mem + offset, 1) < 0) { H5Tclose(memb); - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output of compound member failed"); + H5TOOLS_THROW((-1), "render_bin_output of compound member failed"); } H5Tclose(memb); @@ -1392,7 +1380,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t } else { H5Tclose(memb); - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "calculate the number of array elements failed"); + H5TOOLS_THROW((-1), "calculate the number of array elements failed"); } for (block_index = 0; block_index < block_nelmts; block_index++) { @@ -1400,7 +1388,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t /* dump the array element */ if (render_bin_output(stream, container, memb, mem, nelmts) < 0) { H5Tclose(memb); - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed"); + H5TOOLS_THROW((-1), "render_bin_output failed"); } } H5Tclose(memb); @@ -1423,7 +1411,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t /* dump the array element */ if (render_bin_output(stream, container, memb, ((char *) (((hvl_t *)((void *)mem))->p)), nelmts) < 0) { H5Tclose(memb); - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed"); + H5TOOLS_THROW((-1), "render_bin_output failed"); } } H5Tclose(memb); @@ -1443,7 +1431,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t for (block_index = 0; block_index < block_nelmts; block_index++) { mem = ((unsigned char*)_mem) + block_index * size; if((region_id = H5Ropen_object((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Ropen_object H5T_STD_REF failed"); + H5TOOLS_INFO("H5Ropen_object H5T_STD_REF failed"); else { if((region_space = H5Ropen_region((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { if (!h5tools_is_zero(mem, H5Tget_size(H5T_STD_REF))) { @@ -1454,7 +1442,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t render_bin_output_region_blocks(region_space, region_id, stream, container); } else { - H5TOOLS_GOTO_ERROR(FAIL, "H5Ropen_object H5T_STD_REF NULL"); + H5TOOLS_INFO("H5Ropen_object H5T_STD_REF NULL"); } H5Sclose(region_space); } /* end if (region_space >= 0) */ @@ -1480,7 +1468,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t for (block_index = 0; block_index < block_nelmts; block_index++) { mem = ((unsigned char*)_mem) + block_index * size; if (size != HDfwrite(mem, sizeof(char), size, stream)) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); + H5TOOLS_THROW((-1), "fwrite failed"); } /* end for */ break; @@ -1488,7 +1476,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t case H5T_NCLASSES: default: /* Badness */ - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "bad type class"); + H5TOOLS_THROW((-1), "bad type class"); break; } /* end switch */ @@ -1496,7 +1484,6 @@ done: CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1515,7 +1502,6 @@ int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, hid_t container, unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata) { - H5TOOLS_ERR_INIT(int, SUCCEED) hsize_t *dims1 = NULL; hsize_t *start = NULL; hsize_t *count = NULL; @@ -1525,17 +1511,18 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, size_t type_size; hid_t mem_space = -1; void *region_buf = NULL; + hbool_t past_catch = FALSE; hsize_t blkndx; hid_t sid1 = -1; + int ret_value = -1; - H5TOOLS_PUSH_STACK(); /* Get the dataspace of the dataset */ if((sid1 = H5Dget_space(region_id)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); + H5TOOLS_THROW((-1), "H5Dget_space failed"); /* Allocate space for the dimension array */ if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims"); + H5TOOLS_THROW((-1), "Could not allocate buffer for dims"); /* find the dimensions of each data space from the block coordinates */ numelem = 1; @@ -1546,21 +1533,21 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, /* Create dataspace for reading buffer */ if((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed"); + H5TOOLS_THROW((-1), "H5Screate_simple failed"); if((type_size = H5Tget_size(type_id)) == 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + H5TOOLS_THROW((-1), "H5Tget_size failed"); if((region_buf = HDmalloc(type_size * (size_t)numelem)) == NULL) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate region buffer"); + H5TOOLS_THROW((-1), "Could not allocate region buffer"); /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ /* 1 2 n 1 2 n */ if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start"); + H5TOOLS_THROW((-1), "Could not allocate buffer for start"); if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count"); + H5TOOLS_THROW((-1), "Could not allocate buffer for count"); for (blkndx = 0; blkndx < nblocks; blkndx++) { for (jndx = 0; jndx < ndims; jndx++) { @@ -1569,16 +1556,16 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, } if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sselect_hyperslab failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed"); if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); if(render_bin_output(stream, container, type_id, (char*)region_buf, numelem) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "render_bin_output of data region failed"); + H5TOOLS_GOTO_ERROR((-1), "render_bin_output of data region failed"); /* Render the region data element end */ done: ; @@ -1591,12 +1578,11 @@ CATCH HDfree(dims1); if(H5Sclose(mem_space) < 0) - H5TOOLS_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_ERROR((-1), "H5Sclose failed"); if(H5Sclose(sid1) < 0) - H5TOOLS_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_ERROR((-1), "H5Sclose failed"); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1614,7 +1600,6 @@ hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id, FILE *stream, hid_t container) { - H5TOOLS_ERR_INIT(hbool_t, TRUE) hssize_t snblocks; hsize_t nblocks; hsize_t alloc_size; @@ -1623,15 +1608,16 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id, unsigned ndims; hid_t dtype = -1; hid_t type_id = -1; + hbool_t past_catch = FALSE; + hbool_t ret_value = TRUE; - H5TOOLS_PUSH_STACK(); if((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) - H5TOOLS_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed"); + H5TOOLS_THROW(FALSE, "H5Sget_select_hyper_nblocks failed"); nblocks = (hsize_t)snblocks; /* Print block information */ if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) - H5TOOLS_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + H5TOOLS_THROW(FALSE, "H5Sget_simple_extent_ndims failed"); ndims = (unsigned)sndims; alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); @@ -1661,7 +1647,6 @@ done: CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1687,44 +1672,42 @@ render_bin_output_region_data_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container, unsigned ndims, hid_t type_id, hsize_t npoints) { - H5TOOLS_ERR_INIT(int, SUCCEED) hsize_t *dims1 = NULL; size_t type_size; hid_t mem_space = -1; void *region_buf = NULL; + int ret_value = 0; - H5TOOLS_PUSH_STACK(); if((type_size = H5Tget_size(type_id)) == 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_size failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); if((region_buf = HDmalloc(type_size * (size_t)npoints)) == NULL) - H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for region"); + H5TOOLS_GOTO_ERROR((-1), "Could not allocate buffer for region"); /* Allocate space for the dimension array */ if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) - H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for dims"); + H5TOOLS_GOTO_ERROR((-1), "Could not allocate buffer for dims"); dims1[0] = npoints; if((mem_space = H5Screate_simple(1, dims1, NULL)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Screate_simple failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Screate_simple failed"); if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); if(render_bin_output(stream, container, type_id, (char*)region_buf, npoints) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "render_bin_output of data points failed"); + H5TOOLS_GOTO_ERROR((-1), "render_bin_output of data points failed"); done: HDfree(region_buf); HDfree(dims1); if(H5Sclose(mem_space) < 0) - H5TOOLS_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_ERROR((-1), "H5Sclose failed"); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1742,22 +1725,22 @@ hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container) { - H5TOOLS_ERR_INIT(hbool_t, TRUE) hssize_t snpoints; hsize_t npoints; int sndims; unsigned ndims; hid_t dtype = -1; hid_t type_id = -1; + hbool_t past_catch = FALSE; + hbool_t ret_value = TRUE; - H5TOOLS_PUSH_STACK(); if((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0) - H5TOOLS_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed"); + H5TOOLS_THROW(FALSE, "H5Sget_select_elem_npoints failed"); npoints = (hsize_t)snpoints; /* Allocate space for the dimension array */ if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) - H5TOOLS_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + H5TOOLS_THROW(FALSE, "H5Sget_simple_extent_ndims failed"); ndims = (unsigned)sndims; if((dtype = H5Dget_type(region_id)) < 0) @@ -1778,7 +1761,6 @@ done: H5_LEAVE(ret_value) CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } |