From b737d2cb146ac4e3d808e39ad8a3e1f33cd3d311 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 25 Sep 2008 15:47:26 +0000 Subject: [PATCH] refactoring --- src/H5.c | 6 ++---- src/H5Block.c | 31 ++++++++++++++++----------- src/H5Fed.c | 8 +++---- src/H5Fed.h | 6 +++--- src/H5Fed_adjacency.c | 2 +- src/H5Fed_dof.c | 2 +- src/H5Fed_inquiry.c | 5 ++--- src/H5Fed_map.c | 3 +-- src/H5Fed_retrieve.c | 9 ++++---- src/H5Fed_store.c | 49 ++++++++++++++++++++++++++++++++++++++----- src/H5Part.c | 46 ++++++++++++++++++++-------------------- src/H5Part.h | 3 +-- src/Makefile.am | 14 ++++++------- 13 files changed, 111 insertions(+), 73 deletions(-) diff --git a/src/H5.c b/src/H5.c index c006d16..e2464e8 100644 --- a/src/H5.c +++ b/src/H5.c @@ -42,10 +42,8 @@ #include #include -#include "h5/h5_core.h" -#include "h5/h5_private.h" -#include "H5Fed.h" - +#include "h5_core/h5_core.h" +#include "h5_core/h5_core_private.h" /****** General routines *****************************************************/ diff --git a/src/H5Block.c b/src/H5Block.c index d59d5fc..6a53b08 100644 --- a/src/H5Block.c +++ b/src/H5Block.c @@ -45,8 +45,8 @@ #include -#include "h5/h5_core.h" -#include "h5/h5_private.h" +#include "h5_core/h5_core.h" +#include "h5_core/h5_core_private.h" #include "H5Part.h" #include "H5Block.h" @@ -736,8 +736,11 @@ _open_block_group ( } if ( b->blockgroup < 0 ) { - hid_t herr = H5Gopen ( f->step_gid, H5BLOCK_GROUPNAME_BLOCK ); - if ( herr < 0 ) return HANDLE_H5G_OPEN_ERR ( H5BLOCK_GROUPNAME_BLOCK ); + hid_t herr = H5Gopen ( f->step_gid, H5BLOCK_GROUPNAME_BLOCK, + H5P_DEFAULT ); + if ( herr < 0 ) return HANDLE_H5G_OPEN_ERR ( + h5_get_objname(f->step_gid), + H5BLOCK_GROUPNAME_BLOCK ); b->blockgroup = herr; } b->step_idx = f->step_idx; @@ -782,8 +785,9 @@ _open_field_group ( if ( ! _have_object ( b->blockgroup, name ) ) return HANDLE_H5_NOENT_ERR ( name ); - herr_t herr = H5Gopen ( b->blockgroup, name ); - if ( herr < 0 ) return HANDLE_H5G_OPEN_ERR ( name ); + herr_t herr = H5Gopen ( b->blockgroup, name, H5P_DEFAULT ); + if ( herr < 0 ) return HANDLE_H5G_OPEN_ERR ( + h5_get_objname(b->blockgroup), name ); b->field_group_id = herr; @@ -912,7 +916,7 @@ _read_data ( struct h5b_fdata *b = f->block; - hid_t dataset_id = H5Dopen ( b->field_group_id, name ); + hid_t dataset_id = H5Dopen ( b->field_group_id, name, H5P_DEFAULT ); if ( dataset_id < 0 ) return HANDLE_H5D_OPEN_ERR ( name ); h5part_int64_t herr = _select_hyperslab_for_reading ( f, dataset_id ); @@ -1147,7 +1151,8 @@ _create_block_group ( f->block->blockgroup = -1; } - herr = H5Gcreate ( f->step_gid, H5BLOCK_GROUPNAME_BLOCK, 0 ); + herr = H5Gcreate ( f->step_gid, H5BLOCK_GROUPNAME_BLOCK, 0, + H5P_DEFAULT, H5P_DEFAULT ); if ( herr < 0 ) return HANDLE_H5G_CREATE_ERR ( H5BLOCK_GROUPNAME_BLOCK ); f->block->blockgroup = herr; @@ -1184,7 +1189,7 @@ _create_field_group ( if ( _have_object ( b->blockgroup, name ) ) return HANDLE_H5_GROUP_EXISTS_ERR ( name ); - herr_t herr = H5Gcreate ( b->blockgroup, name, 0 ); + herr_t herr = H5Gcreate ( b->blockgroup, name, 0, H5P_DEFAULT, H5P_DEFAULT ); if ( herr < 0 ) return HANDLE_H5G_CREATE_ERR ( name ); b->field_group_id = herr; @@ -1343,10 +1348,12 @@ _get_field_info ( h5part_int64_t herr = _open_block_group ( f ); if ( herr < 0 ) return herr; - hid_t group_id = H5Gopen ( f->block->blockgroup, field_name ); - if ( group_id < 0 ) return HANDLE_H5G_OPEN_ERR ( field_name ); + hid_t group_id = H5Gopen ( f->block->blockgroup, field_name, + H5P_DEFAULT ); + if ( group_id < 0 ) return HANDLE_H5G_OPEN_ERR ( + h5_get_objname(f->block->blockgroup), field_name ); - hid_t dataset_id = H5Dopen ( group_id, "0" ); + hid_t dataset_id = H5Dopen ( group_id, "0", H5P_DEFAULT ); if ( dataset_id < 0 ) return HANDLE_H5D_OPEN_ERR ( "0" ); hid_t dataspace_id = H5Dget_space ( dataset_id ); diff --git a/src/H5Fed.c b/src/H5Fed.c index 3cc06cc..8c58b28 100644 --- a/src/H5Fed.c +++ b/src/H5Fed.c @@ -15,15 +15,15 @@ #include #include -#include "h5/h5_core.h" -#include "h5/h5_private.h" +#include "h5_core/h5_core.h" +#include "h5_core/h5_core_private.h" #include "H5Fed.h" h5_err_t H5FedOpenMesh ( h5_file * f, const h5_id_t id, - const enum h5_mesh_types type + const h5_oid_t type ) { SET_FNAME ( __func__ ); return h5t_open_mesh ( f, id, type ); @@ -32,7 +32,7 @@ H5FedOpenMesh ( h5_id_t H5FedAddMesh ( h5_file * f, - const enum h5_mesh_types type + const h5_oid_t type ) { SET_FNAME ( __func__ ); return h5t_open_mesh ( f, -1, type ); diff --git a/src/H5Fed.h b/src/H5Fed.h index 13d99ec..f998cd7 100644 --- a/src/H5Fed.h +++ b/src/H5Fed.h @@ -28,19 +28,19 @@ h5_size_t H5FedGetNumMeshes ( h5_file * f, - const enum h5_mesh_types type + const h5_oid_t type ); h5_err_t H5FedOpenMesh ( h5_file * f, const h5_id_t id, - const enum h5_mesh_types type + const h5_oid_t type ); h5_id_t H5FedAddMesh ( h5_file * f, - const enum h5_mesh_types type + const h5_oid_t type ); h5_size_t diff --git a/src/H5Fed_adjacency.c b/src/H5Fed_adjacency.c index b3ad948..77e8c54 100644 --- a/src/H5Fed_adjacency.c +++ b/src/H5Fed_adjacency.c @@ -14,7 +14,7 @@ */ #include -#include "h5/h5_types.h" +#include "h5_core/h5_types.h" #include "H5Fed.h" /****** UPWARD ADJACENCY routines *********************************************/ diff --git a/src/H5Fed_dof.c b/src/H5Fed_dof.c index 0788a41..14dbbe5 100644 --- a/src/H5Fed_dof.c +++ b/src/H5Fed_dof.c @@ -15,7 +15,7 @@ */ #include -#include "h5/h5_types.h" +#include "h5_core/h5_types.h" #include "H5Fed.h" /* DoF acces for vertices */ diff --git a/src/H5Fed_inquiry.c b/src/H5Fed_inquiry.c index 9aad678..b8be2bb 100644 --- a/src/H5Fed_inquiry.c +++ b/src/H5Fed_inquiry.c @@ -19,14 +19,13 @@ #include #include -#include "h5/h5_core.h" -#include "h5/h5_private.h" +#include "h5_core/h5_core.h" #include "H5Fed.h" h5_size_t H5FedGetNumMeshes ( h5_file * f, /*!< file handle */ - const enum h5_mesh_types type + const h5_oid_t type ) { SET_FNAME ( __func__ ); return h5t_get_num_meshes ( f, type ); diff --git a/src/H5Fed_map.c b/src/H5Fed_map.c index efdd870..be5083c 100644 --- a/src/H5Fed_map.c +++ b/src/H5Fed_map.c @@ -19,8 +19,7 @@ #include #include -#include "h5/h5_core.h" -#include "h5/h5_private.h" +#include "h5_core/h5_core.h" #include "H5Fed.h" h5_id_t diff --git a/src/H5Fed_retrieve.c b/src/H5Fed_retrieve.c index 667feff..985b766 100644 --- a/src/H5Fed_retrieve.c +++ b/src/H5Fed_retrieve.c @@ -16,8 +16,7 @@ #include #include -#include "h5/h5_core.h" -#include "h5/h5_private.h" +#include "h5_core/h5_core.h" #include "H5Fed.h" h5_err_t @@ -37,7 +36,7 @@ H5FedStartTraverseVertices ( \return error code (H5_ERR_NOENT means no more vertices on this level) */ -h5_err_t +h5_id_t H5FedTraverseVertices ( h5_file * f, /*!< file handle */ h5_id_t * const id, /*!< OUT: global id */ @@ -57,7 +56,7 @@ H5FedStartTraverseTriangles ( return h5t_start_traverse_triangles ( f ); } -h5_err_t +h5_id_t H5FedTraverseTriangles ( h5_file * f, /*!< file handle */ h5_id_t * const id, /*!< OUT: global tetrahedron id */ @@ -89,7 +88,7 @@ H5FedStartTraverseTetrahedra ( \return pointer to 4-tuple of vertex id's defining the tetrahedron. \return NULL-pointer on error. */ -h5_err_t +h5_id_t H5FedTraverseTetrahedra ( h5_file * f, /*!< file handle */ h5_id_t * const id, /*!< OUT: global tetrahedron id */ diff --git a/src/H5Fed_store.c b/src/H5Fed_store.c index cdefb38..7bd9141 100644 --- a/src/H5Fed_store.c +++ b/src/H5Fed_store.c @@ -15,8 +15,7 @@ #include #include -#include "h5/h5_core.h" -#include "h5/h5_private.h" +#include "h5_core/h5_core.h" #include "H5Fed.h" /*! @@ -44,6 +43,7 @@ H5FedAddLevel ( return h5t_add_level ( f ); } +#if 0 /*! \ingroup h5fed_c_api @@ -66,8 +66,14 @@ H5FedAddNumVertices ( ) { SET_FNAME ( __func__ ); + if ( h5t_get_level ( f ) != 0 ) { + return h5_error ( + H5_ERR_INVAL, + "Vertices can be added to level 0 only!" ); + } return h5t_add_num_vertices ( f, num ); } +#endif /*! \ingroup h5fed_c_api @@ -86,20 +92,34 @@ H5FedStoreVertex ( ) { SET_FNAME ( __func__ ); + if ( h5t_get_level ( f ) != 0 ) { + return h5_error ( + H5_ERR_INVAL, + "Vertices can be added to level 0 only!" ); + } return h5t_store_vertex ( f, id, P ); } /*** T E T R A H E D R A ****************************************************/ h5_err_t -H5FedAddNumEntities ( +H5FedAddNumTets ( h5_file * f, /*!< file handle */ const h5_size_t num /*!< number of additional - entities on current level */ + tets on current level */ ) { SET_FNAME ( __func__ ); + return h5t_add_num_tets ( f, num ); +} - return h5t_add_num_entities ( f, num ); +h5_err_t +H5FedAddNumTriangles ( + h5_file * f, /*!< file handle */ + const h5_size_t num /*!< number of additional + triangle on current level */ + ) { + SET_FNAME ( __func__ ); + return h5t_add_num_triangles ( f, num ); } /*! @@ -125,9 +145,23 @@ H5FedStoreTetrahedron ( const h5_id_t vertex_ids[4] /*!< tuple with vertex id's */ ) { SET_FNAME ( __func__ ); + if ( h5t_get_level ( f ) != 0 ) { + return h5_error ( + H5_ERR_INVAL, + "Tetrahedra can be added to level 0 only!" ); + } return h5t_store_tet ( f, id, parent_id, vertex_ids ); } +h5_id_t +H5FedRefineTetrahedron ( + h5_file * f, /*!< file handle */ + const h5_id_t id /*!< global tetrahedron id */ + ) { + SET_FNAME ( __func__ ); + return h5t_refine_tet ( f, id ); +} + h5_id_t H5FedStoreTriangle ( h5_file * f, /*!< file handle */ @@ -137,5 +171,10 @@ H5FedStoreTriangle ( h5_id_t vertex_ids[3] /*!< tuple with vertex id's */ ) { SET_FNAME ( __func__ ); + if ( h5t_get_level ( f ) != 0 ) { + return h5_error ( + H5_ERR_INVAL, + "Triangles can be added to level 0 only!" ); + } return h5t_store_triangle ( f, id, parent_id, vertex_ids ); } diff --git a/src/H5Part.c b/src/H5Part.c index d5be11a..597d59a 100644 --- a/src/H5Part.c +++ b/src/H5Part.c @@ -90,8 +90,8 @@ Last modified on April 19, 2007. #define close _close #endif /* WIN32 */ -#include "h5/h5_core.h" -#include "h5/h5_private.h" +#include "h5_core/h5_core.h" +#include "h5_core/h5_errorhandling_private.h" #include "H5Part.h" /********* Private Variable Declarations *************/ @@ -325,10 +325,10 @@ H5PartWriteFileAttribString ( const char *attrib_value/*!< [in] Value of attribute */ ) { - SET_FNAME ( "H5PartWriteFileAttribString" ); + SET_FNAME ( __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_write_attrib ( f->root_gid, @@ -363,7 +363,7 @@ H5PartWriteStepAttribString ( SET_FNAME ( "H5PartWriteStepAttribString" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_write_attrib ( f->step_gid, @@ -404,7 +404,7 @@ H5PartWriteStepAttrib ( SET_FNAME ( "H5PartWriteStepAttrib" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_write_attrib ( f->step_gid, @@ -445,7 +445,7 @@ H5PartWriteFileAttrib ( SET_FNAME ( "H5PartWriteFileAttrib" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_write_attrib ( f->root_gid, @@ -470,7 +470,7 @@ H5PartGetNumStepAttribs ( SET_FNAME ( "H5PartGetNumStepAttribs" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_get_num_attribs ( f, f->step_gid ); } @@ -490,7 +490,7 @@ H5PartGetNumFileAttribs ( SET_FNAME ( "H5PartGetNumFileAttribs" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_get_num_attribs ( f, f->root_gid ); } @@ -524,7 +524,7 @@ H5PartGetStepAttribInfo ( SET_FNAME ( "H5PartGetStepAttribInfo" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_get_attrib_info ( f->step_gid, @@ -564,7 +564,7 @@ H5PartGetFileAttribInfo ( SET_FNAME ( "H5PartGetFileAttribInfo" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_get_attrib_info ( f->root_gid, @@ -592,7 +592,7 @@ H5PartReadStepAttrib ( SET_FNAME ( "H5PartReadStepAttrib" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_read_attrib ( f->step_gid, attrib_name, attrib_value ); } @@ -614,7 +614,7 @@ H5PartReadFileAttrib ( SET_FNAME ( "H5PartReadFileAttrib" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_read_attrib ( f->root_gid, attrib_name, attrib_value ); } @@ -657,7 +657,7 @@ H5PartSetStep ( SET_FNAME ( "H5PartSetStep" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_set_step ( f, step ); } @@ -684,7 +684,7 @@ H5PartHasStep ( SET_FNAME ( "H5PartHasStep" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_has_step( f, step ); } @@ -708,7 +708,7 @@ H5PartGetNumSteps ( SET_FNAME ( "H5PartGetNumSteps" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_get_num_objects_matching_pattern ( f->file, @@ -733,7 +733,7 @@ H5PartGetNumDatasets ( SET_FNAME ( "H5PartGetNumDatasets" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_get_num_objects ( f->file, f->step_name, H5G_DATASET ); } @@ -759,7 +759,7 @@ H5PartGetDatasetName ( SET_FNAME ( "H5PartGetDatasetName" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return h5_get_object_name ( f->file, @@ -794,7 +794,7 @@ H5PartGetDatasetInfo ( SET_FNAME ( "H5PartGetDatasetInfo" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); return H5U_get_dataset_info ( f, idx, dataset_name, len_dataset_name, type, nelem ); @@ -818,7 +818,7 @@ H5PartGetNumParticles ( SET_FNAME ( "H5PartGetNumParticles" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); if ( f->step_gid < 0 ) { h5part_int64_t herr = h5_set_step ( f, 0 ); @@ -838,7 +838,7 @@ H5PartResetView ( SET_FNAME ( "H5PartResetView" ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return _h5part_errno; + return h5_get_errno(); CHECK_READONLY_MODE ( f ); @@ -852,12 +852,12 @@ h5part_int64_t H5PartHasView ( h5_file *f /*!< [in] Handle to open file */ ) { - SET_FNAME ( "H5PartResetView" ); + SET_FNAME ( __func__ ); CHECK_FILEHANDLE( f ); CHECK_READONLY_MODE ( f ); - return ( f->viewstart >= 0 ) && ( f->viewend >= 0 ); + return h5u_has_view ( f ); } diff --git a/src/H5Part.h b/src/H5Part.h index 28fe891..7000d2f 100644 --- a/src/H5Part.h +++ b/src/H5Part.h @@ -4,7 +4,7 @@ #include #include #include -#include "h5/h5_core.h" +#include "h5_core/h5_core.h" #ifdef PARALLEL_IO #include #endif @@ -19,7 +19,6 @@ extern "C" { #define H5PART_ERR_BADFD H5_ERR_BADFD #define H5PART_ERR_LAYOUT H5_ERR_LAYOUT #define H5PART_ERR_NOENT H5_ERR_NOENT -#define H5PART_ERR_INIT H5_ERR_INIT #define H5PART_ERR_NOENTRY H5_ERR_NOENTRY #define H5PART_ERR_MPI H5_ERR_MPI diff --git a/src/Makefile.am b/src/Makefile.am index ba228a8..1fd2b4d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -36,10 +36,10 @@ nodist_include_HEADERS = @UNDERSCORE_H@ # What to build... Will be determined by configure script. OBJEXT = o -lib_LIBRARIES = @MTARGET@ +lib_LIBRARIES = libH5.a # Listing of all possible targets that I may build. -EXTRA_LIBRARIES = libH5Part.a +EXTRA_LIBRARIES = libH5.a # Header files that I wish to install in $(prefix)/include include_HEADERS = \ @@ -53,12 +53,12 @@ include_HEADERS = \ EXTRA_HEADERS = # Listing of sources -libH5Part_a_SOURCES = \ +libH5_a_SOURCES = \ H5.c \ H5Block.c \ H5Fed.c \ H5Fed_adjacency.c \ - H5Fed_boundaries.c \y + H5Fed_boundaries.c \ H5Fed_dof.c \ H5Fed_inquiry.c \ H5Fed_map.c \ @@ -66,11 +66,9 @@ libH5Part_a_SOURCES = \ H5Fed_store.c \ H5Part.c -SUBDIRS = h5 bindings +SUBDIRS = h5_core bindings -# Specific building instruction (What compilers to use...) -# ------------ Serial Lib build commands ------------ -libH5Part.a: $(libH5Part_a_OBJECTS) +libH5.a: $(libH5_a_OBJECTS) ${AR} rucs $@ $^ %.o : %.c