summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib/h5tools.c')
-rw-r--r--tools/lib/h5tools.c217
1 files changed, 2 insertions, 215 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 58a663b..d2be237 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -485,7 +485,7 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) {
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_sprint(&buffer, info, container, type, mem + i * size, ctx);
+ h5tools_str_sprint(&buffer, info, container, type, mem + i * size, ctx);
if (i + 1 < nelmts || (flags & END_OF_DATA) == 0)
h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ","));
@@ -1012,219 +1012,6 @@ h5tools_dump_simple_mem(FILE *stream, const h5dump_t *info, hid_t obj_id,
}
/*-------------------------------------------------------------------------
- * Function: h5tools_fixtype
- *
- * Purpose: Given a file data type choose a memory data type which is
- * appropriate for printing the data.
- *
- * Return: Success: Memory data type
- *
- * Failure: FAIL
- *
- * Programmer: Robb Matzke
- * Thursday, July 23, 1998
- *
- * Modifications:
- * Robb Matzke, 1999-06-04
- * Added support for references.
- *
- *-------------------------------------------------------------------------
- */
-hid_t
-h5tools_fixtype(hid_t f_type)
-{
- hid_t m_type = FAIL, f_memb;
- hid_t *memb = NULL;
- char **name = NULL;
- int nmembs = 0, i;
- int ndims;
- hsize_t dim[H5S_MAX_RANK];
- size_t size, offset;
- hid_t array_base;
- /* H5T_str_t strpad; */
-
- size = H5Tget_size(f_type);
-
- switch (H5Tget_class(f_type)) {
- case H5T_INTEGER:
- /*
- * Use the smallest native integer type of the same sign as the file
- * such that the memory type is at least as large as the file type.
- * If there is no memory type large enough then use the largest
- * memory type available.
- */
- if (size <= sizeof(char)) {
- m_type = H5Tcopy(H5T_NATIVE_SCHAR);
- } else if (size <= sizeof(short)) {
- m_type = H5Tcopy(H5T_NATIVE_SHORT);
- } else if (size <= sizeof(int)) {
- m_type = H5Tcopy(H5T_NATIVE_INT);
- } else if (size <= sizeof(long)) {
- m_type = H5Tcopy(H5T_NATIVE_LONG);
- } else {
- m_type = H5Tcopy(H5T_NATIVE_LLONG);
- }
-
- H5Tset_sign(m_type, H5Tget_sign(f_type));
- break;
-
- case H5T_FLOAT:
- /*
- * Use the smallest native floating point type available such that
- * its size is at least as large as the file type. If there is not
- * native type large enough then use the largest native type.
- */
- if (size <= sizeof(float)) {
- m_type = H5Tcopy(H5T_NATIVE_FLOAT);
- } else if (size <= sizeof(double)) {
- m_type = H5Tcopy(H5T_NATIVE_DOUBLE);
- } else {
- m_type = H5Tcopy(H5T_NATIVE_LDOUBLE);
- }
-
- break;
-
- case H5T_STRING:
- /*
- * This is needed because the function in dumputil.c is the case where
- * strDUAction == TRUE. if it is false we will do the original action
- * here.
- */
- if(H5Tis_variable_str(f_type)) {
- m_type = H5Tcopy(H5T_C_S1);
- H5Tset_size(m_type, H5T_VARIABLE);
- } else {
- m_type = H5Tcopy(f_type);
- H5Tset_cset(m_type, H5T_CSET_ASCII);
- }
- break;
-
- case H5T_COMPOUND:
- /*
- * We have to do this in two steps. The first step scans the file
- * type and converts the members to native types and remembers all
- * their names and sizes, computing the size of the memory compound
- * type at the same time. Then we create the memory compound type
- * and add the members.
- */
- nmembs = H5Tget_nmembers(f_type);
- assert(nmembs > 0);
- memb = calloc((size_t)nmembs, sizeof(hid_t));
- name = calloc((size_t)nmembs, sizeof(char *));
-
- for (i = 0, size = 0; i < nmembs; i++) {
- /* Get the member type and fix it */
- f_memb = H5Tget_member_type(f_type, i);
- memb[i] = h5tools_fixtype(f_memb);
- H5Tclose(f_memb);
-
- if (memb[i] < 0)
- goto done;
-
- /* Get the member name */
- name[i] = H5Tget_member_name(f_type, i);
-
- if (name[i] == NULL)
- goto done;
-
- /*
- * Compute the new offset so each member is aligned on a byte
- * boundary which is the same as the member size.
- */
- size = ALIGN(size, H5Tget_size(memb[i])) + H5Tget_size(memb[i]);
- }
-
- m_type = H5Tcreate(H5T_COMPOUND, size);
-
- for (i = 0, offset = 0; i < nmembs; i++) {
- if (offset)
- offset = ALIGN(offset, H5Tget_size(memb[i]));
-
- H5Tinsert(m_type, name[i], offset, memb[i]);
- offset += H5Tget_size(memb[i]);
- }
-
- break;
-
- case H5T_ARRAY:
- /* Get the array information */
- ndims = H5Tget_array_ndims(f_type);
- H5Tget_array_dims(f_type, dim, NULL);
-
- /* Get the array's base type and convert it to the printable version */
- f_memb = H5Tget_super(f_type);
- array_base = h5tools_fixtype(f_memb);
-
- /* Copy the array */
- m_type = H5Tarray_create(array_base, ndims, dim, NULL);
-
- /* Close the temporary datatypes */
- H5Tclose(array_base);
- H5Tclose(f_memb);
- break;
-
- case H5T_VLEN:
- /* Get the VL sequence's base type and convert it to the printable version */
- f_memb = H5Tget_super(f_type);
- array_base = h5tools_fixtype(f_memb);
-
- /* Copy the VL type */
- m_type = H5Tvlen_create(array_base);
-
- /* Close the temporary datatypes */
- H5Tclose(array_base);
- H5Tclose(f_memb);
- break;
-
- case H5T_ENUM:
- case H5T_REFERENCE:
- case H5T_OPAQUE:
- /* Same as file type */
- m_type = H5Tcopy(f_type);
- break;
-
- case H5T_BITFIELD:
- /*
- * Same as the file except the offset is set to zero and the byte
- * order is set to little endian.
- */
- m_type = H5Tcopy(f_type);
- H5Tset_offset(m_type, 0);
- H5Tset_order(m_type, H5T_ORDER_LE);
- break;
-
- case H5T_TIME:
- /*
- * These type classes are not implemented yet.
- */
- break;
-
- default:
- /* What the heck? */
- break;
- }
-
- done:
- /* Clean up temp buffers */
- if (memb && name) {
- register int j;
-
- for (j = 0; j < nmembs; j++) {
- if (memb[j] >= 0)
- H5Tclose(memb[j]);
-
- if (name[j])
- free(name[j]);
- }
-
- free(memb);
- free(name);
- }
-
- return m_type;
-}
-
-/*-------------------------------------------------------------------------
* Function: h5tools_dump_dset
*
* Purpose: Print some values from a dataset DSET to the file STREAM
@@ -1281,7 +1068,7 @@ h5tools_dump_dset(FILE *stream, const h5dump_t *info, hid_t dset, hid_t _p_type,
if (info->raw)
p_type = H5Tcopy(f_type);
else
- p_type = h5tools_fixtype(f_type);
+ p_type = H5Tget_native_type(f_type,H5T_DIR_DEFAULT);
H5Tclose(f_type);