2003-04-01 02:10:51 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2003-04-01 02:10:51 +08:00
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
2007-02-07 22:56:24 +08:00
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2003-04-01 02:10:51 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*
|
|
|
|
* Programmer: Robb Matzke <matzke@llnl.gov>
|
|
|
|
* Thursday, July 23, 1998
|
|
|
|
*
|
2006-07-27 23:01:48 +08:00
|
|
|
* Purpose: A library for displaying the values of a dataset in a human
|
|
|
|
* readable format.
|
2001-02-23 05:55:15 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "h5tools.h"
|
2005-08-26 04:16:40 +08:00
|
|
|
#include "h5tools_ref.h"
|
2001-03-09 04:21:05 +08:00
|
|
|
#include "h5tools_utils.h"
|
2001-02-23 05:55:15 +08:00
|
|
|
#include "H5private.h"
|
|
|
|
|
2008-01-11 05:31:28 +08:00
|
|
|
#define SANITY_CHECK
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2006-07-27 23:01:48 +08:00
|
|
|
#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z))
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
/* global variables */
|
2009-09-15 03:52:42 +08:00
|
|
|
hid_t H5tools_ERR_CLS_g = -1;
|
|
|
|
hid_t H5E_tools_g = -1;
|
|
|
|
hid_t H5E_tools_min_id_g = -1;
|
2001-03-09 04:21:05 +08:00
|
|
|
int compound_data;
|
2006-07-27 23:01:48 +08:00
|
|
|
FILE *rawdatastream; /* should initialize to stdout but gcc moans about it */
|
2006-06-26 22:41:59 +08:00
|
|
|
int bin_output; /* binary output */
|
2006-06-29 03:34:08 +08:00
|
|
|
int bin_form; /* binary form */
|
2009-09-04 22:50:13 +08:00
|
|
|
int region_output; /* region output */
|
2011-04-30 02:38:41 +08:00
|
|
|
int packed_bits_num; /* number of packed bits to display */
|
|
|
|
int packed_data_offset; /* offset of packed bits to display */
|
|
|
|
unsigned long long packed_data_mask; /* mask in which packed bits to display */
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2010-01-30 12:29:13 +08:00
|
|
|
static h5tool_format_t h5tools_dataformat = {
|
2009-09-04 22:50:13 +08:00
|
|
|
0, /*raw */
|
|
|
|
|
|
|
|
"", /*fmt_raw */
|
|
|
|
"%d", /*fmt_int */
|
|
|
|
"%u", /*fmt_uint */
|
2011-01-06 04:18:16 +08:00
|
|
|
"%hhd", /*fmt_schar */
|
2009-09-04 22:50:13 +08:00
|
|
|
"%u", /*fmt_uchar */
|
|
|
|
"%d", /*fmt_short */
|
|
|
|
"%u", /*fmt_ushort */
|
|
|
|
"%ld", /*fmt_long */
|
|
|
|
"%lu", /*fmt_ulong */
|
|
|
|
NULL, /*fmt_llong */
|
|
|
|
NULL, /*fmt_ullong */
|
|
|
|
"%g", /*fmt_double */
|
|
|
|
"%g", /*fmt_float */
|
|
|
|
|
|
|
|
0, /*ascii */
|
|
|
|
0, /*str_locale */
|
|
|
|
0, /*str_repeat */
|
|
|
|
|
|
|
|
"[ ", /*arr_pre */
|
|
|
|
",", /*arr_sep */
|
|
|
|
" ]", /*arr_suf */
|
|
|
|
1, /*arr_linebreak */
|
|
|
|
|
|
|
|
"", /*cmpd_name */
|
|
|
|
",\n", /*cmpd_sep */
|
|
|
|
"{\n", /*cmpd_pre */
|
|
|
|
"}", /*cmpd_suf */
|
|
|
|
"\n", /*cmpd_end */
|
|
|
|
|
|
|
|
", ", /*vlen_sep */
|
|
|
|
"(", /*vlen_pre */
|
|
|
|
")", /*vlen_suf */
|
|
|
|
"", /*vlen_end */
|
|
|
|
|
|
|
|
"%s", /*elmt_fmt */
|
|
|
|
",", /*elmt_suf1 */
|
|
|
|
" ", /*elmt_suf2 */
|
|
|
|
|
|
|
|
"", /*idx_n_fmt */
|
|
|
|
"", /*idx_sep */
|
|
|
|
"", /*idx_fmt */
|
|
|
|
|
|
|
|
80, /*line_ncols *//*standard default columns */
|
|
|
|
0, /*line_per_line */
|
|
|
|
"", /*line_pre */
|
|
|
|
"%s", /*line_1st */
|
|
|
|
"%s", /*line_cont */
|
|
|
|
"", /*line_suf */
|
|
|
|
"", /*line_sep */
|
|
|
|
1, /*line_multi_new */
|
|
|
|
" ", /*line_indent */
|
|
|
|
|
|
|
|
1, /*skip_first */
|
|
|
|
|
|
|
|
1, /*obj_hidefileno */
|
|
|
|
" "H5_PRINTF_HADDR_FMT, /*obj_format */
|
|
|
|
|
|
|
|
1, /*dset_hidefileno */
|
|
|
|
"DATASET %s ", /*dset_format */
|
|
|
|
"%s", /*dset_blockformat_pre */
|
|
|
|
"%s", /*dset_ptformat_pre */
|
|
|
|
"%s", /*dset_ptformat */
|
|
|
|
1, /*array indices */
|
|
|
|
1 /*escape non printable characters */
|
|
|
|
};
|
|
|
|
|
2010-01-30 12:29:13 +08:00
|
|
|
static const h5tools_dump_header_t h5tools_standardformat = {
|
2009-09-04 22:50:13 +08:00
|
|
|
"standardformat", /*name */
|
|
|
|
"HDF5", /*fileebgin */
|
|
|
|
"", /*fileend */
|
|
|
|
SUPER_BLOCK, /*bootblockbegin */
|
|
|
|
"", /*bootblockend */
|
|
|
|
H5_TOOLS_GROUP, /*groupbegin */
|
|
|
|
"", /*groupend */
|
|
|
|
H5_TOOLS_DATASET, /*datasetbegin */
|
|
|
|
"", /*datasetend */
|
|
|
|
ATTRIBUTE, /*attributebegin */
|
|
|
|
"", /*attributeend */
|
|
|
|
H5_TOOLS_DATATYPE, /*datatypebegin */
|
|
|
|
"", /*datatypeend */
|
|
|
|
DATASPACE, /*dataspacebegin */
|
|
|
|
"", /*dataspaceend */
|
|
|
|
DATA, /*databegin */
|
|
|
|
"", /*dataend */
|
|
|
|
SOFTLINK, /*softlinkbegin */
|
|
|
|
"", /*softlinkend */
|
|
|
|
EXTLINK, /*extlinkbegin */
|
|
|
|
"", /*extlinkend */
|
|
|
|
UDLINK, /*udlinkbegin */
|
|
|
|
"", /*udlinkend */
|
|
|
|
SUBSET, /*subsettingbegin */
|
|
|
|
"", /*subsettingend */
|
|
|
|
START, /*startbegin */
|
|
|
|
"", /*startend */
|
|
|
|
STRIDE, /*stridebegin */
|
|
|
|
"", /*strideend */
|
|
|
|
COUNT, /*countbegin */
|
|
|
|
"", /*countend */
|
|
|
|
BLOCK, /*blockbegin */
|
|
|
|
"", /*blockend */
|
|
|
|
|
|
|
|
"{", /*fileblockbegin */
|
|
|
|
"}", /*fileblockend */
|
|
|
|
"{", /*bootblockblockbegin */
|
|
|
|
"}", /*bootblockblockend */
|
|
|
|
"{", /*groupblockbegin */
|
|
|
|
"}", /*groupblockend */
|
|
|
|
"{", /*datasetblockbegin */
|
|
|
|
"}", /*datasetblockend */
|
|
|
|
"{", /*attributeblockbegin */
|
|
|
|
"}", /*attributeblockend */
|
|
|
|
"", /*datatypeblockbegin */
|
|
|
|
"", /*datatypeblockend */
|
|
|
|
"", /*dataspaceblockbegin */
|
|
|
|
"", /*dataspaceblockend */
|
|
|
|
"{", /*datablockbegin */
|
|
|
|
"}", /*datablockend */
|
|
|
|
"{", /*softlinkblockbegin */
|
|
|
|
"}", /*softlinkblockend */
|
|
|
|
"{", /*extlinkblockbegin */
|
|
|
|
"}", /*extlinkblockend */
|
|
|
|
"{", /*udlinkblockbegin */
|
|
|
|
"}", /*udlinkblockend */
|
|
|
|
"{", /*strblockbegin */
|
|
|
|
"}", /*strblockend */
|
|
|
|
"{", /*enumblockbegin */
|
|
|
|
"}", /*enumblockend */
|
|
|
|
"{", /*structblockbegin */
|
|
|
|
"}", /*structblockend */
|
|
|
|
"{", /*vlenblockbegin */
|
|
|
|
"}", /*vlenblockend */
|
|
|
|
"{", /*subsettingblockbegin */
|
|
|
|
"}", /*subsettingblockend */
|
|
|
|
"(", /*startblockbegin */
|
|
|
|
");", /*startblockend */
|
|
|
|
"(", /*strideblockbegin */
|
|
|
|
");", /*strideblockend */
|
|
|
|
"(", /*countblockbegin */
|
|
|
|
");", /*countblockend */
|
|
|
|
"(", /*blockblockbegin */
|
|
|
|
");", /*blockblockend */
|
|
|
|
|
|
|
|
"", /*dataspacedescriptionbegin */
|
|
|
|
"", /*dataspacedescriptionend */
|
|
|
|
"(", /*dataspacedimbegin */
|
|
|
|
")", /*dataspacedimend */
|
|
|
|
};
|
2006-06-29 03:34:08 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
static const h5tools_dump_header_t * h5tools_dump_header_format;
|
2006-06-26 22:41:59 +08:00
|
|
|
|
|
|
|
/* local prototypes */
|
2010-08-10 02:15:37 +08:00
|
|
|
static int do_bin_output(FILE *stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem);
|
|
|
|
static int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem);
|
2010-08-13 05:11:00 +08:00
|
|
|
static int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
|
|
|
|
hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata);
|
2010-08-10 02:15:37 +08:00
|
|
|
static hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
|
2010-08-13 05:11:00 +08:00
|
|
|
FILE *stream, hid_t container);
|
2010-08-10 02:15:37 +08:00
|
|
|
static hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id,
|
2010-08-13 05:11:00 +08:00
|
|
|
FILE *stream, hid_t container);
|
2009-09-04 22:50:13 +08:00
|
|
|
static hbool_t h5tools_is_zero(const void *_mem, size_t size);
|
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
hbool_t h5tools_render_element(FILE *stream, const h5tool_format_t *info,
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_context_t *ctx/*in,out*/,
|
|
|
|
h5tools_str_t *buffer/*string into which to render */,
|
|
|
|
hsize_t *curr_pos/*total data element position*/,
|
|
|
|
size_t ncols, hsize_t local_elmt_counter/*element counter*/,
|
|
|
|
hsize_t elmt_counter);
|
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
hbool_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_context_t *ctx/*in,out*/,
|
|
|
|
h5tools_str_t *buffer/*string into which to render */,
|
|
|
|
hsize_t *curr_pos/*total data element position*/,
|
|
|
|
size_t ncols, hsize_t *ptdata,
|
|
|
|
hsize_t local_elmt_counter/*element counter*/,
|
|
|
|
hsize_t elmt_counter);
|
|
|
|
|
2010-08-13 05:11:00 +08:00
|
|
|
static int h5tools_print_region_data_blocks(hid_t region_id,
|
2011-05-12 04:45:54 +08:00
|
|
|
FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
|
2010-01-30 12:29:13 +08:00
|
|
|
h5tools_str_t *buffer/*string into which to render */, size_t ncols,
|
2009-09-15 03:52:42 +08:00
|
|
|
int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata);
|
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
|
2009-09-04 22:50:13 +08:00
|
|
|
FILE *stream, const h5tool_format_t *info,
|
|
|
|
h5tools_context_t *ctx/*in,out*/,
|
|
|
|
h5tools_str_t *buffer/*string into which to render */,
|
|
|
|
hsize_t *curr_pos/*total data element position*/,
|
|
|
|
size_t ncols, hsize_t region_elmt_counter/*element counter*/,
|
|
|
|
hsize_t elmt_counter);
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
int h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
|
2011-05-12 04:45:54 +08:00
|
|
|
FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
|
2010-01-30 12:29:13 +08:00
|
|
|
h5tools_str_t *buffer, size_t ncols,
|
2009-09-15 03:52:42 +08:00
|
|
|
int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata);
|
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
hbool_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
|
2009-09-04 22:50:13 +08:00
|
|
|
FILE *stream, const h5tool_format_t *info,
|
|
|
|
h5tools_context_t *ctx/*in,out*/,
|
|
|
|
h5tools_str_t *buffer/*string into which to render */,
|
|
|
|
hsize_t *curr_pos/*total data element position*/,
|
|
|
|
size_t ncols, hsize_t region_elmt_counter/*element counter*/,
|
|
|
|
hsize_t elmt_counter);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
|
|
|
/* module-scoped variables */
|
2001-03-09 04:21:05 +08:00
|
|
|
static int h5tools_init_g; /* if h5tools lib has been initialized */
|
2004-04-18 12:10:09 +08:00
|
|
|
#ifdef H5_HAVE_PARALLEL
|
2004-02-05 06:43:00 +08:00
|
|
|
static int h5tools_mpi_init_g; /* if MPI_Init() has been called */
|
2004-04-18 12:10:09 +08:00
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
2004-02-05 06:43:00 +08:00
|
|
|
|
|
|
|
/* Names of VFDs */
|
|
|
|
static const char *drivernames[]={
|
|
|
|
"sec2",
|
|
|
|
"family",
|
|
|
|
"split",
|
|
|
|
"multi",
|
|
|
|
#ifdef H5_HAVE_STREAM
|
|
|
|
"stream",
|
2006-07-27 23:01:48 +08:00
|
|
|
#endif /* H5_HAVE_STREAM */
|
2004-02-05 06:43:00 +08:00
|
|
|
#ifdef H5_HAVE_PARALLEL
|
|
|
|
"mpio",
|
|
|
|
"mpiposix"
|
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This enum should match the entries in the above drivers_list since they
|
|
|
|
* are indexes into the drivers_list array. */
|
|
|
|
enum {
|
|
|
|
SEC2_IDX = 0
|
|
|
|
,FAMILY_IDX
|
|
|
|
,SPLIT_IDX
|
|
|
|
,MULTI_IDX
|
|
|
|
#ifdef H5_HAVE_STREAM
|
|
|
|
,STREAM_IDX
|
2006-07-27 23:01:48 +08:00
|
|
|
#endif /* H5_HAVE_STREAM */
|
2004-02-05 06:43:00 +08:00
|
|
|
#ifdef H5_HAVE_PARALLEL
|
|
|
|
,MPIO_IDX
|
|
|
|
,MPIPOSIX_IDX
|
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
|
|
|
} driver_idx;
|
|
|
|
#define NUM_DRIVERS (sizeof(drivernames) / sizeof(drivernames[0]))
|
2001-02-23 05:55:15 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Initialize the H5 Tools library
|
|
|
|
* Description:
|
|
|
|
* This should be called before any other h5tools function is called.
|
|
|
|
* Effect of any h5tools function called before this has been called is
|
|
|
|
* undetermined.
|
|
|
|
* Return:
|
|
|
|
* None
|
|
|
|
* Programmer:
|
|
|
|
* Albert Cheng, 2000-10-31
|
2001-02-23 05:55:15 +08:00
|
|
|
* Modifications:
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
h5tools_init(void)
|
|
|
|
{
|
2009-09-15 03:52:42 +08:00
|
|
|
char lib_str[256];
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
if (!h5tools_init_g) {
|
2009-09-15 03:52:42 +08:00
|
|
|
/* register the error class */
|
2011-05-05 04:28:09 +08:00
|
|
|
HDsnprintf(lib_str, sizeof(lib_str), "%d.%d.%d",H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE);
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
H5TOOLS_INIT_ERROR()
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (!rawdatastream)
|
|
|
|
rawdatastream = stdout;
|
|
|
|
|
|
|
|
h5tools_dump_header_format = &h5tools_standardformat;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_init_g++;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
2006-07-27 23:01:48 +08:00
|
|
|
* Purpose: Close the H5 Tools library
|
2001-04-11 03:54:08 +08:00
|
|
|
* Description:
|
|
|
|
* Close or release resources such as files opened by the library. This
|
|
|
|
* should be called after all other h5tools functions have been called.
|
|
|
|
* Effect of any h5tools function called after this has been called is
|
|
|
|
* undetermined.
|
|
|
|
* Return:
|
|
|
|
* None
|
|
|
|
* Programmer:
|
|
|
|
* Albert Cheng, 2000-10-31
|
2001-02-23 05:55:15 +08:00
|
|
|
* Modifications:
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
h5tools_close(void)
|
|
|
|
{
|
|
|
|
if (h5tools_init_g) {
|
2007-09-13 23:44:56 +08:00
|
|
|
if (rawdatastream && rawdatastream != stdout) {
|
|
|
|
if (fclose(rawdatastream))
|
2009-09-04 22:50:13 +08:00
|
|
|
perror("closing rawdatastream");
|
2007-09-13 23:44:56 +08:00
|
|
|
else
|
2009-09-04 22:50:13 +08:00
|
|
|
rawdatastream = NULL;
|
2007-09-13 23:44:56 +08:00
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2005-08-26 04:16:40 +08:00
|
|
|
/* Clean up the reference path table, if it's been used */
|
|
|
|
term_ref_path_table();
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
H5TOOLS_CLOSE_ERROR()
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2004-02-05 06:43:00 +08:00
|
|
|
/* Shut down the library */
|
|
|
|
H5close();
|
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
h5tools_init_g = 0;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-05 06:43:00 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Private
|
|
|
|
* Chapter: H5Tools Library
|
2006-07-27 23:01:48 +08:00
|
|
|
* Purpose: Get a FAPL for a driver
|
2004-02-05 06:43:00 +08:00
|
|
|
* Description:
|
|
|
|
* Get a FAPL for a given VFL driver name.
|
|
|
|
* Return:
|
|
|
|
* None
|
|
|
|
* Programmer:
|
|
|
|
* Quincey Koziol, 2004-02-04
|
|
|
|
* Modifications:
|
2006-07-27 23:01:48 +08:00
|
|
|
* Pedro Vicente Nunes, Thursday, July 27, 2006
|
|
|
|
* Added error return conditions for the H5Pset_fapl calls
|
2004-02-05 06:43:00 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static hid_t
|
2007-02-14 21:54:11 +08:00
|
|
|
h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
|
2004-02-05 06:43:00 +08:00
|
|
|
{
|
2009-09-04 22:50:13 +08:00
|
|
|
hid_t new_fapl; /* Copy of file access property list passed in, or new property list */
|
2007-02-14 21:54:11 +08:00
|
|
|
|
|
|
|
/* Make a copy of the FAPL, for the file open call to use, eventually */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (fapl == H5P_DEFAULT) {
|
|
|
|
if ((new_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
|
2007-02-14 21:54:11 +08:00
|
|
|
goto error;
|
|
|
|
} /* end if */
|
|
|
|
else {
|
2009-09-04 22:50:13 +08:00
|
|
|
if ((new_fapl = H5Pcopy(fapl)) < 0)
|
2007-02-14 21:54:11 +08:00
|
|
|
goto error;
|
|
|
|
} /* end else */
|
2004-02-05 06:43:00 +08:00
|
|
|
|
|
|
|
/* Determine which driver the user wants to open the file with. Try
|
|
|
|
* that driver. If it can't open it, then fail. */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (!strcmp(driver, drivernames[SEC2_IDX])) {
|
2007-06-12 02:51:20 +08:00
|
|
|
/* SEC2 driver */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (H5Pset_fapl_sec2(new_fapl) < 0)
|
2007-06-12 02:51:20 +08:00
|
|
|
goto error;
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (drivernum)
|
2004-02-05 06:43:00 +08:00
|
|
|
*drivernum = SEC2_IDX;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (!strcmp(driver, drivernames[FAMILY_IDX])) {
|
2004-02-05 06:43:00 +08:00
|
|
|
/* FAMILY Driver */
|
|
|
|
|
2007-02-14 21:54:11 +08:00
|
|
|
/* Set member size to be 0 to indicate the current first member size
|
|
|
|
* is the member size.
|
|
|
|
*/
|
2009-09-04 22:50:13 +08:00
|
|
|
if (H5Pset_fapl_family(new_fapl, (hsize_t) 0, H5P_DEFAULT) < 0)
|
2007-02-14 21:54:11 +08:00
|
|
|
goto error;
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (drivernum)
|
2007-02-14 21:54:11 +08:00
|
|
|
*drivernum = FAMILY_IDX;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (!strcmp(driver, drivernames[SPLIT_IDX])) {
|
2004-02-05 06:43:00 +08:00
|
|
|
/* SPLIT Driver */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (H5Pset_fapl_split(new_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0)
|
2007-02-14 21:54:11 +08:00
|
|
|
goto error;
|
2004-02-05 06:43:00 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (drivernum)
|
2007-02-14 21:54:11 +08:00
|
|
|
*drivernum = SPLIT_IDX;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (!strcmp(driver, drivernames[MULTI_IDX])) {
|
2004-02-05 06:43:00 +08:00
|
|
|
/* MULTI Driver */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (H5Pset_fapl_multi(new_fapl, NULL, NULL, NULL, NULL, TRUE) < 0)
|
|
|
|
goto error;
|
2004-02-05 06:43:00 +08:00
|
|
|
|
2007-02-14 21:54:11 +08:00
|
|
|
if(drivernum)
|
2009-09-04 22:50:13 +08:00
|
|
|
*drivernum = MULTI_IDX;
|
2004-02-05 06:43:00 +08:00
|
|
|
#ifdef H5_HAVE_STREAM
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if(!strcmp(driver, drivernames[STREAM_IDX])) {
|
|
|
|
/* STREAM Driver */
|
|
|
|
if(H5Pset_fapl_stream(new_fapl, NULL) < 0)
|
|
|
|
goto error;
|
2004-02-05 06:43:00 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if(drivernum)
|
|
|
|
*drivernum = STREAM_IDX;
|
2006-07-27 23:01:48 +08:00
|
|
|
#endif /* H5_HAVE_STREAM */
|
2004-02-05 06:43:00 +08:00
|
|
|
#ifdef H5_HAVE_PARALLEL
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if(!strcmp(driver, drivernames[MPIO_IDX])) {
|
|
|
|
/* MPI-I/O Driver */
|
|
|
|
/* check if MPI has been initialized. */
|
|
|
|
if(!h5tools_mpi_init_g)
|
|
|
|
MPI_Initialized(&h5tools_mpi_init_g);
|
|
|
|
if(h5tools_mpi_init_g) {
|
|
|
|
if(H5Pset_fapl_mpio(new_fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
|
|
|
|
goto error;
|
2006-07-27 23:01:48 +08:00
|
|
|
|
2004-02-05 06:43:00 +08:00
|
|
|
if(drivernum)
|
|
|
|
*drivernum = MPIO_IDX;
|
|
|
|
} /* end if */
|
2010-01-30 12:29:13 +08:00
|
|
|
}
|
2009-09-04 22:50:13 +08:00
|
|
|
else if (!strcmp(driver, drivernames[MPIPOSIX_IDX])) {
|
2004-02-05 06:43:00 +08:00
|
|
|
/* MPI-I/O Driver */
|
2009-09-04 22:50:13 +08:00
|
|
|
/* check if MPI has been initialized. */
|
|
|
|
if(!h5tools_mpi_init_g)
|
|
|
|
MPI_Initialized(&h5tools_mpi_init_g);
|
2007-02-14 21:54:11 +08:00
|
|
|
if(h5tools_mpi_init_g) {
|
|
|
|
if(H5Pset_fapl_mpiposix(new_fapl, MPI_COMM_WORLD, TRUE) < 0)
|
2009-09-04 22:50:13 +08:00
|
|
|
goto error;
|
2006-07-27 23:01:48 +08:00
|
|
|
|
2004-02-05 06:43:00 +08:00
|
|
|
if(drivernum)
|
|
|
|
*drivernum = MPIPOSIX_IDX;
|
|
|
|
} /* end if */
|
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else {
|
2007-02-14 21:54:11 +08:00
|
|
|
goto error;
|
2004-02-05 06:43:00 +08:00
|
|
|
}
|
|
|
|
|
2007-02-14 21:54:11 +08:00
|
|
|
return(new_fapl);
|
2006-07-27 23:01:48 +08:00
|
|
|
|
|
|
|
error:
|
2007-02-14 21:54:11 +08:00
|
|
|
if(new_fapl != H5P_DEFAULT)
|
|
|
|
H5Pclose(new_fapl);
|
2006-07-27 23:01:48 +08:00
|
|
|
return -1;
|
2004-02-05 06:43:00 +08:00
|
|
|
}
|
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Open a file with various VFL drivers.
|
|
|
|
* Description:
|
|
|
|
* Loop through the various types of VFL drivers trying to open FNAME.
|
|
|
|
* If the HDF5 library is version 1.2 or less, then we have only the SEC2
|
|
|
|
* driver to try out. If the HDF5 library is greater than version 1.2,
|
|
|
|
* then we have the FAMILY, SPLIT, and MULTI drivers to play with (and
|
|
|
|
* the STREAM driver if H5_HAVE_STREAM is defined, that is).
|
2001-07-31 05:55:46 +08:00
|
|
|
*
|
|
|
|
* If DRIVER is non-NULL, then it will try to open the file with that
|
|
|
|
* driver first. We assume that the user knows what they are doing so, if
|
|
|
|
* we fail, then we won't try other file drivers.
|
2001-04-11 03:54:08 +08:00
|
|
|
* Return:
|
|
|
|
* On success, returns a file id for the opened file. If DRIVERNAME is
|
|
|
|
* non-null then the first DRIVERNAME_SIZE-1 characters of the driver
|
|
|
|
* name are copied into the DRIVERNAME array and null terminated.
|
|
|
|
*
|
|
|
|
* Otherwise, the function returns FAIL. If DRIVERNAME is non-null then
|
|
|
|
* the first byte is set to the null terminator.
|
|
|
|
* Programmer:
|
|
|
|
* Lost in the mists of time.
|
2001-02-23 05:55:15 +08:00
|
|
|
* Modifications:
|
2001-04-11 03:54:08 +08:00
|
|
|
* Robb Matzke, 2000-06-23
|
|
|
|
* We only have to initialize driver[] on the first call, thereby
|
|
|
|
* preventing memory leaks from repeated calls to H5Pcreate().
|
2001-03-09 04:21:05 +08:00
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Robb Matzke, 2000-06-23
|
|
|
|
* Added DRIVERNAME_SIZE arg to prevent overflows when writing to
|
|
|
|
* DRIVERNAME.
|
2001-03-09 04:21:05 +08:00
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Robb Matzke, 2000-06-23
|
|
|
|
* Added test to prevent coredump when the file could not be opened by
|
|
|
|
* any driver.
|
2001-03-09 04:21:05 +08:00
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Robb Matzke, 2000-06-23
|
|
|
|
* Changed name from H5ToolsFopen() so it jives better with the names we
|
|
|
|
* already have at the top of this source file.
|
2001-03-09 04:21:05 +08:00
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Thomas Radke, 2000-09-12
|
|
|
|
* Added Stream VFD to the driver[] array.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Bill Wendling, 2001-01-10
|
|
|
|
* Changed macro behavior so that if we have a version other than 1.2.x
|
|
|
|
* (i.e., > 1.2), then we do the drivers check.
|
2001-07-31 05:55:46 +08:00
|
|
|
*
|
|
|
|
* Bill Wendling, 2001-07-30
|
|
|
|
* Added DRIVER parameter so that the user can specify "try this driver"
|
|
|
|
* instead of the default behaviour. If it fails to open the file with
|
|
|
|
* that driver, this will fail completely (i.e., we won't try the other
|
|
|
|
* drivers). We're assuming the user knows what they're doing. How UNIX
|
|
|
|
* of us.
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2001-03-09 04:21:05 +08:00
|
|
|
hid_t
|
2007-02-14 21:54:11 +08:00
|
|
|
h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver,
|
2007-02-14 06:42:43 +08:00
|
|
|
char *drivername, size_t drivername_size)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2004-02-05 06:43:00 +08:00
|
|
|
unsigned drivernum;
|
|
|
|
hid_t fid = FAIL;
|
2007-02-14 21:54:11 +08:00
|
|
|
hid_t my_fapl = H5P_DEFAULT;
|
2001-03-09 04:21:05 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (driver && *driver) {
|
2004-02-05 06:43:00 +08:00
|
|
|
/* Get the correct FAPL for the given driver */
|
2009-09-04 22:50:13 +08:00
|
|
|
if ((my_fapl = h5tools_get_fapl(fapl, driver, &drivernum)) < 0)
|
2004-02-05 06:43:00 +08:00
|
|
|
goto done;
|
2001-07-31 05:55:46 +08:00
|
|
|
|
2004-02-05 06:43:00 +08:00
|
|
|
H5E_BEGIN_TRY {
|
2007-02-14 21:54:11 +08:00
|
|
|
fid = H5Fopen(fname, flags, my_fapl);
|
2004-02-05 06:43:00 +08:00
|
|
|
} H5E_END_TRY;
|
2001-07-31 05:55:46 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (fid == FAIL)
|
2001-07-31 05:55:46 +08:00
|
|
|
goto done;
|
2004-02-05 06:43:00 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else {
|
2001-07-31 05:55:46 +08:00
|
|
|
/* Try to open the file using each of the drivers */
|
2009-09-04 22:50:13 +08:00
|
|
|
for (drivernum = 0; drivernum < NUM_DRIVERS; drivernum++) {
|
2004-02-05 06:43:00 +08:00
|
|
|
/* Get the correct FAPL for the given driver */
|
2007-02-14 21:54:11 +08:00
|
|
|
if((my_fapl = h5tools_get_fapl(fapl, drivernames[drivernum], NULL)) < 0)
|
2004-02-05 06:43:00 +08:00
|
|
|
goto done;
|
|
|
|
|
2001-07-31 05:55:46 +08:00
|
|
|
H5E_BEGIN_TRY {
|
2007-02-14 21:54:11 +08:00
|
|
|
fid = H5Fopen(fname, flags, my_fapl);
|
2001-07-31 05:55:46 +08:00
|
|
|
} H5E_END_TRY;
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (fid != FAIL)
|
2001-07-31 05:55:46 +08:00
|
|
|
break;
|
2004-02-05 06:43:00 +08:00
|
|
|
else {
|
|
|
|
/* Close the FAPL */
|
2007-02-14 21:54:11 +08:00
|
|
|
H5Pclose(my_fapl);
|
|
|
|
my_fapl = H5P_DEFAULT;
|
2004-02-05 06:43:00 +08:00
|
|
|
} /* end else */
|
2001-07-31 05:55:46 +08:00
|
|
|
}
|
2001-03-09 04:21:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the driver name */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (drivername && drivername_size) {
|
|
|
|
if (fid != FAIL) {
|
2004-02-05 06:43:00 +08:00
|
|
|
strncpy(drivername, drivernames[drivernum], drivername_size);
|
2001-03-09 04:21:05 +08:00
|
|
|
drivername[drivername_size - 1] = '\0';
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else {
|
2001-04-11 03:54:08 +08:00
|
|
|
/*no file opened*/
|
|
|
|
drivername[0] = '\0';
|
2001-03-09 04:21:05 +08:00
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
2001-07-31 05:55:46 +08:00
|
|
|
done:
|
2007-02-14 21:54:11 +08:00
|
|
|
if(my_fapl != H5P_DEFAULT)
|
|
|
|
H5Pclose(my_fapl);
|
2009-09-15 05:48:32 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
return fid;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Count the number of columns in a string.
|
|
|
|
* Description:
|
|
|
|
* Count the number of columns in a string. This is the number of
|
|
|
|
* characters in the string not counting line-control characters.
|
|
|
|
* Return:
|
|
|
|
* On success, returns the width of the string. Otherwise this function
|
|
|
|
* returns 0.
|
|
|
|
* Programmer:
|
|
|
|
* Robb Matzke, Tuesday, April 27, 1999
|
2001-02-23 05:55:15 +08:00
|
|
|
* Modifications:
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2001-03-09 04:21:05 +08:00
|
|
|
static size_t
|
|
|
|
h5tools_ncols(const char *s)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2001-03-09 04:21:05 +08:00
|
|
|
register size_t i;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
for (i = 0; *s; s++)
|
|
|
|
if (*s >= ' ')
|
|
|
|
i++;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
return i;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
2011-03-19 02:50:19 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2011-03-22 07:02:31 +08:00
|
|
|
* Function: h5tools_detect_vlen
|
2011-03-19 02:50:19 +08:00
|
|
|
*
|
|
|
|
* Purpose: Recursive check for any variable length data in given type.
|
|
|
|
*
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
* Return:
|
2011-03-22 07:02:31 +08:00
|
|
|
* TRUE : type conatains any variable length data
|
|
|
|
* FALSE : type doesn't contain any variable length data
|
|
|
|
* Negative value: error occur
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
*
|
2011-03-19 02:50:19 +08:00
|
|
|
* Programmer: Jonathan Kim March 18, 2011
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
htri_t
|
2011-03-22 07:02:31 +08:00
|
|
|
h5tools_detect_vlen(hid_t tid)
|
2011-03-19 02:50:19 +08:00
|
|
|
{
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
htri_t ret;
|
|
|
|
|
2011-03-22 07:02:31 +08:00
|
|
|
/* recursive detect any vlen data values in type (compound, array ...) */
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
ret = H5Tdetect_class(tid, H5T_VLEN);
|
|
|
|
if((ret == TRUE) || (ret < 0))
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
2011-03-19 02:50:19 +08:00
|
|
|
|
2011-03-22 07:02:31 +08:00
|
|
|
/* recursive detect any vlen string in type (compound, array ...) */
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
ret = h5tools_detect_vlen_str(tid);
|
|
|
|
if((ret == TRUE) || (ret < 0))
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
done:
|
|
|
|
return ret;
|
2011-03-19 02:50:19 +08:00
|
|
|
}
|
|
|
|
|
2011-03-10 04:00:20 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2011-03-15 05:03:20 +08:00
|
|
|
* Function: h5tools_detect_vlen_str
|
2011-03-10 04:00:20 +08:00
|
|
|
*
|
|
|
|
* Purpose: Recursive check for variable length string of a datatype.
|
|
|
|
*
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
* Return:
|
2011-03-22 07:02:31 +08:00
|
|
|
* TRUE : type conatains any variable length string
|
|
|
|
* FALSE : type doesn't contain any variable length string
|
|
|
|
* Negative value: error occur
|
2011-03-10 04:00:20 +08:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
htri_t
|
2011-03-15 05:03:20 +08:00
|
|
|
h5tools_detect_vlen_str(hid_t tid)
|
2011-03-10 04:00:20 +08:00
|
|
|
{
|
|
|
|
H5T_class_t tclass = -1;
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
htri_t ret = FALSE;
|
2011-03-10 04:00:20 +08:00
|
|
|
|
2011-03-22 07:02:31 +08:00
|
|
|
ret = H5Tis_variable_str(tid);
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
if((ret == TRUE) || (ret < 0))
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
2011-03-10 04:00:20 +08:00
|
|
|
|
|
|
|
tclass = H5Tget_class(tid);
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
if(tclass == H5T_ARRAY || tclass == H5T_VLEN) {
|
|
|
|
hid_t btid = H5Tget_super(tid);
|
|
|
|
|
|
|
|
if(btid < 0) {
|
|
|
|
ret = (htri_t)btid;
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
ret = h5tools_detect_vlen_str(btid);
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
if((ret == TRUE) || (ret < 0)) {
|
2011-03-22 07:02:31 +08:00
|
|
|
H5Tclose(btid);
|
|
|
|
goto done;
|
|
|
|
}
|
2011-03-10 04:00:20 +08:00
|
|
|
}
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
else if(tclass == H5T_COMPOUND) {
|
|
|
|
int i = 0;
|
|
|
|
int n = H5Tget_nmembers(tid);
|
|
|
|
|
|
|
|
if(n < 0) {
|
2011-03-22 07:02:31 +08:00
|
|
|
n = ret;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
for(i = 0; i < n; i++) {
|
|
|
|
hid_t mtid = H5Tget_member_type(tid, i);
|
|
|
|
|
2011-03-22 07:02:31 +08:00
|
|
|
ret = h5tools_detect_vlen_str(mtid);
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
if((ret == TRUE) || (ret < 0)) {
|
2011-03-10 04:00:20 +08:00
|
|
|
H5Tclose(mtid);
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
2011-03-10 04:00:20 +08:00
|
|
|
}
|
|
|
|
H5Tclose(mtid);
|
|
|
|
}
|
|
|
|
}
|
2011-03-22 07:02:31 +08:00
|
|
|
|
|
|
|
done:
|
|
|
|
return ret;
|
2011-03-10 04:00:20 +08:00
|
|
|
}
|
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Emit a simple prefix to STREAM.
|
|
|
|
* Description:
|
|
|
|
* If /ctx->need_prefix/ is set then terminate the current line (if
|
|
|
|
* applicable), calculate the prefix string, and display it at the start
|
|
|
|
* of a line.
|
|
|
|
* Return:
|
|
|
|
* None
|
|
|
|
* Programmer:
|
|
|
|
* Robb Matzke, Monday, April 26, 1999
|
2001-02-23 05:55:15 +08:00
|
|
|
* Modifications:
|
2001-04-11 03:54:08 +08:00
|
|
|
* Robb Matzke, 1999-09-29
|
2006-07-27 23:01:48 +08:00
|
|
|
* If a new prefix is printed then the current element number is set back
|
|
|
|
* to zero.
|
2004-07-09 05:49:40 +08:00
|
|
|
* pvn, 2004-07-08
|
2005-08-14 04:53:35 +08:00
|
|
|
* Added support for printing array indices:
|
2004-07-01 02:45:14 +08:00
|
|
|
* the indentation is printed before the prefix (printed one indentation
|
2005-08-14 04:53:35 +08:00
|
|
|
* level before)
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2001-03-09 04:21:05 +08:00
|
|
|
static void
|
2006-01-24 04:46:34 +08:00
|
|
|
h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
|
2001-03-09 04:21:05 +08:00
|
|
|
h5tools_context_t *ctx, hsize_t elmtno, int secnum)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2001-03-09 04:21:05 +08:00
|
|
|
h5tools_str_t prefix;
|
2004-07-01 02:45:14 +08:00
|
|
|
h5tools_str_t str; /*temporary for indentation */
|
2001-03-09 04:21:05 +08:00
|
|
|
size_t templength = 0;
|
|
|
|
int i, indentlevel = 0;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
if (!ctx->need_prefix)
|
2009-09-04 22:50:13 +08:00
|
|
|
return;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2001-07-11 04:18:52 +08:00
|
|
|
memset(&prefix, 0, sizeof(h5tools_str_t));
|
2004-07-01 02:45:14 +08:00
|
|
|
memset(&str, 0, sizeof(h5tools_str_t));
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
/* Terminate previous line, if any */
|
|
|
|
if (ctx->cur_column) {
|
2009-09-04 22:50:13 +08:00
|
|
|
fputs(OPT(info->line_suf, ""), stream);
|
|
|
|
putc('\n', stream);
|
|
|
|
fputs(OPT(info->line_sep, ""), stream);
|
2001-03-09 04:21:05 +08:00
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
/* Calculate new prefix */
|
2010-08-13 05:11:00 +08:00
|
|
|
h5tools_str_prefix(&prefix, info, elmtno, ctx->ndims, ctx);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
/* Write new prefix to output */
|
|
|
|
if (ctx->indent_level >= 0) {
|
|
|
|
indentlevel = ctx->indent_level;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* This is because sometimes we don't print out all the header
|
|
|
|
* info for the data (like the tattr-2.ddl example). If that happens
|
|
|
|
* the ctx->indent_level is negative so we need to skip the above and
|
|
|
|
* just print out the default indent levels.
|
|
|
|
*/
|
|
|
|
indentlevel = ctx->default_indent_level;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* when printing array indices, print the indentation before the prefix
|
|
|
|
the prefix is printed one indentation level before */
|
|
|
|
if (info->pindex) {
|
|
|
|
for (i = 0; i < indentlevel - 1; i++) {
|
|
|
|
fputs(h5tools_str_fmt(&str, 0, info->line_indent), stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (elmtno == 0 && secnum == 0 && info->line_1st)
|
|
|
|
fputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
|
|
|
|
else if (secnum && info->line_cont)
|
|
|
|
fputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
|
|
|
|
else
|
|
|
|
fputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
|
|
|
|
|
|
|
|
templength = h5tools_str_len(&prefix);
|
|
|
|
|
|
|
|
for (i = 0; i < indentlevel; i++) {
|
|
|
|
/*we already made the indent for the array indices case */
|
|
|
|
if (!info->pindex) {
|
|
|
|
fputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
|
|
|
|
templength += h5tools_str_len(&prefix);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*we cannot count the prefix for the array indices case */
|
|
|
|
templength += h5tools_str_len(&str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->cur_column = ctx->prev_prefix_len = templength;
|
|
|
|
ctx->cur_elmt = 0;
|
|
|
|
ctx->need_prefix = 0;
|
|
|
|
|
|
|
|
/* Free string */
|
|
|
|
h5tools_str_close(&prefix);
|
|
|
|
h5tools_str_close(&str);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Emit a simple prefix to STREAM.
|
|
|
|
* Description:
|
|
|
|
* If /ctx->need_prefix/ is set then terminate the current line (if
|
|
|
|
* applicable), calculate the prefix string, and display it at the start
|
|
|
|
* of a line. Calls region specific function.
|
|
|
|
* Return:
|
|
|
|
* None
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
static void
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
|
2010-01-30 12:29:13 +08:00
|
|
|
h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum)
|
2009-09-04 22:50:13 +08:00
|
|
|
{
|
|
|
|
h5tools_str_t prefix;
|
|
|
|
h5tools_str_t str; /*temporary for indentation */
|
|
|
|
size_t templength = 0;
|
|
|
|
int i, indentlevel = 0;
|
|
|
|
|
|
|
|
if (!ctx->need_prefix)
|
|
|
|
return;
|
|
|
|
|
|
|
|
memset(&prefix, 0, sizeof(h5tools_str_t));
|
|
|
|
memset(&str, 0, sizeof(h5tools_str_t));
|
|
|
|
|
|
|
|
/* Terminate previous line, if any */
|
|
|
|
if (ctx->cur_column) {
|
|
|
|
fputs(OPT(info->line_suf, ""), stream);
|
|
|
|
putc('\n', stream);
|
|
|
|
fputs(OPT(info->line_sep, ""), stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate new prefix */
|
2011-05-12 04:45:54 +08:00
|
|
|
h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx->ndims, ctx->p_max_idx, ctx);
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* Write new prefix to output */
|
|
|
|
if (ctx->indent_level >= 0) {
|
|
|
|
indentlevel = ctx->indent_level;
|
|
|
|
}
|
|
|
|
else {
|
2001-03-09 04:21:05 +08:00
|
|
|
/*
|
2001-04-11 03:54:08 +08:00
|
|
|
* This is because sometimes we don't print out all the header
|
|
|
|
* info for the data (like the tattr-2.ddl example). If that happens
|
|
|
|
* the ctx->indent_level is negative so we need to skip the above and
|
|
|
|
* just print out the default indent levels.
|
2001-03-09 04:21:05 +08:00
|
|
|
*/
|
2009-09-04 22:50:13 +08:00
|
|
|
indentlevel = ctx->default_indent_level;
|
2001-03-09 04:21:05 +08:00
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2004-07-01 02:45:14 +08:00
|
|
|
/* when printing array indices, print the indentation before the prefix
|
|
|
|
the prefix is printed one indentation level before */
|
|
|
|
if (info->pindex) {
|
2009-09-04 22:50:13 +08:00
|
|
|
for (i = 0; i < indentlevel - 1; i++) {
|
|
|
|
fputs(h5tools_str_fmt(&str, 0, info->line_indent), stream);
|
|
|
|
}
|
2004-07-01 02:45:14 +08:00
|
|
|
}
|
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
if (elmtno == 0 && secnum == 0 && info->line_1st)
|
2001-07-11 04:18:52 +08:00
|
|
|
fputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
|
2001-03-09 04:21:05 +08:00
|
|
|
else if (secnum && info->line_cont)
|
2001-07-11 04:18:52 +08:00
|
|
|
fputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
|
2001-03-09 04:21:05 +08:00
|
|
|
else
|
2001-07-11 04:18:52 +08:00
|
|
|
fputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
templength = h5tools_str_len(&prefix);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
for (i = 0; i < indentlevel; i++) {
|
2004-07-01 02:45:14 +08:00
|
|
|
/*we already made the indent for the array indices case */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (!info->pindex) {
|
|
|
|
fputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
|
|
|
|
templength += h5tools_str_len(&prefix);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*we cannot count the prefix for the array indices case */
|
|
|
|
templength += h5tools_str_len(&str);
|
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ctx->cur_column = ctx->prev_prefix_len = templength;
|
|
|
|
ctx->cur_elmt = 0;
|
|
|
|
ctx->need_prefix = 0;
|
|
|
|
|
|
|
|
/* Free string */
|
|
|
|
h5tools_str_close(&prefix);
|
2004-07-01 02:45:14 +08:00
|
|
|
h5tools_str_close(&str);
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Prints NELMTS data elements to output STREAM.
|
|
|
|
* Description:
|
|
|
|
* Prints some (NELMTS) data elements to output STREAM. The elements are
|
|
|
|
* stored in _MEM as type TYPE and are printed according to the format
|
|
|
|
* described in INFO. The CTX struct contains context information shared
|
|
|
|
* between calls to this function. The FLAGS is a bit field that
|
|
|
|
* indicates whether the data supplied in this call falls at the
|
|
|
|
* beginning or end of the total data to be printed (START_OF_DATA and
|
|
|
|
* END_OF_DATA).
|
|
|
|
* Return:
|
|
|
|
* None
|
|
|
|
* Programmer:
|
|
|
|
* Robb Matzke, Monday, April 26, 1999
|
2001-02-23 05:55:15 +08:00
|
|
|
* Modifications:
|
2006-07-27 23:01:48 +08:00
|
|
|
* Robb Matzke, 1999-06-04
|
|
|
|
* The `container' argument is the optional dataset for reference types.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2006-07-27 23:01:48 +08:00
|
|
|
* Robb Matzke, 1999-09-29
|
|
|
|
* Understands the `per_line' property which indicates that every Nth
|
|
|
|
* element should begin a new line.
|
2003-06-10 03:29:28 +08:00
|
|
|
*
|
|
|
|
* Robb Matzke, LLNL, 2003-06-05
|
|
|
|
* Do not dereference the memory for a variable-length string here.
|
|
|
|
* Deref in h5tools_str_sprint() instead so recursive types are
|
|
|
|
* handled correctly.
|
2006-07-27 23:01:48 +08:00
|
|
|
*
|
2009-01-23 04:53:59 +08:00
|
|
|
* Pedro Vicente Nunes, The HDF Group, 2005-10-19
|
2005-10-20 00:46:12 +08:00
|
|
|
* pass to the prefix in h5tools_simple_prefix the total position
|
2006-07-27 23:01:48 +08:00
|
|
|
* instead of the current stripmine position i; this is necessary
|
|
|
|
* to print the array indices
|
|
|
|
* new field sm_pos in h5tools_context_t, the current stripmine element position
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
void
|
2006-01-24 04:46:34 +08:00
|
|
|
h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container,
|
2001-03-09 04:21:05 +08:00
|
|
|
h5tools_context_t *ctx/*in,out*/, unsigned flags,
|
|
|
|
hsize_t nelmts, hid_t type, void *_mem)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2009-09-04 22:50:13 +08:00
|
|
|
unsigned char *mem = (unsigned char*) _mem;
|
|
|
|
hsize_t i; /*element counter */
|
|
|
|
size_t size; /*size of each datum */
|
|
|
|
hid_t region_space;
|
|
|
|
hid_t region_id;
|
2009-09-08 22:51:59 +08:00
|
|
|
hbool_t dimension_break = TRUE;
|
|
|
|
H5S_sel_type region_type;
|
2009-09-04 22:50:13 +08:00
|
|
|
size_t ncols = 80; /*available output width */
|
|
|
|
h5tools_str_t buffer; /*string into which to render */
|
|
|
|
hsize_t curr_pos; /* total data element position */
|
|
|
|
hsize_t elmt_counter = 0;/*counts the # elements printed.
|
|
|
|
*I (ptl?) needed something that
|
|
|
|
*isn't going to get reset when a new
|
|
|
|
*line is formed. I'm going to use
|
|
|
|
*this var to count elements and
|
|
|
|
*break after we see a number equal
|
|
|
|
*to the ctx->size_last_dim. */
|
|
|
|
|
|
|
|
/* binary dump */
|
|
|
|
if (bin_output) {
|
2010-08-10 02:15:37 +08:00
|
|
|
do_bin_output(rawdatastream, container, nelmts, type, _mem);
|
2007-09-13 23:44:56 +08:00
|
|
|
} /* end if */
|
2009-09-04 22:50:13 +08:00
|
|
|
else {
|
2008-05-01 03:51:13 +08:00
|
|
|
/* setup */
|
2007-09-13 23:44:56 +08:00
|
|
|
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
|
|
|
|
size = H5Tget_size(type);
|
2006-08-03 07:41:53 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (info->line_ncols > 0)
|
2007-09-13 23:44:56 +08:00
|
|
|
ncols = info->line_ncols;
|
2006-08-03 07:41:53 +08:00
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
/* pass to the prefix in h5tools_simple_prefix the total position
|
|
|
|
* instead of the current stripmine position i; this is necessary
|
|
|
|
* to print the array indices
|
|
|
|
*/
|
|
|
|
curr_pos = ctx->sm_pos;
|
[svn-r13064]
Fix several bugs
1) the parsing of subsetting was using atoi to convert the parameter to an int, which caused problems for numbers greater that int. Substitute with atof
2) the printing of indices in the subsetting case was not being done. Solution: calculate the element position at the start of the subsetting using the algorythm
Given an index I(z,y,x) its position from the beginning of an array of sizes A(size_z, size_y,size_x) is given by
Position of I(z,y,x) = index_z * size_y * size_x
+ index_y * size_x
+ index_x
And pass that position to the function that dumps data, h5tools_dump_simple_data.
3) several index counters were declared as int, use hsize_t instead
4) modified the test generation program so that it includes test cases for subsetting of 1d, 2d, 3d, and 4d arrays and add these tests to the shell script
2006-12-15 05:18:08 +08:00
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) {
|
2009-09-04 22:50:13 +08:00
|
|
|
void* memref = mem + i * size;
|
|
|
|
if (region_output && H5Tequal(type, H5T_STD_REF_DSETREG)) {
|
|
|
|
char ref_name[1024];
|
|
|
|
|
|
|
|
/* region data */
|
2011-07-19 05:23:02 +08:00
|
|
|
region_id = H5Rdereference2(container, H5P_DATASET_ACCESS_DEFAULT, H5R_DATASET_REGION, memref);
|
2009-09-04 22:50:13 +08:00
|
|
|
if (region_id >= 0) {
|
|
|
|
region_space = H5Rget_region(container, H5R_DATASET_REGION, memref);
|
|
|
|
if (region_space >= 0) {
|
|
|
|
if (h5tools_is_zero(memref, H5Tget_size(type))) {
|
|
|
|
h5tools_str_append(&buffer, "NULL");
|
|
|
|
}
|
|
|
|
else {
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Rget_name(region_id, H5R_DATASET_REGION, memref, (char*) ref_name, 1024)<0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_name failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* Render the region element begin */
|
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
|
|
|
|
h5tools_str_append(&buffer, info->dset_format, ref_name);
|
|
|
|
|
2011-03-09 21:07:38 +08:00
|
|
|
dimension_break = h5tools_render_element(stdout, info,
|
2009-09-15 03:52:42 +08:00
|
|
|
ctx, &buffer, &curr_pos, ncols, i, elmt_counter);
|
2009-09-08 22:51:59 +08:00
|
|
|
|
|
|
|
region_type = H5Sget_select_type(region_space);
|
|
|
|
if(region_type==H5S_SEL_POINTS)
|
|
|
|
/* Print point information */
|
|
|
|
dimension_break = h5tools_dump_region_data_points(
|
2011-03-09 21:07:38 +08:00
|
|
|
region_space, region_id, stdout, info, ctx,
|
2009-09-08 22:51:59 +08:00
|
|
|
&buffer, &curr_pos, ncols, i, elmt_counter);
|
2009-09-15 03:52:42 +08:00
|
|
|
else if(region_type==H5S_SEL_HYPERSLABS)
|
2009-09-08 22:51:59 +08:00
|
|
|
/* Print block information */
|
|
|
|
dimension_break = h5tools_dump_region_data_blocks(
|
2011-03-09 21:07:38 +08:00
|
|
|
region_space, region_id, stdout, info, ctx,
|
2009-09-08 22:51:59 +08:00
|
|
|
&buffer, &curr_pos, ncols, i, elmt_counter);
|
2009-09-15 03:52:42 +08:00
|
|
|
else
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "invalid region type");
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Render the region element end */
|
|
|
|
|
|
|
|
} /* end else to if (h5tools_is_zero(... */
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Sclose(region_space) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
} /* end if (region_space >= 0) */
|
2010-01-30 12:29:13 +08:00
|
|
|
else
|
2009-09-15 03:52:42 +08:00
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_region failed");
|
|
|
|
if(H5Dclose(region_id) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
} /* if (region_id >= 0) */
|
2010-01-30 12:29:13 +08:00
|
|
|
else
|
2009-09-15 03:52:42 +08:00
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference failed");
|
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
ctx->need_prefix = TRUE;
|
2009-09-04 22:50:13 +08:00
|
|
|
} /* end if (region_output... */
|
|
|
|
else {
|
|
|
|
/* Render the data element begin*/
|
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_sprint(&buffer, info, container, type, memref, ctx);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (i + 1 < nelmts || (flags & END_OF_DATA) == 0)
|
|
|
|
h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ","));
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2011-03-09 21:07:38 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, &buffer,
|
2009-09-04 22:50:13 +08:00
|
|
|
&curr_pos, ncols, i, elmt_counter);
|
|
|
|
/* Render the data element end*/
|
2007-09-13 23:44:56 +08:00
|
|
|
|
|
|
|
}
|
2009-09-08 22:51:59 +08:00
|
|
|
if(FALSE==dimension_break)
|
2009-09-04 22:50:13 +08:00
|
|
|
elmt_counter = 0;
|
|
|
|
} /* end for (i = 0; i < nelmts... */
|
2006-06-26 22:41:59 +08:00
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
h5tools_str_close(&buffer);
|
|
|
|
}/* else bin */
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
2009-09-04 22:50:13 +08:00
|
|
|
* Purpose: Render an element to output STREAM.
|
2001-04-11 03:54:08 +08:00
|
|
|
* Description:
|
2009-09-04 22:50:13 +08:00
|
|
|
* Prints the string buffer to the output STREAM. The string is
|
2010-01-30 12:29:13 +08:00
|
|
|
* printed according to the format described in INFO. The CTX struct
|
|
|
|
* contains context information shared between calls to this function.
|
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Return:
|
2009-09-04 22:50:13 +08:00
|
|
|
* False if a dimension end is reached, otherwise true
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
|
|
|
* In/Out:
|
2009-09-04 22:50:13 +08:00
|
|
|
* h5tools_context_t *ctx
|
|
|
|
* h5tools_str_t *buffer
|
|
|
|
* hsize_t *curr_pos
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Parameters Description:
|
|
|
|
* h5tools_str_t *buffer is the string into which to render
|
|
|
|
* hsize_t curr_pos is the total data element position
|
|
|
|
* size_t ncols
|
|
|
|
* hsize_t local_elmt_counter is the local element loop counter
|
|
|
|
* hsize_t elmt_count is the data element loop counter
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
2005-08-14 04:53:35 +08:00
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
hbool_t
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_render_element(FILE *stream, const h5tool_format_t *info,
|
|
|
|
h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos,
|
2010-01-30 12:29:13 +08:00
|
|
|
size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2009-09-08 22:51:59 +08:00
|
|
|
hbool_t dimension_break = TRUE;
|
|
|
|
char *s;
|
|
|
|
char *section; /*a section of output */
|
|
|
|
int secnum; /*section sequence number */
|
|
|
|
int multiline; /*datum was multiline */
|
2007-01-11 03:15:16 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
s = h5tools_str_fmt(buffer, 0, "%s");
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If the element would split on multiple lines if printed at our
|
|
|
|
* current location...
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
if (info->line_multi_new == 1 &&
|
|
|
|
(ctx->cur_column + h5tools_ncols(s) +
|
|
|
|
strlen(OPT(info->elmt_suf2, " ")) +
|
2009-09-04 22:50:13 +08:00
|
|
|
strlen(OPT(info->line_suf, ""))) > ncols) {
|
|
|
|
if (ctx->prev_multiline) {
|
|
|
|
/*
|
|
|
|
* ... and the previous element also occupied more than one
|
|
|
|
* line, then start this element at the beginning of a line.
|
|
|
|
*/
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
}
|
2010-01-30 12:29:13 +08:00
|
|
|
else if ((ctx->prev_prefix_len + h5tools_ncols(s) +
|
|
|
|
strlen(OPT(info->elmt_suf2, " ")) +
|
2009-09-04 22:50:13 +08:00
|
|
|
strlen(OPT(info->line_suf, ""))) <= ncols) {
|
|
|
|
/*
|
|
|
|
* ...but *could* fit on one line otherwise, then we
|
|
|
|
* should end the current line and start this element on its
|
|
|
|
* own line.
|
|
|
|
*/
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2001-04-11 03:54:08 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* We need to break after each row of a dimension---> we should
|
|
|
|
* break at the end of the each last dimension well that is the
|
|
|
|
* way the dumper did it before
|
|
|
|
*/
|
|
|
|
if (info->arr_linebreak && ctx->cur_elmt) {
|
|
|
|
if (ctx->size_last_dim && (ctx->cur_elmt % ctx->size_last_dim) == 0)
|
|
|
|
ctx->need_prefix = TRUE;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (elmt_counter == ctx->size_last_dim) {
|
|
|
|
ctx->need_prefix = TRUE;
|
2009-09-08 22:51:59 +08:00
|
|
|
dimension_break = FALSE;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*
|
2009-09-04 22:50:13 +08:00
|
|
|
* If the previous element occupied multiple lines and this element
|
|
|
|
* is too long to fit on a line then start this element at the
|
|
|
|
* beginning of the line.
|
2001-02-23 05:55:15 +08:00
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
if (info->line_multi_new == 1 &&
|
|
|
|
ctx->prev_multiline &&
|
|
|
|
(ctx->cur_column +
|
|
|
|
h5tools_ncols(s) +
|
|
|
|
strlen(OPT(info->elmt_suf2, " ")) +
|
2009-09-04 22:50:13 +08:00
|
|
|
strlen(OPT(info->line_suf, ""))) > ncols)
|
|
|
|
ctx->need_prefix = TRUE;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If too many elements have already been printed then we need to
|
|
|
|
* start a new line.
|
|
|
|
*/
|
|
|
|
if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line)
|
|
|
|
ctx->need_prefix = TRUE;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause
|
|
|
|
* the data to split across multiple lines. We display the sections
|
|
|
|
* one-at a time.
|
|
|
|
*/
|
|
|
|
multiline = 0;
|
2010-01-30 12:29:13 +08:00
|
|
|
for (secnum = 0, multiline = 0;
|
|
|
|
(section = strtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK));
|
2009-09-04 22:50:13 +08:00
|
|
|
secnum++) {
|
|
|
|
/*
|
|
|
|
* If the current section plus possible suffix and end-of-line
|
|
|
|
* information would cause the output to wrap then we need to
|
|
|
|
* start a new line.
|
|
|
|
*/
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
2011-02-16 03:28:48 +08:00
|
|
|
* check for displaying prefix for each section
|
2009-09-04 22:50:13 +08:00
|
|
|
*/
|
2011-02-16 03:28:48 +08:00
|
|
|
if ( (ctx->cur_column + strlen(section) +
|
|
|
|
strlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
strlen(OPT(info->line_suf, ""))) > ncols)
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->need_prefix = 1;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Print the prefix or separate the beginning of this element
|
|
|
|
* from the previous element.
|
|
|
|
*/
|
|
|
|
if (ctx->need_prefix) {
|
|
|
|
if (secnum)
|
|
|
|
multiline++;
|
2007-01-11 03:15:16 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* pass to the prefix in h5tools_simple_prefix the total
|
|
|
|
* position instead of the current stripmine position i;
|
|
|
|
* this is necessary to print the array indices
|
|
|
|
*/
|
|
|
|
*curr_pos = ctx->sm_pos + local_elmt_counter;
|
2008-01-15 02:47:50 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_simple_prefix(stream, info, ctx, *curr_pos, secnum);
|
|
|
|
}
|
|
|
|
else if ((local_elmt_counter || ctx->continuation) && secnum == 0) {
|
|
|
|
fputs(OPT(info->elmt_suf2, " "), stream);
|
|
|
|
ctx->cur_column += strlen(OPT(info->elmt_suf2, " "));
|
2008-01-15 02:47:50 +08:00
|
|
|
}
|
2001-03-09 04:21:05 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Print the section */
|
|
|
|
fputs(section, stream);
|
|
|
|
ctx->cur_column += strlen(section);
|
|
|
|
}
|
2008-01-11 05:31:28 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->prev_multiline = multiline;
|
|
|
|
return dimension_break;
|
|
|
|
}
|
2001-03-09 04:21:05 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Render a region element to output STREAM.
|
|
|
|
* Description:
|
|
|
|
* Prints the string buffer to the output STREAM. The string is
|
2010-01-30 12:29:13 +08:00
|
|
|
* printed according to the format described in INFO. The CTX struct
|
|
|
|
* contains context information shared between calls to this function.
|
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Return:
|
|
|
|
* False if a dimension end is reached, otherwise true
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
|
|
|
* In/Out:
|
2009-09-04 22:50:13 +08:00
|
|
|
* h5tools_context_t *ctx
|
|
|
|
* h5tools_str_t *buffer
|
|
|
|
* hsize_t *curr_pos
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Parameters Description:
|
|
|
|
* h5tools_str_t *buffer is the string into which to render
|
|
|
|
* hsize_t curr_pos is the total data element position
|
|
|
|
* size_t ncols
|
|
|
|
* hsize_t *ptdata
|
|
|
|
* hsize_t local_elmt_counter is the local element loop counter
|
|
|
|
* hsize_t elmt_count is the data element loop counter
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
hbool_t
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
|
|
|
|
h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos,
|
2010-01-30 12:29:13 +08:00
|
|
|
size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter)
|
2009-09-04 22:50:13 +08:00
|
|
|
{
|
2009-09-08 22:51:59 +08:00
|
|
|
hbool_t dimension_break = TRUE;
|
|
|
|
char *s;
|
|
|
|
char *section; /*a section of output */
|
|
|
|
int secnum; /*section sequence number */
|
|
|
|
int multiline; /*datum was multiline */
|
2001-03-16 03:31:40 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
s = h5tools_str_fmt(buffer, 0, "%s");
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If the element would split on multiple lines if printed at our
|
|
|
|
* current location...
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
if (info->line_multi_new == 1 &&
|
|
|
|
(ctx->cur_column + h5tools_ncols(s) +
|
|
|
|
strlen(OPT(info->elmt_suf2, " ")) +
|
2009-09-04 22:50:13 +08:00
|
|
|
strlen(OPT(info->line_suf, ""))) > ncols) {
|
|
|
|
if (ctx->prev_multiline) {
|
|
|
|
/*
|
|
|
|
* ... and the previous element also occupied more than one
|
|
|
|
* line, then start this element at the beginning of a line.
|
|
|
|
*/
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
}
|
2010-01-30 12:29:13 +08:00
|
|
|
else if ((ctx->prev_prefix_len + h5tools_ncols(s) +
|
|
|
|
strlen(OPT(info->elmt_suf2, " ")) +
|
2009-09-04 22:50:13 +08:00
|
|
|
strlen(OPT(info->line_suf, ""))) <= ncols) {
|
|
|
|
/*
|
|
|
|
* ...but *could* fit on one line otherwise, then we
|
|
|
|
* should end the current line and start this element on its
|
|
|
|
* own line.
|
|
|
|
*/
|
|
|
|
ctx->need_prefix = TRUE;
|
2007-01-11 03:15:16 +08:00
|
|
|
}
|
|
|
|
}
|
2001-03-16 03:31:40 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* We need to break after each row of a dimension---> we should
|
|
|
|
* break at the end of the each last dimension well that is the
|
|
|
|
* way the dumper did it before
|
|
|
|
*/
|
|
|
|
if (info->arr_linebreak && ctx->cur_elmt) {
|
|
|
|
if (ctx->size_last_dim && (ctx->cur_elmt % ctx->size_last_dim) == 0)
|
|
|
|
ctx->need_prefix = TRUE;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (elmt_counter == ctx->size_last_dim) {
|
|
|
|
ctx->need_prefix = TRUE;
|
2009-09-08 22:51:59 +08:00
|
|
|
dimension_break = FALSE;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
}
|
2001-03-16 03:31:40 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If the previous element occupied multiple lines and this element
|
|
|
|
* is too long to fit on a line then start this element at the
|
|
|
|
* beginning of the line.
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
if (info->line_multi_new == 1 &&
|
|
|
|
ctx->prev_multiline &&
|
|
|
|
(ctx->cur_column +
|
|
|
|
h5tools_ncols(s) +
|
|
|
|
strlen(OPT(info->elmt_suf2, " ")) +
|
2009-09-04 22:50:13 +08:00
|
|
|
strlen(OPT(info->line_suf, ""))) > ncols)
|
|
|
|
ctx->need_prefix = TRUE;
|
[svn-r14437] bug fix for h5dump subsetting (deal with blocks)and new test runs
add a check for block overlap after the command line parsing
* Algorithm
*
* In a inner loop, the parameters from SSET are translated into temporary
* variables so that 1 row is printed at a time (getting the coordinate indices
* at each row).
* We define the stride, count and block to be 1 in the row dimension to achieve
* this and advance until all points are printed.
* An outer loop for cases where dimensionality is greater than 2D is made.
* In each iteration, the 2D block is displayed in the inner loop. The remaining
* slower dimensions above the first 2 are incremented one at a time in the outer loop
*
* The element position is obtained from the matrix according to:
* Given an index I(z,y,x) its position from the beginning of an array
* of sizes A(size_z, size_y,size_x) is given by
* Position of I(z,y,x) = index_z * size_y * size_x
* + index_y * size_x
* + index_x
*
tested: windows, linux
2008-01-17 00:12:08 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If too many elements have already been printed then we need to
|
|
|
|
* start a new line.
|
|
|
|
*/
|
|
|
|
if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line)
|
|
|
|
ctx->need_prefix = TRUE;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause
|
|
|
|
* the data to split across multiple lines. We display the sections
|
|
|
|
* one-at a time.
|
|
|
|
*/
|
|
|
|
multiline = 0;
|
|
|
|
for (secnum = 0, multiline = 0; (section = strtok(secnum ? NULL : s,
|
|
|
|
OPTIONAL_LINE_BREAK)); secnum++) {
|
|
|
|
/*
|
|
|
|
* If the current section plus possible suffix and end-of-line
|
|
|
|
* information would cause the output to wrap then we need to
|
|
|
|
* start a new line.
|
|
|
|
*/
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Added the info->skip_first because the dumper does not want
|
|
|
|
* this check to happen for the first line
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
if ((!info->skip_first || local_elmt_counter) &&
|
|
|
|
(ctx->cur_column +
|
|
|
|
strlen(section) +
|
|
|
|
strlen(OPT(info->elmt_suf2, " ")) +
|
2009-09-04 22:50:13 +08:00
|
|
|
strlen(OPT(info->line_suf, ""))) > ncols)
|
|
|
|
ctx->need_prefix = 1;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Print the prefix or separate the beginning of this element
|
|
|
|
* from the previous element.
|
|
|
|
*/
|
|
|
|
if (ctx->need_prefix) {
|
|
|
|
if (secnum)
|
|
|
|
multiline++;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* pass to the prefix in h5tools_simple_prefix the total
|
|
|
|
* position instead of the current stripmine position i;
|
|
|
|
* this is necessary to print the array indices
|
|
|
|
*/
|
|
|
|
*curr_pos = ctx->sm_pos + local_elmt_counter;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_region_simple_prefix(stream, info, ctx, local_elmt_counter, ptdata, secnum);
|
2001-04-11 03:54:08 +08:00
|
|
|
}
|
2009-09-04 22:50:13 +08:00
|
|
|
else if ((local_elmt_counter || ctx->continuation) && secnum == 0) {
|
|
|
|
fputs(OPT(info->elmt_suf2, " "), stream);
|
|
|
|
ctx->cur_column += strlen(OPT(info->elmt_suf2, " "));
|
2001-04-11 03:54:08 +08:00
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Print the section */
|
|
|
|
fputs(section, stream);
|
|
|
|
ctx->cur_column += strlen(section);
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->prev_multiline = multiline;
|
|
|
|
return dimension_break;
|
|
|
|
}
|
[svn-r14437] bug fix for h5dump subsetting (deal with blocks)and new test runs
add a check for block overlap after the command line parsing
* Algorithm
*
* In a inner loop, the parameters from SSET are translated into temporary
* variables so that 1 row is printed at a time (getting the coordinate indices
* at each row).
* We define the stride, count and block to be 1 in the row dimension to achieve
* this and advance until all points are printed.
* An outer loop for cases where dimensionality is greater than 2D is made.
* In each iteration, the 2D block is displayed in the inner loop. The remaining
* slower dimensions above the first 2 are incremented one at a time in the outer loop
*
* The element position is obtained from the matrix according to:
* Given an index I(z,y,x) its position from the beginning of an array
* of sizes A(size_z, size_y,size_x) is given by
* Position of I(z,y,x) = index_z * size_y * size_x
* + index_y * size_x
* + index_x
*
tested: windows, linux
2008-01-17 00:12:08 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print the data values from a dataset referenced by region blocks.
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-15 03:52:42 +08:00
|
|
|
* Description:
|
|
|
|
* This is a special case subfunction to print the data in a region reference of type blocks.
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-15 03:52:42 +08:00
|
|
|
* Return:
|
|
|
|
* The function returns FAIL if there was an error, otherwise SUCEED
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-15 03:52:42 +08:00
|
|
|
* Parameters Description:
|
|
|
|
* h5tools_str_t *buffer is the string into which to render
|
|
|
|
* size_t ncols
|
|
|
|
* int ndims is the number of dimensions of the region element
|
|
|
|
* hssize_t nblocks is the number of blocks in the region
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-08-13 05:11:00 +08:00
|
|
|
static int
|
|
|
|
h5tools_print_region_data_blocks(hid_t region_id,
|
2011-05-12 04:45:54 +08:00
|
|
|
FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
|
2010-01-30 12:29:13 +08:00
|
|
|
h5tools_str_t *buffer/*string into which to render */, size_t ncols,
|
2010-10-21 21:08:44 +08:00
|
|
|
int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata)
|
|
|
|
{
|
2009-09-15 03:52:42 +08:00
|
|
|
hbool_t dimension_break = TRUE;
|
|
|
|
hsize_t *dims1 = NULL;
|
|
|
|
hsize_t *start = NULL;
|
|
|
|
hsize_t *count = NULL;
|
|
|
|
size_t numelem;
|
|
|
|
hsize_t total_size[H5S_MAX_RANK];
|
|
|
|
hsize_t elmtno; /* elemnt index */
|
|
|
|
unsigned int region_flags; /* buffer extent flags */
|
|
|
|
hsize_t curr_pos;
|
2011-05-12 04:45:54 +08:00
|
|
|
size_t jndx;
|
|
|
|
int indx;
|
2009-09-15 03:52:42 +08:00
|
|
|
int type_size;
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
hid_t mem_space = -1;
|
2009-09-15 03:52:42 +08:00
|
|
|
void *region_buf = NULL;
|
2011-05-12 04:45:54 +08:00
|
|
|
hsize_t blkndx;
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
hid_t sid1 = -1;
|
2010-10-21 21:08:44 +08:00
|
|
|
int ret_value = SUCCEED;
|
2011-05-12 04:45:54 +08:00
|
|
|
h5tools_context_t ctx;
|
2009-09-15 03:52:42 +08:00
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
assert(info);
|
|
|
|
assert(cur_ctx);
|
|
|
|
assert(buffer);
|
|
|
|
assert(ptdata);
|
|
|
|
|
|
|
|
memset(&ctx, 0, sizeof(ctx));
|
2009-09-15 03:52:42 +08:00
|
|
|
/* Get the dataspace of the dataset */
|
|
|
|
if((sid1 = H5Dget_space(region_id)) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
|
|
|
|
|
|
|
|
/* Allocate space for the dimension array */
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
|
2009-09-15 03:52:42 +08:00
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
|
|
|
|
|
|
|
|
/* find the dimensions of each data space from the block coordinates */
|
|
|
|
numelem = 1;
|
|
|
|
for (jndx = 0; jndx < ndims; jndx++) {
|
|
|
|
dims1[jndx] = ptdata[jndx + ndims] - ptdata[jndx] + 1;
|
|
|
|
numelem = dims1[jndx] * numelem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create dataspace for reading buffer */
|
|
|
|
if((mem_space = H5Screate_simple(ndims, dims1, NULL)) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
|
|
|
|
|
|
|
|
if((type_size = H5Tget_size(type_id)) == 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
|
|
|
|
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
if((region_buf = HDmalloc(type_size * numelem)) == NULL)
|
2009-09-15 03:52:42 +08:00
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate region buffer");
|
|
|
|
|
|
|
|
/* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */
|
|
|
|
/* 1 2 n 1 2 n */
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
|
2009-09-15 03:52:42 +08:00
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start");
|
|
|
|
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
|
2009-09-15 03:52:42 +08:00
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count");
|
|
|
|
|
|
|
|
curr_pos = 0;
|
2011-05-12 04:45:54 +08:00
|
|
|
ctx.indent_level = cur_ctx->indent_level;
|
|
|
|
ctx.cur_column = cur_ctx->cur_column;
|
|
|
|
ctx.prev_multiline = cur_ctx->prev_multiline;
|
|
|
|
ctx.ndims = ndims;
|
2009-09-15 03:52:42 +08:00
|
|
|
for (blkndx = 0; blkndx < nblocks; blkndx++) {
|
|
|
|
ctx.need_prefix = TRUE;
|
|
|
|
ctx.cur_elmt = 0;
|
2011-05-12 04:45:54 +08:00
|
|
|
for (indx = 0; indx < ndims; indx++) {
|
|
|
|
start[indx] = ptdata[indx + blkndx * ndims * 2];
|
|
|
|
count[indx] = dims1[indx];
|
2009-09-15 03:52:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
|
|
|
|
|
|
|
|
if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dread failed");
|
|
|
|
|
|
|
|
ctx.indent_level++;
|
|
|
|
if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
/* assume entire data space to be printed */
|
2010-10-21 21:08:44 +08:00
|
|
|
for (indx = 0; indx < (size_t) ctx.ndims; indx++)
|
|
|
|
ctx.p_min_idx[indx] = start[indx];
|
2009-09-15 03:52:42 +08:00
|
|
|
init_acc_pos(&ctx, total_size);
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
/* print the data */
|
|
|
|
region_flags = START_OF_DATA;
|
|
|
|
if (blkndx == nblocks - 1)
|
|
|
|
region_flags |= END_OF_DATA;
|
|
|
|
|
2010-10-21 21:08:44 +08:00
|
|
|
for (indx = 0; indx < (size_t)ctx.ndims; indx++)
|
|
|
|
ctx.p_max_idx[indx] = dims1[indx];
|
2009-09-15 03:52:42 +08:00
|
|
|
|
|
|
|
curr_pos = 0;
|
|
|
|
ctx.sm_pos = blkndx*2*ndims;
|
|
|
|
ctx.size_last_dim = dims1[ndims-1];
|
|
|
|
|
|
|
|
h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0);
|
|
|
|
|
|
|
|
elmtno = 0;
|
2011-05-12 04:45:54 +08:00
|
|
|
for (jndx = 0; jndx < numelem; jndx++, elmtno++, ctx.cur_elmt++) {
|
2009-09-15 03:52:42 +08:00
|
|
|
/* Render the region data element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
h5tools_str_append(buffer, "%s", jndx ? OPTIONAL_LINE_BREAK "" : "");
|
2010-01-30 12:29:13 +08:00
|
|
|
h5tools_str_sprint(buffer, info, region_id, type_id,
|
2011-05-12 04:45:54 +08:00
|
|
|
((char*)region_buf + jndx * type_size), &ctx);
|
2009-09-15 03:52:42 +08:00
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
if (jndx + 1 < numelem || (region_flags & END_OF_DATA) == 0)
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ","));
|
|
|
|
|
|
|
|
dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos,
|
2011-05-12 04:45:54 +08:00
|
|
|
ncols, ptdata, jndx, elmtno);
|
2009-09-15 03:52:42 +08:00
|
|
|
/* Render the region data element end */
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if(FALSE == dimension_break)
|
|
|
|
elmtno = 0;
|
2011-05-12 04:45:54 +08:00
|
|
|
} /* end for (jndx = 0; jndx < numelem; jndx++, region_elmtno++, ctx.cur_elmt++) */
|
2009-09-15 03:52:42 +08:00
|
|
|
|
|
|
|
ctx.indent_level--;
|
|
|
|
} /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */
|
|
|
|
|
|
|
|
done:
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
HDfree(start);
|
|
|
|
HDfree(count);
|
|
|
|
HDfree(region_buf);
|
|
|
|
HDfree(dims1);
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Sclose(mem_space) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
|
|
|
|
if(H5Sclose(sid1) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print some values from a dataset referenced by region blocks.
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Description:
|
|
|
|
* This is a special case subfunction to dump a region reference using blocks.
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Return:
|
|
|
|
* The function returns False if the last dimension has been reached, otherwise True
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
|
|
|
* In/Out:
|
2009-09-04 22:50:13 +08:00
|
|
|
* h5tools_context_t *ctx
|
|
|
|
* hsize_t *curr_pos
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Parameters Description:
|
|
|
|
* h5tools_str_t *buffer is the string into which to render
|
|
|
|
* hsize_t curr_pos is the total data element position
|
|
|
|
* size_t ncols
|
|
|
|
* hsize_t region_elmt_counter is the region element loop counter
|
|
|
|
* hsize_t elmt_count is the data element loop counter
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
hbool_t
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
|
|
|
|
FILE *stream, const h5tool_format_t *info,
|
|
|
|
h5tools_context_t *ctx/*in,out*/,
|
|
|
|
h5tools_str_t *buffer/*string into which to render */,
|
|
|
|
hsize_t *curr_pos/*total data element position*/,
|
|
|
|
size_t ncols, hsize_t region_elmt_counter/*element counter*/,
|
2010-10-21 21:08:44 +08:00
|
|
|
hsize_t elmt_counter)
|
|
|
|
{
|
2009-09-15 03:52:42 +08:00
|
|
|
HERR_INIT(hbool_t, TRUE)
|
|
|
|
hbool_t dimension_break = TRUE;
|
|
|
|
hssize_t nblocks;
|
|
|
|
hsize_t alloc_size;
|
|
|
|
hsize_t *ptdata = NULL;
|
|
|
|
int ndims;
|
|
|
|
hid_t dtype;
|
|
|
|
hid_t type_id;
|
|
|
|
int i;
|
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
assert(info);
|
|
|
|
assert(ctx);
|
|
|
|
assert(buffer);
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if((nblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
|
|
|
|
H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* Print block information */
|
2009-09-15 03:52:42 +08:00
|
|
|
if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
|
|
|
|
H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Render the region { element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
|
|
|
|
h5tools_str_append(buffer, "{");
|
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the region { element end */
|
|
|
|
|
|
|
|
/* Render the region datatype info and indices element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
|
|
|
|
ctx->indent_level++;
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
h5tools_str_append(buffer, "REGION_TYPE BLOCK ");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
|
|
|
|
assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
|
2009-09-15 03:52:42 +08:00
|
|
|
if((ptdata = (hsize_t*) malloc((size_t) alloc_size)) == NULL)
|
|
|
|
HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t);
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0)
|
|
|
|
HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
for (i = 0; i < nblocks; i++) {
|
|
|
|
int j;
|
|
|
|
|
|
|
|
h5tools_str_append(buffer, info->dset_blockformat_pre,
|
|
|
|
i ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long) i);
|
|
|
|
|
|
|
|
/* Start coordinates and opposite corner */
|
|
|
|
for (j = 0; j < ndims; j++)
|
|
|
|
h5tools_str_append(buffer, "%s%lu", j ? "," : "(",
|
|
|
|
(unsigned long) ptdata[i * 2 * ndims + j]);
|
|
|
|
|
|
|
|
for (j = 0; j < ndims; j++)
|
|
|
|
h5tools_str_append(buffer, "%s%lu", j ? "," : ")-(",
|
|
|
|
(unsigned long) ptdata[i * 2 * ndims + j + ndims]);
|
|
|
|
|
|
|
|
h5tools_str_append(buffer, ")");
|
|
|
|
} /* end for (i = 0; i < nblocks; i++) */
|
|
|
|
|
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the region datatype info and indices element end */
|
|
|
|
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if((dtype = H5Dget_type(region_id)) < 0)
|
|
|
|
HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Dget_type failed");
|
|
|
|
if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
|
|
|
|
HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Tget_native_type failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* Render the datatype element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "%s %s ",
|
|
|
|
h5tools_dump_header_format->datatypebegin,
|
|
|
|
h5tools_dump_header_format->datatypeblockbegin);
|
|
|
|
|
|
|
|
h5tools_print_datatype(buffer, info, ctx, dtype);
|
|
|
|
|
|
|
|
if (HDstrlen(h5tools_dump_header_format->datatypeblockend)) {
|
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeblockend);
|
|
|
|
if (HDstrlen(h5tools_dump_header_format->datatypeend))
|
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
|
|
|
if (HDstrlen(h5tools_dump_header_format->datatypeend))
|
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeend);
|
[svn-r14437] bug fix for h5dump subsetting (deal with blocks)and new test runs
add a check for block overlap after the command line parsing
* Algorithm
*
* In a inner loop, the parameters from SSET are translated into temporary
* variables so that 1 row is printed at a time (getting the coordinate indices
* at each row).
* We define the stride, count and block to be 1 in the row dimension to achieve
* this and advance until all points are printed.
* An outer loop for cases where dimensionality is greater than 2D is made.
* In each iteration, the 2D block is displayed in the inner loop. The remaining
* slower dimensions above the first 2 are incremented one at a time in the outer loop
*
* The element position is obtained from the matrix according to:
* Given an index I(z,y,x) its position from the beginning of an array
* of sizes A(size_z, size_y,size_x) is given by
* Position of I(z,y,x) = index_z * size_y * size_x
* + index_y * size_x
* + index_x
*
tested: windows, linux
2008-01-17 00:12:08 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the datatype element end */
|
[svn-r14437] bug fix for h5dump subsetting (deal with blocks)and new test runs
add a check for block overlap after the command line parsing
* Algorithm
*
* In a inner loop, the parameters from SSET are translated into temporary
* variables so that 1 row is printed at a time (getting the coordinate indices
* at each row).
* We define the stride, count and block to be 1 in the row dimension to achieve
* this and advance until all points are printed.
* An outer loop for cases where dimensionality is greater than 2D is made.
* In each iteration, the 2D block is displayed in the inner loop. The remaining
* slower dimensions above the first 2 are incremented one at a time in the outer loop
*
* The element position is obtained from the matrix according to:
* Given an index I(z,y,x) its position from the beginning of an array
* of sizes A(size_z, size_y,size_x) is given by
* Position of I(z,y,x) = index_z * size_y * size_x
* + index_y * size_x
* + index_x
*
tested: windows, linux
2008-01-17 00:12:08 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->need_prefix = TRUE;
|
[svn-r14437] bug fix for h5dump subsetting (deal with blocks)and new test runs
add a check for block overlap after the command line parsing
* Algorithm
*
* In a inner loop, the parameters from SSET are translated into temporary
* variables so that 1 row is printed at a time (getting the coordinate indices
* at each row).
* We define the stride, count and block to be 1 in the row dimension to achieve
* this and advance until all points are printed.
* An outer loop for cases where dimensionality is greater than 2D is made.
* In each iteration, the 2D block is displayed in the inner loop. The remaining
* slower dimensions above the first 2 are incremented one at a time in the outer loop
*
* The element position is obtained from the matrix according to:
* Given an index I(z,y,x) its position from the beginning of an array
* of sizes A(size_z, size_y,size_x) is given by
* Position of I(z,y,x) = index_z * size_y * size_x
* + index_y * size_x
* + index_x
*
tested: windows, linux
2008-01-17 00:12:08 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Render the dataspace element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin);
|
[svn-r14437] bug fix for h5dump subsetting (deal with blocks)and new test runs
add a check for block overlap after the command line parsing
* Algorithm
*
* In a inner loop, the parameters from SSET are translated into temporary
* variables so that 1 row is printed at a time (getting the coordinate indices
* at each row).
* We define the stride, count and block to be 1 in the row dimension to achieve
* this and advance until all points are printed.
* An outer loop for cases where dimensionality is greater than 2D is made.
* In each iteration, the 2D block is displayed in the inner loop. The remaining
* slower dimensions above the first 2 are incremented one at a time in the outer loop
*
* The element position is obtained from the matrix according to:
* Given an index I(z,y,x) its position from the beginning of an array
* of sizes A(size_z, size_y,size_x) is given by
* Position of I(z,y,x) = index_z * size_y * size_x
* + index_y * size_x
* + index_x
*
tested: windows, linux
2008-01-17 00:12:08 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_print_dataspace(buffer, region_space);
|
[svn-r14437] bug fix for h5dump subsetting (deal with blocks)and new test runs
add a check for block overlap after the command line parsing
* Algorithm
*
* In a inner loop, the parameters from SSET are translated into temporary
* variables so that 1 row is printed at a time (getting the coordinate indices
* at each row).
* We define the stride, count and block to be 1 in the row dimension to achieve
* this and advance until all points are printed.
* An outer loop for cases where dimensionality is greater than 2D is made.
* In each iteration, the 2D block is displayed in the inner loop. The remaining
* slower dimensions above the first 2 are incremented one at a time in the outer loop
*
* The element position is obtained from the matrix according to:
* Given an index I(z,y,x) its position from the beginning of an array
* of sizes A(size_z, size_y,size_x) is given by
* Position of I(z,y,x) = index_z * size_y * size_x
* + index_y * size_x
* + index_x
*
tested: windows, linux
2008-01-17 00:12:08 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (HDstrlen(h5tools_dump_header_format->dataspaceblockend)) {
|
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
|
|
|
|
if (HDstrlen(h5tools_dump_header_format->dataspaceend))
|
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
|
|
|
if (HDstrlen(h5tools_dump_header_format->dataspaceend))
|
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
|
[svn-r14437] bug fix for h5dump subsetting (deal with blocks)and new test runs
add a check for block overlap after the command line parsing
* Algorithm
*
* In a inner loop, the parameters from SSET are translated into temporary
* variables so that 1 row is printed at a time (getting the coordinate indices
* at each row).
* We define the stride, count and block to be 1 in the row dimension to achieve
* this and advance until all points are printed.
* An outer loop for cases where dimensionality is greater than 2D is made.
* In each iteration, the 2D block is displayed in the inner loop. The remaining
* slower dimensions above the first 2 are incremented one at a time in the outer loop
*
* The element position is obtained from the matrix according to:
* Given an index I(z,y,x) its position from the beginning of an array
* of sizes A(size_z, size_y,size_x) is given by
* Position of I(z,y,x) = index_z * size_y * size_x
* + index_y * size_x
* + index_x
*
tested: windows, linux
2008-01-17 00:12:08 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the dataspace element end */
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->need_prefix = TRUE;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Render the databegin element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_str_append(buffer, "%s %s ",
|
|
|
|
h5tools_dump_header_format->databegin,
|
|
|
|
h5tools_dump_header_format->datablockbegin);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the databegin element end */
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->need_prefix = TRUE;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
h5tools_print_region_data_blocks(region_id, rawdatastream, info, ctx,
|
2010-08-13 05:11:00 +08:00
|
|
|
buffer, ncols, ndims, type_id, nblocks, ptdata);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
done:
|
2009-09-04 22:50:13 +08:00
|
|
|
free(ptdata);
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-10-02 00:17:17 +08:00
|
|
|
if(H5Tclose(type_id) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Tclose(dtype) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
|
|
|
|
/* Render the dataend element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "%s %s ",
|
|
|
|
h5tools_dump_header_format->dataend,
|
|
|
|
h5tools_dump_header_format->datablockend);
|
2010-01-30 12:29:13 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos,
|
2009-09-04 22:50:13 +08:00
|
|
|
ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the dataend element end */
|
|
|
|
|
|
|
|
ctx->indent_level--;
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
|
|
|
|
/* Render the region } element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "}");
|
2010-01-30 12:29:13 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos,
|
2009-09-04 22:50:13 +08:00
|
|
|
ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the region } element end */
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
H5_LEAVE(dimension_break)
|
2009-09-15 05:48:32 +08:00
|
|
|
|
|
|
|
CATCH
|
2009-09-15 03:52:42 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print the data values from a dataset referenced by region points.
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-15 03:52:42 +08:00
|
|
|
* Description:
|
|
|
|
* This is a special case subfunction to print the data in a region reference of type points.
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-15 03:52:42 +08:00
|
|
|
* Return:
|
|
|
|
* The function returns FAIL on error, otherwise SUCCEED
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-15 03:52:42 +08:00
|
|
|
* Parameters Description:
|
|
|
|
* h5tools_str_t *buffer is the string into which to render
|
|
|
|
* size_t ncols
|
|
|
|
* int ndims is the number of dimensions of the region element
|
|
|
|
* hssize_t npoints is the number of points in the region
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
int
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
|
2011-05-12 04:45:54 +08:00
|
|
|
FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
|
2010-01-30 12:29:13 +08:00
|
|
|
h5tools_str_t *buffer, size_t ncols,
|
2010-08-13 05:11:00 +08:00
|
|
|
int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata)
|
|
|
|
{
|
2009-09-15 03:52:42 +08:00
|
|
|
hbool_t dimension_break = TRUE;
|
|
|
|
hsize_t *dims1 = NULL;
|
|
|
|
hsize_t elmtno; /* elemnt index */
|
|
|
|
unsigned int region_flags; /* buffer extent flags */
|
|
|
|
hsize_t curr_pos;
|
2011-05-12 04:45:54 +08:00
|
|
|
hsize_t total_size[H5S_MAX_RANK];
|
|
|
|
int indx;
|
|
|
|
size_t jndx;
|
2009-09-15 03:52:42 +08:00
|
|
|
int type_size;
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
hid_t mem_space = -1;
|
2009-09-15 03:52:42 +08:00
|
|
|
void *region_buf = NULL;
|
2010-10-21 21:08:44 +08:00
|
|
|
int ret_value = SUCCEED;
|
2011-05-12 04:45:54 +08:00
|
|
|
h5tools_context_t ctx;
|
2011-05-10 21:52:13 +08:00
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
assert(info);
|
|
|
|
assert(cur_ctx);
|
|
|
|
assert(buffer);
|
|
|
|
assert(ptdata);
|
2009-09-15 03:52:42 +08:00
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
memset(&ctx, 0, sizeof(ctx));
|
2009-09-15 03:52:42 +08:00
|
|
|
/* Allocate space for the dimension array */
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
|
2009-09-15 03:52:42 +08:00
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
|
|
|
|
|
|
|
|
dims1[0] = npoints;
|
2011-05-12 04:45:54 +08:00
|
|
|
|
|
|
|
/* Create dataspace for reading buffer */
|
2009-09-15 03:52:42 +08:00
|
|
|
if((mem_space = H5Screate_simple(1, dims1, NULL)) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
|
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
if((type_size = H5Tget_size(type_id)) == 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
|
|
|
|
|
|
|
|
if((region_buf = HDmalloc(type_size * npoints)) == NULL)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for region");
|
|
|
|
|
|
|
|
curr_pos = 0;
|
|
|
|
ctx.indent_level = cur_ctx->indent_level;
|
|
|
|
ctx.cur_column = cur_ctx->cur_column;
|
|
|
|
ctx.prev_multiline = cur_ctx->prev_multiline;
|
|
|
|
ctx.ndims = ndims;
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
|
|
|
|
|
|
|
|
elmtno = 0;
|
|
|
|
for (jndx = 0; jndx < npoints; jndx++, elmtno++) {
|
|
|
|
ctx.need_prefix = TRUE;
|
|
|
|
ctx.cur_elmt = 0; /* points are always 0 */
|
|
|
|
|
|
|
|
ctx.indent_level++;
|
2011-05-12 04:45:54 +08:00
|
|
|
if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
|
2009-09-15 03:52:42 +08:00
|
|
|
|
|
|
|
/* assume entire data space to be printed */
|
|
|
|
for (indx = 0; indx < (size_t) ctx.ndims; indx++)
|
|
|
|
ctx.p_min_idx[indx] = 0;
|
2011-05-12 04:45:54 +08:00
|
|
|
init_acc_pos(&ctx, total_size);
|
2009-09-15 03:52:42 +08:00
|
|
|
|
|
|
|
/* print the data */
|
|
|
|
region_flags = START_OF_DATA;
|
|
|
|
if (jndx == npoints - 1)
|
|
|
|
region_flags |= END_OF_DATA;
|
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
for (indx = 0; indx < (size_t)ctx.ndims; indx++)
|
|
|
|
ctx.p_max_idx[indx] = cur_ctx->p_max_idx[indx];
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
ctx.sm_pos = jndx * ndims;
|
2011-05-12 04:45:54 +08:00
|
|
|
if (ctx.ndims > 0) {
|
|
|
|
ctx.size_last_dim = (int) (ctx.p_max_idx[ctx.ndims - 1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ctx.size_last_dim = 0;
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
curr_pos = 0; /* points requires constant 0 */
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0);
|
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
/* Render the point element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
|
|
|
|
h5tools_str_append(buffer, "%s", jndx ? OPTIONAL_LINE_BREAK "" : "");
|
2010-01-30 12:29:13 +08:00
|
|
|
h5tools_str_sprint(buffer, info, region_id, type_id,
|
2009-09-15 03:52:42 +08:00
|
|
|
((char*)region_buf + jndx * type_size), &ctx);
|
|
|
|
|
2011-05-10 21:52:13 +08:00
|
|
|
if (jndx + 1 < npoints || (region_flags & END_OF_DATA) == 0)
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ","));
|
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos,
|
|
|
|
ncols, ptdata, (hsize_t)0, elmtno);
|
2009-09-15 03:52:42 +08:00
|
|
|
/* Render the point element end */
|
2011-05-10 21:52:13 +08:00
|
|
|
if(FALSE == dimension_break)
|
|
|
|
elmtno = 0;
|
2011-05-12 04:45:54 +08:00
|
|
|
|
|
|
|
ctx.indent_level--;
|
|
|
|
} /* end for (jndx = 0; jndx < npoints; jndx++, elmtno++) */
|
2009-09-15 03:52:42 +08:00
|
|
|
|
|
|
|
done:
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
HDfree(region_buf);
|
|
|
|
HDfree(dims1);
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Sclose(mem_space) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
|
2010-10-21 21:08:44 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
return ret_value;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print some values from a dataset referenced by region points.
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Description:
|
|
|
|
* This is a special case subfunction to dump a region reference using points.
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Return:
|
|
|
|
* The function returns False if the last dimension has been reached, otherwise True
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
|
|
|
* In/Out:
|
2009-09-04 22:50:13 +08:00
|
|
|
* h5tools_context_t *ctx
|
|
|
|
* hsize_t *curr_pos
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Parameters Description:
|
|
|
|
* h5tools_str_t *buffer is the string into which to render
|
|
|
|
* hsize_t curr_pos is the total data element position
|
|
|
|
* size_t ncols
|
|
|
|
* hsize_t region_elmt_counter is the region element loop counter
|
|
|
|
* hsize_t elmt_count is the data element loop counter
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
hbool_t
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
|
2010-01-30 12:29:13 +08:00
|
|
|
FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter,
|
|
|
|
hsize_t elmt_counter) {
|
2009-09-15 03:52:42 +08:00
|
|
|
HERR_INIT(hbool_t, TRUE)
|
2009-09-08 22:51:59 +08:00
|
|
|
hbool_t dimension_break = TRUE;
|
2009-09-04 22:50:13 +08:00
|
|
|
hssize_t npoints;
|
2009-09-08 22:51:59 +08:00
|
|
|
hsize_t alloc_size;
|
2009-09-04 22:50:13 +08:00
|
|
|
hsize_t *ptdata;
|
2009-09-08 22:51:59 +08:00
|
|
|
int ndims;
|
2010-10-21 21:08:44 +08:00
|
|
|
hssize_t indx;
|
2009-09-08 22:51:59 +08:00
|
|
|
hid_t dtype;
|
|
|
|
hid_t type_id;
|
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
assert(info);
|
|
|
|
assert(ctx);
|
|
|
|
assert(buffer);
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if((npoints = H5Sget_select_elem_npoints(region_space)) <= 0)
|
|
|
|
H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed");
|
|
|
|
|
|
|
|
/* Allocate space for the dimension array */
|
|
|
|
if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
|
|
|
|
H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
|
2008-01-11 05:31:28 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
/* Render the region { element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2008-01-11 05:31:28 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
h5tools_str_append(buffer, "{");
|
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the region { element end */
|
2007-01-11 03:15:16 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
/* Render the region datatype info and indices element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
ctx->indent_level++;
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
h5tools_str_append(buffer, "REGION_TYPE POINT ");
|
2008-01-15 04:16:40 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
alloc_size = npoints * ndims * sizeof(ptdata[0]);
|
|
|
|
assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
|
2010-10-21 21:08:44 +08:00
|
|
|
if(NULL == (ptdata = (hsize_t *)HDmalloc((size_t) alloc_size)))
|
2009-09-15 03:52:42 +08:00
|
|
|
HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
|
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
H5_CHECK_OVERFLOW(npoints, hssize_t, hsize_t);
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Sget_select_elem_pointlist(region_space, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0)
|
|
|
|
HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Sget_select_elem_pointlist failed");
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
for (indx = 0; indx < npoints; indx++) {
|
|
|
|
int loop_indx;
|
2008-01-15 04:16:40 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
h5tools_str_append(buffer, info->dset_ptformat_pre,
|
|
|
|
indx ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long) indx);
|
2008-01-15 04:16:40 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
for (loop_indx = 0; loop_indx < ndims; loop_indx++)
|
|
|
|
h5tools_str_append(buffer, "%s%lu", loop_indx ? "," : "(",
|
|
|
|
(unsigned long) (ptdata[indx * ndims + loop_indx]));
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
h5tools_str_append(buffer, ")");
|
|
|
|
} /* end for (indx = 0; indx < npoints; indx++) */
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the region datatype info and indices element end */
|
2001-03-16 03:31:40 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
ctx->need_prefix = TRUE;
|
2008-01-11 05:31:28 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if((dtype = H5Dget_type(region_id)) < 0)
|
|
|
|
HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Dget_type failed");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
|
|
|
|
HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Tget_native_type failed");
|
2008-01-11 05:31:28 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
/* Render the datatype element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "%s %s ",
|
|
|
|
h5tools_dump_header_format->datatypebegin,
|
|
|
|
h5tools_dump_header_format->datatypeblockbegin);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
h5tools_print_datatype(buffer, info, ctx, dtype);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
if (HDstrlen(h5tools_dump_header_format->datatypeblockend)) {
|
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeblockend);
|
2009-09-04 22:50:13 +08:00
|
|
|
if (HDstrlen(h5tools_dump_header_format->datatypeend))
|
2009-09-08 22:51:59 +08:00
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
|
|
|
if (HDstrlen(h5tools_dump_header_format->datatypeend))
|
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeend);
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the datatype element end */
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
ctx->need_prefix = TRUE;
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
/* Render the dataspace element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin);
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_print_dataspace(buffer, region_space);
|
2009-09-08 22:51:59 +08:00
|
|
|
|
|
|
|
if (HDstrlen(h5tools_dump_header_format->dataspaceblockend)) {
|
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
|
2009-09-04 22:50:13 +08:00
|
|
|
if (HDstrlen(h5tools_dump_header_format->dataspaceend))
|
2009-09-08 22:51:59 +08:00
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
|
|
|
if (HDstrlen(h5tools_dump_header_format->dataspaceend))
|
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the dataspace element end */
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
ctx->need_prefix = TRUE;
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
/* Render the databegin element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
h5tools_str_append(buffer, "%s %s ",
|
|
|
|
h5tools_dump_header_format->databegin,
|
|
|
|
h5tools_dump_header_format->datablockbegin);
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the databegin element end */
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-08 22:51:59 +08:00
|
|
|
ctx->need_prefix = TRUE;
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_print_region_data_points(region_space, region_id,
|
2011-05-12 04:45:54 +08:00
|
|
|
rawdatastream, info, ctx, buffer, ncols, ndims, type_id, npoints, ptdata);
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
done:
|
2009-09-08 22:51:59 +08:00
|
|
|
free(ptdata);
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-10-02 00:17:17 +08:00
|
|
|
if(H5Tclose(type_id) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
2009-09-15 03:52:42 +08:00
|
|
|
|
|
|
|
if(H5Tclose(dtype) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
2009-09-08 22:51:59 +08:00
|
|
|
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
|
|
|
|
/* Render the dataend element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "%s %s ",
|
|
|
|
h5tools_dump_header_format->dataend,
|
|
|
|
h5tools_dump_header_format->datablockend);
|
2010-01-30 12:29:13 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos,
|
2009-09-08 22:51:59 +08:00
|
|
|
ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the dataend element end*/
|
|
|
|
|
|
|
|
ctx->indent_level--;
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
|
|
|
|
/* Render the region } element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "}");
|
2010-01-30 12:29:13 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos,
|
2009-09-08 22:51:59 +08:00
|
|
|
ncols, region_elmt_counter, elmt_counter);
|
|
|
|
/* Render the region } element end */
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
H5_LEAVE(dimension_break)
|
|
|
|
CATCH
|
|
|
|
return ret_value;
|
2001-03-09 04:21:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
2009-09-15 03:52:42 +08:00
|
|
|
* Purpose: print out the data for a subset of a dataset.
|
2001-04-11 03:54:08 +08:00
|
|
|
* Description:
|
2009-09-04 22:50:13 +08:00
|
|
|
*
|
|
|
|
* Select a hyperslab from the dataset DSET using the parameters
|
|
|
|
* specified in SSET. Dump this out to STREAM.
|
|
|
|
*
|
|
|
|
* Hyperslabs select "count" blocks of size "block", spaced "stride" elements
|
|
|
|
* from each other, starting at coordinate "start".
|
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Return:
|
2009-09-04 22:50:13 +08:00
|
|
|
* On success, return SUCCEED. Otherwise, the function returns FAIL.
|
|
|
|
*
|
|
|
|
* Algorithm
|
|
|
|
*
|
2009-09-15 03:52:42 +08:00
|
|
|
* The parameters from SSET are translated into temporary
|
2009-09-04 22:50:13 +08:00
|
|
|
* variables so that 1 row is printed at a time (getting the coordinate indices
|
|
|
|
* at each row).
|
|
|
|
* We define the stride, count and block to be 1 in the row dimension to achieve
|
|
|
|
* this and advance until all points are printed.
|
|
|
|
*
|
|
|
|
* The element position is obtained from the matrix according to:
|
|
|
|
* Given an index I(z,y,x) its position from the beginning of an array
|
|
|
|
* of sizes A(size_z, size_y,size_x) is given by
|
|
|
|
* Position of I(z,y,x) = index_z * size_y * size_x
|
|
|
|
* + index_y * size_x
|
|
|
|
* + index_x
|
|
|
|
*
|
2001-03-09 04:21:05 +08:00
|
|
|
*-------------------------------------------------------------------------
|
2005-08-14 04:53:35 +08:00
|
|
|
*/
|
2009-09-04 22:50:13 +08:00
|
|
|
static herr_t
|
2010-01-30 12:29:13 +08:00
|
|
|
h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
|
2009-09-15 03:52:42 +08:00
|
|
|
hid_t dset, hid_t p_type, struct subset_t *sset,
|
|
|
|
hid_t f_space, hsize_t hyperslab_count,
|
|
|
|
hsize_t *temp_start,/* start inside offset count loop */
|
|
|
|
hsize_t *temp_count,/* count inside offset count loop */
|
|
|
|
hsize_t *temp_block,/* block size used in loop */
|
|
|
|
hsize_t *temp_stride,/* stride size used in loop */
|
|
|
|
hsize_t *total_size,/* total size of dataset */
|
|
|
|
unsigned int row_dim/* index of row_counter dimension */)
|
2001-03-09 04:21:05 +08:00
|
|
|
{
|
2009-09-18 04:31:44 +08:00
|
|
|
HERR_INIT(herr_t, SUCCEED)
|
2009-09-04 22:50:13 +08:00
|
|
|
size_t i; /* counters */
|
|
|
|
size_t j; /* counters */
|
2010-10-21 21:08:44 +08:00
|
|
|
hsize_t zero[1] = {0}; /* vector of zeros */
|
2009-09-04 22:50:13 +08:00
|
|
|
unsigned int flags; /* buffer extent flags */
|
|
|
|
hsize_t elmtno; /* elemnt index */
|
|
|
|
hsize_t low[H5S_MAX_RANK]; /* low bound of hyperslab */
|
|
|
|
hsize_t high[H5S_MAX_RANK]; /* higher bound of hyperslab */
|
|
|
|
size_t p_type_nbytes; /* size of memory type */
|
|
|
|
hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
|
|
|
|
hsize_t sm_nbytes; /* bytes per stripmine */
|
2011-04-13 00:59:33 +08:00
|
|
|
hssize_t ssm_nelmts; /* elements per stripmine*/
|
2009-09-04 22:50:13 +08:00
|
|
|
hsize_t sm_nelmts; /* elements per stripmine*/
|
2009-09-15 03:52:42 +08:00
|
|
|
unsigned char *sm_buf = NULL; /* buffer for raw data */
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
hid_t sm_space = -1; /* stripmine data space */
|
2009-09-15 03:52:42 +08:00
|
|
|
hsize_t size_row_block; /* size for blocks along rows */
|
|
|
|
hsize_t row_counter = 0;
|
|
|
|
|
2011-03-10 04:00:20 +08:00
|
|
|
/* VL data special information */
|
|
|
|
unsigned int vl_data = 0; /* contains VL datatypes */
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if ((size_t) ctx->ndims > NELMTS(sm_size))
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "ndims and sm_size comparision failed");
|
|
|
|
|
|
|
|
if (ctx->ndims > 0)
|
|
|
|
init_acc_pos(ctx, total_size);
|
|
|
|
|
2010-08-20 03:55:48 +08:00
|
|
|
size_row_block = sset->block.data[row_dim];
|
2009-09-15 03:52:42 +08:00
|
|
|
|
2011-03-10 04:00:20 +08:00
|
|
|
/* Check if we have VL data in the dataset's datatype */
|
2011-03-15 05:03:20 +08:00
|
|
|
if (h5tools_detect_vlen_str(p_type) == TRUE)
|
|
|
|
vl_data = TRUE;
|
|
|
|
if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE)
|
2011-03-10 04:00:20 +08:00
|
|
|
vl_data = TRUE;
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
/* display loop */
|
|
|
|
for (; hyperslab_count > 0; temp_start[row_dim] += temp_stride[row_dim], hyperslab_count--) {
|
|
|
|
/* jump rows if size of block exceeded
|
|
|
|
cases where block > 1 only and stride > block */
|
2010-01-30 12:29:13 +08:00
|
|
|
if (size_row_block > 1
|
2009-09-15 03:52:42 +08:00
|
|
|
&& row_counter == size_row_block
|
2010-08-20 03:55:48 +08:00
|
|
|
&& sset->stride.data[row_dim] > sset->block.data[row_dim]) {
|
2009-09-15 03:52:42 +08:00
|
|
|
|
2010-08-20 03:55:48 +08:00
|
|
|
hsize_t increase_rows = sset->stride.data[row_dim] - sset->block.data[row_dim];
|
2009-09-15 03:52:42 +08:00
|
|
|
temp_start[row_dim] += increase_rows;
|
|
|
|
row_counter = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
row_counter++;
|
|
|
|
|
|
|
|
/* calculate the potential number of elements we're going to print */
|
|
|
|
if(H5Sselect_hyperslab(f_space, H5S_SELECT_SET, temp_start, temp_stride, temp_count, temp_block) < 0)
|
2009-12-13 13:28:30 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2011-04-13 00:59:33 +08:00
|
|
|
if((ssm_nelmts = H5Sget_select_npoints(f_space)) < 0)
|
2009-12-13 13:28:30 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_npoints failed");
|
2011-04-13 00:59:33 +08:00
|
|
|
sm_nelmts = (hsize_t)ssm_nelmts;
|
2009-09-15 03:52:42 +08:00
|
|
|
|
|
|
|
if (sm_nelmts > 0) {
|
|
|
|
/*
|
|
|
|
* determine the strip mine size and allocate a buffer. the strip mine is
|
|
|
|
* a hyperslab whose size is manageable.
|
|
|
|
*/
|
|
|
|
if((sm_nbytes = p_type_nbytes = H5Tget_size(p_type)) == 0)
|
2009-12-13 13:28:30 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if (ctx->ndims > 0)
|
|
|
|
for (i = ctx->ndims; i > 0; --i) {
|
|
|
|
hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes;
|
|
|
|
if (size == 0) /* datum size > H5TOOLS_BUFSIZE */
|
|
|
|
size = 1;
|
|
|
|
sm_size[i - 1] = MIN(total_size[i - 1], size);
|
|
|
|
sm_nbytes *= sm_size[i - 1];
|
|
|
|
assert(sm_nbytes > 0);
|
|
|
|
}
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
assert(sm_nbytes == (hsize_t) ((size_t) sm_nbytes)); /*check for overflow*/
|
2010-10-21 21:08:44 +08:00
|
|
|
if(NULL == (sm_buf = (unsigned char *)HDmalloc((size_t) sm_nelmts * p_type_nbytes)))
|
2009-12-13 13:28:30 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for strip-mine");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0)
|
2009-12-13 13:28:30 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2010-10-21 21:08:44 +08:00
|
|
|
if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &sm_nelmts, NULL) < 0)
|
2009-12-13 13:28:30 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
/* read the data */
|
2009-12-13 13:28:30 +08:00
|
|
|
if(H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dread failed");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
/* print the data */
|
|
|
|
flags = START_OF_DATA;
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if (hyperslab_count == 1)
|
|
|
|
flags |= END_OF_DATA;
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
for (i = 0; i < ctx->ndims; i++)
|
|
|
|
ctx->p_max_idx[i] = ctx->p_min_idx[i] + MIN(total_size[i], sm_size[i]);
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
/* print array indices. get the lower bound of the hyperslab and calulate
|
|
|
|
the element position at the start of hyperslab */
|
|
|
|
if(H5Sget_select_bounds(f_space, low, high) < 0)
|
2009-12-13 13:28:30 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_bounds failed");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
elmtno = 0;
|
|
|
|
for (i = 0; i < (size_t) ctx->ndims - 1; i++) {
|
|
|
|
hsize_t offset = 1; /* accumulation of the previous dimensions */
|
|
|
|
for (j = i + 1; j < (size_t) ctx->ndims; j++)
|
|
|
|
offset *= total_size[j];
|
|
|
|
elmtno += low[i] * offset;
|
|
|
|
}
|
|
|
|
elmtno += low[ctx->ndims - 1];
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
/* initialize the current stripmine position; this is necessary to print the array
|
|
|
|
indices */
|
|
|
|
ctx->sm_pos = elmtno;
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_dump_simple_data(stream, info, dset, ctx, flags, sm_nelmts, p_type, sm_buf);
|
2009-12-13 13:28:30 +08:00
|
|
|
|
2011-03-10 04:00:20 +08:00
|
|
|
/* Reclaim any VL memory, if necessary */
|
|
|
|
if (vl_data)
|
|
|
|
H5Dvlen_reclaim(p_type, sm_space, H5P_DEFAULT, sm_buf);
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Sclose(sm_space) < 0)
|
2009-12-13 13:28:30 +08:00
|
|
|
H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
|
|
|
|
if(sm_buf)
|
|
|
|
HDfree(sm_buf);
|
[svn-r18109] Description:
Bring r18076-18096 from hdf5_1_8_coverity branch to trunk:
r18076:
Correct Coverity issue #1 by removing dead code
r18077:
Fix coverity item 142. When an error occurred while copying a linked list in
H5S_point_copy, the library would not free the partially allocated list. Added
code to free the list in this case.
r18078:
Correct Coverity issue #2 by removing impossible to reach code.
r18079:
Correct #3 by removing impossible to reach code.
r18080:
Correct Coverity issue #4 by removing impossible to reach code.
r18081:
fix coverity 26 , check (dblik->parent) before calls H5HF_man_iblock_detach().
r18082:
Fixed coverity issues 321 and 316.
321: freed sm_buf in error handling to remove resource leak.
Also set sm_buf to NULL after other instances in which
it is freed to prevent double free.
316: initialized nmembs to 0.
r18083:
Correct Coverity issue #6 by removing debugging knob from error reporting code.
r18084:
Fix coverity item 269 + others. When a error occurred in a function using the
h5tools error framework, the "past_catch" variable would not be set to true
because that statement was before the label that goto jumped to. This could
cause a failure in the cleanup section to go back to the start of the section,
freeing variables twice, etc.
Moved the label infront of past_catch=TRUE.
r18085:
fixed coverity #27, check if (heap) before use heap->obj....
r18086:
fixed coverity #28, check curr_span not null before use it at if(curr_span &&
(io_bytes_left==0 || curr_seq>=maxseq))
r18087:
Correct Coverity issue #7 by cleaning up correctly on error
r18088:
Correct Coverity #8 by removing unchanged variable checking code.
r18089:
Correct Coverity issue #9 - remove impossible to reach code.
r18090:
Correct Coverity issue #11 by removing impossible to reach code. Also clean
up some minor style issues.
r18091:
Fix coverity items 314 and 318. Changed the improper assertion of the return
value of a library function to a check, and a return(void) on failure.
r18092:
Fix coverity item 70. Changed the improper assertion of the return value of a
library function to a check, and a return(void) on failure.
r18093:
Correct Coverity issue #12 by removing dead code.
r18094:
Correct Coverity issue #16 by removing debugging code.
r18095:
Fixed coverity issue # 271.
Removed redundant checking and freeing of sm_buf1 and sm_buf2.
r18096:
Correct Coverity issue #17 by refactoring test to remove dead code.
Also, removed previous "coverity" statements in comments, we'll review
those issues again and see if we can figure them out, now that we have more
experience with Coverity.
Tested on:
Mac OS X/32 10.6.2 (amazon)
2010-01-15 11:05:59 +08:00
|
|
|
sm_buf = NULL;
|
2009-09-15 03:52:42 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
H5E_THROW(SUCCEED, H5E_tools_min_id_g, "nothing to print");
|
|
|
|
/* we need to jump to next line and update the index */
|
|
|
|
ctx->need_prefix = 1;
|
|
|
|
|
|
|
|
ctx->continuation++;
|
|
|
|
|
|
|
|
} /* hyperslab_count loop */
|
|
|
|
|
|
|
|
CATCH
|
[svn-r18109] Description:
Bring r18076-18096 from hdf5_1_8_coverity branch to trunk:
r18076:
Correct Coverity issue #1 by removing dead code
r18077:
Fix coverity item 142. When an error occurred while copying a linked list in
H5S_point_copy, the library would not free the partially allocated list. Added
code to free the list in this case.
r18078:
Correct Coverity issue #2 by removing impossible to reach code.
r18079:
Correct #3 by removing impossible to reach code.
r18080:
Correct Coverity issue #4 by removing impossible to reach code.
r18081:
fix coverity 26 , check (dblik->parent) before calls H5HF_man_iblock_detach().
r18082:
Fixed coverity issues 321 and 316.
321: freed sm_buf in error handling to remove resource leak.
Also set sm_buf to NULL after other instances in which
it is freed to prevent double free.
316: initialized nmembs to 0.
r18083:
Correct Coverity issue #6 by removing debugging knob from error reporting code.
r18084:
Fix coverity item 269 + others. When a error occurred in a function using the
h5tools error framework, the "past_catch" variable would not be set to true
because that statement was before the label that goto jumped to. This could
cause a failure in the cleanup section to go back to the start of the section,
freeing variables twice, etc.
Moved the label infront of past_catch=TRUE.
r18085:
fixed coverity #27, check if (heap) before use heap->obj....
r18086:
fixed coverity #28, check curr_span not null before use it at if(curr_span &&
(io_bytes_left==0 || curr_seq>=maxseq))
r18087:
Correct Coverity issue #7 by cleaning up correctly on error
r18088:
Correct Coverity #8 by removing unchanged variable checking code.
r18089:
Correct Coverity issue #9 - remove impossible to reach code.
r18090:
Correct Coverity issue #11 by removing impossible to reach code. Also clean
up some minor style issues.
r18091:
Fix coverity items 314 and 318. Changed the improper assertion of the return
value of a library function to a check, and a return(void) on failure.
r18092:
Fix coverity item 70. Changed the improper assertion of the return value of a
library function to a check, and a return(void) on failure.
r18093:
Correct Coverity issue #12 by removing dead code.
r18094:
Correct Coverity issue #16 by removing debugging code.
r18095:
Fixed coverity issue # 271.
Removed redundant checking and freeing of sm_buf1 and sm_buf2.
r18096:
Correct Coverity issue #17 by refactoring test to remove dead code.
Also, removed previous "coverity" statements in comments, we'll review
those issues again and see if we can figure them out, now that we have more
experience with Coverity.
Tested on:
Mac OS X/32 10.6.2 (amazon)
2010-01-15 11:05:59 +08:00
|
|
|
if(sm_buf)
|
|
|
|
HDfree(sm_buf);
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: print out the data for a subset of a dataset.
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
* Select a hyperslab from the dataset DSET using the parameters
|
|
|
|
* specified in SSET. Dump this out to STREAM.
|
|
|
|
*
|
|
|
|
* Hyperslabs select "count" blocks of size "block", spaced "stride" elements
|
|
|
|
* from each other, starting at coordinate "start".
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* On success, return SUCCEED. Otherwise, the function returns FAIL.
|
|
|
|
*
|
|
|
|
* Algorithm
|
|
|
|
*
|
|
|
|
* The parameters from SSET are translated into temporary
|
|
|
|
* variables so that 1 row is printed at a time (getting the coordinate indices
|
|
|
|
* at each row).
|
|
|
|
* We define the stride, count and block to be 1 in the row dimension to achieve
|
|
|
|
* this and advance until all points are printed.
|
|
|
|
*
|
|
|
|
* The element position is obtained from the matrix according to:
|
|
|
|
* Given an index I(z,y,x) its position from the beginning of an array
|
|
|
|
* of sizes A(size_z, size_y,size_x) is given by
|
|
|
|
* Position of I(z,y,x) = index_z * size_y * size_x
|
|
|
|
* + index_y * size_x
|
|
|
|
* + index_x
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static herr_t
|
2010-01-30 12:29:13 +08:00
|
|
|
h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
|
2009-09-15 03:52:42 +08:00
|
|
|
hid_t dset, hid_t p_type, struct subset_t *sset,
|
|
|
|
hid_t f_space, hsize_t *total_size)
|
|
|
|
{
|
|
|
|
size_t i; /* counters */
|
|
|
|
hsize_t n; /* counters */
|
2009-09-04 22:50:13 +08:00
|
|
|
hsize_t count; /* hyperslab count */
|
|
|
|
hsize_t outer_count; /* offset count */
|
|
|
|
unsigned int row_dim; /* index of row_counter dimension */
|
|
|
|
int current_outer_dim; /* dimension for start */
|
|
|
|
hsize_t temp_start[H5S_MAX_RANK];/* temporary start inside offset count loop */
|
|
|
|
hsize_t max_start[H5S_MAX_RANK]; /* maximum start inside offset count loop */
|
|
|
|
hsize_t temp_count[H5S_MAX_RANK];/* temporary count inside offset count loop */
|
|
|
|
hsize_t temp_block[H5S_MAX_RANK];/* temporary block size used in loop */
|
|
|
|
hsize_t temp_stride[H5S_MAX_RANK];/* temporary stride size used in loop */
|
|
|
|
int reset_dim;
|
2010-10-21 21:08:44 +08:00
|
|
|
herr_t ret_value = SUCCEED;
|
2001-03-09 04:21:05 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if (ctx->ndims == 1)
|
2009-09-04 22:50:13 +08:00
|
|
|
row_dim = 0;
|
2004-10-11 03:22:03 +08:00
|
|
|
else
|
2009-09-15 03:52:42 +08:00
|
|
|
row_dim = ctx->ndims - 2;
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* get the offset count */
|
|
|
|
outer_count = 1;
|
2009-09-15 03:52:42 +08:00
|
|
|
if (ctx->ndims > 2)
|
|
|
|
for (i = 0; i < (size_t) ctx->ndims - 2; i++) {
|
2009-09-04 22:50:13 +08:00
|
|
|
/* consider block size */
|
2010-08-20 03:55:48 +08:00
|
|
|
outer_count = outer_count * sset->count.data[i] * sset->block.data[i];
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize temporary start, count and maximum start */
|
2009-09-15 03:52:42 +08:00
|
|
|
for (i = 0; i < (size_t) ctx->ndims; i++) {
|
2010-08-20 03:55:48 +08:00
|
|
|
temp_start[i] = sset->start.data[i];
|
|
|
|
temp_count[i] = sset->count.data[i];
|
|
|
|
temp_block[i] = sset->block.data[i];
|
|
|
|
temp_stride[i] = sset->stride.data[i];
|
2009-09-04 22:50:13 +08:00
|
|
|
max_start[i] = 0;
|
|
|
|
}
|
2009-09-15 03:52:42 +08:00
|
|
|
|
|
|
|
if (ctx->ndims > 2) {
|
|
|
|
for (i = 0; i < (size_t) ctx->ndims - 2; i++) {
|
2010-08-20 03:55:48 +08:00
|
|
|
max_start[i] = temp_start[i] + sset->count.data[i];
|
2009-09-04 22:50:13 +08:00
|
|
|
temp_count[i] = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* offset loop */
|
|
|
|
for (n = 0; n < outer_count; n++) {
|
|
|
|
/* number of read iterations in inner loop, read by rows, to match 2D display */
|
2009-09-15 03:52:42 +08:00
|
|
|
if (ctx->ndims > 1) {
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* count is the number of iterations to display all the rows,
|
|
|
|
the block size count times */
|
2010-08-20 03:55:48 +08:00
|
|
|
count = sset->count.data[row_dim] * sset->block.data[row_dim];
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* always 1 row_counter at a time, that is a block of size 1, 1 time */
|
|
|
|
temp_count[row_dim] = 1;
|
|
|
|
temp_block[row_dim] = 1;
|
|
|
|
|
|
|
|
/* advance 1 row_counter at a time */
|
2010-08-20 03:55:48 +08:00
|
|
|
if (sset->block.data[row_dim] > 1)
|
2009-09-04 22:50:13 +08:00
|
|
|
temp_stride[row_dim] = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
/* for the 1D case */
|
|
|
|
else {
|
|
|
|
count = 1;
|
|
|
|
}
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_print_simple_subset(stream, info, ctx, dset, p_type, sset,
|
2010-01-30 12:29:13 +08:00
|
|
|
f_space, count, temp_start, temp_count,
|
2009-09-15 03:52:42 +08:00
|
|
|
temp_block, temp_stride, total_size, row_dim);
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if (ctx->ndims > 2) {
|
2009-09-04 22:50:13 +08:00
|
|
|
/* dimension for start */
|
2009-09-15 03:52:42 +08:00
|
|
|
current_outer_dim = (ctx->ndims - 2) - 1;
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* set start to original from current_outer_dim up */
|
2009-09-15 03:52:42 +08:00
|
|
|
for (i = current_outer_dim + 1; i < ctx->ndims; i++) {
|
2010-08-20 03:55:48 +08:00
|
|
|
temp_start[i] = sset->start.data[i];
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* increment start dimension */
|
|
|
|
do {
|
|
|
|
reset_dim = 0;
|
|
|
|
temp_start[current_outer_dim]++;
|
|
|
|
if (temp_start[current_outer_dim] >= max_start[current_outer_dim]) {
|
2010-08-20 03:55:48 +08:00
|
|
|
temp_start[current_outer_dim] = sset->start.data[current_outer_dim];
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* consider block */
|
2010-08-20 03:55:48 +08:00
|
|
|
if (sset->block.data[current_outer_dim] > 1)
|
2009-09-04 22:50:13 +08:00
|
|
|
temp_start[current_outer_dim]++;
|
|
|
|
|
|
|
|
current_outer_dim--;
|
|
|
|
reset_dim = 1;
|
|
|
|
}
|
|
|
|
} while (current_outer_dim >= 0 && reset_dim);
|
|
|
|
|
|
|
|
} /* ctx.ndims > 1 */
|
|
|
|
|
|
|
|
} /* outer_count */
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Dump out a subset of a dataset.
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
* Select a hyperslab from the dataset DSET using the parameters
|
|
|
|
* specified in SSET. Dump this out to STREAM.
|
|
|
|
*
|
|
|
|
* Hyperslabs select "count" blocks of size "block", spaced "stride" elements
|
|
|
|
* from each other, starting at coordinate "start".
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* On success, return SUCCEED. Otherwise, the function returns FAIL.
|
|
|
|
*
|
|
|
|
* Original programmer:
|
|
|
|
* Bill Wendling, Wednesday, March 07, 2001
|
|
|
|
*
|
|
|
|
* Rewritten with modified algorithm by:
|
|
|
|
* Pedro Vicente, Wednesday, January 16, 2008, contributions from Quincey Koziol
|
|
|
|
*
|
|
|
|
* Algorithm
|
|
|
|
*
|
|
|
|
* In a inner loop, the parameters from SSET are translated into temporary
|
|
|
|
* variables so that 1 row is printed at a time (getting the coordinate indices
|
|
|
|
* at each row).
|
|
|
|
* We define the stride, count and block to be 1 in the row dimension to achieve
|
|
|
|
* this and advance until all points are printed.
|
|
|
|
* An outer loop for cases where dimensionality is greater than 2D is made.
|
|
|
|
* In each iteration, the 2D block is displayed in the inner loop. The remaining
|
|
|
|
* slower dimensions above the first 2 are incremented one at a time in the outer loop
|
|
|
|
*
|
|
|
|
* The element position is obtained from the matrix according to:
|
|
|
|
* Given an index I(z,y,x) its position from the beginning of an array
|
|
|
|
* of sizes A(size_z, size_y,size_x) is given by
|
|
|
|
* Position of I(z,y,x) = index_z * size_y * size_x
|
|
|
|
* + index_y * size_x
|
|
|
|
* + index_x
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static herr_t
|
|
|
|
h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset,
|
|
|
|
hid_t p_type, struct subset_t *sset, int indentlevel)
|
|
|
|
{
|
2009-09-18 04:31:44 +08:00
|
|
|
HERR_INIT(herr_t, SUCCEED)
|
2009-12-13 13:28:30 +08:00
|
|
|
int sndims;
|
|
|
|
hid_t f_space = -1; /* file data space */
|
2009-09-15 03:52:42 +08:00
|
|
|
size_t i; /* counters */
|
|
|
|
hsize_t total_size[H5S_MAX_RANK];/* total size of dataset*/
|
|
|
|
h5tools_context_t ctx; /* print context */
|
|
|
|
|
|
|
|
if((f_space = H5Dget_space(dset)) < 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check that everything looks okay. the dimensionality must not be too
|
|
|
|
* great and the dimensionality of the items selected for printing must
|
|
|
|
* match the dimensionality of the dataset.
|
|
|
|
*/
|
|
|
|
memset(&ctx, 0, sizeof(ctx));
|
|
|
|
ctx.indent_level = indentlevel;
|
|
|
|
ctx.need_prefix = 1;
|
2009-12-13 13:28:30 +08:00
|
|
|
if((sndims = H5Sget_simple_extent_ndims(f_space)) < 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
|
|
|
|
ctx.ndims = (unsigned)sndims;
|
2009-09-15 03:52:42 +08:00
|
|
|
|
|
|
|
/* assume entire data space to be printed */
|
|
|
|
if (ctx.ndims > 0)
|
|
|
|
for (i = 0; i < (size_t) ctx.ndims; i++)
|
|
|
|
ctx.p_min_idx[i] = 0;
|
|
|
|
|
|
|
|
if(H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0)
|
2009-12-13 13:28:30 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
|
2009-09-15 03:52:42 +08:00
|
|
|
ctx.size_last_dim = total_size[ctx.ndims - 1];
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_display_simple_subset(stream, info, &ctx, dset, p_type, sset, f_space, total_size);
|
2009-12-13 13:28:30 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Terminate the output */
|
|
|
|
if (ctx.cur_column) {
|
2011-03-09 21:07:38 +08:00
|
|
|
fputs(OPT(info->line_suf, ""), stdout);
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
putc('\n', stdout);
|
2011-03-09 21:07:38 +08:00
|
|
|
fputs(OPT(info->line_sep, ""), stdout);
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
CATCH
|
2009-12-13 13:28:30 +08:00
|
|
|
if(f_space >= 0 && H5Sclose(f_space) < 0)
|
|
|
|
H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
return ret_value;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print some values from a dataset with a simple data space.
|
|
|
|
* Description:
|
|
|
|
* This is a special case of h5tools_dump_dset(). This function only
|
|
|
|
* intended for dumping datasets -- it does strip mining and some other
|
|
|
|
* things which are unnecessary for smaller objects such as attributes
|
|
|
|
* (to print small objects like attributes simply read the attribute and
|
|
|
|
* call h5tools_dump_simple_mem()).
|
|
|
|
* Return:
|
|
|
|
* On success, the function returns SUCCEED. Otherwise, the function
|
|
|
|
* returns FAIL.
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
static int
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info,
|
2010-01-30 12:29:13 +08:00
|
|
|
hid_t dset, hid_t p_type, int indentlevel)
|
2009-09-04 22:50:13 +08:00
|
|
|
{
|
|
|
|
hid_t f_space; /* file data space */
|
|
|
|
hsize_t elmtno; /* counter */
|
|
|
|
size_t i; /* counter */
|
|
|
|
int carry; /* counter carry value */
|
|
|
|
hsize_t zero[8]; /* vector of zeros */
|
|
|
|
unsigned int flags; /* buffer extent flags */
|
|
|
|
hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
|
|
|
|
|
|
|
|
/* Print info */
|
|
|
|
h5tools_context_t ctx; /* print context */
|
|
|
|
size_t p_type_nbytes; /* size of memory type */
|
|
|
|
hsize_t p_nelmts; /* total selected elmts */
|
|
|
|
|
|
|
|
/* Stripmine info */
|
|
|
|
hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
|
|
|
|
hsize_t sm_nbytes; /* bytes per stripmine */
|
|
|
|
hsize_t sm_nelmts; /* elements per stripmine*/
|
|
|
|
unsigned char *sm_buf = NULL; /* buffer for raw data */
|
|
|
|
hid_t sm_space; /* stripmine data space */
|
|
|
|
|
|
|
|
/* Hyperslab info */
|
|
|
|
hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */
|
|
|
|
hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */
|
|
|
|
hsize_t hs_nelmts; /* elements in request */
|
|
|
|
|
|
|
|
/* VL data special information */
|
|
|
|
unsigned int vl_data = 0; /* contains VL datatypes */
|
|
|
|
|
|
|
|
f_space = H5Dget_space(dset);
|
|
|
|
|
|
|
|
if (f_space == FAIL)
|
|
|
|
return FAIL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check that everything looks okay. The dimensionality must not be too
|
|
|
|
* great and the dimensionality of the items selected for printing must
|
|
|
|
* match the dimensionality of the dataset.
|
|
|
|
*/
|
|
|
|
memset(&ctx, 0, sizeof(ctx));
|
|
|
|
ctx.ndims = H5Sget_simple_extent_ndims(f_space);
|
|
|
|
|
|
|
|
if ((size_t)ctx.ndims > NELMTS(sm_size)) {
|
|
|
|
H5Sclose(f_space);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.indent_level = indentlevel;
|
|
|
|
ctx.need_prefix = 1;
|
|
|
|
|
|
|
|
/* Assume entire data space to be printed */
|
|
|
|
if (ctx.ndims > 0)
|
|
|
|
for (i = 0; i < (size_t)ctx.ndims; i++)
|
|
|
|
ctx.p_min_idx[i] = 0;
|
|
|
|
|
|
|
|
H5Sget_simple_extent_dims(f_space, total_size, NULL);
|
|
|
|
|
|
|
|
/* calculate the number of elements we're going to print */
|
|
|
|
p_nelmts = 1;
|
|
|
|
|
|
|
|
if (ctx.ndims > 0) {
|
|
|
|
for (i = 0; i < ctx.ndims; i++)
|
|
|
|
p_nelmts *= total_size[i];
|
|
|
|
ctx.size_last_dim = (total_size[ctx.ndims - 1]);
|
|
|
|
} /* end if */
|
|
|
|
else
|
|
|
|
ctx.size_last_dim = 0;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
if (p_nelmts == 0) {
|
|
|
|
/* nothing to print */
|
|
|
|
H5Sclose(f_space);
|
|
|
|
return SUCCEED;
|
|
|
|
}
|
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/* Check if we have VL data in the dataset's datatype */
|
2011-03-15 05:03:20 +08:00
|
|
|
if (h5tools_detect_vlen_str(p_type) == TRUE)
|
|
|
|
vl_data = TRUE;
|
|
|
|
if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE)
|
2001-03-09 04:21:05 +08:00
|
|
|
vl_data = TRUE;
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*
|
|
|
|
* Determine the strip mine size and allocate a buffer. The strip mine is
|
|
|
|
* a hyperslab whose size is manageable.
|
|
|
|
*/
|
2001-03-09 04:21:05 +08:00
|
|
|
sm_nbytes = p_type_nbytes = H5Tget_size(p_type);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
|
|
|
if (ctx.ndims > 0) {
|
2001-03-09 04:21:05 +08:00
|
|
|
for (i = ctx.ndims; i > 0; --i) {
|
[svn-r16614] 3. #1501 (B1) tools bug if dataset is larger than H5TOOLS_BUFSIZE limit.
ISSUE : the tools use the following formula to read by hyperslabs: hyperslab_size[i] = MIN( dim_size[i], H5TOOLS_BUFSIZE / datum_size) where H5TOOLS_BUFSIZE is a constant defined of 1024K. This is OK as long as the datum_size does not exceed 1024K, otherwise we have a hyperslab size of 0 (since 1024K/(greater than 1024K) = 0). This affects h5dump. h5repack, h5diff
SOLUTION: add a check for a 0 size and define as 1 if so.
TEST FOR H5DUMP: Defined a case in the h5dump test generator program of such a type (an array type of doubles with a large array dimension, that was the case the user reported). Since the written file commited in svn would be around 1024K, opted for not writing the data (the part of the code where the hyperslab is defined is executed, since h5dump always reads the files). Defined a macro WRITE_ARRAY to enable such writing if needed. Added a run on the h5dump shell script. Added 2 new files to svn: tools/testfiles/tarray8.ddl, tools/testfiles/tarray8.h5. NOTE: while doing this I thought of adding this dataset case to an existing file, but that would add the large array output to those files (the ddls). The issue is that the file list is increasing.
TEST FOR H5DIFF: for h5diff the check for reading by hyperslabs is H5TOOLS_MALLOCSIZE (128 * H5TOOLS_BUFSIZE) or 128 Mb. This makes it not possible to add such a file to svn, so used the same method as h5dump (only write the dataset if WRITE_ARRAY is defined). As opposed to h5dump, the hyperslab code is NOT executed when the dataset is empty (dataset is not read). Added the new dataset to existing files and shell run (tools/h5diff/testfiles/h5diff_dset1.h5 and tools/h5diff/testfiles/h5diff_dset2.h5 and output in tools/h5diff/testfiles/h5diff_80.txt).
TEST FOR H5REPACK: similar issue as h5diff with the difference that the hyperslab code is run. Added a run to the shell script (with a filter, otherwise the code uses H5Ocopy).
tested: linux (h5commitest failed , apparently it did not detect the code changes in /tools/lib that fix the bug: the error in an assertion in the hyperslab of 0. I am sure that making h5ccomitest --distclean will detect the new code , but don't want to wait more 3 hours :-) )
2009-03-26 04:28:50 +08:00
|
|
|
hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes;
|
|
|
|
if ( size == 0) /* datum size > H5TOOLS_BUFSIZE */
|
|
|
|
size = 1;
|
|
|
|
sm_size[i - 1] = MIN(total_size[i - 1], size);
|
2001-02-23 05:55:15 +08:00
|
|
|
sm_nbytes *= sm_size[i - 1];
|
|
|
|
assert(sm_nbytes > 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
if(!sm_nbytes)
|
2011-04-26 00:59:51 +08:00
|
|
|
goto done;
|
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/
|
2010-10-21 21:08:44 +08:00
|
|
|
sm_buf = (unsigned char *)HDmalloc((size_t)sm_nbytes);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
sm_nelmts = sm_nbytes / p_type_nbytes;
|
|
|
|
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (ctx.ndims > 0)
|
|
|
|
init_acc_pos(&ctx, total_size);
|
2005-02-09 04:55:17 +08:00
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/* The stripmine loop */
|
2001-07-11 04:18:52 +08:00
|
|
|
memset(hs_offset, 0, sizeof hs_offset);
|
|
|
|
memset(zero, 0, sizeof zero);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
|
|
|
for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) {
|
|
|
|
/* Calculate the hyperslab size */
|
|
|
|
if (ctx.ndims > 0) {
|
2004-10-09 02:41:44 +08:00
|
|
|
for (i = 0, hs_nelmts = 1; i < ctx.ndims; i++) {
|
2001-02-23 05:55:15 +08:00
|
|
|
hs_size[i] = MIN(total_size[i] - hs_offset[i], sm_size[i]);
|
|
|
|
ctx.p_max_idx[i] = ctx.p_min_idx[i] + hs_size[i];
|
|
|
|
hs_nelmts *= hs_size[i];
|
|
|
|
}
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL);
|
|
|
|
H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL);
|
|
|
|
}
|
|
|
|
else {
|
2001-02-23 05:55:15 +08:00
|
|
|
H5Sselect_all(f_space);
|
|
|
|
H5Sselect_all(sm_space);
|
|
|
|
hs_nelmts = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read the data */
|
|
|
|
if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) {
|
|
|
|
H5Sclose(f_space);
|
|
|
|
H5Sclose(sm_space);
|
2001-07-11 04:18:52 +08:00
|
|
|
free(sm_buf);
|
2001-03-09 04:21:05 +08:00
|
|
|
return FAIL;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Print the data */
|
|
|
|
flags = (elmtno == 0) ? START_OF_DATA : 0;
|
|
|
|
flags |= ((elmtno + hs_nelmts) >= p_nelmts) ? END_OF_DATA : 0;
|
2005-05-09 22:53:22 +08:00
|
|
|
|
2005-10-20 00:46:12 +08:00
|
|
|
/* initialize the current stripmine position; this is necessary to print the array
|
2009-09-04 22:50:13 +08:00
|
|
|
indices */
|
2005-05-09 22:53:22 +08:00
|
|
|
ctx.sm_pos = elmtno;
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_dump_simple_data(stream, info, dset, &ctx, flags, hs_nelmts, p_type, sm_buf);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
|
|
|
/* Reclaim any VL memory, if necessary */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (vl_data)
|
2001-03-09 04:21:05 +08:00
|
|
|
H5Dvlen_reclaim(p_type, sm_space, H5P_DEFAULT, sm_buf);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
|
|
|
/* Calculate the next hyperslab offset */
|
|
|
|
for (i = ctx.ndims, carry = 1; i > 0 && carry; --i) {
|
|
|
|
ctx.p_min_idx[i - 1] = ctx.p_max_idx[i - 1];
|
|
|
|
hs_offset[i - 1] += hs_size[i - 1];
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (hs_offset[i - 1] == total_size[i - 1])
|
|
|
|
hs_offset[i - 1] = 0;
|
|
|
|
else
|
|
|
|
carry = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.continuation++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Terminate the output */
|
|
|
|
if (ctx.cur_column) {
|
|
|
|
fputs(OPT(info->line_suf, ""), stream);
|
|
|
|
putc('\n', stream);
|
|
|
|
fputs(OPT(info->line_sep, ""), stream);
|
|
|
|
}
|
|
|
|
|
2011-04-26 00:59:51 +08:00
|
|
|
HDfree(sm_buf);
|
|
|
|
|
|
|
|
done:
|
2009-09-04 22:50:13 +08:00
|
|
|
H5Sclose(sm_space);
|
|
|
|
H5Sclose(f_space);
|
|
|
|
|
|
|
|
return SUCCEED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_dump_simple_mem
|
|
|
|
*
|
|
|
|
* Purpose: Print some values from memory with a simple data space.
|
|
|
|
* This is a special case of h5tools_dump_mem().
|
|
|
|
*
|
|
|
|
* Return: Success: SUCCEED
|
|
|
|
* Failure: FAIL
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id,
|
|
|
|
hid_t type, hid_t space, void *mem, int indentlevel)
|
|
|
|
{
|
|
|
|
int i; /*counters */
|
|
|
|
hsize_t nelmts; /*total selected elmts */
|
|
|
|
h5tools_context_t ctx; /*printing context */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check that everything looks okay. The dimensionality must not be too
|
|
|
|
* great and the dimensionality of the items selected for printing must
|
|
|
|
* match the dimensionality of the dataset.
|
|
|
|
*/
|
|
|
|
memset(&ctx, 0, sizeof(ctx));
|
|
|
|
ctx.ndims = H5Sget_simple_extent_ndims(space);
|
|
|
|
|
|
|
|
if ((size_t) ctx.ndims > NELMTS(ctx.p_min_idx))
|
|
|
|
return FAIL;
|
|
|
|
|
|
|
|
ctx.indent_level = indentlevel;
|
|
|
|
ctx.need_prefix = 1;
|
|
|
|
|
|
|
|
/* Assume entire data space to be printed */
|
|
|
|
for (i = 0; i < ctx.ndims; i++)
|
|
|
|
ctx.p_min_idx[i] = 0;
|
|
|
|
|
|
|
|
H5Sget_simple_extent_dims(space, ctx.p_max_idx, NULL);
|
|
|
|
|
|
|
|
for (i = 0, nelmts = 1; ctx.ndims != 0 && i < ctx.ndims; i++)
|
|
|
|
nelmts *= ctx.p_max_idx[i] - ctx.p_min_idx[i];
|
|
|
|
|
|
|
|
if (nelmts == 0)
|
|
|
|
return SUCCEED; /*nothing to print*/
|
|
|
|
if (ctx.ndims > 0) {
|
|
|
|
assert(ctx.p_max_idx[ctx.ndims - 1] == (hsize_t) ((int) ctx.p_max_idx[ctx.ndims - 1]));
|
|
|
|
ctx.size_last_dim = (int) (ctx.p_max_idx[ctx.ndims - 1]);
|
|
|
|
} /* end if */
|
|
|
|
else
|
|
|
|
ctx.size_last_dim = 0;
|
|
|
|
|
|
|
|
if (ctx.ndims > 0)
|
|
|
|
init_acc_pos(&ctx, ctx.p_max_idx);
|
|
|
|
|
|
|
|
/* Print it */
|
|
|
|
h5tools_dump_simple_data(stream, info, obj_id, &ctx, START_OF_DATA | END_OF_DATA, nelmts, type, mem);
|
|
|
|
|
|
|
|
/* Terminate the output */
|
|
|
|
if (ctx.cur_column) {
|
|
|
|
fputs(OPT(info->line_suf, ""), stream);
|
|
|
|
putc('\n', stream);
|
|
|
|
fputs(OPT(info->line_sep, ""), stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
return SUCCEED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_dump_dset
|
|
|
|
*
|
|
|
|
* Purpose: Print some values from a dataset DSET to the file STREAM
|
|
|
|
* after converting all types to P_TYPE (which should be a
|
|
|
|
* native type). If P_TYPE is a negative value then it will be
|
|
|
|
* computed from the dataset type using only native types.
|
|
|
|
*
|
|
|
|
* Note: This function is intended only for datasets since it does
|
|
|
|
* some things like strip mining which are unnecessary for
|
|
|
|
* smaller objects such as attributes. The easiest way to print
|
|
|
|
* small objects is to read the object into memory and call
|
|
|
|
* h5tools_dump_mem().
|
|
|
|
*
|
|
|
|
* Return: Success: SUCCEED
|
|
|
|
* Failure: FAIL
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
* Robb Matzke, 1999-06-07
|
|
|
|
* If info->raw is set then the memory datatype will be the same
|
|
|
|
* as the file datatype.
|
|
|
|
*
|
|
|
|
* Bill Wendling, 2001-02-27
|
|
|
|
* Renamed to ``h5tools_dump_dset'' and added the subsetting
|
|
|
|
* parameter.
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
int
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset,
|
2010-01-30 12:29:13 +08:00
|
|
|
hid_t _p_type, struct subset_t *sset, int indentlevel)
|
2009-09-04 22:50:13 +08:00
|
|
|
{
|
|
|
|
hid_t f_space;
|
|
|
|
hid_t p_type = _p_type;
|
|
|
|
hid_t f_type;
|
|
|
|
H5S_class_t space_type;
|
|
|
|
int status = FAIL;
|
|
|
|
h5tool_format_t info_dflt;
|
|
|
|
/* Use default values */
|
|
|
|
if (!stream)
|
|
|
|
stream = stdout;
|
|
|
|
|
|
|
|
if (!info) {
|
|
|
|
memset(&info_dflt, 0, sizeof info_dflt);
|
|
|
|
info = &info_dflt;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_type < 0) {
|
|
|
|
f_type = H5Dget_type(dset);
|
|
|
|
|
|
|
|
if (info->raw || bin_form == 1)
|
|
|
|
p_type = H5Tcopy(f_type);
|
|
|
|
else if (bin_form == 2)
|
|
|
|
p_type = h5tools_get_little_endian_type(f_type);
|
|
|
|
else if (bin_form == 3)
|
|
|
|
p_type = h5tools_get_big_endian_type(f_type);
|
|
|
|
else
|
|
|
|
p_type = h5tools_get_native_type(f_type);
|
|
|
|
|
|
|
|
H5Tclose(f_type);
|
|
|
|
|
|
|
|
if (p_type < 0)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the data space */
|
|
|
|
f_space = H5Dget_space(dset);
|
|
|
|
|
|
|
|
space_type = H5Sget_simple_extent_type(f_space);
|
|
|
|
|
|
|
|
/* Print the data */
|
|
|
|
if (space_type == H5S_SIMPLE || space_type == H5S_SCALAR) {
|
2010-08-20 03:55:48 +08:00
|
|
|
if(!sset)
|
2011-03-09 21:07:38 +08:00
|
|
|
status = h5tools_dump_simple_dset(rawdatastream, info, dset, p_type, indentlevel);
|
2010-08-20 03:55:48 +08:00
|
|
|
else
|
2011-03-09 21:07:38 +08:00
|
|
|
status = h5tools_dump_simple_subset(rawdatastream, info, dset, p_type, sset, indentlevel);
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
/* space is H5S_NULL */
|
|
|
|
status = SUCCEED;
|
|
|
|
|
|
|
|
/* Close the dataspace */
|
|
|
|
H5Sclose(f_space);
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (p_type != _p_type)
|
|
|
|
H5Tclose(p_type);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_dump_mem
|
|
|
|
*
|
|
|
|
* Purpose: Displays the data contained in MEM. MEM must have the
|
|
|
|
* specified data TYPE and SPACE. Currently only simple data
|
|
|
|
* spaces are allowed and only the `all' selection.
|
|
|
|
*
|
|
|
|
* Return: Success: SUCCEED
|
|
|
|
* Failure: FAIL
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t type,
|
|
|
|
hid_t space, void *mem, int indentlevel)
|
|
|
|
{
|
2009-09-18 04:31:44 +08:00
|
|
|
HERR_INIT(int, SUCCEED)
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tool_format_t info_dflt;
|
|
|
|
|
|
|
|
/* Use default values */
|
|
|
|
if (!stream)
|
|
|
|
stream = stdout;
|
|
|
|
|
|
|
|
if (!info) {
|
|
|
|
memset(&info_dflt, 0, sizeof(info_dflt));
|
|
|
|
info = &info_dflt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the data space */
|
|
|
|
if (H5Sis_simple(space) <= 0)
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sis_simple failed")
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
H5_LEAVE(h5tools_dump_simple_mem(stream, info, obj_id, type, space, mem, indentlevel))
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
CATCH
|
|
|
|
return ret_value;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: print_datatype
|
|
|
|
*
|
|
|
|
* Purpose: print the datatype.
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* In/Out: h5tools_str_t *buffer
|
|
|
|
* h5tools_context_t *ctx
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
int
|
|
|
|
h5tools_print_datatype(h5tools_str_t *buffer, const h5tool_format_t *info,
|
|
|
|
h5tools_context_t *ctx, hid_t type)
|
2009-09-04 22:50:13 +08:00
|
|
|
{
|
2010-08-10 02:15:37 +08:00
|
|
|
HERR_INIT(int, SUCCEED)
|
2009-09-15 03:52:42 +08:00
|
|
|
char *mname;
|
|
|
|
hid_t mtype, str_type;
|
2011-04-13 00:59:33 +08:00
|
|
|
int snmembers;
|
2009-09-15 03:52:42 +08:00
|
|
|
unsigned nmembers;
|
2011-04-13 00:59:33 +08:00
|
|
|
int sndims;
|
2009-09-15 03:52:42 +08:00
|
|
|
unsigned i;
|
|
|
|
size_t size = 0;
|
|
|
|
hsize_t dims[H5TOOLS_DUMP_MAX_RANK];
|
|
|
|
H5T_str_t str_pad;
|
|
|
|
H5T_cset_t cset;
|
|
|
|
H5T_order_t order;
|
|
|
|
H5T_class_t type_class;
|
|
|
|
hid_t super;
|
|
|
|
hid_t tmp_type;
|
|
|
|
htri_t is_vlstr = FALSE;
|
|
|
|
const char *order_s = NULL; /* byte order string */
|
|
|
|
H5T_sign_t sign; /* sign scheme value */
|
|
|
|
const char *sign_s = NULL; /* sign scheme string */
|
|
|
|
|
|
|
|
if((type_class = H5Tget_class(type)) < 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed");
|
|
|
|
switch (type_class) {
|
2009-09-04 22:50:13 +08:00
|
|
|
case H5T_INTEGER:
|
|
|
|
if (H5Tequal(type, H5T_STD_I8BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_I8BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_I8LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_I8LE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_I16BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_I16BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_I16LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_I16LE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_I32BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_I32BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_I32LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_I32LE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_I64BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_I64BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_I64LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_I64LE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_U8BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_U8BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_U8LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_U8LE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_U16BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_U16BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_U16LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_U16LE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_U32BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_U32BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_U32LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_U32LE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_U64BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_U64BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_U64LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_U64LE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_SCHAR) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_SCHAR");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_UCHAR) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_UCHAR");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_SHORT) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_SHORT");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_USHORT) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_USHORT");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_INT) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_INT");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_UINT) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_UINT");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_LONG) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_LONG");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_ULONG) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_ULONG");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_LLONG) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_LLONG");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_ULLONG) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_ULLONG");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
/* byte order */
|
|
|
|
if (H5Tget_size(type) > 1) {
|
|
|
|
order = H5Tget_order(type);
|
|
|
|
if (H5T_ORDER_LE == order) {
|
|
|
|
order_s = " little-endian";
|
|
|
|
}
|
|
|
|
else if (H5T_ORDER_BE == order) {
|
|
|
|
order_s = " big-endian";
|
|
|
|
}
|
|
|
|
else if (H5T_ORDER_VAX == order) {
|
|
|
|
order_s = " mixed-endian";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
order_s = " unknown-byte-order";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
order_s = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sign */
|
|
|
|
if ((sign = H5Tget_sign(type)) >= 0) {
|
|
|
|
if (H5T_SGN_NONE == sign) {
|
|
|
|
sign_s = " unsigned";
|
|
|
|
}
|
|
|
|
else if (H5T_SGN_2 == sign) {
|
|
|
|
sign_s = "";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sign_s = " unknown-sign";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sign_s = " unknown-sign";
|
|
|
|
}
|
|
|
|
|
|
|
|
/* print size, order, and sign */
|
|
|
|
h5tools_str_append(buffer, "%lu-bit%s%s integer",
|
|
|
|
(unsigned long) (8 * H5Tget_size(type)), order_s, sign_s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5T_FLOAT:
|
|
|
|
if (H5Tequal(type, H5T_IEEE_F32BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_IEEE_F32BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_IEEE_F32LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_IEEE_F32LE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_IEEE_F64BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_IEEE_F64BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_IEEE_F64LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_IEEE_F64LE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_VAX_F32) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_VAX_F32");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_VAX_F64) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_VAX_F64");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_FLOAT) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_FLOAT");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_DOUBLE");
|
|
|
|
#if H5_SIZEOF_LONG_DOUBLE !=0
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_LDOUBLE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_LDOUBLE");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
/* byte order */
|
|
|
|
if (H5Tget_size(type) > 1) {
|
|
|
|
order = H5Tget_order(type);
|
|
|
|
if (H5T_ORDER_LE == order) {
|
|
|
|
order_s = " little-endian";
|
|
|
|
}
|
|
|
|
else if (H5T_ORDER_BE == order) {
|
|
|
|
order_s = " big-endian";
|
|
|
|
}
|
|
|
|
else if (H5T_ORDER_VAX == order) {
|
|
|
|
order_s = " mixed-endian";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
order_s = " unknown-byte-order";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
order_s = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
/* print size and byte order */
|
|
|
|
h5tools_str_append(buffer, "%lu-bit%s floating-point",
|
|
|
|
(unsigned long) (8 * H5Tget_size(type)), order_s);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5T_TIME:
|
|
|
|
h5tools_str_append(buffer, "H5T_TIME: not yet implemented");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5T_STRING:
|
|
|
|
/* Make a copy of type in memory in case when TYPE is on disk, the size
|
|
|
|
* will be bigger than in memory. This makes it easier to compare
|
|
|
|
* types in memory. */
|
|
|
|
tmp_type = H5Tcopy(type);
|
|
|
|
size = H5Tget_size(tmp_type);
|
|
|
|
str_pad = H5Tget_strpad(tmp_type);
|
|
|
|
cset = H5Tget_cset(tmp_type);
|
|
|
|
is_vlstr = H5Tis_variable_str(tmp_type);
|
|
|
|
|
|
|
|
h5tools_str_append(buffer, "H5T_STRING %s\n", h5tools_dump_header_format->strblockbegin);
|
|
|
|
ctx->indent_level++;
|
|
|
|
|
|
|
|
if (is_vlstr)
|
|
|
|
h5tools_str_append(buffer, "%s H5T_VARIABLE;\n", STRSIZE);
|
|
|
|
else
|
|
|
|
h5tools_str_append(buffer, "%s %d;\n", STRSIZE, (int) size);
|
|
|
|
|
|
|
|
h5tools_str_append(buffer, "%s ", STRPAD);
|
|
|
|
if (str_pad == H5T_STR_NULLTERM)
|
|
|
|
h5tools_str_append(buffer, "H5T_STR_NULLTERM;\n");
|
|
|
|
else if (str_pad == H5T_STR_NULLPAD)
|
|
|
|
h5tools_str_append(buffer, "H5T_STR_NULLPAD;\n");
|
|
|
|
else if (str_pad == H5T_STR_SPACEPAD)
|
|
|
|
h5tools_str_append(buffer, "H5T_STR_SPACEPAD;\n");
|
|
|
|
else
|
|
|
|
h5tools_str_append(buffer, "H5T_STR_ERROR;\n");
|
|
|
|
|
|
|
|
h5tools_str_append(buffer, "%s ", CSET);
|
|
|
|
|
|
|
|
if (cset == H5T_CSET_ASCII)
|
|
|
|
h5tools_str_append(buffer, "H5T_CSET_ASCII;\n");
|
|
|
|
else
|
|
|
|
h5tools_str_append(buffer, "unknown_cset;\n");
|
|
|
|
|
|
|
|
str_type = H5Tcopy(H5T_C_S1);
|
|
|
|
if (is_vlstr)
|
|
|
|
H5Tset_size(str_type, H5T_VARIABLE);
|
|
|
|
else
|
|
|
|
H5Tset_size(str_type, size);
|
|
|
|
H5Tset_cset(str_type, cset);
|
|
|
|
H5Tset_strpad(str_type, str_pad);
|
|
|
|
|
|
|
|
h5tools_str_append(buffer, "%s ", CTYPE);
|
|
|
|
|
|
|
|
/* Check C variable-length string first. Are the two types equal? */
|
|
|
|
if (H5Tequal(tmp_type, str_type)) {
|
|
|
|
h5tools_str_append(buffer, "H5T_C_S1;\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Change the endianness and see if they're equal. */
|
|
|
|
order = H5Tget_order(tmp_type);
|
|
|
|
if (order == H5T_ORDER_LE)
|
|
|
|
H5Tset_order(str_type, H5T_ORDER_LE);
|
|
|
|
else if (order == H5T_ORDER_BE)
|
|
|
|
H5Tset_order(str_type, H5T_ORDER_BE);
|
|
|
|
|
|
|
|
if (H5Tequal(tmp_type, str_type)) {
|
|
|
|
h5tools_str_append(buffer, "H5T_C_S1;\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If not equal to C variable-length string, check Fortran type. */
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Tclose(str_type) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
str_type = H5Tcopy(H5T_FORTRAN_S1);
|
2009-09-15 03:52:42 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
H5Tset_cset(str_type, cset);
|
|
|
|
H5Tset_size(str_type, size);
|
|
|
|
H5Tset_strpad(str_type, str_pad);
|
|
|
|
|
|
|
|
/* Are the two types equal? */
|
|
|
|
if (H5Tequal(tmp_type, str_type)) {
|
|
|
|
h5tools_str_append(buffer, "H5T_FORTRAN_S1;\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Change the endianness and see if they're equal. */
|
|
|
|
order = H5Tget_order(tmp_type);
|
|
|
|
if (order == H5T_ORDER_LE)
|
|
|
|
H5Tset_order(str_type, H5T_ORDER_LE);
|
|
|
|
else if (order == H5T_ORDER_BE)
|
|
|
|
H5Tset_order(str_type, H5T_ORDER_BE);
|
|
|
|
|
|
|
|
if (H5Tequal(tmp_type, str_type)) {
|
|
|
|
h5tools_str_append(buffer, "H5T_FORTRAN_S1;\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Type doesn't match any of above. */
|
|
|
|
h5tools_str_append(buffer, "unknown_one_character_type;\n ");
|
|
|
|
|
2010-08-10 02:15:37 +08:00
|
|
|
done:
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Tclose(str_type) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
|
|
|
if(H5Tclose(tmp_type) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
ctx->indent_level--;
|
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->strblockend);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5T_BITFIELD:
|
|
|
|
if (H5Tequal(type, H5T_STD_B8BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_B8BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_B8LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_B8LE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_B16BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_B16BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_B16LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_B16LE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_B32BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_B32BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_B32LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_B32LE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_B64BE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_B64BE");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(type, H5T_STD_B64LE) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, "H5T_STD_B64LE");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
h5tools_str_append(buffer, "undefined bitfield");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5T_OPAQUE:
|
|
|
|
h5tools_str_append(buffer, "\n");
|
|
|
|
h5tools_str_append(buffer, "H5T_OPAQUE;\n");
|
2011-05-05 04:28:09 +08:00
|
|
|
{
|
|
|
|
char *ttag = H5Tget_tag(type);
|
|
|
|
h5tools_str_append(buffer, "OPAQUE_TAG \"%s\";\n", ttag);
|
|
|
|
if (ttag)
|
|
|
|
HDfree(ttag);
|
|
|
|
}
|
2009-09-04 22:50:13 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case H5T_COMPOUND:
|
2011-04-13 00:59:33 +08:00
|
|
|
if((snmembers = H5Tget_nmembers(type)) < 0)
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
|
2011-04-13 00:59:33 +08:00
|
|
|
nmembers = (unsigned)snmembers;
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_COMPOUND %s\n", h5tools_dump_header_format->structblockbegin);
|
|
|
|
|
|
|
|
for (i = 0; i < nmembers; i++) {
|
|
|
|
mname = H5Tget_member_name(type, i);
|
2009-09-15 03:52:42 +08:00
|
|
|
if((mtype = H5Tget_member_type(type, i))>=0) {
|
|
|
|
if (H5Tget_class(mtype) == H5T_COMPOUND)
|
|
|
|
ctx->indent_level++;
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_print_datatype(buffer, info, ctx, mtype);
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if (H5Tget_class(mtype) == H5T_COMPOUND)
|
|
|
|
ctx->indent_level--;
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_str_append(buffer, " \"%s\";\n", mname);
|
|
|
|
if(H5Tclose(mtype) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_member_type failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
free(mname);
|
|
|
|
}
|
|
|
|
|
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->structblockend);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5T_REFERENCE:
|
|
|
|
h5tools_str_append(buffer, "H5T_REFERENCE");
|
|
|
|
if(region_output) {
|
|
|
|
if (H5Tequal(type, H5T_STD_REF_DSETREG) == TRUE) {
|
|
|
|
h5tools_str_append(buffer, " { H5T_STD_REF_DSETREG }");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
h5tools_str_append(buffer, " { H5T_STD_REF_OBJECT }");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5T_ENUM:
|
2009-09-15 03:52:42 +08:00
|
|
|
if((super = H5Tget_super(type)) < 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_ENUM %s\n", h5tools_dump_header_format->enumblockbegin);
|
|
|
|
ctx->indent_level++;
|
2009-09-15 03:52:42 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_print_datatype(buffer, info, ctx, super);
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Tclose(super) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_str_append(buffer, ";\n");
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_print_enum(buffer, type);
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->indent_level--;
|
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->enumblockend);
|
2009-09-15 03:52:42 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case H5T_VLEN:
|
2009-09-15 03:52:42 +08:00
|
|
|
if((super = H5Tget_super(type)) < 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_VLEN %s ", h5tools_dump_header_format->vlenblockbegin);
|
2009-09-15 03:52:42 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_print_datatype(buffer, info, ctx, super);
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Tclose(super) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->vlenblockend);
|
2009-09-15 03:52:42 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case H5T_ARRAY:
|
|
|
|
h5tools_str_append(buffer, "H5T_ARRAY { ");
|
|
|
|
|
|
|
|
/* Get array information */
|
2011-04-13 00:59:33 +08:00
|
|
|
if((sndims = H5Tget_array_ndims(type)) >= 0) {
|
|
|
|
unsigned ndims = (unsigned)sndims;
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Tget_array_dims2(type, dims) >= 0) {
|
|
|
|
/* Print array dimensions */
|
|
|
|
for (i = 0; i < ndims; i++)
|
|
|
|
h5tools_str_append(buffer, "[%d]", (int) dims[i]);
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_array_dims2 failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_array_ndims failed");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
/* Get array base type */
|
|
|
|
if((super = H5Tget_super(type)) >= 0) {
|
|
|
|
/* Print base type */
|
|
|
|
h5tools_print_datatype(buffer, info, ctx, super);
|
|
|
|
/* Close array base type */
|
|
|
|
if(H5Tclose(super) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_super failed");
|
2002-11-19 00:38:11 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_str_append(buffer, " }");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
h5tools_str_append(buffer, "unknown datatype");
|
|
|
|
break;
|
|
|
|
}
|
2009-09-15 03:52:42 +08:00
|
|
|
|
|
|
|
CATCH
|
|
|
|
return ret_value;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2009-09-04 22:50:13 +08:00
|
|
|
* Function: print_dataspace
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Purpose: print the dataspace.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Return: void
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* In/Out: h5tools_str_t *buffer
|
|
|
|
* h5tools_context_t *ctx
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
int
|
|
|
|
h5tools_print_dataspace(h5tools_str_t *buffer, hid_t space)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2009-09-18 04:31:44 +08:00
|
|
|
HERR_INIT(int, SUCCEED)
|
2009-09-04 22:50:13 +08:00
|
|
|
hsize_t size[H5TOOLS_DUMP_MAX_RANK];
|
|
|
|
hsize_t maxsize[H5TOOLS_DUMP_MAX_RANK];
|
2009-09-15 03:52:42 +08:00
|
|
|
int ndims = -1;
|
|
|
|
H5S_class_t space_type = -1;
|
2009-09-04 22:50:13 +08:00
|
|
|
int i;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if((ndims = H5Sget_simple_extent_dims(space, size, maxsize)) < 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
|
|
|
|
|
|
|
|
if((space_type = H5Sget_simple_extent_type(space)) < 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_type failed");
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
switch(space_type) {
|
|
|
|
case H5S_SCALAR:
|
|
|
|
/* scalar dataspace */
|
|
|
|
h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin, S_SCALAR);
|
|
|
|
break;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
case H5S_SIMPLE:
|
|
|
|
/* simple dataspace */
|
|
|
|
h5tools_str_append(buffer, "%s %s { %s %" H5_PRINTF_LL_WIDTH "u",
|
|
|
|
h5tools_dump_header_format->dataspacedescriptionbegin, S_SIMPLE,
|
|
|
|
h5tools_dump_header_format->dataspacedimbegin, size[0]);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
for(i = 1; i < ndims; i++)
|
|
|
|
h5tools_str_append(buffer, ", %" H5_PRINTF_LL_WIDTH "u", size[i]);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_str_append(buffer, " %s / ", h5tools_dump_header_format->dataspacedimend);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if(maxsize[0] == H5S_UNLIMITED)
|
|
|
|
h5tools_str_append(buffer, "%s %s",
|
|
|
|
h5tools_dump_header_format->dataspacedimbegin, "H5S_UNLIMITED");
|
|
|
|
else
|
|
|
|
h5tools_str_append(buffer, "%s %" H5_PRINTF_LL_WIDTH "u",
|
|
|
|
h5tools_dump_header_format->dataspacedimbegin, maxsize[0]);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
for(i = 1; i < ndims; i++)
|
|
|
|
if(maxsize[i] == H5S_UNLIMITED)
|
|
|
|
h5tools_str_append(buffer, ", %s", "H5S_UNLIMITED");
|
|
|
|
else
|
|
|
|
h5tools_str_append(buffer, ", %" H5_PRINTF_LL_WIDTH "u", maxsize[i]);
|
2005-02-09 04:55:17 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_str_append(buffer, " %s }", h5tools_dump_header_format->dataspacedimend);
|
|
|
|
break;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
case H5S_NULL:
|
|
|
|
/* null dataspace */
|
|
|
|
h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin, S_NULL);
|
|
|
|
break;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
case H5S_NO_CLASS:
|
|
|
|
default:
|
|
|
|
h5tools_str_append(buffer, "%s unknown dataspace %s\n", BEGIN, END);
|
|
|
|
break;
|
|
|
|
} /* end switch */
|
2009-09-15 03:52:42 +08:00
|
|
|
|
|
|
|
CATCH
|
|
|
|
return ret_value;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2009-09-04 22:50:13 +08:00
|
|
|
* Function: print_enum
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Purpose: prints the enum data
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Return: void
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* In/Out: h5tools_str_t *buffer
|
|
|
|
* h5tools_context_t *ctx
|
2001-03-09 04:21:05 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
*-----------------------------------------------------------------------*/
|
2010-01-30 12:29:13 +08:00
|
|
|
int
|
|
|
|
h5tools_print_enum(h5tools_str_t *buffer, hid_t type)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2009-09-18 04:31:44 +08:00
|
|
|
HERR_INIT(int, SUCCEED)
|
2009-09-04 22:50:13 +08:00
|
|
|
char **name = NULL; /*member names */
|
|
|
|
unsigned char *value = NULL; /*value array */
|
|
|
|
unsigned char *copy = NULL; /*a pointer to value array */
|
[svn-r18109] Description:
Bring r18076-18096 from hdf5_1_8_coverity branch to trunk:
r18076:
Correct Coverity issue #1 by removing dead code
r18077:
Fix coverity item 142. When an error occurred while copying a linked list in
H5S_point_copy, the library would not free the partially allocated list. Added
code to free the list in this case.
r18078:
Correct Coverity issue #2 by removing impossible to reach code.
r18079:
Correct #3 by removing impossible to reach code.
r18080:
Correct Coverity issue #4 by removing impossible to reach code.
r18081:
fix coverity 26 , check (dblik->parent) before calls H5HF_man_iblock_detach().
r18082:
Fixed coverity issues 321 and 316.
321: freed sm_buf in error handling to remove resource leak.
Also set sm_buf to NULL after other instances in which
it is freed to prevent double free.
316: initialized nmembs to 0.
r18083:
Correct Coverity issue #6 by removing debugging knob from error reporting code.
r18084:
Fix coverity item 269 + others. When a error occurred in a function using the
h5tools error framework, the "past_catch" variable would not be set to true
because that statement was before the label that goto jumped to. This could
cause a failure in the cleanup section to go back to the start of the section,
freeing variables twice, etc.
Moved the label infront of past_catch=TRUE.
r18085:
fixed coverity #27, check if (heap) before use heap->obj....
r18086:
fixed coverity #28, check curr_span not null before use it at if(curr_span &&
(io_bytes_left==0 || curr_seq>=maxseq))
r18087:
Correct Coverity issue #7 by cleaning up correctly on error
r18088:
Correct Coverity #8 by removing unchanged variable checking code.
r18089:
Correct Coverity issue #9 - remove impossible to reach code.
r18090:
Correct Coverity issue #11 by removing impossible to reach code. Also clean
up some minor style issues.
r18091:
Fix coverity items 314 and 318. Changed the improper assertion of the return
value of a library function to a check, and a return(void) on failure.
r18092:
Fix coverity item 70. Changed the improper assertion of the return value of a
library function to a check, and a return(void) on failure.
r18093:
Correct Coverity issue #12 by removing dead code.
r18094:
Correct Coverity issue #16 by removing debugging code.
r18095:
Fixed coverity issue # 271.
Removed redundant checking and freeing of sm_buf1 and sm_buf2.
r18096:
Correct Coverity issue #17 by refactoring test to remove dead code.
Also, removed previous "coverity" statements in comments, we'll review
those issues again and see if we can figure them out, now that we have more
experience with Coverity.
Tested on:
Mac OS X/32 10.6.2 (amazon)
2010-01-15 11:05:59 +08:00
|
|
|
unsigned nmembs = 0; /*number of members */
|
2009-09-04 22:50:13 +08:00
|
|
|
int nchars; /*number of output characters */
|
2009-09-15 03:52:42 +08:00
|
|
|
hid_t super = -1; /*enum base integer type */
|
2009-09-04 22:50:13 +08:00
|
|
|
hid_t native = -1; /*native integer datatype */
|
2010-01-30 12:29:13 +08:00
|
|
|
H5T_sign_t sign_type; /*sign of value type */
|
2009-09-15 03:52:42 +08:00
|
|
|
size_t type_size; /*value type size */
|
2009-09-04 22:50:13 +08:00
|
|
|
size_t dst_size; /*destination value type size */
|
2009-12-13 13:28:30 +08:00
|
|
|
int snmembs;
|
2009-09-04 22:50:13 +08:00
|
|
|
unsigned i;
|
|
|
|
|
2009-12-13 13:28:30 +08:00
|
|
|
if((snmembs = H5Tget_nmembers(type)) < 0)
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
|
2009-12-13 13:28:30 +08:00
|
|
|
nmembs = (unsigned)snmembs;
|
2009-09-04 22:50:13 +08:00
|
|
|
assert(nmembs > 0);
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if((super = H5Tget_super(type)) < 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed");
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if((type_size = H5Tget_size(type)) <= 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size(type) failed");
|
2009-12-13 13:28:30 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Determine what datatype to use for the native values. To simplify
|
|
|
|
* things we entertain three possibilities:
|
|
|
|
* 1. long long -- the largest native signed integer
|
2009-09-15 03:52:42 +08:00
|
|
|
* 2. unsigned long long -- the largest native unsigned integer
|
|
|
|
* 3. raw format
|
2009-09-04 22:50:13 +08:00
|
|
|
*/
|
2009-12-13 13:28:30 +08:00
|
|
|
if(type_size <= sizeof(long long)) {
|
2009-09-04 22:50:13 +08:00
|
|
|
dst_size = sizeof(long long);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if((sign_type = H5Tget_sign(type))<0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_sign failed");
|
2009-12-13 13:28:30 +08:00
|
|
|
if(H5T_SGN_NONE == sign_type)
|
2009-09-04 22:50:13 +08:00
|
|
|
native = H5T_NATIVE_ULLONG;
|
2009-12-13 13:28:30 +08:00
|
|
|
else
|
2009-09-04 22:50:13 +08:00
|
|
|
native = H5T_NATIVE_LLONG;
|
2009-12-13 13:28:30 +08:00
|
|
|
} /* end if */
|
|
|
|
else
|
2009-09-15 03:52:42 +08:00
|
|
|
dst_size = type_size;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Get the names and raw values of all members */
|
2010-10-21 21:08:44 +08:00
|
|
|
if(NULL == (name = (char **)HDcalloc(nmembs, sizeof(char *))))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for member name");
|
2010-10-21 21:08:44 +08:00
|
|
|
if(NULL == (value = (unsigned char *)HDcalloc(nmembs, MAX(type_size, dst_size))))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for member value");
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
for (i = 0; i < nmembs; i++) {
|
|
|
|
name[i] = H5Tget_member_name(type, i);
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Tget_member_value(type, i, value + i * type_size) < 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_member_value failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Convert values to native datatype */
|
|
|
|
if (native > 0)
|
2009-09-15 03:52:42 +08:00
|
|
|
if(H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT) < 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tconvert failed");
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Sort members by increasing value
|
|
|
|
* ***not implemented yet***
|
|
|
|
*/
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Print members */
|
|
|
|
for (i = 0; i < nmembs; i++) {
|
|
|
|
h5tools_str_append(buffer, "\"%s\"", name[i]);
|
|
|
|
nchars = strlen(name[i]);
|
|
|
|
h5tools_str_append(buffer, "%*s ", MAX(0, 16 - nchars), "");
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (native < 0) {
|
|
|
|
size_t j;
|
2004-05-21 23:58:53 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_str_append(buffer, "0x");
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
for (j = 0; j < dst_size; j++)
|
|
|
|
h5tools_str_append(buffer, "%02x", value[i * dst_size + j]);
|
|
|
|
}
|
|
|
|
else if (H5T_SGN_NONE == H5Tget_sign(native)) {
|
|
|
|
/*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
|
|
|
|
*strangely, unless use another pointer "copy".*/
|
|
|
|
copy = value + i * dst_size;
|
|
|
|
h5tools_str_append(buffer, "%" H5_PRINTF_LL_WIDTH "u", *((unsigned long long *) ((void *) copy)));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
|
|
|
|
*strangely, unless use another pointer "copy".*/
|
|
|
|
copy = value + i * dst_size;
|
|
|
|
h5tools_str_append(buffer, "%" H5_PRINTF_LL_WIDTH "d", *((long long *) ((void *) copy)));
|
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_str_append(buffer, ";\n");
|
|
|
|
}
|
2009-09-15 03:52:42 +08:00
|
|
|
|
|
|
|
CATCH
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
if(name) {
|
|
|
|
/* Release resources */
|
[svn-r18109] Description:
Bring r18076-18096 from hdf5_1_8_coverity branch to trunk:
r18076:
Correct Coverity issue #1 by removing dead code
r18077:
Fix coverity item 142. When an error occurred while copying a linked list in
H5S_point_copy, the library would not free the partially allocated list. Added
code to free the list in this case.
r18078:
Correct Coverity issue #2 by removing impossible to reach code.
r18079:
Correct #3 by removing impossible to reach code.
r18080:
Correct Coverity issue #4 by removing impossible to reach code.
r18081:
fix coverity 26 , check (dblik->parent) before calls H5HF_man_iblock_detach().
r18082:
Fixed coverity issues 321 and 316.
321: freed sm_buf in error handling to remove resource leak.
Also set sm_buf to NULL after other instances in which
it is freed to prevent double free.
316: initialized nmembs to 0.
r18083:
Correct Coverity issue #6 by removing debugging knob from error reporting code.
r18084:
Fix coverity item 269 + others. When a error occurred in a function using the
h5tools error framework, the "past_catch" variable would not be set to true
because that statement was before the label that goto jumped to. This could
cause a failure in the cleanup section to go back to the start of the section,
freeing variables twice, etc.
Moved the label infront of past_catch=TRUE.
r18085:
fixed coverity #27, check if (heap) before use heap->obj....
r18086:
fixed coverity #28, check curr_span not null before use it at if(curr_span &&
(io_bytes_left==0 || curr_seq>=maxseq))
r18087:
Correct Coverity issue #7 by cleaning up correctly on error
r18088:
Correct Coverity #8 by removing unchanged variable checking code.
r18089:
Correct Coverity issue #9 - remove impossible to reach code.
r18090:
Correct Coverity issue #11 by removing impossible to reach code. Also clean
up some minor style issues.
r18091:
Fix coverity items 314 and 318. Changed the improper assertion of the return
value of a library function to a check, and a return(void) on failure.
r18092:
Fix coverity item 70. Changed the improper assertion of the return value of a
library function to a check, and a return(void) on failure.
r18093:
Correct Coverity issue #12 by removing dead code.
r18094:
Correct Coverity issue #16 by removing debugging code.
r18095:
Fixed coverity issue # 271.
Removed redundant checking and freeing of sm_buf1 and sm_buf2.
r18096:
Correct Coverity issue #17 by refactoring test to remove dead code.
Also, removed previous "coverity" statements in comments, we'll review
those issues again and see if we can figure them out, now that we have more
experience with Coverity.
Tested on:
Mac OS X/32 10.6.2 (amazon)
2010-01-15 11:05:59 +08:00
|
|
|
for(i = 0; i < nmembs; i++)
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
if(name[i])
|
|
|
|
free(name[i]);
|
|
|
|
free(name);
|
|
|
|
} /* end if */
|
2009-09-04 22:50:13 +08:00
|
|
|
|
[svn-r17953] Description:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-04 03:11:29 +08:00
|
|
|
if(value)
|
|
|
|
free(value);
|
|
|
|
|
|
|
|
if(super >= 0 && H5Tclose(super) < 0)
|
2009-12-13 13:28:30 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not close datatype's super class");
|
2009-09-04 22:50:13 +08:00
|
|
|
|
[svn-r18109] Description:
Bring r18076-18096 from hdf5_1_8_coverity branch to trunk:
r18076:
Correct Coverity issue #1 by removing dead code
r18077:
Fix coverity item 142. When an error occurred while copying a linked list in
H5S_point_copy, the library would not free the partially allocated list. Added
code to free the list in this case.
r18078:
Correct Coverity issue #2 by removing impossible to reach code.
r18079:
Correct #3 by removing impossible to reach code.
r18080:
Correct Coverity issue #4 by removing impossible to reach code.
r18081:
fix coverity 26 , check (dblik->parent) before calls H5HF_man_iblock_detach().
r18082:
Fixed coverity issues 321 and 316.
321: freed sm_buf in error handling to remove resource leak.
Also set sm_buf to NULL after other instances in which
it is freed to prevent double free.
316: initialized nmembs to 0.
r18083:
Correct Coverity issue #6 by removing debugging knob from error reporting code.
r18084:
Fix coverity item 269 + others. When a error occurred in a function using the
h5tools error framework, the "past_catch" variable would not be set to true
because that statement was before the label that goto jumped to. This could
cause a failure in the cleanup section to go back to the start of the section,
freeing variables twice, etc.
Moved the label infront of past_catch=TRUE.
r18085:
fixed coverity #27, check if (heap) before use heap->obj....
r18086:
fixed coverity #28, check curr_span not null before use it at if(curr_span &&
(io_bytes_left==0 || curr_seq>=maxseq))
r18087:
Correct Coverity issue #7 by cleaning up correctly on error
r18088:
Correct Coverity #8 by removing unchanged variable checking code.
r18089:
Correct Coverity issue #9 - remove impossible to reach code.
r18090:
Correct Coverity issue #11 by removing impossible to reach code. Also clean
up some minor style issues.
r18091:
Fix coverity items 314 and 318. Changed the improper assertion of the return
value of a library function to a check, and a return(void) on failure.
r18092:
Fix coverity item 70. Changed the improper assertion of the return value of a
library function to a check, and a return(void) on failure.
r18093:
Correct Coverity issue #12 by removing dead code.
r18094:
Correct Coverity issue #16 by removing debugging code.
r18095:
Fixed coverity issue # 271.
Removed redundant checking and freeing of sm_buf1 and sm_buf2.
r18096:
Correct Coverity issue #17 by refactoring test to remove dead code.
Also, removed previous "coverity" statements in comments, we'll review
those issues again and see if we can figure them out, now that we have more
experience with Coverity.
Tested on:
Mac OS X/32 10.6.2 (amazon)
2010-01-15 11:05:59 +08:00
|
|
|
if(0 == nmembs)
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_str_append(buffer, "\n<empty>");
|
2009-09-15 03:52:42 +08:00
|
|
|
|
|
|
|
return ret_value;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2009-09-04 22:50:13 +08:00
|
|
|
* Function: dump_datatype
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Purpose: Dump the datatype. Datatype can be HDF5 predefined
|
|
|
|
* atomic datatype or committed/transient datatype.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Return: void
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* In/Out: h5tools_context_t *ctx
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
void
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info,
|
2010-01-30 12:29:13 +08:00
|
|
|
h5tools_context_t *ctx, hid_t type)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2009-09-04 22:50:13 +08:00
|
|
|
size_t ncols = 80; /* available output width */
|
|
|
|
h5tools_str_t buffer; /* string into which to render */
|
|
|
|
hsize_t curr_pos; /* total data element position */
|
|
|
|
hsize_t elmt_counter = 0;/* counts the # elements printed.*/
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* setup */
|
|
|
|
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (info->line_ncols > 0)
|
|
|
|
ncols = info->line_ncols;
|
|
|
|
|
|
|
|
/* pass to the prefix in h5tools_simple_prefix the total position
|
|
|
|
* instead of the current stripmine position i; this is necessary
|
|
|
|
* to print the array indices
|
|
|
|
*/
|
|
|
|
curr_pos = ctx->sm_pos;
|
|
|
|
|
|
|
|
h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
|
|
|
|
/* Render the element */
|
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
|
|
|
|
ctx->indent_level++;
|
|
|
|
h5tools_str_append(&buffer, "%s %s ",
|
|
|
|
h5tools_dump_header_format->datatypebegin,
|
|
|
|
h5tools_dump_header_format->datatypeblockbegin);
|
|
|
|
|
|
|
|
h5tools_print_datatype(&buffer, info, ctx, type);
|
|
|
|
|
|
|
|
if (HDstrlen(h5tools_dump_header_format->datatypeblockend)) {
|
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeblockend);
|
|
|
|
if (HDstrlen(h5tools_dump_header_format->datatypeend))
|
|
|
|
h5tools_str_append(&buffer, " ");
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
2009-09-04 22:50:13 +08:00
|
|
|
if (HDstrlen(h5tools_dump_header_format->datatypeend))
|
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeend);
|
|
|
|
h5tools_str_append(&buffer, "\n");
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-08 21:03:38 +08:00
|
|
|
curr_pos = h5tools_render_element(stream, info, ctx, &buffer, &curr_pos,
|
|
|
|
ncols, elmt_counter, 0);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
ctx->indent_level--;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
2004-10-07 00:11:18 +08:00
|
|
|
|
2005-02-09 04:55:17 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: init_acc_pos
|
|
|
|
*
|
|
|
|
* Purpose: initialize accumulator and matrix position
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
void
|
|
|
|
init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
|
2005-02-09 04:55:17 +08:00
|
|
|
{
|
2009-09-04 22:50:13 +08:00
|
|
|
int i;
|
2005-02-09 04:55:17 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
assert(ctx->ndims);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->acc[ctx->ndims - 1] = 1;
|
|
|
|
for (i = (ctx->ndims - 2); i >= 0; i--) {
|
|
|
|
ctx->acc[i] = ctx->acc[i + 1] * dims[i + 1];
|
|
|
|
}
|
|
|
|
for (i = 0; i < ctx->ndims; i++)
|
|
|
|
ctx->pos[i] = 0;
|
2005-02-09 04:55:17 +08:00
|
|
|
}
|
|
|
|
|
2006-06-26 22:41:59 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2006-07-27 23:01:48 +08:00
|
|
|
* Function: do_bin_output
|
2006-06-26 22:41:59 +08:00
|
|
|
*
|
2006-07-27 23:01:48 +08:00
|
|
|
* Purpose: Dump memory buffer to a binary file stream
|
2006-06-26 22:41:59 +08:00
|
|
|
*
|
2006-07-27 23:01:48 +08:00
|
|
|
* Return: Success: SUCCEED
|
|
|
|
* Failure: FAIL
|
2006-06-26 22:41:59 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2006-08-03 07:41:53 +08:00
|
|
|
static
|
2010-08-10 02:15:37 +08:00
|
|
|
int do_bin_output(FILE *stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem)
|
2006-06-26 22:41:59 +08:00
|
|
|
{
|
2009-09-18 04:31:44 +08:00
|
|
|
HERR_INIT(int, SUCCEED)
|
2009-09-04 22:50:13 +08:00
|
|
|
unsigned char *mem = (unsigned char*)_mem;
|
|
|
|
size_t size; /* datum size */
|
|
|
|
hsize_t i; /* element counter */
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if((size = H5Tget_size(tid)) == 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
for (i = 0; i < nelmts; i++) {
|
2010-08-10 02:15:37 +08:00
|
|
|
if (render_bin_output(stream, container, tid, mem + i * size) < 0) {
|
2009-09-04 22:50:13 +08:00
|
|
|
printf("\nError in writing binary stream\n");
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
CATCH
|
|
|
|
return ret_value;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2006-06-26 22:41:59 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2006-07-27 23:01:48 +08:00
|
|
|
* Function: render_bin_output
|
2006-06-26 22:41:59 +08:00
|
|
|
*
|
2006-07-27 23:01:48 +08:00
|
|
|
* Purpose: Write one element of memory buffer to a binary file stream
|
2006-06-26 22:41:59 +08:00
|
|
|
*
|
2006-07-27 23:01:48 +08:00
|
|
|
* Return: Success: SUCCEED
|
|
|
|
* Failure: FAIL
|
2006-06-26 22:41:59 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
static int
|
2010-08-10 02:15:37 +08:00
|
|
|
render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem)
|
2006-06-26 22:41:59 +08:00
|
|
|
{
|
2009-09-18 04:31:44 +08:00
|
|
|
HERR_INIT(int, SUCCEED)
|
2009-09-04 22:50:13 +08:00
|
|
|
unsigned char *mem = (unsigned char*)_mem;
|
|
|
|
size_t size; /* datum size */
|
|
|
|
float tempfloat;
|
|
|
|
double tempdouble;
|
|
|
|
unsigned long long tempullong;
|
|
|
|
long long templlong;
|
|
|
|
unsigned long tempulong;
|
|
|
|
long templong;
|
|
|
|
unsigned int tempuint;
|
|
|
|
int tempint;
|
|
|
|
unsigned short tempushort;
|
|
|
|
short tempshort;
|
|
|
|
unsigned char tempuchar;
|
|
|
|
char tempschar;
|
2006-06-26 22:41:59 +08:00
|
|
|
#if H5_SIZEOF_LONG_DOUBLE !=0
|
2009-09-04 22:50:13 +08:00
|
|
|
long double templdouble;
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
static char fmt_llong[8], fmt_ullong[8];
|
|
|
|
if (!fmt_llong[0]) {
|
|
|
|
sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH);
|
|
|
|
sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH);
|
|
|
|
}
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2006-08-03 07:41:53 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
if((size = H5Tget_size(tid)) == 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
|
2006-08-03 07:41:53 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (H5Tequal(tid, H5T_NATIVE_FLOAT)) {
|
|
|
|
memcpy(&tempfloat, mem, sizeof(float));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%g ", tempfloat);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempfloat, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) {
|
|
|
|
memcpy(&tempdouble, mem, sizeof(double));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%g ", tempdouble);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempdouble, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2006-06-26 22:41:59 +08:00
|
|
|
#if H5_SIZEOF_LONG_DOUBLE !=0
|
2009-09-04 22:50:13 +08:00
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) {
|
|
|
|
memcpy(&templdouble, mem, sizeof(long double));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%Lf ", templdouble);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&templdouble, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
else if (H5T_STRING == H5Tget_class(tid)) {
|
|
|
|
unsigned int i;
|
|
|
|
H5T_str_t pad;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
pad = H5Tget_strpad(tid);
|
|
|
|
|
|
|
|
if (H5Tis_variable_str(tid)) {
|
|
|
|
s = *(char**) mem;
|
|
|
|
if (s != NULL)
|
|
|
|
size = HDstrlen(s);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
s = (char *) mem;
|
2009-09-15 03:52:42 +08:00
|
|
|
if((size = H5Tget_size(tid)) == 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
|
|
|
|
memcpy(&tempuchar, &s[i], sizeof(unsigned char));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%d", tempuchar);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempuchar, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
} /* i */
|
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_INT)) {
|
|
|
|
memcpy(&tempint, mem, sizeof(int));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%d ", tempint);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempint, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_UINT)) {
|
|
|
|
memcpy(&tempuint, mem, sizeof(unsigned int));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%u ", tempuint);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempuint, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_SCHAR)) {
|
|
|
|
memcpy(&tempschar, mem, sizeof(char));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%d ", tempschar);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempschar, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_UCHAR)) {
|
|
|
|
memcpy(&tempuchar, mem, sizeof(unsigned char));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%u ", tempuchar);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempuchar, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_SHORT)) {
|
|
|
|
memcpy(&tempshort, mem, sizeof(short));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%d ", tempshort);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempshort, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_USHORT)) {
|
|
|
|
memcpy(&tempushort, mem, sizeof(unsigned short));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%u ", tempushort);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempushort, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_LONG)) {
|
|
|
|
memcpy(&templong, mem, sizeof(long));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%ld ", templong);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&templong, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_ULONG)) {
|
|
|
|
memcpy(&tempulong, mem, sizeof(unsigned long));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%lu ", tempulong);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempulong, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_LLONG)) {
|
|
|
|
memcpy(&templlong, mem, sizeof(long long));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, fmt_llong, templlong);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&templlong, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_ULLONG)) {
|
|
|
|
memcpy(&tempullong, mem, sizeof(unsigned long long));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, fmt_ullong, tempullong);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempullong, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_HSSIZE)) {
|
|
|
|
if (sizeof(hssize_t) == sizeof(int)) {
|
|
|
|
memcpy(&tempint, mem, sizeof(int));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%d ", tempint);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempint, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (sizeof(hssize_t) == sizeof(long)) {
|
|
|
|
memcpy(&templong, mem, sizeof(long));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%ld ", templong);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&templong, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
memcpy(&templlong, mem, sizeof(long long));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, fmt_llong, templlong);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&templlong, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_NATIVE_HSIZE)) {
|
|
|
|
if (sizeof(hsize_t) == sizeof(int)) {
|
|
|
|
memcpy(&tempuint, mem, sizeof(unsigned int));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%u ", tempuint);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempuint, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else if (sizeof(hsize_t) == sizeof(long)) {
|
|
|
|
memcpy(&tempulong, mem, sizeof(unsigned long));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%lu ", tempulong);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempulong, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
memcpy(&tempullong, mem, sizeof(unsigned long long));
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, fmt_ullong, tempullong);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&tempullong, size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (H5Tget_class(tid) == H5T_COMPOUND) {
|
|
|
|
unsigned j;
|
|
|
|
hid_t memb;
|
|
|
|
unsigned nmembs;
|
|
|
|
size_t offset;
|
|
|
|
|
|
|
|
nmembs = H5Tget_nmembers(tid);
|
|
|
|
|
|
|
|
for (j = 0; j < nmembs; j++) {
|
|
|
|
offset = H5Tget_member_offset(tid, j);
|
|
|
|
memb = H5Tget_member_type(tid, j);
|
|
|
|
|
2010-08-10 02:15:37 +08:00
|
|
|
if (render_bin_output(stream, container, memb, mem + offset) < 0)
|
2009-09-04 22:50:13 +08:00
|
|
|
return FAIL;
|
|
|
|
|
|
|
|
H5Tclose(memb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (H5Tget_class(tid) == H5T_ENUM) {
|
|
|
|
unsigned int i;
|
|
|
|
if (1 == size) {
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "0x%02x", mem[0]);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&mem[0], size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (i = 0; i < size; i++) {
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%s%02x", i?":":"", mem[i]);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&mem[i], sizeof(char), 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
} /*i*/
|
|
|
|
}/*else 1 */
|
|
|
|
}
|
|
|
|
else if (H5Tget_class(tid) == H5T_ARRAY) {
|
|
|
|
int k, ndims;
|
|
|
|
hsize_t i, dims[H5S_MAX_RANK], temp_nelmts, nelmts;
|
|
|
|
hid_t memb;
|
|
|
|
|
|
|
|
/* get the array's base datatype for each element */
|
|
|
|
memb = H5Tget_super(tid);
|
|
|
|
size = H5Tget_size(memb);
|
|
|
|
ndims = H5Tget_array_ndims(tid);
|
|
|
|
H5Tget_array_dims2(tid, dims);
|
|
|
|
assert(ndims >= 1 && ndims <= H5S_MAX_RANK);
|
|
|
|
|
|
|
|
/* calculate the number of array elements */
|
|
|
|
for (k = 0, nelmts = 1; k < ndims; k++) {
|
|
|
|
temp_nelmts = nelmts;
|
|
|
|
temp_nelmts *= dims[k];
|
|
|
|
nelmts = (size_t) temp_nelmts;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dump the array element */
|
|
|
|
for (i = 0; i < nelmts; i++) {
|
2010-08-10 02:15:37 +08:00
|
|
|
if (render_bin_output(stream, container, memb, mem + i * size) < 0)
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
H5Tclose(memb);
|
|
|
|
}
|
|
|
|
else if (H5Tget_class(tid) == H5T_VLEN) {
|
|
|
|
unsigned int i;
|
|
|
|
hsize_t nelmts;
|
|
|
|
hid_t memb;
|
|
|
|
|
|
|
|
/* get the VL sequences's base datatype for each element */
|
|
|
|
memb = H5Tget_super(tid);
|
|
|
|
size = H5Tget_size(memb);
|
|
|
|
|
|
|
|
/* Get the number of sequence elements */
|
|
|
|
nelmts = ((hvl_t *) mem)->len;
|
|
|
|
|
|
|
|
for (i = 0; i < nelmts; i++) {
|
|
|
|
/* dump the array element */
|
2010-08-10 02:15:37 +08:00
|
|
|
if (render_bin_output(stream, container, memb, ((char *) (((hvl_t *) mem)->p)) + i * size) < 0)
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
H5Tclose(memb);
|
|
|
|
}
|
2010-08-10 02:15:37 +08:00
|
|
|
else if (H5Tequal(tid, H5T_STD_REF_DSETREG)) {
|
|
|
|
if (region_output) {
|
|
|
|
/* region data */
|
|
|
|
hid_t region_id, region_space;
|
|
|
|
H5S_sel_type region_type;
|
|
|
|
|
2011-07-19 05:23:02 +08:00
|
|
|
region_id = H5Rdereference2(container, H5P_DATASET_ACCESS_DEFAULT, H5R_DATASET_REGION, mem);
|
2010-08-10 02:15:37 +08:00
|
|
|
if (region_id >= 0) {
|
|
|
|
region_space = H5Rget_region(container, H5R_DATASET_REGION, mem);
|
|
|
|
if (region_space >= 0) {
|
|
|
|
region_type = H5Sget_select_type(region_space);
|
2010-08-13 05:11:00 +08:00
|
|
|
if(region_type == H5S_SEL_POINTS)
|
|
|
|
render_bin_output_region_points(region_space, region_id, stream, container);
|
2010-08-10 02:15:37 +08:00
|
|
|
else
|
2010-08-13 05:11:00 +08:00
|
|
|
render_bin_output_region_blocks(region_space, region_id, stream, container);
|
2010-08-10 02:15:37 +08:00
|
|
|
H5Sclose(region_space);
|
|
|
|
} /* end if (region_space >= 0) */
|
|
|
|
H5Dclose(region_id);
|
|
|
|
} /* end if (region_id >= 0) */
|
|
|
|
} /* end if (region_output... */
|
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_STD_REF_OBJ)) {
|
|
|
|
}
|
2009-09-04 22:50:13 +08:00
|
|
|
else {
|
|
|
|
size_t i;
|
|
|
|
if (1 == size) {
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "0x%02x", mem[0]);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&mem[0], size, 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (i = 0; i < size; i++) {
|
2006-07-16 03:49:04 +08:00
|
|
|
#ifdef DEBUG_H5DUMP_BIN
|
2009-09-04 22:50:13 +08:00
|
|
|
fprintf(stream, "%s%02x", i?":":"", mem[i]);
|
2006-06-26 22:41:59 +08:00
|
|
|
#else
|
2009-09-04 22:50:13 +08:00
|
|
|
if (1 != fwrite(&mem[i], sizeof(char), 1, stream))
|
2009-09-15 03:52:42 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
2006-06-26 22:41:59 +08:00
|
|
|
#endif
|
2009-09-04 22:50:13 +08:00
|
|
|
} /*i*/
|
|
|
|
}/*else 1 */
|
|
|
|
}
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
CATCH
|
|
|
|
return ret_value;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
|
2010-08-10 02:15:37 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print the data values from a dataset referenced by region blocks.
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is a special case subfunction to print the data in a region reference of type blocks.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* The function returns FAIL if there was an error, otherwise SUCEED
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-08-13 05:11:00 +08:00
|
|
|
static int
|
|
|
|
render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
|
|
|
|
hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata)
|
|
|
|
{
|
2010-08-10 02:15:37 +08:00
|
|
|
hsize_t *dims1 = NULL;
|
|
|
|
hsize_t *start = NULL;
|
|
|
|
hsize_t *count = NULL;
|
|
|
|
size_t numelem;
|
|
|
|
hsize_t total_size[H5S_MAX_RANK];
|
|
|
|
int jndx;
|
|
|
|
int type_size;
|
|
|
|
hid_t mem_space = -1;
|
|
|
|
void *region_buf = NULL;
|
|
|
|
int blkndx;
|
|
|
|
hid_t sid1 = -1;
|
2010-10-21 21:08:44 +08:00
|
|
|
int ret_value = SUCCEED;
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
/* Get the dataspace of the dataset */
|
|
|
|
if((sid1 = H5Dget_space(region_id)) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
|
|
|
|
|
|
|
|
/* Allocate space for the dimension array */
|
|
|
|
if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
|
|
|
|
|
|
|
|
/* find the dimensions of each data space from the block coordinates */
|
|
|
|
numelem = 1;
|
|
|
|
for (jndx = 0; jndx < ndims; jndx++) {
|
|
|
|
dims1[jndx] = ptdata[jndx + ndims] - ptdata[jndx] + 1;
|
|
|
|
numelem = dims1[jndx] * numelem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create dataspace for reading buffer */
|
|
|
|
if((mem_space = H5Screate_simple(ndims, dims1, NULL)) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
|
|
|
|
|
|
|
|
if((type_size = H5Tget_size(type_id)) == 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
|
|
|
|
|
|
|
|
if((region_buf = HDmalloc(type_size * numelem)) == NULL)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "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)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start");
|
|
|
|
|
|
|
|
if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count");
|
|
|
|
|
|
|
|
for (blkndx = 0; blkndx < nblocks; blkndx++) {
|
|
|
|
for (jndx = 0; jndx < ndims; jndx++) {
|
|
|
|
start[jndx] = ptdata[jndx + blkndx * ndims * 2];
|
|
|
|
count[jndx] = dims1[jndx];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
|
|
|
|
|
|
|
|
if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dread failed");
|
|
|
|
|
|
|
|
if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
|
|
|
|
|
|
|
|
for (jndx = 0; jndx < numelem; jndx++) {
|
|
|
|
|
|
|
|
render_bin_output(stream, container, type_id,
|
|
|
|
((char*)region_buf + jndx * type_size));
|
|
|
|
/* Render the region data element end */
|
|
|
|
} /* end for (jndx = 0; jndx < numelem; jndx++) */
|
|
|
|
} /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */
|
|
|
|
|
|
|
|
done:
|
|
|
|
HDfree(start);
|
|
|
|
HDfree(count);
|
|
|
|
HDfree(region_buf);
|
|
|
|
HDfree(dims1);
|
|
|
|
|
|
|
|
if(H5Sclose(mem_space) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
|
|
|
|
if(H5Sclose(sid1) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
|
|
|
|
|
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print some values from a dataset referenced by region blocks.
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is a special case subfunction to dump a region reference using blocks.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* The function returns False if ERROR, otherwise True
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-08-13 05:11:00 +08:00
|
|
|
static hbool_t
|
2010-08-10 02:15:37 +08:00
|
|
|
render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
|
2010-08-13 05:11:00 +08:00
|
|
|
FILE *stream, hid_t container)
|
|
|
|
{
|
2010-08-10 02:15:37 +08:00
|
|
|
HERR_INIT(hbool_t, TRUE)
|
|
|
|
hssize_t nblocks;
|
|
|
|
hsize_t alloc_size;
|
|
|
|
hsize_t *ptdata = NULL;
|
|
|
|
int ndims;
|
|
|
|
hid_t dtype;
|
|
|
|
hid_t type_id;
|
|
|
|
|
|
|
|
if((nblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
|
|
|
|
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed");
|
|
|
|
|
|
|
|
/* Print block information */
|
|
|
|
if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
|
|
|
|
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
|
|
|
|
|
|
|
|
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
|
|
|
|
assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
|
|
|
|
if((ptdata = (hsize_t*) malloc((size_t) alloc_size)) == NULL)
|
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
|
|
|
|
|
|
|
|
H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t);
|
|
|
|
if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0)
|
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed");
|
|
|
|
|
|
|
|
if((dtype = H5Dget_type(region_id)) < 0)
|
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
|
|
|
|
if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
|
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed");
|
|
|
|
|
2010-08-13 05:11:00 +08:00
|
|
|
render_bin_output_region_data_blocks(region_id, stream, container, ndims,
|
|
|
|
type_id, nblocks, ptdata);
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
done:
|
|
|
|
free(ptdata);
|
|
|
|
|
|
|
|
if(H5Tclose(type_id) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
|
|
|
|
|
|
|
if(H5Tclose(dtype) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
|
|
|
|
|
|
|
H5_LEAVE(TRUE)
|
|
|
|
|
|
|
|
CATCH
|
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print the data values from a dataset referenced by region points.
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is a special case subfunction to print the data in a region reference of type points.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* The function returns FAIL on error, otherwise SUCCEED
|
|
|
|
*
|
|
|
|
* Parameters Description:
|
|
|
|
* h5tools_str_t *buffer is the string into which to render
|
|
|
|
* size_t ncols
|
|
|
|
* int ndims is the number of dimensions of the region element
|
|
|
|
* hssize_t npoints is the number of points in the region
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
render_bin_output_region_data_points(hid_t region_space, hid_t region_id,
|
|
|
|
FILE *stream, hid_t container,
|
2010-08-13 05:11:00 +08:00
|
|
|
int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata)
|
|
|
|
{
|
2010-08-10 02:15:37 +08:00
|
|
|
hsize_t *dims1 = NULL;
|
|
|
|
int jndx;
|
|
|
|
int type_size;
|
|
|
|
hid_t mem_space = -1;
|
|
|
|
void *region_buf = NULL;
|
2010-10-21 21:08:44 +08:00
|
|
|
int ret_value = SUCCEED;
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
if((type_size = H5Tget_size(type_id)) == 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
|
|
|
|
|
|
|
|
if((region_buf = HDmalloc(type_size * npoints)) == NULL)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for region");
|
|
|
|
|
|
|
|
/* Allocate space for the dimension array */
|
|
|
|
if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
|
|
|
|
|
|
|
|
dims1[0] = npoints;
|
|
|
|
if((mem_space = H5Screate_simple(1, dims1, NULL)) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
|
|
|
|
|
|
|
|
if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
|
|
|
|
for (jndx = 0; jndx < npoints; jndx++) {
|
|
|
|
if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
|
|
|
|
|
2011-05-12 04:45:54 +08:00
|
|
|
render_bin_output(stream, container, type_id, ((char*)region_buf + jndx * type_size));
|
2010-08-10 02:15:37 +08:00
|
|
|
} /* end for (jndx = 0; jndx < npoints; jndx++) */
|
|
|
|
|
|
|
|
done:
|
|
|
|
HDfree(region_buf);
|
|
|
|
HDfree(dims1);
|
|
|
|
|
|
|
|
if(H5Sclose(mem_space) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
|
2010-10-21 21:08:44 +08:00
|
|
|
|
2010-08-10 02:15:37 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print some values from a dataset referenced by region points.
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is a special case subfunction to dump a region reference using points.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* The function returns False if the last dimension has been reached, otherwise True
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-08-13 05:11:00 +08:00
|
|
|
static hbool_t
|
2010-08-10 02:15:37 +08:00
|
|
|
render_bin_output_region_points(hid_t region_space, hid_t region_id,
|
2010-08-13 05:11:00 +08:00
|
|
|
FILE *stream, hid_t container)
|
|
|
|
{
|
2010-08-10 02:15:37 +08:00
|
|
|
HERR_INIT(hbool_t, TRUE)
|
|
|
|
hssize_t npoints;
|
2010-08-20 23:48:12 +08:00
|
|
|
hsize_t alloc_size;
|
|
|
|
hsize_t *ptdata;
|
2010-08-10 02:15:37 +08:00
|
|
|
int ndims;
|
|
|
|
hid_t dtype;
|
|
|
|
hid_t type_id;
|
|
|
|
|
|
|
|
if((npoints = H5Sget_select_elem_npoints(region_space)) <= 0)
|
|
|
|
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed");
|
|
|
|
|
|
|
|
/* Allocate space for the dimension array */
|
|
|
|
if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
|
|
|
|
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
|
|
|
|
|
2010-08-20 23:48:12 +08:00
|
|
|
alloc_size = npoints * ndims * sizeof(ptdata[0]);
|
|
|
|
assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
|
2010-10-21 21:08:44 +08:00
|
|
|
if(NULL == (ptdata = (hsize_t *)HDmalloc((size_t) alloc_size)))
|
2010-08-20 23:48:12 +08:00
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
|
|
|
|
|
2010-08-10 02:15:37 +08:00
|
|
|
H5_CHECK_OVERFLOW(npoints, hssize_t, hsize_t);
|
|
|
|
if(H5Sget_select_elem_pointlist(region_space, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0)
|
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_pointlist failed");
|
|
|
|
|
|
|
|
if((dtype = H5Dget_type(region_id)) < 0)
|
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
|
|
|
|
|
|
|
|
if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
|
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed");
|
|
|
|
|
|
|
|
render_bin_output_region_data_points(region_space, region_id,
|
|
|
|
stream, container, ndims, type_id, npoints, ptdata);
|
|
|
|
|
|
|
|
done:
|
|
|
|
free(ptdata);
|
|
|
|
|
|
|
|
if(H5Tclose(type_id) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
|
|
|
|
|
|
|
if(H5Tclose(dtype) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
|
|
|
|
|
|
|
H5_LEAVE(ret_value)
|
|
|
|
CATCH
|
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_is_zero
|
|
|
|
*
|
|
|
|
* Purpose: Determines if memory is initialized to all zero bytes.
|
|
|
|
*
|
|
|
|
* Return: TRUE if all bytes are zero; FALSE otherwise
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
static
|
|
|
|
hbool_t h5tools_is_zero(const void *_mem, size_t size)
|
2009-09-04 22:50:13 +08:00
|
|
|
{
|
|
|
|
const unsigned char *mem = (const unsigned char *) _mem;
|
2006-08-03 07:41:53 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
while (size-- > 0)
|
|
|
|
if (mem[size])
|
|
|
|
return FALSE;
|
2006-06-26 22:41:59 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
return TRUE;
|
2006-06-26 22:41:59 +08:00
|
|
|
}
|
|
|
|
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_is_obj_same
|
|
|
|
*
|
|
|
|
* Purpose: Check if two given object IDs or link names point to the same object.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* hid_t loc_id1: location of the first object
|
|
|
|
* char *name1: link name of the first object.
|
|
|
|
* Use "." or NULL if loc_id1 is the object to be compared.
|
|
|
|
* hid_t loc_id2: location of the second object
|
|
|
|
* char *name1: link name of the first object.
|
|
|
|
* Use "." or NULL if loc_id2 is the object to be compared.
|
|
|
|
*
|
|
|
|
* Return: TRUE if it is the same object; FALSE otherwise.
|
|
|
|
*
|
|
|
|
* Programmer: Peter Cao
|
|
|
|
* 4/27/2011
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
hbool_t h5tools_is_obj_same(hid_t loc_id1, const char *name1,
|
2011-05-04 01:56:23 +08:00
|
|
|
hid_t loc_id2, const char *name2)
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
{
|
|
|
|
H5O_info_t oinfo1, oinfo2;
|
|
|
|
hbool_t ret_val = 0;
|
|
|
|
|
|
|
|
if ( name1 && strcmp(name1, "."))
|
2011-05-04 01:56:23 +08:00
|
|
|
H5Oget_info_by_name(loc_id1, name1, &oinfo1, H5P_DEFAULT);
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
else
|
2011-05-04 01:56:23 +08:00
|
|
|
H5Oget_info(loc_id1, &oinfo1);
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
|
|
|
|
if ( name2 && strcmp(name2, "."))
|
2011-05-04 01:56:23 +08:00
|
|
|
H5Oget_info_by_name(loc_id2, name2, &oinfo2, H5P_DEFAULT);
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
else
|
2011-05-04 01:56:23 +08:00
|
|
|
H5Oget_info(loc_id2, &oinfo2);
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
|
|
|
|
if (oinfo1.fileno == oinfo2.fileno && oinfo1.addr==oinfo2.addr)
|
2011-05-04 01:56:23 +08:00
|
|
|
ret_val = 1;
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|