2012-02-18 05:41:58 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* Copyright by The HDF Group. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
2017-04-18 03:32:16 +08:00
|
|
|
* the COPYING file, which can be found at the root of the source code *
|
2021-02-17 22:52:36 +08:00
|
|
|
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
2017-04-18 03:32:16 +08:00
|
|
|
* If you do not have access to either file, you may request a copy from *
|
|
|
|
* help@hdfgroup.org. *
|
2012-02-18 05:41:58 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Purpose: A library for displaying the values of a dataset in a human
|
|
|
|
* readable format.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "h5tools.h"
|
|
|
|
#include "h5tools_dump.h"
|
|
|
|
#include "h5tools_ref.h"
|
|
|
|
#include "h5tools_utils.h"
|
|
|
|
#include "H5private.h"
|
|
|
|
|
|
|
|
h5tool_format_t h5tools_dataformat = {
|
2020-09-30 22:27:10 +08:00
|
|
|
0, /*raw */
|
|
|
|
|
|
|
|
"", /*fmt_raw */
|
|
|
|
"%d", /*fmt_int */
|
|
|
|
"%u", /*fmt_uint */
|
|
|
|
"%hhd", /*fmt_schar */
|
|
|
|
"%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 */
|
|
|
|
"{", /*cmpd_pre */
|
|
|
|
"}", /*cmpd_suf */
|
|
|
|
"\n", /*cmpd_end */
|
|
|
|
NULL, /* cmpd_listv */
|
|
|
|
|
|
|
|
", ", /*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 */
|
Squash my changes on branch `fprintf-experiment` into one commit for
reapplication to my new warnings branch, `warnings-again`. These
changes are included:
commit 915551b7bf64e777dd2007386ec77b1d117770da
Merge: 63858c2 a8892bb
Author: David Young <dyoung@hdfgroup.org>
Date: Mon Nov 25 17:39:49 2019 -0600
Merge remote-tracking branch 'hdf5/develop' into fprintf-experiment
commit a8892bb42d6f6e4fbc30fae0eb2b957f81c938b9
Merge: 5c911d8 f907b51
Author: David Young <dyoung@hdfgroup.org>
Date: Mon Nov 25 17:33:54 2019 -0600
Merge pull request #2055 in HDFFV/hdf5 from ~DYOUNG/vchoi_fork:add-werror-and-squash-some to develop
* commit 'f907b511d06612dafc7814a7c30f2f3d2b76d52b':
Oops, remove more C99 designated initializers for VS 2010 compatibility.
commit 63858c22e168acaec0af8ced6641f26102cc6bb0
Merge: 20ae787 5c911d8
Author: David Young <dyoung@hdfgroup.org>
Date: Mon Nov 25 17:04:42 2019 -0600
Merge remote-tracking branch 'hdf5/develop' into fprintf-experiment
commit 5c911d8baf3ee7fe654269088eebdf07f59a8192
Merge: b8a5671 62208b0
Author: David Young <dyoung@hdfgroup.org>
Date: Mon Nov 25 16:58:27 2019 -0600
Merge pull request #2030 in HDFFV/hdf5 from ~DYOUNG/vchoi_fork:add-werror-and-squash-some to develop
* commit '62208b056a09c01855fbac7f75146be58ad6bfe5': (44 commits)
Add an #include to get a function declaration.
Don't use C99 designated initializers, they're not compatible with Visual Studio 2010.
Quiet some more maybe-uninitialized warnings---each is a false positive, *sigh*. This is more code that may not compile with VS2010, *sigh sigh*.
Always warn on maybe-uninitialized. -Wincompatible-pointer-types was not available until GCC 5, so enable it only if that's the GCC version we're using.
Only promote maybe-uninitialized warnings to errors on GCC 8. Even on GCC 8, there may be false positives at low optimization levels? I need to check.
Only use -Werror=cast-function-type with GCC 8 and later.
Put all of the -W options back into the order I found them in so that it's easier to compare old and new config/gnu-flags.
Add new source files to CMakeLists.txt.
Mention the -Werror= flags in libhdf5.settings.in.
free -> HDfree
Promote decleration-after-statement warnings to errors.
Quiet decleration-after-statement warnings.
Move a statement under some declarations since some vintages of Visual Studio don't like declarations after statements.
Document H5D__chunk_mem_xfree_wrapper().
Undo accidental test deletion.
Oops, delete a debug printf that snuck in here.
Undo my changes to the HD macros, hadn't really intended those to be on this branch....
Make errors of some more warnings. Move disabled warnings to DEVELOPER_WARNING_CFLAGS. Put just one warning option on a line, and sort some of the options.
Cast to the parameter type, H5VL_token_t *, instead of to unsigned char *.
Change hdset_reg_ref_t and H5R_ref_t from arrays of unsigned char to structs containing those arrays. Encapsulating the arrays in this way makes it easier to write and think about pointers to these types, casts to/from these types, etc.
...
commit 20ae7877e33931b95e8c3502b027d6c3fe94a11f
Merge: 46f8c61 edd5297
Author: David Young <dyoung@hdfgroup.org>
Date: Fri Nov 22 15:34:09 2019 -0600
Merge remote-tracking branch 'origin/add-werror-and-squash-some' into fprintf-experiment
commit 46f8c613d5117a8be5bc8385a072daa0b4262f06
Author: David Young <dyoung@hdfgroup.org>
Date: Fri Nov 22 15:29:00 2019 -0600
GCC really wants us to use `ll` to format `long long`, so try to make that work
before any other format modifier. Seems like we're not compiling the autoconf
test program with -Werror=format ? Probably should.
commit eee35b8ef3759c391327cd48a9b3c56b6f8abc99
Author: David Young <dyoung@hdfgroup.org>
Date: Fri Nov 22 15:28:05 2019 -0600
It's hard to know just how wide an HDoff_t will be, and I don't think POSIX or
C standards provide a PRI macro for it, so cast to intmax_t and format using
PRIdMAX.
commit 86eab12df7a89b546a38e99f8178dd2adbcb3433
Author: David Young <dyoung@hdfgroup.org>
Date: Fri Nov 22 15:26:25 2019 -0600
URemove some casts.se the right format string for the argument. Here and there
stop casting a printf argument.
commit f722f7cbecbaa99449941484b014426f62f1bed5
Merge: 58e3743 6d5ec83
Author: David Young <dyoung@hdfgroup.org>
Date: Fri Nov 22 14:44:16 2019 -0600
Merge branch 'add-werror-and-squash-some' into fprintf-experiment
commit 58e3743b7faa9836606ee91798fe80dfc0040da7
Author: David Young <dyoung@hdfgroup.org>
Date: Wed Nov 20 21:07:21 2019 -0600
Remove custom HDfprintf implementation, using the standard library's,
instead. Take a swipe at repairing fprintf format strings, mainly
replacing "%Hu" with "%" PRIuHSIZE, "%a" with "%" PRIuHADDR, "%Zu" with
"%zu".
Here and there remove an awkward cast of a printf argument to `long
long` and use PRI[doux]8, PRI[doux]32, or PRI[doux]64, instead.
Change occurrences of "%t" to "%s" and perform a suitable change of
argument, `cond` -> `cond ? "TRUE" : "FALSE"`.
Some occurrences of %Hu, %a, and %t remain, they just weren't flagged by
the compiler because of #ifdef'age.
commit d4366909293fa970c23512ac80e5d865d76cddbf
Author: David Young <dyoung@hdfgroup.org>
Date: Wed Nov 20 20:54:32 2019 -0600
Promote format-string warnigns to errors.
2019-11-28 03:58:43 +08:00
|
|
|
" %" PRIuHADDR, /*obj_format */
|
2017-02-20 10:28:52 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
1, /*dset_hidefileno */
|
2017-02-20 10:28:52 +08:00
|
|
|
"DATASET %s ", /*dset_format */
|
2020-09-30 22:27:10 +08:00
|
|
|
"%s", /*dset_blockformat_pre */
|
|
|
|
"%s", /*dset_ptformat_pre */
|
|
|
|
"%s", /*dset_ptformat */
|
|
|
|
1, /*array indices */
|
|
|
|
1 /*escape non printable characters */
|
2012-02-18 05:41:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const h5tools_dump_header_t h5tools_standardformat = {
|
2020-09-30 22:27:10 +08:00
|
|
|
"standardformat", /*name */
|
|
|
|
"HDF5", /*filebegin */
|
|
|
|
"", /*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 */
|
|
|
|
|
2023-08-24 23:45:38 +08:00
|
|
|
"{", /*fileblockbegin */
|
|
|
|
"}", /*fileblockend */
|
|
|
|
"{", /*bootblockblockbegin */
|
|
|
|
"}", /*bootblockblockend */
|
|
|
|
"{", /*groupblockbegin */
|
|
|
|
"}", /*groupblockend */
|
|
|
|
"{", /*datasetblockbegin */
|
|
|
|
"}", /*datasetblockend */
|
|
|
|
"{", /*attributeblockbegin */
|
|
|
|
"}", /*attributeblockend */
|
|
|
|
"", /*datatypeblockbegin */
|
|
|
|
"", /*datatypeblockend */
|
|
|
|
"", /*dataspaceblockbegin */
|
|
|
|
"", /*dataspaceblockend */
|
|
|
|
"{", /*datablockbegin */
|
|
|
|
"}", /*datablockend */
|
|
|
|
"{", /*softlinkblockbegin */
|
|
|
|
"}", /*softlinkblockend */
|
|
|
|
"{", /*extlinkblockbegin */
|
|
|
|
"}", /*extlinkblockend */
|
|
|
|
"{", /*udlinkblockbegin */
|
|
|
|
"}", /*udlinkblockend */
|
|
|
|
"H5T_ARRAY { ", /*arrblockbegin */
|
|
|
|
" }", /*arrblockend */
|
|
|
|
"H5T_COMPOUND {", /*cmpdblockbegin */
|
|
|
|
"}", /*cmpdblockend */
|
|
|
|
"H5T_ENUM {", /*enumblockbegin */
|
|
|
|
"}", /*enumblockend */
|
|
|
|
"H5T_OPAQUE {", /*opaqblockbegin */
|
|
|
|
"}", /*opaqblockend */
|
|
|
|
"H5T_REFERENCE { ", /*refblockbegin */
|
|
|
|
" }", /*refblockend */
|
|
|
|
"H5T_STRING {", /*strblockbegin */
|
|
|
|
"}", /*strblockend */
|
|
|
|
"H5T_VLEN { ", /*vlenblockbegin */
|
|
|
|
" }", /*vlenblockend */
|
|
|
|
"{", /*structblockbegin */
|
|
|
|
"}", /*structblockend */
|
|
|
|
"{", /*subsettingblockbegin */
|
|
|
|
"}", /*subsettingblockend */
|
|
|
|
"(", /*startblockbegin */
|
|
|
|
");", /*startblockend */
|
|
|
|
"(", /*strideblockbegin */
|
|
|
|
");", /*strideblockend */
|
|
|
|
"(", /*countblockbegin */
|
|
|
|
");", /*countblockend */
|
|
|
|
"(", /*blockblockbegin */
|
|
|
|
");", /*blockblockend */
|
2020-09-30 22:27:10 +08:00
|
|
|
|
|
|
|
"", /*dataspacedescriptionbegin */
|
|
|
|
"", /*dataspacedescriptionend */
|
|
|
|
"(", /*dataspacedimbegin */
|
|
|
|
")", /*dataspacedimend */
|
|
|
|
|
|
|
|
"", /*virtualselectionbegin */
|
|
|
|
"", /*virtualselectionend */
|
|
|
|
"{", /*virtualselectionblockbegin */
|
|
|
|
"}", /*virtualselectionblockend */
|
|
|
|
"\"", /*virtualfilenamebeginbegin */
|
|
|
|
"\"", /*virtualfilenamebeginend */
|
|
|
|
"\"", /*virtualdatasetnamebegin */
|
|
|
|
"\"", /*virtualdtatasetnameend */
|
2012-02-18 05:41:58 +08:00
|
|
|
};
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
const h5tools_dump_header_t *h5tools_dump_header_format;
|
2022-07-27 05:45:46 +08:00
|
|
|
table_t *h5dump_type_table = NULL; /* type table reference for datatype dump */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* local prototypes */
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
static int h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_format_t *info,
|
|
|
|
h5tools_context_t *cur_ctx,
|
2022-07-27 05:45:46 +08:00
|
|
|
h5tools_str_t *buffer, /* string into which to render */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t ncols, unsigned ndims, hid_t type_id, hsize_t nblocks,
|
|
|
|
hsize_t *ptdata);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
static int h5tools_print_region_data_points(hid_t region_space, hid_t region_id, FILE *stream,
|
|
|
|
const h5tool_format_t *info, h5tools_context_t *cur_ctx,
|
|
|
|
h5tools_str_t *buffer, size_t ncols, unsigned ndims,
|
|
|
|
hid_t type_id, hsize_t npoints, hsize_t *ptdata);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2012-11-02 00:01:37 +08:00
|
|
|
void h5tools_print_dims(h5tools_str_t *buffer, hsize_t *s, int dims);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
void h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
|
|
|
|
int dims);
|
2012-11-02 00:01:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
static void h5tools_print_virtual_selection(hid_t vspace, FILE *stream, const h5tool_format_t *info,
|
|
|
|
h5tools_context_t *ctx, /* in,out */
|
2022-07-27 05:45:46 +08:00
|
|
|
h5tools_str_t *buffer, /* string into which to render */
|
|
|
|
hsize_t *curr_pos, /* total data element position */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t ncols);
|
2015-02-24 02:41:02 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
void
|
|
|
|
h5tools_dump_init(void)
|
|
|
|
{
|
|
|
|
h5tools_dump_header_format = &h5tools_standardformat;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* 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).
|
2012-03-13 00:33:15 +08:00
|
|
|
* Return: Success: SUCCEED
|
|
|
|
* Failure: FAIL
|
2012-02-18 05:41:58 +08:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-03-13 00:33:15 +08:00
|
|
|
int
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, /* in,out */
|
2020-07-16 00:20:16 +08:00
|
|
|
hid_t container, unsigned flags, hsize_t nelmts, hid_t type, void *_mem)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned char *mem = (unsigned char *)_mem;
|
|
|
|
hsize_t i; /* element counter */
|
|
|
|
size_t size; /* size of each datum */
|
2023-09-06 02:50:06 +08:00
|
|
|
bool dimension_break = true;
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t ncols = 80; /* available output width */
|
|
|
|
h5tools_str_t buffer; /* string into which to render */
|
|
|
|
hsize_t curr_pos = 0; /* 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. */
|
|
|
|
int ret_value = 0;
|
|
|
|
|
|
|
|
H5TOOLS_START_DEBUG(" file=%p", (void *)stream);
|
|
|
|
H5TOOLS_DEBUG("rawdata file=%p", (void *)rawdatastream);
|
2012-02-18 05:41:58 +08:00
|
|
|
/* binary dump */
|
2013-01-23 04:43:12 +08:00
|
|
|
if (bin_output && (rawdatastream != NULL)) {
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("render_bin_output");
|
2012-07-26 06:17:48 +08:00
|
|
|
if (render_bin_output(rawdatastream, container, type, _mem, nelmts) < 0) {
|
2013-01-23 04:43:12 +08:00
|
|
|
PRINTVALSTREAM(rawoutstream, "\nError in writing binary stream\n");
|
2012-07-26 06:17:48 +08:00
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
} /* end if */
|
|
|
|
else {
|
|
|
|
/* setup */
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&buffer, 0, sizeof(h5tools_str_t));
|
2012-02-18 05:41:58 +08:00
|
|
|
size = H5Tget_size(type);
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("type size is %ld", size);
|
2012-02-18 05:41:58 +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;
|
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("data render start:%ld", nelmts);
|
2019-11-07 23:48:56 +08:00
|
|
|
for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) {
|
2020-09-30 22:27:10 +08:00
|
|
|
void *memref = mem + i * size;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the data element begin*/
|
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_sprint(&buffer, info, container, type, memref, ctx);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
if (i + 1 < nelmts || (flags & END_OF_DATA) == 0)
|
|
|
|
h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ","));
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break =
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, i, elmt_counter);
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the data element end*/
|
2023-09-06 02:50:06 +08:00
|
|
|
if (false == dimension_break)
|
2019-11-07 23:48:56 +08:00
|
|
|
elmt_counter = 0;
|
|
|
|
} /* end for (i = 0; i < nelmts... */
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("data render finish");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_close(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
} /* else bin */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_ENDDEBUG("exit");
|
2019-11-07 23:48:56 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print some values from an attribute referenced by object reference.
|
|
|
|
*
|
|
|
|
* Description:
|
2021-02-26 05:12:57 +08:00
|
|
|
* This is a special case subfunction to dump an attribute reference.
|
2019-11-07 23:48:56 +08:00
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* The function returns False if the last dimension has been reached, otherwise True
|
|
|
|
*
|
|
|
|
* In/Out:
|
|
|
|
* h5tools_context_t *ctx
|
|
|
|
* hsize_t *curr_pos
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
bool
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_dump_region_attribute(hid_t region_id, FILE *stream, const h5tool_format_t *info,
|
|
|
|
h5tools_context_t *ctx, /* in,out */
|
2022-07-27 05:45:46 +08:00
|
|
|
h5tools_str_t *buffer, /* string into which to render */
|
|
|
|
hsize_t *curr_pos, /* total data element position */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t ncols, hsize_t region_elmt_counter, /* element counter */
|
|
|
|
hsize_t elmt_counter)
|
2019-11-07 23:48:56 +08:00
|
|
|
{
|
2023-09-06 02:50:06 +08:00
|
|
|
bool dimension_break = true;
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t atype = H5I_INVALID_HID;
|
|
|
|
hid_t type_id = H5I_INVALID_HID;
|
|
|
|
hid_t region_space = H5I_INVALID_HID;
|
2019-12-28 16:16:44 +08:00
|
|
|
h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
|
|
|
bool ret_value = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(info);
|
|
|
|
assert(ctx);
|
|
|
|
assert(buffer);
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
outputformat = *info;
|
2019-11-07 23:48:56 +08:00
|
|
|
outputformat.idx_fmt = "";
|
|
|
|
outputformat.idx_n_fmt = "";
|
|
|
|
outputformat.idx_sep = "";
|
|
|
|
outputformat.line_pre = "";
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
H5TOOLS_DEBUG("enter file=%p", (void *)stream);
|
|
|
|
H5TOOLS_DEBUG("rawdata file=%p", (void *)rawdatastream);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the region { element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, " {");
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols,
|
|
|
|
region_elmt_counter, elmt_counter);
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the region { element end */
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((region_space = H5Aget_space(region_id)) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(dimension_break, "H5Aget_space failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((atype = H5Aget_type(region_id)) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(dimension_break, "H5Aget_type failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((type_id = H5Tget_native_type(atype, H5T_DIR_DEFAULT)) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(dimension_break, "H5Tget_native_type failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
|
|
|
|
ctx->indent_level++;
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2019-11-07 23:48:56 +08:00
|
|
|
|
|
|
|
/* Render the datatype element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "%s %s ", h5tools_dump_header_format->datatypebegin,
|
|
|
|
h5tools_dump_header_format->datatypeblockbegin);
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2019-11-07 23:48:56 +08:00
|
|
|
ctx->indent_level++;
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_print_datatype(stream, buffer, info, ctx, atype, true);
|
2019-11-07 23:48:56 +08:00
|
|
|
ctx->indent_level--;
|
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datatypeblockend)) {
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeblockend);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datatypeend))
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datatypeend))
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeend);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break =
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the datatype element end */
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2019-11-07 23:48:56 +08:00
|
|
|
|
|
|
|
/* Render the dataspace element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin);
|
|
|
|
|
|
|
|
h5tools_print_dataspace(buffer, region_space);
|
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataspaceblockend)) {
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataspaceend))
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataspaceend))
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break =
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the dataspace element end */
|
|
|
|
|
|
|
|
if (region_output) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_dump_data(stream, &outputformat, ctx, region_id, false);
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
done:
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Tclose(type_id) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_ERROR(dimension_break, "H5Tclose failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Tclose(atype) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_ERROR(dimension_break, "H5Tclose failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2021-02-26 05:12:57 +08:00
|
|
|
if (H5Sclose(region_space) < 0)
|
|
|
|
H5TOOLS_ERROR(dimension_break, "H5Sclose failed");
|
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
ctx->indent_level--;
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2019-11-07 23:48:56 +08:00
|
|
|
|
|
|
|
/* Render the region } element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "}");
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break =
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the region } element end */
|
|
|
|
|
2023-07-25 05:18:04 +08:00
|
|
|
H5_LEAVE(dimension_break);
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2012-03-13 00:33:15 +08:00
|
|
|
return ret_value;
|
2012-02-18 05:41:58 +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:
|
2021-12-07 22:27:29 +08:00
|
|
|
* The function returns FAIL if there was an error, otherwise SUCCEED
|
2012-02-18 05:41:58 +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
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static int
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_format_t *info,
|
|
|
|
h5tools_context_t *cur_ctx,
|
2022-07-27 05:45:46 +08:00
|
|
|
h5tools_str_t *buffer, /* string into which to render */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t ncols, unsigned ndims, hid_t type_id, hsize_t nblocks,
|
|
|
|
hsize_t *ptdata)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2023-09-06 02:50:06 +08:00
|
|
|
bool dimension_break = true;
|
2022-07-27 05:45:46 +08:00
|
|
|
hsize_t *dims1 = NULL;
|
|
|
|
hsize_t *start = NULL;
|
|
|
|
hsize_t *count = NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
hsize_t blkndx;
|
|
|
|
hsize_t total_size[H5S_MAX_RANK];
|
2021-12-07 22:27:29 +08:00
|
|
|
hsize_t elmtno; /* element index */
|
2020-09-30 22:27:10 +08:00
|
|
|
hsize_t curr_pos = 0;
|
|
|
|
unsigned int region_flags; /* buffer extent flags */
|
|
|
|
hsize_t numelem;
|
|
|
|
hsize_t numindex;
|
|
|
|
unsigned indx;
|
|
|
|
unsigned jndx;
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t type_size;
|
|
|
|
hid_t mem_space = H5I_INVALID_HID;
|
|
|
|
hid_t sid1 = H5I_INVALID_HID;
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_context_t ctx;
|
2022-07-27 05:45:46 +08:00
|
|
|
void *region_buf = NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
int ret_value = 0;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(info);
|
|
|
|
assert(cur_ctx);
|
|
|
|
assert(buffer);
|
|
|
|
assert(ptdata);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&ctx, 0, sizeof(ctx));
|
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
2013-05-11 23:59:48 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((type_size = H5Tget_size(type_id)) == 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "H5Tget_size failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Get the dataspace of the dataset */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((sid1 = H5Dget_space(region_id)) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_space failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Allocate space for the dimension array */
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((dims1 = (hsize_t *)malloc((size_t)(sizeof(hsize_t) * ndims))) == NULL)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for dims");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* 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;
|
2020-09-30 22:27:10 +08:00
|
|
|
numelem = dims1[jndx] * numelem;
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Create dataspace for reading buffer */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Screate_simple failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((region_buf = malloc(type_size * (size_t)numelem)) == NULL)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate region buffer");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */
|
|
|
|
/* 1 2 n 1 2 n */
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((start = (hsize_t *)malloc(sizeof(hsize_t) * ndims)) == NULL)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for start");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((count = (hsize_t *)malloc(sizeof(hsize_t) * ndims)) == NULL)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for count");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
curr_pos = 0;
|
|
|
|
ctx.indent_level = cur_ctx->indent_level;
|
|
|
|
ctx.cur_column = cur_ctx->cur_column;
|
2012-02-18 05:41:58 +08:00
|
|
|
ctx.prev_multiline = cur_ctx->prev_multiline;
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx.ndims = ndims;
|
2012-02-18 05:41:58 +08:00
|
|
|
for (blkndx = 0; blkndx < nblocks; blkndx++) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx.need_prefix = true;
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx.cur_elmt = 0;
|
2012-02-18 05:41:58 +08:00
|
|
|
for (indx = 0; indx < ndims; indx++) {
|
|
|
|
start[indx] = ptdata[indx + blkndx * ndims * 2];
|
|
|
|
count[indx] = dims1[indx];
|
|
|
|
}
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) >= 0) {
|
|
|
|
if (H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) {
|
2019-11-07 23:48:56 +08:00
|
|
|
ctx.indent_level++;
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) {
|
2019-11-07 23:48:56 +08:00
|
|
|
/* assume entire data space to be printed */
|
2020-07-16 00:20:16 +08:00
|
|
|
init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx);
|
|
|
|
|
|
|
|
/* reset data space to be printed */
|
2019-11-07 23:48:56 +08:00
|
|
|
for (indx = 0; indx < (unsigned)ctx.ndims; indx++)
|
|
|
|
ctx.p_min_idx[indx] = start[indx];
|
|
|
|
|
|
|
|
/* print the data */
|
|
|
|
region_flags = START_OF_DATA;
|
|
|
|
if (blkndx == nblocks - 1)
|
|
|
|
region_flags |= END_OF_DATA;
|
|
|
|
|
|
|
|
for (indx = 0; indx < (unsigned)ctx.ndims; indx++)
|
|
|
|
ctx.p_max_idx[indx] = dims1[indx];
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
curr_pos = 0;
|
|
|
|
ctx.sm_pos = blkndx * 2 * ndims;
|
|
|
|
ctx.size_last_dim = dims1[ndims - 1];
|
2019-11-07 23:48:56 +08:00
|
|
|
|
|
|
|
h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0);
|
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("data render start:%ld", numelem);
|
2019-11-07 23:48:56 +08:00
|
|
|
elmtno = 0;
|
|
|
|
for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) {
|
|
|
|
/* Render the region data element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
|
|
|
|
h5tools_str_append(buffer, "%s", numindex ? OPTIONAL_LINE_BREAK "" : "");
|
|
|
|
h5tools_str_sprint(buffer, info, region_id, type_id,
|
2020-09-30 22:27:10 +08:00
|
|
|
((char *)region_buf + numindex * type_size), &ctx);
|
2019-11-07 23:48:56 +08:00
|
|
|
|
|
|
|
if (numindex + 1 < numelem || (region_flags & END_OF_DATA) == 0)
|
|
|
|
h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ","));
|
|
|
|
|
|
|
|
dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos,
|
2020-09-30 22:27:10 +08:00
|
|
|
ncols, ptdata, numindex, elmtno);
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the region data element end */
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
if (false == dimension_break)
|
2019-11-07 23:48:56 +08:00
|
|
|
elmtno = 0;
|
|
|
|
} /* end for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) */
|
|
|
|
}
|
|
|
|
else {
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR(FAIL, "H5Sget_simple_extent_dims failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
|
|
|
ctx.indent_level--;
|
|
|
|
}
|
|
|
|
else {
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR(FAIL, "H5Dread failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR(FAIL, "H5Sselect_hyperslab failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
} /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */
|
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
done:
|
2023-06-29 06:48:12 +08:00
|
|
|
free(start);
|
|
|
|
free(count);
|
|
|
|
free(region_buf);
|
|
|
|
free(dims1);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sclose(mem_space) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_ERROR(FAIL, "H5Sclose failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sclose(sid1) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_ERROR(FAIL, "H5Sclose failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
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 the last dimension has been reached, otherwise True
|
|
|
|
*
|
|
|
|
* In/Out:
|
|
|
|
* h5tools_context_t *ctx
|
|
|
|
* hsize_t *curr_pos
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
bool
|
2020-09-30 22:27:10 +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 */
|
2022-07-27 05:45:46 +08:00
|
|
|
hsize_t *curr_pos, /* total data element position */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t ncols, hsize_t region_elmt_counter, /* element counter */
|
|
|
|
hsize_t elmt_counter)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2023-09-06 02:50:06 +08:00
|
|
|
bool dimension_break = true;
|
2020-09-30 22:27:10 +08:00
|
|
|
hssize_t snblocks;
|
|
|
|
hsize_t nblocks;
|
|
|
|
hsize_t alloc_size;
|
2022-07-27 05:45:46 +08:00
|
|
|
hsize_t *ptdata = NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
int sndims;
|
|
|
|
unsigned ndims;
|
|
|
|
hsize_t indx;
|
|
|
|
hid_t dtype = H5I_INVALID_HID;
|
|
|
|
hid_t type_id = H5I_INVALID_HID;
|
|
|
|
h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
|
|
|
bool ret_value = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(info);
|
|
|
|
assert(ctx);
|
|
|
|
assert(buffer);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2020-09-30 22:27:10 +08:00
|
|
|
outputformat = *info;
|
2019-11-07 23:48:56 +08:00
|
|
|
outputformat.idx_fmt = "";
|
|
|
|
outputformat.idx_n_fmt = "";
|
|
|
|
outputformat.idx_sep = "";
|
|
|
|
outputformat.line_pre = "";
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(dimension_break, "H5Sget_select_hyper_nblocks failed");
|
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
2013-05-11 23:59:48 +08:00
|
|
|
nblocks = (hsize_t)snblocks;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Print block information */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(dimension_break, "H5Sget_simple_extent_ndims failed");
|
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
2013-05-11 23:59:48 +08:00
|
|
|
ndims = (unsigned)sndims;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("enter ndims=%d", ndims);
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Render the region { element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, " {");
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols,
|
|
|
|
region_elmt_counter, elmt_counter);
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Render the region { element end */
|
|
|
|
|
|
|
|
ctx->indent_level++;
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Render the region datatype info and indices element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "REGION_TYPE BLOCK ");
|
|
|
|
|
|
|
|
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((ptdata = (hsize_t *)malloc((size_t)alloc_size)) == NULL)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(dimension_break, "Could not allocate buffer for ptdata");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sget_select_hyper_blocklist(region_space, (hsize_t)0, nblocks, ptdata) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(dimension_break, "H5Rget_select_hyper_blocklist failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
for (indx = 0; indx < nblocks; indx++) {
|
2019-11-07 23:48:56 +08:00
|
|
|
unsigned loop_indx;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2022-07-12 01:28:02 +08:00
|
|
|
H5_GCC_CLANG_DIAG_OFF("format-nonliteral")
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, outputformat.dset_blockformat_pre, indx ? "," OPTIONAL_LINE_BREAK " " : "",
|
|
|
|
(unsigned long)indx);
|
2022-07-12 01:28:02 +08:00
|
|
|
H5_GCC_CLANG_DIAG_ON("format-nonliteral")
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Start coordinates and opposite corner */
|
2019-11-07 23:48:56 +08:00
|
|
|
for (loop_indx = 0; loop_indx < ndims; loop_indx++)
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(buffer, "%s%" PRIuHSIZE, loop_indx ? "," : "(",
|
2020-09-30 22:27:10 +08:00
|
|
|
ptdata[indx * 2 * ndims + loop_indx]);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
for (loop_indx = 0; loop_indx < ndims; loop_indx++)
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(buffer, "%s%" PRIuHSIZE, loop_indx ? "," : ")-(",
|
2020-09-30 22:27:10 +08:00
|
|
|
ptdata[indx * 2 * ndims + loop_indx + ndims]);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
h5tools_str_append(buffer, ")");
|
2019-11-07 23:48:56 +08:00
|
|
|
} /* end for (indx = 0; indx < nblocks; indx++) */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break =
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Render the region datatype info and indices element end */
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((dtype = H5Dget_type(region_id)) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(dimension_break, "H5Dget_type failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(dimension_break, "H5Tget_native_type failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Render the datatype element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "%s %s ", h5tools_dump_header_format->datatypebegin,
|
|
|
|
h5tools_dump_header_format->datatypeblockbegin);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
ctx->indent_level++;
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_print_datatype(stream, buffer, info, ctx, dtype, true);
|
2012-02-18 05:41:58 +08:00
|
|
|
ctx->indent_level--;
|
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datatypeblockend)) {
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeblockend);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datatypeend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datatypeend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeend);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break =
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Render the datatype element end */
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Render the dataspace element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin);
|
|
|
|
|
2012-11-02 00:01:37 +08:00
|
|
|
h5tools_print_dataspace(buffer, region_space);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataspaceblockend)) {
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataspaceend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataspaceend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break =
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Render the dataspace element end */
|
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
if (region_output) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the databegin element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->databegin,
|
|
|
|
h5tools_dump_header_format->datablockbegin);
|
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols,
|
|
|
|
region_elmt_counter, elmt_counter);
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the databegin element end */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_print_region_data_blocks(region_id, rawdatastream, info, ctx, buffer, ncols, ndims, type_id,
|
|
|
|
nblocks, ptdata);
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
done:
|
2023-06-29 06:48:12 +08:00
|
|
|
free(ptdata);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (type_id > 0 && H5Tclose(type_id) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_ERROR(dimension_break, "H5Tclose failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (dtype > 0 && H5Tclose(dtype) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_ERROR(dimension_break, "H5Tclose failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
if (region_output) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the dataend element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datablockend)) {
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datablockend);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataend))
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataend))
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataend);
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols,
|
|
|
|
region_elmt_counter, elmt_counter);
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the dataend element end */
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
ctx->indent_level--;
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Render the region } element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "}");
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break =
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Render the region } element end */
|
|
|
|
|
2023-07-25 05:18:04 +08:00
|
|
|
H5_LEAVE(dimension_break);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
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
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2016-06-29 05:53:48 +08:00
|
|
|
static int
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_print_region_data_points(hid_t region_space, hid_t region_id, FILE *stream,
|
|
|
|
const h5tool_format_t *info, h5tools_context_t *cur_ctx,
|
|
|
|
h5tools_str_t *buffer, size_t ncols, unsigned ndims, hid_t type_id,
|
|
|
|
hsize_t npoints, hsize_t *ptdata)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2023-09-06 02:50:06 +08:00
|
|
|
bool dimension_break = true;
|
2022-07-27 05:45:46 +08:00
|
|
|
hsize_t *dims1 = NULL;
|
2021-12-07 22:27:29 +08:00
|
|
|
hsize_t elmtno; /* element index */
|
2020-09-30 22:27:10 +08:00
|
|
|
hsize_t curr_pos = 0;
|
|
|
|
hsize_t total_size[H5S_MAX_RANK];
|
|
|
|
hsize_t jndx;
|
|
|
|
unsigned indx;
|
|
|
|
size_t type_size;
|
|
|
|
unsigned int region_flags; /* buffer extent flags */
|
|
|
|
hid_t mem_space = H5I_INVALID_HID;
|
2022-07-27 05:45:46 +08:00
|
|
|
void *region_buf = NULL;
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_context_t ctx;
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
2020-09-30 22:27:10 +08:00
|
|
|
int ret_value = 0;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(info);
|
|
|
|
assert(cur_ctx);
|
|
|
|
assert(buffer);
|
|
|
|
assert(ptdata);
|
|
|
|
assert(ndims > 0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&ctx, 0, sizeof(ctx));
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Allocate space for the dimension array */
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((dims1 = (hsize_t *)malloc(sizeof(hsize_t) * ndims)) == NULL)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "Could not allocate buffer for dims");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
dims1[0] = npoints;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Create dataspace for reading buffer */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((mem_space = H5Screate_simple(1, dims1, NULL)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Screate_simple failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((type_size = H5Tget_size(type_id)) == 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Tget_size failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((region_buf = malloc(type_size * (size_t)npoints)) == NULL)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "Could not allocate buffer for region");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
curr_pos = 0;
|
|
|
|
ctx.indent_level = cur_ctx->indent_level;
|
|
|
|
ctx.cur_column = cur_ctx->cur_column;
|
2012-02-18 05:41:58 +08:00
|
|
|
ctx.prev_multiline = cur_ctx->prev_multiline;
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx.ndims = ndims;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("data render start:%ld", npoints);
|
2012-02-18 05:41:58 +08:00
|
|
|
elmtno = 0;
|
|
|
|
for (jndx = 0; jndx < npoints; jndx++, elmtno++) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx.need_prefix = true;
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx.cur_elmt = 0; /* points are always 0 */
|
2012-02-18 05:41:58 +08:00
|
|
|
ctx.indent_level++;
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) {
|
2019-11-07 23:48:56 +08:00
|
|
|
/* assume entire data space to be printed */
|
2020-07-16 00:20:16 +08:00
|
|
|
init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
/* print the data */
|
|
|
|
region_flags = START_OF_DATA;
|
|
|
|
if (jndx == npoints - 1)
|
|
|
|
region_flags |= END_OF_DATA;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
for (indx = 0; indx < ctx.ndims; indx++)
|
|
|
|
ctx.p_max_idx[indx] = cur_ctx->p_max_idx[indx];
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
ctx.sm_pos = jndx * ndims;
|
|
|
|
if (ctx.ndims > 0)
|
|
|
|
ctx.size_last_dim = ctx.p_max_idx[ctx.ndims - 1];
|
|
|
|
else
|
|
|
|
ctx.size_last_dim = 0;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
curr_pos = 0; /* points requires constant 0 */
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the point element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, "%s", jndx ? OPTIONAL_LINE_BREAK "" : "");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_sprint(buffer, info, region_id, type_id, ((char *)region_buf + jndx * type_size),
|
|
|
|
&ctx);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
if (jndx + 1 < npoints || (region_flags & END_OF_DATA) == 0)
|
|
|
|
h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ","));
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos, ncols,
|
|
|
|
ptdata, (hsize_t)0, elmtno);
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the point element end */
|
2023-09-06 02:50:06 +08:00
|
|
|
if (false == dimension_break)
|
2019-11-07 23:48:56 +08:00
|
|
|
elmtno = 0;
|
|
|
|
}
|
|
|
|
else {
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Sget_simple_extent_dims failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
ctx.indent_level--;
|
|
|
|
} /* end for (jndx = 0; jndx < npoints; jndx++, elmtno++) */
|
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
done:
|
2023-06-29 06:48:12 +08:00
|
|
|
free(region_buf);
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
2023-06-29 06:48:12 +08:00
|
|
|
free(dims1);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sclose(mem_space) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Sclose failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2012-02-18 05:41:58 +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
|
|
|
|
*
|
|
|
|
* In/Out:
|
|
|
|
* h5tools_context_t *ctx
|
|
|
|
* hsize_t *curr_pos
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
bool
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, FILE *stream,
|
|
|
|
const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer,
|
|
|
|
hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter,
|
|
|
|
hsize_t elmt_counter)
|
2019-11-07 23:48:56 +08:00
|
|
|
{
|
2023-09-06 02:50:06 +08:00
|
|
|
bool dimension_break = true;
|
2020-09-30 22:27:10 +08:00
|
|
|
hssize_t snpoints;
|
|
|
|
hsize_t npoints;
|
|
|
|
hsize_t alloc_size;
|
2022-07-27 05:45:46 +08:00
|
|
|
hsize_t *ptdata;
|
2020-09-30 22:27:10 +08:00
|
|
|
int sndims;
|
|
|
|
unsigned ndims;
|
|
|
|
hsize_t indx;
|
|
|
|
hid_t dtype = H5I_INVALID_HID;
|
|
|
|
hid_t type_id = H5I_INVALID_HID;
|
|
|
|
h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
|
|
|
bool ret_value = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(info);
|
|
|
|
assert(ctx);
|
|
|
|
assert(buffer);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2020-09-30 22:27:10 +08:00
|
|
|
outputformat = *info;
|
2019-11-07 23:48:56 +08:00
|
|
|
outputformat.idx_fmt = "";
|
|
|
|
outputformat.idx_n_fmt = "";
|
|
|
|
outputformat.idx_sep = "";
|
|
|
|
outputformat.line_pre = "";
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(dimension_break, "H5Sget_select_elem_npoints failed");
|
2016-06-29 05:53:48 +08:00
|
|
|
npoints = (hsize_t)snpoints;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Allocate space for the dimension array */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(dimension_break, "H5Sget_simple_extent_ndims failed");
|
2016-06-29 05:53:48 +08:00
|
|
|
ndims = (unsigned)sndims;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("enter ndims=%d", ndims);
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Render the region { element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
|
|
|
|
h5tools_str_append(buffer, "{");
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols,
|
|
|
|
region_elmt_counter, elmt_counter);
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Render the region { element end */
|
|
|
|
|
|
|
|
ctx->indent_level++;
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2019-11-07 23:48:56 +08:00
|
|
|
|
|
|
|
/* Render the region datatype info and indices element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, "REGION_TYPE POINT ");
|
|
|
|
|
|
|
|
alloc_size = npoints * ndims * sizeof(ptdata[0]);
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
|
2023-06-29 06:48:12 +08:00
|
|
|
if (NULL == (ptdata = (hsize_t *)malloc((size_t)alloc_size)))
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(dimension_break, "Could not allocate buffer for ptdata");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sget_select_elem_pointlist(region_space, (hsize_t)0, npoints, ptdata) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(dimension_break, "H5Sget_select_elem_pointlist failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
for (indx = 0; indx < npoints; indx++) {
|
2016-06-29 05:53:48 +08:00
|
|
|
unsigned loop_indx;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2022-07-12 01:28:02 +08:00
|
|
|
H5_GCC_CLANG_DIAG_OFF("format-nonliteral")
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, outputformat.dset_ptformat_pre, indx ? "," OPTIONAL_LINE_BREAK " " : "",
|
|
|
|
(unsigned long)indx);
|
2022-07-12 01:28:02 +08:00
|
|
|
H5_GCC_CLANG_DIAG_ON("format-nonliteral")
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
for (loop_indx = 0; loop_indx < ndims; loop_indx++)
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(buffer, "%s%" PRIuHSIZE, loop_indx ? "," : "(",
|
2020-09-30 22:27:10 +08:00
|
|
|
ptdata[indx * ndims + loop_indx]);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
h5tools_str_append(buffer, ")");
|
|
|
|
} /* end for (indx = 0; indx < npoints; indx++) */
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break =
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Render the region datatype info and indices element end */
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((dtype = H5Dget_type(region_id)) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(dimension_break, "H5Dget_type failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(dimension_break, "H5Tget_native_type failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Render the datatype element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "%s %s ", h5tools_dump_header_format->datatypebegin,
|
|
|
|
h5tools_dump_header_format->datatypeblockbegin);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
ctx->indent_level++;
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_print_datatype(stream, buffer, info, ctx, dtype, true);
|
2012-02-18 05:41:58 +08:00
|
|
|
ctx->indent_level--;
|
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datatypeblockend)) {
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeblockend);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datatypeend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datatypeend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeend);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break =
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Render the datatype element end */
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Render the dataspace element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin);
|
|
|
|
|
2012-11-02 00:01:37 +08:00
|
|
|
h5tools_print_dataspace(buffer, region_space);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataspaceblockend)) {
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataspaceend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataspaceend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break =
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Render the dataspace element end */
|
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
if (region_output) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the databegin element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->databegin,
|
|
|
|
h5tools_dump_header_format->datablockbegin);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols,
|
|
|
|
region_elmt_counter, elmt_counter);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_print_region_data_points(region_space, region_id, rawdatastream, info, ctx, buffer, ncols,
|
|
|
|
ndims, type_id, npoints, ptdata);
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
done:
|
2023-06-29 06:48:12 +08:00
|
|
|
free(ptdata);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (type_id > 0 && H5Tclose(type_id) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_ERROR(dimension_break, "H5Tclose failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (dtype > 0 && H5Tclose(dtype) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_ERROR(dimension_break, "H5Tclose failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
if (region_output) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the dataend element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datablockend)) {
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datablockend);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataend))
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataend))
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataend);
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols,
|
|
|
|
region_elmt_counter, elmt_counter);
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Render the dataend element end*/
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
ctx->indent_level--;
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Render the region } element begin */
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "}");
|
2020-09-30 22:27:10 +08:00
|
|
|
dimension_break =
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Render the region } element end */
|
|
|
|
|
2023-07-25 05:18:04 +08:00
|
|
|
H5_LEAVE(dimension_break);
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2012-02-18 05:41:58 +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
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset,
|
|
|
|
hid_t p_type, hid_t f_space, hsize_t hyperslab_count,
|
2022-07-27 05:45:46 +08:00
|
|
|
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 */
|
2021-03-10 00:59:44 +08:00
|
|
|
const hsize_t *total_size, /* total size of dataset */
|
|
|
|
unsigned int row_dim) /* index of row_counter dimension */
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t i; /* counters */
|
|
|
|
size_t j; /* counters */
|
|
|
|
hsize_t zero[1] = {0}; /* vector of zeros */
|
|
|
|
unsigned int flags; /* buffer extent flags */
|
|
|
|
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 */
|
|
|
|
hssize_t ssm_nelmts; /* elements per stripmine*/
|
|
|
|
hsize_t sm_nelmts; /* elements per stripmine*/
|
|
|
|
unsigned char *sm_buf = NULL; /* buffer for raw data */
|
|
|
|
hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */
|
|
|
|
hsize_t size_row_block; /* size for blocks along rows */
|
|
|
|
hsize_t row_counter = 0;
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
2012-02-18 05:41:58 +08:00
|
|
|
/* VL data special information */
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned int vl_data = 0; /* contains VL datatypes */
|
|
|
|
herr_t ret_value = SUCCEED;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((size_t)ctx->ndims > NELMTS(sm_size))
|
2021-12-07 22:27:29 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "ndims and sm_size comparison failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
size_row_block = ctx->sset->block.data[row_dim];
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Check if we have VL data in the dataset's datatype */
|
2023-09-06 02:50:06 +08:00
|
|
|
if (h5tools_detect_vlen(p_type) == true)
|
|
|
|
vl_data = true;
|
2012-02-18 05:41:58 +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 */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (size_row_block > 1 && row_counter == size_row_block &&
|
|
|
|
ctx->sset->stride.data[row_dim] > ctx->sset->block.data[row_dim]) {
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
hsize_t increase_rows = ctx->sset->stride.data[row_dim] - ctx->sset->block.data[row_dim];
|
2012-02-18 05:41:58 +08:00
|
|
|
temp_start[row_dim] += increase_rows;
|
|
|
|
row_counter = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
row_counter++;
|
|
|
|
|
|
|
|
/* calculate the potential number of elements we're going to print */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sselect_hyperslab(f_space, H5S_SELECT_SET, temp_start, temp_stride, temp_count, temp_block) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "H5Sselect_hyperslab failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((ssm_nelmts = H5Sget_select_npoints(f_space)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "H5Sget_select_npoints failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
sm_nelmts = (hsize_t)ssm_nelmts;
|
|
|
|
|
|
|
|
if (sm_nelmts > 0) {
|
|
|
|
/*
|
|
|
|
* determine the strip mine size and allocate a buffer. the strip mine is
|
|
|
|
* a hyperslab whose size is manageable.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((sm_nbytes = p_type_nbytes = H5Tget_size(p_type)) == 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "H5Tget_size failed");
|
2012-02-18 05:41:58 +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];
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(sm_nbytes > 0);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/
|
2023-06-29 06:48:12 +08:00
|
|
|
if (NULL == (sm_buf = (unsigned char *)malloc((size_t)sm_nelmts * p_type_nbytes)))
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "Could not allocate buffer for strip-mine");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "H5Screate_simple failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &sm_nelmts, NULL) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "H5Sselect_hyperslab failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* read the data */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "H5Dread failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* print the data */
|
|
|
|
flags = START_OF_DATA;
|
|
|
|
|
|
|
|
if (hyperslab_count == 1)
|
|
|
|
flags |= END_OF_DATA;
|
|
|
|
|
|
|
|
for (i = 0; i < ctx->ndims; i++)
|
|
|
|
ctx->p_max_idx[i] = ctx->p_min_idx[i] + MIN(total_size[i], sm_size[i]);
|
|
|
|
|
2020-07-16 00:20:16 +08:00
|
|
|
/* print array indices. get the lower bound of the hyperslab and calculate
|
|
|
|
the element position at the start of hyperslab */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sget_select_bounds(f_space, low, high) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "H5Sget_select_bounds failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-07-16 00:20:16 +08:00
|
|
|
/* initialize the current stripmine position; this is necessary to print the array indices */
|
|
|
|
ctx->sm_pos = 0;
|
2020-09-30 22:27:10 +08:00
|
|
|
for (i = 0; i < (size_t)ctx->ndims - 1; i++) {
|
2012-02-18 05:41:58 +08:00
|
|
|
hsize_t offset = 1; /* accumulation of the previous dimensions */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (j = i + 1; j < (size_t)ctx->ndims; j++)
|
2012-02-18 05:41:58 +08:00
|
|
|
offset *= total_size[j];
|
2020-07-16 00:20:16 +08:00
|
|
|
ctx->sm_pos += low[i] * offset;
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
2020-07-16 00:20:16 +08:00
|
|
|
ctx->sm_pos += low[ctx->ndims - 1];
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (h5tools_dump_simple_data(stream, info, ctx, dset, flags, sm_nelmts, p_type, sm_buf) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "h5tools_dump_simple_data failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Reclaim any VL memory, if necessary */
|
|
|
|
if (vl_data)
|
2019-08-15 00:41:53 +08:00
|
|
|
H5Treclaim(p_type, sm_space, H5P_DEFAULT, sm_buf);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sclose(sm_space) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "H5Sclose failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
if (sm_buf)
|
2023-06-29 06:48:12 +08:00
|
|
|
free(sm_buf);
|
2012-02-18 05:41:58 +08:00
|
|
|
sm_buf = NULL;
|
|
|
|
}
|
|
|
|
else
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(SUCCEED, "nothing to print");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
ctx->continuation++;
|
|
|
|
|
|
|
|
} /* hyperslab_count loop */
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
|
|
|
if (sm_buf)
|
2023-06-29 06:48:12 +08:00
|
|
|
free(sm_buf);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2012-02-18 05:41:58 +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
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset,
|
|
|
|
hid_t p_type, hid_t f_space, hsize_t *total_size)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t i; /* counters */
|
|
|
|
hsize_t n; /* counters */
|
|
|
|
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;
|
|
|
|
herr_t ret_value = SUCCEED;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
if (ctx->ndims == 1)
|
|
|
|
row_dim = 0;
|
|
|
|
else
|
|
|
|
row_dim = ctx->ndims - 2;
|
|
|
|
|
|
|
|
/* get the offset count */
|
|
|
|
outer_count = 1;
|
|
|
|
if (ctx->ndims > 2)
|
2020-09-30 22:27:10 +08:00
|
|
|
for (i = 0; i < (size_t)ctx->ndims - 2; i++) {
|
2012-02-18 05:41:58 +08:00
|
|
|
/* block size is handled by containing h5tools_print_simple_subset call */
|
2019-11-07 23:48:56 +08:00
|
|
|
outer_count = outer_count * ctx->sset->count.data[i];
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize temporary start, count and maximum start */
|
2016-06-29 05:53:48 +08:00
|
|
|
for (i = 0; i < ctx->ndims; i++) {
|
2020-09-30 22:27:10 +08:00
|
|
|
temp_start[i] = ctx->sset->start.data[i];
|
|
|
|
temp_count[i] = ctx->sset->count.data[i];
|
|
|
|
temp_block[i] = ctx->sset->block.data[i];
|
2019-11-07 23:48:56 +08:00
|
|
|
temp_stride[i] = ctx->sset->stride.data[i];
|
2020-09-30 22:27:10 +08:00
|
|
|
max_start[i] = 0;
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx->ndims > 2) {
|
2020-09-30 22:27:10 +08:00
|
|
|
for (i = 0; i < (size_t)ctx->ndims - 2; i++) {
|
|
|
|
max_start[i] = temp_start[i] + ctx->sset->count.data[i] * ctx->sset->stride.data[i];
|
2012-02-18 05:41:58 +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 */
|
|
|
|
if (ctx->ndims > 1) {
|
|
|
|
/* count is the number of iterations to display all the rows,
|
|
|
|
the block size count times */
|
2019-11-07 23:48:56 +08:00
|
|
|
count = ctx->sset->count.data[row_dim] * ctx->sset->block.data[row_dim];
|
2012-02-18 05:41:58 +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 */
|
2019-11-07 23:48:56 +08:00
|
|
|
if (ctx->sset->block.data[row_dim] > 1)
|
2012-02-18 05:41:58 +08:00
|
|
|
temp_stride[row_dim] = 1;
|
|
|
|
}
|
|
|
|
/* for the 1D case */
|
|
|
|
else {
|
|
|
|
count = 1;
|
|
|
|
}
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_print_simple_subset(stream, info, ctx, dset, p_type, f_space, count, temp_start, temp_count,
|
|
|
|
temp_block, temp_stride, total_size, row_dim);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
if (ctx->ndims > 2) {
|
|
|
|
/* dimension for start */
|
2016-06-29 05:53:48 +08:00
|
|
|
current_outer_dim = (int)(ctx->ndims - 2) - 1;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* set start to original from current_outer_dim up */
|
2016-06-29 05:53:48 +08:00
|
|
|
for (i = (size_t)(current_outer_dim + 1); i < ctx->ndims; i++)
|
2019-11-07 23:48:56 +08:00
|
|
|
temp_start[i] = ctx->sset->start.data[i];
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* increment start dimension */
|
|
|
|
do {
|
|
|
|
reset_dim = 0;
|
2019-11-07 23:48:56 +08:00
|
|
|
temp_start[current_outer_dim] += ctx->sset->stride.data[current_outer_dim];
|
2012-02-18 05:41:58 +08:00
|
|
|
if (temp_start[current_outer_dim] >= max_start[current_outer_dim]) {
|
2019-11-07 23:48:56 +08:00
|
|
|
temp_start[current_outer_dim] = ctx->sset->start.data[current_outer_dim];
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
current_outer_dim--;
|
|
|
|
reset_dim = 1;
|
|
|
|
}
|
|
|
|
} while (current_outer_dim >= 0 && reset_dim);
|
|
|
|
|
|
|
|
} /* ctx.ndims > 1 */
|
|
|
|
|
|
|
|
} /* outer_count */
|
|
|
|
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* 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
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset,
|
|
|
|
hid_t p_type)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2019-12-28 16:16:44 +08:00
|
|
|
int sndims;
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t f_space = H5I_INVALID_HID; /* file data space */
|
|
|
|
hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
2020-09-30 22:27:10 +08:00
|
|
|
herr_t ret_value = SUCCEED;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((f_space = H5Dget_space(dset)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "H5Dget_space failed");
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((sndims = H5Sget_simple_extent_ndims(f_space)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "H5Sget_simple_extent_ndims failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
ctx->ndims = (unsigned)sndims;
|
|
|
|
|
|
|
|
/* assume entire data space to be printed */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "H5Sget_simple_extent_dims failed");
|
2020-07-16 00:20:16 +08:00
|
|
|
init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx);
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
ctx->size_last_dim = total_size[ctx->ndims - 1];
|
|
|
|
|
2016-12-12 03:25:08 +08:00
|
|
|
/* Set the compound datatype field list for display */
|
|
|
|
ctx->cmpd_listv = info->cmpd_listv;
|
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_display_simple_subset(stream, info, ctx, dset, p_type, f_space, total_size);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
|
|
|
if (f_space >= 0 && H5Sclose(f_space) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW(FAIL, "H5Sclose failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2012-02-18 05:41:58 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* 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.
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static int
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset,
|
|
|
|
hid_t p_type)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t f_space = H5I_INVALID_HID; /* file data space */
|
|
|
|
hsize_t elmtno; /* counter */
|
|
|
|
size_t i = 0; /* counter */
|
|
|
|
int sndims; /* rank of dataspace */
|
|
|
|
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*/
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Print info */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t p_type_nbytes; /* size of memory type */
|
|
|
|
hsize_t p_nelmts; /* total selected elmts */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Stripmine info */
|
2020-09-30 22:27:10 +08:00
|
|
|
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 = H5I_INVALID_HID; /* stripmine data space */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Hyperslab info */
|
2020-09-30 22:27:10 +08:00
|
|
|
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 */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* VL data special information */
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned int vl_data = 0; /* contains VL datatypes */
|
|
|
|
int ret_value = 0;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2019-12-28 16:16:44 +08:00
|
|
|
if (H5I_INVALID_HID == (f_space = H5Dget_space(dset)))
|
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2016-06-29 05:53:48 +08:00
|
|
|
sndims = H5Sget_simple_extent_ndims(f_space);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (sndims < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Dget_simple_extent_ndims failed");
|
2016-06-29 05:53:48 +08:00
|
|
|
ctx->ndims = (unsigned)sndims;
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("sndims:%d", sndims);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2016-06-29 05:53:48 +08:00
|
|
|
if ((size_t)ctx->ndims > NELMTS(sm_size))
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "ctx->ndims > NELMTS(sm_size) failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Assume entire data space to be printed */
|
|
|
|
H5Sget_simple_extent_dims(f_space, total_size, NULL);
|
2020-07-16 00:20:16 +08:00
|
|
|
init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
if (p_nelmts == 0) {
|
2012-03-13 00:33:15 +08:00
|
|
|
H5_LEAVE(SUCCEED); /* nothing to print */
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we have VL data in the dataset's datatype */
|
2023-09-06 02:50:06 +08:00
|
|
|
if (h5tools_detect_vlen(p_type) == true)
|
|
|
|
vl_data = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine the strip mine size and allocate a buffer. The strip mine is
|
|
|
|
* a hyperslab whose size is manageable.
|
|
|
|
*/
|
|
|
|
sm_nbytes = p_type_nbytes = H5Tget_size(p_type);
|
|
|
|
if (ctx->ndims > 0) {
|
|
|
|
for (i = ctx->ndims; i > 0; --i) {
|
|
|
|
hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes;
|
2019-12-05 06:36:32 +08:00
|
|
|
if (size == 0) /* datum size > H5TOOLS_BUFSIZE */
|
2012-02-18 05:41:58 +08:00
|
|
|
size = 1;
|
|
|
|
sm_size[i - 1] = MIN(total_size[i - 1], size);
|
|
|
|
sm_nbytes *= sm_size[i - 1];
|
|
|
|
}
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
if (!sm_nbytes)
|
2012-02-18 05:41:58 +08:00
|
|
|
goto done;
|
|
|
|
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/
|
2023-06-29 06:48:12 +08:00
|
|
|
if (NULL != (sm_buf = (unsigned char *)malloc((size_t)sm_nbytes))) {
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("stripmine size:%ld", sm_nbytes);
|
2019-11-07 23:48:56 +08:00
|
|
|
|
|
|
|
sm_nelmts = sm_nbytes / p_type_nbytes;
|
2020-09-30 22:27:10 +08:00
|
|
|
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("sm_nelmts size:%ld", sm_nelmts);
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("ctx->ndims:%d", ctx->ndims);
|
2019-11-07 23:48:56 +08:00
|
|
|
|
|
|
|
/* The stripmine loop */
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(hs_offset, 0, sizeof hs_offset);
|
|
|
|
memset(zero, 0, sizeof zero);
|
2019-11-07 23:48:56 +08:00
|
|
|
|
|
|
|
for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) {
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("stripmine read loop:%d", i);
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Calculate the hyperslab size */
|
|
|
|
if (ctx->ndims > 0) {
|
|
|
|
for (i = 0, hs_nelmts = 1; i < ctx->ndims; i++) {
|
2020-09-30 22:27:10 +08:00
|
|
|
hs_size[i] = MIN(total_size[i] - hs_offset[i], sm_size[i]);
|
2019-11-07 23:48:56 +08:00
|
|
|
ctx->p_max_idx[i] = ctx->p_min_idx[i] + hs_size[i];
|
|
|
|
hs_nelmts *= hs_size[i];
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
if (H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Sselect_hyperslab hs_offset failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Sselect_hyperslab zero failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (H5Sselect_all(f_space) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Sselect_all f_space failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
if (H5Sselect_all(sm_space) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Sselect_all sm_space failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
hs_nelmts = 1;
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("Read the data");
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Read the data */
|
|
|
|
if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) >= 0) {
|
|
|
|
/* Print the data */
|
|
|
|
flags = (elmtno == 0) ? START_OF_DATA : 0;
|
|
|
|
flags |= ((elmtno + hs_nelmts) >= p_nelmts) ? END_OF_DATA : 0;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
/* initialize the current stripmine position; this is necessary to print the array
|
|
|
|
indices */
|
|
|
|
ctx->sm_pos = elmtno;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (h5tools_dump_simple_data(stream, info, ctx, dset, flags, hs_nelmts, p_type, sm_buf) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Reclaim any VL memory, if necessary */
|
|
|
|
if (vl_data)
|
|
|
|
H5Treclaim(p_type, sm_space, H5P_DEFAULT, sm_buf);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("Calculate the next hyperslab offset");
|
2019-11-07 23:48:56 +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];
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
if (hs_offset[i - 1] == total_size[i - 1])
|
|
|
|
hs_offset[i - 1] = 0;
|
|
|
|
else
|
|
|
|
carry = 0;
|
|
|
|
}
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
else
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Dread failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
ctx->continuation++;
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("stripmine read loop:%d complete", i);
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
2023-06-29 06:48:12 +08:00
|
|
|
free(sm_buf);
|
2019-11-07 23:48:56 +08:00
|
|
|
} /* if (NULL != (sm_buf...)) */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
done:
|
2020-09-30 22:27:10 +08:00
|
|
|
if (sm_space >= 0 && H5Sclose(sm_space) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Sclose failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
if (f_space >= 0 && H5Sclose(f_space) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Sclose failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2012-03-13 00:33:15 +08:00
|
|
|
return ret_value;
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* 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
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t attr_id,
|
|
|
|
hid_t p_type)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t f_space = H5I_INVALID_HID; /* file data space */
|
2019-12-05 06:36:32 +08:00
|
|
|
hsize_t alloc_size;
|
2020-09-30 22:27:10 +08:00
|
|
|
int sndims; /* rank of dataspace */
|
|
|
|
unsigned i; /* counters */
|
|
|
|
hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
|
|
|
|
hsize_t p_nelmts; /* total selected elmts */
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned char *buf = NULL; /* buffer for raw data */
|
|
|
|
int ret_value = 0;
|
2019-12-05 06:36:32 +08:00
|
|
|
|
|
|
|
/* VL data special information */
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned int vl_data = 0; /* contains VL datatypes */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2019-12-28 16:16:44 +08:00
|
|
|
if (H5I_INVALID_HID == (f_space = H5Aget_space(attr_id)))
|
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-12-05 06:36:32 +08:00
|
|
|
sndims = H5Sget_simple_extent_ndims(f_space);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (sndims < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Dget_simple_extent_ndims failed");
|
2016-06-29 05:53:48 +08:00
|
|
|
ctx->ndims = (unsigned)sndims;
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("sndims:%d", sndims);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((size_t)ctx->ndims > NELMTS(ctx->p_min_idx))
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "ctx->ndims > NELMTS(ctx->p_min_idx) failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Assume entire data space to be printed */
|
2019-12-05 06:36:32 +08:00
|
|
|
H5Sget_simple_extent_dims(f_space, total_size, NULL);
|
2020-07-16 00:20:16 +08:00
|
|
|
init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-12-05 06:36:32 +08:00
|
|
|
/* calculate the number of elements we're going to print */
|
|
|
|
p_nelmts = 1;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
if (ctx->ndims > 0) {
|
2019-12-05 06:36:32 +08:00
|
|
|
for (i = 0; i < ctx->ndims; i++)
|
|
|
|
p_nelmts *= total_size[i];
|
|
|
|
ctx->size_last_dim = (total_size[ctx->ndims - 1]);
|
2012-02-18 05:41:58 +08:00
|
|
|
} /* end if */
|
|
|
|
else
|
|
|
|
ctx->size_last_dim = 0;
|
|
|
|
|
2019-12-05 06:36:32 +08:00
|
|
|
if (p_nelmts == 0)
|
|
|
|
H5_LEAVE(SUCCEED); /* nothing to print */
|
|
|
|
|
|
|
|
/* Check if we have VL data in the dataset's datatype */
|
2023-09-06 02:50:06 +08:00
|
|
|
if (h5tools_detect_vlen(p_type) == true)
|
|
|
|
vl_data = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-12-05 06:36:32 +08:00
|
|
|
alloc_size = p_nelmts * H5Tget_size(p_type);
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
|
2023-06-29 06:48:12 +08:00
|
|
|
if (NULL != (buf = (unsigned char *)malloc((size_t)alloc_size))) {
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("ctx->ndims:%d", ctx->ndims);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("Read the data");
|
2019-12-05 06:36:32 +08:00
|
|
|
/* Read the data */
|
|
|
|
if (H5Aread(attr_id, p_type, buf) >= 0) {
|
2020-09-30 22:27:10 +08:00
|
|
|
if (h5tools_dump_simple_data(stream, info, ctx, attr_id, START_OF_DATA | END_OF_DATA, p_nelmts,
|
|
|
|
p_type, buf) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-12-05 06:36:32 +08:00
|
|
|
/* Reclaim any VL memory, if necessary */
|
|
|
|
if (vl_data)
|
|
|
|
H5Treclaim(p_type, f_space, H5P_DEFAULT, buf);
|
|
|
|
}
|
|
|
|
else
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Aread failed");
|
2023-06-29 06:48:12 +08:00
|
|
|
free(buf);
|
2019-12-05 06:36:32 +08:00
|
|
|
} /* if (NULL != (buf...)) */
|
|
|
|
done:
|
2020-09-30 22:27:10 +08:00
|
|
|
if (f_space >= 0 && H5Sclose(f_space) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Sclose failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2012-03-13 00:33:15 +08:00
|
|
|
return ret_value;
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* 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
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t f_space = H5I_INVALID_HID;
|
|
|
|
hid_t p_type = H5I_INVALID_HID;
|
|
|
|
hid_t f_type = H5I_INVALID_HID;
|
|
|
|
H5S_class_t space_type;
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tool_format_t info_dflt;
|
2020-09-30 22:27:10 +08:00
|
|
|
int ret_value = 0;
|
2019-12-28 16:16:44 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Use default values */
|
|
|
|
if (!stream)
|
2012-02-25 05:14:47 +08:00
|
|
|
stream = rawoutstream;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
if (!info) {
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&info_dflt, 0, sizeof info_dflt);
|
2012-02-18 05:41:58 +08:00
|
|
|
info = &info_dflt;
|
|
|
|
}
|
|
|
|
|
2014-07-31 04:55:14 +08:00
|
|
|
f_type = H5Dget_type(dset);
|
|
|
|
if (f_type < 0)
|
|
|
|
goto done;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2014-07-31 04:55:14 +08:00
|
|
|
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
|
2017-05-10 23:59:13 +08:00
|
|
|
p_type = H5Tget_native_type(f_type, H5T_DIR_DEFAULT);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2014-07-31 04:55:14 +08:00
|
|
|
if (p_type < 0)
|
|
|
|
goto done;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* Check the data space */
|
|
|
|
f_space = H5Dget_space(dset);
|
2014-07-31 04:55:14 +08:00
|
|
|
if (f_space < 0)
|
|
|
|
goto done;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
space_type = H5Sget_simple_extent_type(f_space);
|
|
|
|
|
|
|
|
/* Print the data */
|
|
|
|
if (space_type == H5S_SIMPLE || space_type == H5S_SCALAR) {
|
2020-09-30 22:27:10 +08:00
|
|
|
if (!ctx->sset)
|
2019-12-05 06:36:32 +08:00
|
|
|
ret_value = h5tools_dump_simple_dset(rawdatastream, info, ctx, dset, p_type);
|
2012-02-18 05:41:58 +08:00
|
|
|
else
|
2019-12-05 06:36:32 +08:00
|
|
|
ret_value = h5tools_dump_simple_subset(rawdatastream, info, ctx, dset, p_type);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
2019-11-07 23:48:56 +08:00
|
|
|
else {
|
2012-02-18 05:41:58 +08:00
|
|
|
/* space is H5S_NULL */
|
2019-12-05 06:36:32 +08:00
|
|
|
ret_value = SUCCEED;
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
done:
|
2014-07-31 04:55:14 +08:00
|
|
|
if (f_type > 0)
|
|
|
|
H5Tclose(f_type);
|
|
|
|
if (p_type > 0)
|
2012-02-18 05:41:58 +08:00
|
|
|
H5Tclose(p_type);
|
2014-07-31 04:55:14 +08:00
|
|
|
if (f_space > 0)
|
|
|
|
H5Sclose(f_space);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2019-12-05 06:36:32 +08:00
|
|
|
return ret_value;
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* 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
|
2019-12-05 06:36:32 +08:00
|
|
|
h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t attr_id)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t f_space = H5I_INVALID_HID;
|
|
|
|
hid_t p_type = H5I_INVALID_HID;
|
|
|
|
hid_t f_type = H5I_INVALID_HID;
|
|
|
|
h5tool_format_t info_dflt;
|
|
|
|
int ret_value = 0;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Use default values */
|
|
|
|
if (!stream)
|
2012-02-25 05:14:47 +08:00
|
|
|
stream = rawoutstream;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
if (!info) {
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&info_dflt, 0, sizeof(info_dflt));
|
2012-02-18 05:41:58 +08:00
|
|
|
info = &info_dflt;
|
|
|
|
}
|
|
|
|
|
2019-12-05 06:36:32 +08:00
|
|
|
f_type = H5Aget_type(attr_id);
|
|
|
|
if (f_type < 0)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
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 = H5Tget_native_type(f_type, H5T_DIR_DEFAULT);
|
|
|
|
|
|
|
|
if (p_type < 0)
|
|
|
|
goto done;
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Check the data space */
|
2019-12-05 06:36:32 +08:00
|
|
|
f_space = H5Aget_space(attr_id);
|
|
|
|
if (f_space < 0)
|
|
|
|
goto done;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-12-05 06:36:32 +08:00
|
|
|
/* Check the data space */
|
|
|
|
if (H5Sis_simple(f_space) <= 0) {
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Sis_simple failed");
|
2019-12-05 06:36:32 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ret_value = h5tools_dump_simple_mem(rawattrstream, info, ctx, attr_id, p_type);
|
|
|
|
}
|
|
|
|
done:
|
|
|
|
if (f_type > 0)
|
|
|
|
H5Tclose(f_type);
|
|
|
|
if (p_type > 0)
|
|
|
|
H5Tclose(p_type);
|
|
|
|
if (f_space > 0)
|
|
|
|
H5Sclose(f_space);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2012-02-18 05:41:58 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: print_datatype
|
|
|
|
*
|
|
|
|
* Purpose: print the datatype - do not prefix.
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* In/Out: h5tools_str_t *buffer
|
|
|
|
* h5tools_context_t *ctx
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info,
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_context_t *ctx, hid_t type, int object_search)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
char *mname;
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t mtype = H5I_INVALID_HID;
|
|
|
|
hid_t str_type = H5I_INVALID_HID;
|
|
|
|
hid_t super = H5I_INVALID_HID;
|
|
|
|
hid_t tmp_type = H5I_INVALID_HID;
|
|
|
|
int snmembers;
|
|
|
|
int sndims;
|
|
|
|
unsigned nmembers;
|
|
|
|
unsigned i;
|
|
|
|
size_t size = 0;
|
|
|
|
size_t ncols = 80; /*available output width */
|
|
|
|
hsize_t dims[H5TOOLS_DUMP_MAX_RANK];
|
|
|
|
hsize_t curr_pos = 0; /* total data element position */
|
|
|
|
H5T_str_t str_pad;
|
|
|
|
H5T_cset_t cset;
|
|
|
|
H5T_order_t order;
|
|
|
|
H5T_class_t type_class;
|
|
|
|
H5T_sign_t sign; /* sign scheme value */
|
2023-09-06 02:50:06 +08:00
|
|
|
htri_t is_vlstr = false;
|
|
|
|
bool past_catch = false;
|
2020-09-30 22:27:10 +08:00
|
|
|
const char *sign_s = NULL; /* sign scheme string */
|
|
|
|
const char *order_s = NULL; /* byte order string */
|
|
|
|
int ret_value = 0;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((type_class = H5Tget_class(type)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Tget_class failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
if (object_search && H5Tcommitted(type) > 0) {
|
2020-09-30 22:27:10 +08:00
|
|
|
H5O_info2_t oinfo;
|
2022-07-27 05:45:46 +08:00
|
|
|
obj_t *obj = NULL; /* Found object */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-01-17 05:29:34 +08:00
|
|
|
H5Oget_info3(type, &oinfo, H5O_INFO_BASIC);
|
|
|
|
obj = search_obj(h5dump_type_table, &oinfo.token);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (obj) {
|
|
|
|
if (!obj->recorded) {
|
2020-03-30 16:51:36 +08:00
|
|
|
char *obj_tok_str = NULL;
|
2020-01-17 05:29:34 +08:00
|
|
|
|
2020-03-30 16:51:36 +08:00
|
|
|
H5Otoken_to_str(type, &oinfo.token, &obj_tok_str);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "\"/#%s\"", obj_tok_str);
|
2020-03-30 16:51:36 +08:00
|
|
|
H5free_memory(obj_tok_str);
|
2020-01-17 05:29:34 +08:00
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
else
|
|
|
|
h5tools_str_append(buffer, "\"%s\"", obj->objname);
|
2015-06-13 05:29:20 +08:00
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
else {
|
|
|
|
error_msg("unknown committed type.\n");
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret_value;
|
2015-06-13 05:29:20 +08:00
|
|
|
}
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
if (info->line_ncols > 0)
|
|
|
|
ncols = info->line_ncols;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
switch (type_class) {
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5T_INTEGER:
|
2023-09-06 02:50:06 +08:00
|
|
|
if (H5Tequal(type, H5T_STD_I8BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_I8BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I8LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_I8LE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I16BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_I16BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I16LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_I16LE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I32BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_I32BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I32LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_I32LE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I64BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_I64BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I64LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_I64LE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U8BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_U8BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U8LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_U8LE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U16BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_U16BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U16LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_U16LE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U32BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_U32BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U32LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_U32LE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U64BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_U64BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U64LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_U64LE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_SCHAR) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_SCHAR");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_UCHAR) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_UCHAR");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_SHORT) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_SHORT");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_USHORT) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_USHORT");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_INT) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_INT");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_UINT) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_UINT");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_LONG) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_LONG");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_ULONG) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_ULONG");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_LLONG) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_LLONG");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_ULLONG) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_ULLONG");
|
|
|
|
else {
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
/* 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";
|
|
|
|
}
|
2017-10-14 05:34:01 +08:00
|
|
|
else
|
2020-09-30 22:27:10 +08:00
|
|
|
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";
|
|
|
|
}
|
2017-10-14 05:34:01 +08:00
|
|
|
else
|
2012-02-18 05:41:58 +08:00
|
|
|
sign_s = " unknown-sign";
|
2020-09-30 22:27:10 +08:00
|
|
|
|
2021-04-15 20:59:01 +08:00
|
|
|
/* print size, order, sign, and precision */
|
2022-08-03 20:46:33 +08:00
|
|
|
h5tools_str_append(buffer, "%zu-bit%s%s integer %zu-bit precision", 8 * H5Tget_size(type),
|
|
|
|
order_s, sign_s, H5Tget_precision(type));
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5T_FLOAT:
|
2023-09-06 02:50:06 +08:00
|
|
|
if (H5Tequal(type, H5T_IEEE_F32BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_IEEE_F32BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_IEEE_F32LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_IEEE_F32LE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_IEEE_F64BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_IEEE_F64BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_IEEE_F64LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_IEEE_F64LE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_VAX_F32) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_VAX_F32");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_VAX_F64) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_VAX_F64");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_FLOAT) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_FLOAT");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_DOUBLE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_NATIVE_DOUBLE");
|
|
|
|
else {
|
2021-04-15 20:59:01 +08:00
|
|
|
/* print what the library knows */
|
2020-09-30 22:27:10 +08:00
|
|
|
/* 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";
|
|
|
|
}
|
2017-10-14 05:34:01 +08:00
|
|
|
else
|
2020-09-30 22:27:10 +08:00
|
|
|
order_s = "";
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-04-15 20:59:01 +08:00
|
|
|
/* print size. byte order, and precision */
|
2022-08-03 20:46:33 +08:00
|
|
|
h5tools_str_append(buffer, "%zu-bit%s floating-point %zu-bit precision",
|
|
|
|
8 * H5Tget_size(type), order_s, H5Tget_precision(type));
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5T_TIME:
|
|
|
|
h5tools_str_append(buffer, "H5T_TIME: not yet implemented");
|
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
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);
|
|
|
|
|
|
|
|
curr_pos = ctx->cur_column;
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->strblockbegin);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level++;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(buffer);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (is_vlstr)
|
|
|
|
h5tools_str_append(buffer, "%s H5T_VARIABLE;", STRSIZE);
|
|
|
|
else
|
|
|
|
h5tools_str_append(buffer, "%s %d;", STRSIZE, (int)size);
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(buffer);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "%s ", STRPAD);
|
|
|
|
switch (str_pad) {
|
|
|
|
case H5T_STR_NULLTERM:
|
|
|
|
h5tools_str_append(buffer, "H5T_STR_NULLTERM;");
|
|
|
|
break;
|
|
|
|
case H5T_STR_NULLPAD:
|
|
|
|
h5tools_str_append(buffer, "H5T_STR_NULLPAD;");
|
|
|
|
break;
|
|
|
|
case H5T_STR_SPACEPAD:
|
|
|
|
h5tools_str_append(buffer, "H5T_STR_SPACEPAD;");
|
|
|
|
break;
|
|
|
|
case H5T_STR_RESERVED_3:
|
|
|
|
case H5T_STR_RESERVED_4:
|
|
|
|
case H5T_STR_RESERVED_5:
|
|
|
|
case H5T_STR_RESERVED_6:
|
|
|
|
case H5T_STR_RESERVED_7:
|
|
|
|
case H5T_STR_RESERVED_8:
|
|
|
|
case H5T_STR_RESERVED_9:
|
|
|
|
case H5T_STR_RESERVED_10:
|
|
|
|
case H5T_STR_RESERVED_11:
|
|
|
|
case H5T_STR_RESERVED_12:
|
|
|
|
case H5T_STR_RESERVED_13:
|
|
|
|
case H5T_STR_RESERVED_14:
|
|
|
|
case H5T_STR_RESERVED_15:
|
|
|
|
h5tools_str_append(buffer, "H5T_STR_UNKNOWN;");
|
|
|
|
break;
|
|
|
|
case H5T_STR_ERROR:
|
|
|
|
h5tools_str_append(buffer, "H5T_STR_ERROR;");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
h5tools_str_append(buffer, "ERROR;");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(buffer);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "%s ", CSET);
|
|
|
|
|
|
|
|
switch (cset) {
|
|
|
|
case H5T_CSET_ASCII:
|
|
|
|
h5tools_str_append(buffer, "H5T_CSET_ASCII;");
|
|
|
|
break;
|
|
|
|
case H5T_CSET_UTF8:
|
|
|
|
h5tools_str_append(buffer, "H5T_CSET_UTF8;");
|
|
|
|
break;
|
|
|
|
case H5T_CSET_RESERVED_2:
|
|
|
|
case H5T_CSET_RESERVED_3:
|
|
|
|
case H5T_CSET_RESERVED_4:
|
|
|
|
case H5T_CSET_RESERVED_5:
|
|
|
|
case H5T_CSET_RESERVED_6:
|
|
|
|
case H5T_CSET_RESERVED_7:
|
|
|
|
case H5T_CSET_RESERVED_8:
|
|
|
|
case H5T_CSET_RESERVED_9:
|
|
|
|
case H5T_CSET_RESERVED_10:
|
|
|
|
case H5T_CSET_RESERVED_11:
|
|
|
|
case H5T_CSET_RESERVED_12:
|
|
|
|
case H5T_CSET_RESERVED_13:
|
|
|
|
case H5T_CSET_RESERVED_14:
|
|
|
|
case H5T_CSET_RESERVED_15:
|
|
|
|
h5tools_str_append(buffer, "H5T_CSET_UNKNOWN;");
|
|
|
|
break;
|
|
|
|
case H5T_CSET_ERROR:
|
|
|
|
h5tools_str_append(buffer, "H5T_CSET_ERROR;");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
h5tools_str_append(buffer, "ERROR;");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(buffer);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
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);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "%s ", CTYPE);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
/* Check C variable-length string first. Are the two types equal? */
|
|
|
|
if (H5Tequal(tmp_type, str_type)) {
|
|
|
|
h5tools_str_append(buffer, "H5T_C_S1;");
|
|
|
|
goto found_string_type;
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
/* Change the endianness and see if they're equal. */
|
|
|
|
order = H5Tget_order(tmp_type);
|
|
|
|
if (order == H5T_ORDER_LE) {
|
|
|
|
if (H5Tset_order(str_type, H5T_ORDER_LE) < 0)
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tset_order failed");
|
|
|
|
} /* end if */
|
|
|
|
else if (order == H5T_ORDER_BE) {
|
|
|
|
if (H5Tset_order(str_type, H5T_ORDER_BE) < 0)
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tset_order failed");
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
if (H5Tequal(tmp_type, str_type)) {
|
|
|
|
h5tools_str_append(buffer, "H5T_C_S1;");
|
|
|
|
goto found_string_type;
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
/* If not equal to C variable-length string, check Fortran type. */
|
|
|
|
if (H5Tclose(str_type) < 0)
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tclose failed");
|
|
|
|
str_type = H5Tcopy(H5T_FORTRAN_S1);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
H5Tset_cset(str_type, cset);
|
|
|
|
H5Tset_size(str_type, size);
|
|
|
|
H5Tset_strpad(str_type, str_pad);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
/* Are the two types equal? */
|
|
|
|
if (H5Tequal(tmp_type, str_type)) {
|
|
|
|
h5tools_str_append(buffer, "H5T_FORTRAN_S1;");
|
|
|
|
goto found_string_type;
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
/* Change the endianness and see if they're equal. */
|
|
|
|
order = H5Tget_order(tmp_type);
|
|
|
|
if (order == H5T_ORDER_LE) {
|
|
|
|
if (H5Tset_order(str_type, H5T_ORDER_LE) < 0)
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tset_order failed");
|
|
|
|
} /* end if */
|
|
|
|
else if (order == H5T_ORDER_BE) {
|
|
|
|
if (H5Tset_order(str_type, H5T_ORDER_BE) < 0)
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tset_order failed");
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
if (H5Tequal(tmp_type, str_type)) {
|
|
|
|
h5tools_str_append(buffer, "H5T_FORTRAN_S1;");
|
|
|
|
goto found_string_type;
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
/* Type doesn't match any of above. */
|
|
|
|
h5tools_str_append(buffer, "unknown_one_character_type;");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
found_string_type:
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
|
|
|
ctx->indent_level--;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
if (H5Tclose(str_type) < 0)
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tclose failed");
|
|
|
|
if (H5Tclose(tmp_type) < 0)
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tclose failed");
|
2012-11-02 00:01:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->strblockend);
|
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5T_BITFIELD:
|
2023-09-06 02:50:06 +08:00
|
|
|
if (H5Tequal(type, H5T_STD_B8BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_B8BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B8LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_B8LE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B16BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_B16BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B16LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_B16LE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B32BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_B32BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B32LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_B32LE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B64BE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_B64BE");
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B64LE) == true)
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_B64LE");
|
|
|
|
else
|
|
|
|
h5tools_str_append(buffer, "undefined bitfield");
|
|
|
|
break;
|
2019-08-28 04:10:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5T_OPAQUE:
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->opaqblockbegin);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
|
|
|
ctx->indent_level++;
|
|
|
|
{
|
|
|
|
char *ttag;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == (ttag = H5Tget_tag(type)))
|
|
|
|
H5TOOLS_THROW((-1), "H5Tget_tag failed");
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2019-08-28 04:10:37 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "OPAQUE_TAG \"%s\";", ttag);
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
|
|
|
|
|
|
|
H5free_memory(ttag);
|
|
|
|
|
|
|
|
if ((size = H5Tget_size(type)) <= 0) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2020-09-30 22:27:10 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(buffer);
|
2022-02-05 00:53:55 +08:00
|
|
|
h5tools_str_append(buffer, "OPAQUE_SIZE \"%zu\";", size);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
|
|
|
}
|
2019-08-28 04:10:37 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level--;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(buffer);
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->opaqblockend);
|
2020-09-30 22:27:10 +08:00
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5T_COMPOUND:
|
|
|
|
if ((snmembers = H5Tget_nmembers(type)) < 0)
|
|
|
|
H5TOOLS_THROW((-1), "H5Tget_nmembers failed");
|
|
|
|
nmembers = (unsigned)snmembers;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->cmpdblockbegin);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level++;
|
|
|
|
for (i = 0; i < nmembers; i++) {
|
|
|
|
mname = H5Tget_member_name(type, i);
|
|
|
|
if ((mtype = H5Tget_member_type(type, i)) >= 0) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(buffer);
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_print_datatype(stream, buffer, info, ctx, mtype, true);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, " \"%s\";", mname);
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
|
|
|
if (H5Tclose(mtype) < 0)
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tclose failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tget_member_type failed");
|
|
|
|
H5free_memory(mname);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level--;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(buffer);
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->cmpdblockend);
|
2020-09-30 22:27:10 +08:00
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5T_REFERENCE:
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->refblockbegin);
|
2023-09-06 02:50:06 +08:00
|
|
|
if (H5Tequal(type, H5T_STD_REF_DSETREG) == true) {
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_REF_DSETREG");
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_REF_OBJ) == true) {
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_REF_OBJECT");
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_REF) == true) {
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "H5T_STD_REF");
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
|
|
|
else {
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "UNDEFINED");
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->refblockend);
|
2020-09-30 22:27:10 +08:00
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5T_ENUM:
|
|
|
|
if ((super = H5Tget_super(type)) < 0)
|
|
|
|
H5TOOLS_THROW((-1), "H5Tget_super failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->enumblockbegin);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
|
|
|
ctx->indent_level++;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(buffer);
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_print_datatype(stream, buffer, info, ctx, super, true);
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Tclose(super) < 0)
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tclose failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, ";");
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_print_enum(stream, buffer, info, ctx, type);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level--;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->enumblockend);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5T_VLEN:
|
|
|
|
if ((super = H5Tget_super(type)) < 0)
|
|
|
|
H5TOOLS_THROW((-1), "H5Tget_super failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->vlenblockbegin);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_print_datatype(stream, buffer, info, ctx, super, true);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Tclose(super) < 0)
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tclose failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->vlenblockend);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5T_ARRAY:
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->arrblockbegin);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
/* Get array information */
|
|
|
|
if ((sndims = H5Tget_array_ndims(type)) >= 0) {
|
|
|
|
unsigned ndims = (unsigned)sndims;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Tget_array_dims2(type, dims) >= 0) {
|
|
|
|
/* Print array dimensions */
|
|
|
|
for (i = 0; i < ndims; i++)
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(buffer, "[%" PRIuHSIZE "]", dims[i]);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, " ");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tget_array_dims2 failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
else
|
2020-09-30 22:27:10 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Tget_array_ndims failed");
|
|
|
|
|
|
|
|
/* Get array base type */
|
|
|
|
if ((super = H5Tget_super(type)) >= 0) {
|
|
|
|
/* Print base type */
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_print_datatype(stream, buffer, info, ctx, super, true);
|
2020-09-30 22:27:10 +08:00
|
|
|
/* Close array base type */
|
|
|
|
if (H5Tclose(super) < 0)
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tclose failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
H5TOOLS_ERROR((-1), "H5Tget_super failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-08-24 23:45:38 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->arrblockend);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5T_NO_CLASS:
|
|
|
|
case H5T_NCLASSES:
|
|
|
|
default:
|
|
|
|
h5tools_str_append(buffer, "unknown datatype");
|
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2012-02-18 05:41:58 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: print_dataspace
|
|
|
|
*
|
|
|
|
* Purpose: print the dataspace.
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* In/Out: h5tools_str_t *buffer
|
|
|
|
* h5tools_context_t *ctx
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
2012-11-02 00:01:37 +08:00
|
|
|
h5tools_print_dataspace(h5tools_str_t *buffer, hid_t space)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
|
|
|
hsize_t size[H5TOOLS_DUMP_MAX_RANK];
|
|
|
|
hsize_t maxsize[H5TOOLS_DUMP_MAX_RANK];
|
2020-09-30 22:27:10 +08:00
|
|
|
int ndims = -1;
|
2012-02-18 05:41:58 +08:00
|
|
|
H5S_class_t space_type = -1;
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
2012-02-18 05:41:58 +08:00
|
|
|
int i;
|
2019-12-28 16:16:44 +08:00
|
|
|
int ret_value = 0;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((ndims = H5Sget_simple_extent_dims(space, size, maxsize)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Sget_simple_extent_dims failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((space_type = H5Sget_simple_extent_type(space)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Sget_simple_extent_type failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
switch (space_type) {
|
|
|
|
case H5S_SCALAR:
|
|
|
|
/* scalar dataspace */
|
|
|
|
h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin,
|
|
|
|
S_SCALAR);
|
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5S_SIMPLE:
|
|
|
|
/* simple dataspace */
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(buffer, "%s %s { %s %" PRIuHSIZE,
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_dump_header_format->dataspacedescriptionbegin, S_SIMPLE,
|
|
|
|
h5tools_dump_header_format->dataspacedimbegin, size[0]);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
for (i = 1; i < ndims; i++)
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(buffer, ", %" PRIuHSIZE, size[i]);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, " %s / ", h5tools_dump_header_format->dataspacedimend);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (maxsize[0] == H5S_UNLIMITED)
|
|
|
|
h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedimbegin,
|
|
|
|
"H5S_UNLIMITED");
|
2012-02-18 05:41:58 +08:00
|
|
|
else
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(buffer, "%s %" PRIuHSIZE, h5tools_dump_header_format->dataspacedimbegin,
|
|
|
|
maxsize[0]);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
for (i = 1; i < ndims; i++)
|
|
|
|
if (maxsize[i] == H5S_UNLIMITED)
|
|
|
|
h5tools_str_append(buffer, ", %s", "H5S_UNLIMITED");
|
|
|
|
else
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(buffer, ", %" PRIuHSIZE, maxsize[i]);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, " %s }", h5tools_dump_header_format->dataspacedimend);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5S_NULL:
|
|
|
|
/* null dataspace */
|
|
|
|
h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin,
|
|
|
|
S_NULL);
|
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5S_NO_CLASS:
|
|
|
|
default:
|
|
|
|
h5tools_str_append(buffer, "%s unknown dataspace %s\n", BEGIN, END);
|
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
} /* end switch */
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2012-02-18 05:41:58 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: print_enum
|
|
|
|
*
|
|
|
|
* Purpose: prints the enum data
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* In/Out: h5tools_str_t *buffer
|
|
|
|
* h5tools_context_t *ctx
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
int
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info, h5tools_context_t *ctx,
|
|
|
|
hid_t type)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
char **name = NULL; /*member names */
|
2012-02-18 05:41:58 +08:00
|
|
|
unsigned char *value = NULL; /*value array */
|
|
|
|
unsigned i;
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned nmembs = 0; /*number of members */
|
2012-02-18 05:41:58 +08:00
|
|
|
int snmembs;
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t super = H5I_INVALID_HID; /*enum base integer type */
|
|
|
|
hid_t native = H5I_INVALID_HID; /*native integer datatype */
|
|
|
|
H5T_sign_t sign_type; /*sign of value type */
|
|
|
|
size_t type_size; /*value type size */
|
|
|
|
size_t dst_size; /*destination value type size */
|
|
|
|
size_t ncols = 80; /*available output width */
|
|
|
|
hsize_t curr_pos = 0; /* total data element position */
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
2020-09-30 22:27:10 +08:00
|
|
|
int ret_value = 0;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2012-02-18 05:41:58 +08:00
|
|
|
if (info->line_ncols > 0)
|
|
|
|
ncols = info->line_ncols;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((snmembs = H5Tget_nmembers(type)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Tget_nmembers failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
nmembs = (unsigned)snmembs;
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(nmembs > 0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((super = H5Tget_super(type)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Tget_super failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((type_size = H5Tget_size(type)) <= 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Tget_size(type) failed");
|
2012-02-18 05:41:58 +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
|
|
|
|
* 2. unsigned long long -- the largest native unsigned integer
|
|
|
|
* 3. raw format
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
if (type_size <= sizeof(long long)) {
|
2012-02-18 05:41:58 +08:00
|
|
|
dst_size = sizeof(long long);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((sign_type = H5Tget_sign(type)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Tget_sign failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5T_SGN_NONE == sign_type)
|
2012-02-18 05:41:58 +08:00
|
|
|
native = H5T_NATIVE_ULLONG;
|
|
|
|
else
|
|
|
|
native = H5T_NATIVE_LLONG;
|
|
|
|
} /* end if */
|
|
|
|
else
|
|
|
|
dst_size = type_size;
|
|
|
|
|
|
|
|
/* Get the names and raw values of all members */
|
2023-06-29 06:48:12 +08:00
|
|
|
if (NULL == (name = (char **)calloc((size_t)nmembs, sizeof(char *))))
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "Could not allocate buffer for member name");
|
2023-06-29 06:48:12 +08:00
|
|
|
if (NULL == (value = (unsigned char *)calloc((size_t)nmembs, MAX(type_size, dst_size))))
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "Could not allocate buffer for member value");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
for (i = 0; i < nmembs; i++) {
|
|
|
|
name[i] = H5Tget_member_name(type, i);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Tget_member_value(type, i, value + i * type_size) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Tget_member_value failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert values to native datatype */
|
|
|
|
if (native > 0)
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Tconvert failed");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sort members by increasing value
|
|
|
|
* ***not implemented yet***
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Print members */
|
|
|
|
for (i = 0; i < nmembs; i++) {
|
2020-09-30 22:27:10 +08:00
|
|
|
int nchars; /*number of output characters */
|
2016-06-29 05:53:48 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_simple_prefix(stream, info, ctx, (hsize_t)0, 0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(buffer);
|
|
|
|
h5tools_str_append(buffer, "\"%s\"", name[i]);
|
2023-09-16 06:13:18 +08:00
|
|
|
nchars = (int)strlen(name[i]);
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, "%*s ", MAX(0, 16 - nchars), "");
|
|
|
|
|
|
|
|
if (native < 0) {
|
|
|
|
size_t j;
|
|
|
|
|
|
|
|
h5tools_str_append(buffer, "0x");
|
|
|
|
|
|
|
|
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)) {
|
2022-02-22 05:31:57 +08:00
|
|
|
unsigned long long copy;
|
|
|
|
|
2023-06-30 03:33:46 +08:00
|
|
|
memcpy(©, value + i * dst_size, sizeof(copy));
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(buffer, "%llu", copy);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
else {
|
2022-02-22 05:31:57 +08:00
|
|
|
long long copy;
|
|
|
|
|
2023-06-30 03:33:46 +08:00
|
|
|
memcpy(©, value + i * dst_size, sizeof(copy));
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(buffer, "%lld", copy);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
h5tools_str_append(buffer, ";");
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
|
|
|
if (name) {
|
2012-02-18 05:41:58 +08:00
|
|
|
/* Release resources */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (i = 0; i < nmembs; i++)
|
|
|
|
if (name[i])
|
2014-04-01 07:35:09 +08:00
|
|
|
H5free_memory(name[i]);
|
2023-06-29 06:48:12 +08:00
|
|
|
free(name);
|
2012-02-18 05:41:58 +08:00
|
|
|
} /* end if */
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (value)
|
2023-06-29 06:48:12 +08:00
|
|
|
free(value);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (super >= 0 && H5Tclose(super) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "Could not close datatype's super class");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (0 == nmembs)
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(buffer, "\n<empty>");
|
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2012-02-18 05:41:58 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_datatype
|
|
|
|
*
|
|
|
|
* Purpose: Dump the datatype. Datatype can be HDF5 predefined
|
|
|
|
* atomic datatype or committed/transient datatype.
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* In/Out: h5tools_context_t *ctx
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t type)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_t buffer; /* string into which to render */
|
|
|
|
size_t ncols = 80; /* available output width */
|
|
|
|
hsize_t curr_pos = ctx->sm_pos; /* total data element position */
|
|
|
|
/* 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
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* setup */
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&buffer, 0, sizeof(h5tools_str_t));
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
if (info->line_ncols > 0)
|
|
|
|
ncols = info->line_ncols;
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->datatypebegin,
|
|
|
|
h5tools_dump_header_format->datatypeblockbegin);
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_print_datatype(stream, &buffer, info, ctx, type, true);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datatypeblockend)) {
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeblockend);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datatypeend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, " ");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datatypeend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeend);
|
|
|
|
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
h5tools_str_close(&buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_dataspace
|
|
|
|
*
|
2015-06-13 05:29:20 +08:00
|
|
|
* Purpose: Dump the dataspace.
|
2012-02-18 05:41:58 +08:00
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* In/Out: h5tools_context_t *ctx
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t type)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_t buffer; /* string into which to render */
|
|
|
|
size_t ncols = 80; /* available output width */
|
|
|
|
hsize_t curr_pos = ctx->sm_pos; /* total data element position */
|
|
|
|
/* 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
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* setup */
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&buffer, 0, sizeof(h5tools_str_t));
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
if (info->line_ncols > 0)
|
|
|
|
ncols = info->line_ncols;
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s ", h5tools_dump_header_format->dataspacebegin);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2012-11-02 00:01:37 +08:00
|
|
|
h5tools_print_dataspace(&buffer, type);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataspaceblockend)) {
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataspaceend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, " ");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataspaceend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->dataspaceend);
|
|
|
|
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
h5tools_str_close(&buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_oid
|
|
|
|
*
|
|
|
|
* Purpose: Dump the oid.
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* In/Out: h5tools_context_t *ctx
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_dump_oid(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t oid)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_t buffer; /* string into which to render */
|
|
|
|
size_t ncols = 80; /* available output width */
|
|
|
|
hsize_t curr_pos = ctx->sm_pos; /* total data element position */
|
|
|
|
/* 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
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* setup */
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&buffer, 0, sizeof(h5tools_str_t));
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
if (info->line_ncols > 0)
|
|
|
|
ncols = info->line_ncols;
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2022-02-05 00:53:55 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s %" PRId64 " %s", OBJID, BEGIN, oid, END);
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
h5tools_str_close(&buffer);
|
|
|
|
}
|
|
|
|
|
2015-02-24 02:41:02 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2015-02-24 03:19:19 +08:00
|
|
|
* Function: print_virtual_selection
|
2015-02-24 02:41:02 +08:00
|
|
|
*
|
2015-02-24 03:19:19 +08:00
|
|
|
* Purpose: Print the virtual dataset selection.
|
2015-02-24 02:41:02 +08:00
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2015-09-22 08:21:18 +08:00
|
|
|
static void
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_print_virtual_selection(hid_t vspace, FILE *stream, const h5tool_format_t *info,
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_context_t *ctx, /* in,out*/
|
2022-07-27 05:45:46 +08:00
|
|
|
h5tools_str_t *buffer, /* string into which to render */
|
|
|
|
hsize_t *curr_pos, /* total data element position */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t ncols)
|
2015-02-24 02:41:02 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
switch (H5Sget_select_type(vspace)) {
|
|
|
|
case H5S_SEL_NONE: /* Nothing selected */
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-03-13 06:29:59 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(buffer);
|
2015-03-04 22:08:58 +08:00
|
|
|
h5tools_str_append(buffer, "%s", VDS_NONE);
|
2015-02-26 23:59:15 +08:00
|
|
|
break;
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5S_SEL_POINTS: /* Sequence of points selected */
|
2015-03-13 06:29:59 +08:00
|
|
|
h5tools_str_reset(buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "%s %s ", VDS_POINT,
|
|
|
|
h5tools_dump_header_format->virtualselectionblockbegin);
|
2015-02-26 23:59:15 +08:00
|
|
|
h5tools_str_dump_space_points(buffer, vspace, info);
|
|
|
|
h5tools_str_append(buffer, " %s", h5tools_dump_header_format->virtualselectionblockend);
|
|
|
|
break;
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5S_SEL_HYPERSLABS: /* "New-style" hyperslab selection defined */
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-04-14 04:15:00 +08:00
|
|
|
|
2015-03-13 06:29:59 +08:00
|
|
|
h5tools_str_reset(buffer);
|
2015-03-04 21:34:24 +08:00
|
|
|
if (H5Sis_regular_hyperslab(vspace)) {
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "%s %s ", VDS_REG_HYPERSLAB,
|
|
|
|
h5tools_dump_header_format->virtualselectionblockbegin);
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-04-14 04:15:00 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(buffer);
|
2015-03-04 21:34:24 +08:00
|
|
|
h5tools_str_dump_space_slabs(buffer, vspace, info, ctx);
|
|
|
|
}
|
|
|
|
else {
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "%s %s ", VDS_IRR_HYPERSLAB,
|
|
|
|
h5tools_dump_header_format->virtualselectionblockbegin);
|
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-04-14 04:15:00 +08:00
|
|
|
ctx->indent_level++;
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-09-22 08:21:18 +08:00
|
|
|
h5tools_simple_prefix(stream, info, ctx, *curr_pos, 0);
|
2015-04-14 04:15:00 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(buffer);
|
2015-03-04 21:34:24 +08:00
|
|
|
h5tools_str_dump_space_blocks(buffer, vspace, info);
|
2015-04-14 04:15:00 +08:00
|
|
|
ctx->indent_level--;
|
2015-03-04 21:34:24 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-04-14 04:15:00 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(buffer);
|
2015-03-04 21:34:24 +08:00
|
|
|
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->virtualselectionblockend);
|
2015-02-26 23:59:15 +08:00
|
|
|
break;
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5S_SEL_ALL: /* Entire extent selected */
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-03-13 06:29:59 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(buffer);
|
2015-03-04 22:08:58 +08:00
|
|
|
h5tools_str_append(buffer, "%s", VDS_ALL);
|
2015-02-26 23:59:15 +08:00
|
|
|
break;
|
2016-06-29 05:53:48 +08:00
|
|
|
case H5S_SEL_ERROR:
|
|
|
|
case H5S_SEL_N:
|
2015-02-26 23:59:15 +08:00
|
|
|
default:
|
|
|
|
h5tools_str_append(buffer, "Unknown Selection");
|
2015-02-24 03:19:19 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2015-02-24 02:41:02 +08:00
|
|
|
}
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_fill_value
|
|
|
|
*
|
|
|
|
* Purpose: prints the fill value
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_print_fill_value(h5tools_str_t *buffer /*in,out*/, const h5tool_format_t *info,
|
|
|
|
h5tools_context_t *ctx /*in,out*/, hid_t dcpl, hid_t type_id, hid_t obj_id)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t size;
|
2023-08-02 12:14:32 +08:00
|
|
|
hid_t n_type = H5I_INVALID_HID;
|
|
|
|
void *buf = NULL;
|
|
|
|
bool vl_data = false;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2017-05-10 23:59:13 +08:00
|
|
|
n_type = H5Tget_native_type(type_id, H5T_DIR_DEFAULT);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
if (h5tools_detect_vlen(type_id) == true)
|
2023-08-02 12:14:32 +08:00
|
|
|
vl_data = true;
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
size = H5Tget_size(n_type);
|
2023-06-29 06:48:12 +08:00
|
|
|
buf = malloc(size);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
H5Pget_fill_value(dcpl, n_type, buf);
|
|
|
|
|
|
|
|
h5tools_str_sprint(buffer, info, obj_id, n_type, buf, ctx);
|
|
|
|
|
|
|
|
H5Tclose(n_type);
|
|
|
|
|
2023-08-02 12:14:32 +08:00
|
|
|
if (vl_data) {
|
|
|
|
hsize_t dims[1] = {1};
|
|
|
|
hid_t space_id = H5I_INVALID_HID;
|
|
|
|
|
|
|
|
space_id = H5Screate_simple(1, dims, NULL);
|
|
|
|
|
|
|
|
H5Treclaim(type_id, space_id, H5P_DEFAULT, buf);
|
|
|
|
|
|
|
|
H5Sclose(space_id);
|
|
|
|
}
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
if (buf)
|
2023-06-29 06:48:12 +08:00
|
|
|
free(buf);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_dcpl
|
|
|
|
*
|
|
|
|
* Purpose: prints several dataset create property list properties
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dcpl_id,
|
|
|
|
hid_t type_id, hid_t dset_id)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2023-08-02 12:14:32 +08:00
|
|
|
int nfilters = -1; /* number of filters */
|
|
|
|
int rank; /* rank */
|
2012-02-18 05:41:58 +08:00
|
|
|
int i;
|
|
|
|
unsigned j;
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned filt_flags; /* filter flags */
|
|
|
|
unsigned cd_values[20]; /* filter client data values */
|
2012-02-18 05:41:58 +08:00
|
|
|
unsigned szip_options_mask;
|
|
|
|
unsigned szip_pixels_per_block;
|
2020-09-30 22:27:10 +08:00
|
|
|
H5Z_filter_t filtn; /* filter identification number */
|
2023-08-02 12:14:32 +08:00
|
|
|
H5D_fill_value_t fvstatus = H5D_FILL_VALUE_ERROR;
|
|
|
|
H5D_alloc_time_t at = H5D_ALLOC_TIME_ERROR;
|
|
|
|
H5D_fill_time_t ft = H5D_FILL_TIME_ERROR;
|
|
|
|
H5D_layout_t stl = H5D_LAYOUT_ERROR;
|
|
|
|
size_t ncols = 80; /* available output width */
|
|
|
|
size_t cd_nelmts; /* filter client number of values */
|
|
|
|
off_t offset; /* offset of external file */
|
|
|
|
char f_name[256]; /* filter name */
|
|
|
|
char name[256]; /* external or virtual file name */
|
|
|
|
hsize_t chsize[64]; /* chunk size in elements */
|
|
|
|
hsize_t size; /* size of external file */
|
2012-02-18 05:41:58 +08:00
|
|
|
hsize_t storage_size;
|
2020-09-30 22:27:10 +08:00
|
|
|
hsize_t curr_pos = 0; /* total data element position */
|
|
|
|
h5tools_str_t buffer; /* string into which to render */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* setup */
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&buffer, 0, sizeof(h5tools_str_t));
|
2012-02-18 05:41:58 +08:00
|
|
|
if (info->line_ncols > 0)
|
|
|
|
ncols = info->line_ncols;
|
|
|
|
|
2020-04-02 17:12:19 +08:00
|
|
|
storage_size = H5Dget_storage_size(dset_id);
|
2023-08-02 12:14:32 +08:00
|
|
|
if (dcpl_id >= 0)
|
|
|
|
nfilters = H5Pget_nfilters(dcpl_id);
|
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
strcpy(f_name, "\0");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2020-09-30 22:27:10 +08:00
|
|
|
* STORAGE_LAYOUT
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s %s", STORAGE_LAYOUT, BEGIN);
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-08-02 12:14:32 +08:00
|
|
|
if (dcpl_id >= 0)
|
|
|
|
stl = H5Pget_layout(dcpl_id);
|
|
|
|
|
2015-02-26 23:59:15 +08:00
|
|
|
switch (stl) {
|
|
|
|
case H5D_CHUNKED:
|
2015-04-14 04:47:03 +08:00
|
|
|
ctx->indent_level++;
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-04-14 04:47:03 +08:00
|
|
|
|
2015-02-26 23:59:15 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s ", CHUNKED);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
rank = H5Pget_chunk(dcpl_id, (int)NELMTS(chsize), chsize);
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %" PRIuHSIZE, h5tools_dump_header_format->dataspacedimbegin,
|
2020-09-30 22:27:10 +08:00
|
|
|
chsize[0]);
|
|
|
|
for (i = 1; i < rank; i++)
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(&buffer, ", %" PRIuHSIZE, chsize[i]);
|
2015-02-26 23:59:15 +08:00
|
|
|
h5tools_str_append(&buffer, " %s", h5tools_dump_header_format->dataspacedimend);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-02-26 23:59:15 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(&buffer);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2015-02-26 23:59:15 +08:00
|
|
|
/* if there are filters, print a compression ratio */
|
|
|
|
if (nfilters) {
|
|
|
|
hsize_t dims[H5S_MAX_RANK];
|
|
|
|
hsize_t nelmts = 1;
|
2020-09-30 22:27:10 +08:00
|
|
|
double ratio = 0;
|
|
|
|
int ok = 0;
|
2015-02-26 23:59:15 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t tid = H5Dget_type(dset_id);
|
|
|
|
hid_t sid = H5Dget_space(dset_id);
|
2015-02-26 23:59:15 +08:00
|
|
|
size_t datum_size = H5Tget_size(tid);
|
2020-09-30 22:27:10 +08:00
|
|
|
int ndims = H5Sget_simple_extent_dims(sid, dims, NULL);
|
2015-02-26 23:59:15 +08:00
|
|
|
|
|
|
|
/* only print the compression ratio for these filters */
|
|
|
|
for (i = 0; i < nfilters && !ok; i++) {
|
|
|
|
cd_nelmts = NELMTS(cd_values);
|
2020-09-30 22:27:10 +08:00
|
|
|
filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, cd_values,
|
2022-07-27 05:45:46 +08:00
|
|
|
sizeof(f_name), f_name, NULL);
|
2020-09-30 22:27:10 +08:00
|
|
|
ok = (filtn >= 0);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (ndims && ok) {
|
2015-02-26 23:59:15 +08:00
|
|
|
hsize_t uncomp_size;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
for (i = 0; i < ndims; i++) {
|
2015-02-26 23:59:15 +08:00
|
|
|
nelmts *= dims[i];
|
|
|
|
}
|
|
|
|
uncomp_size = nelmts * datum_size;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2015-02-26 23:59:15 +08:00
|
|
|
/* compression ratio = uncompressed size / compressed size */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (storage_size != 0)
|
|
|
|
ratio = (double)uncomp_size / (double)storage_size;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(&buffer, "SIZE %" PRIuHSIZE " (%.3f:1 COMPRESSION)", storage_size,
|
2020-09-30 22:27:10 +08:00
|
|
|
ratio);
|
2015-02-26 23:59:15 +08:00
|
|
|
}
|
|
|
|
else
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(&buffer, "SIZE %" PRIuHSIZE, storage_size);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2015-02-26 23:59:15 +08:00
|
|
|
H5Sclose(sid);
|
|
|
|
H5Tclose(tid);
|
|
|
|
}
|
|
|
|
else {
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(&buffer, "SIZE %" PRIuHSIZE, storage_size);
|
2015-02-26 23:59:15 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-04-14 04:47:03 +08:00
|
|
|
ctx->indent_level--;
|
2015-02-26 23:59:15 +08:00
|
|
|
break;
|
|
|
|
case H5D_COMPACT:
|
2015-04-14 04:47:03 +08:00
|
|
|
ctx->indent_level++;
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-04-14 04:47:03 +08:00
|
|
|
|
2015-02-26 23:59:15 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s", COMPACT);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2015-02-26 23:59:15 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(&buffer, "SIZE %" PRIuHSIZE, storage_size);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-04-14 04:47:03 +08:00
|
|
|
ctx->indent_level--;
|
2015-02-26 23:59:15 +08:00
|
|
|
break;
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5D_CONTIGUOUS: {
|
|
|
|
int n_external;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
n_external = H5Pget_external_count(dcpl_id);
|
2020-03-30 16:51:36 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level++;
|
|
|
|
if (n_external) {
|
2015-04-14 04:47:03 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
/* EXTERNAL FILE */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s", CONTIGUOUS);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s %s", EXTERNAL, BEGIN);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level++;
|
|
|
|
for (j = 0; j < (unsigned)n_external; j++) {
|
|
|
|
H5Pget_external(dcpl_id, j, sizeof(name), name, &offset, &size);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-04-17 05:20:26 +08:00
|
|
|
|
2015-02-26 23:59:15 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(&buffer, "FILENAME %s SIZE %" PRIuHSIZE, name, size);
|
2022-08-03 20:46:33 +08:00
|
|
|
/* Using %lld with a cast to (long long) is probably the only portable
|
|
|
|
* way to print off_t values. There's no real standard for off_t other
|
|
|
|
* than it must be signed, according to POSIX.
|
|
|
|
*/
|
|
|
|
h5tools_str_append(&buffer, " OFFSET %lld", (long long)offset);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-02-26 23:59:15 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level--;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2020-03-30 16:51:36 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s", END);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
|
|
|
}
|
|
|
|
else {
|
2020-12-01 05:59:22 +08:00
|
|
|
haddr_t ioffset;
|
|
|
|
uint64_t supported = 0;
|
2015-04-14 04:47:03 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
/* NORMAL FILE */
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s", CONTIGUOUS);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2020-04-02 17:12:19 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(&buffer, "SIZE %" PRIuHSIZE, storage_size);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2020-04-02 17:12:19 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
/* Only dump the offset if the VOL connector implements
|
|
|
|
* the functionality.
|
|
|
|
*/
|
|
|
|
H5VLquery_optional(dset_id, H5VL_SUBCLS_DATASET, H5VL_NATIVE_DATASET_GET_OFFSET, &supported);
|
2020-04-02 17:12:19 +08:00
|
|
|
|
2020-12-01 05:59:22 +08:00
|
|
|
if (supported & H5VL_OPT_QUERY_SUPPORTED) {
|
2020-09-30 22:27:10 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2020-09-30 22:27:10 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
ioffset = H5Dget_offset(dset_id);
|
|
|
|
if (HADDR_UNDEF == ioffset)
|
|
|
|
h5tools_str_append(&buffer, "OFFSET HADDR_UNDEF");
|
|
|
|
else
|
|
|
|
h5tools_str_append(&buffer, "OFFSET %" PRIuHADDR, ioffset);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-02-26 23:59:15 +08:00
|
|
|
}
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level--;
|
|
|
|
} break;
|
2015-09-01 04:14:57 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5D_VIRTUAL: {
|
2021-12-07 22:27:29 +08:00
|
|
|
char dsetname[256]; /* virtual dataset name */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t n_vmaps;
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
H5Pget_virtual_count(dcpl_id, &n_vmaps);
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (n_vmaps) {
|
|
|
|
size_t curr_vmap;
|
|
|
|
ssize_t H5_ATTR_NDEBUG_UNUSED ssize_out;
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level++;
|
|
|
|
for (curr_vmap = 0; curr_vmap < n_vmaps; curr_vmap++) {
|
|
|
|
hid_t virtual_vspace = H5Pget_virtual_vspace(dcpl_id, curr_vmap);
|
|
|
|
hid_t virtual_srcspace = H5Pget_virtual_srcspace(dcpl_id, curr_vmap);
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2022-08-03 20:46:33 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %zu %s ", VDS_MAPPING, curr_vmap, BEGIN);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level++;
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-03-11 04:53:57 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s %s", VDS_VIRTUAL, BEGIN);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-03-13 05:22:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level++;
|
2015-03-13 05:22:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_print_virtual_selection(virtual_vspace, stream, info, ctx, &buffer, &curr_pos,
|
|
|
|
(size_t)ncols);
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level--;
|
2015-03-13 05:22:48 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-03-13 06:29:59 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s", END);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-03-13 05:22:48 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-03-13 05:22:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s %s", VDS_SOURCE, BEGIN);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-03-13 05:22:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level++;
|
2015-03-13 05:22:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
ssize_out = H5Pget_virtual_filename(dcpl_id, curr_vmap, NULL, 0);
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(ssize_out > 0);
|
|
|
|
assert((size_t)ssize_out < sizeof(name));
|
2020-09-30 22:27:10 +08:00
|
|
|
H5Pget_virtual_filename(dcpl_id, curr_vmap, name, sizeof(name));
|
|
|
|
ssize_out = H5Pget_virtual_dsetname(dcpl_id, curr_vmap, NULL, 0);
|
2023-06-28 22:31:56 +08:00
|
|
|
assert(ssize_out > 0);
|
|
|
|
assert((size_t)ssize_out < sizeof(name));
|
2020-09-30 22:27:10 +08:00
|
|
|
H5Pget_virtual_dsetname(dcpl_id, curr_vmap, dsetname, sizeof(dsetname));
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-02-24 03:19:19 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s %s", VDS_SRC_FILE,
|
|
|
|
h5tools_dump_header_format->virtualfilenamebegin);
|
|
|
|
h5tools_str_append(&buffer, "%s", name);
|
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->virtualfilenameend);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-02-24 03:19:19 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s %s", VDS_SRC_DATASET,
|
|
|
|
h5tools_dump_header_format->virtualdatasetnamebegin);
|
|
|
|
h5tools_str_append(&buffer, "%s", dsetname);
|
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->virtualdatasetnameend);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_print_virtual_selection(virtual_srcspace, stream, info, ctx, &buffer, &curr_pos,
|
|
|
|
(size_t)ncols);
|
2015-03-13 05:22:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level--;
|
2015-03-13 05:22:48 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s", END);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level--;
|
2015-02-24 01:07:40 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-02-26 23:59:15 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s", END);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2015-02-26 23:59:15 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->indent_level--;
|
2015-02-24 02:41:02 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
} break;
|
2015-09-01 04:14:57 +08:00
|
|
|
|
2015-09-01 03:04:23 +08:00
|
|
|
case H5D_LAYOUT_ERROR:
|
|
|
|
case H5D_NLAYOUTS:
|
2015-02-26 23:59:15 +08:00
|
|
|
default:
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2015-02-26 23:59:15 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", "Unknown layout");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
|
|
|
} /*switch*/
|
2015-02-24 02:41:02 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-02-24 01:07:40 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(&buffer);
|
2015-02-26 23:59:15 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", END);
|
2015-02-24 01:07:40 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2020-09-30 22:27:10 +08:00
|
|
|
* FILTERS
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2016-03-03 21:56:44 +08:00
|
|
|
if (H5D_VIRTUAL != stl) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s %s", FILTERS, BEGIN);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
ctx->indent_level++;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (nfilters) {
|
|
|
|
for (i = 0; i < nfilters; i++) {
|
2016-03-03 21:56:44 +08:00
|
|
|
cd_nelmts = NELMTS(cd_values);
|
2020-09-30 22:27:10 +08:00
|
|
|
filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, cd_values,
|
2022-07-27 05:45:46 +08:00
|
|
|
sizeof(f_name), f_name, NULL);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (filtn < 0)
|
2016-03-03 21:56:44 +08:00
|
|
|
continue; /* nothing to print for invalid filter */
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
switch (filtn) {
|
2016-03-03 21:56:44 +08:00
|
|
|
case H5Z_FILTER_DEFLATE:
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s %s %d %s", DEFLATE, BEGIN, DEFLATE_LEVEL,
|
|
|
|
cd_values[0], END);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2016-03-03 21:56:44 +08:00
|
|
|
break;
|
|
|
|
case H5Z_FILTER_SHUFFLE:
|
|
|
|
h5tools_str_append(&buffer, "%s", SHUFFLE);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2016-03-03 21:56:44 +08:00
|
|
|
break;
|
|
|
|
case H5Z_FILTER_FLETCHER32:
|
|
|
|
h5tools_str_append(&buffer, "%s", FLETCHER32);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2016-03-03 21:56:44 +08:00
|
|
|
break;
|
|
|
|
case H5Z_FILTER_SZIP:
|
2023-06-16 12:49:02 +08:00
|
|
|
szip_options_mask = cd_values[0];
|
2016-03-03 21:56:44 +08:00
|
|
|
szip_pixels_per_block = cd_values[1];
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s", SZIP, BEGIN);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
ctx->indent_level++;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "PIXELS_PER_BLOCK %d", szip_pixels_per_block);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (szip_options_mask & H5_SZIP_CHIP_OPTION_MASK)
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_append(&buffer, "MODE %s", "HARDWARE");
|
2020-09-30 22:27:10 +08:00
|
|
|
else if (szip_options_mask & H5_SZIP_ALLOW_K13_OPTION_MASK)
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_append(&buffer, "MODE %s", "K13");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-02-26 23:59:15 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (szip_options_mask & H5_SZIP_EC_OPTION_MASK)
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_append(&buffer, "CODING %s", "ENTROPY");
|
2020-09-30 22:27:10 +08:00
|
|
|
else if (szip_options_mask & H5_SZIP_NN_OPTION_MASK)
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_append(&buffer, "CODING %s", "NEAREST NEIGHBOUR");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2015-02-26 23:59:15 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (szip_options_mask & H5_SZIP_LSB_OPTION_MASK)
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_append(&buffer, "BYTE_ORDER %s", "LSB");
|
2020-09-30 22:27:10 +08:00
|
|
|
else if (szip_options_mask & H5_SZIP_MSB_OPTION_MASK)
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_append(&buffer, "BYTE_ORDER %s", "MSB");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2015-02-26 23:59:15 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (szip_options_mask & H5_SZIP_RAW_OPTION_MASK) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-02-26 23:59:15 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "HEADER %s", "RAW");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2016-03-03 21:56:44 +08:00
|
|
|
}
|
2015-02-26 23:59:15 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
ctx->indent_level--;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s", END);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2016-03-03 21:56:44 +08:00
|
|
|
break;
|
|
|
|
case H5Z_FILTER_NBIT:
|
|
|
|
h5tools_str_append(&buffer, "%s", NBIT);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2016-03-03 21:56:44 +08:00
|
|
|
break;
|
|
|
|
case H5Z_FILTER_SCALEOFFSET:
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s %s %d %s", SCALEOFFSET, BEGIN, SCALEOFFSET_MINBIT,
|
|
|
|
cd_values[0], END);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2016-03-03 21:56:44 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
h5tools_str_append(&buffer, "%s %s", "USER_DEFINED_FILTER", BEGIN);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
ctx->indent_level++;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_append(&buffer, "FILTER_ID %d", filtn);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2016-03-03 21:56:44 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (f_name[0] != '\0') {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2016-03-03 21:56:44 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "COMMENT %s", f_name);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2016-03-03 21:56:44 +08:00
|
|
|
}
|
|
|
|
if (cd_nelmts) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2016-03-03 21:56:44 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s ", "PARAMS", BEGIN);
|
|
|
|
for (j = 0; j < cd_nelmts; j++)
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_append(&buffer, "%d ", cd_values[j]);
|
|
|
|
h5tools_str_append(&buffer, "%s", END);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2016-03-03 21:56:44 +08:00
|
|
|
}
|
|
|
|
ctx->indent_level--;
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", END);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2016-03-03 21:56:44 +08:00
|
|
|
break;
|
2020-09-30 22:27:10 +08:00
|
|
|
} /*switch*/
|
|
|
|
} /*i*/
|
|
|
|
} /*nfilters*/
|
2016-03-03 21:56:44 +08:00
|
|
|
else {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "NONE");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2016-03-03 21:56:44 +08:00
|
|
|
}
|
|
|
|
ctx->indent_level--;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", END);
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2016-03-03 21:56:44 +08:00
|
|
|
} /* end if (H5D_VIRTUAL != stl) */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2020-09-30 22:27:10 +08:00
|
|
|
* FILLVALUE
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s %s", FILLVALUE, BEGIN);
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
ctx->indent_level++;
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "FILL_TIME ");
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2023-08-02 12:14:32 +08:00
|
|
|
if (dcpl_id >= 0)
|
|
|
|
H5Pget_fill_time(dcpl_id, &ft);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
switch (ft) {
|
2012-02-18 05:41:58 +08:00
|
|
|
case H5D_FILL_TIME_ALLOC:
|
|
|
|
h5tools_str_append(&buffer, "%s", "H5D_FILL_TIME_ALLOC");
|
|
|
|
break;
|
|
|
|
case H5D_FILL_TIME_NEVER:
|
|
|
|
h5tools_str_append(&buffer, "%s", "H5D_FILL_TIME_NEVER");
|
|
|
|
break;
|
|
|
|
case H5D_FILL_TIME_IFSET:
|
|
|
|
h5tools_str_append(&buffer, "%s", "H5D_FILL_TIME_IFSET");
|
|
|
|
break;
|
2015-09-01 03:04:23 +08:00
|
|
|
case H5D_FILL_TIME_ERROR:
|
2012-02-18 05:41:58 +08:00
|
|
|
default:
|
2023-08-02 12:14:32 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", "INVALID");
|
2012-02-18 05:41:58 +08:00
|
|
|
break;
|
|
|
|
}
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s ", "VALUE ");
|
2023-08-02 12:14:32 +08:00
|
|
|
|
|
|
|
if (dcpl_id >= 0)
|
|
|
|
H5Pfill_value_defined(dcpl_id, &fvstatus);
|
|
|
|
|
2016-03-03 23:27:48 +08:00
|
|
|
switch (fvstatus) {
|
|
|
|
case H5D_FILL_VALUE_UNDEFINED:
|
|
|
|
h5tools_str_append(&buffer, "%s", "H5D_FILL_VALUE_UNDEFINED");
|
|
|
|
break;
|
|
|
|
case H5D_FILL_VALUE_DEFAULT:
|
|
|
|
h5tools_str_append(&buffer, "%s", "H5D_FILL_VALUE_DEFAULT");
|
|
|
|
break;
|
|
|
|
case H5D_FILL_VALUE_USER_DEFINED:
|
|
|
|
ctx->indent_level--;
|
2020-04-02 17:12:19 +08:00
|
|
|
h5tools_print_fill_value(&buffer, info, ctx, dcpl_id, type_id, dset_id);
|
2016-03-03 23:27:48 +08:00
|
|
|
ctx->indent_level++;
|
|
|
|
break;
|
|
|
|
case H5D_FILL_VALUE_ERROR:
|
|
|
|
default:
|
2023-08-02 12:14:32 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", "INVALID");
|
2016-03-03 23:27:48 +08:00
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
ctx->indent_level--;
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s", END);
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2020-09-30 22:27:10 +08:00
|
|
|
* ALLOCATION_TIME
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2016-03-03 21:56:44 +08:00
|
|
|
if (H5D_VIRTUAL != stl) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "ALLOCATION_TIME %s", BEGIN);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
ctx->indent_level++;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2023-08-02 12:14:32 +08:00
|
|
|
|
|
|
|
if (dcpl_id >= 0)
|
|
|
|
H5Pget_alloc_time(dcpl_id, &at);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
switch (at) {
|
2016-03-03 21:56:44 +08:00
|
|
|
case H5D_ALLOC_TIME_EARLY:
|
|
|
|
h5tools_str_append(&buffer, "%s", "H5D_ALLOC_TIME_EARLY");
|
|
|
|
break;
|
|
|
|
case H5D_ALLOC_TIME_INCR:
|
|
|
|
h5tools_str_append(&buffer, "%s", "H5D_ALLOC_TIME_INCR");
|
|
|
|
break;
|
|
|
|
case H5D_ALLOC_TIME_LATE:
|
|
|
|
h5tools_str_append(&buffer, "%s", "H5D_ALLOC_TIME_LATE");
|
|
|
|
break;
|
|
|
|
case H5D_ALLOC_TIME_ERROR:
|
|
|
|
case H5D_ALLOC_TIME_DEFAULT:
|
|
|
|
default:
|
2023-08-02 12:14:32 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", "INVALID");
|
2016-03-03 21:56:44 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
ctx->indent_level--;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2016-03-03 21:56:44 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "%s", END);
|
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
|
|
|
} /* end if (H5D_VIRTUAL != stl) */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
h5tools_str_close(&buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_comment
|
|
|
|
*
|
2023-05-02 00:06:39 +08:00
|
|
|
* Purpose: prints the comment for the object name
|
2012-02-18 05:41:58 +08:00
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
char *comment = NULL;
|
2012-02-18 05:41:58 +08:00
|
|
|
ssize_t cmt_bufsize = -1;
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t buf_size = 0;
|
|
|
|
size_t ncols = 80; /* available output width */
|
|
|
|
h5tools_str_t buffer; /* string into which to render */
|
|
|
|
hsize_t curr_pos = ctx->sm_pos; /* total data element position */
|
|
|
|
/* 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
|
|
|
|
*/
|
2020-12-01 05:59:22 +08:00
|
|
|
uint64_t supported = 0;
|
2020-04-02 17:12:19 +08:00
|
|
|
|
|
|
|
/* Check if comments are supported and return if not */
|
2020-04-09 07:44:19 +08:00
|
|
|
H5VLquery_optional(obj_id, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_GET_COMMENT, &supported);
|
|
|
|
|
2020-12-01 05:59:22 +08:00
|
|
|
if (!(supported & H5VL_OPT_QUERY_SUPPORTED))
|
2020-04-02 17:12:19 +08:00
|
|
|
return;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* setup */
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&buffer, 0, sizeof(h5tools_str_t));
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
if (info->line_ncols > 0)
|
|
|
|
ncols = info->line_ncols;
|
|
|
|
|
|
|
|
cmt_bufsize = H5Oget_comment(obj_id, comment, buf_size);
|
|
|
|
|
2020-04-02 17:12:19 +08:00
|
|
|
/* call H5Oget_comment again with the correct value */
|
2012-02-18 05:41:58 +08:00
|
|
|
if (cmt_bufsize > 0) {
|
2023-06-29 06:48:12 +08:00
|
|
|
comment = (char *)malloc((size_t)(cmt_bufsize + 1)); /* new_size including null terminator */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (comment) {
|
2016-06-29 05:53:48 +08:00
|
|
|
cmt_bufsize = H5Oget_comment(obj_id, comment, (size_t)cmt_bufsize);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (cmt_bufsize > 0) {
|
2012-02-18 05:41:58 +08:00
|
|
|
comment[cmt_bufsize] = '\0'; /* necessary because null char is not returned */
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "COMMENT \"%s\"", comment);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
h5tools_str_close(&buffer);
|
2020-04-02 17:12:19 +08:00
|
|
|
}
|
2023-06-29 06:48:12 +08:00
|
|
|
free(comment);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* end dump_comment() */
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_attribute
|
|
|
|
*
|
2015-06-13 05:29:20 +08:00
|
|
|
* Purpose: Dump the attribute.
|
2012-02-18 05:41:58 +08:00
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* In/Out: h5tools_context_t *ctx
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
|
|
|
|
const char *attr_name, hid_t attr_id)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_t buffer; /* string into which to render */
|
|
|
|
size_t ncols = 80; /* available output width */
|
|
|
|
hsize_t curr_pos = ctx->sm_pos; /* total data element position */
|
|
|
|
/* 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
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* setup */
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&buffer, 0, sizeof(h5tools_str_t));
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
if (info->line_ncols > 0)
|
|
|
|
ncols = info->line_ncols;
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->attributebegin, attr_name,
|
|
|
|
h5tools_dump_header_format->attributeblockbegin);
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (attr_id < 0) {
|
2012-02-18 05:41:58 +08:00
|
|
|
error_msg("unable to open attribute \"%s\"\n", attr_name);
|
2015-06-13 05:29:20 +08:00
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
else {
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t type = H5I_INVALID_HID;
|
2020-01-14 07:09:48 +08:00
|
|
|
hid_t space = H5I_INVALID_HID;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
ctx->indent_level++;
|
|
|
|
|
|
|
|
type = H5Aget_type(attr_id);
|
|
|
|
h5tools_dump_datatype(stream, info, ctx, type);
|
|
|
|
|
|
|
|
space = H5Aget_space(attr_id);
|
|
|
|
h5tools_dump_dataspace(stream, info, ctx, space);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (oid_output)
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_dump_oid(stream, info, ctx, attr_id);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (data_output || attr_data_output)
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_dump_data(stream, info, ctx, attr_id, false);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
ctx->indent_level--;
|
|
|
|
|
|
|
|
H5Tclose(type);
|
|
|
|
H5Sclose(space);
|
|
|
|
H5Aclose(attr_id);
|
|
|
|
}
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->attributeblockend)) {
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->attributeblockend);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->attributeend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, " ");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->attributeend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->attributeend);
|
|
|
|
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
h5tools_str_close(&buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_dims
|
|
|
|
*
|
|
|
|
* Purpose: Dump the dimensions handed to it in a comma separated list
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
h5tools_print_dims(h5tools_str_t *buffer, hsize_t *s, int dims)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < dims; i++) {
|
2022-02-22 05:31:57 +08:00
|
|
|
h5tools_str_append(buffer, "%" PRIuHSIZE, s[i]);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2012-11-02 00:01:37 +08:00
|
|
|
if (i + 1 != dims)
|
|
|
|
h5tools_str_append(buffer, ", ");
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: print_packed_bits
|
|
|
|
*
|
|
|
|
* Purpose: Prints the packed bits offset and length
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
h5tools_print_packed_bits(h5tools_str_t *buffer, hid_t type)
|
|
|
|
{
|
2016-06-29 05:53:48 +08:00
|
|
|
unsigned packed_bits_size = 0;
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t n_type = H5Tget_native_type(type, H5T_DIR_DEFAULT);
|
2016-06-29 05:53:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Tget_class(n_type) == H5T_INTEGER) {
|
2023-09-06 02:50:06 +08:00
|
|
|
if (H5Tequal(n_type, H5T_NATIVE_SCHAR) == true)
|
2012-02-18 05:41:58 +08:00
|
|
|
packed_bits_size = 8 * sizeof(char);
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(n_type, H5T_NATIVE_UCHAR) == true)
|
2012-02-18 05:41:58 +08:00
|
|
|
packed_bits_size = 8 * sizeof(unsigned char);
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(n_type, H5T_NATIVE_SHORT) == true)
|
2012-02-18 05:41:58 +08:00
|
|
|
packed_bits_size = 8 * sizeof(short);
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(n_type, H5T_NATIVE_USHORT) == true)
|
2012-02-18 05:41:58 +08:00
|
|
|
packed_bits_size = 8 * sizeof(unsigned short);
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(n_type, H5T_NATIVE_INT) == true)
|
2012-02-18 05:41:58 +08:00
|
|
|
packed_bits_size = 8 * sizeof(int);
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(n_type, H5T_NATIVE_UINT) == true)
|
2012-02-18 05:41:58 +08:00
|
|
|
packed_bits_size = 8 * sizeof(unsigned int);
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(n_type, H5T_NATIVE_LONG) == true)
|
2012-02-18 05:41:58 +08:00
|
|
|
packed_bits_size = 8 * sizeof(long);
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(n_type, H5T_NATIVE_ULONG) == true)
|
2012-02-18 05:41:58 +08:00
|
|
|
packed_bits_size = 8 * sizeof(unsigned long);
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(n_type, H5T_NATIVE_LLONG) == true)
|
2012-02-18 05:41:58 +08:00
|
|
|
packed_bits_size = 8 * sizeof(long long);
|
2023-09-06 02:50:06 +08:00
|
|
|
else if (H5Tequal(n_type, H5T_NATIVE_ULLONG) == true)
|
2012-02-18 05:41:58 +08:00
|
|
|
packed_bits_size = 8 * sizeof(unsigned long long);
|
|
|
|
else
|
|
|
|
error_msg("Packed Bit not valid for this datatype");
|
|
|
|
}
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((packed_bits_size > 0) && (packed_data_offset + packed_data_length) > packed_bits_size) {
|
|
|
|
error_msg("Packed Bit offset+length value(%u) too large. Max is %d\n",
|
|
|
|
packed_data_offset + packed_data_length, packed_bits_size);
|
2012-02-18 05:41:58 +08:00
|
|
|
packed_data_mask = 0;
|
2023-06-16 12:49:02 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(buffer, "%s %s=%u %s=%u", PACKED_BITS, PACKED_OFFSET, packed_data_offset,
|
|
|
|
PACKED_LENGTH, packed_data_length);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_subsetting_header
|
|
|
|
*
|
|
|
|
* Purpose: Dump the subsetting header like specified in the DDL.
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, int dims)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_t buffer; /* string into which to render */
|
|
|
|
hsize_t curr_pos = 0; /* total data element position */
|
|
|
|
size_t ncols = 80; /* available output width */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
/* setup */
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&buffer, 0, sizeof(h5tools_str_t));
|
2012-02-18 05:41:58 +08:00
|
|
|
if (info->line_ncols > 0)
|
|
|
|
ncols = info->line_ncols;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->subsettingbegin,
|
|
|
|
h5tools_dump_header_format->subsettingblockbegin);
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
ctx->indent_level++;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->startbegin,
|
|
|
|
h5tools_dump_header_format->startblockbegin);
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_print_dims(&buffer, ctx->sset->start.data, dims);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->startend,
|
|
|
|
h5tools_dump_header_format->startblockend);
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->stridebegin,
|
|
|
|
h5tools_dump_header_format->strideblockbegin);
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_print_dims(&buffer, ctx->sset->stride.data, dims);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->strideend,
|
|
|
|
h5tools_dump_header_format->strideblockend);
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->countbegin,
|
|
|
|
h5tools_dump_header_format->countblockbegin);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (ctx->sset->count.data)
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_print_dims(&buffer, ctx->sset->count.data, dims);
|
2012-02-18 05:41:58 +08:00
|
|
|
else
|
|
|
|
h5tools_str_append(&buffer, "DEFAULT");
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->countend,
|
|
|
|
h5tools_dump_header_format->countblockend);
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->blockbegin,
|
|
|
|
h5tools_dump_header_format->blockblockbegin);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (ctx->sset->block.data)
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_print_dims(&buffer, ctx->sset->block.data, dims);
|
2012-02-18 05:41:58 +08:00
|
|
|
else
|
|
|
|
h5tools_str_append(&buffer, "DEFAULT");
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->blockend,
|
|
|
|
h5tools_dump_header_format->blockblockend);
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
ctx->indent_level--;
|
|
|
|
|
|
|
|
h5tools_str_close(&buffer);
|
|
|
|
}
|
|
|
|
|
2020-07-16 00:20:16 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_reference
|
|
|
|
*
|
|
|
|
* Purpose: Dump reference data
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t container,
|
|
|
|
H5R_ref_t *ref_buf, int ndims)
|
2020-07-16 00:20:16 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t new_obj_id = H5I_INVALID_HID;
|
|
|
|
hid_t new_obj_sid = H5I_INVALID_HID;
|
|
|
|
hsize_t elmt_counter = 0; /*counts the # elements printed. */
|
|
|
|
size_t ncols = 80; /* available output width */
|
|
|
|
int i;
|
|
|
|
hsize_t curr_pos = 0; /* total data element position */
|
|
|
|
h5tools_str_t buffer; /* string into which to render */
|
|
|
|
h5tools_context_t datactx; /* print context */
|
2020-07-16 00:20:16 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2020-07-16 00:20:16 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
datactx = *ctx; /* print context */
|
2020-07-16 00:20:16 +08:00
|
|
|
/* Assume entire data space to be printed */
|
2023-09-06 02:50:06 +08:00
|
|
|
datactx.need_prefix = true;
|
2020-07-16 00:20:16 +08:00
|
|
|
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&buffer, 0, sizeof(h5tools_str_t));
|
2020-09-30 22:27:10 +08:00
|
|
|
for (i = 0; i < ndims; i++, datactx.cur_elmt++, elmt_counter++) {
|
|
|
|
H5O_type_t obj_type = -1; /* Object type */
|
|
|
|
H5R_type_t ref_type; /* Reference type */
|
2020-07-16 00:20:16 +08:00
|
|
|
|
|
|
|
H5TOOLS_DEBUG("reference loop:%d with curr_pos=%ld", i, curr_pos);
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
datactx.need_prefix = true;
|
2020-07-16 00:20:16 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
H5TOOLS_DEBUG("reference loop - h5tools_str_sprint with H5T_STD_REF:%d", i);
|
|
|
|
h5tools_str_sprint(&buffer, info, container, H5T_STD_REF, &ref_buf[i], &datactx);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)i,
|
|
|
|
(hsize_t)ndims);
|
2020-07-16 00:20:16 +08:00
|
|
|
|
|
|
|
ref_type = H5Rget_type((const H5R_ref_t *)&ref_buf[i]);
|
|
|
|
switch (ref_type) {
|
|
|
|
case H5R_OBJECT1:
|
|
|
|
H5TOOLS_DEBUG("ref_type is H5R_OBJECT1");
|
|
|
|
if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
|
|
|
|
switch (obj_type) {
|
|
|
|
case H5O_TYPE_DATASET:
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
|
2020-07-16 00:20:16 +08:00
|
|
|
datactx.indent_level++;
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_dump_data(stream, info, &datactx, new_obj_id, true);
|
2020-09-30 22:27:10 +08:00
|
|
|
// h5tools_dump_dset(stream, info, &datactx, new_obj_id);
|
2020-07-16 00:20:16 +08:00
|
|
|
datactx.indent_level--;
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Dclose(new_obj_id) < 0)
|
2020-07-16 00:20:16 +08:00
|
|
|
H5TOOLS_INFO("H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
H5TOOLS_INFO("H5Ropen_object H5R_OBJECT1:H5O_TYPE_DATASET failed");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5O_TYPE_GROUP:
|
|
|
|
case H5O_TYPE_NAMED_DATATYPE:
|
|
|
|
case H5O_TYPE_MAP:
|
|
|
|
case H5O_TYPE_UNKNOWN:
|
|
|
|
case H5O_TYPE_NTYPES:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} /* end switch */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT1 failed");
|
|
|
|
break;
|
|
|
|
case H5R_DATASET_REGION1:
|
|
|
|
H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
|
2020-07-16 00:20:16 +08:00
|
|
|
datactx.indent_level++;
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_dump_data(stream, info, &datactx, new_obj_id, true);
|
2020-09-30 22:27:10 +08:00
|
|
|
// h5tools_dump_dset(stream, info, &datactx, new_obj_id);
|
2020-07-16 00:20:16 +08:00
|
|
|
datactx.indent_level--;
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Dclose(new_obj_id) < 0)
|
2020-07-16 00:20:16 +08:00
|
|
|
H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION1 failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed");
|
|
|
|
break;
|
|
|
|
case H5R_OBJECT2:
|
|
|
|
H5TOOLS_DEBUG("ref_type is H5R_OBJECT2");
|
|
|
|
if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
|
|
|
|
switch (obj_type) {
|
|
|
|
case H5O_TYPE_GROUP:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5O_TYPE_DATASET:
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
|
2020-07-16 00:20:16 +08:00
|
|
|
datactx.indent_level++;
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_dump_data(stream, info, &datactx, new_obj_id, true);
|
2020-09-30 22:27:10 +08:00
|
|
|
// h5tools_dump_dset(stream, info, &datactx, new_obj_id);
|
2020-07-16 00:20:16 +08:00
|
|
|
datactx.indent_level--;
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Oclose(new_obj_id) < 0)
|
2020-07-16 00:20:16 +08:00
|
|
|
H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
H5TOOLS_INFO("H5Ropen_object H5R_OBJECT2 failed");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5O_TYPE_NAMED_DATATYPE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5O_TYPE_MAP:
|
|
|
|
case H5O_TYPE_UNKNOWN:
|
|
|
|
case H5O_TYPE_NTYPES:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} /* end switch */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT2 failed");
|
|
|
|
break;
|
|
|
|
case H5R_DATASET_REGION2:
|
|
|
|
H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2");
|
|
|
|
|
|
|
|
if (info->line_ncols > 0)
|
|
|
|
ncols = info->line_ncols;
|
|
|
|
|
|
|
|
/* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
2020-07-16 00:20:16 +08:00
|
|
|
H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed");
|
|
|
|
else {
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((new_obj_sid = H5Ropen_region(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
|
2020-07-16 00:20:16 +08:00
|
|
|
if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) {
|
|
|
|
H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
|
|
|
|
|
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, " {");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2020-07-16 00:20:16 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
datactx.need_prefix = true;
|
2020-07-16 00:20:16 +08:00
|
|
|
datactx.indent_level++;
|
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "NULL");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2020-07-16 00:20:16 +08:00
|
|
|
datactx.indent_level--;
|
2023-09-06 02:50:06 +08:00
|
|
|
datactx.need_prefix = true;
|
2020-07-16 00:20:16 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "}");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2020-07-16 00:20:16 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
H5S_sel_type region_type;
|
|
|
|
|
|
|
|
region_type = H5Sget_select_type(new_obj_sid);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (region_type == H5S_SEL_POINTS) {
|
2020-07-16 00:20:16 +08:00
|
|
|
/* Print point information */
|
|
|
|
H5TOOLS_DEBUG("H5S_SEL_POINTS H5R_DATASET_REGION2");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_dump_region_data_points(new_obj_sid, new_obj_id, stream, info,
|
|
|
|
&datactx, &buffer, &curr_pos, ncols,
|
|
|
|
(hsize_t)i, elmt_counter);
|
2020-07-16 00:20:16 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
else if (region_type == H5S_SEL_HYPERSLABS) {
|
2020-07-16 00:20:16 +08:00
|
|
|
/* Print block information */
|
|
|
|
H5TOOLS_DEBUG("H5S_SEL_HYPERSLABS H5R_DATASET_REGION2");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_dump_region_data_blocks(new_obj_sid, new_obj_id, stream, info,
|
|
|
|
&datactx, &buffer, &curr_pos, ncols,
|
|
|
|
(hsize_t)i, elmt_counter);
|
2020-07-16 00:20:16 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
H5TOOLS_INFO("invalid region type");
|
|
|
|
} /* end else to if (h5tools_is_zero(... */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sclose(new_obj_sid) < 0)
|
2020-07-16 00:20:16 +08:00
|
|
|
H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Dclose(new_obj_id) < 0)
|
2020-07-16 00:20:16 +08:00
|
|
|
H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case H5R_ATTR:
|
|
|
|
H5TOOLS_DEBUG("ref_type is H5R_ATTR");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((new_obj_id = H5Ropen_attr(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
|
|
|
|
h5tools_dump_region_attribute(new_obj_id, stream, info, &datactx, &buffer, &curr_pos,
|
|
|
|
(size_t)ncols, (hsize_t)0, (hsize_t)0);
|
|
|
|
if (H5Aclose(new_obj_id) < 0)
|
2020-07-16 00:20:16 +08:00
|
|
|
H5TOOLS_INFO("H5Aclose H5R_ATTR failed");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
H5TOOLS_DEBUG("NULL H5R_ATTR");
|
|
|
|
|
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, " {");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2020-07-16 00:20:16 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
datactx.need_prefix = true;
|
2020-07-16 00:20:16 +08:00
|
|
|
datactx.indent_level++;
|
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "NULL");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2020-07-16 00:20:16 +08:00
|
|
|
datactx.indent_level--;
|
2023-09-06 02:50:06 +08:00
|
|
|
datactx.need_prefix = true;
|
2020-07-16 00:20:16 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "}");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2020-07-16 00:20:16 +08:00
|
|
|
|
|
|
|
H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case H5R_BADTYPE:
|
|
|
|
case H5R_MAXTYPE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} /* end switch */
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Rdestroy(&ref_buf[i]) < 0)
|
2020-07-16 00:20:16 +08:00
|
|
|
H5TOOLS_INFO("H5Rdestroy failed");
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
H5TOOLS_DEBUG("finished reference loop:%d", i);
|
2020-07-16 00:20:16 +08:00
|
|
|
} /* end for(i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) */
|
|
|
|
|
|
|
|
h5tools_str_close(&buffer);
|
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2020-07-16 00:20:16 +08:00
|
|
|
}
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_data
|
|
|
|
*
|
2023-09-06 02:50:06 +08:00
|
|
|
* Purpose: Dump attribute, obj_data is false, or dataset data, obj_data is true
|
2012-02-18 05:41:58 +08:00
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id,
|
|
|
|
int obj_data)
|
2012-02-18 05:41:58 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
H5S_class_t space_type;
|
|
|
|
int ndims;
|
|
|
|
hid_t space = H5I_INVALID_HID;
|
|
|
|
hid_t f_type = H5I_INVALID_HID;
|
|
|
|
hsize_t total_size[H5S_MAX_RANK];
|
|
|
|
int status = -1;
|
|
|
|
h5tools_context_t datactx; /* print context */
|
|
|
|
h5tools_str_t buffer; /* string into which to render */
|
|
|
|
hsize_t curr_pos = 0; /* total data element position */
|
|
|
|
size_t ncols = 80; /* available output width */
|
|
|
|
h5tool_format_t string_dataformat;
|
|
|
|
h5tool_format_t outputformat;
|
2022-07-27 05:45:46 +08:00
|
|
|
H5R_ref_t *ref_buf = NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
|
|
|
|
H5TOOLS_START_DEBUG(" file=%p", (void *)stream);
|
|
|
|
H5TOOLS_DEBUG("rawdata file=%p", (void *)rawdatastream);
|
2012-02-18 05:41:58 +08:00
|
|
|
/* setup */
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&buffer, 0, sizeof(h5tools_str_t));
|
2012-02-18 05:41:58 +08:00
|
|
|
if (info->line_ncols > 0)
|
|
|
|
ncols = info->line_ncols;
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
outputformat = *info;
|
2012-02-18 05:41:58 +08:00
|
|
|
string_dataformat = *info;
|
|
|
|
/* print the matrix indices */
|
2019-11-07 23:48:56 +08:00
|
|
|
string_dataformat.pindex = ctx->display_index;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (obj_data) {
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("dataset");
|
2019-11-07 23:48:56 +08:00
|
|
|
f_type = H5Dget_type(obj_id);
|
2020-09-30 22:27:10 +08:00
|
|
|
space = H5Dget_space(obj_id);
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
|
|
|
else {
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("attribute");
|
2019-11-07 23:48:56 +08:00
|
|
|
f_type = H5Aget_type(obj_id);
|
2020-09-30 22:27:10 +08:00
|
|
|
space = H5Aget_space(obj_id);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (string_dataformat.pindex) {
|
|
|
|
string_dataformat.idx_fmt = "(%s): ";
|
2022-02-22 05:31:57 +08:00
|
|
|
string_dataformat.idx_n_fmt = "%" PRIuHSIZE;
|
2012-02-18 05:41:58 +08:00
|
|
|
string_dataformat.idx_sep = ",";
|
|
|
|
string_dataformat.line_pre = "%s";
|
|
|
|
}
|
|
|
|
info = &string_dataformat;
|
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
if (ctx->sset && obj_data) {
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
h5tools_dump_subsetting_header(stream, &outputformat, ctx, H5Sget_simple_extent_ndims(space));
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
ctx->indent_level++;
|
|
|
|
}
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->databegin,
|
|
|
|
h5tools_dump_header_format->datablockbegin);
|
|
|
|
h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
if (H5Tget_class(f_type) == H5T_REFERENCE) {
|
2019-12-14 02:28:18 +08:00
|
|
|
ctx->indent_level++;
|
|
|
|
datactx = *ctx;
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("reference class type");
|
2020-09-30 22:27:10 +08:00
|
|
|
if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) &&
|
|
|
|
!H5Tequal(f_type, H5T_STD_REF_OBJ)) {
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_DONE_NO_RET();
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
ndims = (int)H5Sget_simple_extent_npoints(space);
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("ndims=%d - datactx.ndims=%d", ndims, datactx.ndims);
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
/* Assume entire data space to be printed */
|
|
|
|
H5Sget_simple_extent_dims(space, total_size, NULL);
|
2020-07-16 00:20:16 +08:00
|
|
|
init_acc_pos(datactx.ndims, total_size, datactx.acc, datactx.pos, datactx.p_min_idx);
|
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
datactx.need_prefix = true;
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL !=
|
2023-06-29 06:48:12 +08:00
|
|
|
(ref_buf = (H5R_ref_t *)calloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) {
|
2020-03-01 04:01:45 +08:00
|
|
|
if (obj_data) {
|
|
|
|
if (H5Dread(obj_id, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf) < 0) {
|
2023-06-29 06:48:12 +08:00
|
|
|
free(ref_buf);
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_INFO("H5Dread reference failed");
|
|
|
|
H5TOOLS_GOTO_DONE_NO_RET();
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2020-03-01 04:01:45 +08:00
|
|
|
if (H5Aread(obj_id, H5T_STD_REF, ref_buf) < 0) {
|
2023-06-29 06:48:12 +08:00
|
|
|
free(ref_buf);
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_INFO("H5Aread reference failed");
|
|
|
|
H5TOOLS_GOTO_DONE_NO_RET();
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
|
|
|
}
|
2020-07-16 00:20:16 +08:00
|
|
|
h5tools_dump_reference(stream, &outputformat, &datactx, obj_id, ref_buf, ndims);
|
2023-06-29 06:48:12 +08:00
|
|
|
free(ref_buf);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
2019-12-14 02:28:18 +08:00
|
|
|
ctx->indent_level--;
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
else {
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("Print all the values");
|
2020-09-30 22:27:10 +08:00
|
|
|
datactx = *ctx;
|
2019-12-05 06:36:32 +08:00
|
|
|
string_dataformat = *info;
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((datactx.display_char && H5Tget_size(f_type) == 1) && (H5Tget_class(f_type) == H5T_INTEGER)) {
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("Print 1-byte integer data as an ASCII character string");
|
2012-02-18 05:41:58 +08:00
|
|
|
/*
|
2020-09-30 22:27:10 +08:00
|
|
|
* Print 1-byte integer data as an ASCII character string
|
|
|
|
* instead of integers if the `-r' or `--string' command-line
|
|
|
|
* option was given.
|
|
|
|
*
|
|
|
|
* We don't want to modify the global dataformat, so make a
|
|
|
|
* copy of it instead.
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
string_dataformat.idx_fmt = "\"";
|
|
|
|
datactx.indent_level++;
|
2023-09-06 02:50:06 +08:00
|
|
|
datactx.need_prefix = true;
|
2019-12-05 06:36:32 +08:00
|
|
|
h5tools_simple_prefix(stream, &string_dataformat, &datactx, (hsize_t)0, 0);
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
string_dataformat.line_multi_new = 1;
|
2020-09-30 22:27:10 +08:00
|
|
|
string_dataformat.str_repeat = 8;
|
2023-09-06 02:50:06 +08:00
|
|
|
string_dataformat.ascii = true;
|
2020-09-30 22:27:10 +08:00
|
|
|
string_dataformat.elmt_suf1 = "";
|
|
|
|
string_dataformat.elmt_suf2 = "";
|
|
|
|
string_dataformat.line_suf = "\"";
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
2019-12-05 06:36:32 +08:00
|
|
|
else {
|
2023-09-06 02:50:06 +08:00
|
|
|
datactx.need_prefix = true;
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
2019-11-07 23:48:56 +08:00
|
|
|
|
|
|
|
/* Print all the values. */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (obj_data) {
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("h5tools_dump_dset");
|
2019-11-07 23:48:56 +08:00
|
|
|
status = h5tools_dump_dset(stream, &string_dataformat, &datactx, obj_id);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
else {
|
2019-11-07 23:48:56 +08:00
|
|
|
/* need to call h5tools_dump_mem for the attribute data */
|
|
|
|
space_type = H5Sget_simple_extent_type(space);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (space_type == H5S_NULL || space_type == H5S_NO_CLASS) {
|
2012-02-18 05:41:58 +08:00
|
|
|
status = SUCCEED;
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
|
|
|
else {
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("call h5tools_dump_mem");
|
2019-12-05 06:36:32 +08:00
|
|
|
status = h5tools_dump_mem(stream, &string_dataformat, &datactx, obj_id);
|
2015-06-13 05:29:20 +08:00
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
2019-12-05 06:36:32 +08:00
|
|
|
if (datactx.display_char && H5Tget_size(f_type) == 1 && H5Tget_class(f_type) == H5T_INTEGER) {
|
2020-09-30 22:27:10 +08:00
|
|
|
H5TOOLS_DEBUG("Print 1-byte integer data as an ASCII character string eol=%s",
|
|
|
|
string_dataformat.line_suf);
|
2023-09-06 02:50:06 +08:00
|
|
|
datactx.need_prefix = false;
|
2020-09-30 22:27:10 +08:00
|
|
|
string_dataformat.arr_linebreak = 0;
|
|
|
|
string_dataformat.idx_fmt = "";
|
2019-12-05 06:36:32 +08:00
|
|
|
string_dataformat.line_multi_new = 0;
|
2020-09-30 22:27:10 +08:00
|
|
|
string_dataformat.line_suf = "";
|
2019-12-05 06:36:32 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
|
|
|
h5tools_str_append(&buffer, "\"");
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, &string_dataformat, &datactx, &buffer, &curr_pos, (size_t)ncols,
|
|
|
|
(hsize_t)0, (hsize_t)0);
|
2019-12-05 06:36:32 +08:00
|
|
|
}
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("Print all the values Complete");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
if (status == FAIL) {
|
|
|
|
error_msg("unable to print data\n");
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
2019-11-07 23:48:56 +08:00
|
|
|
done:
|
|
|
|
H5Sclose(space);
|
|
|
|
H5Tclose(f_type);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_simple_prefix(stream, &outputformat, ctx, (hsize_t)0, 0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(&buffer);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->datablockend)) {
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datablockend);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, " ");
|
|
|
|
}
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->dataend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->dataend);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
if (ctx->sset && obj_data) {
|
2012-02-18 05:41:58 +08:00
|
|
|
ctx->indent_level--;
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2013-09-07 06:48:28 +08:00
|
|
|
h5tools_simple_prefix(stream, &outputformat, ctx, (hsize_t)0, 0);
|
2015-06-13 05:29:20 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_reset(&buffer);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->subsettingblockend)) {
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->subsettingblockend);
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->subsettingend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, " ");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(h5tools_dump_header_format->subsettingend))
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->subsettingend);
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
|
|
|
|
(hsize_t)0);
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
h5tools_str_close(&buffer);
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2012-02-18 05:41:58 +08:00
|
|
|
}
|