Commit bdcc8f20 authored by gsell's avatar gsell

this commits includes several changes which should have been done in

multiple steps:
- the functions for inquiring datasets and attributes do not return
  an HDF5 type any more but an enum of type h5_types_t. This change
  was required for the Python module.
- bugfix in reading attributes: See https://git.psi.ch/H5hut/src/issues/4
- several consts and macros have been moved from the public C-API to
  the core API
- more consitent file naming
- several 'private' function have been moved to their 'private' header
  files as 'static inline'.
- minor formatting changes
parent bbbaa6a2
Pipeline #7 skipped
......@@ -13,7 +13,7 @@ include_HEADERS = \
$(top_srcdir)/src/include/H5Part_model.h \
$(top_srcdir)/src/include/H5_attachments.h \
$(top_srcdir)/src/include/H5_debug.h \
$(top_srcdir)/src/include/H5_error.h \
$(top_srcdir)/src/include/H5_err.h \
$(top_srcdir)/src/include/H5_file.h \
$(top_srcdir)/src/include/H5_file_attribs.h \
$(top_srcdir)/src/include/H5_log.h \
......
......@@ -9,7 +9,6 @@
#include "h5_private.h"
#include "h5core/h5_init.h"
#include "h5core/h5_debug.h"
#include "h5core/h5_file.h"
......
......@@ -11,10 +11,10 @@
#include "h5core/h5_debug.h"
#include "h5core/h5b_attribs.h"
#define H5_R8_T H5_FLOAT64_T
#define H5_R4_T H5_FLOAT32_T
#define H5_I8_T H5_INT64_T
#define H5_I4_T H5_INT32_T
#define H5_R8_T H5_FLOAT64
#define H5_R4_T H5_FLOAT32
#define H5_I8_T H5_INT64
#define H5_I4_T H5_INT32
/*
__ _ _ _ ___ _ __ _ _
......@@ -163,7 +163,7 @@ h5bl_writefieldattrib_string (
f,
field_name, l_field_name,
attrib_name, l_attrib_name,
H5_STRING_T,
H5_STRING,
attrib_value2, strlen(attrib_value2)+1 );
free (attrib_value2);
H5_API_RETURN (h5err);
......@@ -193,7 +193,7 @@ h5bl_readfieldattrib_string (
f,
field_name, l_field_name,
attrib_name, l_attrib_name,
H5_STRING_T, attrib_value);
H5_STRING, attrib_value);
h5_strc2for (attrib_value, l_attrib_value);
H5_API_RETURN (h5err);
......
......@@ -189,7 +189,7 @@ h5pt_getdatasetname (
H5_API_ENTER (h5_int64_t,
"fh=%p, index=%lld, name='%s', l_name=%d",
(h5_file_p)f, (long long)*index, name, l_name);
h5_int64_t herr = h5u_get_dataset_info (
h5_int64_t herr = h5u_get_dataset_info_by_idx (
f, *index - 1, name, l_name, NULL, NULL );
h5_strc2for (name, l_name);
H5_API_RETURN (herr);
......@@ -217,7 +217,7 @@ h5pt_getdatasetinfo (
(h5_file_p)f,
(long long)*dataset_idx,
dataset_name, dataset_type, dataset_nelem);
h5_int64_t h5err = h5u_get_dataset_info (
h5_int64_t h5err = h5u_get_dataset_info_by_idx (
f,
*dataset_idx - 1,
dataset_name, l_dataset_name,
......
......@@ -160,7 +160,7 @@ h5_writefileattrib_string (
(h5_file_p)f, l_name, name, l_buffer, buffer);
char *buffer2 = h5_strdupfor2c (buffer, l_buffer);
h5_int64_t herr = write_file_attrib (
f, name, l_name, H5_STRING_T, buffer2, strlen(buffer2)+1 );
f, name, l_name, H5_STRING, buffer2, strlen(buffer2)+1 );
free (buffer2);
H5_API_RETURN (herr);
}
......@@ -180,7 +180,7 @@ h5_readfileattrib_string (
H5_API_ENTER (h5_int64_t,
"fh=%p, name='%.*s', buffer='%.*s'",
(h5_file_p)f, l_name, name, l_buffer, buffer);
h5_int64_t herr = read_file_attrib (f, name, l_name, H5_STRING_T, buffer);
h5_int64_t herr = read_file_attrib (f, name, l_name, H5_STRING, buffer);
h5_strc2for (buffer, l_buffer);
H5_API_RETURN (herr);
}
......@@ -203,7 +203,7 @@ h5_writefileattrib_r8 (
H5_API_RETURN (write_file_attrib(
f,
name, l_name,
H5_FLOAT64_T,
H5_FLOAT64,
buffer, (hsize_t)*nelem));
}
......@@ -224,7 +224,7 @@ h5_readfileattrib_r8 (
H5_API_RETURN (read_file_attrib(
f,
name, l_name,
H5_FLOAT64_T,
H5_FLOAT64,
(void*)buffer));
}
......@@ -246,7 +246,7 @@ h5_writefileattrib_r4 (
H5_API_RETURN (write_file_attrib(
f,
name, l_name,
H5_FLOAT32_T,
H5_FLOAT32,
buffer, (hsize_t)*nelem));
}
......@@ -267,7 +267,7 @@ h5_readfileattrib_r4 (
H5_API_RETURN (read_file_attrib(
f,
name, l_name,
H5_FLOAT32_T,
H5_FLOAT32,
buffer));
}
......@@ -289,7 +289,7 @@ h5_writefileattrib_i8 (
H5_API_RETURN (write_file_attrib(
f,
name, l_name,
H5_INT64_T,
H5T_NATIVE_INT64,
buffer, (hsize_t)*nelem));
}
......@@ -310,7 +310,7 @@ h5_readfileattrib_i8 (
H5_API_RETURN (read_file_attrib(
f,
name, l_name,
H5_INT64_T,
H5T_NATIVE_INT64,
buffer));
}
......@@ -332,7 +332,7 @@ h5_writefileattrib_i4 (
H5_API_RETURN (write_file_attrib(
f,
name, l_name,
H5_INT32_T,
H5T_NATIVE_INT32,
buffer, (hsize_t)*nelem));
}
......@@ -353,7 +353,7 @@ h5_readfileattrib_i4 (
H5_API_RETURN (read_file_attrib(
f,
name, l_name,
H5_INT32_T,
H5T_NATIVE_INT32,
buffer));
}
......@@ -508,7 +508,7 @@ h5_writestepattrib_string (
(h5_file_p)f, l_name, name, l_buffer, buffer);
char *buffer2 = h5_strdupfor2c (buffer, l_buffer);
h5_int64_t herr = write_step_attrib (
f, name, l_name, H5_STRING_T, buffer2, strlen(buffer2)+1 );
f, name, l_name, H5_STRING, buffer2, strlen(buffer2)+1 );
free (buffer2);
H5_API_RETURN (herr);
}
......@@ -528,7 +528,7 @@ h5_readstepattrib_string (
H5_API_ENTER (h5_int64_t,
"f=%p, name='%.*s', buffer='%.*s'",
(h5_file_p)f, l_name, name, l_buffer, buffer);
h5_int64_t herr = read_step_attrib (f, name, l_name, H5_STRING_T, buffer);
h5_int64_t herr = read_step_attrib (f, name, l_name, H5_STRING, buffer);
h5_strc2for (buffer, l_buffer);
H5_API_RETURN (herr);
}
......@@ -551,7 +551,7 @@ h5_writestepattrib_r8 (
H5_API_RETURN (write_step_attrib(
f,
name, l_name,
H5_FLOAT64_T,
H5_FLOAT64,
buffer, (hsize_t)*nelem));
}
......@@ -572,7 +572,7 @@ h5_readstepattrib_r8 (
H5_API_RETURN (read_step_attrib(
f,
name, l_name,
H5_FLOAT64_T,
H5_FLOAT64,
(void*)buffer));
}
......@@ -594,7 +594,7 @@ h5_writestepattrib_r4 (
H5_API_RETURN (write_step_attrib(
f,
name, l_name,
H5_FLOAT32_T,
H5_FLOAT32,
buffer, (hsize_t)*nelem));
}
......@@ -615,7 +615,7 @@ h5_readstepattrib_r4 (
H5_API_RETURN (read_step_attrib(
f,
name, l_name,
H5_FLOAT32_T,
H5_FLOAT32,
buffer));
}
......@@ -637,7 +637,7 @@ h5_writestepattrib_i8 (
H5_API_RETURN (write_step_attrib(
f,
name, l_name,
H5_INT64_T,
H5T_NATIVE_INT64,
buffer, (hsize_t)*nelem));
}
......@@ -658,7 +658,7 @@ h5_readstepattrib_i8 (
H5_API_RETURN (read_step_attrib(
f,
name, l_name,
H5_INT64_T,
H5T_NATIVE_INT64,
buffer));
}
......@@ -680,7 +680,7 @@ h5_writestepattrib_i4 (
H5_API_RETURN (write_step_attrib(
f,
name, l_name,
H5_INT32_T,
H5T_NATIVE_INT32,
buffer, (hsize_t)*nelem));
}
......@@ -701,6 +701,6 @@ h5_readstepattrib_i4 (
H5_API_RETURN (read_step_attrib(
f,
name, l_name,
H5_INT32_T,
H5T_NATIVE_INT32,
buffer));
}
......@@ -9,7 +9,6 @@
#include "h5_private.h"
#include "h5core/h5_init.h"
#include "h5core/h5_debug.h"
#include "h5core/h5_model.h"
......
......@@ -10,7 +10,7 @@ F90_FILES = \
$(top_srcdir)/src/include/H5_file_attribs.f90 \
$(top_srcdir)/src/include/H5_step_attribs.f90 \
$(top_srcdir)/src/include/H5_debug.f90 \
$(top_srcdir)/src/include/H5_error.f90 \
$(top_srcdir)/src/include/H5_err.f90 \
$(top_srcdir)/src/include/H5_log.f90 \
$(top_srcdir)/src/include/H5Part_model.f90 \
$(top_srcdir)/src/include/H5Part_io.f90 \
......
/*
Copyright (c) 2006-2015, The Regents of the University of California,
Copyright (c) 2006-2016, The Regents of the University of California,
through Lawrence Berkeley National Laboratory (subject to receipt of any
required approvals from the U.S. Dept. of Energy) and the Paul Scherrer
Institut (Switzerland). All rights reserved.
......@@ -13,7 +13,7 @@
#include <stdlib.h>
#include <string.h>
#include "h5core/h5_init.h"
#include "h5core/h5_types.h"
#if defined(FC_MANGLING_LOWERCASE_NO_UNDERSCORE)
# define FC_MANGLING(a,b) a
......@@ -31,23 +31,23 @@
# error "Unknown Fortran symbol mangling"
#endif
#define convert_type2for(type) \
if (*type == H5_STRING_T) { \
*type = 1; \
} else if (*type == H5_INT16_T) { \
*type = 2; \
} else if (*type == H5_INT32_T) { \
*type = 3; \
} else if (*type == H5_INT64_T) { \
*type = 4; \
} else if (*type == H5_FLOAT32_T) { \
*type = 5; \
} else if (*type == H5_FLOAT64_T) { \
*type = 6; \
} else { \
H5_API_LEAVE ( \
h5_error ( \
H5_ERR_H5, \
#define convert_type2for(type) \
if (*type == H5_STRING) { \
*type = 1; \
} else if (*type == H5_INT16) { \
*type = 2; \
} else if (*type == H5_INT32) { \
*type = 3; \
} else if (*type == H5_INT64) { \
*type = 4; \
} else if (*type == H5_FLOAT32) { \
*type = 5; \
} else if (*type == H5_FLOAT64) { \
*type = 6; \
} else { \
H5_API_LEAVE ( \
h5_error ( \
H5_ERR_H5, \
"Unknown attribute type")); \
}
......
......@@ -3,6 +3,7 @@ AUTOMAKE_OPTIONS = subdir-objects
AM_CPPFLAGS = -I$(top_srcdir)/src/include @AM_CPPFLAGS@
EXTRA_HEADERS = \
private/h5_file.h \
private/h5_hdf5.h \
private/h5_hsearch.h \
private/h5_init.h \
......@@ -10,7 +11,6 @@ EXTRA_HEADERS = \
private/h5_maps.h \
private/h5_model.h \
private/h5_mpi.h \
private/h5.h \
private/h5_qsort.h \
private/h5_io.h \
private/h5_types.h \
......@@ -21,7 +21,7 @@ EXTRA_HEADERS = \
private/h5t_access.h \
private/h5t_adjacencies.h \
private/h5t_core.h \
private/h5t_errorhandling.h \
private/h5t_err.h \
private/h5t_map.h \
private/h5t_model.h \
private/h5t_octree.h \
......@@ -35,7 +35,7 @@ EXTRA_HEADERS = \
private/h5u_types.h \
private/h5_attribs.h \
private/h5_debug.h \
private/h5_errorhandling.h \
private/h5_err.h \
private/h5_fcmp.h
# Extra files that I wish to include in the dist tar ball.
......
......@@ -7,15 +7,16 @@
License: see file COPYING in top level of source distribution.
*/
#include "h5core/h5_init.h"
#include "private/h5_types.h"
#include "private/h5_errorhandling.h"
#include "private/h5_err.h"
#include "private/h5_hdf5.h"
#include "private/h5_model.h"
#include "h5core/h5_syscall.h"
#include "private/h5_va_macros.h"
#include "h5core/h5_file.h"
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
......@@ -133,9 +134,8 @@ h5_has_attachments (
) {
h5_file_p f = (h5_file_p)f_;
H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f);
h5_err_t exists;
TRY (exists = hdf5_link_exists (f->file, H5_ATTACHMENT));
H5_CORE_API_RETURN (exists);
TRY (ret_value = hdf5_link_exists (f->file, H5_ATTACHMENT));
H5_CORE_API_RETURN (ret_value);
}
h5_ssize_t
......@@ -151,10 +151,9 @@ h5_get_num_attachments (
}
hid_t group_id;
TRY (group_id = hdf5_open_group (f->file, H5_ATTACHMENT));
h5_ssize_t num = 0;
TRY (num = hdf5_get_num_datasets (group_id));
TRY (ret_value = hdf5_get_num_datasets (group_id));
TRY (hdf5_close_group (group_id));
H5_CORE_API_RETURN (num);
H5_CORE_API_RETURN (ret_value);
}
h5_err_t
......@@ -197,9 +196,8 @@ h5_has_attachment (
H5_CORE_API_ENTER (h5_err_t, "f=%p, fname='%s'", f, fname);
hid_t loc_id;
TRY (loc_id = hdf5_open_group (f->file, H5_ATTACHMENT));
h5_err_t exists;
TRY (exists = hdf5_link_exists (f->file, fname));
H5_CORE_API_RETURN (exists);
TRY (ret_value = hdf5_link_exists (f->file, fname));
H5_CORE_API_RETURN (ret_value);
}
h5_err_t
......@@ -243,7 +241,7 @@ h5_get_attachment (
// read dataset
hid_t dataset_id, diskspace_id;
h5_ssize_t fsize;
TRY (dataset_id = hdf5_open_dataset (loc_id, fname));
TRY (dataset_id = hdf5_open_dataset_by_name (loc_id, fname));
TRY (diskspace_id = hdf5_get_dataset_space (dataset_id));
TRY (fsize = hdf5_get_npoints_of_dataspace (diskspace_id));
......
This diff is collapsed.
......@@ -7,7 +7,7 @@
License: see file COPYING in top level of source distribution.
*/
#include "h5core/h5_init.h"
#include "h5core/h5_debug.h"
#include "private/h5_init.h"
h5_int32_t h5_debug_level = H5_VERBOSE_ERROR;
......
......@@ -7,7 +7,8 @@
License: see file COPYING in top level of source distribution.
*/
#include "h5core/h5_init.h"
#include "h5core/h5_debug.h"
#include "h5core/h5_err.h"
#include "private/h5_init.h"
static h5_errorhandler_t h5_errhandler = h5_report_errorhandler;
......
......@@ -11,10 +11,9 @@
#include <errno.h>
#include <fcntl.h>
#include "h5core/h5_init.h"
#include "h5core/h5_debug.h"
#include "private/h5.h"
#include "private/h5_file.h"
#include "private/h5_hdf5.h"
#include "private/h5_model.h"
......@@ -22,7 +21,7 @@
#include "private/h5u_io.h"
#include "private/h5b_io.h"
#include "h5core/h5_errorhandling.h"
#include "h5core/h5_err.h"
#include "h5core/h5_syscall.h"
/*!
......@@ -60,7 +59,7 @@ h5_get_hdf5_file(
}
/*!
Initialize H5Part
Initialize H5hut
*/
static herr_t
hdf5_error_handler (
......@@ -583,7 +582,8 @@ h5_close_hdf5 (
void
) {
H5_CORE_API_ENTER (h5_err_t, "%s", "");
H5_CORE_API_RETURN (hdf5_close ());
TRY (ret_value = hdf5_close ());
H5_CORE_API_RETURN (ret_value);
}
h5_err_t
......@@ -592,7 +592,8 @@ h5_flush_step (
) {
h5_file_p f = (h5_file_p)f_;
H5_CORE_API_ENTER (h5_err_t, "f=%p", f);
H5_CORE_API_RETURN (hdf5_flush (f->step_gid, H5F_SCOPE_LOCAL));
TRY (ret_value = hdf5_flush (f->step_gid, H5F_SCOPE_LOCAL));
H5_CORE_API_RETURN (ret_value);
}
h5_err_t
......@@ -601,7 +602,8 @@ h5_flush_file (
) {
h5_file_p f = (h5_file_p)f_;
H5_CORE_API_ENTER (h5_err_t, "f=%p", f);
H5_CORE_API_RETURN (hdf5_flush (f->file, H5F_SCOPE_GLOBAL));
TRY (ret_value = hdf5_flush (f->file, H5F_SCOPE_GLOBAL));
H5_CORE_API_RETURN (ret_value);
}
......@@ -703,9 +705,10 @@ h5_get_num_steps(
) {
h5_file_p f = (h5_file_p)f_;
H5_CORE_API_ENTER (int, "f=%p", f);
H5_CORE_API_RETURN (hdf5_get_num_groups_matching_prefix (
f->root_gid,
f->props->prefix_step_name));
TRY (ret_value = hdf5_get_num_groups_matching_prefix (
f->root_gid,
f->props->prefix_step_name));
H5_CORE_API_RETURN (ret_value);
}
/*!
......
......@@ -14,15 +14,12 @@
#include "config.h"
#include "h5core/h5_init.h"
#include "private/h5_hdf5.h"
#include "private/h5_mpi.h"
#include "private/h5t_types.h"
#include "private/h5t_tags.h"
int h5_initialized = 0;
h5_dta_types_t h5_dta_types; // type ids' for base & compound data types
int h5_myproc = 0; // proc id
......@@ -39,33 +36,33 @@ create_array_types (
hsize_t dims[1] = { 3 };
TRY(
h5_dta_types.h5_coord3d_t = hdf5_create_array_type (
H5_FLOAT64_T,
H5_FLOAT64,
1,
dims)
);
TRY(
h5_dta_types.h5_3glb_idx_t = hdf5_create_array_type (
H5_ID_T,
H5_ID,
1,
dims)
);
dims[0] = 4;
TRY(
h5_dta_types.h5_4glb_idx_t = hdf5_create_array_type (
H5_ID_T,
H5_ID,
1,
dims)
);
TRY(
h5_dta_types.h5_4chk_idx_t = hdf5_create_array_type (
H5_INT32_T,
H5_INT32,
1,
dims)
);
dims[0] = 6;
TRY(
h5_dta_types.h5_coord6d_t = hdf5_create_array_type (
H5_FLOAT64_T,
H5_FLOAT64,
1,
dims)
);
......@@ -80,14 +77,14 @@ create_vertex_type (
TRY(
h5_dta_types.h5_vertex_t = hdf5_create_type (
H5_COMPOUND_T,
H5_COMPOUND,
sizeof (h5_glb_vertex_t)) );
TRY(
hdf5_insert_type (
h5_dta_types.h5_vertex_t,
"idx",
HOFFSET (h5_glb_vertex_t, idx),
H5_ID_T) );
H5_ID) );
TRY(
hdf5_insert_type (
h5_dta_types.h5_vertex_t,
......@@ -106,44 +103,44 @@ create_triangle_type (
TRY(
h5_dta_types.h5_triangle_t = hdf5_create_type (
H5_COMPOUND_T,
H5_COMPOUND,
sizeof (h5_glb_tri_t)) );
TRY(
hdf5_insert_type (
h5_dta_types.h5_triangle_t,
"idx",
HOFFSET (h5_glb_tri_t, idx),
H5_ID_T) );
H5_ID) );
TRY(
hdf5_insert_type (
h5_dta_types.h5_triangle_t,
"parent_idx",
HOFFSET (h5_glb_tri_t, parent_idx),
H5_ID_T) );
H5_ID) );
TRY(
hdf5_insert_type (
h5_dta_types.h5_triangle_t,
"child_idx",
HOFFSET(h5_glb_tri_t, child_idx),
H5_ID_T) );
H5_ID) );
TRY(
hdf5_insert_type (
h5_dta_types.h5_triangle_t,
"level_idx",
HOFFSET(h5_glb_tri_t, level_idx),
H5_INT16_T) );
H5_INT16) );
TRY(
hdf5_insert_type (
h5_dta_types.h5_triangle_t,
"refinement",
HOFFSET(h5_glb_tri_t, refinement),
H5_INT16_T) );
H5_INT16) );
TRY(
hdf5_insert_type (
h5_dta_types.h5_triangle_t,
"flags",
HOFFSET(h5_glb_tri_t, flags),
H5_INT32_T) );
H5_INT32) );
TRY(
hdf5_insert_type (
h5_dta_types.h5_triangle_t,
......@@ -168,20 +165,20 @@ create_tag_types (
TRY (
h5_dta_types.h5t_glb_tag_idx_t = hdf5_create_type (
H5_COMPOUND_T,
H5_COMPOUND,
sizeof (h5t_glb_tag_idx_t)) );
TRY (
hdf5_insert_type (
h5_dta_types.h5t_glb_tag_idx_t,
"eid",
HOFFSET (h5t_glb_tag_idx_t, eid),
H5_ID_T) );
H5_ID) );
TRY (
hdf5_insert_type (
h5_dta_types.h5t_glb_tag_idx_t,
"idx",
HOFFSET (h5t_glb_tag_idx_t, idx),
H5_ID_T) );
H5_ID) );
H5_PRIV_FUNC_RETURN (H5_SUCCESS);
}
......@@ -194,20 +191,20 @@ create_tet_type (
TRY(
h5_dta_types.h5_tet_t = hdf5_create_type (
H5_COMPOUND_T,
H5_COMPOUND,
sizeof (h5_glb_tet_t)) );
TRY(
hdf5_insert_type (
h5_dta_types.h5_tet_t,
"idx",
HOFFSET (h5_glb_tet_t, idx),
H5_ID_T) );
H5_ID) );
TRY(
hdf5_insert_type (
h5_dta_types.h5_tet_t,
"parent_idx",
HOFFSET (h5_glb_tet_t, parent_idx),
H5_ID_T) );
H5_ID) );
TRY(
hdf5_insert_type (
h5_dta_types.h5_tet_t,
......@@ -219,19 +216,19 @@ create_tet_type (
h5_dta_types.h5_tet_t,
"level_idx",
HOFFSET(h5_glb_tet_t, level_idx),
H5_INT16_T) );
H5_INT16) );
TRY(
hdf5_insert_type (
h5_dta_types.h5_tet_t,
"refinement",
HOFFSET(h5_glb_tet_t, refinement),
H5_INT16_T) );
H5_INT16) );