diff --git a/src/C/H5.c b/src/C/H5.c index 3f6aeef..6fee39c 100644 --- a/src/C/H5.c +++ b/src/C/H5.c @@ -44,13 +44,14 @@ \return File handle. \return NULL on error. */ -h5_file_t* +h5_file_p H5OpenFile ( const char* filename, /*!< file name */ h5_int32_t flags, /*!< file open flags */ MPI_Comm comm /*!< MPI communicator */ ) { - return h5_open_file (filename, flags, comm, __func__); + H5_API_ENTER (h5_file_p); + H5_API_RETURN (h5_open_file (filename, flags, comm)); } /*! @@ -64,9 +65,8 @@ h5_err_t H5CloseFile ( h5_file_t* const f /*!< file handle */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_close_file (f); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_close_file (f)); } /*! @@ -80,9 +80,8 @@ h5_err_t H5CheckFile ( h5_file_t* const f /*!< file handle */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_check_filehandle (f); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_check_filehandle (f)); } /*! @@ -101,9 +100,8 @@ H5SetStepNameFormat ( const char* name, /*!< Prefix */ const h5_int64_t width /*!< Width of the number */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_set_stepname_fmt (f, name, width); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_set_stepname_fmt (f, name, width)); } /*! @@ -121,9 +119,8 @@ H5GetStepNameFormat ( const h5_size_t l_name, /*!< length of buffer name */ int* width /*!< OUT: Width of the number */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_get_stepname_fmt (f, name, l_name, width); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_get_stepname_fmt (f, name, l_name, width)); } /*! @@ -139,9 +136,8 @@ H5SetStep ( const h5_id_t step /*!< [in] Step to set. */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_set_step (f, step); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_set_step (f, step)); } /*! @@ -155,10 +151,8 @@ h5_id_t H5GetStep ( h5_file_t* const f /*!< Handle to open file */ ) { - - H5_API_ENTER; - h5_id_t id = h5_get_step (f); - H5_API_RETURN (id); + H5_API_ENTER (h5_id_t); + H5_API_RETURN (h5_get_step (f)); } /*! @@ -175,9 +169,8 @@ int H5GetNumProcs ( h5_file_t* const f ) { - H5_API_ENTER; - int nprocs = h5_get_num_procs(f); - H5_API_RETURN (nprocs); + H5_API_ENTER (int); + H5_API_RETURN (h5_get_num_procs(f)); } /*! @@ -197,9 +190,8 @@ h5_ssize_t H5GetNumSteps ( h5_file_t* const f ) { - H5_API_ENTER; - h5_ssize_t nsteps = h5_get_num_steps(f); - H5_API_RETURN (nsteps); + H5_API_ENTER (h5_ssize_t); + H5_API_RETURN (h5_get_num_steps(f)); } /*! @@ -217,9 +209,8 @@ H5HasStep ( h5_file_t* const f, h5_id_t stepno ) { - H5_API_ENTER; - h5_err_t h5err = h5_has_step (f, stepno); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_has_step (f, stepno)); } /*! @@ -233,9 +224,8 @@ h5_err_t H5StartTraverseSteps ( h5_file_t* const f /*!< Handle to open file */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_start_traverse_steps (f); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_start_traverse_steps (f)); } /*! @@ -249,9 +239,8 @@ h5_err_t H5TraverseSteps ( h5_file_t* const f /*!< Handle to open file */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_traverse_steps (f); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_traverse_steps (f)); } /*! @@ -276,9 +265,8 @@ H5SetThrottle ( h5_file_t* f, int factor ) { - H5_API_ENTER( f, __func__ ); - h5_err_t h5err = h5_set_throttle( f, factor ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_set_throttle(f, factor)); } #endif // PARALLEL_IO @@ -293,7 +281,8 @@ h5_err_t H5SetVerbosityLevel ( const h5_id_t level ) { - return h5_set_debuglevel (level); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_set_debuglevel (level)); } /*! @@ -307,7 +296,8 @@ h5_err_t H5SetErrorHandler ( h5_errorhandler_t handler ) { - return h5_set_errorhandler (handler); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_set_errorhandler (handler)); } /*! @@ -321,25 +311,26 @@ h5_errorhandler_t H5GetErrorHandler ( void ) { - return h5_get_errorhandler(); + H5_API_ENTER (h5_errorhandler_t); + H5_API_RETURN (h5_get_errorhandler()); } h5_err_t H5ReportErrorhandler ( - const h5_file_t* const f, const char* fmt, va_list ap ) { - return h5_report_errorhandler (f, fmt, ap); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_report_errorhandler (fmt, ap)); } h5_err_t H5AbortErrorhandler ( - const h5_file_t* const f, const char* fmt, va_list ap ) { - return h5_abort_errorhandler (f, fmt, ap); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_abort_errorhandler (fmt, ap)); } /*! @@ -353,7 +344,8 @@ h5_err_t H5GetErrno ( h5_file_t* const f ) { - return h5_get_errno (f); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_get_errno ()); } diff --git a/src/C/H5Block.c b/src/C/H5Block.c index 4711f8a..d6234ac 100644 --- a/src/C/H5Block.c +++ b/src/C/H5Block.c @@ -72,9 +72,8 @@ h5_int64_t H5Block3dHasView ( h5_file_t *const f /*!< IN: File handle */ ) { - H5_API_ENTER; - h5_int64_t retval = h5b_3d_has_view(f); - H5_API_RETURN (retval); + H5_API_ENTER (h5_int64_t); + H5_API_RETURN (h5b_3d_has_view (f)); } /*! @@ -100,9 +99,8 @@ H5Block3dSetView ( const h5_int64_t k_start, /*!< IN: start index of \c k */ const h5_int64_t k_end /*!< IN: end index of \c k */ ) { - H5_API_ENTER; - h5_err_t h5err = h5b_3d_set_view(f, i_start, i_end, j_start, j_end, k_start, k_end); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5b_3d_set_view(f, i_start, i_end, j_start, j_end, k_start, k_end)); } /*! @@ -122,9 +120,8 @@ H5Block3dGetView ( h5_size_t *k_start, /*!< OUT: start index of \c k */ h5_size_t *k_end /*!< OUT: end index of \c k */ ) { - H5_API_ENTER; - h5_err_t h5err = h5b_3d_get_view(f, i_start, i_end, j_start, j_end, k_start, k_end); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5b_3d_get_view (f, i_start, i_end, j_start, j_end, k_start, k_end)); } /*! @@ -144,9 +141,8 @@ H5Block3dGetReducedView ( h5_size_t *const k_start, /*!< OUT: start index of \c j */ h5_size_t *const k_end /*!< OUT: end index of \c j */ ) { - H5_API_ENTER; - h5_err_t h5err = h5b_3d_get_reduced_view(f, i_start, i_end, j_start, j_end, k_start, k_end); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5b_3d_get_reduced_view(f, i_start, i_end, j_start, j_end, k_start, k_end)); } /*! @@ -164,9 +160,8 @@ H5Block3dSetChunk ( const h5_size_t j, /*!< IN: size of \c j */ const h5_size_t k /*!< IN: size of \c k */ ) { - H5_API_ENTER; - h5_err_t h5err = h5b_3d_set_chunk(f, i, j, k); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5b_3d_set_chunk(f, i, j, k)); } /*! @@ -184,9 +179,8 @@ H5Block3dGetChunk ( h5_size_t *const j, /*!< OUT: size of \c j */ h5_size_t *const k /*!< OUT: size of \c k */ ) { - H5_API_ENTER; - h5_err_t h5err = h5b_3d_get_chunk(f, field_name, i, j, k); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5b_3d_get_chunk(f, field_name, i, j, k)); } #ifdef PARALLEL_IO @@ -211,9 +205,8 @@ H5Block3dSetGrid ( const h5_size_t j, /*!< IN: dimension in \c j */ const h5_size_t k /*!< IN: dimension in \c k */ ) { - H5_API_ENTER; - h5_err_t h5err = h5b_3d_set_grid(f, i, j, k); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5b_3d_set_grid(f, i, j, k)); } /*! @@ -232,9 +225,8 @@ H5Block3dGetGridCoords ( h5_int64_t *j, /*!< OUT: index in \c j */ h5_int64_t *k /*!< OUT: index in \c k */ ) { - H5_API_ENTER; - h5_err_t h5err = h5b_3d_get_grid_coords(f, proc, i, j, k); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5b_3d_get_grid_coords(f, proc, i, j, k)); } /*! @@ -255,9 +247,8 @@ H5Block3dSetDims ( const h5_size_t j, /*!< IN: dimension in \c j */ const h5_size_t k /*!< IN: dimension in \c k */ ) { - H5_API_ENTER; - h5_err_t h5err = h5b_3d_set_dims(f, i, j, k); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5b_3d_set_dims(f, i, j, k)); } #endif @@ -280,9 +271,8 @@ H5Block3dSetHalo ( const h5_size_t j, /*!< IN: radius in \c j */ const h5_size_t k /*!< IN: radius in \c k */ ) { - H5_API_ENTER; - h5_err_t h5err = h5b_3d_set_halo(f, i, j, k); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5b_3d_set_halo(f, i, j, k)); } /*! @@ -296,9 +286,8 @@ h5_size_t H5BlockGetNumFields ( h5_file_t *const f /*!< IN: file handle */ ) { - H5_API_ENTER; - h5_err_t h5err = h5b_get_num_fields(f); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5b_get_num_fields(f)); } @@ -329,10 +318,17 @@ H5BlockGetFieldInfo ( h5_size_t *elem_rank, /*!< OUT: element rank */ h5_int64_t *type /*!< OUT: datatype */ ) { - H5_API_ENTER; - h5_err_t h5err = h5b_get_field_info (f, - idx, name, len_name, field_rank, field_dims, elem_rank, type); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN ( + h5b_get_field_info ( + f, + idx, + name, + len_name, + field_rank, + field_dims, + elem_rank, + type)); } /*! @@ -352,10 +348,15 @@ H5BlockGetFieldInfoByName ( h5_size_t *elem_rank, /*!< OUT: element rank */ h5_int64_t *type /*!< OUT: datatype */ ) { - H5_API_ENTER; - h5_err_t h5err = h5b_get_field_info_by_name (f, - name, field_rank, field_dims, elem_rank, type ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN ( + h5b_get_field_info_by_name ( + f, + name, + field_rank, + field_dims, + elem_rank, + type)); } /********************** reading and writing attribute ************************/ @@ -375,15 +376,15 @@ H5BlockWriteFieldAttribString ( const char *attrib_name, /*!< IN: attribute name */ const char *value /*!< IN: attribute value */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_write_field_attrib ( - f, - field_name, - attrib_name, - H5T_NATIVE_CHAR, - value, - strlen(value) + 1 ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN ( + h5_write_field_attrib ( + f, + field_name, + attrib_name, + H5T_NATIVE_CHAR, + value, + strlen(value) + 1)); } /*! @@ -401,14 +402,14 @@ H5BlockReadFieldAttribString ( const char *attrib_name, /*!< IN: attribute name */ char *buffer /*!< OUT: attribute value */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_read_field_attrib ( - f, - field_name, - attrib_name, - H5_STRING_T, - (void*)buffer); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN ( + h5_read_field_attrib ( + f, + field_name, + attrib_name, + H5_STRING_T, + (void*)buffer)); } /*! @@ -423,9 +424,8 @@ H5BlockGetNumFieldAttribs ( h5_file_t *const f, /*myproc); - h5_ssize_t num = h5t_get_num_vertices (f, -1); - H5_API_RETURN (num); + H5_API_ENTER (h5_ssize_t); + H5_API_RETURN (h5t_get_num_vertices (f, -1)); } /*! @@ -103,9 +97,8 @@ H5FedGetNumVerticesCnode ( h5_file_t* const f, const h5_id_t cnode ) { - H5_API_ENTER; - h5_ssize_t num = h5t_get_num_vertices (f, cnode); - H5_API_RETURN (num); + H5_API_ENTER (h5_ssize_t); + H5_API_RETURN (h5t_get_num_vertices (f, cnode)); } /*! @@ -120,9 +113,8 @@ h5_ssize_t H5FedGetNumVerticesTotal ( h5_file_t* const f ) { - H5_API_ENTER; - h5_ssize_t num = h5t_get_num_vertices (f, -1); - H5_API_RETURN (num); + H5_API_ENTER (h5_ssize_t); + H5_API_RETURN (h5t_get_num_vertices (f, -1)); } /*! @@ -137,11 +129,10 @@ h5_ssize_t H5FedGetNumElements ( h5_file_t* const f ) { - H5_API_ENTER; + H5_API_ENTER (h5_ssize_t); // MLH: can't use field from opaque h5_file_t! //h5_ssize_t num = h5t_get_num_elems (f, f->myproc); - h5_ssize_t num = h5t_get_num_elems (f, -1); - H5_API_RETURN (num); + H5_API_RETURN (h5t_get_num_elems (f, -1)); } /*! @@ -158,9 +149,8 @@ H5FedGetNumElementsCnode ( h5_file_t* const f, const h5_id_t cnode ) { - H5_API_ENTER; - h5_ssize_t num = h5t_get_num_elems (f, cnode); - H5_API_RETURN (num); + H5_API_ENTER (h5_ssize_t); + H5_API_RETURN (h5t_get_num_elems (f, cnode)); } /*! Returns the number of elements present in the mesh @@ -174,7 +164,6 @@ h5_ssize_t H5FedGetNumElementsTotal ( h5_file_t* const f ) { - H5_API_ENTER; - h5_ssize_t num = h5t_get_num_elems (f, -1); - H5_API_RETURN (num); + H5_API_ENTER (h5_ssize_t); + H5_API_RETURN (h5t_get_num_elems (f, -1)); } diff --git a/src/C/H5Fed_retrieve.c b/src/C/H5Fed_retrieve.c index 035ad57..bf01121 100644 --- a/src/C/H5Fed_retrieve.c +++ b/src/C/H5Fed_retrieve.c @@ -31,27 +31,27 @@ \return H5_SUCCESS or error code */ -h5t_iterator_t* +h5t_iterator_p H5FedBeginTraverseEntities ( h5_file_t* const f, const int codim ) { - H5_API_ENTER; - h5t_iterator_t* iter; - TRY2( iter = h5_calloc (f, 1, sizeof (*iter)) ); - TRY2( h5t_init_leaf_iterator (f, iter, codim) ); + H5_API_ENTER (h5t_iterator_p); + h5t_iterator_p iter; + TRY2 (iter = h5_calloc (1, sizeof (*iter))); + TRY2 (h5t_init_leaf_iterator (f, iter, codim)); H5_API_RETURN (iter); } -h5t_iterator_t* +h5t_iterator_p H5FedBeginTraverseBoundaryFaces ( h5_file_t* const f, const int codim ) { - H5_API_ENTER; - h5t_iterator_t* iter; - TRY2( iter = h5_calloc (f, 1, sizeof (*iter)) ); - TRY2( h5t_init_boundary_face_iterator (f, iter, codim) ); + H5_API_ENTER (h5t_iterator_p); + h5t_iterator_p iter; + TRY2 (iter = h5_calloc (1, sizeof (*iter))); + TRY2 (h5t_init_boundary_face_iterator (f, iter, codim)); H5_API_RETURN (iter); } @@ -70,9 +70,8 @@ H5FedTraverseEntities ( h5_file_t* const f, h5t_iterator_t* iter ) { - H5_API_ENTER; - h5_loc_id_t id = h5t_iterate_entities (f, iter); - H5_API_RETURN (id); + H5_API_ENTER (h5_loc_id_t); + H5_API_RETURN (h5t_iterate_entities (f, iter)); } /*! @@ -88,9 +87,8 @@ H5FedEndTraverseEntities ( h5_file_t* const f, h5t_iterator_t* iter ) { - H5_API_ENTER; - h5_err_t h5err = h5t_release_entity_iterator (f, iter); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_release_entity_iterator (f, iter)); } @@ -109,9 +107,8 @@ H5FedGetVertexCoordsByIndex ( h5_loc_idx_t vertex_index, h5_float64_t P[3] ) { - H5_API_ENTER; - h5_err_t h5err = h5t_get_vertex_coords_by_index (f, vertex_index, P); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_get_vertex_coords_by_index (f, vertex_index, P)); } h5_err_t @@ -120,9 +117,8 @@ H5FedGetVertexCoordsByID ( h5_loc_id_t vertex_id, h5_float64_t P[3] ) { - H5_API_ENTER; - h5_err_t h5err = h5t_get_vertex_coords_by_id (f, vertex_id, P); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_get_vertex_coords_by_id (f, vertex_id, P)); } h5_err_t @@ -131,9 +127,8 @@ H5FedGetVertexIndicesOfEdge ( h5_loc_id_t entity_id, h5_loc_idx_t* vertex_indices ) { - H5_API_ENTER; - h5_err_t h5err = h5t_get_vertex_indices_of_edge (f, entity_id, vertex_indices); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_get_vertex_indices_of_edge (f, entity_id, vertex_indices)); } h5_err_t @@ -142,9 +137,8 @@ H5FedGetVertexIndicesOfTriangle ( h5_loc_id_t entity_id, h5_loc_idx_t* vertex_indices ) { - H5_API_ENTER; - h5_err_t h5err = h5t_get_vertex_indices_of_triangle (f, entity_id, vertex_indices); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_get_vertex_indices_of_triangle (f, entity_id, vertex_indices)); } h5_err_t @@ -153,9 +147,8 @@ H5FedGetVertexIndicesOfTet ( h5_loc_id_t entity_id, h5_loc_idx_t* vertex_indices ) { - H5_API_ENTER - h5_err_t h5err = h5t_get_vertex_indices_of_tet (f, entity_id, vertex_indices); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_get_vertex_indices_of_tet (f, entity_id, vertex_indices)); } h5_err_t @@ -164,9 +157,8 @@ H5FedGetVertexIndicesOfEntity ( h5_loc_id_t entity_id, h5_loc_idx_t* vertex_indices ) { - H5_API_ENTER; - h5_err_t h5err = h5t_get_vertex_indices_of_entity (f, entity_id, vertex_indices); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_get_vertex_indices_of_entity (f, entity_id, vertex_indices)); } diff --git a/src/C/H5Fed_store.c b/src/C/H5Fed_store.c index eca9930..57547aa 100644 --- a/src/C/H5Fed_store.c +++ b/src/C/H5Fed_store.c @@ -22,9 +22,8 @@ H5FedAddMesh ( h5_file_t* const f, const h5_oid_t mesh_type_id ) { - H5_API_ENTER; - h5_id_t id = h5t_add_mesh (f, mesh_type_id); - H5_API_RETURN (id); + H5_API_ENTER (h5_id_t); + H5_API_RETURN (h5t_add_mesh (f, mesh_type_id)); } /*! @@ -51,9 +50,8 @@ h5t_lvl_idx_t H5FedAddLevel ( h5_file_t* const f ) { - H5_API_ENTER; - h5t_lvl_idx_t idx = h5t_add_level (f); - H5_API_RETURN (idx); + H5_API_ENTER (h5t_lvl_idx_t); + H5_API_RETURN (h5t_add_level (f)); } h5_err_t @@ -61,9 +59,8 @@ H5FedBeginStoreVertices ( h5_file_t* const f, const h5_size_t num ) { - H5_API_ENTER; - h5_err_t h5err = h5t_begin_store_vertices (f, num); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_begin_store_vertices (f, num)); } /*! @@ -81,27 +78,22 @@ H5FedStoreVertex ( const h5_glb_id_t vertex_id, /*!< id from mesher or -1 */ const h5_float64_t P[3] /*!< coordinates */ ) { - - H5_API_ENTER; - h5_loc_idx_t idx; + H5_API_ENTER (h5_loc_idx_t); if (h5t_get_level (f) != 0) { - idx = h5_error ( - f, - H5_ERR_INVAL, - "Vertices can be added to level 0 only!"); - goto done; + H5_API_LEAVE ( + h5_error ( + H5_ERR_INVAL, + "Vertices can be added to level 0 only!")); } - idx = h5t_store_vertex (f, vertex_id, P); - H5_API_RETURN (idx); + H5_API_RETURN (h5t_store_vertex (f, vertex_id, P)); } h5_err_t H5FedEndStoreVertices ( h5_file_t* const f ) { - H5_API_ENTER; - h5_err_t h5err = h5t_end_store_vertices (f); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_end_store_vertices (f)); } h5_err_t @@ -109,9 +101,8 @@ H5FedBeginStoreElements ( h5_file_t* const f, const h5_size_t num ) { - H5_API_ENTER; - h5_err_t h5err = h5t_begin_store_elems (f, num); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_begin_store_elems (f, num)); } /*! @@ -133,34 +124,30 @@ H5FedStoreElement ( h5_file_t* const f, /*!< file handle */ const h5_loc_idx_t local_vids[] /*!< tuple with vertex id's */ ) { - H5_API_ENTER; - h5_loc_idx_t idx; + H5_API_ENTER (h5_loc_idx_t); if (h5t_get_level (f) != 0) { - idx = h5_error ( - f, - H5_ERR_INVAL, - "Elements can be added to level 0 only!"); + H5_API_LEAVE ( + h5_error ( + H5_ERR_INVAL, + "Elements can be added to level 0 only!")); } - idx = h5t_store_elem ( f, -1, local_vids ); - H5_API_RETURN (idx); + H5_API_RETURN (h5t_store_elem (f, -1, local_vids)); } h5_err_t H5FedEndStoreElements ( h5_file_t* const f ) { - H5_API_ENTER; - h5_err_t h5err = h5t_end_store_elems (f); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_end_store_elems (f)); } h5_err_t H5FedBeginRefineElements ( h5_file_t* const f ) { - H5_API_ENTER; - h5_err_t h5err = h5t_begin_refine_elems (f); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_begin_refine_elems (f)); } h5_loc_idx_t @@ -168,16 +155,14 @@ H5FedRefineElement ( h5_file_t* const f, /*!< file handle */ const h5_loc_id_t local_eid /*!< local element id */ ) { - H5_API_ENTER; - h5_err_t h5err = h5t_mark_entity (f, local_eid); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_loc_idx_t); + H5_API_RETURN (h5t_mark_entity (f, local_eid)); } h5_err_t H5FedEndRefineElements ( h5_file_t* const f ) { - H5_API_ENTER; - h5_err_t h5err = h5t_end_refine_elems (f); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_end_refine_elems (f)); } diff --git a/src/C/H5Fed_tags.c b/src/C/H5Fed_tags.c index 1ffbafe..636df2d 100644 --- a/src/C/H5Fed_tags.c +++ b/src/C/H5Fed_tags.c @@ -29,9 +29,8 @@ H5FedAddMTagset ( char* name, h5_id_t type ) { - H5_API_ENTER; - h5_err_t h5err = h5t_add_mtagset (f, name, type); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_add_mtagset (f, name, type)); } /*! @@ -47,9 +46,8 @@ H5FedRemoveMTagset ( h5_file_t* const f, char name[] ) { - H5_API_ENTER; - h5_err_t h5err = h5t_remove_mtagset (f, name ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_remove_mtagset (f, name)); } /*! @@ -65,9 +63,8 @@ H5FedGetMTagsets ( h5_file_t* const f, char** names[] ) { - H5_API_ENTER; - h5_ssize_t num = h5t_get_mtagsets (f, names); - H5_API_RETURN (num); + H5_API_ENTER (h5_ssize_t); + H5_API_RETURN (h5t_get_mtagsets (f, names)); } /*! @@ -83,9 +80,8 @@ H5FedGetTypeOfMTagset ( h5_file_t* const f, char name[] ) { - H5_API_ENTER; - h5_id_t id = h5t_get_mtagset_type_by_name (f, name); - H5_API_RETURN (id); + H5_API_ENTER (h5_id_t); + H5_API_RETURN (h5t_get_mtagset_type_by_name (f, name)); } /*! @@ -107,9 +103,8 @@ H5FedSetMTag ( const size_t dims, void* val ) { - H5_API_ENTER; - h5_err_t h5err = h5t_set_mtag_by_name (f, name, id, dims, val); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_set_mtag_by_name (f, name, id, dims, val)); } /*! @@ -131,9 +126,8 @@ H5FedGetMTag ( size_t* dim, void* vals ) { - H5_API_ENTER; - h5_err_t h5err = h5t_get_mtag_by_name (f, name, id, dim, vals); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_get_mtag_by_name (f, name, id, dim, vals)); } /*! @@ -149,7 +143,6 @@ H5FedRemoveMTag ( const char name[], const h5_loc_id_t id ) { - H5_API_ENTER; - h5_err_t h5err = h5t_remove_mtag_by_name (f, name, id); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5t_remove_mtag_by_name (f, name, id)); } diff --git a/src/C/H5Part.c b/src/C/H5Part.c index e2429f5..76f6e87 100644 --- a/src/C/H5Part.c +++ b/src/C/H5Part.c @@ -49,10 +49,9 @@ H5PartSetNumParticles ( h5_file_t *f, /*!< [in] Handle to open file */ h5_size_t nparticles /*!< [in] Number of particles */ ) { - H5_API_ENTER; + H5_API_ENTER (h5_err_t); h5_size_t stride = 1; - h5_err_t h5err = h5u_set_num_particles( f, nparticles, stride ); - H5_API_RETURN (h5err); + H5_API_RETURN (h5u_set_num_particles(f, nparticles, stride)); } /*! @@ -88,9 +87,8 @@ H5PartSetNumParticlesStrided ( h5_size_t nparticles, /*!< [in] Number of particles */ h5_size_t stride /*!< [in] Stride value (e.g. number of fields in the particle array) */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_set_num_particles( f, nparticles, stride ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_set_num_particles (f, nparticles, stride)); } /*! @@ -111,9 +109,8 @@ H5PartSetChunk ( h5_file_t *f, h5_size_t size ) { - H5_API_ENTER; - h5_err_t h5err = h5u_set_chunk( f, size ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_set_chunk (f, size)); } /*! @@ -148,9 +145,8 @@ H5PartWriteDataFloat64 ( const char *name, /*!< [in] Name to associate array with */ const h5_float64_t *data /*!< [in] Array to commit to disk */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_write_data( f, name, (void*)data, H5T_NATIVE_DOUBLE ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_write_data (f, name, (void*)data, H5T_NATIVE_DOUBLE)); } /*! @@ -185,7 +181,7 @@ H5PartWriteDataFloat32 ( const char *name, /*!< [in] Name to associate array with */ const h5_float32_t *data /*!< [in] Array to commit to disk */ ) { - H5_API_ENTER; + H5_API_ENTER (h5_err_t); h5_err_t h5err = h5u_write_data( f, name, (void*)data, H5T_NATIVE_FLOAT ); H5_API_RETURN (h5err); } @@ -222,9 +218,8 @@ H5PartWriteDataInt64 ( const char *name, /*!< [in] Name to associate array with */ const h5_int64_t *data /*!< [in] Array to commit to disk */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_write_data ( f, name, (void*)data, H5T_NATIVE_INT64 ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_write_data (f, name, (void*)data, H5T_NATIVE_INT64)); } /*! @@ -259,9 +254,8 @@ H5PartWriteDataInt32 ( const char *name, /*!< [in] Name to associate array with */ const h5_int32_t *data /*!< [in] Array to commit to disk */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_write_data ( f, name, (void*)data, H5T_NATIVE_INT32 ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_write_data (f, name, (void*)data, H5T_NATIVE_INT32)); } /*! @@ -282,9 +276,8 @@ H5PartReadDataFloat64 ( const char *name, /*!< [in] Name to associate dataset with */ h5_float64_t *data /*!< [out] Array of data */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_read_data ( f, name, data, H5T_NATIVE_DOUBLE ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_read_data (f, name, data, H5T_NATIVE_DOUBLE)); } /*! @@ -305,9 +298,8 @@ H5PartReadDataFloat32 ( const char *name, /*!< [in] Name to associate dataset with */ h5_float32_t *data /*!< [out] Array of data */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_read_data ( f, name, data, H5T_NATIVE_FLOAT ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_read_data (f, name, data, H5T_NATIVE_FLOAT)); } /*! @@ -328,9 +320,8 @@ H5PartReadDataInt64 ( const char *name, /*!< [in] Name to associate dataset with */ h5_int64_t *data /*!< [out] Array of data */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_read_data ( f, name, data, H5T_NATIVE_INT64 ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_read_data (f, name, data, H5T_NATIVE_INT64)); } /*! @@ -351,9 +342,8 @@ H5PartReadDataInt32 ( const char *name, /*!< [in] Name to associate dataset with */ h5_int32_t *data /*!< [out] Array of data */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_read_data ( f, name, data, H5T_NATIVE_INT32 ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_read_data (f, name, data, H5T_NATIVE_INT32)); } /*! @@ -368,9 +358,8 @@ h5_ssize_t H5PartGetNumDatasets ( h5_file_t *f /*!< [in] Handle to open file */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_get_num_datasets(f); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_get_num_datasets(f)); } /*! @@ -390,9 +379,8 @@ H5PartGetDatasetName ( char *name, /*!< [out] Name of dataset */ const h5_size_t len /*!< [in] Size of buffer \c name */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_get_dataset_info(f, idx, name, len, NULL, NULL); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_get_dataset_info(f, idx, name, len, NULL, NULL)); } /*! @@ -420,9 +408,8 @@ H5PartGetDatasetInfo ( h5_int64_t *type, /*!< [out] Type of data in dataset */ h5_size_t *nelem /*!< [out] Number of elements. */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_get_dataset_info(f, idx, dataset_name, len_dataset_name, type, nelem); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_get_dataset_info(f, idx, dataset_name, len_dataset_name, type, nelem)); } /*! @@ -450,10 +437,9 @@ h5_ssize_t H5PartGetNumParticles ( h5_file_t *f /*!< [in] Handle to open file */ ) { - H5_API_ENTER; + H5_API_ENTER (h5_ssize_t); CHECK_FILEHANDLE( f ); - h5_ssize_t nparticels = h5u_get_num_particles( f ); - H5_API_RETURN (nparticels); + H5_API_RETURN (h5u_get_num_particles (f)); } /*! @@ -467,9 +453,8 @@ h5_err_t H5PartResetView ( h5_file_t *f /*!< [in] Handle to open file */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_reset_view ( f ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_reset_view (f)); } /*! @@ -485,9 +470,8 @@ h5_err_t H5PartHasView ( h5_file_t *f /*!< [in] Handle to open file */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_has_view ( f ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_has_view (f)); } /*! @@ -517,9 +501,8 @@ H5PartSetView ( h5_int64_t start, /*!< [in] Start particle */ h5_int64_t end /*!< [in] End particle */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_set_view ( f, start, end ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_set_view (f, start, end)); } /*! @@ -546,9 +529,8 @@ H5PartSetViewIndices ( const h5_id_t *indices, /*!< [in] List of indices */ h5_size_t nelems /*!< [in] Size of list */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_set_view_indices ( f, indices, nelems ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_set_view_indices (f, indices, nelems)); } /*! @@ -567,9 +549,8 @@ H5PartGetView ( h5_int64_t *start, /*!< [out] Start particle */ h5_int64_t *end /*!< [out] End particle */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_get_view( f, start, end ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_get_view (f, start, end)); } /*! @@ -586,8 +567,7 @@ h5_err_t H5PartSetCanonicalView ( h5_file_t *f /*!< [in] Handle to open file */ ) { - H5_API_ENTER; - h5_err_t h5err = h5u_set_canonical_view( f ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5u_set_canonical_view (f)); } diff --git a/src/C/H5_attribs.c b/src/C/H5_attribs.c index c76ac08..fca426c 100644 --- a/src/C/H5_attribs.c +++ b/src/C/H5_attribs.c @@ -20,15 +20,14 @@ H5WriteFileAttribString ( const char *name, /*!< [in] Name of attribute to create */ const char *value /*!< [in] Value of attribute */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_write_attrib ( - f, - H5_ATTRIB_FILE, - name, - H5T_NATIVE_CHAR, - value, - strlen(value) + 1 ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_write_attrib ( + f, + H5_ATTRIB_FILE, + name, + H5T_NATIVE_CHAR, + value, + strlen(value) + 1 )); } /*! @@ -45,15 +44,14 @@ H5WriteStepAttribString ( const char *name, /*!< [in] Name of attribute to create */ const char *value /*!< [in] Value of attribute */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_write_attrib ( - f, - H5_ATTRIB_STEP, - name, - H5T_NATIVE_CHAR, - value, - strlen(value) + 1 ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_write_attrib ( + f, + H5_ATTRIB_STEP, + name, + H5T_NATIVE_CHAR, + value, + strlen(value) + 1 )); } /*! @@ -71,15 +69,14 @@ H5WriteFileAttribFloat32 ( const h5_float32_t *values, /*!< [in] Values of attribute */ const h5_size_t nelems /*!< [in] Number of values */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_write_attrib ( - f, - H5_ATTRIB_FILE, - name, - H5T_NATIVE_FLOAT, - values, - nelems ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_write_attrib ( + f, + H5_ATTRIB_FILE, + name, + H5T_NATIVE_FLOAT, + values, + nelems )); } /*! @@ -97,15 +94,14 @@ H5WriteStepAttribFloat32 ( const h5_float32_t *values, /*!< [in] Values of attribute */ const h5_size_t nelems /*!< [in] Number of values */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_write_attrib ( - f, - H5_ATTRIB_STEP, - name, - H5T_NATIVE_FLOAT, - values, - nelems ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_write_attrib ( + f, + H5_ATTRIB_STEP, + name, + H5T_NATIVE_FLOAT, + values, + nelems )); } /*! @@ -123,15 +119,14 @@ H5WriteFileAttribFloat64 ( const h5_float64_t *values, /*!< [in] Values of attribute */ const h5_size_t nelems /*!< [in] Number of values */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_write_attrib ( - f, - H5_ATTRIB_FILE, - name, - H5T_NATIVE_DOUBLE, - values, - nelems ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_write_attrib ( + f, + H5_ATTRIB_FILE, + name, + H5T_NATIVE_DOUBLE, + values, + nelems)); } /*! @@ -149,15 +144,14 @@ H5WriteStepAttribFloat64 ( const h5_float64_t *values, /*!< [in] Values of attribute */ const h5_size_t nelems /*!< [in] Number of values */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_write_attrib ( - f, - H5_ATTRIB_STEP, - name, - H5T_NATIVE_DOUBLE, - values, - nelems ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_write_attrib ( + f, + H5_ATTRIB_STEP, + name, + H5T_NATIVE_DOUBLE, + values, + nelems)); } /*! @@ -175,15 +169,14 @@ H5WriteFileAttribInt32 ( const h5_int32_t *values, /*!< [in] Values of attribute */ const h5_size_t nelems /*!< [in] Number of values */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_write_attrib ( - f, - H5_ATTRIB_FILE, - name, - H5T_NATIVE_INT32, - values, - nelems ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_write_attrib ( + f, + H5_ATTRIB_FILE, + name, + H5T_NATIVE_INT32, + values, + nelems)); } /*! @@ -201,15 +194,14 @@ H5WriteStepAttribInt32 ( const h5_int32_t *values, /*!< [in] Values of attribute */ const h5_size_t nelems /*!< [in] Number of values */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_write_attrib ( - f, - H5_ATTRIB_STEP, - name, - H5T_NATIVE_INT32, - values, - nelems ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_write_attrib ( + f, + H5_ATTRIB_STEP, + name, + H5T_NATIVE_INT32, + values, + nelems)); } /*! @@ -227,15 +219,14 @@ H5WriteFileAttribInt64 ( const h5_int64_t *values, /*!< [in] Values of attribute */ const h5_size_t nelems /*!< [in] Number of values */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_write_attrib ( - f, - H5_ATTRIB_FILE, - name, - H5T_NATIVE_INT64, - values, - nelems ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_write_attrib ( + f, + H5_ATTRIB_FILE, + name, + H5T_NATIVE_INT64, + values, + nelems)); } /*! @@ -253,15 +244,14 @@ H5WriteStepAttribInt64 ( const h5_int64_t *values, /*!< [in] Values of attribute */ const h5_size_t nelems /*!< [in] Number of values */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_write_attrib ( - f, - H5_ATTRIB_STEP, - name, - H5T_NATIVE_INT64, - values, - nelems ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_write_attrib ( + f, + H5_ATTRIB_STEP, + name, + H5T_NATIVE_INT64, + values, + nelems)); } /*** READ ***/ @@ -280,14 +270,13 @@ H5ReadFileAttribString ( const char *name, /*!< [in] Name of attribute to create */ char *buffer /*!< [out] Value of attribute */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_read_attrib ( - f, - H5_ATTRIB_FILE, - name, - H5_STRING_T, - (void*)buffer); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_read_attrib ( + f, + H5_ATTRIB_FILE, + name, + H5_STRING_T, + (void*)buffer)); } /*! @@ -304,14 +293,13 @@ H5ReadStepAttribString ( const char *name, /*!< [in] Name of attribute to create */ char *buffer /*!< [out] Value of attribute */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_read_attrib ( - f, - H5_ATTRIB_STEP, - name, - H5_STRING_T, - (void*)buffer); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_read_attrib ( + f, + H5_ATTRIB_STEP, + name, + H5_STRING_T, + (void*)buffer)); } /*! @@ -328,14 +316,13 @@ H5ReadFileAttribInt32 ( const char *name, /*!< [in] Name of attribute to create */ h5_int32_t *buffer /*!< [out] Values of attribute */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_read_attrib ( - f, - H5_ATTRIB_FILE, - name, - H5_INT32_T, - (void*)buffer); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_read_attrib ( + f, + H5_ATTRIB_FILE, + name, + H5_INT32_T, + (void*)buffer)); } /*! @@ -352,14 +339,13 @@ H5ReadStepAttribInt32 ( const char *name, /*!< [in] Name of attribute to create */ h5_int32_t *buffer /*!< [out] Values of attribute */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_read_attrib ( - f, - H5_ATTRIB_STEP, - name, - H5_INT32_T, - (void*)buffer); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_read_attrib ( + f, + H5_ATTRIB_STEP, + name, + H5_INT32_T, + (void*)buffer)); } /*! @@ -376,14 +362,13 @@ H5ReadFileAttribInt64 ( const char *name, /*!< [in] Name of attribute to create */ h5_int64_t *buffer /*!< [out] Values of attribute */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_read_attrib ( - f, - H5_ATTRIB_FILE, - name, - H5_INT64_T, - (void*)buffer); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_read_attrib ( + f, + H5_ATTRIB_FILE, + name, + H5_INT64_T, + (void*)buffer)); } /*! @@ -400,7 +385,7 @@ H5ReadStepAttribInt64 ( const char *name, /*!< [in] Name of attribute to create */ h5_int64_t *buffer /*!< [out] Values of attribute */ ) { - H5_API_ENTER; + H5_API_ENTER (h5_err_t); h5_err_t h5err = h5_read_attrib ( f, H5_ATTRIB_STEP, @@ -424,14 +409,13 @@ H5ReadFileAttribFloat32 ( const char *name, /*!< [in] Name of attribute to create */ h5_float32_t *buffer /*!< [out] Values of attribute */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_read_attrib ( - f, - H5_ATTRIB_FILE, - name, - H5_FLOAT32_T, - (void*)buffer); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_read_attrib ( + f, + H5_ATTRIB_FILE, + name, + H5_FLOAT32_T, + (void*)buffer)); } /*! @@ -448,14 +432,13 @@ H5ReadStepAttribFloat32 ( const char *name, /*!< [in] Name of attribute to create */ h5_float32_t *buffer /*!< [out] Values of attribute */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_read_attrib ( - f, - H5_ATTRIB_STEP, - name, - H5_FLOAT32_T, - (void*)buffer); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_read_attrib ( + f, + H5_ATTRIB_STEP, + name, + H5_FLOAT32_T, + (void*)buffer)); } /*! @@ -472,14 +455,13 @@ H5ReadFileAttribFloat64 ( const char *name, /*!< [in] Name of attribute to create */ h5_float64_t *buffer /*!< [out] Values of attribute */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_read_attrib ( - f, - H5_ATTRIB_FILE, - name, - H5_FLOAT64_T, - (void*)buffer); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_read_attrib ( + f, + H5_ATTRIB_FILE, + name, + H5_FLOAT64_T, + (void*)buffer)); } /*! @@ -496,14 +478,13 @@ H5ReadStepAttribFloat64 ( const char *name, /*!< [in] Name of attribute to create */ h5_float64_t *buffer /*!< [out] Values of attribute */ ) { - H5_API_ENTER; - h5_err_t h5err = h5_read_attrib ( - f, - H5_ATTRIB_STEP, - name, - H5_FLOAT64_T, - (void*)buffer); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_read_attrib ( + f, + H5_ATTRIB_STEP, + name, + H5_FLOAT64_T, + (void*)buffer)); } /*** QUERY ***/ @@ -519,9 +500,8 @@ h5_int64_t H5GetNumFileAttribs ( h5_file_t *const f /*!< [in] Handle to open file */ ) { - H5_API_ENTER; - h5_int64_t nattribs = h5_get_num_attribs ( f, H5_ATTRIB_FILE ); - H5_API_RETURN (nattribs); + H5_API_ENTER (h5_int64_t); + H5_API_RETURN (h5_get_num_attribs (f, H5_ATTRIB_FILE)); } /*! @@ -535,9 +515,8 @@ h5_int64_t H5GetNumStepAttribs ( h5_file_t *const f /*!< [in] Handle to open file */ ) { - H5_API_ENTER; - h5_int64_t nattribs = h5_get_num_attribs ( f, H5_ATTRIB_STEP ); - H5_API_RETURN (nattribs); + H5_API_ENTER (h5_int64_t); + H5_API_RETURN (h5_get_num_attribs (f, H5_ATTRIB_STEP)); } @@ -555,7 +534,7 @@ H5GetNumStepAttribs ( \return \c H5_SUCCESS or error code */ -h5_int64_t +h5_err_t H5GetFileAttribInfo ( h5_file_t *const f, /*!< [in] Handle to open file */ const h5_size_t attrib_idx, /*!< [in] Index of attribute to get @@ -566,16 +545,15 @@ H5GetFileAttribInfo ( h5_int64_t *attrib_type, /*!< [out] Type of value. */ h5_size_t *attrib_nelem /*!< [out] Number of elements */ ) { - H5_API_ENTER; - h5_int64_t h5err = h5_get_attrib_info ( - f, - H5_ATTRIB_FILE, - attrib_idx, - attrib_name, - len_of_attrib_name, - attrib_type, - attrib_nelem ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_int64_t); + H5_API_RETURN (h5_get_attrib_info ( + f, + H5_ATTRIB_FILE, + attrib_idx, + attrib_name, + len_of_attrib_name, + attrib_type, + attrib_nelem)); } /*! @@ -591,7 +569,7 @@ H5GetFileAttribInfo ( \return \c H5_SUCCESS or error code */ -h5_int64_t +h5_err_t H5GetStepAttribInfo ( h5_file_t *const f, /*!< [in] Handle to open file */ const h5_size_t attrib_idx, /*!< [in] Index of attribute to @@ -602,15 +580,14 @@ H5GetStepAttribInfo ( h5_int64_t *attrib_type, /*!< [out] Type of value. */ h5_size_t *attrib_nelem /*!< [out] Number of elements */ ) { - H5_API_ENTER; - h5_int64_t h5err = h5_get_attrib_info ( - f, - H5_ATTRIB_STEP, - attrib_idx, - attrib_name, - len_of_attrib_name, - attrib_type, - attrib_nelem ); - H5_API_RETURN (h5err); + H5_API_ENTER (h5_err_t); + H5_API_RETURN (h5_get_attrib_info ( + f, + H5_ATTRIB_STEP, + attrib_idx, + attrib_name, + len_of_attrib_name, + attrib_type, + attrib_nelem)); } diff --git a/src/h5core/h5_attribs.c b/src/h5core/h5_attribs.c index 55b3e4b..97ad7b4 100644 --- a/src/h5core/h5_attribs.c +++ b/src/h5core/h5_attribs.c @@ -10,7 +10,7 @@ get_hdf5_obj_id( if (mode == H5_ATTRIB_FILE) *id = f->root_gid; else if (mode == H5_ATTRIB_STEP) *id = f->step_gid; else if (mode == H5_ATTRIB_FIELD) *id = f->b->field_gid; - else h5_error(f, H5_ERR_INVAL, "Attibute flag not recognized"); + else h5_error(H5_ERR_INVAL, "Attibute flag not recognized"); return H5_SUCCESS; } @@ -22,29 +22,30 @@ h5priv_read_attrib ( const hid_t attrib_type, /*!< HDF5 type of attribute */ void* const attrib_value /*!< OUT: attribute value */ ) { + H5_PRIV_API_ENTER (h5_err_t); hid_t attrib_id; hid_t type_id; hid_t space_id; - TRY( attrib_id = h5priv_open_hdf5_attribute (f, id, attrib_name) ); - TRY( type_id = h5priv_get_hdf5_attribute_type (f, attrib_id) ); + TRY (attrib_id = hdf5_open_attribute (id, attrib_name)); + TRY (type_id = hdf5_get_attribute_type (attrib_id)); hid_t h5type_id; - TRY( h5type_id = h5_normalize_h5_type(f, type_id) ); - if ( h5type_id != attrib_type ) - return h5_error ( - f, - H5_ERR_HDF5, - "Attribute '%s' has type '%s' but was requested as '%s'.", - attrib_name, - h5priv_get_base_type_name(f, h5type_id), - h5priv_get_base_type_name(f, attrib_type) ); + TRY (h5type_id = h5_normalize_h5_type (f, type_id)); + if (h5type_id != attrib_type) + H5_PRIV_API_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Attribute '%s' has type '%s' but was requested as '%s'.", + attrib_name, + hdf5_get_type_name (h5type_id), + hdf5_get_type_name (attrib_type))); - TRY( space_id = h5priv_get_hdf5_attribute_dataspace (f, attrib_id) ); - TRY( h5priv_read_hdf5_attribute (f, attrib_id, type_id, attrib_value) ); - TRY( h5priv_close_hdf5_dataspace(f, space_id) ); - TRY( h5priv_close_hdf5_type(f, type_id) ); - TRY( h5priv_close_hdf5_attribute (f, attrib_id) ); - return H5_SUCCESS; + TRY (space_id = hdf5_get_attribute_dataspace (attrib_id)); + TRY (hdf5_read_attribute (attrib_id, type_id, attrib_value)); + TRY (hdf5_close_dataspace(space_id)); + TRY (hdf5_close_type (type_id)); + TRY (hdf5_close_attribute (attrib_id)); + H5_PRIV_API_RETURN (H5_SUCCESS); } /*! @@ -64,13 +65,13 @@ h5_read_attrib ( const hid_t attrib_type, /*!< HDF5 type of attribute */ void* const attrib_value /*!< OUT: attribute value */ ) { + H5_CORE_API_ENTER (h5_err_t); if (mode != H5_ATTRIB_FILE) CHECK_TIMEGROUP( f ); hid_t id; - TRY( get_hdf5_obj_id(f, mode, &id) ); - TRY( h5priv_read_attrib (f, id, attrib_name, attrib_type, attrib_value) ); - - return H5_SUCCESS; + TRY (get_hdf5_obj_id(f, mode, &id)); + TRY (h5priv_read_attrib (f, id, attrib_name, attrib_type, attrib_value)); + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -82,37 +83,33 @@ h5priv_write_attrib ( const void* attrib_value, /*!< value of attribute */ const hsize_t attrib_nelem /*!< number of elements (dimension) */ ) { - + H5_PRIV_API_ENTER (h5_err_t); hid_t space_id; hid_t attrib_id; hid_t type_id; if ( attrib_type == H5T_NATIVE_CHAR ) { - TRY( type_id = h5priv_create_hdf5_string_type(f, - attrib_nelem) ); - TRY( space_id = h5priv_create_hdf5_dataspace_scalar(f) ); + TRY (type_id = hdf5_create_string_type (attrib_nelem)); + TRY (space_id = hdf5_create_dataspace_scalar ()); } else { type_id = attrib_type; - TRY( space_id = h5priv_create_hdf5_dataspace (f, - 1, &attrib_nelem, NULL) ); + TRY (space_id = hdf5_create_dataspace (1, &attrib_nelem, NULL)); } - TRY( attrib_id = h5priv_create_hdf5_attribute ( - f, + TRY (attrib_id = hdf5_create_attribute ( id, attrib_name, type_id, space_id, - H5P_DEFAULT, H5P_DEFAULT) ); + H5P_DEFAULT, H5P_DEFAULT)); - TRY( h5priv_write_hdf5_attribute (f, - attrib_id, type_id, attrib_value) ); - TRY( h5priv_close_hdf5_attribute (f, attrib_id) ); - TRY( h5priv_close_hdf5_dataspace (f, space_id) ); + TRY (hdf5_write_attribute (attrib_id, type_id, attrib_value)); + TRY (hdf5_close_attribute (attrib_id)); + TRY (hdf5_close_dataspace (space_id)); - if ( attrib_type == H5T_NATIVE_CHAR ) - TRY( h5priv_close_hdf5_type(f, type_id) ); + if (attrib_type == H5T_NATIVE_CHAR) + TRY (hdf5_close_type (type_id)); - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } /*! @@ -131,14 +128,15 @@ h5_write_attrib ( const void* attrib_value, /*!< value of attribute */ const hsize_t attrib_nelem /*!< number of elements (dimension) */ ) { + H5_CORE_API_ENTER (h5_err_t); if (mode != H5_ATTRIB_FILE) CHECK_TIMEGROUP( f ); CHECK_WRITABLE_MODE( f ); hid_t id; - TRY( get_hdf5_obj_id(f, mode, &id) ); - TRY( h5priv_write_attrib (f, id, attrib_name, attrib_type, - attrib_value, attrib_nelem) ); - return H5_SUCCESS; + TRY (get_hdf5_obj_id(f, mode, &id)); + TRY (h5priv_write_attrib (f, id, attrib_name, attrib_type, + attrib_value, attrib_nelem)); + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -151,34 +149,32 @@ h5priv_get_attrib_info ( h5_int64_t* attrib_type, /*!< OUT: H5 type of attribute */ h5_size_t* attrib_nelem /*!< OUT: number of elements */ ) { + H5_PRIV_API_ENTER (h5_err_t); hid_t attrib_id; hid_t mytype; hid_t space_id; - TRY( attrib_id = h5priv_open_hdf5_attribute_idx ( - f, + TRY (attrib_id = hdf5_open_attribute_idx ( id, - (unsigned int)attrib_idx) ); + (unsigned int)attrib_idx)); if (attrib_nelem) { - TRY( space_id = h5priv_get_hdf5_attribute_dataspace (f, attrib_id) ); - TRY( *attrib_nelem = h5priv_get_npoints_of_hdf5_dataspace ( - f, space_id) ); - TRY( h5priv_close_hdf5_dataspace (f, space_id) ); + TRY (space_id = hdf5_get_attribute_dataspace (attrib_id)); + TRY (*attrib_nelem = hdf5_get_npoints_of_dataspace (space_id)); + TRY (hdf5_close_dataspace (space_id)); } if (attrib_name) { - TRY( h5priv_get_hdf5_attribute_name ( - f, - attrib_id, - (size_t)len_attrib_name, - attrib_name) ); + TRY (hdf5_get_attribute_name ( + attrib_id, + (size_t)len_attrib_name, + attrib_name)); } if (attrib_type) { - TRY( mytype = h5priv_get_hdf5_attribute_type (f, attrib_id) ); - TRY( *attrib_type = h5_normalize_h5_type (f, mytype) ); - TRY( h5priv_close_hdf5_type(f, mytype) ); + TRY (mytype = hdf5_get_attribute_type (attrib_id)); + TRY (*attrib_type = h5_normalize_h5_type (f, mytype)); + TRY (hdf5_close_type (mytype)); } - TRY( h5priv_close_hdf5_attribute (f, attrib_id) ); - return H5_SUCCESS; + TRY (hdf5_close_attribute (attrib_id)); + H5_PRIV_API_RETURN (H5_SUCCESS); } /*! @@ -198,13 +194,14 @@ h5_get_attrib_info ( h5_int64_t* attrib_type, /*!< OUT: H5 type of attribute */ h5_size_t* attrib_nelem /*!< OUT: number of elements */ ) { + H5_CORE_API_ENTER (h5_err_t); if (mode != H5_ATTRIB_FILE) CHECK_TIMEGROUP( f ); hid_t id; - TRY( get_hdf5_obj_id(f, mode, &id) ); - TRY( h5priv_get_attrib_info (f, id, attrib_idx, attrib_name, len_attrib_name, - attrib_type, attrib_nelem) ); - return H5_SUCCESS; + TRY (get_hdf5_obj_id(f, mode, &id)); + TRY (h5priv_get_attrib_info (f, id, attrib_idx, attrib_name, len_attrib_name, + attrib_type, attrib_nelem)); + H5_CORE_API_RETURN (H5_SUCCESS); } /*! @@ -219,9 +216,10 @@ h5_get_num_attribs ( h5_file_t *const f, /*!< handle to open file */ const char mode /*!< FILE or STEP flag */ ) { + H5_CORE_API_ENTER (h5_ssize_t); if (mode != H5_ATTRIB_FILE) CHECK_TIMEGROUP( f ); hid_t id; - TRY( get_hdf5_obj_id(f, mode, &id) ); - return h5priv_get_num_hdf5_attribute (f, id); + TRY (get_hdf5_obj_id(f, mode, &id)); + H5_CORE_API_RETURN (hdf5_get_num_attribute (id)); } diff --git a/src/h5core/h5_core_private.h b/src/h5core/h5_core_private.h index 2cd6854..dd38489 100644 --- a/src/h5core/h5_core_private.h +++ b/src/h5core/h5_core_private.h @@ -1,19 +1,62 @@ #ifndef __H5_CORE_PRIVATE_H #define __H5_CORE_PRIVATE_H -#define H5_CORE_API_ENTER { \ - h5_debug (f, "%s", " "); \ - } \ +#define H5_CORE_API_ENTER(type) __FUNC_ENTER(type) +#define H5_CORE_API_ENTER1(type, fmt, a1) \ + __FUNC_ENTER1(type, fmt, a1, H5_DEBUG_CORE_API) +#define H5_CORE_API_ENTER2(type, fmt, a1, a2) \ + __FUNC_ENTER2(type, fmt, a1, a2, H5_DEBUG_CORE_API) +#define H5_CORE_API_ENTER3(type, fmt, a1, a2, a3) \ + __FUNC_ENTER3(type, fmt, a1, a2, a3, H5_DEBUG_CORE_API) +#define H5_CORE_API_LEAVE(value) __FUNC_LEAVE(value) +#define H5_CORE_API_RETURN(value) __FUNC_RETURN(value, H5_DEBUG_CORE_API) -#define H5_CORE_API_RETURN(retval) \ - \ - goto done; \ -done: \ - return (retval); \ +#define H5_PRIV_API_ENTER(type) __FUNC_ENTER(type) +#define H5_PRIV_API_ENTER1(type, fmt, a1) \ + __FUNC_ENTER1(type, fmt, a1, H5_DEBUG_PRIV_API) +#define H5_PRIV_API_ENTER2(type, fmt, a1, a2) \ + __FUNC_ENTER2(type, fmt, a1, a2, H5_DEBUG_PRIV_API) +#define H5_PRIV_API_ENTER3(type, fmt, a1, a2, a3) \ + __FUNC_ENTER3(type, fmt, a1, a2, a3, H5_DEBUG_PRIV_API) +#define H5_PRIV_API_LEAVE(value) __FUNC_LEAVE(value) +#define H5_PRIV_API_RETURN(value) __FUNC_RETURN(value, H5_DEBUG_PRIV_API) -#define H5_GOTO_DONE( ret_val) \ - ret_value = ret_val; \ - goto done; \ +#define H5_PRIV_FUNC_ENTER(type) __FUNC_ENTER(type) +#define H5_PRIV_FUNC_ENTER1(type, fmt, a1) \ + __FUNC_ENTER1(type, fmt, a1, H5_DEBUG_PRIV_FUNC) +#define H5_PRIV_FUNC_ENTER2(type, fmt, a1, a2) \ + __FUNC_ENTER2(type, fmt, a1, a2, H5_DEBUG_PRIV_FUNC) +#define H5_PRIV_FUNC_ENTER3(type, fmt, a1, a2, a3) \ + __FUNC_ENTER3(type, fmt,a1, a2, a3, H5_DEBUG_PRIV_FUNC) +#define H5_PRIV_FUNC_ENTER4(type, fmt, a1, a2, a3, a4) \ + __FUNC_ENTER4(type, fmt,a1, a2, a3, a4, H5_DEBUG_PRIV_FUNC) +#define H5_PRIV_FUNC_LEAVE(value) __FUNC_LEAVE(value) +#define H5_PRIV_FUNC_RETURN(value) __FUNC_RETURN(value, H5_DEBUG_PRIV_FUNC) + +#define HDF5_WRAPPER_ENTER(type) __FUNC_ENTER(type) +#define HDF5_WRAPPER_ENTER0(type) \ + __FUNC_ENTER0(type, H5_DEBUG_HDF5) +#define HDF5_WRAPPER_ENTER1(type, fmt, a1) \ + __FUNC_ENTER1(type, fmt, a1, H5_DEBUG_HDF5) +#define HDF5_WRAPPER_ENTER2(type, fmt, a1, a2) \ + __FUNC_ENTER2(type, fmt, a1, a2, H5_DEBUG_HDF5) +#define HDF5_WRAPPER_ENTER3(type, fmt, a1, a2, a3) \ + __FUNC_ENTER3(type, fmt, a1, a2, a3, H5_DEBUG_HDF5) +#define HDF5_WRAPPER_ENTER4(type, fmt, a1, a2, a3, a4) \ + __FUNC_ENTER4(type, fmt, a1, a2, a3, a4, H5_DEBUG_HDF5) +#define HDF5_WRAPPER_ENTER5(type, fmt, a1, a2, a3, a4, a5) \ + __FUNC_ENTER5(type, fmt, a1, a2, a3, a4, a5, H5_DEBUG_HDF5) +#define HDF5_WRAPPER_LEAVE(value) __FUNC_LEAVE(value) +#define HDF5_WRAPPER_RETURN(value) __FUNC_RETURN(value, H5_DEBUG_HDF5) + +#define MALLOC_WRAPPER_ENTER1(type, fmt, a1) \ + __FUNC_ENTER1(type, fmt, a1, H5_DEBUG_MALLOC) +#define MALLOC_WRAPPER_ENTER2(type, fmt, a1, a2) \ + __FUNC_ENTER2(type, fmt, a1, a2, H5_DEBUG_MALLOC) +#define MALLOC_WRAPPER_ENTER3(type, fmt, a1, a2, a3) \ + __FUNC_ENTER3(type, fmt, a1, a2, a3, H5_DEBUG_MALLOC) +#define MALLOC_WRAPPER_LEAVE(value) __FUNC_LEAVE(value) +#define MALLOC_WRAPPER_RETURN(value) __FUNC_RETURN(value, H5_DEBUG_MALLOC) /* WARNING! Changing these values will alter the data model and introduce * file incompatibilities with previous versions. */ diff --git a/src/h5core/h5_errorhandling.c b/src/h5core/h5_errorhandling.c index 31fa1c4..aa3d26d 100644 --- a/src/h5core/h5_errorhandling.c +++ b/src/h5core/h5_errorhandling.c @@ -5,8 +5,31 @@ #include "h5core/h5_core.h" #include "h5_core_private.h" -static h5_errorhandler_t h5priv_errhandler = h5_report_errorhandler; -h5_int32_t h5priv_debug_level = 1; +static h5_errorhandler_t h5_errhandler = h5_report_errorhandler; +h5_err_t h5_errno; +h5_int32_t h5_debug_level = 1; +int h5_initialized = 0; +struct call_stack h5_call_stack; + +char *h5_rfmts[] = { + [e_int] "%d", + [e_ssize_t] "%ld", + [e_char_p] "%s", + [e_void_p] "0x%p", + [e_h5_err_t] "%lld", + [e_h5_int64_t] "%lld", + [e_h5_id_t] "%lld", + [e_h5_ssize_t] "%lld", + [e_h5_errorhandler_t] "0x%p", + [e_h5_file_p] "0x%p", + [e_h5t_lvl_idx_t] "%d", + [e_h5t_iterator_p] "0x%p", + [e_h5_loc_id_t] "%ld", + [e_h5_loc_idx_t] "%ld", + [e_hid_t] "%ld", + [e_H5O_type_t] "%ld", + [e_herr_t] "%ld" +}; /*! \ingroup h5_core @@ -19,6 +42,15 @@ const char* const H5_O_MODES[] = { "H5_O_APPEND" }; +void +h5_initialize ( + void + ) { + memset (&h5_call_stack, 0, sizeof (h5_call_stack)); + h5_initialized = 1; +} + + /*! \ingroup h5_core_errorhandling @@ -38,9 +70,9 @@ h5_set_debuglevel ( const h5_id_t level /*!< debug level */ ) { if (level < 0) - h5priv_debug_level = 0; + h5_debug_level = 0; else - h5priv_debug_level = level; + h5_debug_level = level; return H5_SUCCESS; } @@ -55,7 +87,7 @@ h5_id_t h5_get_debuglevel ( void ) { - return h5priv_debug_level; + return h5_debug_level; } /*! @@ -69,7 +101,7 @@ h5_err_t h5_set_errorhandler ( const h5_errorhandler_t handler ) { - h5priv_errhandler = handler; + h5_errhandler = handler; return H5_SUCCESS; } @@ -84,7 +116,7 @@ h5_errorhandler_t h5_get_errorhandler ( void ) { - return h5priv_errhandler; + return h5_errhandler; } /*! @@ -96,9 +128,9 @@ h5_get_errorhandler ( */ h5_err_t h5_get_errno ( - const h5_file_t* const f + void ) { - return f->__errno; + return h5_errno; } /*! @@ -110,10 +142,9 @@ h5_get_errno ( */ void h5_set_errno ( - h5_file_t* const f, const h5_err_t errno ) { - f->__errno = errno; + h5_errno = errno; } @@ -127,15 +158,13 @@ h5_set_errno ( */ h5_err_t h5_report_errorhandler ( - const h5_file_t* const f, const char* fmt, va_list ap ) { - - if (h5priv_debug_level > 0) { - h5_verror (f, fmt, ap); + if (h5_debug_level > 0) { + h5_verror (fmt, ap); } - return f->__errno; + return h5_errno; } /*! @@ -146,20 +175,18 @@ h5_report_errorhandler ( */ h5_err_t h5_abort_errorhandler ( - const h5_file_t* const f, const char* fmt, va_list ap ) { - - if (h5priv_debug_level > 0) { - h5_verror (f, fmt, ap); + if (h5_debug_level > 0) { + h5_verror (fmt, ap); } #ifdef PARALLEL_IO - MPI_Abort(f->comm, -(int)f->__errno); + MPI_Abort(MPI_COMM_WORLD, -(int)h5_errno); #else - exit (-(int)f->__errno); + exit (-(int)h5_errno); #endif - return -(int)f->__errno; // never executed, just to supress a warning + return -(int)h5_errno; // never executed, just to supress a warning } void @@ -184,19 +211,18 @@ h5priv_vprintf ( */ h5_err_t h5_error ( - h5_file_t* const f, - const h5_err_t __errno, + const h5_err_t errno_, const char* fmt, ... ) { - f->__errno = __errno; + h5_errno = errno_; va_list ap; va_start (ap, fmt); - (*h5priv_errhandler)(f, fmt, ap); + (*h5_errhandler)(fmt, ap); va_end (ap); - return f->__errno; + return h5_errno; } /*! @@ -206,37 +232,10 @@ h5_error ( */ void h5_verror ( - const h5_file_t* const f, const char* fmt, va_list ap ) { - if (h5priv_debug_level < 1) return; - h5priv_vprintf (stderr, "E", f->__funcname, fmt, ap); + if (h5_debug_level < 1) return; + h5priv_vprintf (stderr, "E", h5_call_stack.entry[0].name, fmt, ap); } - -/*! - \ingroup h5_core_errorhandling - - Set function name. This name will used as prefix to all message. -*/ -void -h5_set_funcname ( - h5_file_t* const f, - const char* const fname - ) { - f->__funcname = (char *)fname; -} - -/*! - \ingroup h5_core_errorhandling - - Get function name. -*/ -const char* -h5_get_funcname ( - const h5_file_t* const f - ) { - return f->__funcname; -} - diff --git a/src/h5core/h5_errorhandling_private.h b/src/h5core/h5_errorhandling_private.h index 6be2660..80ce0b8 100644 --- a/src/h5core/h5_errorhandling_private.h +++ b/src/h5core/h5_errorhandling_private.h @@ -1,60 +1,52 @@ #ifndef __H5_ERRORHANDLING_PRIVATE_H #define __H5_ERRORHANDLING_PRIVATE_H -#define HANDLE_H5_DATASET_RANK_ERR( f, m, n ) \ +#define HANDLE_H5_DATASET_RANK_ERR( m, n ) \ h5_error( \ - f, \ H5_ERR_INVAL, \ "Wrong rank of dataset: Is %d, but should be %d", \ m, n ); -#define HANDLE_H5_GROUP_EXISTS_ERR( f, name ) \ +#define HANDLE_H5_GROUP_EXISTS_ERR( name ) \ h5_error( \ - f, \ H5_ERR_INVAL, \ "Group \"%s\" already exists", name ) /**************** H5 *********************/ -#define h5priv_handle_file_mode_error( f, mode_id ) \ +#define h5priv_handle_file_mode_error( mode_id ) \ h5_error( \ - f, \ H5_ERR_BADF, \ "Operation not permitted in mode \"%s\"", \ H5_O_MODES[mode_id] ); -#define HANDLE_H5_STEP_EXISTS_ERR( f, step ) \ +#define HANDLE_H5_STEP_EXISTS_ERR( step ) \ h5_error( \ - f, \ H5_ERR_INVAL, \ "Step #%lld already exists, step cannot be set " \ "to an existing step in write and append mode", \ (long long)step ); -#define HANDLE_H5_NOENTRY_ERR( f, group_name, type, idx ) \ +#define HANDLE_H5_NOENTRY_ERR( group_name, type, idx ) \ h5_error( \ - f, \ H5_ERR_NOENTRY, \ "No entry with index %lld and type %d in group %s!", \ (long long)idx, type, group_name ); -#define HANDLE_H5_OVERFLOW_ERR( f, otype, max ) \ +#define HANDLE_H5_OVERFLOW_ERR( otype, max ) \ h5_error( \ - f, \ H5_ERR_INVAL, \ "Cannot store more than %lld %s", (long long)max, otype ); -#define HANDLE_H5_PARENT_ID_ERR( f, otype, parent_id ) \ +#define HANDLE_H5_PARENT_ID_ERR( otype, parent_id ) \ h5_error( \ - f, \ H5_ERR_INVAL, \ "Impossible parent_id %lld for %s.", \ (long long)parent_id, otype ); -#define HANDLE_H5_OUT_OF_RANGE_ERR( f, otype, oid ) \ +#define HANDLE_H5_OUT_OF_RANGE_ERR( otype, oid ) \ h5_error( \ - f, \ H5_ERR_INVAL, \ "%s id %lld out of range", \ otype, (long long)oid ); diff --git a/src/h5core/h5_hdf5.c b/src/h5core/h5_hdf5.c index b423fe2..6d05953 100644 --- a/src/h5core/h5_hdf5.c +++ b/src/h5core/h5_hdf5.c @@ -8,46 +8,46 @@ /****** G r o u p ************************************************************/ hid_t -h5priv_open_hdf5_group ( - h5_file_t* const f, +hdf5_open_group ( const hid_t loc_id, const char* const group_name ) { - h5_debug (f, "%s (loc_id=%lld, group_name=\"%s/%s\")", - __func__, (long long)loc_id, - h5_get_objname (loc_id), group_name); + HDF5_WRAPPER_ENTER3 (hid_t, + "loc_id=%d (%s), group_name=\"%s\"", + loc_id, + h5_get_objname (loc_id), + group_name); hid_t group_id = H5Gopen (loc_id, group_name, H5P_DEFAULT); if (group_id < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot open group \"%s/%s\".", - h5_get_objname (loc_id), - group_name); - h5_debug (f, "%s (): return group id: %lld", __func__, (long long)group_id); - return group_id; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot open group \"%s/%s\".", + h5_get_objname (loc_id), + group_name)); + HDF5_WRAPPER_RETURN (group_id); } hid_t -h5priv_create_hdf5_group ( - h5_file_t* const f, +hdf5_create_group ( const hid_t loc_id, const char* const group_name ) { - h5_debug (f, "%s (loc_id=%lld, group_name=\"%s/%s\")", - __func__, (long long)loc_id, - h5_get_objname (loc_id), group_name); + HDF5_WRAPPER_ENTER3 (hid_t, + "loc_id=%d (%s), group_name=\"%s\"", + loc_id, + h5_get_objname (loc_id), + group_name); hid_t group_id = H5Gcreate ( loc_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (group_id < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot create group \"%s/%s\".", - h5_get_objname (loc_id), - group_name); - h5_debug (f, "%s (): return group id: %lld", __func__, (long long)group_id); - return group_id; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot create group \"%s/%s\".", + h5_get_objname (loc_id), + group_name)); + HDF5_WRAPPER_RETURN (group_id); } /*! @@ -65,6 +65,12 @@ h5priv_open_group ( ) { hid_t group_id; + H5_PRIV_API_ENTER3 (hid_t, + "loc_id=%d (%s), group_name=\"%s\"", + loc_id, + h5_get_objname (loc_id), + group_name); + /* check access modes: Open Create @@ -75,15 +81,15 @@ h5priv_open_group ( */ h5_err_t exists; - TRY( exists = h5priv_hdf5_link_exists(f, loc_id, group_name) ); + TRY (exists = hdf5_link_exists(loc_id, group_name)); if (exists > 0) { - TRY( group_id = h5priv_open_hdf5_group (f, loc_id, group_name) ); + TRY (group_id = hdf5_open_group (loc_id, group_name)); } else { CHECK_WRITABLE_MODE (f); - TRY( group_id = h5priv_create_hdf5_group (f, loc_id, group_name) ); + TRY (group_id = hdf5_create_group (loc_id, group_name)); } - return group_id; + H5_PRIV_API_RETURN (group_id); } /*! @@ -93,41 +99,43 @@ h5priv_open_group ( \param[in] group_id id of group to close */ h5_err_t -h5priv_close_hdf5_group ( - h5_file_t* const f, +hdf5_close_group ( const hid_t group_id ) { - if (group_id == 0 || group_id == -1) return H5_SUCCESS; - - h5_debug (f, "%s (group_id=%lld, group_name=\"%s\")", - __func__, - (long long)group_id, - h5_get_objname (group_id)); + HDF5_WRAPPER_ENTER2 (h5_err_t, + "group_id=%d (%s)", + group_id, + h5_get_objname (group_id)); + if (group_id == 0 || group_id == -1) + HDF5_WRAPPER_LEAVE (H5_SUCCESS); if (H5Gclose (group_id) < 0 ) { - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot terminate access to group \"%s\".", - h5_get_objname (group_id)); + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot terminate access to group \"%s\").", + h5_get_objname (group_id))); } - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_ssize_t -h5priv_get_num_objs_in_hdf5_group ( - h5_file_t* const f, +hdf5_get_num_objs_in_group ( const hid_t group_id ) { + HDF5_WRAPPER_ENTER2 (h5_ssize_t, + "group_id=%d (%s)", + group_id, + h5_get_objname (group_id)); H5G_info_t group_info; if (H5Gget_info (group_id, &group_info) < 0) { - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get number of objects in group %s.", - h5_get_objname(group_id)); + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get number of objects in group \"%s\".", + h5_get_objname(group_id))); } - return (h5_ssize_t)group_info.nlinks; + HDF5_WRAPPER_RETURN ((h5_ssize_t)group_info.nlinks); } @@ -136,37 +144,34 @@ h5priv_get_num_objs_in_hdf5_group ( return size of name. */ h5_ssize_t -h5priv_get_hdf5_objname_by_idx ( - h5_file_t* const f, +hdf5_get_objname_by_idx ( hid_t loc_id, hsize_t idx, char *name, size_t size ) { - ssize_t len; + HDF5_WRAPPER_ENTER3 (h5_ssize_t, + "loc_id=%d (%s), idx=%lld", + loc_id, + h5_get_objname (loc_id), + (long long)idx); + if (name == NULL) { - len = H5Lget_name_by_idx (loc_id, ".", - H5_INDEX_NAME, H5_ITER_INC, - idx, - NULL, 0, - H5P_DEFAULT); - if (len < 0) goto error; - } else { - len = H5Lget_name_by_idx (loc_id, ".", - H5_INDEX_NAME, H5_ITER_INC, - idx, - name, size, - H5P_DEFAULT); - if (len < 0) goto error; + size = 0; } - return len; -error: - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get name of object %ld in group %s.", - (long)idx, - h5_get_objname (loc_id)); + ssize_t len = H5Lget_name_by_idx (loc_id, ".", + H5_INDEX_NAME, H5_ITER_INC, + idx, + name, size, + H5P_DEFAULT); + if (len < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get name of object %llu in group \"%s\".", + (unsigned long long)idx, + h5_get_objname (loc_id))); + HDF5_WRAPPER_RETURN (len); } /****** D a t a s e t ********************************************************/ @@ -178,28 +183,27 @@ error: \param[in] dataset_name name of dataset to open */ hid_t -h5priv_open_hdf5_dataset ( - h5_file_t* const f, +hdf5_open_dataset ( const hid_t loc_id, const char* const dataset_name ) { - h5_debug (f, "%s (loc_id=%lld, dataset_name=\"%s/%s\")", - __func__, (long long)loc_id, - h5_get_objname (loc_id), dataset_name); - - hid_t dataset_id; - - dataset_id = H5Dopen ( + HDF5_WRAPPER_ENTER3 (hid_t, + "loc_id=%d (%s), dataset_name=\"%s\"", + loc_id, + h5_get_objname (loc_id), + dataset_name); + hid_t dataset_id = H5Dopen ( loc_id, dataset_name, H5P_DEFAULT); if (dataset_id < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot open dataset \"%s\".", dataset_name); - h5_debug (f, "%s (): return dataset id: %lld", __func__, (long long)dataset_id); - return dataset_id; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot open dataset \"%s/%s\".", + h5_get_objname (loc_id), + dataset_name)); + HDF5_WRAPPER_RETURN (dataset_id); } /*! @@ -214,18 +218,18 @@ h5priv_open_hdf5_dataset ( */ hid_t -h5priv_create_hdf5_dataset ( - h5_file_t* const f, +hdf5_create_dataset ( hid_t loc_id, const char* dataset_name, const hid_t type_id, const hid_t dataspace_id, const hid_t create_proplist ) { - h5_debug (f, "%s (loc_id=%lld, dataset_name=\"%s/%s\")", - __func__, (long long)loc_id, - h5_get_objname (loc_id), dataset_name); - + HDF5_WRAPPER_ENTER3 (hid_t, + "loc_id=%d (%s), dataset_name=\"%s\"", + loc_id, + h5_get_objname (loc_id), + dataset_name); hid_t dataset_id = H5Dcreate ( loc_id, dataset_name, @@ -235,14 +239,13 @@ h5priv_create_hdf5_dataset ( create_proplist, H5P_DEFAULT); if (dataset_id < 0) - return h5_error( - f, - H5_ERR_HDF5, - "Cannot create dataset %s/%s", - h5_get_objname (loc_id), - dataset_name); - h5_debug (f, "%s (): return dataset id: %lld", __func__, (long long)dataset_id); - return dataset_id; + HDF5_WRAPPER_LEAVE ( + h5_error( + H5_ERR_HDF5, + "Cannot create dataset \"%s/%s\"", + h5_get_objname (loc_id), + dataset_name)); + HDF5_WRAPPER_RETURN (dataset_id); } /*! @@ -252,24 +255,24 @@ h5priv_create_hdf5_dataset ( \param[in] dataset_id id of dataset to close */ h5_err_t -h5priv_close_hdf5_dataset ( - h5_file_t* const f, - const hid_t dset_id +hdf5_close_dataset ( + const hid_t dataset_id ) { - if (dset_id == 0 || dset_id == -1) return H5_SUCCESS; - h5_debug (f, "%s (dataset_id=%lld, dataset_name=\"%s\")", - __func__, - (long long)dset_id, - h5_get_objname (dset_id)); + HDF5_WRAPPER_ENTER2 (h5_err_t, + "dataset_id=%d (%s)", + dataset_id, + h5_get_objname (dataset_id)); + if (dataset_id == 0 || dataset_id == -1) + HDF5_WRAPPER_LEAVE (H5_SUCCESS); - if (H5Dclose (dset_id) < 0) { - return h5_error( - f, - H5_ERR_HDF5, - "Close of dataset \"%s\" failed.", - h5_get_objname (dset_id) ); + if (H5Dclose (dataset_id) < 0) { + HDF5_WRAPPER_LEAVE ( + h5_error( + H5_ERR_HDF5, + "Close of dataset \"%s\" failed.", + h5_get_objname (dataset_id))); } - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } /*! @@ -280,18 +283,21 @@ h5priv_close_hdf5_dataset ( */ hid_t -h5priv_get_hdf5_dataset_space ( - h5_file_t* const f, +hdf5_get_dataset_space ( const hid_t dataset_id ) { + HDF5_WRAPPER_ENTER2 (hid_t, + "dataset_id=%d (%s)", + dataset_id, + h5_get_objname(dataset_id)); hid_t dataspace_id = H5Dget_space (dataset_id); if (dataspace_id < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get dataspace for dataset \"%s\".", - h5_get_objname (dataset_id) ); - return dataspace_id; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get dataspace for dataset \"%s\".", + h5_get_objname (dataset_id))); + HDF5_WRAPPER_RETURN (dataspace_id); } /*! @@ -308,8 +314,7 @@ h5priv_get_hdf5_dataset_space ( */ h5_err_t -h5priv_write_hdf5_dataset ( - h5_file_t* const f, +hdf5_write_dataset ( const hid_t dataset_id, const hid_t type_id, const hid_t memspace_id, @@ -317,9 +322,12 @@ h5priv_write_hdf5_dataset ( const hid_t xfer_prop, const void* buf ) { -#ifdef PARALLEL_IO - TRY ( h5_start_throttle ( f ) ); -#endif + HDF5_WRAPPER_ENTER3 (h5_err_t, + "dataset_id=%d (%s) type_id=%d", + dataset_id, + h5_get_objname(dataset_id), + type_id); + herr_t herr = H5Dwrite ( dataset_id, type_id, @@ -328,34 +336,31 @@ h5priv_write_hdf5_dataset ( xfer_prop, buf); if (herr < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Write to dataset \"%s\" failed.", \ - h5_get_objname (dataset_id)); + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Write to dataset \"%s\" failed.", \ + h5_get_objname (dataset_id))); -#ifdef PARALLEL_IO - TRY ( h5_end_throttle ( f ) ); -#endif - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } /* Wrapper for H5Dread */ h5_err_t -h5priv_read_hdf5_dataset ( - h5_file_t* const f, +hdf5_read_dataset ( const hid_t dataset_id, const hid_t type_id, const hid_t memspace_id, const hid_t diskspace_id, const hid_t xfer_prop, void* const buf ) { - -#ifdef PARALLEL_IO - TRY ( h5_start_throttle ( f ) ); -#endif + HDF5_WRAPPER_ENTER3 (h5_err_t, + "dataset_id=%d (%s) type_id=%d", + dataset_id, + h5_get_objname(dataset_id), + type_id); herr_t herr = H5Dread ( dataset_id, type_id, @@ -364,75 +369,86 @@ h5priv_read_hdf5_dataset ( xfer_prop, buf); if (herr < 0) - return h5_error( - f, - H5_ERR_HDF5, - "Error reading dataset \"%s\".", - h5_get_objname (dataset_id) ); + HDF5_WRAPPER_LEAVE ( + h5_error( + H5_ERR_HDF5, + "Error reading dataset \"%s\".", + h5_get_objname (dataset_id))); -#ifdef PARALLEL_IO - TRY ( h5_end_throttle ( f ) ); -#endif - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } hid_t -h5priv_get_hdf5_dataset_type ( - h5_file_t* const f, +hdf5_get_dataset_type ( const hid_t dataset_id ) { + HDF5_WRAPPER_ENTER2 (h5_err_t, + "dataset_id=%d (%s)", + dataset_id, + h5_get_objname(dataset_id)); hid_t datatype_id = H5Dget_type (dataset_id); if (datatype_id < 0) - return h5_error( - f, - H5_ERR_HDF5, - "Cannot determine dataset type."); + HDF5_WRAPPER_LEAVE ( + h5_error( + H5_ERR_HDF5, + "Cannot determine dataset type.")); - return datatype_id; + HDF5_WRAPPER_RETURN (datatype_id); } h5_err_t -h5priv_set_hdf5_dataset_extent ( - h5_file_t* const f, - hid_t dset_id, +hdf5_set_dataset_extent ( + hid_t dataset_id, const hsize_t* size ) { - if (H5Dset_extent(dset_id, size) < 0) { - return h5_error( - f, - H5_ERR_HDF5, - "Changing size of dataset \"%s\" dimensions failed.", - h5_get_objname (dset_id)); + HDF5_WRAPPER_ENTER3 (h5_err_t, + "dataset_id=%d (%s), size=%llu", + dataset_id, + h5_get_objname(dataset_id), + *size); + if (H5Dset_extent(dataset_id, size) < 0) { + HDF5_WRAPPER_LEAVE ( + h5_error( + H5_ERR_HDF5, + "Changing size of dataset \"%s\" dimensions failed.", + h5_get_objname (dataset_id))); } - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_ssize_t -h5priv_get_npoints_of_hdf5_dataset ( - h5_file_t* const f, - hid_t dset_id +hdf5_get_npoints_of_dataset ( + hid_t dataset_id ) { + HDF5_WRAPPER_ENTER2 (h5_ssize_t, + "dataset_id=%d (%s)", + dataset_id, + h5_get_objname(dataset_id)); hid_t dspace_id; hsize_t size; - TRY( dspace_id = h5priv_get_hdf5_dataset_space (f, dset_id) ); - TRY( size = h5priv_get_npoints_of_hdf5_dataspace (f, dspace_id) ); - TRY( h5priv_close_hdf5_dataspace (f, dspace_id) ); - return size; + TRY (dspace_id = hdf5_get_dataset_space (dataset_id)); + TRY (size = hdf5_get_npoints_of_dataspace (dspace_id)); + TRY (hdf5_close_dataspace (dspace_id)); + HDF5_WRAPPER_RETURN (size); } h5_ssize_t -h5priv_get_npoints_of_hdf5_dataset_by_name ( - h5_file_t* const f, +hdf5_get_npoints_of_dataset_by_name ( hid_t loc_id, char* name ) { + HDF5_WRAPPER_ENTER3 (h5_ssize_t, + "loc_id=%d (%s), name=\"%s\"", + loc_id, + h5_get_objname(loc_id), + name); hid_t dset_id; hsize_t size; - TRY( dset_id = h5priv_open_hdf5_dataset (f, loc_id, name) ); - TRY( size = h5priv_get_npoints_of_hdf5_dataset (f, dset_id) ); - TRY( h5priv_close_hdf5_dataset (f, dset_id) ); - return size; + TRY (dset_id = hdf5_open_dataset (loc_id, name)); + TRY (size = hdf5_get_npoints_of_dataset (dset_id)); + TRY (hdf5_close_dataset (dset_id)); + HDF5_WRAPPER_RETURN (size); } @@ -440,45 +456,46 @@ h5priv_get_npoints_of_hdf5_dataset_by_name ( /*! Create dataspace for dataset. H5Screate_simple wrapper. - \param[in] f file handle \param[in] rank rank of dataspace \param[in] dims dimensions of dataspace \param[in] maxdims maximum dimensions of dataspace */ hid_t -h5priv_create_hdf5_dataspace ( - h5_file_t* const f, +hdf5_create_dataspace ( const int rank, const hsize_t* dims, const hsize_t* maxdims ) { + HDF5_WRAPPER_ENTER1 (hid_t, + "rank=%d", + rank); hid_t dataspace_id = H5Screate_simple (rank, dims, maxdims); if (dataspace_id < 0) - h5_error ( - f, - H5_ERR_HDF5, - "Cannot create dataspace with rank %d.", - rank); - return dataspace_id; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot create dataspace with rank %d.", + rank)); + HDF5_WRAPPER_RETURN (dataspace_id); } hid_t -h5priv_create_hdf5_dataspace_scalar ( - h5_file_t* const f +hdf5_create_dataspace_scalar ( + void ) { + HDF5_WRAPPER_ENTER0 (hid_t); hid_t dataspace_id = H5Screate (H5S_SCALAR); if (dataspace_id < 0) - h5_error ( - f, - H5_ERR_HDF5, - "Cannot create scalar dataspace."); - return dataspace_id; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot create scalar dataspace.")); + HDF5_WRAPPER_RETURN (dataspace_id); } h5_err_t -h5priv_select_hyperslab_of_hdf5_dataspace ( - h5_file_t* const f, +hdf5_select_hyperslab_of_dataspace ( hid_t space_id, H5S_seloper_t op, const hsize_t* start, @@ -486,6 +503,9 @@ h5priv_select_hyperslab_of_hdf5_dataspace ( const hsize_t* count, const hsize_t* block ) { + HDF5_WRAPPER_ENTER1 (h5_err_t, + "%d", + space_id); herr_t herr = H5Sselect_hyperslab ( space_id, op, @@ -494,22 +514,24 @@ h5priv_select_hyperslab_of_hdf5_dataspace ( count, block); if (herr < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot set select hyperslap region or add the " - "specified region"); - return H5_SUCCESS; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot set select hyperslap region or add the " + "specified region")); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_err_t -h5priv_select_elements_of_hdf5_dataspace ( - h5_file_t* const f, +hdf5_select_elements_of_dataspace ( hid_t space_id, H5S_seloper_t op, hsize_t nelems, const hsize_t* indices ) { + HDF5_WRAPPER_ENTER1 (h5_err_t, + "%d", + space_id); herr_t herr; if ( nelems > 0 ) { herr = H5Sselect_elements ( @@ -521,56 +543,64 @@ h5priv_select_elements_of_hdf5_dataspace ( herr = H5Sselect_none ( space_id ); } if (herr < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot set select hyperslap region or add the " - "specified region"); - return H5_SUCCESS; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot set select hyperslap region or add the " + "specified region")); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_ssize_t -h5priv_get_selected_npoints_of_hdf5_dataspace ( - h5_file_t* const f, +hdf5_get_selected_npoints_of_dataspace ( hid_t space_id ) { + HDF5_WRAPPER_ENTER1 (h5_ssize_t, + "%d", + space_id); hssize_t size = H5Sget_select_npoints (space_id); if (size < 0) - h5_error( - f, - H5_ERR_HDF5, - "Cannot determine number of selected elements in dataspace."); - return size; + HDF5_WRAPPER_LEAVE ( + h5_error( + H5_ERR_HDF5, + "Cannot determine number of " + "selected elements in dataspace.")); + HDF5_WRAPPER_RETURN (size); } h5_ssize_t -h5priv_get_npoints_of_hdf5_dataspace ( - h5_file_t* const f, +hdf5_get_npoints_of_dataspace ( hid_t space_id ) { + HDF5_WRAPPER_ENTER1 (h5_ssize_t, + "%d", + space_id); hssize_t size = H5Sget_simple_extent_npoints (space_id); if (size < 0) - h5_error( - f, - H5_ERR_HDF5, - "Cannot determine number of elements in dataspace."); - return size; + HDF5_WRAPPER_LEAVE ( + h5_error( + H5_ERR_HDF5, + "Cannot determine number of" + "elements in dataspace.")); + HDF5_WRAPPER_RETURN (size); } int -h5priv_get_dims_of_hdf5_dataspace ( - h5_file_t* const f, +hdf5_get_dims_of_dataspace ( hid_t space_id, hsize_t* dims, hsize_t* maxdims ) { + HDF5_WRAPPER_ENTER1 (int, + "%d", + space_id); int rank = H5Sget_simple_extent_dims (space_id, dims, maxdims); if (rank < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot determine rank of dataspace."); - return rank; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot determine rank of dataspace.")); + HDF5_WRAPPER_RETURN (rank); } @@ -581,49 +611,67 @@ h5priv_get_dims_of_hdf5_dataspace ( \param[in] dataspace_id id of space to close */ h5_err_t -h5priv_close_hdf5_dataspace ( - h5_file_t* const f, +hdf5_close_dataspace ( const hid_t dataspace_id ) { + HDF5_WRAPPER_ENTER1 (h5_err_t, + "dataspace_%d", + dataspace_id); if (dataspace_id <= 0 || dataspace_id == H5S_ALL) - return H5_SUCCESS; + HDF5_WRAPPER_LEAVE (H5_SUCCESS); herr_t herr = H5Sclose (dataspace_id); if (herr < 0) - return h5_error( - f, - H5_ERR_HDF5, - "Cannot terminate access to dataspace!"); + HDF5_WRAPPER_LEAVE ( + h5_error( + H5_ERR_HDF5, + "Cannot terminate access to dataspace!")); - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } /****** D a t a t y p e ******************************************************/ -const char* -h5priv_get_base_type_name ( - h5_file_t* const f, - hid_t base_type_id +char_p +hdf5_get_type_name ( + hid_t type_id ) { - if (base_type_id == H5_INT32_T) return "H5_INT32_T"; - if (base_type_id == H5_INT64_T) return "H5_INT64_T"; - if (base_type_id == H5_FLOAT32_T) return "H5_FLOAT32_T"; - if (base_type_id == H5_FLOAT64_T) return "H5_FLOAT64_T"; - if (base_type_id == H5_STRING_T) return "H5_STRING_T"; + if (type_id == H5_INT32_T) + return "H5_INT32_T"; + if (type_id == H5_INT64_T) + return "H5_INT64_T"; + if (type_id == H5_FLOAT32_T) + return "H5_FLOAT32_T"; + if (type_id == H5_FLOAT64_T) + return "H5_FLOAT64_T"; + if (type_id == H5_STRING_T) + return "H5_STRING_T"; - h5_warn (f, "Unknown base type id %lu", (unsigned long)base_type_id); + h5_warn ("Unknown type id %d", type_id); return "[unknown]"; } static const char* get_class_type_name ( - h5_file_t* const f, - hid_t base_type_id + const hid_t class_id ) { - UNUSED_ARGUMENT(f); - if (base_type_id == H5_COMPOUND_T) return "H5_COMPOUND_T"; - - return "[unknown]"; + const char* const map[] = { + [H5T_INTEGER] "H5T_INTEGER", + [H5T_FLOAT] "H5T_FLOAT", + [H5T_TIME] "H5T_TIME", + [H5T_STRING] "H5T_STRING", + [H5T_BITFIELD] "H5T_BITFIELD", + [H5T_OPAQUE] "H5T_OPAQUE", + [H5T_COMPOUND] "H5T_COMPOUND", + [H5T_REFERENCE] "H5T_REFERENCE", + [H5T_ENUM] "H5T_ENUM", + [H5T_VLEN] "H5T_VLEN", + [H5T_ARRAY] "H5T_ARRAY" + }; + if (class_id < 0 || class_id >= H5T_NCLASSES) { + return ("[unknown]"); + } + return map[class_id]; } /*! @@ -635,110 +683,117 @@ get_class_type_name ( \param[in] dims dimensions */ hid_t -h5priv_create_hdf5_array_type ( - h5_file_t* const f, - hid_t base_type_id, - int rank, +hdf5_create_array_type ( + const hid_t base_type_id, + const int rank, const hsize_t* dims ) { + HDF5_WRAPPER_ENTER3 (hid_t, + "base_type_id=%d (%s), rank=%d", + base_type_id, + hdf5_get_type_name (base_type_id), + rank); hid_t type_id = H5Tarray_create (base_type_id, rank, dims); if (type_id < 0) { - return h5_error ( - f, - H5_ERR_HDF5, - "Can't create array datatype object with base " - "type %s and rank %d", - h5priv_get_base_type_name (f, base_type_id), - rank); + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Can't create array datatype object with base " + "type %s and rank %d", + hdf5_get_type_name (base_type_id), + rank)); } - return type_id; + HDF5_WRAPPER_RETURN (type_id); } hid_t -h5priv_create_hdf5_type ( - h5_file_t* const f, +hdf5_create_type ( H5T_class_t class, const size_t size ) { + HDF5_WRAPPER_ENTER2 (hid_t, + "class=%d (%s)", + class, + get_class_type_name (class)); hid_t type_id = H5Tcreate (class, size); if (type_id < 0) { - return h5_error ( - f, - H5_ERR_HDF5, - "Can't create datatype object of class %s.", - get_class_type_name (f, class) - ); + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Can't create datatype object of class %s.", + get_class_type_name (class))); } - return type_id; + HDF5_WRAPPER_RETURN (type_id); } hid_t -h5priv_create_hdf5_string_type( - h5_file_t *const f, +hdf5_create_string_type( const hsize_t len ) { + HDF5_WRAPPER_ENTER1 (hid_t, + "len = %llu", len); hid_t type_id = H5Tcopy ( H5T_C_S1 ); if (type_id < 0) - return h5_error( - f, - H5_ERR_HDF5, - "Can't duplicate C string type."); + HDF5_WRAPPER_LEAVE ( + h5_error( + H5_ERR_HDF5, + "Can't duplicate C string type.")); herr_t herr = H5Tset_size ( type_id, len ); if (herr < 0) - return h5_error( - f, - H5_ERR_HDF5, - "Can't set length of C string type."); - return type_id; + HDF5_WRAPPER_LEAVE ( + h5_error( + H5_ERR_HDF5, + "Can't set length of C string type.")); + HDF5_WRAPPER_RETURN (type_id); } h5_err_t -h5priv_insert_hdf5_type ( - h5_file_t* const f, - hid_t dtype_id, +hdf5_insert_type ( + hid_t type_id, const char* name, size_t offset, hid_t field_id ) { - herr_t herr = H5Tinsert (dtype_id, name, offset, field_id); + HDF5_WRAPPER_ENTER2 (h5_err_t, "type_id=%d, name=%s", type_id, name); + herr_t herr = H5Tinsert (type_id, name, offset, field_id); if (herr < 0) - return h5_error( - f, - H5_ERR_HDF5, - "Can't insert field %s to compound datatype.", - name); - return H5_SUCCESS; + HDF5_WRAPPER_LEAVE ( + h5_error( + H5_ERR_HDF5, + "Can't insert field %s to compound datatype.", + name)); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_err_t -h5priv_close_hdf5_type ( - h5_file_t* const f, +hdf5_close_type ( hid_t dtype_id ) { + HDF5_WRAPPER_ENTER1 (h5_err_t, "dtype_id=%d", dtype_id); herr_t herr = H5Tclose (dtype_id); if (herr < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot release datatype."); - return H5_SUCCESS; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot release datatype.")); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } /****** P r o p e r t y ******************************************************/ hid_t -h5priv_create_hdf5_property ( - h5_file_t* const f, +hdf5_create_property ( hid_t cls_id ) { + HDF5_WRAPPER_ENTER1 (hid_t, "cls_id=%d", cls_id); hid_t prop_id = H5Pcreate (cls_id); - if (prop_id < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot create property list."); - return prop_id; + if (prop_id < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot create property list.")); + HDF5_WRAPPER_RETURN (prop_id); } /*! @@ -749,274 +804,295 @@ h5priv_create_hdf5_property ( */ hid_t -h5priv_get_hdf5_dataset_create_plist ( - h5_file_t* const f, +hdf5_get_dataset_create_plist ( const hid_t dataset_id ) { + HDF5_WRAPPER_ENTER2 (hid_t, "dataset_id=%d (%s)", + dataset_id, + h5_get_objname (dataset_id)); hid_t plist_id = H5Dget_create_plist (dataset_id); if (plist_id < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get create properties for dataset \"%s\".", - h5_get_objname (dataset_id) ); - return plist_id; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get create properties for dataset \"%s\".", + h5_get_objname (dataset_id))); + HDF5_WRAPPER_RETURN (plist_id); } h5_err_t -h5priv_set_hdf5_chunk_property ( - h5_file_t* const f, +hdf5_set_chunk_property ( hid_t plist, int rank, hsize_t* dims ) { + HDF5_WRAPPER_ENTER3 (h5_err_t, + "plist=%d, rank=%d, dims[0]=%llu ...", + plist, rank, dims[0]); if (H5Pset_chunk (plist, rank, dims) < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot add chunking property to list."); + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot add chunking property to list.")); - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_err_t -h5priv_get_hdf5_chunk_property ( - h5_file_t* const f, +hdf5_get_chunk_property ( hid_t plist, int rank, hsize_t* dims ) { + HDF5_WRAPPER_ENTER2 (h5_err_t, "plist=%d, rank=%d", plist, rank); if (H5Pget_chunk (plist, rank, dims) < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get chunking property from list."); + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get chunking property from list.")); - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_err_t -h5priv_set_hdf5_layout_property ( - h5_file_t* const f, +hdf5_set_layout_property ( hid_t plist, H5D_layout_t layout ) { + HDF5_WRAPPER_ENTER1 (h5_err_t, "plist=%d", plist); if (H5Pset_layout (plist, layout) < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot add layout property to list."); + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot add layout property to list.")); - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } #ifdef PARALLEL_IO h5_err_t -h5priv_set_hdf5_fapl_mpio_property ( - h5_file_t* const f, +hdf5_set_fapl_mpio_property ( hid_t fapl_id, MPI_Comm comm, MPI_Info info ) { - herr_t herr = H5Pset_fapl_mpio (fapl_id, comm, info); - if (herr < 0) - h5_error ( - f, - H5_ERR_HDF5, - "Cannot store IO communicator information to the " - "file access property list."); - return H5_SUCCESS; + HDF5_WRAPPER_ENTER3 (h5_err_t, + "fapl_id=%d, comm=%d, info=%d", + fapl_id, (int)comm, (int)info); + if (H5Pset_fapl_mpio (fapl_id, comm, info) < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot store IO communicator information to the " + "file access property list.")); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_err_t -h5priv_set_hdf5_fapl_mpiposix_property ( - h5_file_t* const f, +hdf5_set_fapl_mpiposix_property ( hid_t fapl_id, MPI_Comm comm, hbool_t use_gpfs ) { - herr_t herr = H5Pset_fapl_mpiposix (fapl_id, comm, use_gpfs); - if (herr < 0) - h5_error ( - f, - H5_ERR_HDF5, - "Cannot store IO communicator information to the " - "file access property list."); - return H5_SUCCESS; + HDF5_WRAPPER_ENTER3 (h5_err_t, + "fapl_id=%d, comm=%d, use_gpfs=%d", + fapl_id, (int)comm, (int)use_gpfs); + if ( H5Pset_fapl_mpiposix (fapl_id, comm, use_gpfs) < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot store IO communicator information to" + " the file access property list.")); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_err_t -h5priv_set_hdf5_dxpl_mpio_property ( - h5_file_t* const f, +hdf5_set_dxpl_mpio_property ( hid_t dxpl_id, H5FD_mpio_xfer_t mode ) { - herr_t herr = H5Pset_dxpl_mpio (dxpl_id, mode); - if (herr < 0) - h5_error ( - f, - H5_ERR_HDF5, - "Cannot store IO communicator information to the " - "dataset transfer property list."); - return H5_SUCCESS; + HDF5_WRAPPER_ENTER2 (h5_err_t, + "dxpl_id=%d, mode=%d", + dxpl_id, (int)mode); + if (H5Pset_dxpl_mpio (dxpl_id, mode) < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot store IO communicator information to" + " the dataset transfer property list.")); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } #endif h5_err_t -h5priv_set_hdf5_mdc_property ( - h5_file_t* const f, +hdf5_set_mdc_property ( hid_t fapl_id, H5AC_cache_config_t *config ) { - herr_t herr = H5Pset_mdc_config (fapl_id, config); - if (herr < 0) - h5_error ( - f, - H5_ERR_HDF5, - "Cannot store metadata cache configuration in the " - "file access property list."); - return H5_SUCCESS; + HDF5_WRAPPER_ENTER2 (h5_err_t, + "fapl_id=%d, config=0x%p", + fapl_id, config); + if (H5Pset_mdc_config (fapl_id, config) < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot store metadata cache configuration in" + " the file access property list.")); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_err_t -h5priv_get_hdf5_mdc_property ( - h5_file_t* const f, +hdf5_get_mdc_property ( hid_t fapl_id, H5AC_cache_config_t *config ) { - herr_t herr = H5Pget_mdc_config (fapl_id, config); - if (herr < 0) - h5_error ( - f, - H5_ERR_HDF5, - "Cannot get metadata cache configuration in the " - "file access property list."); - return H5_SUCCESS; + HDF5_WRAPPER_ENTER2 (h5_err_t, + "fapl_id=%d, config=0x%p", + fapl_id, config); + if (H5Pget_mdc_config (fapl_id, config) < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get metadata cache configuration in" + " the file access property list.")); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_err_t -h5priv_set_hdf5_alignment_property ( - h5_file_t* const f, +hdf5_set_alignment_property ( const hid_t fapl_id, const hsize_t threshold, const hsize_t alignment ) { - herr_t herr = H5Pset_alignment (fapl_id, threshold, alignment); - if (herr < 0) - h5_error ( - f, - H5_ERR_HDF5, - "Cannot set alignment in the " - "file access property list."); - return H5_SUCCESS; + HDF5_WRAPPER_ENTER3 (h5_err_t, + "fapl_id=%d, threshold=%llu, alignment=%llu", + fapl_id, threshold, alignment); + if (H5Pset_alignment (fapl_id, threshold, alignment) < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot set alignment in the " + "file access property list.")); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_err_t -h5priv_set_hdf5_btree_ik_property ( - h5_file_t* const f, +hdf5_set_btree_ik_property ( const hid_t fcpl_id, const hsize_t btree_ik ) { - herr_t herr = H5Pset_istore_k (fcpl_id, btree_ik); - if (herr < 0) - h5_error ( - f, - H5_ERR_HDF5, - "Cannot set btree size in the " - "file access property list."); - return H5_SUCCESS; + HDF5_WRAPPER_ENTER2 (h5_err_t, + "fapl_id=%d, btree_ik=%llu", + fcpl_id, btree_ik); + if (H5Pset_istore_k (fcpl_id, btree_ik) < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot set btree size in the " + "file access property list.")); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_err_t -h5priv_close_hdf5_property ( - h5_file_t* const f, +hdf5_close_property ( hid_t prop ) { - herr_t herr = H5Pclose (prop); - if (herr < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot close property."); - return H5_SUCCESS; + HDF5_WRAPPER_ENTER1 (h5_err_t, "prop=%d", prop); + if (H5Pclose (prop) < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot close property.")); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } /****** F i l e **************************************************************/ h5_err_t -h5priv_close_hdf5_file ( - h5_file_t* const f, - hid_t fileid +hdf5_close_file ( + hid_t file_id ) { - herr_t herr = H5Fclose (fileid); - if (herr < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot close file."); - return H5_SUCCESS; + HDF5_WRAPPER_ENTER2 (h5_err_t, + "file_id=%d (%s)", + file_id, + h5_get_objname (file_id)); + if (H5Fclose (file_id) < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot close file \"%s\".", + h5_get_objname (file_id))); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } /****** E r r o r h a n d l i n g ********************************************/ h5_err_t -h5priv_set_hdf5_errorhandler ( - h5_file_t* const f, +hdf5_set_errorhandler ( hid_t estack_id, H5E_auto_t func, void* client_data ) { - herr_t herr = H5Eset_auto (estack_id, func, client_data); - if (herr < 0) - return h5_error ( - f, - H5_ERR_INIT, - "Cannot initialize H5."); - return H5_SUCCESS; + HDF5_WRAPPER_ENTER3 (h5_err_t, + "estack_id=%d, func=0x%p, client_data=0x%p", + estack_id, func, client_data); + if (H5Eset_auto (estack_id, func, client_data) < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_INIT, + "Cannot initialize H5.")); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } /****** A t t r i b u t e ****************************************************/ hid_t -h5priv_open_hdf5_attribute ( - h5_file_t* const f, +hdf5_open_attribute ( hid_t loc_id, - const char* attr_name + const char* attrib_name ) { - hid_t attr_id = H5Aopen (loc_id, attr_name, H5P_DEFAULT); - if (attr_id < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot open attribute \"%s\" of \"%s\".", - attr_name, - h5_get_objname (loc_id)); - return attr_id; + HDF5_WRAPPER_ENTER3 (hid_t, + "loc_id=%d (%s), attr_name=\"%s\"", + loc_id, h5_get_objname (loc_id), attrib_name); + hid_t attrib_id = H5Aopen (loc_id, attrib_name, H5P_DEFAULT); + if (attrib_id < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot open attribute \"%s\" of \"%s\".", + attrib_name, + h5_get_objname (loc_id))); + HDF5_WRAPPER_RETURN (attrib_id); } hid_t -h5priv_open_hdf5_attribute_idx ( - h5_file_t* const f, +hdf5_open_attribute_idx ( hid_t loc_id, unsigned int idx ) { + HDF5_WRAPPER_ENTER3 (hid_t, + "loc_id=%d (%s), idx=%u", + loc_id, h5_get_objname (loc_id), idx); hid_t attr_id = H5Aopen_idx (loc_id, idx); if (attr_id < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot open attribute \"%u\" of \"%s\".", - idx, - h5_get_objname (loc_id)); - return attr_id; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot open attribute \"%u\" of \"%s\".", + idx, + h5_get_objname (loc_id))); + HDF5_WRAPPER_RETURN (attr_id); } hid_t -h5priv_open_hdf5_attribute_by_name ( - h5_file_t* const f, +hdf5_open_attribute_by_name ( hid_t loc_id, const char* obj_name, const char* attr_name ) { + HDF5_WRAPPER_ENTER4 (hid_t, + "loc_id=%d (%s), obj_name=\"%s\", attr_name=\"%s\"", + loc_id, h5_get_objname (loc_id), + obj_name, attr_name); hid_t attr_id = H5Aopen_by_name ( loc_id, obj_name, @@ -1024,18 +1100,17 @@ h5priv_open_hdf5_attribute_by_name ( H5P_DEFAULT, H5P_DEFAULT); if (attr_id < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot open attribute \"%s\" of \"%s\".", - attr_name, - obj_name); - return attr_id; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot open attribute \"%s\" of \"%s\".", + attr_name, + obj_name)); + HDF5_WRAPPER_RETURN (attr_id); } hid_t -h5priv_create_hdf5_attribute ( - h5_file_t* const f, +hdf5_create_attribute ( hid_t loc_id, const char* attr_name, hid_t type_id, @@ -1043,6 +1118,10 @@ h5priv_create_hdf5_attribute ( hid_t acpl_id, hid_t aapl_id ) { + HDF5_WRAPPER_ENTER4 (hid_t, + "loc_id=%d (%s), attr_name=\"%s\", type_id=%d", + loc_id, h5_get_objname (loc_id), + attr_name, type_id); hid_t attr_id = H5Acreate ( loc_id, attr_name, @@ -1051,139 +1130,154 @@ h5priv_create_hdf5_attribute ( acpl_id, aapl_id); if (attr_id < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot create attribute \"%s\" for \"%s\".", - attr_name, - h5_get_objname (loc_id)); - return attr_id; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot create attribute \"%s\" for \"%s\".", + attr_name, + h5_get_objname (loc_id))); + HDF5_WRAPPER_RETURN (attr_id); } h5_err_t -h5priv_read_hdf5_attribute ( - h5_file_t* const f, +hdf5_read_attribute ( hid_t attr_id, hid_t mem_type_id, void* buf ) { - herr_t herr = H5Aread (attr_id, mem_type_id, buf); - if (herr < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot read attribute \"%s\".", - h5_get_objname (attr_id)); - - return H5_SUCCESS; + HDF5_WRAPPER_ENTER4 (h5_err_t, + "attr_id=%d (%s), mem_type_id=%d, buf=0x%p", + attr_id, h5_get_objname (attr_id), + mem_type_id, buf); + if (H5Aread (attr_id, mem_type_id, buf) < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot read attribute \"%s\".", + h5_get_objname (attr_id))); + HDF5_WRAPPER_RETURN (H5_SUCCESS); } /* Wrapper for H5Awrite. */ h5_err_t -h5priv_write_hdf5_attribute ( - h5_file_t* const f, +hdf5_write_attribute ( hid_t attr_id, hid_t mem_type_id, const void* buf ) { - herr_t herr = H5Awrite (attr_id, mem_type_id, buf); - if (herr < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot write attribute \"%s\".", - h5_get_objname (attr_id)); + HDF5_WRAPPER_ENTER4 (h5_err_t, + "attr_id=%d (%s), mem_type_id=%d, buf=0x%p", + attr_id, h5_get_objname (attr_id), + mem_type_id, buf); + if (H5Awrite (attr_id, mem_type_id, buf) < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot write attribute \"%s\".", + h5_get_objname (attr_id))); - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } h5_ssize_t -h5priv_get_hdf5_attribute_name ( - h5_file_t * const f, +hdf5_get_attribute_name ( hid_t attr_id, size_t buf_size, char *buf ) { + HDF5_WRAPPER_ENTER4 (h5_ssize_t, + "attr_id=%d (%s), buf_size=%zd, buf=0x%p", + attr_id, h5_get_objname (attr_id), + buf_size, buf); ssize_t size = H5Aget_name ( attr_id, buf_size, buf ); - if ( size < 0 ) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get attribute name." ); - return (h5_size_t)size; + if (size < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get attribute name." )); + HDF5_WRAPPER_RETURN ((h5_size_t)size); } hid_t -h5priv_get_hdf5_attribute_type ( - h5_file_t* const f, +hdf5_get_attribute_type ( hid_t attr_id ) { + HDF5_WRAPPER_ENTER2 (hid_t, + "attr_id=%d (%s)", + attr_id, h5_get_objname (attr_id)); hid_t datatype_id = H5Aget_type (attr_id); if (datatype_id < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get type of attribute \"%s\".", - h5_get_objname (attr_id)); - return datatype_id; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get type of attribute \"%s\".", + h5_get_objname (attr_id))); + HDF5_WRAPPER_RETURN (datatype_id); } hid_t -h5priv_get_hdf5_attribute_dataspace ( - h5_file_t* const f, +hdf5_get_attribute_dataspace ( hid_t attr_id ) { + HDF5_WRAPPER_ENTER2 (hid_t, + "attr_id=%d (%s)", + attr_id, h5_get_objname (attr_id)); hid_t space_id = H5Aget_space (attr_id); if (space_id < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get dataspace of attribute \"%s\".", - h5_get_objname (attr_id)); - return space_id; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get dataspace of attribute \"%s\".", + h5_get_objname (attr_id))); + HDF5_WRAPPER_RETURN (space_id); } int -h5priv_get_num_hdf5_attribute ( - h5_file_t* const f, +hdf5_get_num_attribute ( hid_t loc_id ) { + HDF5_WRAPPER_ENTER2 (int, + "loc_id=%d (%s)", + loc_id, h5_get_objname (loc_id)); int num = H5Aget_num_attrs (loc_id); if (num < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get number of attributes of \"%s\".", - h5_get_objname (loc_id)); - return num; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get number of attributes of \"%s\".", + h5_get_objname (loc_id))); + HDF5_WRAPPER_RETURN (num); } h5_err_t -h5priv_close_hdf5_attribute ( - h5_file_t* const f, +hdf5_close_attribute ( hid_t attr_id ) { - herr_t herr = H5Aclose (attr_id); - if (herr < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot close attribute \"%s\".", - h5_get_objname (attr_id)); + HDF5_WRAPPER_ENTER2 (h5_err_t, + "attr_id=%d (%s)", + attr_id, h5_get_objname (attr_id)); + if (H5Aclose (attr_id)) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot close attribute \"%s\".", + h5_get_objname (attr_id))); - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } /****** L i n k **************************************************************/ h5_err_t -h5priv_hdf5_link_exists ( - h5_file_t* const f, +hdf5_link_exists ( const hid_t loc_id, const char* name ) { + HDF5_WRAPPER_ENTER3 (h5_err_t, + "loc_id=%d (%s), name=\"%s\"", + loc_id, h5_get_objname (loc_id), name); /* Save old error handler */ H5E_auto2_t old_func; void *old_client_data; @@ -1200,29 +1294,31 @@ h5priv_hdf5_link_exists ( H5Eset_auto(H5E_DEFAULT, old_func, old_client_data); if (exists < 0 ) - return h5_error (f, - H5_ERR_HDF5, - "Cannot query link %s/%s.", - h5_get_objname (loc_id), name); - return exists; + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot query link %s/%s.", + h5_get_objname (loc_id), name)); + HDF5_WRAPPER_RETURN (exists); } h5_err_t -h5priv_delete_hdf5_link ( - h5_file_t* const f, +hdf5_delete_link ( hid_t loc_id, const char* name, hid_t lapl_id ) { - herr_t herr = H5Ldelete (loc_id, name, lapl_id); - if (herr < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot remove link %s/%s.", - h5_get_objname (loc_id), name); + HDF5_WRAPPER_ENTER4 (h5_err_t, + "loc_id=%d (%s), name=\"%s\", lapl_id=%d", + loc_id, h5_get_objname (loc_id), name, lapl_id); + if (H5Ldelete (loc_id, name, lapl_id) < 0) + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot remove link %s/%s.", + h5_get_objname (loc_id), name)); - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } typedef struct op_data { @@ -1232,65 +1328,70 @@ typedef struct op_data { char *name; size_t len; char *prefix; - h5_file_t *f; } op_data_t; static H5O_type_t -_iter_op_get_obj_type ( - h5_file_t *const f, +iter_op_get_obj_type ( const hid_t g_id, const char* name, const H5L_info_t* info ) { + H5_PRIV_FUNC_ENTER3 (H5O_type_t, + "g_id=%d, name=\"%s\", info=0x%p", + g_id, name, info); herr_t herr; H5O_info_t objinfo; if ( info->type == H5L_TYPE_EXTERNAL ) { char *buf; - TRY( buf = h5_calloc(f, 1, info->u.val_size) ); + TRY (buf = h5_calloc (1, info->u.val_size)); herr = H5Lget_val(g_id, name, buf, info->u.val_size, H5P_DEFAULT); - if ( herr < 0 ) - return (H5O_type_t)h5_error (f, - H5_ERR_HDF5, - "Can't get external link for object '%s'!", - name); + if (herr < 0) + H5_PRIV_FUNC_LEAVE ( + (H5O_type_t)h5_error ( + H5_ERR_HDF5, + "Can't get external link for object '%s'!", + name)); const char *filename; const char *objname; herr = H5Lunpack_elink_val(buf, info->u.val_size, 0, - &filename, &objname); - if ( herr < 0 ) - return (H5O_type_t)h5_error(f, - H5_ERR_HDF5, - "Can't unpack external link for object '%s'!", - name); - - h5_debug(f, + &filename, &objname); + if (herr < 0) + H5_PRIV_FUNC_LEAVE ( + (H5O_type_t)h5_error( + H5_ERR_HDF5, + "Can't unpack external link for object '%s'!", + name)); + + h5_debug( "Followed external link to file '%s' / object '%s'.", filename, objname); - h5_free(f, buf); + h5_free (buf); hid_t obj_id = H5Oopen(g_id, name, H5P_DEFAULT); - if ( obj_id < 0 ) - return (H5O_type_t)h5_error(f, - H5_ERR_HDF5, - "Can't open external link for object '%s'!", - name); + if (obj_id < 0) + H5_PRIV_FUNC_LEAVE ( + (H5O_type_t)h5_error( + H5_ERR_HDF5, + "Can't open external link for object '%s'!", + name)); herr = H5Oget_info(obj_id, &objinfo); } else { // H5L_TYPE_HARD herr = H5Oget_info_by_name(g_id, name, &objinfo, H5P_DEFAULT); } - if ( herr < 0 ) - return (H5O_type_t)h5_error(f, - H5_ERR_HDF5, - "Can't query object with name '%s'!", name); + if (herr < 0) + H5_PRIV_FUNC_LEAVE ( + (H5O_type_t)h5_error( + H5_ERR_HDF5, + "Can't query object with name '%s'!", name)); - return objinfo.type; + H5_PRIV_FUNC_RETURN (objinfo.type); } static herr_t @@ -1300,12 +1401,16 @@ iter_op_count ( const H5L_info_t* info, void* _op_data ) { + H5_PRIV_FUNC_ENTER4 (herr_t, + "g_id=%d, name=\"%s\", info=0x%p, _op_data=0x%p", + g_id, name, info, _op_data); op_data_t* op_data = (op_data_t*)_op_data; H5O_type_t type; - TRY( type = _iter_op_get_obj_type(op_data->f, g_id, name, info) ); - if ( type != op_data->type ) return 0; + TRY (type = iter_op_get_obj_type (g_id, name, info)); + if (type != op_data->type ) + H5_PRIV_FUNC_LEAVE (0); op_data->cnt++; - return 0; + H5_PRIV_FUNC_RETURN (0); } static herr_t @@ -1315,18 +1420,22 @@ iter_op_idx ( const H5L_info_t* info, void* _op_data ) { + H5_PRIV_FUNC_ENTER4 (herr_t, + "g_id=%d, name=\"%s\", info=0x%p, _op_data=0x%p", + g_id, name, info, _op_data); op_data_t* op_data = (op_data_t*)_op_data; H5O_type_t type; - TRY( type = _iter_op_get_obj_type(op_data->f, g_id, name, info) ); - if ( type != op_data->type ) return 0; + TRY (type = iter_op_get_obj_type (g_id, name, info)); + if (type != op_data->type) + H5_PRIV_FUNC_LEAVE (0); op_data->cnt++; /* stop iterating if index is equal cnt */ if (op_data->queried_idx == op_data->cnt) { memset (op_data->name, 0, op_data->len); strncpy (op_data->name, name, op_data->len-1); - return 1; + H5_PRIV_FUNC_LEAVE (1); } - return 0; + H5_PRIV_FUNC_RETURN (0); } static herr_t @@ -1336,22 +1445,27 @@ iter_op_count_match ( const H5L_info_t* info, void* _op_data ) { + H5_PRIV_FUNC_ENTER4 (herr_t, + "g_id=%d, name=\"%s\", info=0x%p, _op_data=0x%p", + g_id, name, info, _op_data); op_data_t* op_data = (op_data_t*)_op_data; H5O_type_t type; - TRY( type = _iter_op_get_obj_type(op_data->f, g_id, name, info) ); - if ( type != op_data->type ) return 0; + TRY (type = iter_op_get_obj_type (g_id, name, info)); + if (type != op_data->type) + H5_PRIV_FUNC_LEAVE (0); /* count if prefix matches */ if (strncmp (name, op_data->prefix, strlen(op_data->prefix)) == 0) { op_data->cnt++; } - return 0; + H5_PRIV_FUNC_RETURN (0); } ssize_t h5_get_num_hdf5_groups ( - h5_file_t* const f, const hid_t loc_id ) { + HDF5_WRAPPER_ENTER2 (ssize_t, + "loc_id=%d (%s)", loc_id, h5_get_objname (loc_id)); op_data_t op_data; memset (&op_data, 0, sizeof (op_data)); op_data.type = H5O_TYPE_GROUP; @@ -1360,24 +1474,25 @@ h5_get_num_hdf5_groups ( &start_idx, iter_op_count, &op_data); if (herr < 0) { - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get number of groups in \"%s\".", - h5_get_objname (loc_id)); + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get number of groups in \"%s\".", + h5_get_objname (loc_id))); } - return op_data.cnt; + HDF5_WRAPPER_RETURN (op_data.cnt); } ssize_t h5_get_num_hdf5_groups_matching_prefix ( - h5_file_t* const f, const hid_t loc_id, char* prefix ) { + HDF5_WRAPPER_ENTER3 (ssize_t, + "loc_id=%d (%s), prefix=\"%s\"", + loc_id, h5_get_objname (loc_id), prefix); op_data_t op_data; memset (&op_data, 0, sizeof (op_data)); - op_data.f = f; op_data.type = H5O_TYPE_GROUP; op_data.prefix = prefix; hsize_t start_idx = 0; @@ -1385,26 +1500,29 @@ h5_get_num_hdf5_groups_matching_prefix ( &start_idx, iter_op_count_match, &op_data); if (herr < 0) { - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get number of groups with prefix \"%s\" in \"%s\".", - prefix, h5_get_objname (loc_id)); + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get number of groups with prefix" + " \"%s\" in \"%s\".", + prefix, h5_get_objname (loc_id))); } - return op_data.cnt; + HDF5_WRAPPER_RETURN (op_data.cnt); } h5_err_t h5_get_hdf5_groupname_by_idx ( - h5_file_t* const f, hid_t loc_id, hsize_t idx, char *name, size_t len ) { + HDF5_WRAPPER_ENTER5 (h5_err_t, + "loc_id=%d (%s), idx=%llu, name=0x%p, len=%zd", + loc_id, h5_get_objname (loc_id), + idx, name, len); op_data_t op_data; memset (&op_data, 0, sizeof (op_data)); - op_data.f = f; op_data.type = H5O_TYPE_GROUP; op_data.cnt = -1; op_data.queried_idx = idx; @@ -1415,36 +1533,38 @@ h5_get_hdf5_groupname_by_idx ( &start_idx, iter_op_idx, &op_data); if (herr < 0) { - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get name of group with index \"%lu\" in \"%s\".", - (long unsigned int)idx, h5_get_objname (loc_id)); + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get name of group with index" + " \"%lu\" in \"%s\".", + (long unsigned int)idx, + h5_get_objname (loc_id))); } - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } ssize_t h5_get_num_hdf5_datasets ( - h5_file_t* const f, const hid_t loc_id ) { + HDF5_WRAPPER_ENTER2 (ssize_t, + "loc_id=%d (%s)", loc_id, h5_get_objname (loc_id)); op_data_t op_data; memset (&op_data, 0, sizeof (op_data)); - op_data.f = f; op_data.type = H5O_TYPE_DATASET; hsize_t start_idx = 0; herr_t herr = H5Literate (loc_id, H5_INDEX_NAME, H5_ITER_INC, &start_idx, iter_op_count, &op_data); if (herr < 0) { - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get number of datasets in \"%s\".", - h5_get_objname (loc_id)); + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get number of datasets in \"%s\".", + h5_get_objname (loc_id))); } - return op_data.cnt; + HDF5_WRAPPER_RETURN (op_data.cnt); } /* @@ -1452,15 +1572,17 @@ h5_get_num_hdf5_datasets ( */ h5_err_t h5_get_hdf5_datasetname_by_idx ( - h5_file_t* const f, hid_t loc_id, hsize_t idx, char *name, size_t len ) { + HDF5_WRAPPER_ENTER5 (h5_err_t, + "loc_id=%d (%s), idx=%llu, name=0x%p, len=%zd", + loc_id, h5_get_objname (loc_id), + idx, name, len); op_data_t op_data; memset (&op_data, 0, sizeof (op_data)); - op_data.f = f; op_data.type = H5O_TYPE_DATASET; op_data.cnt = -1; op_data.queried_idx = idx; @@ -1471,13 +1593,15 @@ h5_get_hdf5_datasetname_by_idx ( &start_idx, iter_op_idx, &op_data); if (herr < 0) { - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot get name of dataset with index \"%lu\" in \"%s\".", - (long unsigned int)idx, h5_get_objname (loc_id)); + HDF5_WRAPPER_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Cannot get name of dataset with index" + " \"%lu\" in \"%s\".", + (long unsigned int)idx, + h5_get_objname (loc_id))); } - return H5_SUCCESS; + HDF5_WRAPPER_RETURN (H5_SUCCESS); } /****** I d e n t i f i e r **************************************************/ @@ -1498,15 +1622,3 @@ h5_get_objname ( return objname; } - -#if 0 -herr_t -h5priv_get_objinfo_by_name ( - hid_t loc_id, - const char *object_name, - H5O_info_t *object_info - ) { - herr_t herr = H5Oget_info_by_name ( - loc_id, object_name, object_info, H5P_DEFAULT); -} -#endif diff --git a/src/h5core/h5_hdf5_private.h b/src/h5core/h5_hdf5_private.h index 4e81e1d..c6dc721 100644 --- a/src/h5core/h5_hdf5_private.h +++ b/src/h5core/h5_hdf5_private.h @@ -3,15 +3,13 @@ /*** group ***/ hid_t -h5priv_open_hdf5_group ( - h5_file_t* const f, +hdf5_open_group ( const hid_t loc_id, const char* const group_name ); hid_t -h5priv_create_hdf5_group ( - h5_file_t* const f, +hdf5_create_group ( const hid_t loc_id, const char* const group_name ); @@ -24,20 +22,17 @@ h5priv_open_group ( ); h5_err_t -h5priv_close_hdf5_group ( - h5_file_t* const f, +hdf5_close_group ( const hid_t group_id ); h5_ssize_t -h5priv_get_num_objs_in_hdf5_group ( - h5_file_t* const f, +hdf5_get_num_objs_in_group ( const hid_t group_id ); h5_ssize_t -h5priv_get_hdf5_objname_by_idx ( - h5_file_t* const f, +hdf5_get_objname_by_idx ( hid_t loc_id, hsize_t idx, char* name, @@ -46,15 +41,13 @@ h5priv_get_hdf5_objname_by_idx ( /*** dataset ***/ hid_t -h5priv_open_hdf5_dataset ( - h5_file_t* const f, +hdf5_open_dataset ( const hid_t gid, const char* const dataset_name ); hid_t -h5priv_create_hdf5_dataset ( - h5_file_t* const f, +hdf5_create_dataset ( hid_t loc_id, const char* dataset_name, const hid_t type_id, @@ -63,14 +56,12 @@ h5priv_create_hdf5_dataset ( ); h5_err_t -h5priv_close_hdf5_dataset ( - h5_file_t* const f, +hdf5_close_dataset ( const hid_t dataset_id ); h5_err_t -h5priv_write_hdf5_dataset ( - h5_file_t* const f, +hdf5_write_dataset ( const hid_t dataset_id, const hid_t type_id, const hid_t memspace_id, @@ -80,8 +71,7 @@ h5priv_write_hdf5_dataset ( ); h5_err_t -h5priv_read_hdf5_dataset ( - h5_file_t* const f, +hdf5_read_dataset ( const hid_t dataset_id, const hid_t type_id, const hid_t memspace_id, @@ -90,54 +80,46 @@ h5priv_read_hdf5_dataset ( void* const buf ); hid_t -h5priv_get_hdf5_dataset_type ( - h5_file_t* const f, +hdf5_get_dataset_type ( const hid_t dataset_id ); h5_err_t -h5priv_set_hdf5_dataset_extent ( - h5_file_t* const f, +hdf5_set_dataset_extent ( hid_t dset_id, const hsize_t* size ); h5_ssize_t -h5priv_get_npoints_of_hdf5_dataset ( - h5_file_t* const f, +hdf5_get_npoints_of_dataset ( hid_t dset_id ); h5_ssize_t -h5priv_get_npoints_of_hdf5_dataset_by_name ( - h5_file_t* const f, +hdf5_get_npoints_of_dataset_by_name ( hid_t loc_id, char* name ); /*** dataspace ***/ hid_t -h5priv_create_hdf5_dataspace ( - h5_file_t* const f, +hdf5_create_dataspace ( const int rank, const hsize_t* dims, const hsize_t* maxdims ); hid_t -h5priv_create_hdf5_dataspace_scalar ( - h5_file_t* const f +hdf5_create_dataspace_scalar ( ); hid_t -h5priv_get_hdf5_dataset_space ( - h5_file_t* const f, +hdf5_get_dataset_space ( const hid_t dataset_id ); h5_err_t -h5priv_select_hyperslab_of_hdf5_dataspace ( - h5_file_t* const f, +hdf5_select_hyperslab_of_dataspace ( hid_t space_id, H5S_seloper_t op, const hsize_t* start, @@ -147,8 +129,7 @@ h5priv_select_hyperslab_of_hdf5_dataspace ( ); h5_err_t -h5priv_select_elements_of_hdf5_dataspace ( - h5_file_t* const f, +hdf5_select_elements_of_dataspace ( hid_t space_id, H5S_seloper_t op, hsize_t nelems, @@ -156,26 +137,22 @@ h5priv_select_elements_of_hdf5_dataspace ( ); h5_ssize_t -h5priv_get_selected_npoints_of_hdf5_dataspace ( - h5_file_t* const f, +hdf5_get_selected_npoints_of_dataspace ( hid_t space_id ); h5_ssize_t -h5priv_get_npoints_of_hdf5_dataspace ( - h5_file_t* const f, +hdf5_get_npoints_of_dataspace ( hid_t space_id ); h5_err_t -h5priv_close_hdf5_dataspace ( - h5_file_t* const f, +hdf5_close_dataspace ( const hid_t dataspace_id ); int -h5priv_get_dims_of_hdf5_dataspace ( - h5_file_t* const f, +hdf5_get_dims_of_dataspace ( hid_t space_id, hsize_t* dims, hsize_t* maxdims @@ -183,29 +160,25 @@ h5priv_get_dims_of_hdf5_dataspace ( /*** type ***/ hid_t -h5priv_create_hdf5_array_type ( - h5_file_t* const f, +hdf5_create_array_type ( hid_t base_type_id, int rank, const hsize_t* dims ); hid_t -h5priv_create_hdf5_type ( - h5_file_t* const f, +hdf5_create_type ( H5T_class_t _class, const size_t size ); hid_t -h5priv_create_hdf5_string_type( - h5_file_t *const f, +hdf5_create_string_type( const hsize_t len ); h5_err_t -h5priv_insert_hdf5_type ( - h5_file_t* const f, +hdf5_insert_type ( hid_t dtype_id, const char* name, size_t offset, @@ -213,118 +186,102 @@ h5priv_insert_hdf5_type ( ); h5_err_t -h5priv_close_hdf5_type ( - h5_file_t* const f, +hdf5_close_type ( hid_t dtype_id ); /*** property ***/ hid_t -h5priv_create_hdf5_property ( - h5_file_t* const f, +hdf5_create_property ( hid_t cls_id ); hid_t -h5priv_get_hdf5_dataset_create_plist ( - h5_file_t* const f, +hdf5_get_dataset_create_plist ( const hid_t dataset_id ); h5_err_t -h5priv_set_hdf5_chunk_property ( - h5_file_t* const f, +hdf5_set_chunk_property ( hid_t plist, int rank, hsize_t* dims ); h5_err_t -h5priv_get_hdf5_chunk_property ( - h5_file_t* const f, +hdf5_get_chunk_property ( hid_t plist, int rank, hsize_t* dims ); h5_err_t -h5priv_set_hdf5_layout_property ( - h5_file_t* const f, +hdf5_set_layout_property ( hid_t plist, H5D_layout_t layout ); #ifdef PARALLEL_IO h5_err_t -h5priv_set_hdf5_fapl_mpio_property ( - h5_file_t* const f, +hdf5_set_fapl_mpio_property ( hid_t fapl_id, MPI_Comm comm, MPI_Info info ); h5_err_t -h5priv_set_hdf5_fapl_mpiposix_property ( - h5_file_t* const f, +hdf5_set_fapl_mpiposix_property ( hid_t fapl_id, MPI_Comm comm, hbool_t use_gpfs ); h5_err_t -h5priv_set_hdf5_dxpl_mpio_property ( - h5_file_t* const f, +hdf5_set_dxpl_mpio_property ( hid_t dxpl_id, H5FD_mpio_xfer_t mode ); #endif h5_err_t -h5priv_set_hdf5_mdc_property ( - h5_file_t* const f, +hdf5_set_mdc_property ( hid_t fapl_id, H5AC_cache_config_t *config ); h5_err_t -h5priv_get_hdf5_mdc_property ( - h5_file_t* const f, +hdf5_get_mdc_property ( hid_t fapl_id, H5AC_cache_config_t *config ); h5_err_t -h5priv_set_hdf5_alignment_property ( - h5_file_t* const f, +hdf5_set_alignment_property ( const hid_t fapl_id, const hsize_t threshold, const hsize_t alignment ); h5_err_t -h5priv_set_hdf5_btree_ik_property ( - h5_file_t* const f, +hdf5_set_btree_ik_property ( const hid_t fcpl_id, const hsize_t btree_ik ); h5_err_t -h5priv_close_hdf5_property ( - h5_file_t* const f, +hdf5_close_property ( hid_t prop ); /*** file ***/ h5_err_t -h5priv_close_hdf5_file ( - h5_file_t* const f, +hdf5_close_file ( hid_t fileid ); /*** error handling ***/ h5_err_t -h5priv_set_hdf5_errorhandler ( - h5_file_t* const f, +hdf5_set_errorhandler ( hid_t estack_id, H5E_auto_t func, void* client_data @@ -332,30 +289,26 @@ h5priv_set_hdf5_errorhandler ( /*** attributes ***/ hid_t -h5priv_open_hdf5_attribute ( - h5_file_t* const f, +hdf5_open_attribute ( hid_t loc_id, const char *attr_name ); hid_t -h5priv_open_hdf5_attribute_idx ( - h5_file_t* const f, +hdf5_open_attribute_idx ( hid_t loc_id, unsigned int idx ); hid_t -h5priv_open_hdf5_attribute_by_name ( - h5_file_t* const f, +hdf5_open_attribute_by_name ( hid_t loc_id, const char* obj_name, const char* attr_name ); hid_t -h5priv_create_hdf5_attribute ( - h5_file_t* const f, +hdf5_create_attribute ( hid_t loc_id, const char* attr_name, hid_t type_id, @@ -365,70 +318,60 @@ h5priv_create_hdf5_attribute ( ); h5_err_t -h5priv_read_hdf5_attribute ( - h5_file_t* const f, +hdf5_read_attribute ( hid_t attr_id, hid_t mem_type_id, void* buf ); h5_err_t -h5priv_write_hdf5_attribute ( - h5_file_t* const f, +hdf5_write_attribute ( hid_t attr_id, hid_t mem_type_id, const void* buf ); h5_ssize_t -h5priv_get_hdf5_attribute_name ( - h5_file_t* const f, +hdf5_get_attribute_name ( hid_t attr_id, size_t buf_size, char* buf ); hid_t -h5priv_get_hdf5_attribute_type ( - h5_file_t* const f, +hdf5_get_attribute_type ( hid_t attr_id ); hid_t -h5priv_get_hdf5_attribute_dataspace ( - h5_file_t* const f, +hdf5_get_attribute_dataspace ( hid_t attr_id ); int -h5priv_get_num_hdf5_attribute ( - h5_file_t* const f, +hdf5_get_num_attribute ( hid_t loc_id ); h5_err_t -h5priv_close_hdf5_attribute ( - h5_file_t* const f, +hdf5_close_attribute ( hid_t attr_id ); -const char* -h5priv_get_base_type_name ( - h5_file_t* const f, +char_p +hdf5_get_type_name ( hid_t base_type_id ); /*** link ***/ h5_err_t -h5priv_hdf5_link_exists ( - h5_file_t* const f, +hdf5_link_exists ( const hid_t loc_id, const char* name ); h5_err_t -h5priv_delete_hdf5_link ( - h5_file_t* const f, +hdf5_delete_link ( hid_t loc_id, const char* name, hid_t lapl_id diff --git a/src/h5core/h5_hsearch.c b/src/h5core/h5_hsearch.c index 9de693e..7656568 100644 --- a/src/h5core/h5_hsearch.c +++ b/src/h5core/h5_hsearch.c @@ -68,12 +68,11 @@ h5priv_hcreate ( unsigned int (*compute_hash)(const void*), h5_err_t (*free_entry)(h5_file_t* const f, const void*) ) { - H5_CORE_API_ENTER; - h5_err_t h5err = H5_SUCCESS; + H5_PRIV_API_ENTER (h5_err_t); /* Test for correct arguments. */ if (htab == NULL || htab->table != NULL) { - TRY2( h5_error_internal (f, __FILE__, __func__, __LINE__) ); + H5_PRIV_API_LEAVE (h5_error_internal (__FILE__, __func__, __LINE__)); } /* Change nel to the first prime number not smaller as nel. */ nel |= 1; /* make odd */ @@ -87,11 +86,11 @@ h5priv_hcreate ( htab->free_entry = free_entry; /* allocate memory and zero out */ - TRY2( (htab->table = (_ENTRY *) h5_calloc ( - f, htab->size + 1, sizeof (_ENTRY))) ); + TRY (htab->table = (_ENTRY *) h5_calloc ( + htab->size + 1, sizeof (_ENTRY))); /* everything went alright */ - H5_CORE_API_RETURN (h5err); + H5_PRIV_API_RETURN (H5_SUCCESS); } /* @@ -103,40 +102,38 @@ h5priv_hresize ( size_t nel, // number of entries to grow h5_hashtable_t* htab // hash table to resize ) { - H5_CORE_API_ENTER; - h5_err_t h5err = H5_SUCCESS; + H5_PRIV_API_ENTER (h5_err_t); if (htab == NULL || htab->table == NULL) { - TRY2( h5_error_internal (f, __FILE__, __func__, __LINE__) ); + H5_PRIV_API_LEAVE (h5_error_internal (__FILE__, __func__, __LINE__)); } // create new hash table h5_hashtable_t __htab; memset (&__htab, 0, sizeof (__htab)); nel += htab->size; - h5_debug (f, "Resize hash table from %u to %lu elements.", - htab->size, nel); - TRY2( h5priv_hcreate (f, nel, &__htab, htab->compare, - htab->compute_hash, htab->free_entry) ); + h5_debug ("Resize hash table from %u to %lu elements.", htab->size, nel); + TRY (h5priv_hcreate (f, nel, &__htab, htab->compare, + htab->compute_hash, htab->free_entry)); // add all entries to new hash table unsigned int idx; for (idx = 1; idx <= htab->size; idx++) { if (htab->table[idx].used) { void* ventry; - TRY2( h5priv_hsearch ( + TRY (h5priv_hsearch ( f, htab->table[idx].entry, H5_ENTER, &ventry, - &__htab) ); + &__htab)); } } /* Free used memory. */ - TRY2( h5_free (f, htab->table) ); + TRY (h5_free (htab->table)); /* the sign for an existing table is an value != NULL in htable */ htab->table = NULL; *htab = __htab; - H5_CORE_API_RETURN (h5err); + H5_PRIV_API_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -145,13 +142,14 @@ hwalk ( struct hsearch_data* htab, h5_err_t (*visit)(h5_file_t*const f, const void *item) ) { + H5_PRIV_FUNC_ENTER (h5_err_t); unsigned int idx = 1; for (idx = 1; idx < htab->size; idx++) { if (htab->table[idx].used) { - TRY( (*visit)(f, &htab->table[idx].entry) ); + TRY ((*visit)(f, &htab->table[idx].entry)); } } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } @@ -162,21 +160,20 @@ h5priv_hdestroy ( h5_file_t* const f, struct hsearch_data* htab ) { - H5_CORE_API_ENTER; - h5_err_t ret_value = H5_SUCCESS; + H5_PRIV_API_ENTER (h5_err_t); /* Test for correct arguments. */ if (htab == NULL) { - TRY2( h5_error_internal (f, __FILE__, __func__, __LINE__) ); + H5_PRIV_API_LEAVE (h5_error_internal (__FILE__, __func__, __LINE__)); } - TRY2( hwalk (f, htab, htab->free_entry) ); + TRY (hwalk (f, htab, htab->free_entry)); /* Free used memory. */ - TRY2( h5_free (f, htab->table) ); + TRY (h5_free (htab->table)); /* the sign for an existing table is an value != NULL in htable */ htab->table = NULL; - H5_CORE_API_RETURN (ret_value); + H5_PRIV_API_RETURN (H5_SUCCESS); } @@ -202,8 +199,7 @@ h5priv_hsearch ( void** retval, struct hsearch_data* htab ) { - H5_CORE_API_ENTER; - h5_err_t ret_value = H5_SUCCESS; + H5_PRIV_API_ENTER (h5_err_t); unsigned int hval; unsigned int idx; @@ -221,7 +217,7 @@ h5priv_hsearch ( if (retval) { *retval = htab->table[idx].entry; } - H5_GOTO_DONE (H5_SUCCESS); + H5_PRIV_API_LEAVE (H5_SUCCESS); } /* Second hash function, as suggested in [Knuth] */ @@ -248,7 +244,7 @@ h5priv_hsearch ( if (retval) { *retval = htab->table[idx].entry; } - H5_GOTO_DONE (H5_SUCCESS); + H5_PRIV_API_LEAVE (H5_SUCCESS); } } while (htab->table[idx].used); } @@ -258,11 +254,10 @@ h5priv_hsearch ( /* If table is full and another entry should be entered return with error. */ if (htab->filled == htab->size) { - h5_error_internal (f, __FILE__, __func__, __LINE__); if (retval) { *retval = NULL; } - H5_GOTO_DONE (H5_ERR); + H5_PRIV_API_LEAVE (h5_error_internal (__FILE__, __func__, __LINE__)); } htab->table[idx].used = hval; @@ -273,16 +268,15 @@ h5priv_hsearch ( if (retval) { *retval = htab->table[idx].entry; } - H5_GOTO_DONE (H5_SUCCESS); + H5_PRIV_API_LEAVE (H5_SUCCESS); } else if (action == H5_REMOVE) { htab->table[idx].used = 0; /* mark as unused, but */ *retval = htab->table[idx].entry; /* return ptr to entry */ - H5_GOTO_DONE (H5_SUCCESS); + H5_PRIV_API_LEAVE (H5_SUCCESS); } if (retval) *retval = NULL; - h5_debug (f, "Key not found in hash table."); - ret_value = H5_NOK; - H5_CORE_API_RETURN (ret_value); + h5_debug ("Key not found in hash table."); + H5_PRIV_API_RETURN (H5_NOK); } typedef struct { @@ -319,10 +313,11 @@ free_string_keyed ( h5_file_t* const f, const void* __entry ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_hitem_string_keyed_t* entry = (h5_hitem_string_keyed_t*) __entry; - TRY( h5_free (f, entry->key) ); - TRY( h5_free (f, entry) ); - return H5_SUCCESS; + TRY (h5_free (entry->key)); + TRY (h5_free (entry)); + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } h5_err_t @@ -332,37 +327,17 @@ h5priv_hcreate_string_keyed ( h5_hashtable_t* htab, h5_err_t (*free_entry)(h5_file_t* const f, const void*) ) { - H5_CORE_API_ENTER; - h5_err_t ret_value = H5_SUCCESS; + H5_PRIV_API_ENTER (h5_err_t); if (free_entry == NULL) { - TRY2( ret_value = h5priv_hcreate (f, nel, htab, - cmp_string_keyed, - compute_string_keyed, - free_string_keyed) ); + TRY (h5priv_hcreate (f, nel, htab, + cmp_string_keyed, + compute_string_keyed, + free_string_keyed)); } else { - TRY2( ret_value = h5priv_hcreate (f, nel, htab, - cmp_string_keyed, - compute_string_keyed, - free_entry) ); + TRY (h5priv_hcreate (f, nel, htab, + cmp_string_keyed, + compute_string_keyed, + free_entry)); } - H5_CORE_API_RETURN (ret_value); + H5_PRIV_API_RETURN (H5_SUCCESS); } - -#if 0 -static unsigned int -hcompute_loc_id_keyed ( - const void*__item - ) { - register uint16_t* key = (uint16_t*)__item; - register int count = sizeof(h5_loc_id_t)/sizeof(uint16_t); - register unsigned int hval = sizeof (h5_loc_id_t); - while (count--) { - if (*key) { - hval <<= 6; - hval += *key; - } - key++; - } - return hval; -} -#endif diff --git a/src/h5core/h5_lustre.c b/src/h5core/h5_lustre.c index b10031a..375ef45 100644 --- a/src/h5core/h5_lustre.c +++ b/src/h5core/h5_lustre.c @@ -33,7 +33,7 @@ _get_lustre_stripe_size(h5_file_t *const f, const char *path ) size_t nbytes = sizeof(struct lov_user_md) + INIT_ALLOC_NUM_OSTS * sizeof(struct lov_user_ost_data); struct lov_user_md *lum; - TRY( lum = h5_calloc(f, 1, nbytes) ); + TRY( lum = h5_calloc (1, nbytes) ); lum->lmm_magic = LOV_USER_MAGIC; int fd = open64(path, O_RDONLY); @@ -84,7 +84,7 @@ _get_lustre_stripe_size(h5_file_t *const f, const char *path ) _print_stripe_info(lum); ssize_t stripe_size = (ssize_t)lum->lmm_stripe_size; - h5_free(f, lum); + h5_free(lum); return stripe_size; } @@ -98,7 +98,7 @@ h5_optimize_for_lustre ( ssize_t stripe_size; if ( f->myproc == 0 ) { - char *path = h5_calloc(f, 1, strlen(filename)+4); + char *path = h5_calloc (1, strlen(filename)+4); strcpy(path, filename); /* check for existing file */ FILE *test = fopen(path, "r"); @@ -116,7 +116,7 @@ h5_optimize_for_lustre ( stripe_size = _get_lustre_stripe_size(f, path); - h5_free(f, path); + h5_free(path); } TRY( h5priv_mpi_bcast(f, &stripe_size, 1, MPI_LONG_LONG, 0, f->comm) ); @@ -129,10 +129,10 @@ h5_optimize_for_lustre ( h5_info(f, MSG_HEADER "Setting HDF5 btree ik to %lld (= %lld bytes at rank 3)", (long long)btree_ik, (long long)btree_bytes); - TRY( h5priv_set_hdf5_btree_ik_property(f, f->create_prop, btree_ik) ); + TRY( hdf5_set_btree_ik_property(f, f->create_prop, btree_ik) ); /* set alignment to lustre stripe size */ - TRY( h5priv_set_hdf5_alignment_property(f, + TRY( hdf5_set_alignment_property(f, f->access_prop, 0, stripe_size) ); h5_info(f, MSG_HEADER "Disabling metadata cache flushes."); diff --git a/src/h5core/h5_maps.c b/src/h5core/h5_maps.c index 99fc7e2..b99a196 100644 --- a/src/h5core/h5_maps.c +++ b/src/h5core/h5_maps.c @@ -19,9 +19,11 @@ h5priv_alloc_idlist ( h5_loc_idlist_t** list, const h5_size_t size ) { - TRY( *list = h5_calloc (f, 1, sizeof (**list)+size*sizeof ((*list)->items[0])) ); + H5_PRIV_API_ENTER (h5_err_t); + TRY (*list = h5_calloc ( + 1, sizeof (**list)+size*sizeof ((*list)->items[0]))); (*list)->size = size; - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } h5_err_t @@ -29,10 +31,11 @@ h5priv_free_idlist ( h5_file_t* const f, h5_loc_idlist_t** list ) { + H5_PRIV_API_ENTER (h5_err_t); if (*list == NULL) return H5_SUCCESS; - TRY( h5_free( f, *list) ); + TRY (h5_free (*list)); *list = NULL; - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -41,10 +44,11 @@ grow_idlist ( h5_loc_idlist_t** list, size_t new_size ) { - size_t bytes_to_allocate = sizeof (**list) + (new_size-1)*sizeof((*list)->items[0]); - TRY( *list = h5_alloc (f, *list, bytes_to_allocate) ); + H5_PRIV_FUNC_ENTER (h5_err_t); + size_t num_bytes = sizeof (**list) + (new_size-1)*sizeof((*list)->items[0]); + TRY (*list = h5_alloc (*list, num_bytes)); (*list)->size = new_size; - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -57,8 +61,9 @@ h5priv_insert_idlist ( h5_loc_id_t id, h5_loc_idx_t idx ) { + H5_PRIV_API_ENTER (h5_loc_idx_t); if (*list == NULL) { - TRY( h5priv_alloc_idlist (f, list, 2) ); + TRY (h5priv_alloc_idlist (f, list, 2)); } else if ((*list)->num_items == (*list)->size) { h5_size_t size = (*list)->size; if (size == 0) { @@ -66,7 +71,7 @@ h5priv_insert_idlist ( } else { size *= 2; } - TRY( grow_idlist (f, list, size) ); + TRY (grow_idlist (f, list, size)); } h5_loc_idlist_t* l = *list; if (idx == -1) { @@ -79,7 +84,7 @@ h5priv_insert_idlist ( } l->items[idx] = id; l->num_items++; - return idx; + H5_PRIV_API_RETURN (idx); } /* @@ -91,9 +96,10 @@ h5priv_find_idlist ( h5_loc_idlist_t* list, const h5_loc_id_t item ) { + H5_PRIV_API_ENTER (h5_loc_id_t); UNUSED_ARGUMENT (f); if (!list) { - return -1; + H5_PRIV_API_LEAVE (-1); } register h5_loc_idx_t low = 0; register h5_loc_idx_t high = list->num_items - 1; @@ -113,9 +119,9 @@ h5priv_find_idlist ( else if ( diff < 0 ) low = mid + 1; else - return mid; // found + H5_PRIV_API_LEAVE (mid); // found } - return -(low+1); // not found + H5_PRIV_API_RETURN (-(low+1)); // not found } @@ -128,12 +134,13 @@ h5priv_search_idlist ( h5_loc_idlist_t** list, h5_loc_id_t item ) { + H5_PRIV_API_ENTER (h5_loc_idx_t); h5_loc_idx_t idx = h5priv_find_idlist (f, *list, item); if (idx < 0) { idx = -(idx+1); - idx = h5priv_insert_idlist (f, list, item, idx); + TRY (idx = h5priv_insert_idlist (f, list, item, idx)); } - return idx; + H5_PRIV_API_RETURN (idx); } @@ -143,12 +150,13 @@ h5priv_alloc_idxmap ( h5_idxmap_t* map, const h5_size_t size ) { + H5_PRIV_API_ENTER (h5_err_t); int new = (map->items == NULL); size_t size_in_bytes = size * sizeof (map->items[0]); - TRY( map->items = h5_alloc (f, map->items, size_in_bytes) ); + TRY (map->items = h5_alloc (map->items, size_in_bytes)); map->size = size; if (new) map->num_items = 0; - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } h5_err_t @@ -158,12 +166,15 @@ h5priv_insert_idxmap ( h5_glb_idx_t glb_idx, h5_loc_idx_t loc_idx ) { + H5_PRIV_API_ENTER (h5_err_t); if (map->num_items == map->size) - return HANDLE_H5_OVERFLOW_ERR (f, "g2lmap", (long long)map->size); + H5_PRIV_API_LEAVE ( + HANDLE_H5_OVERFLOW_ERR ( + "g2lmap", (long long)map->size)); h5_loc_idx_t i = h5priv_search_idxmap (map, glb_idx); if (i >= 0) /* global id already in use ? */ - return -1; + H5_PRIV_API_LEAVE (-1); i = -(i+1); @@ -175,7 +186,7 @@ h5priv_insert_idxmap ( map->items[i].loc_idx = loc_idx; map->num_items++; - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } /*! @@ -193,7 +204,6 @@ h5priv_search_idxmap ( h5_idxmap_t* map, h5_glb_idx_t value ) { - register h5_loc_idx_t low = 0; register h5_loc_idx_t high = map->num_items - 1; while (low <= high) { @@ -206,7 +216,7 @@ h5priv_search_idxmap ( else return mid; // found } - return -(low+1); // not found + return (-(low+1)); // not found } static int @@ -229,5 +239,5 @@ h5priv_sort_idxmap ( ) { qsort ( map->items, map->num_items, sizeof (map->items[0]), cmp_idxmap_items); - return H5_SUCCESS; + return (H5_SUCCESS); } diff --git a/src/h5core/h5_mpi.c b/src/h5core/h5_mpi.c index 3529e7f..3c3472e 100644 --- a/src/h5core/h5_mpi.c +++ b/src/h5core/h5_mpi.c @@ -23,7 +23,7 @@ h5priv_mpi_recv( MPI_STATUS_IGNORE ); if (err != MPI_SUCCESS) - return h5_error (f, H5_ERR_MPI, "Cannot receive data"); + return h5_error (H5_ERR_MPI, "Cannot receive data"); return H5_SUCCESS; } @@ -46,7 +46,7 @@ h5priv_mpi_send( comm ); if (err != MPI_SUCCESS) - return h5_error (f, H5_ERR_MPI, "Cannot send data"); + return h5_error (H5_ERR_MPI, "Cannot send data"); return H5_SUCCESS; } @@ -67,7 +67,7 @@ h5priv_mpi_bcast ( comm ); if (err != MPI_SUCCESS) - return h5_error (f, H5_ERR_MPI, "Cannot perform broadcast"); + return h5_error (H5_ERR_MPI, "Cannot perform broadcast"); return H5_SUCCESS; } @@ -91,7 +91,7 @@ h5priv_mpi_sum ( comm ); if (err != MPI_SUCCESS) - return h5_error (f, H5_ERR_MPI, "Cannot perform sum reduction"); + return h5_error (H5_ERR_MPI, "Cannot perform sum reduction"); return H5_SUCCESS; } @@ -113,7 +113,7 @@ h5priv_mpi_prefix_sum ( comm ); if (err != MPI_SUCCESS) - return h5_error (f, H5_ERR_MPI, "Cannot perform prefix sum"); + return h5_error (H5_ERR_MPI, "Cannot perform prefix sum"); return H5_SUCCESS; } @@ -137,7 +137,7 @@ h5priv_mpi_allgather ( recvtype, comm); if (err != MPI_SUCCESS) - return h5_error (f, H5_ERR_MPI, "Cannot gather data"); + return h5_error (H5_ERR_MPI, "Cannot gather data"); return H5_SUCCESS; } @@ -149,7 +149,7 @@ h5priv_mpi_comm_size ( ) { int err = MPI_Comm_size (comm, size); if (err != MPI_SUCCESS) - return h5_error (f, H5_ERR_MPI, "Cannot get communicator size"); + return h5_error (H5_ERR_MPI, "Cannot get communicator size"); return H5_SUCCESS; } @@ -162,7 +162,7 @@ h5priv_mpi_comm_rank ( ) { int err = MPI_Comm_rank (comm, rank); if (err != MPI_SUCCESS) - return h5_error (f, H5_ERR_MPI, "Cannot get this task's rank"); + return h5_error (H5_ERR_MPI, "Cannot get this task's rank"); return H5_SUCCESS; } @@ -176,10 +176,10 @@ h5priv_mpi_type_contiguous ( int err; err = MPI_Type_contiguous ( nelems, oldtype, newtype ); if (err != MPI_SUCCESS) - return h5_error (f, H5_ERR_MPI, "Cannot create new MPI type"); + return h5_error (H5_ERR_MPI, "Cannot create new MPI type"); err = MPI_Type_commit ( newtype ); if (err != MPI_SUCCESS) - return h5_error (f, H5_ERR_MPI, "Cannot commit new MPI type"); + return h5_error (H5_ERR_MPI, "Cannot commit new MPI type"); return H5_SUCCESS; } @@ -190,7 +190,7 @@ h5priv_mpi_type_free ( ) { int err = MPI_Type_free( type ); if (err != MPI_SUCCESS) - return h5_error(f, H5_ERR_MPI, "Cannot free MPI type"); + return h5_error(H5_ERR_MPI, "Cannot free MPI type"); return H5_SUCCESS; } @@ -207,7 +207,7 @@ h5priv_mpi_cart_create ( int err = MPI_Cart_create( old_comm, ndims, dims, period, reorder, new_comm); if (err != MPI_SUCCESS) - return h5_error(f, H5_ERR_MPI, "Cannot create cartesian grid"); + return h5_error(H5_ERR_MPI, "Cannot create cartesian grid"); return H5_SUCCESS; } @@ -221,7 +221,7 @@ h5priv_mpi_cart_coords ( ) { int err = MPI_Cart_coords( comm, rank, maxdim, coords ); if (err != MPI_SUCCESS) - return h5_error(f, H5_ERR_MPI, "Cannot create cartesian grid"); + return h5_error(H5_ERR_MPI, "Cannot create cartesian grid"); return H5_SUCCESS; } diff --git a/src/h5core/h5_openclose.c b/src/h5core/h5_openclose.c index 6fd71c7..ee4fc8e 100644 --- a/src/h5core/h5_openclose.c +++ b/src/h5core/h5_openclose.c @@ -30,7 +30,6 @@ h5_check_filehandle ( #endif ) { return h5_error ( - f, H5_ERR_BADFD, "Called with bad filehandle."); } @@ -67,7 +66,8 @@ static h5_err_t h5upriv_open_file ( h5_file_t* const f /*!< IN: file handle */ ) { - TRY( f->u = (h5u_fdata_t*)h5_alloc (f, NULL, sizeof (*f->u)) ); + H5_PRIV_API_ENTER (h5_err_t); + TRY (f->u = (h5u_fdata_t*)h5_alloc (NULL, sizeof (*f->u))); h5u_fdata_t *u = f->u; u->shape = -1; @@ -77,9 +77,9 @@ h5upriv_open_file ( u->viewend = -1; u->viewindexed = 0; - TRY( u->dcreate_prop = h5priv_create_hdf5_property(f, H5P_DATASET_CREATE) ); + TRY (u->dcreate_prop = hdf5_create_property (H5P_DATASET_CREATE)); - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } /*! @@ -97,19 +97,21 @@ static h5_err_t h5bpriv_open_file ( h5_file_t * const f /*!< IN: file handle */ ) { + H5_PRIV_API_ENTER (h5_err_t); h5b_fdata_t* b; - if ( f->b ) return H5_SUCCESS; + if (f->b) + H5_PRIV_API_LEAVE (H5_SUCCESS); - TRY( f->b = (h5b_fdata_t*)h5_alloc( f, NULL, sizeof (*f->b)) ); + TRY (f->b = (h5b_fdata_t*)h5_alloc (NULL, sizeof (*f->b))); b = f->b; memset (b, 0, sizeof (*b)); #if defined(PARALLEL_IO) size_t n = sizeof (struct h5b_partition) / sizeof (h5_int64_t); - TRY( h5priv_mpi_type_contiguous(f, - n, MPI_LONG_LONG, &b->partition_mpi_t) ); + TRY (h5priv_mpi_type_contiguous(f, + n, MPI_LONG_LONG, &b->partition_mpi_t)); #endif memset (b->user_layout, 0, sizeof(*b->user_layout)); memset (b->write_layout, 0, sizeof(*b->write_layout)); @@ -121,9 +123,9 @@ h5bpriv_open_file ( b->field_gid = -1; b->have_layout = 0; - TRY( b->dcreate_prop = h5priv_create_hdf5_property(f, H5P_DATASET_CREATE) ); + TRY (b->dcreate_prop = hdf5_create_property (H5P_DATASET_CREATE)); - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } /*! @@ -135,23 +137,19 @@ h5bpriv_open_file ( \return File handle. \return NULL on error. */ - -static h5_err_t -open_file ( - h5_file_t* const f, +h5_file_p +h5_open_file ( const char* filename, /*!< The name of the data file to open. */ h5_int32_t flags, /*!< The access mode for the file. */ MPI_Comm comm /*!< MPI communicator */ ) { - -#if !defined(PARALLEL_IO) - UNUSED_ARGUMENT (f); -#endif - - h5_info (f, "Opening file %s.", filename); - - TRY( h5priv_set_hdf5_errorhandler (f, H5E_DEFAULT, h5priv_error_handler, NULL) ); - TRY( h5_set_stepname_fmt (f, H5_STEPNAME, H5_STEPWIDTH) ); + H5_CORE_API_ENTER (h5_file_p); + h5_info ("Opening file %s.", filename); + h5_file_p f = NULL; + TRY2 (f = h5_calloc (1, sizeof (h5_file_t))); + + TRY2 (hdf5_set_errorhandler (H5E_DEFAULT, h5priv_error_handler, NULL)); + TRY2 (h5_set_stepname_fmt (f, H5_STEPNAME, H5_STEPWIDTH)); f->xfer_prop = f->create_prop = f->access_prop = H5P_DEFAULT; @@ -161,37 +159,34 @@ open_file ( #ifdef PARALLEL_IO f->comm = comm; - TRY( h5priv_mpi_comm_size (f, comm, &f->nprocs) ); - TRY( h5priv_mpi_comm_rank (f, comm, &f->myproc) ); + TRY2 (h5priv_mpi_comm_size (f, comm, &f->nprocs)); + TRY2 (h5priv_mpi_comm_rank (f, comm, &f->myproc)); /* xfer_prop: also used for parallel I/O, during actual writes rather than the access_prop which is for file creation. */ - TRY( f->xfer_prop = h5priv_create_hdf5_property(f, H5P_DATASET_XFER) ); - TRY( f->access_prop = h5priv_create_hdf5_property(f, H5P_FILE_ACCESS) ); - TRY( f->create_prop = h5priv_create_hdf5_property(f, H5P_FILE_CREATE) ); + TRY2 (f->xfer_prop = hdf5_create_property(H5P_DATASET_XFER)); + TRY2 (f->access_prop = hdf5_create_property(H5P_FILE_ACCESS)); + TRY2 (f->create_prop = hdf5_create_property(H5P_FILE_CREATE)); /* select the HDF5 VFD */ if (flags & H5_VFD_MPIPOSIX) { - h5_info(f, "Selecting MPI-POSIX VFD"); + h5_info("Selecting MPI-POSIX VFD"); hbool_t use_gpfs = 0; // TODO autodetect GPFS? - TRY( h5priv_set_hdf5_fapl_mpiposix_property(f, - f->access_prop, comm, use_gpfs) ); + TRY2 (hdf5_set_fapl_mpiposix_property(f->access_prop, comm, use_gpfs)); } else { - h5_info(f, "Selecting MPI-IO VFD"); - TRY( h5priv_set_hdf5_fapl_mpio_property(f, - f->access_prop, comm, MPI_INFO_NULL) ); + h5_info("Selecting MPI-IO VFD"); + TRY2 (hdf5_set_fapl_mpio_property(f->access_prop, comm, MPI_INFO_NULL)); if (flags & H5_VFD_INDEPENDENT) { - h5_info(f, "MPI-IO: Using independent mode"); + h5_info("MPI-IO: Using independent mode"); } else { - h5_info(f, "MPI-IO: Using collective mode"); - TRY( h5priv_set_hdf5_dxpl_mpio_property(f, - f->xfer_prop, H5FD_MPIO_COLLECTIVE) ); + h5_info("MPI-IO: Using collective mode"); + TRY2 (hdf5_set_dxpl_mpio_property(f->xfer_prop, H5FD_MPIO_COLLECTIVE) ); } } #endif /* PARALLEL_IO */ #ifdef H5_USE_LUSTRE - TRY( h5_optimize_for_lustre(f, filename) ); + TRY (h5_optimize_for_lustre(f, filename)); #endif if (flags & H5_O_RDONLY) { @@ -216,19 +211,19 @@ open_file ( } } else { - return h5_error ( - f, - H5_ERR_INVAL, - "Invalid file access mode \"%d\".", flags); + H5_PRIV_FUNC_LEAVE ( + (h5_file_p)h5_error ( + H5_ERR_INVAL, + "Invalid file access mode \"%d\".", flags)); } if (f->file < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot open file \"%s\" with mode \"%d\"", - filename, flags); - TRY( f->root_gid = h5priv_open_hdf5_group (f, f->file, "/" ) ); + H5_PRIV_FUNC_LEAVE ( + (h5_file_p)h5_error ( + H5_ERR_HDF5, + "Cannot open file \"%s\" with mode \"%d\"", + filename, flags)); + TRY2 (f->root_gid = hdf5_open_group (f->file, "/" )); f->mode = flags; f->step_gid = -1; f->throttle = 0; @@ -238,46 +233,12 @@ open_file ( "%s#%0*lld", f->prefix_step_name, f->width_step_idx, (long long)f->step_idx); - TRY( h5upriv_open_file (f) ); - TRY( h5bpriv_open_file (f) ); + TRY2 (h5upriv_open_file (f)); + TRY2 (h5bpriv_open_file (f)); #ifndef PARALLEL_IO - TRY( h5tpriv_open_file (f) ); + TRY2 (h5tpriv_open_file (f)); #endif - return H5_SUCCESS; -} - -h5_file_t* -h5_open_file ( - const char* filename, /*!< The name of the data file to open. */ - h5_int32_t flags, /*!< The access mode for the file. */ - MPI_Comm comm, /*!< MPI communicator */ - const char* funcname /*!< calling function name */ - ) { - h5_file_t* f = NULL; - - f = (h5_file_t*) malloc (sizeof (h5_file_t)); - if (f == NULL) { - fprintf( - stderr, - "E: %s: Can't open file %s. Not enough memory!", - funcname, - filename); - return NULL; - } - memset (f, 0, sizeof (h5_file_t)); - f->__funcname = funcname; - if (open_file (f, filename, flags, comm) < 0) { - if (f != NULL) { - /* Oops, cannot open file. We release the memory allocated for - f only, there is most likely more allocated memory we do - *not* release. - We don't use the wrapper function because we don't know - wheter it will work or not! */ - free (f); - } - return NULL; - } - return f; + H5_CORE_API_RETURN (f); } /*! @@ -294,18 +255,18 @@ static h5_err_t h5upriv_close_file ( h5_file_t* const f /*!< file handle */ ) { + H5_PRIV_API_ENTER (h5_err_t); struct h5u_fdata* u = f->u; - h5_debug (f, "%s ()", __func__); - f->__errno = H5_SUCCESS; - TRY( h5priv_close_hdf5_dataspace (f, u->shape) ); - TRY( h5priv_close_hdf5_dataspace (f, u->diskshape) ); - TRY( h5priv_close_hdf5_dataspace (f, u->memshape) ); - TRY( h5priv_close_hdf5_property (f, u->dcreate_prop) ); - h5_free (f, f->u); + h5_errno = H5_SUCCESS; + TRY (hdf5_close_dataspace (u->shape)); + TRY (hdf5_close_dataspace (u->diskshape)); + TRY (hdf5_close_dataspace (u->memshape)); + TRY (hdf5_close_property (u->dcreate_prop)); + TRY (h5_free (f->u)); f->u = NULL; - return f->__errno; + H5_PRIV_API_RETURN (H5_SUCCESS); } /*! @@ -322,21 +283,21 @@ static h5_err_t h5bpriv_close_file ( h5_file_t* const f /*!< IN: file handle */ ) { + H5_PRIV_API_ENTER (h5_err_t); struct h5b_fdata* b = f->b; - h5_debug (f, "%s ()", __func__); - TRY( h5priv_close_hdf5_group (f, b->block_gid) ); - TRY( h5priv_close_hdf5_group (f, b->field_gid) ); - TRY( h5priv_close_hdf5_dataspace (f, b->shape) ); - TRY( h5priv_close_hdf5_dataspace (f, b->diskshape) ); - TRY( h5priv_close_hdf5_dataspace (f, b->memshape) ); - TRY( h5priv_close_hdf5_property (f, b->dcreate_prop) ); + TRY (hdf5_close_group (b->block_gid)); + TRY (hdf5_close_group (b->field_gid)); + TRY (hdf5_close_dataspace (b->shape)); + TRY (hdf5_close_dataspace (b->diskshape)); + TRY (hdf5_close_dataspace (b->memshape)); + TRY (hdf5_close_property (b->dcreate_prop)); #if defined(PARALLEL_IO) - TRY( h5priv_mpi_type_free (f, &b->partition_mpi_t) ); + TRY (h5priv_mpi_type_free (f, &b->partition_mpi_t)); #endif - h5_free (f, f->b); + TRY (h5_free (f->b)); f->b = NULL; - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } /*! @@ -352,26 +313,24 @@ h5_err_t h5_close_file ( h5_file_t* const f /*!< file handle */ ) { - h5_debug (f, "%s ()", __func__); - f->__errno = H5_SUCCESS; + H5_PRIV_API_ENTER (h5_err_t); + h5_errno = H5_SUCCESS; CHECK_FILEHANDLE (f); - TRY( h5priv_close_step (f) ); - TRY( h5upriv_close_file (f) ); - TRY( h5bpriv_close_file (f) ); + TRY (h5priv_close_step (f)); + TRY (h5upriv_close_file (f)); + TRY (h5bpriv_close_file (f)); #ifndef PARALLEL_IO - TRY( h5tpriv_close_file (f) ); + TRY (h5tpriv_close_file (f)); #endif - TRY( h5priv_close_hdf5_property (f, f->xfer_prop) ); - TRY( h5priv_close_hdf5_property (f, f->access_prop) ); - TRY( h5priv_close_hdf5_property (f, f->create_prop) ); - TRY( h5priv_close_hdf5_group (f, f->root_gid) ); - TRY( h5priv_close_hdf5_file (f, f->file) ); - h5_debug (f, "%s (): done", __func__); - - h5_free (f, f); - return H5_SUCCESS; + TRY (hdf5_close_property (f->xfer_prop)); + TRY (hdf5_close_property (f->access_prop)); + TRY (hdf5_close_property (f->create_prop)); + TRY (hdf5_close_group (f->root_gid)); + TRY (hdf5_close_file (f->file)); + h5_free (f); + H5_PRIV_API_RETURN (H5_SUCCESS); } /*! @@ -390,6 +349,7 @@ h5_set_stepname_fmt ( const char* name, int width ) { + H5_CORE_API_ENTER (h5_err_t); if (width < 0) width = 0; else if (width > H5_STEPNAME_LEN - 1) width = H5_STEPNAME_LEN - 1; strncpy ( @@ -398,7 +358,7 @@ h5_set_stepname_fmt ( H5_STEPNAME_LEN - 1); f->width_step_idx = width; - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } /*! @@ -419,7 +379,7 @@ h5_get_stepname_fmt ( UNUSED_ARGUMENT (name); UNUSED_ARGUMENT (l_name); UNUSED_ARGUMENT (width); - return h5_error_not_implemented (f, __FILE__, __func__, __LINE__); + return h5_error_not_implemented (__FILE__, __func__, __LINE__); } /*! @@ -433,7 +393,7 @@ h5_id_t h5_get_step ( h5_file_t* const f /*!< file handle */ ) { - return h5_error_not_implemented (f, __FILE__, __func__, __LINE__); + return h5_error_not_implemented (__FILE__, __func__, __LINE__); } /*! @@ -447,7 +407,8 @@ int h5_get_num_procs ( h5_file_t* const f /*!< file handle */ ) { - return f->nprocs; + H5_CORE_API_ENTER (int); + H5_CORE_API_RETURN (f->nprocs); } /*! @@ -461,7 +422,8 @@ hid_t h5_get_hdf5_file( h5_file_t* const f /*!< file handle */ ) { - return f->file; + H5_CORE_API_ENTER (hid_t); + H5_CORE_API_RETURN (f->file); } /*! @@ -476,7 +438,6 @@ h5_get_num_steps( h5_file_t* const f /*!< file handle */ ) { return h5_get_num_hdf5_groups_matching_prefix ( - f, f->step_gid, f->prefix_step_name); } @@ -492,7 +453,7 @@ h5_err_t h5_start_traverse_steps ( h5_file_t* const f /*!< file handle */ ) { - return h5_error_not_implemented (f, __FILE__, __func__, __LINE__); + return h5_error_not_implemented (__FILE__, __func__, __LINE__); } /*! @@ -506,7 +467,7 @@ h5_err_t h5_traverse_steps ( h5_file_t* const f /*!< file handle */ ) { - return h5_error_not_implemented (f, __FILE__, __func__, __LINE__); + return h5_error_not_implemented (__FILE__, __func__, __LINE__); } char * diff --git a/src/h5core/h5_readwrite.c b/src/h5core/h5_readwrite.c index ffd8626..da2ae75 100644 --- a/src/h5core/h5_readwrite.c +++ b/src/h5core/h5_readwrite.c @@ -21,25 +21,16 @@ h5priv_write_dataset_by_name ( hid_t (*set_diskspace)(h5_file_t*,hid_t), const void* const data ) { - h5_info (f, "Writing dataset %s/%s.", + H5_PRIV_API_ENTER (h5_err_t); + h5_info ("Writing dataset %s/%s.", h5_get_objname (loc_id), dsinfo->name); -#if 0 - H5O_info_t obj_info; - herr_t herr = H5Oget_info_by_name( - loc_id, - dsinfo->name, - &obj_info, - H5P_DEFAULT); -#else h5_err_t exists; - TRY( exists = h5priv_hdf5_link_exists (f, loc_id, dsinfo->name) ); -#endif + TRY (exists = hdf5_link_exists (loc_id, dsinfo->name)); if ((exists > 0) && ((f->mode==H5_O_WRONLY) || (f->mode==H5_O_APPEND))) { - h5_warn (f, - "Dataset %s/%s already exist.", + h5_warn ("Dataset %s/%s already exist.", h5_get_objname (loc_id), dsinfo->name); - return h5priv_handle_file_mode_error(f, f->mode); + H5_PRIV_API_LEAVE (h5priv_handle_file_mode_error(f->mode)); } /* @@ -52,49 +43,44 @@ h5priv_write_dataset_by_name ( if (exists) { /* overwrite dataset */ - TRY( dset_id = h5priv_open_hdf5_dataset ( - f, - loc_id, - dsinfo->name) ); - TRY( dataspace_id = h5priv_get_hdf5_dataset_space ( - f, - dset_id) ); - TRY( h5priv_set_hdf5_dataset_extent ( - f, - dset_id, - dsinfo->dims) ); + TRY (dset_id = hdf5_open_dataset (loc_id, dsinfo->name)); + TRY (dataspace_id = hdf5_get_dataset_space (dset_id)); + TRY (hdf5_set_dataset_extent (dset_id, dsinfo->dims)); /* exten dataset? */ } else { /* create dataset */ - TRY( dataspace_id = h5priv_create_hdf5_dataspace ( - f, + TRY (dataspace_id = hdf5_create_dataspace ( dsinfo->rank, dsinfo->dims, - dsinfo->max_dims) ); - TRY ( dset_id = h5priv_create_hdf5_dataset ( - f, - loc_id, - dsinfo->name, - dsinfo->type_id, - dataspace_id, - dsinfo->create_prop) ); + dsinfo->max_dims)); + TRY (dset_id = hdf5_create_dataset ( + loc_id, + dsinfo->name, + dsinfo->type_id, + dataspace_id, + dsinfo->create_prop)); } - TRY( memspace_id = (*set_memspace)(f, 0) ); - TRY( diskspace_id = (*set_diskspace)(f, dataspace_id) ); - TRY( h5priv_write_hdf5_dataset ( - f, + TRY (memspace_id = (*set_memspace)(f, 0)); + TRY (diskspace_id = (*set_diskspace)(f, dataspace_id)); +#ifdef PARALLEL_IO + TRY (h5_start_throttle (f)); +#endif + TRY (hdf5_write_dataset ( dset_id, dsinfo->type_id, memspace_id, diskspace_id, f->xfer_prop, - data) ); - TRY( h5priv_close_hdf5_dataspace (f, diskspace_id) ); - TRY( h5priv_close_hdf5_dataspace (f, memspace_id) ); - TRY( h5priv_close_hdf5_dataset (f, dset_id) ); + data)); +#ifdef PARALLEL_IO + TRY (h5_end_throttle (f)); +#endif + TRY (hdf5_close_dataspace (diskspace_id)); + TRY (hdf5_close_dataspace (memspace_id)); + TRY (hdf5_close_dataset (dset_id)); f->empty = 0; - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } h5_err_t @@ -106,24 +92,29 @@ h5priv_read_dataset ( hid_t (*set_dspace)(h5_file_t*,hid_t), void* const data ) { - + H5_PRIV_API_ENTER (h5_err_t); hid_t mspace_id; hid_t dspace_id; - TRY( mspace_id = (*set_mspace)(f, dset_id) ); - TRY( dspace_id = (*set_dspace)(f, dset_id) ); - TRY( h5priv_read_hdf5_dataset ( - f, + TRY (mspace_id = (*set_mspace)(f, dset_id)); + TRY (dspace_id = (*set_dspace)(f, dset_id)); +#ifdef PARALLEL_IO + TRY (h5_start_throttle (f)); +#endif + TRY (hdf5_read_dataset ( dset_id, dsinfo->type_id, mspace_id, dspace_id, f->xfer_prop, - data) ); - TRY( h5priv_close_hdf5_dataspace (f, dspace_id) ); - TRY( h5priv_close_hdf5_dataspace (f, mspace_id) ); + data)); +#ifdef PARALLEL_IO + TRY (h5_end_throttle (f)); +#endif + TRY (hdf5_close_dataspace (dspace_id)); + TRY (hdf5_close_dataspace (mspace_id)); - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } h5_err_t @@ -135,63 +126,28 @@ h5priv_read_dataset_by_name ( hid_t (*set_dspace)(h5_file_t*,hid_t), void* const data ) { - + H5_PRIV_API_ENTER (h5_err_t); hid_t dset_id; - TRY( dset_id = h5priv_open_hdf5_dataset ( - f, - loc_id, - dsinfo->name) ); - TRY( h5priv_read_dataset (f, dset_id, dsinfo, set_mspace, set_dspace, - data) ); - TRY( h5priv_close_hdf5_dataset (f, dset_id) ); + TRY (dset_id = hdf5_open_dataset (loc_id, dsinfo->name)); + TRY (h5priv_read_dataset (f, dset_id, dsinfo, set_mspace, set_dspace, data)); + TRY (hdf5_close_dataset (dset_id)); - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } - -static h5_err_t -_init_step ( - h5_file_t* const f - ) { - TRY( h5tpriv_init_step (f) ); - - return H5_SUCCESS; -} - h5_err_t h5priv_close_step ( h5_file_t* const f ) { - h5_debug (f, "%s ()", __func__); - if (f->step_gid <= 0) return H5_SUCCESS; - TRY( h5tpriv_close_step (f) ); - TRY( h5priv_close_hdf5_group (f, f->step_gid) ); + H5_PRIV_API_ENTER (h5_err_t); + if (f->step_gid <= 0) + H5_PRIV_API_LEAVE (H5_SUCCESS); + TRY (h5tpriv_close_step (f)); + TRY (hdf5_close_group (f->step_gid)); f->step_gid = -1; - return H5_SUCCESS; -} - -static h5_err_t -_set_step ( - h5_file_t* const f, - const h5_id_t step_idx /*!< [in] Step to set. */ - ) { - f->step_idx = step_idx; - - sprintf ( - f->step_name, - "%s#%0*lld", - f->prefix_step_name, f->width_step_idx, (long long) f->step_idx); - h5_info ( - f, - "Proc[%d]: Open step #%lld for file %lld", - f->myproc, - (long long)f->step_idx, - (long long)(size_t) f); - TRY ( f->step_gid = h5priv_open_group (f, f->file, f->step_name) ); - - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } h5_err_t @@ -199,12 +155,23 @@ h5_set_step ( h5_file_t* const f, /*!< [in] Handle to open file */ const h5_id_t step_idx /*!< [in] Step to set. */ ) { + H5_CORE_API_ENTER (h5_err_t); + TRY (h5priv_close_step (f)); + f->step_idx = step_idx; - TRY( h5priv_close_step (f) ); - TRY( _set_step (f, step_idx) ); - TRY( _init_step (f) ); + sprintf ( + f->step_name, + "%s#%0*lld", + f->prefix_step_name, f->width_step_idx, (long long) f->step_idx); + h5_info ( + "Proc[%d]: Open step #%lld for file %lld", + f->myproc, + (long long)f->step_idx, + (long long)(size_t) f); + TRY (f->step_gid = h5priv_open_group (f, f->file, f->step_name)); + TRY (h5tpriv_init_step (f)); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } /*! @@ -215,53 +182,54 @@ h5_normalize_h5_type ( h5_file_t* const f, hid_t type ) { - H5T_class_t tclass = H5Tget_class (type); - int size = H5Tget_size (type); + H5_CORE_API_ENTER (h5_int64_t); + H5T_class_t tclass; + int size; + TRY (tclass = H5Tget_class (type)); + TRY (size = H5Tget_size (type)); switch (tclass){ case H5T_INTEGER: if (size==8) { - return H5_INT64_T; + H5_CORE_API_LEAVE (H5_INT64_T); } else if (size==4) { - return H5_INT32_T; + H5_CORE_API_LEAVE (H5_INT32_T); } break; case H5T_FLOAT: if ( size==8 ) { - return H5_FLOAT64_T; + H5_CORE_API_LEAVE (H5_FLOAT64_T); } else if ( size==4 ) { - return H5_FLOAT32_T; + H5_CORE_API_LEAVE (H5_FLOAT32_T); } break; case H5T_STRING: - return H5_STRING_T; + H5_CORE_API_LEAVE (H5_STRING_T); default: ; /* NOP */ } - h5_warn (f, "Unknown type %d", (int)type); - - return -1; + H5_CORE_API_RETURN (h5_warn ("Unknown type %d", (int)type)); } - h5_int64_t h5_get_dataset_type( h5_file_t* const f, hid_t group_id, const char* dset_name ) { + H5_CORE_API_ENTER (h5_int64_t); hid_t dset_id; hid_t hdf5_type; + h5_int64_t type; + TRY (dset_id = hdf5_open_dataset (group_id, dset_name)); + TRY (hdf5_type = hdf5_get_dataset_type (dset_id)); + TRY (type = h5_normalize_h5_type (f, hdf5_type)); + TRY (hdf5_close_type (hdf5_type)); + TRY (hdf5_close_dataset (dset_id)); - TRY( dset_id = h5priv_open_hdf5_dataset (f, group_id, dset_name) ); - TRY( hdf5_type = h5priv_get_hdf5_dataset_type (f, dset_id) ); - h5_int64_t type = h5_normalize_h5_type (f, hdf5_type); - TRY( h5priv_close_hdf5_type (f, hdf5_type) ); - TRY( h5priv_close_hdf5_dataset (f, dset_id) ); - - return type; + H5_CORE_API_RETURN (type); } h5_err_t @@ -269,11 +237,12 @@ h5_has_step ( h5_file_t* const f, /*!< [in] Handle to open file */ const h5_id_t step /*!< [in] Step number to query */ ) { + H5_CORE_API_ENTER (h5_err_t); char name[2*H5_STEPNAME_LEN]; sprintf (name, "%s#%0*lld", f->prefix_step_name, f->width_step_idx, (long long)step); - return h5priv_hdf5_link_exists(f, f->file, name); + H5_CORE_API_RETURN (hdf5_link_exists(f->file, name)); } h5_err_t @@ -282,24 +251,24 @@ h5_normalize_dataset_name ( const char *name, char *name2 ) { - + H5_CORE_API_ENTER (h5_err_t); if ( strlen(name) > H5_DATANAME_LEN ) { strncpy ( name2, name, H5_DATANAME_LEN-1 ); name2[H5_DATANAME_LEN-1] = '\0'; - h5_warn (f, "Truncated name '%s' to '%s'.", name, name2); + h5_warn ("Truncated name '%s' to '%s'.", name, name2); } else { strcpy ( name2, name ); } if ( strcmp( name2, H5_BLOCKNAME ) == 0 ) { - h5_error (f, - H5_ERR_INVAL, - "Can't create dataset or field with name '%s' because " - "it is reserved by H5Block.", - H5_BLOCKNAME); + H5_CORE_API_LEAVE ( + h5_error ( + H5_ERR_INVAL, + "Can't create dataset or field with name '%s'" + " because it is reserved by H5Block.", + H5_BLOCKNAME)); } - - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } #ifdef PARALLEL_IO @@ -308,33 +277,29 @@ h5_set_throttle ( h5_file_t* const f, const int factor ) { + H5_CORE_API_ENTER (h5_err_t); if ( (f->mode & H5_VFD_INDEPENDENT) || (f->mode & H5_VFD_MPIPOSIX) ) { f->throttle = factor; - h5_info (f, - "Throttling enabled with factor = %d", f->throttle ); + h5_info ("Throttling enabled with factor = %d", f->throttle ); } else { - h5_warn (f, - "Throttling is only permitted with the MPI-POSIX " + h5_warn ("Throttling is only permitted with the MPI-POSIX " "or MPI-IO Independent VFD." ); } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t h5_start_throttle ( h5_file_t* const f ) { - + H5_CORE_API_ENTER (h5_err_t); if (f->throttle > 0) { int token = 1; - h5_info (f, - "Throttling with factor = %d", - f->throttle); + h5_info ("Throttling with factor = %d", f->throttle); if (f->myproc / f->throttle > 0) { - h5_debug (f, - "[%d] throttle: waiting on token from %d", - f->myproc, f->myproc - f->throttle); + h5_debug ("[%d] throttle: waiting on token from %d", + f->myproc, f->myproc - f->throttle); // wait to receive token before continuing with read TRY( h5priv_mpi_recv(f, &token, 1, MPI_INT, @@ -343,34 +308,32 @@ h5_start_throttle ( f->comm ) ); } - h5_debug (f, - "[%d] throttle: received token", - f->myproc); + h5_debug ("[%d] throttle: received token", f->myproc); } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t h5_end_throttle ( h5_file_t* const f ) { - + H5_CORE_API_ENTER (h5_err_t); if (f->throttle > 0) { int token; if (f->myproc + f->throttle < f->nprocs) { // pass token to next proc - h5_debug (f, - "[%d] throttle: passing token to %d", - f->myproc, f->myproc + f->throttle); - TRY( h5priv_mpi_send(f, - &token, 1, MPI_INT, - f->myproc + f->throttle, // send to next proc - f->myproc + f->throttle, // use the id of the target as tag - f->comm - ) ); + h5_debug ("[%d] throttle: passing token to %d", + f->myproc, f->myproc + f->throttle); + TRY (h5priv_mpi_send( + f, + &token, 1, MPI_INT, + f->myproc + f->throttle, // send to next proc + f->myproc + f->throttle, // use the id of the target as tag + f->comm + )); } } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } #endif // PARALLEL_IO diff --git a/src/h5core/h5_syscall.c b/src/h5core/h5_syscall.c index fa84e76..34ffe1c 100644 --- a/src/h5core/h5_syscall.c +++ b/src/h5core/h5_syscall.c @@ -5,73 +5,69 @@ #include "h5core/h5_core.h" #include "h5_core_private.h" -void* +void_p h5_alloc ( - h5_file_t* const f, void* ptr, const size_t size ) { - h5_debug (f, "%s (ptr=%p, size=%lu)", __func__, ptr, size); + MALLOC_WRAPPER_ENTER2 (void_p, + "ptr=%p, size=%lu", ptr, size); ptr = realloc (ptr, size); if (ptr == NULL) { - h5_error (f, H5_ERR_NOMEM, "Out of memory."); - return (void*)(H5_ERR); + MALLOC_WRAPPER_LEAVE ( + (void_p)h5_error (H5_ERR_NOMEM, "Out of memory.")); } - h5_debug (f, "%s (): return address: 0x%p", __func__, ptr); - return ptr; + MALLOC_WRAPPER_RETURN (ptr); } -void* +void_p h5_calloc ( - h5_file_t* const f, const size_t count, const size_t size ) { - h5_debug (f, "%s (count=%lu , size=%lu)", __func__, count, size); + MALLOC_WRAPPER_ENTER2 (void_p, + "count=%lu , size=%lu", count, size); void* ptr = calloc (count, size); if (ptr == NULL) { - h5_error (f, H5_ERR_NOMEM, "Out of memory."); - return (void*)(H5_ERR); + MALLOC_WRAPPER_LEAVE ( + (void_p)h5_error (H5_ERR_NOMEM, "Out of memory.")); } - h5_debug (f, "%s (): return address: 0x%p", __func__, ptr); - return ptr; + MALLOC_WRAPPER_RETURN (ptr); } -char* +char_p h5priv_strdup ( - h5_file_t* const f, const char* s1 ) { - char* s2 = strdup (s1); + MALLOC_WRAPPER_ENTER1 (char_p, "s=%s", s1); + char_p s2 = strdup (s1); if (s2 == NULL) { - h5_error (f, H5_ERR_NOMEM, "Out of memory."); - return (void*)(H5_ERR); + MALLOC_WRAPPER_LEAVE ( + (char_p)h5_error (H5_ERR_NOMEM, "Out of memory.")); } - return s2; + MALLOC_WRAPPER_RETURN (s2); } h5_err_t h5_free ( - h5_file_t* const f, void* ptr ) { + MALLOC_WRAPPER_ENTER1 (h5_err_t, "ptr=0x%p", ptr); if (ptr) { - h5_debug (f, "%s (%p)", __func__, ptr); free (ptr); } - return H5_SUCCESS; + MALLOC_WRAPPER_RETURN (H5_SUCCESS); } void* h5priv_tsearch ( - h5_file_t* const f, const void* key, void** rootp, int (*compar) (const void* key1, const void* key2) ) { void* ptr = tsearch (key, rootp, compar); if (ptr == NULL) { - h5_error (f, H5_ERR_NOMEM, "Out of memory."); + h5_error (H5_ERR_NOMEM, "Out of memory."); return (void*)(H5_ERR); } return ptr; @@ -79,12 +75,10 @@ h5priv_tsearch ( void* h5priv_tfind ( - h5_file_t* const f, const void* key, void* const* rootp, int (*compar) (const void* key1, const void* key2) ) { - UNUSED_ARGUMENT (f); void* ptr = tfind (key, rootp, compar); if (ptr == NULL) { return (void*)(H5_ERR); diff --git a/src/h5core/h5_syscall_private.h b/src/h5core/h5_syscall_private.h index 9e6bb59..c1d8490 100644 --- a/src/h5core/h5_syscall_private.h +++ b/src/h5core/h5_syscall_private.h @@ -3,12 +3,10 @@ char* h5priv_strdup ( - h5_file_t* const f, const char* s1 ); void* h5priv_tsearch ( - h5_file_t* const f, const void* key, void** rootp, int (*compar) (const void* key1, const void* key2) @@ -16,7 +14,6 @@ h5priv_tsearch ( void* h5priv_tfind ( - h5_file_t* const f, const void* key, void *const* rootp, int (*compar) (const void* key1, const void* key2) diff --git a/src/h5core/h5_types_private.h b/src/h5core/h5_types_private.h index 3d2a264..c1861b4 100644 --- a/src/h5core/h5_types_private.h +++ b/src/h5core/h5_types_private.h @@ -14,9 +14,6 @@ struct h5_file { h5_int32_t mode; /* file access mode */ char empty; - h5_err_t __errno; /* error number */ - const char * __funcname; /* H5Block/Fed/Part API function*/ - /* MPI */ MPI_Comm comm; /* MPI communicator */ diff --git a/src/h5core/h5b_attribs.c b/src/h5core/h5b_attribs.c index dad8329..9354c23 100644 --- a/src/h5core/h5b_attribs.c +++ b/src/h5core/h5b_attribs.c @@ -10,7 +10,7 @@ h5_write_field_attrib ( const void *attrib_value, /*!< IN: attribute value */ const h5_int64_t attrib_nelem /*!< IN: number of elements */ ) { - + H5_CORE_API_ENTER (h5_err_t); TRY( h5bpriv_create_field_group(f, field_name) ); TRY( h5_write_attrib ( @@ -21,7 +21,7 @@ h5_write_field_attrib ( attrib_value, attrib_nelem) ); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -32,7 +32,7 @@ h5_read_field_attrib ( const h5_int64_t attrib_type, /*!< IN: attribute type */ void *buffer /*!< OUT: attribute value */ ) { - + H5_CORE_API_ENTER (h5_err_t); TRY( h5bpriv_open_field_group(f, field_name) ); TRY( h5_read_attrib ( @@ -42,7 +42,7 @@ h5_read_field_attrib ( attrib_type, buffer) ); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_ssize_t @@ -50,13 +50,11 @@ h5b_get_num_field_attribs ( h5_file_t *const f, /*b->field_gid ) ); - - return n; + H5_CORE_API_RETURN (hdf5_get_num_attribute (f->b->field_gid)); } h5_err_t @@ -69,16 +67,17 @@ h5b_get_field_attrib_info ( h5_int64_t *attrib_type, /*!< OUT: attribute type */ h5_size_t *attrib_nelem /*!< OUT: number of elements */ ) { + H5_CORE_API_ENTER (h5_err_t); + TRY (h5bpriv_open_field_group(f, field_name)); - TRY( h5bpriv_open_field_group(f, field_name) ); - - return h5_get_attrib_info ( - f, - H5_ATTRIB_FIELD, - attrib_idx, - attrib_name, - len_attrib_name, - attrib_type, - attrib_nelem ); + H5_CORE_API_RETURN ( + h5_get_attrib_info ( + f, + H5_ATTRIB_FIELD, + attrib_idx, + attrib_name, + len_attrib_name, + attrib_type, + attrib_nelem)); } diff --git a/src/h5core/h5b_errorhandling_private.h b/src/h5core/h5b_errorhandling_private.h index ab89fa3..fca4013 100644 --- a/src/h5core/h5b_errorhandling_private.h +++ b/src/h5core/h5b_errorhandling_private.h @@ -4,13 +4,11 @@ #define CHECK_LAYOUT( f ) \ if (! f->b->have_layout) \ return h5_error( \ - f, \ H5_ERR_LAYOUT, \ "No view has been defined!") #define HANDLE_H5_LAYOUT_ERR( f ) \ h5_error( \ - f, \ H5_ERR_LAYOUT, \ "Bad view!"); diff --git a/src/h5core/h5b_model.c b/src/h5core/h5b_model.c index 72a7c5f..68499c9 100644 --- a/src/h5core/h5b_model.c +++ b/src/h5core/h5b_model.c @@ -283,7 +283,7 @@ _dissolve_ghostzone ( } } if ( max_vol <= 0 ) { - return h5_error (f, + return h5_error ( H5_ERR_LAYOUT, "Cannot dissolve ghostzones in specified layout!" ); } @@ -321,7 +321,7 @@ _dissolve_ghostzones ( const h5b_partition_t *const user_layout, h5b_partition_t *const write_layout ) { - + H5_PRIV_FUNC_ENTER (h5_err_t); h5b_partition_t *p; h5b_partition_t *q; int proc_p, proc_q; @@ -336,7 +336,7 @@ _dissolve_ghostzones ( memcpy( write_layout, user_layout, f->nprocs*sizeof(h5b_partition_t) ); - TRY( p_begin = (struct list*)h5_alloc(f, NULL, sizeof(*p_begin)) ); + TRY( p_begin = (struct list*)h5_alloc (NULL, sizeof(*p_begin)) ); p_max = p_end = p_begin; memset( p_begin, 0, sizeof ( *p_begin ) ); @@ -349,7 +349,7 @@ _dissolve_ghostzones ( proc_q++, q++ ) { if ( have_ghostzone ( p, q ) ) { - TRY( p_el = (struct list*)h5_alloc(f, NULL, sizeof(*p_el)) ); + TRY( p_el = (struct list*)h5_alloc (NULL, sizeof(*p_el)) ); p_el->p = p; p_el->q = q; @@ -371,7 +371,7 @@ _dissolve_ghostzones ( _dissolve_ghostzone ( f, p_max->p, p_max->q ); - h5_free (f, p_max); + h5_free (p_max); p_el = p_max = p_begin->next; while ( p_el ) { @@ -385,15 +385,14 @@ _dissolve_ghostzones ( p_el->next->prev = p_el->prev; p_el->prev->next = p_el->next; p_save = p_el->next; - h5_free (f, p_el); + h5_free (p_el); p_el = p_save; } } } - h5_free (f, p_begin); - - return H5_SUCCESS; + h5_free (p_begin); + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } #endif @@ -401,55 +400,55 @@ h5_err_t h5bpriv_release_hyperslab ( h5_file_t *const f /*!< IN: file handle */ ) { - if ( f->b->shape > 0 ) { - TRY( h5priv_close_hdf5_dataspace(f, f->b->shape) ); + H5_CORE_API_ENTER (h5_err_t); + if (f->b->shape > 0) { + TRY (hdf5_close_dataspace (f->b->shape)); f->b->shape = -1; } - if ( f->b->diskshape > 0 ) { - TRY( h5priv_close_hdf5_dataspace(f, f->b->diskshape) ); + if (f->b->diskshape > 0) { + TRY (hdf5_close_dataspace(f->b->diskshape)); f->b->diskshape = -1; } - if ( f->b->memshape > 0 ) { - TRY( h5priv_close_hdf5_dataspace(f, f->b->memshape) ); + if (f->b->memshape > 0) { + TRY (hdf5_close_dataspace(f->b->memshape)); f->b->memshape = -1; } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t h5bpriv_open_block_group ( h5_file_t *const f /*!< IN: file handle */ ) { - + H5_CORE_API_ENTER (h5_err_t); h5b_fdata_t *b = f->b; - TRY( h5priv_close_hdf5_group(f, b->block_gid) ); - b->block_gid = h5priv_open_hdf5_group(f, f->step_gid, H5_BLOCKNAME); + TRY (hdf5_close_group (b->block_gid)); + b->block_gid = hdf5_open_group (f->step_gid, H5_BLOCKNAME); if (f->b->block_gid < 0) - return h5_error(f, + return h5_error( H5_ERR_INVAL, "Time step does not contain H5Block data!"); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } static h5_err_t _create_block_group ( h5_file_t *const f /*!< IN: file handle */ ) { - + H5_PRIV_FUNC_ENTER (h5_err_t); h5_err_t exists; - TRY( exists = h5priv_hdf5_link_exists(f, f->step_gid, H5_BLOCKNAME) ); + TRY (exists = hdf5_link_exists (f->step_gid, H5_BLOCKNAME)); if (exists > 0) { - TRY( h5bpriv_open_block_group(f) ); + TRY (h5bpriv_open_block_group(f)); } else { - TRY( h5priv_close_hdf5_group(f, f->b->block_gid) ); - TRY( f->b->block_gid = h5priv_create_hdf5_group(f, - f->step_gid, H5_BLOCKNAME) ); + TRY (hdf5_close_group(f->b->block_gid) ); + TRY (f->b->block_gid = hdf5_create_group( + f->step_gid, H5_BLOCKNAME) ); } - - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } h5_err_t @@ -457,16 +456,12 @@ h5bpriv_have_field_group ( h5_file_t *const f, /*!< IN: file handle */ const char *name ) { - + H5_CORE_API_ENTER (h5_err_t); char name2[H5_DATANAME_LEN]; h5_normalize_dataset_name(f, name, name2); TRY( h5bpriv_open_block_group(f) ); - - h5_err_t exists; - TRY( exists = h5priv_hdf5_link_exists(f, f->b->block_gid, name2) ); - - return exists; + H5_CORE_API_RETURN (hdf5_link_exists(f->b->block_gid, name2)); } h5_err_t @@ -474,19 +469,19 @@ h5bpriv_open_field_group ( h5_file_t *const f, /*!< IN: file handle */ const char *name ) { - + H5_CORE_API_ENTER (h5_err_t); char name2[H5_DATANAME_LEN]; h5_normalize_dataset_name(f, name, name2); - TRY( h5priv_close_hdf5_group(f, f->b->field_gid) ); - TRY( h5bpriv_open_block_group(f) ); - f->b->field_gid = h5priv_open_hdf5_group(f, f->b->block_gid, name2); + TRY (hdf5_close_group (f->b->field_gid)); + TRY (h5bpriv_open_block_group (f)); + f->b->field_gid = hdf5_open_group (f->b->block_gid, name2); if (f->b->field_gid < 0) - return h5_error(f, + return h5_error( H5_ERR_INVAL, "Field '%s' does not exist!", name2); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -494,7 +489,7 @@ h5bpriv_create_field_group ( h5_file_t *const f, /*!< IN: file handle */ const char *name /*!< IN: name of field group to create */ ) { - + H5_CORE_API_ENTER (h5_err_t); h5b_fdata_t *b = f->b; TRY( _create_block_group(f) ); @@ -503,17 +498,16 @@ h5bpriv_create_field_group ( h5_normalize_dataset_name(f, name, name2); h5_err_t exists; - TRY( exists = h5priv_hdf5_link_exists(f, b->block_gid, name2) ); + TRY (exists = hdf5_link_exists ( b->block_gid, name2)); if (exists > 0) { - TRY( h5bpriv_open_field_group(f, name2) ); + TRY (h5bpriv_open_field_group (f, name2)); } else { - TRY( h5priv_close_hdf5_group(f, f->b->field_gid) ); - TRY( b->field_gid = h5priv_create_hdf5_group(f, - b->block_gid, name2) ); + TRY (hdf5_close_group (f->b->field_gid) ); + TRY (b->field_gid = hdf5_create_group (b->block_gid, name2)); } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_int64_t @@ -533,7 +527,7 @@ h5b_3d_set_view ( const h5_size_t k_start, /*!< IN: start index of \c k */ const h5_size_t k_end /*!< IN: end index of \c k */ ) { - + H5_CORE_API_ENTER (h5_err_t); h5b_partition_t *p = f->b->user_layout; p->i_start = i_start; p->i_end = i_end; @@ -549,8 +543,8 @@ h5b_3d_set_view ( h5b_partition_t *write_layout; size_t size = f->nprocs * sizeof (h5b_partition_t); - TRY( user_layout = h5_alloc (f, NULL, size) ); - TRY( write_layout = h5_alloc (f, NULL, size) ); + TRY( user_layout = h5_alloc (NULL, size) ); + TRY( write_layout = h5_alloc (NULL, size) ); TRY( h5priv_mpi_allgather(f, p, 1, f->b->partition_mpi_t, @@ -564,7 +558,7 @@ h5b_3d_set_view ( b->have_layout = 1; p = b->user_layout; - h5_debug (f, + h5_debug ( "[%d] User layout: %lld:%lld, %lld:%lld, %lld:%lld", f->myproc, (long long)p->i_start, (long long)p->i_end, @@ -572,7 +566,7 @@ h5b_3d_set_view ( (long long)p->k_start, (long long)p->k_end ); p = b->write_layout; - h5_debug (f, + h5_debug ( "[%d] Ghost-zone layout: %lld:%lld, %lld:%lld, %lld:%lld", f->myproc, (long long)p->i_start, (long long)p->i_end, @@ -581,13 +575,13 @@ h5b_3d_set_view ( - h5_free(f, user_layout); - h5_free(f, write_layout); + h5_free(user_layout); + h5_free(write_layout); TRY( h5bpriv_release_hyperslab(f) ); #endif - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -600,7 +594,7 @@ h5b_3d_get_view ( h5_size_t *const k_start, /*!< OUT: start index of \c k */ h5_size_t *const k_end /*!< OUT: end index of \c k */ ) { - + H5_CORE_API_ENTER (h5_err_t); h5b_partition_t *p = f->b->user_layout; *i_start = p->i_start; @@ -610,7 +604,7 @@ h5b_3d_get_view ( *k_start = p->k_start; *k_end = p->k_end; - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -623,7 +617,7 @@ h5b_3d_get_reduced_view ( h5_size_t *const k_start, /*!< OUT: start index of \c k */ h5_size_t *const k_end /*!< OUT: end index of \c k */ ) { - + H5_CORE_API_ENTER (h5_err_t); h5b_partition_t *p = f->b->write_layout; *i_start = p->i_start; @@ -633,7 +627,7 @@ h5b_3d_get_reduced_view ( *k_start = p->k_start; *k_end = p->k_end; - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -643,22 +637,20 @@ h5b_3d_set_chunk ( const h5_size_t j, /*!< IN: size of \c j */ const h5_size_t k /*!< IN: size of \c k */ ) { - + H5_CORE_API_ENTER (h5_err_t); if ( i == 0 || j == 0 || k == 0 ) { - h5_info(f, "Disabling chunking" ); - TRY( h5priv_set_hdf5_layout_property(f, - f->b->dcreate_prop, H5D_CONTIGUOUS) ); + h5_info ("Disabling chunking" ); + TRY (hdf5_set_layout_property(f->b->dcreate_prop, H5D_CONTIGUOUS)); } else { - h5_info(f, "Setting chunk to (%lld,%lld,%lld)", - (long long)i, (long long)j, (long long)k); + h5_info ("Setting chunk to (%lld,%lld,%lld)", + (long long)i, (long long)j, (long long)k); hsize_t dims[3] = { k, j, i }; - TRY( h5priv_set_hdf5_chunk_property(f, - f->b->dcreate_prop, 1, dims) ); + TRY (hdf5_set_chunk_property (f->b->dcreate_prop, 1, dims)); } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -669,7 +661,7 @@ h5b_3d_get_chunk ( h5_size_t *const j, /*!< OUT: size of \c j */ h5_size_t *const k /*!< OUT: size of \c k */ ) { - + H5_CORE_API_ENTER (h5_err_t); CHECK_TIMEGROUP ( f ); h5b_fdata_t *b = f->b; @@ -680,23 +672,22 @@ h5b_3d_get_chunk ( hid_t plist_id; hsize_t hdims[3]; - TRY( dataset_id = h5priv_open_hdf5_dataset(f, b->field_gid, H5_BLOCKNAME_X) ); - TRY( plist_id = h5priv_get_hdf5_dataset_create_plist(f, dataset_id) ); - TRY( h5priv_get_hdf5_chunk_property(f, plist_id, 3, hdims) ); - TRY( h5priv_close_hdf5_property(f, plist_id) ); - TRY( h5priv_close_hdf5_dataset(f, dataset_id) ); + TRY (dataset_id = hdf5_open_dataset (b->field_gid, H5_BLOCKNAME_X)); + TRY (plist_id = hdf5_get_dataset_create_plist (dataset_id)); + TRY (hdf5_get_chunk_property (plist_id, 3, hdims)); + TRY (hdf5_close_property (plist_id)); + TRY (hdf5_close_dataset (dataset_id)); *i = hdims[2]; *j = hdims[1]; *k = hdims[0]; - h5_info(f, - "Found chunk dimensions (%lld,%lld,%lld)", + h5_info("Found chunk dimensions (%lld,%lld,%lld)", (long long)hdims[0], (long long)hdims[1], (long long)hdims[2] ); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } #ifdef PARALLEL_IO @@ -707,15 +698,16 @@ h5b_3d_set_grid ( const h5_size_t j, /*!< IN: dimension in \c j */ const h5_size_t k /*!< IN: dimension in \c k */ ) { - + H5_CORE_API_ENTER (h5_err_t); if (i*j*k != f->nprocs) { - return h5_error(f, H5_ERR_INVAL, - "Grid dimensions (%lld,%lld,%lld) do not multiply " - "out to %d MPI processors!", - (long long)i, - (long long)j, - (long long)k, - f->nprocs); + H5_CORE_API_LEAVE ( + h5_error(H5_ERR_INVAL, + "Grid dimensions (%lld,%lld,%lld) do not multiply " + "out to %d MPI processors!", + (long long)i, + (long long)j, + (long long)k, + f->nprocs)); } f->b->k_grid = i; @@ -729,7 +721,7 @@ h5b_3d_set_grid ( f->b->have_grid = 1; - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -740,17 +732,18 @@ h5b_3d_get_grid_coords ( h5_int64_t *j, /*!< OUT: index in \c j */ h5_int64_t *k /*!< OUT: index in \c k */ ) { - + H5_CORE_API_ENTER (h5_err_t); if ( ! f->b->have_grid ) - return h5_error(f, H5_ERR_INVAL, - "Grid dimensions have not been set!"); + H5_CORE_API_LEAVE ( + h5_error(H5_ERR_INVAL, + "Grid dimensions have not been set!")); int coords[3]; TRY( h5priv_mpi_cart_coords(f, f->b->cart_comm, proc, 3, coords) ); *k = coords[0]; *j = coords[1]; *i = coords[2]; - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -760,10 +753,11 @@ h5b_3d_set_dims ( const h5_size_t j, /*!< IN: dimension in \c j */ const h5_size_t k /*!< IN: dimension in \c k */ ) { - + H5_CORE_API_ENTER (h5_err_t); if ( ! f->b->have_grid ) - return h5_error(f, H5_ERR_INVAL, - "Grid dimensions have not been set!"); + H5_CORE_API_LEAVE ( + h5_error(H5_ERR_INVAL, + "Grid dimensions have not been set!")); h5_size_t dims[3] = { k, j, i }; h5_size_t check_dims[3] = { k, j, i }; @@ -775,12 +769,17 @@ h5b_3d_set_dims ( dims[1] != check_dims[1] || dims[2] != check_dims[2] ) { - return h5_error(f, H5_ERR_INVAL, - "[%d] Block dimensions do not agree: " - "(%lld,%lld,%lld) != (%lld,%lld,%lld)!", - f->myproc, - (long long)dims[0], (long long)dims[1], (long long)dims[2], - (long long)check_dims[0], (long long)check_dims[1], (long long)check_dims[2]); + H5_CORE_API_LEAVE ( + h5_error(H5_ERR_INVAL, + "[%d] Block dimensions do not agree: " + "(%lld,%lld,%lld) != (%lld,%lld,%lld)!", + f->myproc, + (long long)dims[0], + (long long)dims[1], + (long long)dims[2], + (long long)check_dims[0], + (long long)check_dims[1], + (long long)check_dims[2])); } h5_int64_t coords[3]; TRY( h5b_3d_get_grid_coords(f, @@ -803,7 +802,7 @@ h5b_3d_set_dims ( b->have_layout = 1; - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } #endif @@ -814,14 +813,16 @@ h5b_3d_set_halo ( const h5_size_t j, /*!< IN: radius in \c j */ const h5_size_t k /*!< IN: radius in \c k */ ) { - - if ( ! f->b->have_grid ) - return h5_error(f, H5_ERR_INVAL, - "Grid dimensions have not been set!"); - else if ( ! f->b->have_layout ) - return h5_error(f, H5_ERR_INVAL, - "Block dimensions for grid have not been set!"); - + H5_CORE_API_ENTER (h5_err_t); + if ( ! f->b->have_grid ) { + H5_CORE_API_LEAVE ( + h5_error(H5_ERR_INVAL, + "Grid dimensions have not been set!")); + } else if ( ! f->b->have_layout ) { + H5_CORE_API_LEAVE ( + h5_error(H5_ERR_INVAL, + "Block dimensions for grid have not been set!")); + } h5b_fdata_t *b = f->b; b->user_layout->i_start -= i; @@ -831,18 +832,18 @@ h5b_3d_set_halo ( b->user_layout->k_start -= k; b->user_layout->k_end += k; - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_ssize_t h5b_get_num_fields ( h5_file_t *const f /*!< IN: File handle */ ) { - + H5_CORE_API_ENTER (h5_ssize_t); CHECK_TIMEGROUP( f ); - TRY( h5bpriv_open_block_group(f) ); - return h5priv_get_num_objs_in_hdf5_group( f, f->b->block_gid ); + TRY (h5bpriv_open_block_group(f)); + H5_CORE_API_RETURN (hdf5_get_num_objs_in_group (f->b->block_gid)); } h5_err_t @@ -854,7 +855,7 @@ h5b_get_field_info_by_name ( h5_size_t *elem_rank, /*!< OUT: element rank */ h5_int64_t *type /*!< OUT: datatype */ ) { - + H5_CORE_API_ENTER (h5_err_t); CHECK_TIMEGROUP( f ); hsize_t dims[16]; /* give it plenty of space even though we don't expect rank > 3 */ @@ -866,33 +867,30 @@ h5b_get_field_info_by_name ( hid_t dataset_id; hid_t dataspace_id; - TRY( dataset_id = h5priv_open_hdf5_dataset(f, - f->b->field_gid, H5_BLOCKNAME_X) ); - TRY( dataspace_id = h5priv_get_hdf5_dataset_space(f, dataset_id) ); + TRY (dataset_id = hdf5_open_dataset (f->b->field_gid, H5_BLOCKNAME_X)); + TRY (dataspace_id = hdf5_get_dataset_space (dataset_id) ); - TRY( _field_rank = h5priv_get_dims_of_hdf5_dataspace(f, - dataspace_id, dims, NULL) ); - if ( field_rank ) *field_rank = (h5_size_t) _field_rank; + TRY (_field_rank = hdf5_get_dims_of_dataspace (dataspace_id, dims, NULL)); + if (field_rank) *field_rank = (h5_size_t) _field_rank; - if ( field_dims ) { + if (field_dims) { for ( i = 0, j = _field_rank-1; i < _field_rank; i++, j-- ) field_dims[i] = (h5_size_t)dims[j]; } - TRY( _elem_rank = h5priv_get_num_objs_in_hdf5_group(f, - f->b->field_gid) ); - if ( elem_rank ) *elem_rank = (h5_size_t) _elem_rank; + TRY (_elem_rank = hdf5_get_num_objs_in_group (f->b->field_gid)); + if (elem_rank) *elem_rank = (h5_size_t) _elem_rank; hid_t h5type; - TRY( h5type = h5priv_get_hdf5_dataset_type(f, dataset_id) ); + TRY (h5type = hdf5_get_dataset_type (dataset_id)); if ( type ) TRY( *type = h5_normalize_h5_type(f, h5type) ); - TRY( h5priv_close_hdf5_dataspace(f, dataspace_id) ); - TRY( h5priv_close_hdf5_dataset(f, dataset_id) ); + TRY (hdf5_close_dataspace (dataspace_id)); + TRY (hdf5_close_dataset (dataset_id)); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -906,18 +904,18 @@ h5b_get_field_info ( h5_size_t *elem_rank, /*!< OUT: element rank */ h5_int64_t *type /*!< OUT: datatype */ ) { - + H5_CORE_API_ENTER (h5_err_t); CHECK_TIMEGROUP( f ); - TRY( h5bpriv_open_block_group(f) ); - TRY( h5priv_get_hdf5_objname_by_idx( - f, - f->b->block_gid, - (hsize_t)idx, - name, - (size_t)len_name) ); + TRY (h5bpriv_open_block_group(f)); + TRY (hdf5_get_objname_by_idx( + f->b->block_gid, + (hsize_t)idx, + name, + (size_t)len_name) ); - return h5b_get_field_info_by_name(f, - name, field_rank, field_dims, elem_rank, type); + H5_CORE_API_RETURN (h5b_get_field_info_by_name ( + f, + name, field_rank, field_dims, elem_rank, type)); } diff --git a/src/h5core/h5b_readwrite.c b/src/h5core/h5b_readwrite.c index 6151819..b20a885 100644 --- a/src/h5core/h5b_readwrite.c +++ b/src/h5core/h5b_readwrite.c @@ -5,7 +5,7 @@ static h5_err_t _select_hyperslab_for_writing ( h5_file_t *const f /*!< IN: file handle */ ) { - + H5_PRIV_FUNC_ENTER (h5_err_t); /* re-use existing hyperslab */ @@ -36,11 +36,9 @@ _select_hyperslab_for_writing ( }; - TRY( b->shape = h5priv_create_hdf5_dataspace(f, - rank, field_dims, NULL) ); - TRY( b->diskshape = h5priv_create_hdf5_dataspace(f, - rank, field_dims, NULL) ); - h5_debug (f, + TRY (b->shape = hdf5_create_dataspace(rank, field_dims, NULL)); + TRY (b->diskshape = hdf5_create_dataspace(rank,field_dims,NULL)); + h5_debug ( "PROC[%d]: Select hyperslab on diskshape: \n" "\tstart: (%lld,%lld,%lld)\n" "\tstride: (%lld,%lld,%lld)\n" @@ -56,26 +54,25 @@ _select_hyperslab_for_writing ( (long long)part_dims[1], (long long)part_dims[0] ); - TRY( h5priv_select_hyperslab_of_hdf5_dataspace(f, - b->diskshape, - H5S_SELECT_SET, - start, - stride, - part_dims, - NULL) ); + TRY( hdf5_select_hyperslab_of_dataspace( + b->diskshape, + H5S_SELECT_SET, + start, + stride, + part_dims, + NULL) ); field_dims[0] = q->k_end - q->k_start + 1; field_dims[1] = q->j_end - q->j_start + 1; field_dims[2] = q->i_end - q->i_start + 1; - TRY( b->memshape = h5priv_create_hdf5_dataspace(f, - rank, field_dims, NULL) ); + TRY (b->memshape = hdf5_create_dataspace(rank,field_dims,NULL)); start[0] = p->k_start - q->k_start; start[1] = p->j_start - q->j_start; start[2] = p->i_start - q->i_start; - h5_debug (f, + h5_debug ( "PROC[%d]: Select hyperslab on memshape: \n" "\tstart: (%lld,%lld,%lld)\n" "\tstride: (%lld,%lld,%lld)\n" @@ -91,15 +88,15 @@ _select_hyperslab_for_writing ( (long long)part_dims[1], (long long)part_dims[0] ); - TRY( h5priv_select_hyperslab_of_hdf5_dataspace(f, - b->memshape, - H5S_SELECT_SET, - start, - stride, - part_dims, - NULL) ); + TRY (hdf5_select_hyperslab_of_dataspace( + b->memshape, + H5S_SELECT_SET, + start, + stride, + part_dims, + NULL)); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t @@ -110,46 +107,49 @@ _write_data ( const void *data, /*!< IN: data to write */ const hid_t type /*!< IN: data type */ ) { - + H5_PRIV_FUNC_ENTER (h5_err_t); hid_t dataset; h5b_fdata_t *b = f->b; h5_err_t exists; - TRY( exists = h5priv_hdf5_link_exists (f, b->field_gid, data_name) ); + TRY (exists = hdf5_link_exists (b->field_gid, data_name)); if ( exists > 0 ) { - TRY( dataset = h5priv_open_hdf5_dataset(f, - b->field_gid, data_name) ); + TRY (dataset = hdf5_open_dataset (b->field_gid, data_name)); hid_t type_file; - TRY( type_file = h5priv_get_hdf5_dataset_type(f, dataset) ); + TRY( type_file = hdf5_get_dataset_type (dataset) ); if ( type != type_file ) { - return h5_error(f, + return h5_error( H5_ERR_HDF5, "Field '%s' already has type '%s' " "but was written as '%s'.", field_name, - h5priv_get_base_type_name(f, type_file), - h5priv_get_base_type_name(f, type) ); + hdf5_get_type_name (type_file), + hdf5_get_type_name (type)); } } else { - TRY( dataset = h5priv_create_hdf5_dataset(f, - b->field_gid, - data_name, - type, - b->shape, - b->dcreate_prop) ); + TRY (dataset = hdf5_create_dataset( + b->field_gid, + data_name, + type, + b->shape, + b->dcreate_prop)); } +#ifdef PARALLEL_IO + TRY (h5_start_throttle (f)); +#endif + TRY (hdf5_write_dataset( + dataset, + type, + b->memshape, + b->diskshape, + f->xfer_prop, + data)); +#ifdef PARALLEL_IO + TRY (h5_end_throttle (f)); +#endif + TRY (hdf5_close_dataset (dataset)); - TRY( h5priv_write_hdf5_dataset(f, - dataset, - type, - b->memshape, - b->diskshape, - f->xfer_prop, - data) ); - - TRY( h5priv_close_hdf5_dataset(f, dataset) ); - - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } h5_err_t @@ -159,13 +159,14 @@ h5b_write_scalar_data ( const void *data, /*!< IN: data to write */ const hid_t type /*!< IN: data type */ ) { + H5_CORE_API_ENTER (h5_err_t); CHECK_TIMEGROUP( f ); CHECK_WRITABLE_MODE( f ); CHECK_LAYOUT( f ); TRY( h5bpriv_create_field_group(f, field_name) ); TRY( _select_hyperslab_for_writing(f) ); TRY( _write_data(f, field_name, H5_BLOCKNAME_X, data, type) ); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -177,6 +178,7 @@ h5b_write_vector3d_data ( const void *zdata, /*!< IN: z data to write */ const hid_t type /*!< IN: data type */ ) { + H5_CORE_API_ENTER (h5_err_t); CHECK_TIMEGROUP( f ); CHECK_WRITABLE_MODE( f ); CHECK_LAYOUT( f ); @@ -185,7 +187,7 @@ h5b_write_vector3d_data ( TRY( _write_data(f, field_name, H5_BLOCKNAME_X, xdata, type) ); TRY( _write_data(f, field_name, H5_BLOCKNAME_Y, ydata, type) ); TRY( _write_data(f, field_name, H5_BLOCKNAME_Z, zdata, type) ); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } static h5_err_t @@ -193,7 +195,7 @@ _select_hyperslab_for_reading ( h5_file_t *const f, /*!< IN: file handle */ const hid_t dataset ) { - + H5_PRIV_FUNC_ENTER (h5_err_t); h5b_fdata_t *b = f->b; h5b_partition_t *p = b->user_layout; int rank; @@ -210,44 +212,44 @@ _select_hyperslab_for_reading ( TRY( h5bpriv_release_hyperslab(f) ); - TRY( b->diskshape = h5priv_get_hdf5_dataset_space(f, dataset) ); + TRY (b->diskshape = hdf5_get_dataset_space (dataset)); - TRY( rank = h5priv_get_dims_of_hdf5_dataspace(f, - b->diskshape, field_dims, NULL) ); - if ( rank != 3 ) - return h5_error(f, - H5_ERR_INVAL, - "H5Block dataset has bad rank '%d' instead of rank 3! " - "Is the file corrupt?", - rank); + TRY (rank = hdf5_get_dims_of_dataspace(b->diskshape, field_dims, NULL)); + if (rank != 3) + H5_PRIV_FUNC_LEAVE ( + h5_error( + H5_ERR_INVAL, + "H5Block dataset has bad rank '%d' instead" + " of rank 3! Is the file corrupt?", + rank)); if ( (field_dims[0] < (hsize_t)b->k_max) || (field_dims[1] < (hsize_t)b->j_max) || (field_dims[2] < (hsize_t)b->i_max) ) - return h5_error(f, - H5_ERR_LAYOUT, - "H5Block dataset has invalid layout. " - "Is the file corrupt?"); + H5_PRIV_FUNC_LEAVE ( + h5_error( + H5_ERR_LAYOUT, + "H5Block dataset has invalid layout. " + "Is the file corrupt?")); - h5_debug (f, + h5_debug ( "[%d]: field_dims: (%lld,%lld,%lld)", f->myproc, (long long)field_dims[2], (long long)field_dims[1], (long long)field_dims[0] ); - TRY( b->memshape = h5priv_create_hdf5_dataspace(f, - rank, part_dims, NULL) ); + TRY (b->memshape = hdf5_create_dataspace (rank, part_dims, NULL)); - TRY( h5priv_select_hyperslab_of_hdf5_dataspace(f, - b->diskshape, - H5S_SELECT_SET, - start, - stride, - part_dims, - NULL) ); + TRY (hdf5_select_hyperslab_of_dataspace( + b->diskshape, + H5S_SELECT_SET, + start, + stride, + part_dims, + NULL)); - h5_debug (f, + h5_debug ( "PROC[%d]: Select hyperslab: \n" "\tstart: (%lld,%lld,%lld)\n" "\tstride: (%lld,%lld,%lld)\n" @@ -263,7 +265,7 @@ _select_hyperslab_for_reading ( (long long)part_dims[1], (long long)part_dims[0] ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t @@ -273,22 +275,28 @@ read_data ( void *data, /*!< OUT: ptr to read buffer */ const hid_t type /*!< IN: data type */ ) { - + H5_PRIV_FUNC_ENTER (h5_err_t); hid_t dataset; h5b_fdata_t *b = f->b; - TRY( dataset = h5priv_open_hdf5_dataset(f, b->field_gid, dataset_name) ); - TRY( _select_hyperslab_for_reading(f, dataset) ); - TRY( h5priv_read_hdf5_dataset(f, - dataset, - type, - f->b->memshape, - f->b->diskshape, - f->xfer_prop, - data) ); - TRY( h5priv_close_hdf5_dataset(f, dataset) ); + TRY (dataset = hdf5_open_dataset (b->field_gid, dataset_name)); + TRY (_select_hyperslab_for_reading (f, dataset) ); +#ifdef PARALLEL_IO + TRY (h5_start_throttle (f)); +#endif + TRY (hdf5_read_dataset( + dataset, + type, + f->b->memshape, + f->b->diskshape, + f->xfer_prop, + data)); +#ifdef PARALLEL_IO + TRY (h5_end_throttle (f)); +#endif + TRY (hdf5_close_dataset(dataset)); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } h5_err_t @@ -298,11 +306,12 @@ h5b_read_scalar_data ( void *data, /*!< OUT: read bufer */ const hid_t type /*!< IN: data type */ ) { + H5_CORE_API_ENTER (h5_err_t); CHECK_TIMEGROUP( f ); CHECK_LAYOUT( f ); TRY( h5bpriv_open_field_group(f, field_name) ); TRY( read_data(f, H5_BLOCKNAME_X, data, type) ); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -314,12 +323,13 @@ h5b_read_vector3d_data ( void *zdata, /*!< IN: z data to write */ const hid_t type /*!< IN: data type */ ) { + H5_CORE_API_ENTER (h5_err_t); CHECK_TIMEGROUP( f ); CHECK_LAYOUT( f ); TRY( h5bpriv_open_field_group(f, field_name) ); TRY( read_data(f, H5_BLOCKNAME_X, xdata, type) ); TRY( read_data(f, H5_BLOCKNAME_Y, ydata, type) ); TRY( read_data(f, H5_BLOCKNAME_Z, zdata, type) ); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5t_access_tetm.c b/src/h5core/h5t_access_tetm.c index 46c7605..b0583a2 100644 --- a/src/h5core/h5t_access_tetm.c +++ b/src/h5core/h5t_access_tetm.c @@ -326,7 +326,7 @@ is_boundary_face ( UNUSED_ARGUMENT (elem_idx); UNUSED_ARGUMENT (facet_idx); - return h5_error_internal (f, __FILE__, __func__, __LINE__); + return h5_error_internal (__FILE__, __func__, __LINE__); } struct h5t_access_methods h5tpriv_access_tetm_methods = { diff --git a/src/h5core/h5t_access_trim.c b/src/h5core/h5t_access_trim.c index 38ed9eb..2ad32a0 100644 --- a/src/h5core/h5t_access_trim.c +++ b/src/h5core/h5t_access_trim.c @@ -322,7 +322,7 @@ is_boundary_face ( UNUSED_ARGUMENT (dim); UNUSED_ARGUMENT (elem_idx); UNUSED_ARGUMENT (facet_idx); - return h5_error_internal (f, __FILE__, __func__, __LINE__); + return h5_error_internal (__FILE__, __func__, __LINE__); } struct h5t_access_methods h5tpriv_access_trim_methods = { diff --git a/src/h5core/h5t_adjacencies.c b/src/h5core/h5t_adjacencies.c index 7934c06..fbca8a6 100644 --- a/src/h5core/h5t_adjacencies.c +++ b/src/h5core/h5t_adjacencies.c @@ -23,7 +23,8 @@ h5t_get_adjacencies ( const h5_int32_t dim, h5_loc_idlist_t** list ) { - return h5tpriv_get_adjacencies (f, entity_id, dim, list); + H5_CORE_API_ENTER (h5_err_t); + H5_CORE_API_RETURN (h5tpriv_get_adjacencies (f, entity_id, dim, list)); } h5_err_t @@ -31,8 +32,8 @@ h5t_release_list_of_adjacencies ( h5_file_t* const f, h5_loc_idlist_t** list ) { - TRY( h5priv_free_idlist (f, list) ); - return H5_SUCCESS; + H5_CORE_API_ENTER (h5_err_t);; + H5_CORE_API_RETURN (h5priv_free_idlist (f, list)); } h5_err_t @@ -42,5 +43,6 @@ h5t_find_te2 ( h5_loc_idx_t elem_idx, h5_loc_idlist_t** retval ) { - return h5tpriv_find_te2 (f,face_idx,elem_idx,retval); + H5_CORE_API_ENTER (h5_err_t); + H5_CORE_API_RETURN (h5tpriv_find_te2 (f,face_idx,elem_idx,retval)); } diff --git a/src/h5core/h5t_adjacencies_private.h b/src/h5core/h5t_adjacencies_private.h index a178e91..a076593 100644 --- a/src/h5core/h5t_adjacencies_private.h +++ b/src/h5core/h5t_adjacencies_private.h @@ -19,17 +19,20 @@ h5tpriv_get_adjacencies ( const h5_int32_t dim, h5_loc_idlist_t** list ) { + H5_PRIV_API_ENTER (h5_err_t); if (f->t->methods.adjacency == NULL) { - h5_error_internal (f, __FILE__, __func__, __LINE__); + H5_PRIV_API_LEAVE ( + h5_error_internal (__FILE__, __func__, __LINE__)); } - return (*f->t->methods.adjacency->get_adjacencies)(f, entity_id, dim, list); + H5_PRIV_API_RETURN (f->t->methods.adjacency->get_adjacencies( + f, entity_id, dim, list)); } static inline h5_err_t h5tpriv_release_adjacency_structs ( h5_file_t* const f ) { - h5_debug (f, "%s ()", __func__); + h5_debug ("%s ()", __func__); if (f->t->methods.adjacency == NULL) { return 0; } @@ -41,7 +44,7 @@ h5tpriv_update_adjacency_structs ( h5_file_t* const f, const h5t_lvl_idx_t level_id ) { - h5_debug (f, "%s (%lld)", __func__, (long long)level_id); + h5_debug ("%s (%lld)", __func__, (long long)level_id); return (*f->t->methods.adjacency->update_internal_structs)(f, level_id); } diff --git a/src/h5core/h5t_adjacencies_tetm.c b/src/h5core/h5t_adjacencies_tetm.c index 28e98a8..47b1748 100644 --- a/src/h5core/h5t_adjacencies_tetm.c +++ b/src/h5core/h5t_adjacencies_tetm.c @@ -26,17 +26,18 @@ alloc_tv ( h5_file_t* const f, const h5t_lvl_idx_t from_lvl ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; h5_loc_idx_t num_vertices = t->num_vertices[t->num_leaf_levels-1]; h5t_adjacencies_t* adj = &t->adjacencies; // allocate ptr to ID-list per vertex - TRY( adj->tv.v = h5_alloc (f, adj->tv.v, num_vertices*sizeof(*adj->tv.v)) ); + TRY( adj->tv.v = h5_alloc (adj->tv.v, num_vertices*sizeof(*adj->tv.v)) ); size_t i = from_lvl <= 0 ? 0 : t->num_vertices[from_lvl-1]; bzero (adj->tv.v+i, (num_vertices-i)*sizeof(*adj->tv.v)); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -46,18 +47,20 @@ static inline h5_err_t release_tv ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; h5t_adjacencies_t* adj = &t->adjacencies; - if (adj->tv.v == NULL) return H5_SUCCESS; + if (adj->tv.v == NULL) + H5_PRIV_FUNC_LEAVE (H5_SUCCESS); h5_loc_idx_t vertex_idx = 0; h5_loc_idx_t last = t->num_vertices[t->num_leaf_levels-1]; for (; vertex_idx < last; vertex_idx++) { TRY( h5priv_free_idlist (f, &adj->tv.v[vertex_idx]) ); } - TRY( h5_free (f, adj->tv.v) ); + TRY( h5_free (adj->tv.v) ); adj->tv.v = NULL; - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -68,6 +71,7 @@ compute_elems_of_vertices ( h5_file_t* const f, const h5t_lvl_idx_t from_lvl ) { + H5_PRIV_FUNC_ENTER (h5_err_t); /* expand structure */ TRY( alloc_tv (f, from_lvl) ); @@ -82,7 +86,7 @@ compute_elems_of_vertices ( TRY( h5tpriv_search_tv2 (f, face_idx, elem_idx, NULL) ); } } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -93,6 +97,7 @@ compute_elems_of_edges ( h5_file_t* const f, const h5t_lvl_idx_t from_lvl ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; h5_loc_idx_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; @@ -104,7 +109,7 @@ compute_elems_of_edges ( TRY( h5tpriv_search_te2 (f, face_idx, elem_idx, NULL) ); } } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -115,6 +120,7 @@ compute_elems_of_triangles ( h5_file_t* const f, const h5t_lvl_idx_t from_lvl ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; h5_loc_idx_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; @@ -126,7 +132,7 @@ compute_elems_of_triangles ( TRY( h5tpriv_search_td2 (f, face_idx, elem_idx, NULL) ); } } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -138,6 +144,7 @@ compute_children_of_edge ( h5_loc_id_t entity_id, h5_loc_idlist_t** children ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* te; TRY( h5tpriv_find_te (f, entity_id, &te ) ); h5_loc_id_t* edge_idp = te->items; @@ -159,7 +166,7 @@ compute_children_of_edge ( TRY( compute_children_of_edge (f, edge_ids[1], children) ); } } while (++edge_idp < end); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -171,6 +178,7 @@ compute_sections_of_edge ( h5_loc_id_t entity_id, h5_loc_idlist_t** children ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* te; TRY( h5tpriv_find_te (f, entity_id, &te) ); h5_loc_id_t* edge_idp = te->items; @@ -195,7 +203,7 @@ compute_sections_of_edge ( if (!refined) { TRY( h5priv_insert_idlist (f, children, te->items[0], -1) ); } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -236,6 +244,7 @@ compute_direct_children_of_triangle ( h5_loc_idx_t elem_idx, // in h5_loc_id_t* children // out ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idx_t map[4][4][2] = { {{0,0},{0,1},{0,2},{0,5}}, {{1,0},{1,1},{1,3},{2,4}}, @@ -244,7 +253,8 @@ compute_direct_children_of_triangle ( }; int num_faces = h5tpriv_ref_elem_get_num_facets (f->t); if ((face_idx < 0) || (face_idx >= num_faces)) { - return h5_error_internal (f, __FILE__, __func__, __LINE__); + H5_PRIV_FUNC_LEAVE ( + h5_error_internal (__FILE__, __func__, __LINE__)); } children[0] = h5tpriv_build_triangle_id ( map[face_idx][0][0], elem_idx+map[face_idx][0][1]); @@ -254,7 +264,7 @@ compute_direct_children_of_triangle ( map[face_idx][2][0], elem_idx+map[face_idx][2][1]); children[3] = h5tpriv_build_triangle_id ( map[face_idx][3][0], elem_idx+map[face_idx][3][1]); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -263,6 +273,7 @@ compute_children_of_triangle ( h5_loc_id_t entity_id, h5_loc_idlist_t** children ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* td; TRY( h5tpriv_find_td (f, entity_id, &td) ); h5_loc_id_t* triangle_idp = td->items; @@ -286,7 +297,7 @@ compute_children_of_triangle ( TRY( compute_children_of_triangle (f, triangle_ids[3], children) ); } } while (++triangle_idp < end); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -295,6 +306,7 @@ compute_sections_of_triangle ( h5_loc_id_t entity_id, h5_loc_idlist_t** children ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* td; TRY( h5tpriv_find_td (f, entity_id, &td) ); h5_loc_id_t* triangle_idp = td->items; @@ -321,7 +333,7 @@ compute_sections_of_triangle ( if (! refined) { TRY( h5priv_insert_idlist (f, children, td->items[0], -1) ); } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -334,10 +346,11 @@ add_vertex2 ( h5_loc_idx_t face_idx, // in h5_loc_idx_t elem_idx // in ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* tv; TRY( h5tpriv_find_tv2 (f, face_idx, elem_idx, &tv) ); TRY( h5priv_search_idlist (f, list, tv->items[0]) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -349,10 +362,11 @@ add_edge ( h5_loc_idlist_t** list, // out h5_loc_id_t entity_id // in ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* te; TRY( h5tpriv_find_te (f, entity_id, &te) ); TRY( h5priv_search_idlist (f, list, te->items[0]) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -362,10 +376,11 @@ add_edge2 ( h5_loc_idx_t face_idx, // in h5_loc_idx_t elem_idx // in ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* te; TRY( h5tpriv_find_te2 (f, face_idx, elem_idx, &te) ); TRY( h5priv_search_idlist (f, list, te->items[0]) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -377,11 +392,12 @@ add_triangle ( h5_loc_idlist_t** list, // out h5_loc_idx_t entity_id // in ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* td; TRY( h5tpriv_find_td (f, entity_id, &td) ); TRY( h5priv_search_idlist (f, list, td->items[0]) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -391,11 +407,12 @@ add_triangle2 ( h5_loc_idx_t face_idx, // in h5_loc_idx_t elem_idx // in ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* td; TRY( h5tpriv_find_td2 (f, face_idx, elem_idx, &td) ); TRY( h5priv_search_idlist (f, list, td->items[0]) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -404,10 +421,11 @@ add_elem2 ( h5_loc_idlist_t** list, // out h5_loc_idx_t elem_idx // in ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_id_t elem_id = h5tpriv_build_tet_id (0, elem_idx); TRY( h5priv_search_idlist (f, list, elem_id) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -419,6 +437,7 @@ get_edges_uadj_to_vertex ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idx_t vertex_idx; TRY( h5t_get_vertex_index_of_vertex (f, entity_id, &vertex_idx) ); h5_loc_idlist_t* tv = f->t->adjacencies.tv.v[vertex_idx]; @@ -447,7 +466,7 @@ get_edges_uadj_to_vertex ( f->t, 0, face_idx, 2), elem_idx) ); } while (++vertex_idp < end); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -456,6 +475,7 @@ get_triangles_uadj_to_vertex ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); /* get list of all tetrahedra connected to given vertex Note: this list may include tetrahedra which are not in the (current) leaf grid */ @@ -487,7 +507,7 @@ get_triangles_uadj_to_vertex ( f->t, 0, face_idx, 2), elem_idx) ); } while (++vertex_idp < end); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -496,6 +516,7 @@ get_tets_uadj_to_vertex ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idx_t vertex_idx; TRY( h5t_get_vertex_index_of_vertex (f, entity_id, &vertex_idx) ); h5_loc_idlist_t* tv = f->t->adjacencies.tv.v[vertex_idx]; @@ -511,7 +532,7 @@ get_tets_uadj_to_vertex ( } TRY( add_elem2 (f, list, elem_idx) ); } while (++vertex_idp < end); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -520,6 +541,7 @@ get_triangles_uadj_to_edge ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); TRY( compute_children_of_edge (f, entity_id, &children) ); @@ -540,7 +562,7 @@ get_triangles_uadj_to_edge ( } while (++edge_idp < end); TRY( h5priv_free_idlist ( f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -549,6 +571,7 @@ get_tets_uadj_to_edge ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); TRY( compute_children_of_edge (f, entity_id, &children) ); @@ -559,7 +582,7 @@ get_tets_uadj_to_edge ( TRY( add_elem2 (f, list, h5tpriv_get_elem_idx (*edge_idp)) ); } while (++edge_idp < end); TRY( h5priv_free_idlist (f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -568,6 +591,7 @@ get_tets_uadj_to_triangle ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); TRY( compute_children_of_triangle (f, entity_id, &children) ); @@ -578,7 +602,7 @@ get_tets_uadj_to_triangle ( TRY( add_elem2 (f, list, h5tpriv_get_elem_idx (*triangle_idp)) ); } while (++triangle_idp < end); TRY( h5priv_free_idlist (f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -587,6 +611,7 @@ get_vertices_dadj_to_edge ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); TRY( compute_sections_of_edge (f, entity_id, &children) ); @@ -608,7 +633,7 @@ get_vertices_dadj_to_edge ( elem_idx) ); } while (++edge_idp < end); TRY( h5priv_free_idlist(f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -620,6 +645,7 @@ get_vertices_dadj_to_triangle ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); @@ -652,7 +678,7 @@ get_vertices_dadj_to_triangle ( elem_idx) ); } while (++edge_idp < end ); TRY( h5priv_free_idlist(f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -664,6 +690,7 @@ get_vertices_dadj_to_tet ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* children; h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); TRY( h5priv_alloc_idlist (f, &children, 8) ); @@ -693,7 +720,7 @@ get_vertices_dadj_to_tet ( elem_idx) ); } while (++edge_idp < end); TRY( h5priv_free_idlist(f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -702,6 +729,7 @@ get_edges_dadj_to_triangle ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); h5_loc_idx_t face_idx = h5tpriv_get_face_idx (entity_id); @@ -725,7 +753,7 @@ get_edges_dadj_to_triangle ( TRY( add_edge (f, list, *edge_idp) ); } while (++edge_idp < end); TRY( h5priv_free_idlist (f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -734,6 +762,7 @@ get_edges_dadj_to_tet ( const h5_loc_id_t elem_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (elem_id); @@ -754,7 +783,7 @@ get_edges_dadj_to_tet ( TRY( add_edge (f, list, *edge_idp) ); } while (++edge_idp < end); TRY( h5priv_free_idlist (f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -763,6 +792,7 @@ get_triangles_dadj_to_tet ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); @@ -781,7 +811,7 @@ get_triangles_dadj_to_tet ( TRY( add_triangle (f, list, *triangle_idp) ); } while (++triangle_idp < end); TRY( h5priv_free_idlist (f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -790,7 +820,6 @@ dim_error( const h5_int32_t dim ) { return h5_error ( - f, H5_ERR_INVAL, "Illegal dimension %ld", (long)dim); } @@ -891,7 +920,7 @@ get_adjacencies ( default: break; } - return h5_error_internal (f, __FILE__, __func__, __LINE__); + return h5_error_internal (__FILE__, __func__, __LINE__); } @@ -900,6 +929,7 @@ update_internal_structs ( h5_file_t* const f, const h5t_lvl_idx_t from_lvl ) { + H5_PRIV_FUNC_ENTER (h5_err_t); clock_t t1 = clock(); TRY( compute_elems_of_vertices (f, from_lvl) ); clock_t t2 = clock(); @@ -916,19 +946,20 @@ update_internal_structs ( fprintf (stderr, "compute_tets_of_triangle(): %f\n", (float)(t2-t1)/CLOCKS_PER_SEC); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t release_internal_structs ( h5_file_t * const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; TRY( release_tv (f) ); TRY( h5priv_hdestroy (f, &t->adjacencies.te_hash) ); TRY( h5priv_hdestroy (f, &t->adjacencies.td_hash) ); bzero (&t->adjacencies, sizeof (t->adjacencies)); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } struct h5t_adjacency_methods h5tpriv_tetm_adjacency_methods = { diff --git a/src/h5core/h5t_adjacencies_trim.c b/src/h5core/h5t_adjacencies_trim.c index cd3fbae..593f279 100644 --- a/src/h5core/h5t_adjacencies_trim.c +++ b/src/h5core/h5t_adjacencies_trim.c @@ -22,35 +22,38 @@ alloc_tv ( h5_file_t* const f, const h5t_lvl_idx_t from_lvl ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; h5_loc_idx_t num_vertices = t->num_vertices[t->num_leaf_levels-1]; h5t_adjacencies_t* adj = &t->adjacencies; // allocate ptr to ID-list per vertex - TRY( adj->tv.v = h5_alloc (f, adj->tv.v, num_vertices*sizeof(*adj->tv.v)) ); + TRY( adj->tv.v = h5_alloc (adj->tv.v, num_vertices*sizeof(*adj->tv.v)) ); size_t i = from_lvl <= 0 ? 0 : t->num_vertices[from_lvl-1]; bzero (adj->tv.v+i, (num_vertices-i)*sizeof(*adj->tv.v)); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t release_tv ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; h5t_adjacencies_t* adj = &t->adjacencies; - if (adj->tv.v == NULL) return H5_SUCCESS; + if (adj->tv.v == NULL) + H5_PRIV_FUNC_LEAVE (H5_SUCCESS); h5_loc_idx_t vertex_idx = 0; h5_loc_idx_t last = t->num_vertices[t->num_leaf_levels-1]; for (; vertex_idx < last; vertex_idx++) { TRY( h5priv_free_idlist (f, &adj->tv.v[vertex_idx]) ); } - TRY( h5_free (f, adj->tv.v) ); + TRY( h5_free (adj->tv.v) ); adj->tv.v = NULL; - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -61,6 +64,7 @@ compute_elems_of_vertices ( h5_file_t* const f, const h5t_lvl_idx_t from_lvl ) { + H5_PRIV_FUNC_ENTER (h5_err_t); /* expand structure */ TRY( alloc_tv (f, from_lvl) ); @@ -75,7 +79,7 @@ compute_elems_of_vertices ( TRY( h5tpriv_search_tv2 (f, face_idx, elem_idx, NULL) ); } } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -86,6 +90,7 @@ compute_elems_of_edges ( h5_file_t* const f, const h5t_lvl_idx_t from_lvl ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t *t = f->t; h5_loc_idx_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; @@ -97,7 +102,7 @@ compute_elems_of_edges ( TRY ( h5tpriv_search_te2 (f, face_idx, elem_idx, NULL ) ); } } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -109,6 +114,7 @@ compute_children_of_edge ( h5_loc_id_t entity_id, h5_loc_idlist_t** children ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* te; TRY( h5tpriv_find_te (f, entity_id, &te ) ); h5_loc_id_t* edge_idp = te->items; @@ -131,7 +137,7 @@ compute_children_of_edge ( } } while (++edge_idp < end); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -143,6 +149,7 @@ compute_sections_of_edge ( h5_loc_id_t entity_id, h5_loc_idlist_t** children ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* te; TRY( h5tpriv_find_te (f, entity_id, &te) ); h5_loc_id_t* edge_idp = te->items; @@ -167,7 +174,7 @@ compute_sections_of_edge ( if (!refined) { TRY( h5priv_insert_idlist (f, children, te->items[0], -1) ); } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -180,10 +187,11 @@ add_vertex2 ( h5_loc_idx_t face_idx, // in h5_loc_idx_t elem_idx // in ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* tv; TRY( h5tpriv_find_tv2 (f, face_idx, elem_idx, &tv) ); TRY( h5priv_search_idlist (f, list, tv->items[0]) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -195,10 +203,11 @@ add_edge ( h5_loc_idlist_t** list, // out h5_loc_id_t entity_id // in ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* te; TRY( h5tpriv_find_te (f, entity_id, &te) ); TRY( h5priv_search_idlist (f, list, te->items[0]) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -208,10 +217,11 @@ add_edge2 ( h5_loc_idx_t face_idx, h5_loc_idx_t elem_idx ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t *te; TRY( h5tpriv_find_te2 (f, face_idx, elem_idx, &te) ); TRY( h5priv_search_idlist (f, list, te->items[0]) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -220,10 +230,11 @@ add_elem2 ( h5_loc_idlist_t** list, // out h5_loc_idx_t elem_idx // in ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_id_t elem_id = h5tpriv_build_triangle_id (0, elem_idx); TRY( h5priv_search_idlist (f, list, elem_id) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -235,6 +246,7 @@ get_edges_uadj_to_vertex ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idx_t vertex_idx; TRY( h5t_get_vertex_index_of_vertex (f, entity_id, &vertex_idx) ); h5_loc_idlist_t* tv = f->t->adjacencies.tv.v[vertex_idx]; @@ -259,7 +271,7 @@ get_edges_uadj_to_vertex ( f->t, 0, face_idx, 1), elem_idx) ); } while (++vertex_idp < end); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -268,6 +280,7 @@ get_triangles_uadj_to_vertex ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idx_t vertex_idx; TRY( h5t_get_vertex_index_of_vertex (f, entity_id, &vertex_idx) ); h5_loc_idlist_t* tv = f->t->adjacencies.tv.v[vertex_idx]; @@ -284,7 +297,7 @@ get_triangles_uadj_to_vertex ( } TRY( add_elem2 (f, list, elem_idx) ); } while (++vertex_idp < end); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -293,6 +306,7 @@ get_triangles_uadj_to_edge ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); TRY( compute_children_of_edge (f, entity_id, &children) ); @@ -305,7 +319,7 @@ get_triangles_uadj_to_edge ( } while (++edge_idp < end); TRY( h5priv_free_idlist (f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -314,6 +328,7 @@ get_edges_adj_to_edge ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); TRY( h5priv_alloc_idlist (f, list, 8) ); h5_loc_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); @@ -325,7 +340,7 @@ get_edges_adj_to_edge ( TRY( add_edge (f, list, *edge_idp) ); } while (++edge_idp < end); TRY( h5priv_free_idlist(f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -334,6 +349,7 @@ get_vertices_dadj_to_edge ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); TRY( compute_sections_of_edge (f, entity_id, &children) ); @@ -354,7 +370,7 @@ get_vertices_dadj_to_edge ( elem_idx) ); } while (++edge_idp < end); TRY( h5priv_free_idlist (f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -366,6 +382,7 @@ get_vertices_dadj_to_triangle ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* children; TRY ( h5priv_alloc_idlist ( f, &children, 8 ) ); @@ -396,7 +413,7 @@ get_vertices_dadj_to_triangle ( elem_idx) ); } while (++edge_idp < end); TRY ( h5priv_free_idlist(f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -405,6 +422,7 @@ get_edges_dadj_to_triangle ( const h5_loc_id_t entity_id, h5_loc_idlist_t** list ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_loc_idlist_t* children; TRY ( h5priv_alloc_idlist (f, &children, 8) ); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); @@ -423,7 +441,7 @@ get_edges_dadj_to_triangle ( TRY( add_edge (f, list, *edge_idp) ); } while (++edge_idp < end); TRY ( h5priv_free_idlist(f, &children) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -432,7 +450,6 @@ dim_error( const h5_int32_t dim ) { return h5_error ( - f, H5_ERR_INVAL, "Illegal dimension %ld", (long)dim); } @@ -508,7 +525,7 @@ get_adjacencies ( default: break; } - return h5_error_internal (f, __FILE__, __func__, __LINE__); + return h5_error_internal (__FILE__, __func__, __LINE__); } static inline h5_err_t @@ -516,7 +533,8 @@ update_internal_structs ( h5_file_t* const f, const h5t_lvl_idx_t from_lvl ) { - h5_debug (f, "%s (%lld)", __func__, (long long)from_lvl); + H5_PRIV_FUNC_ENTER (h5_err_t); + h5_debug ("%s (%lld)", __func__, (long long)from_lvl); clock_t t1 = clock(); TRY( compute_elems_of_vertices (f, from_lvl) ); clock_t t2 = clock(); @@ -527,19 +545,20 @@ update_internal_structs ( t2 = clock(); fprintf (stderr, "compute_elems_of_edge(): %f\n", (float)(t2-t1)/CLOCKS_PER_SEC); - h5_debug (f, "%s (%lld): done", __func__, (long long)from_lvl); - return H5_SUCCESS; + h5_debug ("%s (%lld): done", __func__, (long long)from_lvl); + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static inline h5_err_t release_internal_structs ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t *t = f->t; TRY( release_tv (f) ); TRY( h5priv_hdestroy (f, &t->adjacencies.te_hash) ); bzero (&t->adjacencies, sizeof (t->adjacencies)); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } struct h5t_adjacency_methods h5tpriv_trim_adjacency_methods = { diff --git a/src/h5core/h5t_errorhandling.c b/src/h5core/h5t_errorhandling.c index f53ec2b..7ed871a 100644 --- a/src/h5core/h5t_errorhandling.c +++ b/src/h5core/h5t_errorhandling.c @@ -5,31 +5,3 @@ #include #include "h5core/h5_core.h" #include "h5_core_private.h" - -#if 0 -const char* ERR_ELEM_NEXIST = "Element with local vertex IDs (%s) doesn't exist!"; -h5_err_t -h5tpriv_error_local_elem_nexist ( - h5_file_t* const f, - h5_loc_idx_t local_vertex_indices[] - ) { - h5t_fdata_t* t = f->t; - char s[1024]; - - int num_chars_printed = snprintf (s, sizeof(s), "%lld,", - (long long)local_vertex_indices[0]); - int i; - int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); - for (i = 1; i < num_vertices; i++) { - num_chars_printed += snprintf ( - s + num_chars_printed, sizeof (s) - num_chars_printed, - "%lld,", (long long)local_vertex_indices[i]); - if ((sizeof (s) - num_chars_printed) < 32) { - // buffer to small - return h5_error_internal (f, __FILE__, __func__, __LINE__); - } - } - - return h5_error (f, H5_ERR_NOENTRY, ERR_ELEM_NEXIST, s); -} -#endif diff --git a/src/h5core/h5t_errorhandling_private.h b/src/h5core/h5t_errorhandling_private.h index 378797a..29882ca 100644 --- a/src/h5core/h5t_errorhandling_private.h +++ b/src/h5core/h5t_errorhandling_private.h @@ -21,11 +21,11 @@ h5tpriv_error_local_elem_nexist ( "%lld,", (long long)vertex_indices[i]); if ((sizeof (s) - num_chars_printed) < 32) { // buffer to small - return h5_error_internal (f, __FILE__, __func__, __LINE__); + return h5_error_internal (__FILE__, __func__, __LINE__); } } - return h5_error (f, H5_ERR_NOENTRY, ERR_ELEM_NEXIST, s); + return h5_error (H5_ERR_NOENTRY, ERR_ELEM_NEXIST, s); } static inline h5_err_t @@ -35,57 +35,50 @@ h5tpriv_inval_codim ( int min_codim, int max_codim ) { - return h5_error (f, H5_ERR_INVAL, + return h5_error (H5_ERR_INVAL, "Co-dimension %d requested, " "but must be between %d and %d", codim, min_codim, max_codim); } -#define h5tpriv_error_undef_mesh( f ) \ +#define h5tpriv_error_undef_mesh() \ h5_error( \ - f, \ H5_ERR_INVAL, \ "Mesh not yet defined." ); -#define h5tpriv_error_undef_level( f ) \ +#define h5tpriv_error_undef_level() \ h5_error( \ - f, \ H5_ERR_INVAL, \ "Level not defined." ); -#define h5tpriv_error_nexist_level( f, level_id ) \ +#define h5tpriv_error_nexist_level( level_id ) \ h5_error( \ - f, \ H5_ERR_INVAL, \ "Level %lld doesn't exist.", (long long)level_id ); -#define h5tpriv_error_global_id_nexist( f, name, id ) \ +#define h5tpriv_error_global_id_nexist( name, id ) \ h5_error( \ - f, \ H5_ERR_NOENTRY, \ "%s with global id %lld does not exist!", \ name, (long long)id ); -#define h5tpriv_error_global_triangle_id_nexist( f, vids ) \ +#define h5tpriv_error_global_triangle_id_nexist( vids ) \ h5_error( \ - f, \ H5_ERR_NOENTRY, \ "Triangle with global vertex ids (%lld,%lld,%lld) doesn't exist!", \ (long long)vids[0], (long long)vids[1], (long long)vids[2] ); -#define h5tpriv_error_local_triangle_nexist( f, indices ) \ +#define h5tpriv_error_local_triangle_nexist( indices ) \ h5_error( \ - f, \ H5_ERR_NOENTRY, \ "Triangle with global vertex ids (%lld,%lld,%lld) doesn't exist!", \ (long long)indices[0], (long long)indices[1], (long long)indices[2] ); -#define h5tpriv_error_store_boundaryface_local_id( f, local_fid ) \ +#define h5tpriv_error_store_boundaryface_local_id( local_fid ) \ h5_error( \ - f, \ H5_ERR_INVAL, \ "Boundary face with local id %lld is not on level 0!", \ (long long)local_fid ); diff --git a/src/h5core/h5t_hsearch.c b/src/h5core/h5t_hsearch.c index b3873f7..2dfde93 100644 --- a/src/h5core/h5t_hsearch.c +++ b/src/h5core/h5t_hsearch.c @@ -11,22 +11,20 @@ h5tpriv_search_tv2 ( h5_loc_idx_t elem_idx, h5_loc_idlist_t** idlist ) { - H5_CORE_API_ENTER; - h5_err_t ret_value = H5_SUCCESS; + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; h5_loc_idx_t vertex_idx; - TRY2( ret_value = h5t_get_vertex_index_of_vertex2 ( - f, - face_idx, elem_idx, - &vertex_idx) ); + TRY (h5t_get_vertex_index_of_vertex2 ( + f, + face_idx, elem_idx, + &vertex_idx)); - TRY2( ret_value = h5priv_search_idlist ( - f, - &t->adjacencies.tv.v[vertex_idx], - h5tpriv_build_vertex_id (face_idx, elem_idx)) ); - - H5_CORE_API_RETURN (ret_value); + TRY (h5priv_search_idlist ( + f, + &t->adjacencies.tv.v[vertex_idx], + h5tpriv_build_vertex_id (face_idx, elem_idx))); + H5_PRIV_API_RETURN (H5_SUCCESS); } static int @@ -62,11 +60,12 @@ release_te_entry ( h5_file_t * const f, const void* __entry ) { + H5_PRIV_FUNC_ENTER (h5_err_t); struct h5_te_entry* entry = *(struct h5_te_entry**)__entry; h5_loc_idlist_t* list = entry->value; - TRY( h5priv_free_idlist (f, &list) ); - TRY( h5_free (f, entry) ); - return H5_SUCCESS; + TRY (h5priv_free_idlist (f, &list)); + TRY (h5_free (entry)); + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } h5_err_t @@ -74,19 +73,20 @@ h5tpriv_resize_te_htab ( h5_file_t* const f, size_t nel ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_adjacencies_t* a = &f->t->adjacencies; if ( a->te_hash.size == 0 ) { - TRY( h5priv_hcreate ( + TRY (h5priv_hcreate ( f, nel, &a->te_hash, cmp_te_entries, compute_te_hashval, - release_te_entry) ); + release_te_entry)); } else if (a->te_hash.size < nel) { - TRY( h5priv_hresize (f, nel, &a->te_hash) ); + TRY (h5priv_hresize (f, nel, &a->te_hash)); } - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } h5_err_t @@ -96,15 +96,16 @@ h5tpriv_search_te2 ( h5_loc_idx_t elem_idx, h5_loc_idlist_t** idlist ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; h5t_adjacencies_t* a = &t->adjacencies; void* __retval; h5t_te_entry_t* entry; - TRY( entry = h5_calloc (f, 1, sizeof (*entry)) ); + TRY (entry = h5_calloc (1, sizeof (*entry))); - TRY( h5t_get_vertex_indices_of_edge2 ( - f, face_idx, elem_idx, entry->key.vids) ); + TRY (h5t_get_vertex_indices_of_edge2 ( + f, face_idx, elem_idx, entry->key.vids)); /* resize hash table if more than 3/4 filled */ @@ -119,30 +120,30 @@ h5tpriv_search_te2 ( of edges we still have to add to the hash table. */ h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; - TRY( h5priv_hresize ( + TRY (h5priv_hresize ( f, 3*(num_elems - elem_idx), - &a->te_hash) ); + &a->te_hash)); } - TRY( h5priv_hsearch ( + TRY (h5priv_hsearch ( f, entry, H5_ENTER, &__retval, - &a->te_hash) ); + &a->te_hash)); h5t_te_entry_t* te_entry = (h5t_te_entry_t *)__retval; - TRY( h5priv_search_idlist ( + TRY (h5priv_search_idlist ( f, &te_entry->value, - h5tpriv_build_edge_id (face_idx, elem_idx)) ); + h5tpriv_build_edge_id (face_idx, elem_idx))); if (te_entry->value->num_items > 1) { /* search returned existing entry */ - TRY( h5_free (f, entry) ); + TRY (h5_free (entry)); } if (idlist) { *idlist = te_entry->value; } - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } /* @@ -156,21 +157,22 @@ find_te ( h5t_te_entry_t* item, // in: item to find h5_loc_idlist_t** idlist // out: ) { + H5_PRIV_FUNC_ENTER (h5_err_t); void* __entry; - TRY( h5priv_hsearch ( + TRY (h5priv_hsearch ( f, item, H5_FIND, &__entry, - &f->t->adjacencies.te_hash) ); + &f->t->adjacencies.te_hash)); h5t_te_entry_t* entry = (h5t_te_entry_t*)__entry; if (entry ==NULL) { - return H5_NOK; // not found + H5_PRIV_FUNC_LEAVE (H5_NOK); // not found } if (idlist) { *idlist = entry->value; } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -184,12 +186,14 @@ h5tpriv_find_te ( h5_loc_idx_t edge_id, // in h5_loc_idlist_t** idlist // out ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_te_entry_t item; - TRY( h5t_get_vertex_indices_of_edge ( + TRY (h5t_get_vertex_indices_of_edge ( f, edge_id, - item.key.vids) ); - return find_te (f, &item, idlist); + item.key.vids)); + TRY (find_te (f, &item, idlist)); + H5_PRIV_API_RETURN (H5_SUCCESS); } h5_err_t @@ -199,13 +203,15 @@ h5tpriv_find_te2 ( h5_loc_idx_t elem_idx, // in h5_loc_idlist_t** idlist // out ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_te_entry_t item; - TRY( h5t_get_vertex_indices_of_edge2 ( - f, - face_idx, - elem_idx, - item.key.vids) ); - return find_te (f, &item, idlist); + TRY (h5t_get_vertex_indices_of_edge2 ( + f, + face_idx, + elem_idx, + item.key.vids)); + TRY (find_te (f, &item, idlist)); + H5_PRIV_API_RETURN (H5_SUCCESS); } static int @@ -241,11 +247,12 @@ release_td_entry ( h5_file_t * const f, const void* __entry ) { + H5_PRIV_FUNC_ENTER (h5_err_t); struct h5_td_entry* entry = *(struct h5_td_entry**)__entry; h5_loc_idlist_t* list = entry->value; - TRY( h5priv_free_idlist (f, &list) ); - TRY( h5_free (f, entry) ); - return H5_SUCCESS; + TRY (h5priv_free_idlist (f, &list)); + TRY (h5_free (entry)); + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } @@ -254,19 +261,20 @@ h5tpriv_resize_td_htab ( h5_file_t* const f, size_t nel ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_adjacencies_t* a = &f->t->adjacencies; if (a->td_hash.size == 0) { - TRY( h5priv_hcreate ( + TRY (h5priv_hcreate ( f, nel, &a->td_hash, cmp_td_entries, compute_td_hashval, - release_td_entry) ); + release_td_entry)); } else if (a->td_hash.size < nel) { - TRY( h5priv_hresize (f, nel, &a->td_hash) ); + TRY (h5priv_hresize (f, nel, &a->td_hash)); } - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } h5_err_t @@ -276,46 +284,47 @@ h5tpriv_search_td2 ( h5_loc_idx_t elem_idx, h5_loc_idlist_t** idlist // out ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; h5t_adjacencies_t* a = &f->t->adjacencies; void* __retval; h5t_td_entry_t* entry; - TRY( entry = h5_calloc (f, 1, sizeof(*entry)) ); + TRY (entry = h5_calloc (1, sizeof(*entry)) ); - TRY( h5t_get_vertex_indices_of_triangle2 ( + TRY (h5t_get_vertex_indices_of_triangle2 ( f, face_idx, elem_idx, entry->key.vids) ); /* resize hash table if more than 3/4 filled */ if ((a->td_hash.size*6) <= (a->td_hash.filled<<3)) { h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; - TRY( h5priv_hresize ( + TRY (h5priv_hresize ( f, 3*(num_elems-elem_idx), &a->td_hash)); } /* search in directory, add if entry doen't already exists */ - TRY( h5priv_hsearch ( + TRY (h5priv_hsearch ( f, entry, H5_ENTER, &__retval, - &a->td_hash) ); + &a->td_hash)); /* search ID in list of IDs for given triangle */ h5t_td_entry_t *td_entry = (h5t_td_entry_t *)__retval; - TRY( h5priv_search_idlist ( + TRY (h5priv_search_idlist ( f, &td_entry->value, - h5tpriv_build_triangle_id (face_idx, elem_idx)) ); + h5tpriv_build_triangle_id (face_idx, elem_idx))); if (td_entry->value->num_items > 1) { - TRY( h5_free (f, entry) ); + TRY (h5_free (entry)); } if (idlist) { *idlist = td_entry->value; } - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -332,7 +341,7 @@ find_td ( &__entry, &f->t->adjacencies.td_hash); if (__entry == NULL) { - return h5tpriv_error_local_triangle_nexist (f, item->key.vids); + return h5tpriv_error_local_triangle_nexist (item->key.vids); } h5t_td_entry_t* entry = (h5t_td_entry_t*)__entry; *idlist = entry->value; @@ -345,12 +354,14 @@ h5tpriv_find_td ( h5_loc_idx_t triangle_id, h5_loc_idlist_t** idlist ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_td_entry_t item; - TRY( h5t_get_vertex_indices_of_triangle ( + TRY (h5t_get_vertex_indices_of_triangle ( f, triangle_id, - item.key.vids) ); - return find_td (f, &item, idlist); + item.key.vids)); + TRY (find_td (f, &item, idlist)); + H5_PRIV_API_RETURN (H5_SUCCESS); } h5_err_t @@ -360,13 +371,15 @@ h5tpriv_find_td2 ( h5_loc_idx_t elem_idx, h5_loc_idlist_t** idlist ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_td_entry_t item; - TRY( h5t_get_vertex_indices_of_triangle2 ( + TRY (h5t_get_vertex_indices_of_triangle2 ( f, face_idx, elem_idx, - item.key.vids) ); - return find_td (f, &item, idlist); + item.key.vids)); + TRY (find_td (f, &item, idlist)); + H5_PRIV_API_RETURN (H5_SUCCESS); } /* @@ -379,9 +392,9 @@ h5tpriv_find_tv2 ( h5_loc_idx_t elem_idx, h5_loc_idlist_t** idlist ) { + H5_PRIV_API_ENTER (h5_err_t); h5_loc_idx_t idx; - TRY( idx = h5tpriv_get_loc_elem_vertex_idx (f, elem_idx, face_idx) ); + TRY (idx = h5tpriv_get_loc_elem_vertex_idx (f, elem_idx, face_idx)); *idlist = f->t->adjacencies.tv.v[idx]; - - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5t_inquiry.c b/src/h5core/h5t_inquiry.c index 148f3ca..37f287a 100644 --- a/src/h5core/h5t_inquiry.c +++ b/src/h5core/h5t_inquiry.c @@ -9,29 +9,31 @@ \return Number of meshes of type \c type_id or error code. */ -h5_size_t +h5_ssize_t h5t_get_num_meshes ( h5_file_t* const f, const h5_oid_t type_id ) { + H5_CORE_API_ENTER (h5_ssize_t); hid_t topo_gid = -1; hid_t meshes_gid = -1; h5_err_t exists; - TRY( exists = h5priv_hdf5_link_exists (f, f->root_gid, H5T_CONTAINER_GRPNAME) ); + TRY (exists = hdf5_link_exists (f->root_gid, H5T_CONTAINER_GRPNAME)); if (!exists) return 0; - TRY( topo_gid = h5priv_open_hdf5_group (f, f->root_gid, H5T_CONTAINER_GRPNAME) ); + TRY (topo_gid = hdf5_open_group (f->root_gid, H5T_CONTAINER_GRPNAME)); - TRY( exists = h5priv_hdf5_link_exists (f, topo_gid, h5tpriv_meshes_grpnames[type_id]) ); + TRY (exists = hdf5_link_exists (topo_gid, h5tpriv_meshes_grpnames[type_id])); if (!exists) return 0; - TRY( meshes_gid = h5priv_open_hdf5_group (f, topo_gid, h5tpriv_meshes_grpnames[type_id]) ); + TRY (meshes_gid = hdf5_open_group (topo_gid, h5tpriv_meshes_grpnames[type_id])); + h5_ssize_t num_meshes; + TRY (num_meshes = h5_get_num_hdf5_groups (meshes_gid)); + TRY (hdf5_close_group (meshes_gid) ); + TRY (hdf5_close_group (topo_gid) ); - h5_size_t num_meshes = h5_get_num_hdf5_groups (f, meshes_gid); - TRY( h5priv_close_hdf5_group (f, meshes_gid) ); - TRY( h5priv_close_hdf5_group (f, topo_gid) ); - return num_meshes; + H5_CORE_API_RETURN (num_meshes); } /*! @@ -41,16 +43,15 @@ h5t_get_num_meshes ( \return Number of hierarchical mesh levels or error code. */ -h5_size_t +h5_ssize_t h5t_get_num_leaf_levels ( h5_file_t* const f ) { - h5t_fdata_t* t = f->t; - - if (t->cur_mesh < 0) { - return h5tpriv_error_undef_mesh (f); + H5_CORE_API_ENTER (h5_ssize_t); + if (f->t->cur_mesh < 0) { + H5_CORE_API_LEAVE (h5tpriv_error_undef_mesh ()); } - return t->num_leaf_levels; + H5_CORE_API_RETURN (f->t->num_leaf_levels); } /*! @@ -64,7 +65,8 @@ h5t_lvl_idx_t h5t_get_level ( h5_file_t* const f ) { - return f->t->leaf_level; + H5_CORE_API_ENTER (h5t_lvl_idx_t); + H5_CORE_API_RETURN (f->t->leaf_level); } /*! @@ -80,21 +82,21 @@ h5t_get_level ( \return Number of elements or error code. */ -h5_size_t +h5_ssize_t h5t_get_num_elems ( h5_file_t* const f, const h5_id_t cnode ) { + H5_CORE_API_ENTER (h5_ssize_t); UNUSED_ARGUMENT (cnode); - h5t_fdata_t* t = f->t; - if (t->cur_mesh < 0) { - return h5tpriv_error_undef_mesh (f); + if (f->t->cur_mesh < 0) { + H5_CORE_API_LEAVE (h5tpriv_error_undef_mesh ()); } - if (t->leaf_level < 0) { - return h5tpriv_error_undef_level (f); + if (f->t->leaf_level < 0) { + H5_CORE_API_LEAVE (h5tpriv_error_undef_level ()); } - return t->num_elems_on_leaf_level[t->leaf_level]; + H5_CORE_API_RETURN (f->t->num_elems_on_leaf_level[f->t->leaf_level]); } /*! @@ -110,20 +112,20 @@ h5t_get_num_elems ( \return Number of vertices or error code. */ -h5_size_t +h5_ssize_t h5t_get_num_vertices ( h5_file_t* const f, h5_id_t cnode ) { + H5_CORE_API_ENTER (h5_ssize_t); UNUSED_ARGUMENT (cnode); - h5t_fdata_t* t = f->t; - if (t->cur_mesh < 0) { - return h5tpriv_error_undef_mesh (f); + if (f->t->cur_mesh < 0) { + H5_CORE_API_LEAVE (h5tpriv_error_undef_mesh ()); } - if (t->leaf_level < 0) { - return h5tpriv_error_undef_level (f); + if (f->t->leaf_level < 0) { + H5_CORE_API_LEAVE (h5tpriv_error_undef_level ()); } - return t->num_vertices[t->leaf_level]; + H5_CORE_API_RETURN (f->t->num_vertices[f->t->leaf_level]); } diff --git a/src/h5core/h5t_map.c b/src/h5core/h5t_map.c index 792dc1c..5fb6812 100644 --- a/src/h5core/h5t_map.c +++ b/src/h5core/h5t_map.c @@ -33,9 +33,10 @@ cmp_vertices ( h5_err_t h5tpriv_sort_local_vertex_indices ( h5_file_t* const f, - h5_loc_idx_t* const indices, /* IN/OUT: local vertex indices */ + h5_loc_idx_t* const indices, /* IN/OUT: local vertex indices */ const h5_size_t size /* size of array */ ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; h5_size_t i; @@ -52,7 +53,7 @@ h5tpriv_sort_local_vertex_indices ( } indices[j] = idx; } - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } /*! @@ -63,12 +64,14 @@ h5t_map_global_vertex_idx2local ( h5_file_t* const f, const h5_glb_idx_t glb_idx ) { + H5_CORE_API_ENTER (h5_loc_idx_t); if (glb_idx < 0) return -1; h5_loc_idx_t loc_idx = h5priv_search_idxmap (&f->t->map_vertex_g2l, glb_idx); - if (loc_idx < 0) - return h5tpriv_error_global_id_nexist (f, "vertex", glb_idx); - return loc_idx; + if (loc_idx < 0) { + H5_CORE_API_LEAVE (h5tpriv_error_global_id_nexist ("vertex", glb_idx)); + } + H5_CORE_API_RETURN (loc_idx); } h5_err_t @@ -78,12 +81,13 @@ h5t_map_global_vertex_indices2local ( const h5_size_t size, h5_loc_idx_t* const loc_indices ) { + H5_CORE_API_ENTER (h5_err_t); h5_size_t i; for (i = 0; i < size; i++) { - TRY( (loc_indices[i] = - h5t_map_global_vertex_idx2local (f, glb_indices[i])) ); + TRY (loc_indices[i] = + h5t_map_global_vertex_idx2local (f, glb_indices[i])); } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } /*! @@ -99,12 +103,13 @@ h5t_map_glb_elem_idx2loc ( h5_file_t* const f, const h5_glb_idx_t glb_idx ) { - if (glb_idx < 0) return -1; + H5_CORE_API_ENTER (h5_loc_idx_t); + if (glb_idx < 0) H5_CORE_API_LEAVE (-1); h5_loc_idx_t loc_idx = h5priv_search_idxmap (&f->t->map_elem_g2l, glb_idx); if (loc_idx < 0) - return h5tpriv_error_global_id_nexist (f, "elem", glb_idx); - return loc_idx; + H5_CORE_API_LEAVE (h5tpriv_error_global_id_nexist ("elem", glb_idx)); + H5_CORE_API_RETURN (loc_idx); } h5_err_t @@ -114,15 +119,16 @@ h5t_map_glb_elem_indices2loc ( const h5_size_t size, h5_loc_idx_t* loc_indices ) { + H5_CORE_API_ENTER (h5_err_t); const h5_glb_idx_t* end = glb_indices+size; while (glb_indices < end) { - TRY( (*loc_indices = - h5t_map_glb_elem_idx2loc (f, *glb_indices)) ); + TRY (*loc_indices = + h5t_map_glb_elem_idx2loc (f, *glb_indices)); loc_indices++; glb_indices++; } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } @@ -133,9 +139,9 @@ h5_err_t h5tpriv_rebuild_vertex_indices_mapping ( h5_file_t* const f ) { - h5_debug (f, "%s()", __func__); + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; - if (t->num_leaf_levels <= 0) return H5_SUCCESS; + if (t->num_leaf_levels <= 0) H5_PRIV_API_LEAVE (H5_SUCCESS); h5_loc_idx_t loc_idx = t->leaf_level > 0 ? t->num_vertices[t->leaf_level-1] : 0; h5_loc_idx_t num_loc_vertices = t->num_vertices[t->num_leaf_levels-1]; @@ -147,8 +153,7 @@ h5tpriv_rebuild_vertex_indices_mapping ( t->map_vertex_g2l.num_items++; } h5priv_sort_idxmap (&t->map_vertex_g2l); - - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } /* @@ -158,9 +163,9 @@ h5_err_t h5tpriv_rebuild_elem_indices_mapping ( h5_file_t* const f ) { - h5_debug (f, "%s()", __func__); + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; - if (t->num_leaf_levels <= 0) return H5_SUCCESS; + if (t->num_leaf_levels <= 0) H5_PRIV_API_LEAVE (H5_SUCCESS); h5_loc_idx_t loc_idx = t->leaf_level > 0 ? t->num_elems[t->leaf_level-1] : 0; h5_loc_idx_t num_loc_elems = t->num_elems[t->num_leaf_levels-1]; @@ -172,8 +177,7 @@ h5tpriv_rebuild_elem_indices_mapping ( t->map_elem_g2l.num_items++; } h5priv_sort_idxmap (&t->map_elem_g2l); - - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } /* @@ -185,6 +189,7 @@ h5t_get_vertex_indices_of_entity ( const h5_loc_id_t entity_id, // in h5_loc_idx_t* vertex_indices // out ) { + H5_CORE_API_ENTER (h5_err_t); h5_loc_idx_t type = h5tpriv_get_entity_type (entity_id); h5_loc_idx_t face_idx = h5tpriv_get_face_idx (entity_id); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); @@ -195,9 +200,9 @@ h5t_get_vertex_indices_of_entity ( case H5T_TYPE_TRIANGLE: dim = 2; break; case H5T_TYPE_TET: dim = 3; break; default: - h5_error_internal (f, __FILE__, __func__, __LINE__); + H5_CORE_API_LEAVE (h5_error_internal (__FILE__, __func__, __LINE__)); } - return h5t_get_vertex_indices_of_entity2 (f, dim, face_idx, elem_idx, vertex_indices); + H5_CORE_API_RETURN (h5t_get_vertex_indices_of_entity2 (f, dim, face_idx, elem_idx, vertex_indices)); } /* @@ -211,6 +216,7 @@ h5t_get_vertex_indices_of_entity2 ( const h5_loc_idx_t elem_idx, // [in] local element index h5_loc_idx_t* vertex_indices // [out] ) { + H5_CORE_API_ENTER (h5_err_t); h5_loc_idx_t* indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); const h5t_ref_elem_t* ref_elem = f->t->ref_elem; int num_vertices = ref_elem->num_vertices_of_face[dim][face_idx]; @@ -219,7 +225,7 @@ h5t_get_vertex_indices_of_entity2 ( int idx = h5tpriv_ref_elem_get_vertex_idx(f->t, dim, face_idx, i); vertex_indices[i] = indices[idx]; } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -228,10 +234,11 @@ h5t_get_vertex_index_of_vertex ( const h5_loc_id_t entity_id, h5_loc_idx_t* vertex_index ) { + H5_CORE_API_ENTER (h5_err_t); h5_loc_idx_t face_idx = h5tpriv_get_face_idx (entity_id); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); - return h5t_get_vertex_index_of_vertex2 ( - f, face_idx, elem_idx, vertex_index); + H5_CORE_API_RETURN (h5t_get_vertex_index_of_vertex2 ( + f, face_idx, elem_idx, vertex_index)); } h5_err_t @@ -241,8 +248,9 @@ h5t_get_vertex_index_of_vertex2 ( const h5_loc_idx_t elem_idx, // local element index h5_loc_idx_t* vertex_indices // OUT: vertex ID's ) { + H5_CORE_API_ENTER (h5_err_t); vertex_indices[0] = h5tpriv_get_loc_elem_vertex_idx (f, elem_idx, face_idx); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } /* @@ -254,10 +262,11 @@ h5t_get_vertex_indices_of_edge ( const h5_loc_id_t entity_id, h5_loc_idx_t* vertex_indices ) { + H5_CORE_API_ENTER (h5_err_t); h5_loc_idx_t face_idx = h5tpriv_get_face_idx (entity_id); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); - return h5t_get_vertex_indices_of_edge2 ( - f, face_idx, elem_idx, vertex_indices); + H5_CORE_API_RETURN (h5t_get_vertex_indices_of_edge2 ( + f, face_idx, elem_idx, vertex_indices)); } /*! @@ -274,6 +283,7 @@ h5t_get_vertex_indices_of_edge2 ( const h5_loc_idx_t elem_idx, // local element index h5_loc_idx_t* vertex_indices // OUT: vertex indices ) { + H5_CORE_API_ENTER (h5_err_t); const h5_loc_idx_t* indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); h5_loc_idx_t idx; @@ -281,7 +291,7 @@ h5t_get_vertex_indices_of_edge2 ( vertex_indices[0] = indices[idx]; idx = h5tpriv_ref_elem_get_vertex_idx (f->t, 1, face_idx, 1); vertex_indices[1] = indices[idx]; - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -290,10 +300,11 @@ h5t_get_vertex_indices_of_triangle ( const h5_loc_id_t entity_id, h5_loc_idx_t* vertex_indices ) { + H5_CORE_API_ENTER (h5_err_t); h5_loc_idx_t face_idx = h5tpriv_get_face_idx (entity_id); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); - return h5t_get_vertex_indices_of_triangle2 ( - f, face_idx, elem_idx, vertex_indices); + H5_CORE_API_RETURN (h5t_get_vertex_indices_of_triangle2 ( + f, face_idx, elem_idx, vertex_indices)); } h5_err_t @@ -303,6 +314,7 @@ h5t_get_vertex_indices_of_triangle2 ( const h5_loc_idx_t elem_idx, h5_loc_idx_t* vertex_indices ) { + H5_CORE_API_ENTER (h5_err_t); const h5_loc_idx_t* indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); h5_loc_idx_t idx; @@ -312,8 +324,7 @@ h5t_get_vertex_indices_of_triangle2 ( vertex_indices[1] = indices[idx]; idx = h5tpriv_ref_elem_get_vertex_idx (f->t, 2, face_idx, 2); vertex_indices[2] = indices[idx]; - - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -322,6 +333,7 @@ h5t_get_vertex_indices_of_tet ( const h5_loc_id_t entity_id, h5_loc_idx_t* vertex_indices ) { + H5_CORE_API_ENTER (h5_err_t); const h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); const h5_loc_idx_t* indices = h5tpriv_get_loc_elem_vertex_indices ( f, elem_idx); @@ -335,6 +347,5 @@ h5t_get_vertex_indices_of_tet ( vertex_indices[2] = indices[idx]; idx = h5tpriv_ref_elem_get_vertex_idx (f->t, 3, 0, 3); vertex_indices[3] = indices[idx]; - - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5t_openclose.c b/src/h5core/h5t_openclose.c index 3c0b7cd..23b2444 100644 --- a/src/h5core/h5t_openclose.c +++ b/src/h5core/h5t_openclose.c @@ -22,202 +22,187 @@ static struct h5t_methods tri_funcs = { /* create several HDF5 types */ -static h5_err_t +static inline h5_err_t create_array_types ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; h5_dtypes_t* dtypes = &(t->dtypes); hsize_t dims[1] = { 3 }; TRY( - dtypes->h5_coord3d_t = h5priv_create_hdf5_array_type ( - f, + dtypes->h5_coord3d_t = hdf5_create_array_type ( H5_FLOAT64_T, 1, dims) ); TRY( - dtypes->h5_3glb_idx_t = h5priv_create_hdf5_array_type ( - f, + dtypes->h5_3glb_idx_t = hdf5_create_array_type ( H5_ID_T, 1, dims) ); dims[0] = 4; TRY( - dtypes->h5_4glb_idx_t = h5priv_create_hdf5_array_type ( - f, + dtypes->h5_4glb_idx_t = hdf5_create_array_type ( H5_ID_T, 1, dims) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } -static h5_err_t +static inline h5_err_t create_vertex_type ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_dtypes_t* dtypes = &f->t->dtypes; TRY( - dtypes->h5_vertex_t = h5priv_create_hdf5_type ( - f, + dtypes->h5_vertex_t = hdf5_create_type ( H5_COMPOUND_T, sizeof (h5_glb_vertex_t)) ); TRY( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5_vertex_t, "idx", HOFFSET (h5_glb_vertex_t, idx), H5_ID_T) ); TRY( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5_vertex_t, "P", HOFFSET (h5_glb_vertex_t, P), dtypes->h5_coord3d_t) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } -static h5_err_t +static inline h5_err_t create_triangle_type ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_dtypes_t* dtypes = &f->t->dtypes; TRY( - dtypes->h5_triangle_t = h5priv_create_hdf5_type ( - f, + dtypes->h5_triangle_t = hdf5_create_type ( H5_COMPOUND_T, sizeof (h5_glb_triangle_t)) ); TRY( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5_triangle_t, "idx", HOFFSET (h5_glb_triangle_t, idx), H5_ID_T) ); TRY( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5_triangle_t, "parent_idx", HOFFSET (h5_glb_triangle_t, parent_idx), H5_ID_T) ); TRY( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5_triangle_t, "child_idx", HOFFSET(h5_glb_triangle_t, child_idx), H5_ID_T) ); TRY( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5_triangle_t, "vertex_indices", HOFFSET (h5_glb_triangle_t, vertex_indices), dtypes->h5_3glb_idx_t) ); TRY( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5_triangle_t, "neighbor_indices", HOFFSET(h5_glb_triangle_t, neighbor_indices), dtypes->h5_3glb_idx_t) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } -static h5_err_t +static inline h5_err_t create_tag_types ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_dtypes_t* dtypes = &f->t->dtypes; TRY ( - dtypes->h5t_glb_tag_idx_t = h5priv_create_hdf5_type ( - f, + dtypes->h5t_glb_tag_idx_t = hdf5_create_type ( H5_COMPOUND_T, sizeof (h5t_glb_tag_idx_t)) ); TRY ( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5t_glb_tag_idx_t, "eid", HOFFSET (h5t_glb_tag_idx_t, eid), H5_ID_T) ); TRY ( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5t_glb_tag_idx_t, "idx", HOFFSET (h5t_glb_tag_idx_t, idx), H5_ID_T) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } -static h5_err_t +static inline h5_err_t create_tet_type ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5_dtypes_t* dtypes = &f->t->dtypes; TRY( - dtypes->h5_tet_t = h5priv_create_hdf5_type ( - f, + dtypes->h5_tet_t = hdf5_create_type ( H5_COMPOUND_T, sizeof (h5_glb_tetrahedron_t)) ); TRY( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5_tet_t, "idx", HOFFSET (h5_glb_tetrahedron_t, idx), H5_ID_T) ); TRY( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5_tet_t, "parent_idx", HOFFSET (h5_glb_tetrahedron_t, parent_idx), H5_ID_T) ); TRY( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5_tet_t, "child_idx", HOFFSET (h5_glb_tetrahedron_t, child_idx), H5T_NATIVE_INT32) ); TRY( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5_tet_t, "vertex_indices", HOFFSET (h5_glb_tetrahedron_t, vertex_indices), dtypes->h5_4glb_idx_t) ); TRY( - h5priv_insert_hdf5_type ( - f, + hdf5_insert_type ( dtypes->h5_tet_t, "neighbor_indices", HOFFSET (h5_glb_tetrahedron_t, neighbor_indices), dtypes->h5_4glb_idx_t) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t init_fdata ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; memset (t->mesh_name, 0, sizeof (t->mesh_name)); @@ -253,28 +238,24 @@ init_fdata ( t->dsinfo_vertices.max_dims[0] = H5S_UNLIMITED; t->dsinfo_vertices.chunk_dims[0] = 4096; t->dsinfo_vertices.type_id = t->dtypes.h5_vertex_t; - TRY( t->dsinfo_vertices.create_prop = h5priv_create_hdf5_property ( - f, + TRY (t->dsinfo_vertices.create_prop = hdf5_create_property ( H5P_DATASET_CREATE) ); - TRY( h5priv_set_hdf5_chunk_property ( - f, + TRY (hdf5_set_chunk_property ( t->dsinfo_vertices.create_prop, t->dsinfo_vertices.rank, t->dsinfo_vertices.chunk_dims) ); t->dsinfo_vertices.access_prop = H5P_DEFAULT; /* NumVertices */ - strcpy( t->dsinfo_num_vertices.name, "NumVertices" ); + strcpy (t->dsinfo_num_vertices.name, "NumVertices"); t->dsinfo_num_vertices.rank = 1; t->dsinfo_num_vertices.dims[0] = 0; t->dsinfo_num_vertices.max_dims[0] = H5S_UNLIMITED; t->dsinfo_num_vertices.chunk_dims[0] = 4096; t->dsinfo_num_vertices.type_id = t->dtypes.h5_glb_idx_t; - TRY( t->dsinfo_num_vertices.create_prop = h5priv_create_hdf5_property ( - f, + TRY (t->dsinfo_num_vertices.create_prop = hdf5_create_property ( H5P_DATASET_CREATE) ); - TRY( h5priv_set_hdf5_chunk_property ( - f, + TRY (hdf5_set_chunk_property ( t->dsinfo_num_vertices.create_prop, t->dsinfo_num_vertices.rank, t->dsinfo_num_vertices.chunk_dims) ); @@ -286,11 +267,9 @@ init_fdata ( t->dsinfo_elems.dims[0] = 0; t->dsinfo_elems.max_dims[0] = H5S_UNLIMITED; t->dsinfo_elems.chunk_dims[0] = 4096; - TRY( t->dsinfo_elems.create_prop = h5priv_create_hdf5_property ( - f, + TRY (t->dsinfo_elems.create_prop = hdf5_create_property ( H5P_DATASET_CREATE) ); - TRY( h5priv_set_hdf5_chunk_property ( - f, + TRY (hdf5_set_chunk_property ( t->dsinfo_elems.create_prop, t->dsinfo_elems.rank, t->dsinfo_elems.chunk_dims) ); @@ -303,11 +282,9 @@ init_fdata ( t->dsinfo_num_elems.max_dims[0] = H5S_UNLIMITED; t->dsinfo_num_elems.chunk_dims[0] = 4096; t->dsinfo_num_elems.type_id = t->dtypes.h5_glb_idx_t; - TRY( t->dsinfo_num_elems.create_prop = h5priv_create_hdf5_property ( - f, + TRY (t->dsinfo_num_elems.create_prop = hdf5_create_property ( H5P_DATASET_CREATE) ); - TRY( h5priv_set_hdf5_chunk_property ( - f, + TRY( hdf5_set_chunk_property ( t->dsinfo_num_elems.create_prop, t->dsinfo_num_elems.rank, t->dsinfo_num_elems.chunk_dims) ); @@ -320,17 +297,15 @@ init_fdata ( t->dsinfo_num_elems_on_leaf_level.max_dims[0] = H5S_UNLIMITED; t->dsinfo_num_elems_on_leaf_level.chunk_dims[0] = 4096; t->dsinfo_num_elems_on_leaf_level.type_id = t->dtypes.h5_glb_idx_t; - TRY( t->dsinfo_num_elems_on_leaf_level.create_prop = h5priv_create_hdf5_property ( - f, + TRY( t->dsinfo_num_elems_on_leaf_level.create_prop = hdf5_create_property ( H5P_DATASET_CREATE) ); - TRY( h5priv_set_hdf5_chunk_property ( - f, + TRY( hdf5_set_chunk_property ( t->dsinfo_num_elems_on_leaf_level.create_prop, t->dsinfo_num_elems_on_leaf_level.rank, t->dsinfo_num_elems_on_leaf_level.chunk_dims) ); t->dsinfo_num_elems_on_leaf_level.access_prop = H5P_DEFAULT; - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /*! @@ -347,30 +322,30 @@ h5_err_t h5tpriv_open_file ( h5_file_t* const f /*!< IN: file handle */ ) { - - TRY( (f->t = h5_calloc (f, 1, sizeof (*f->t))) ); + H5_PRIV_API_ENTER (h5_err_t); + TRY (f->t = h5_calloc (1, sizeof (*f->t))); h5t_fdata_t* t = f->t; t->dtypes.h5_glb_idx_t = H5_INT64_T; t->dtypes.h5_int64_t = H5_INT64_T; t->dtypes.h5_float64_t = H5_FLOAT64_T; - TRY( create_array_types (f) ); - TRY( create_vertex_type (f) ); - TRY( create_triangle_type (f) ); - TRY( create_tet_type (f) ); - TRY( create_tag_types (f) ); - TRY( init_fdata (f) ); - - return H5_SUCCESS; + TRY (create_array_types (f)); + TRY (create_vertex_type (f)); + TRY (create_triangle_type (f)); + TRY (create_tet_type (f)); + TRY (create_tag_types (f)); + TRY (init_fdata (f)); + H5_PRIV_API_RETURN (H5_SUCCESS); } h5_err_t h5tpriv_init_step ( h5_file_t* const f ) { + H5_PRIV_API_ENTER (h5_err_t); UNUSED_ARGUMENT (f); - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } /* @@ -382,8 +357,9 @@ h5_err_t h5tpriv_close_step ( h5_file_t* const f ) { + H5_PRIV_API_ENTER (h5_err_t); UNUSED_ARGUMENT (f); - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } @@ -391,11 +367,12 @@ h5_err_t h5tpriv_open_topo_group ( h5_file_t * const f ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; if (t->topo_gid == 0 || t->topo_gid == -1) { - t->topo_gid = h5priv_open_group (f, f->root_gid, H5T_CONTAINER_GRPNAME); + TRY (t->topo_gid = h5priv_open_group (f, f->root_gid, H5T_CONTAINER_GRPNAME)); } - return t->topo_gid; + H5_PRIV_API_RETURN (t->topo_gid); } h5_err_t @@ -403,18 +380,19 @@ h5tpriv_open_meshes_group ( h5_file_t* const f, const h5_oid_t type_id ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; if (t->topo_gid < 0) { - TRY( h5tpriv_open_topo_group (f) ); + TRY (h5tpriv_open_topo_group (f)); } - TRY( (t->meshes_gid = h5priv_open_group ( + TRY (t->meshes_gid = h5priv_open_group ( f, t->topo_gid, - h5tpriv_meshes_grpnames[type_id])) ); + h5tpriv_meshes_grpnames[type_id])); t->mesh_type = type_id; - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } /* @@ -427,19 +405,20 @@ h5tpriv_open_mesh_group ( const h5_oid_t type_id, const h5_id_t id ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; if (t->meshes_gid < 0) { - TRY( h5tpriv_open_meshes_group (f, type_id) ); + TRY (h5tpriv_open_meshes_group (f, type_id)); } snprintf (t->mesh_name, sizeof (t->mesh_name), "%lld", (long long)id); - TRY( (t->mesh_gid = h5priv_open_group ( + TRY (t->mesh_gid = h5priv_open_group ( f, t->meshes_gid, - t->mesh_name)) ); + t->mesh_name)); t->cur_mesh = id; - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } /* @@ -451,17 +430,17 @@ h5t_open_mesh ( h5_id_t id, const h5_oid_t type_id ) { - h5_debug (f, "%s ()", __func__); + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; - TRY( h5t_close_mesh (f) ); + TRY (h5t_close_mesh (f)); if (t->num_meshes < 0) { h5_size_t result = h5t_get_num_meshes (f, type_id); t->num_meshes = (result > 0 ? result : 0); } if ((id < -1) || (id >= t->num_meshes)) { - return HANDLE_H5_OUT_OF_RANGE_ERR (f, "mesh", id); + H5_CORE_API_LEAVE (HANDLE_H5_OUT_OF_RANGE_ERR ("mesh", id)); } if (id == -1) { /* append new mesh */ id = t->num_meshes; @@ -478,13 +457,14 @@ h5t_open_mesh ( t->ref_elem = &h5t_tri_ref_elem; break; default: - return h5_error_internal (f, __FILE__, __func__, __LINE__); + H5_CORE_API_LEAVE ( + h5_error_internal (__FILE__, __func__, __LINE__)); } - TRY( h5tpriv_open_mesh_group (f, type_id, id) ); + TRY (h5tpriv_open_mesh_group (f, type_id, id)); if (id != t->num_meshes) { /* open existing */ - TRY( h5tpriv_read_mesh (f) ); + TRY (h5tpriv_read_mesh (f)); } else { /* append new */ t->num_meshes++; @@ -492,67 +472,70 @@ h5t_open_mesh ( t->num_leaf_levels = 0; } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } static h5_err_t release_elems ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; - TRY( h5_free (f, t->loc_elems.data) ); + TRY( h5_free (t->loc_elems.data) ); t->loc_elems.data = NULL; - TRY( h5_free (f, t->num_elems) ); + TRY( h5_free (t->num_elems) ); t->num_elems = NULL; - TRY( h5_free (f, t->num_elems_on_leaf_level) ); + TRY( h5_free (t->num_elems_on_leaf_level) ); t->num_elems_on_leaf_level = NULL; - TRY( h5_free (f, t->map_elem_g2l.items) ); + TRY( h5_free (t->map_elem_g2l.items) ); t->map_elem_g2l.items = NULL; - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t release_vertices ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; - TRY( h5_free (f, t->vertices) ); + TRY( h5_free (t->vertices) ); t->vertices = NULL; - TRY( h5_free (f, t->num_vertices) ); + TRY( h5_free (t->num_vertices) ); t->num_vertices = NULL; - TRY( h5_free (f, t->map_vertex_g2l.items) ); + TRY( h5_free (t->map_vertex_g2l.items) ); t->map_vertex_g2l.items = NULL; - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t release_memory ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); TRY( h5tpriv_release_tags (f) ); TRY( h5tpriv_release_adjacency_structs (f) ); TRY( release_elems (f) ); TRY( release_vertices (f) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } h5_err_t h5t_close_mesh ( h5_file_t* const f ) { - h5_debug (f, "%s ()", __func__); + H5_CORE_API_ENTER (h5_err_t); if (!(f->mode & H5_O_RDONLY)) { - TRY( h5tpriv_write_mesh (f) ); + TRY (h5tpriv_write_mesh (f)); } - TRY( h5priv_close_hdf5_group (f, f->t->mesh_gid) ); - TRY( h5priv_close_hdf5_group (f, f->t->meshes_gid) ); - TRY( h5priv_close_hdf5_group (f, f->t->topo_gid) ); + TRY (hdf5_close_group (f->t->mesh_gid)); + TRY (hdf5_close_group (f->t->meshes_gid)); + TRY (hdf5_close_group (f->t->topo_gid)); - TRY( release_memory (f) ); - TRY( init_fdata (f) ); - return H5_SUCCESS; + TRY (release_memory (f)); + TRY (init_fdata (f)); + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -560,18 +543,19 @@ h5t_set_level ( h5_file_t* const f, const h5t_lvl_idx_t level_id ) { + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; if ((level_id < 0) || (level_id >= t->num_leaf_levels)) - return HANDLE_H5_OUT_OF_RANGE_ERR (f, "Level", level_id); + H5_CORE_API_LEAVE (HANDLE_H5_OUT_OF_RANGE_ERR ("Level", level_id)); h5t_lvl_idx_t prev_level = t->leaf_level; t->leaf_level = level_id; if (level_id >= t->num_loaded_levels) { - TRY( (h5tpriv_update_adjacency_structs)(f, prev_level+1) ); + TRY (h5tpriv_update_adjacency_structs (f, prev_level+1)); } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } /* @@ -582,13 +566,12 @@ h5tpriv_alloc_num_vertices ( h5_file_t* const f, const h5_size_t num ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; - ssize_t size = num * sizeof (t->vertices[0]); - TRY( t->vertices = h5_alloc (f, t->vertices, size) ); - TRY( h5priv_alloc_idxmap (f, &t->map_vertex_g2l, num) ); - - return H5_SUCCESS; + TRY (t->vertices = h5_alloc (t->vertices, size)); + TRY (h5priv_alloc_idxmap (f, &t->map_vertex_g2l, num)); + H5_CORE_API_RETURN (H5_SUCCESS); } /*! @@ -605,9 +588,8 @@ h5_err_t h5tpriv_close_file ( h5_file_t* const f /*!< IN: file handle */ ) { - h5_debug (f, "%s ()", __func__); - TRY( h5t_close_mesh (f) ); - TRY( h5priv_close_hdf5_group (f, f->t->meshes_gid) ); - - return H5_SUCCESS; + H5_PRIV_API_ENTER (h5_err_t); + TRY (h5t_close_mesh (f)); + TRY (hdf5_close_group (f->t->meshes_gid)); + H5_CORE_API_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5t_readwrite.c b/src/h5core/h5t_readwrite.c index ffb28af..9cf6238 100644 --- a/src/h5core/h5t_readwrite.c +++ b/src/h5core/h5t_readwrite.c @@ -23,10 +23,10 @@ static h5_err_t write_vertices ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t *t = f->t; - assert (t->num_leaf_levels > 0); - + t->dsinfo_vertices.dims[0] = t->num_vertices[t->num_leaf_levels-1]; TRY( h5priv_write_dataset_by_name ( f, @@ -43,13 +43,14 @@ write_vertices ( open_space_all, t->num_vertices) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t write_elems ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; assert (t->num_leaf_levels > 0); @@ -83,29 +84,30 @@ write_elems ( open_space_all, t->num_elems_on_leaf_level) ); // release mem - TRY( h5_free (f, t->glb_elems.data) ); + TRY( h5_free (t->glb_elems.data) ); t->glb_elems.tets = NULL; - return H5_SUCCESS; + + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } h5_err_t h5tpriv_write_mesh ( h5_file_t* const f ) { - h5_debug (f, "%s ()", __func__); + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; if (t->mesh_changed) { - TRY( write_vertices (f) ); - TRY( write_elems (f) ); + TRY (write_vertices (f)); + TRY (write_elems (f)); } if (t->mtags.changed) { - TRY( h5tpriv_write_mtags (f) ); + TRY (h5tpriv_write_mtags (f)); } - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } -static h5_size_t +static h5_ssize_t read_num_leaf_levels ( h5_file_t* const f ) { @@ -114,16 +116,17 @@ read_num_leaf_levels ( hid_t diskspace_id; hssize_t size; + H5_PRIV_FUNC_ENTER (h5_ssize_t); if (t->cur_mesh < 0) { - return h5tpriv_error_undef_mesh (f); + return h5tpriv_error_undef_mesh (); } - TRY( dataset_id = h5priv_open_hdf5_dataset (f, t->mesh_gid, "NumVertices") ); - TRY( diskspace_id = h5priv_get_hdf5_dataset_space (f, dataset_id) ); - TRY( size = h5priv_get_npoints_of_hdf5_dataspace (f, diskspace_id) ); - TRY( h5priv_close_hdf5_dataspace (f, diskspace_id) ); + TRY (dataset_id = hdf5_open_dataset (t->mesh_gid, "NumVertices") ); + TRY (diskspace_id = hdf5_get_dataset_space (dataset_id) ); + TRY (size = hdf5_get_npoints_of_dataspace (diskspace_id) ); + TRY (hdf5_close_dataspace (diskspace_id) ); t->num_leaf_levels = size; - return size; + H5_PRIV_FUNC_RETURN (size); } @@ -147,17 +150,19 @@ open_file_space_vertices ( return H5S_ALL; } -static h5_err_t +static inline h5_err_t read_num_vertices ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; if (t->mesh_gid < 0) { - return h5_error_internal (f, __FILE__, __func__, __LINE__); + H5_PRIV_FUNC_LEAVE ( + h5_error_internal (__FILE__, __func__, __LINE__)); } ssize_t num_bytes = t->num_leaf_levels*sizeof (t->num_vertices[0]); - TRY( t->num_vertices = h5_alloc (f, t->num_vertices, num_bytes) ); + TRY( t->num_vertices = h5_alloc (t->num_vertices, num_bytes) ); TRY( h5priv_read_dataset_by_name ( f, t->mesh_gid, @@ -166,13 +171,14 @@ read_num_vertices ( open_space_all, t->num_vertices) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t read_vertices ( h5_file_t * f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; TRY( h5tpriv_alloc_num_vertices (f, t->num_vertices[t->num_leaf_levels-1]) ); @@ -184,7 +190,7 @@ read_vertices ( open_file_space_vertices, t->vertices) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static hid_t @@ -211,11 +217,12 @@ static h5_err_t read_elems ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; size_t size = t->num_leaf_levels * sizeof (t->num_elems[0]); - TRY( t->num_elems = h5_calloc (f, 1, size) ); - TRY( t->num_elems_on_leaf_level = h5_calloc (f, 1, size) ); + TRY( t->num_elems = h5_calloc (1, size) ); + TRY( t->num_elems_on_leaf_level = h5_calloc (1, size) ); TRY( h5priv_read_dataset_by_name ( f, t->mesh_gid, @@ -242,46 +249,49 @@ read_elems ( open_mem_space_elems, open_file_space_elems, t->glb_elems.data) ); - return H5_SUCCESS; + + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } -static h5_err_t +static inline h5_err_t read_mtags ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; h5_err_t exists; - TRY( exists = h5priv_hdf5_link_exists (f, t->mesh_gid, "Tags") ); + TRY (exists = hdf5_link_exists (t->mesh_gid, "Tags")); if (exists) { - TRY( t->mtags.group_id = h5priv_open_group (f, t->mesh_gid, "Tags") ); - TRY( h5tpriv_read_tag_container (f, &f->t->mtags) ); + TRY (t->mtags.group_id = h5priv_open_group (f, t->mesh_gid, "Tags") ); + TRY (h5tpriv_read_tag_container (f, &f->t->mtags) ); } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } h5_err_t h5tpriv_read_mesh ( h5_file_t* const f ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; if (t->mesh_gid < 0) { - return h5_error_internal (f, __FILE__, __func__, __LINE__); + H5_PRIV_API_LEAVE (h5_error_internal (__FILE__, __func__, __LINE__)); } - TRY( read_num_leaf_levels (f) ); - TRY( read_num_vertices (f) ); + TRY (read_num_leaf_levels (f)); + TRY (read_num_vertices (f)); - TRY( read_vertices (f) ); - TRY( h5tpriv_rebuild_vertex_indices_mapping (f) ); + TRY (read_vertices (f)); + TRY (h5tpriv_rebuild_vertex_indices_mapping (f)); - TRY( read_elems (f) ); + TRY (read_elems (f)); - TRY( h5tpriv_init_glb2loc_elem_map (f) ); - TRY( h5tpriv_init_loc_elems_struct (f, 0) ); - TRY( h5_free (f, t->glb_elems.data) ); - TRY( h5tpriv_update_adjacency_structs (f, 0) ); - TRY( h5tpriv_init_geom_boundary_info (f, 0) ); + TRY (h5tpriv_init_glb2loc_elem_map (f)); + TRY (h5tpriv_init_loc_elems_struct (f, 0)); + TRY (h5_free (t->glb_elems.data)); + TRY (h5tpriv_update_adjacency_structs (f, 0)); + TRY (h5tpriv_init_geom_boundary_info (f, 0)); - TRY( read_mtags (f) ); + TRY (read_mtags (f)); t->num_loaded_levels = t->num_leaf_levels; - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5t_readwrite_tetm.c b/src/h5core/h5t_readwrite_tetm.c index a7e7af0..87b3d0d 100644 --- a/src/h5core/h5t_readwrite_tetm.c +++ b/src/h5core/h5t_readwrite_tetm.c @@ -10,6 +10,7 @@ init_loc_elems_struct ( h5_file_t* const f, const h5t_lvl_idx_t from_lvl ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; h5_loc_idx_t elem_idx = 0; const h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; @@ -59,7 +60,7 @@ init_loc_elems_struct ( num_facets, loc_elem->neighbor_indices) ); } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t @@ -67,6 +68,7 @@ init_geom_boundary_info ( h5_file_t* const f, const h5t_lvl_idx_t from_lvl ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; h5_loc_idx_t elem_idx = 0; const h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; @@ -88,7 +90,7 @@ init_geom_boundary_info ( continue; // no facet on boundary } } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -99,26 +101,27 @@ alloc_glb_elems_struct ( h5_file_t* const f, h5_loc_idx_t num_elems ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; - TRY ( t->glb_elems.tets = h5_calloc ( - f, - num_elems, - sizeof(t->glb_elems.tets[0]) ) ); + TRY (t->glb_elems.tets = h5_calloc ( + num_elems, + sizeof(t->glb_elems.tets[0]) ) ); memset ( t->glb_elems.tets, -1, (num_elems) * sizeof(t->glb_elems.tets[0]) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t init_glb2loc_elem_map ( h5_file_t* const f ) { - h5_debug (f, "%s()", __func__); + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; - if (t->num_leaf_levels <= 0) return H5_SUCCESS; + if (t->num_leaf_levels <= 0) + H5_PRIV_FUNC_LEAVE (H5_SUCCESS); h5_loc_idx_t loc_idx = 0; h5_loc_idx_t num_loc_elems = t->num_elems[t->num_leaf_levels-1]; @@ -132,7 +135,7 @@ init_glb2loc_elem_map ( } h5priv_sort_idxmap (&t->map_elem_g2l); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -142,6 +145,7 @@ static h5_err_t init_glb_elems_struct ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; @@ -162,7 +166,7 @@ init_glb_elems_struct ( loc_elem++; glb_elem++; } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5t_readwrite_trim.c b/src/h5core/h5t_readwrite_trim.c index 1427b1c..119181b 100644 --- a/src/h5core/h5t_readwrite_trim.c +++ b/src/h5core/h5t_readwrite_trim.c @@ -10,6 +10,7 @@ init_loc_elems_struct ( h5_file_t* const f, const h5t_lvl_idx_t from_lvl ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; h5_loc_idx_t elem_idx = 0; const h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; @@ -60,7 +61,7 @@ init_loc_elems_struct ( loc_elem->neighbor_indices) ); } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t @@ -68,6 +69,7 @@ init_geom_boundary_info ( h5_file_t* const f, const h5t_lvl_idx_t from_lvl ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; h5_loc_idx_t elem_idx = 0; const h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; @@ -89,7 +91,7 @@ init_geom_boundary_info ( continue; // no facet on boundary } } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -100,27 +102,28 @@ alloc_glb_elems_struct ( h5_file_t* const f, h5_loc_idx_t num_elems ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; TRY ( t->glb_elems.tris = h5_calloc ( - f, num_elems, sizeof(t->glb_elems.tris[0]) ) ); memset ( t->glb_elems.tris, -1, (num_elems) * sizeof(t->glb_elems.tris[0]) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t init_glb2loc_elem_map ( h5_file_t* const f ) { - h5_debug (f, "%s()", __func__); + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; - if (t->num_leaf_levels <= 0) return H5_SUCCESS; + if (t->num_leaf_levels <= 0) + H5_PRIV_FUNC_LEAVE (H5_SUCCESS); h5_loc_idx_t loc_idx = 0; h5_loc_idx_t num_loc_elems = t->num_elems[t->num_leaf_levels-1]; @@ -134,7 +137,7 @@ init_glb2loc_elem_map ( } h5priv_sort_idxmap (&t->map_elem_g2l); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -144,6 +147,7 @@ static h5_err_t init_glb_elems_struct ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; @@ -164,7 +168,7 @@ init_glb_elems_struct ( loc_elem++; glb_elem++; } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } struct h5t_read_methods h5tpriv_read_trim_methods = { diff --git a/src/h5core/h5t_retrieve.c b/src/h5core/h5t_retrieve.c index 4c6f88c..a432daa 100644 --- a/src/h5core/h5t_retrieve.c +++ b/src/h5core/h5t_retrieve.c @@ -29,7 +29,7 @@ iterate_leaf_elems ( ) { h5t_leaf_iterator_t* it = (h5t_leaf_iterator_t*)&iter->leaf; if ( iter_leaf_elem_idx (f, it) == H5_NOK) { - h5_debug ( f, "Traversing done!" ); + h5_debug ("Traversing done!"); return H5_NOK; } int dim = h5tpriv_ref_elem_get_dim (it); @@ -45,7 +45,7 @@ iterate_boundary_elems ( h5t_leaf_iterator_t* it = (h5t_leaf_iterator_t*)&iter->leaf; do { if ( iter_leaf_elem_idx (f, it) == H5_NOK) { - h5_debug ( f, "Traversing done!" ); + h5_debug ("Traversing done!"); return H5_NOK; } } while (!h5tpriv_is_boundary_elem (f, it->elem_idx)); @@ -64,6 +64,7 @@ iterate_boundary_facets ( h5_file_t* const f, h5t_iterator_t* iter ) { + H5_PRIV_FUNC_ENTER (h5_loc_id_t); h5t_leaf_iterator_t* it = (h5t_leaf_iterator_t*)&iter->leaf; int num_facets = h5tpriv_ref_elem_get_num_facets (it) - 1; int dim = h5tpriv_ref_elem_get_dim (it) - it->codim; @@ -72,7 +73,7 @@ iterate_boundary_facets ( h5_loc_id_t elem_id; TRY( elem_id = iterate_boundary_elems (f, iter) ); if (elem_id == H5_NOK) { - return H5_NOK; // done! + H5_PRIV_FUNC_LEAVE (H5_NOK); // done! } it->elem_idx = h5tpriv_get_elem_idx (elem_id); it->face_idx = 0; @@ -81,7 +82,7 @@ iterate_boundary_facets ( } } while (! h5tpriv_is_boundary_facet (f, it->elem_idx, it->face_idx)); int type = h5tpriv_ref_elem_get_entity_type (it, dim); - return h5tpriv_build_entity_id (type, it->face_idx, it->elem_idx ); + H5_PRIV_FUNC_RETURN (h5tpriv_build_entity_id (type, it->face_idx, it->elem_idx)); } /*! @@ -92,6 +93,7 @@ iterate_leaf_faces ( h5_file_t* const f, h5t_iterator_t* iter ) { + H5_PRIV_FUNC_ENTER (h5_loc_id_t); h5t_leaf_iterator_t* it = (h5t_leaf_iterator_t*)iter; h5_loc_idlist_t* entry; int dim = h5tpriv_ref_elem_get_dim (it) - it->codim; @@ -100,8 +102,8 @@ iterate_leaf_faces ( do { if (it->face_idx >= num_faces) { if (iter_leaf_elem_idx (f, it) == H5_NOK) { - h5_debug (f, "Traversing done!"); - return H5_NOK; + h5_debug ("Traversing done!"); + H5_PRIV_FUNC_LEAVE (H5_NOK); // done! } it->face_idx = 0; } else { @@ -130,17 +132,18 @@ iterate_leaf_faces ( current level and the element index of entry->items[i] is the smallest element index with the given face on the current level. */ - return entry->items[i]; + H5_PRIV_FUNC_RETURN (entry->items[i]); } /* - Iterate boundary faces + Iterate boundary faces with co-dim > 1 */ static h5_loc_id_t iterate_boundary_faces ( h5_file_t* const f, h5t_iterator_t* iter ) { + H5_PRIV_FUNC_ENTER (h5_loc_id_t); h5t_leaf_iterator_t* it = (h5t_leaf_iterator_t*)iter; // TODO!!! int dim = h5tpriv_ref_elem_get_dim (it) - it->codim; @@ -154,7 +157,7 @@ iterate_boundary_faces ( h5_loc_id_t elem_id; TRY( elem_id = iterate_boundary_elems (f, iter) ); if (elem_id == H5_NOK) { - return H5_NOK; // done! + H5_PRIV_FUNC_LEAVE (H5_NOK); // done! } it->face_idx = 0; } else { @@ -164,7 +167,7 @@ iterate_boundary_faces ( f, dim, it->elem_idx, it->face_idx)); // Skip already visited faces } while (0); - return h5_error_internal (f, __FILE__, __func__, __LINE__); + H5_PRIV_FUNC_RETURN (h5_error_internal (__FILE__, __func__, __LINE__)); } static h5_loc_id_t @@ -172,6 +175,7 @@ iterate_tags ( h5_file_t* const f, h5t_iterator_t* iter ) { + H5_PRIV_FUNC_ENTER (h5_loc_id_t); UNUSED_ARGUMENT (f); #if 0 h5t_tagsel_t* tags; @@ -184,8 +188,8 @@ iterate_tags ( } tags = iter->tagset->elems[iter->elem_idx]; } while ((tags == NULL) || (tags->idx[iter->subentity_idx])); -#endif - return 0; +#endif + H5_PRIV_FUNC_RETURN (h5_error_internal (__FILE__, __func__, __LINE__)); } h5_err_t @@ -194,8 +198,7 @@ h5t_init_leaf_iterator ( h5t_iterator_t* iter, int codim ) { - H5_CORE_API_ENTER; - h5_err_t h5err = H5_SUCCESS; + H5_CORE_API_ENTER (h5_err_t); h5t_leaf_iterator_t* it = (h5t_leaf_iterator_t*)&iter->leaf; it->face_idx = 999; it->elem_idx = -1; @@ -208,8 +211,8 @@ h5t_init_leaf_iterator ( } else if (it->codim == 0) { it->iter = iterate_leaf_elems; } - TRY2( h5tpriv_init_entity_iterator (f, iter, codim) ); - H5_CORE_API_RETURN (h5err); + TRY (h5tpriv_init_entity_iterator (f, iter, codim)); + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -218,8 +221,7 @@ h5t_init_boundary_face_iterator ( h5t_iterator_t* iter, int codim ) { - H5_CORE_API_ENTER; - h5_err_t h5err = H5_SUCCESS; + H5_CORE_API_ENTER (h5_err_t); h5t_leaf_iterator_t* it = (h5t_leaf_iterator_t*)iter; it->face_idx = 999; // something > max number of faces it->elem_idx = -1; @@ -228,14 +230,14 @@ h5t_init_boundary_face_iterator ( it->ref_elem = f->t->ref_elem; if (it->codim <= 0 || it->codim > it->ref_elem->dim) { - return h5tpriv_inval_codim (f, codim, 1, it->ref_elem->dim); + H5_CORE_API_LEAVE (h5tpriv_inval_codim (f, codim, 1, it->ref_elem->dim)); } else if (it->codim == 1) { it->iter = iterate_boundary_facets; } else if (it->codim > 1) { it->iter = iterate_boundary_faces; } - H5_CORE_API_RETURN (h5err); + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -244,16 +246,14 @@ h5t_init_mtag_iterator ( h5t_iterator_t* iter, const char* name ) { - H5_CORE_API_ENTER; - h5_err_t h5err = H5_SUCCESS; + H5_CORE_API_ENTER (h5_err_t); h5t_tag_iterator_t* it = (h5t_tag_iterator_t*)iter; - TRY2( h5err = h5t_open_mtagset (f, name, &it->tagset) ); + TRY (h5t_open_mtagset (f, name, &it->tagset)); it->elem_idx = -1; it->subentity_idx = 999; it->level_idx = f->t->leaf_level; it->iter = iterate_tags; - h5err = H5_SUCCESS; - H5_CORE_API_RETURN (h5err); + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -261,9 +261,8 @@ h5t_release_entity_iterator ( h5_file_t* const f, h5t_iterator_t* iter ) { - H5_CORE_API_ENTER; - h5_err_t h5err = h5_free (f, iter); - H5_CORE_API_RETURN (h5err); + H5_CORE_API_ENTER (h5_err_t); + H5_CORE_API_RETURN (h5_free (iter)); } h5_loc_id_t @@ -271,10 +270,9 @@ h5t_iterate_entities ( h5_file_t* const f, h5t_iterator_t* iter ) { - H5_CORE_API_ENTER; + H5_CORE_API_ENTER (h5_loc_id_t); h5t_generic_iterator_t* it = (h5t_generic_iterator_t*)iter; - h5_err_t h5err = it->iter (f, iter); - H5_CORE_API_RETURN (h5err); + H5_CORE_API_RETURN (it->iter (f, iter)); } h5_err_t @@ -283,14 +281,13 @@ h5t_end_iterate_entities ( h5t_iterator_t* iter ) { UNUSED_ARGUMENT (f); - H5_CORE_API_ENTER; - h5_err_t h5err = H5_SUCCESS; + H5_CORE_API_ENTER (h5_err_t); bzero (iter, sizeof(*iter)); h5t_leaf_iterator_t* it = (h5t_leaf_iterator_t*)iter; it->face_idx = -1; it->elem_idx = -1; it->codim = -1; - H5_CORE_API_RETURN (h5err); + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -299,11 +296,10 @@ h5t_get_vertex_coords_by_index ( h5_loc_idx_t vertex_index, h5_float64_t P[3] ) { - H5_CORE_API_ENTER; - h5_err_t h5err = H5_SUCCESS; + H5_CORE_API_ENTER (h5_err_t); h5_loc_vertex_t *vertex = &f->t->vertices[vertex_index]; memcpy ( P, &vertex->P, sizeof ( vertex->P ) ); - H5_CORE_API_RETURN (h5err); + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -312,11 +308,10 @@ h5t_get_vertex_coords_by_id ( h5_loc_id_t vertex_id, h5_float64_t P[3] ) { - H5_CORE_API_ENTER; - h5_err_t h5err = H5_SUCCESS; + H5_CORE_API_ENTER (h5_err_t); h5_loc_idx_t vertex_index; - TRY2( h5err = h5t_get_vertex_index_of_vertex (f, vertex_id, &vertex_index) ); - TRY2( h5t_get_vertex_coords_by_index (f, vertex_index, P) ); - H5_CORE_API_RETURN (h5err); + TRY (h5t_get_vertex_index_of_vertex (f, vertex_id, &vertex_index)); + TRY (h5t_get_vertex_coords_by_index (f, vertex_index, P)); + H5_CORE_API_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5t_retrieve_tetm.c b/src/h5core/h5t_retrieve_tetm.c index aed1106..e9dfb87 100644 --- a/src/h5core/h5t_retrieve_tetm.c +++ b/src/h5core/h5t_retrieve_tetm.c @@ -24,7 +24,7 @@ begin_iterate_entities ( it->find = NULL; break; default: - return h5_error_internal (f, __FILE__, __func__, __LINE__); + return h5_error_internal (__FILE__, __func__, __LINE__); } return H5_SUCCESS; } diff --git a/src/h5core/h5t_retrieve_trim.c b/src/h5core/h5t_retrieve_trim.c index 29470ff..9a6503e 100644 --- a/src/h5core/h5t_retrieve_trim.c +++ b/src/h5core/h5t_retrieve_trim.c @@ -21,7 +21,7 @@ begin_iterate_entities ( it->find = NULL; break; default: - return h5_error_internal (f, __FILE__, __func__, __LINE__); + return h5_error_internal (__FILE__, __func__, __LINE__); } return H5_SUCCESS; } diff --git a/src/h5core/h5t_store.c b/src/h5core/h5t_store.c index 6076684..c8f8140 100644 --- a/src/h5core/h5t_store.c +++ b/src/h5core/h5t_store.c @@ -13,14 +13,12 @@ h5t_add_mesh ( h5_file_t* const f, const h5_oid_t mesh_type ) { + H5_CORE_API_ENTER (h5_id_t); h5_id_t mesh_id = 0; - - TRY( (mesh_id = h5t_open_mesh (f, -1, mesh_type)) ); - TRY( h5t_add_level (f) ); - + TRY (mesh_id = h5t_open_mesh (f, -1, mesh_type)); + TRY (h5t_add_level (f)); f->t->mesh_changed = 1; - - return mesh_id; + H5_CORE_API_RETURN (mesh_id); } /* @@ -78,15 +76,16 @@ h5t_lvl_idx_t h5t_add_level ( h5_file_t* const f ) { + H5_CORE_API_ENTER (h5t_lvl_idx_t); h5t_fdata_t* const t = f->t; if (f->mode == H5_O_RDONLY) { - return H5_ERR_INVAL; + H5_CORE_API_LEAVE (h5priv_handle_file_mode_error(f->mode)); } /* t->num_leaf_levels will be set to zero on file creation(!) */ if ((t->cur_mesh < 0) || (t->num_leaf_levels == -1)) { - return h5tpriv_error_undef_mesh (f); + H5_CORE_API_LEAVE (h5tpriv_error_undef_mesh ()); } t->leaf_level = t->num_leaf_levels++; t->num_loaded_levels = t->num_leaf_levels; @@ -95,13 +94,13 @@ h5t_add_level ( t->dsinfo_num_elems_on_leaf_level.dims[0] = t->num_leaf_levels; ssize_t num_bytes = t->num_leaf_levels*sizeof (h5_size_t); - TRY( t->num_vertices = h5_alloc (f, t->num_vertices, num_bytes) ); + TRY (t->num_vertices = h5_alloc (t->num_vertices, num_bytes)); t->num_vertices[t->leaf_level] = -1; - TRY( t->num_elems = h5_alloc (f, t->num_elems, num_bytes) ); + TRY (t->num_elems = h5_alloc (t->num_elems, num_bytes)); t->num_elems[t->leaf_level] = -1; - TRY( t->num_elems_on_leaf_level = h5_alloc ( - f, t->num_elems_on_leaf_level, num_bytes) ); + TRY ( t->num_elems_on_leaf_level = h5_alloc ( + t->num_elems_on_leaf_level, num_bytes)); t->num_elems_on_leaf_level[t->leaf_level] = -1; if (t->leaf_level == 0) { @@ -110,7 +109,7 @@ h5t_add_level ( t->last_stored_eid = -1; } - return t->leaf_level; + H5_CORE_API_RETURN (t->leaf_level); } /*! @@ -121,16 +120,17 @@ h5t_begin_store_vertices ( h5_file_t* const f, const h5_size_t num ) { + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; if (t->leaf_level < 0) { - return h5tpriv_error_undef_level(f); + H5_CORE_API_LEAVE (h5tpriv_error_undef_level()); } h5_size_t cur_num_vertices = (t->leaf_level > 0 ? t->num_vertices[t->leaf_level-1] : 0); t->num_vertices[t->leaf_level] = cur_num_vertices+num; t->dsinfo_vertices.dims[0] = cur_num_vertices+num; - return h5tpriv_alloc_num_vertices (f, cur_num_vertices+num); + H5_CORE_API_RETURN (h5tpriv_alloc_num_vertices (f, cur_num_vertices+num)); } h5_loc_idx_t @@ -139,38 +139,40 @@ h5t_store_vertex ( const h5_glb_idx_t glb_id, /*!< global vertex id from mesher or -1 */ const h5_float64_t P[3] /*!< coordinates */ ) { + H5_CORE_API_ENTER (h5_loc_idx_t); h5t_fdata_t* const t = f->t; /* more than allocated */ if (t->last_stored_vid+1 >= t->num_vertices[t->leaf_level]) - return HANDLE_H5_OVERFLOW_ERR( - f, "vertex", t->num_vertices[t->leaf_level]); + H5_CORE_API_LEAVE (HANDLE_H5_OVERFLOW_ERR( + "vertex", t->num_vertices[t->leaf_level])); /* missing call to add the first level */ if (t->leaf_level < 0) - return h5tpriv_error_undef_level(f); + H5_CORE_API_LEAVE (h5tpriv_error_undef_level()); h5_loc_idx_t local_idx = ++t->last_stored_vid; h5_loc_vertex_t *vertex = &t->vertices[local_idx]; vertex->idx = glb_id; /* ID from mesher, replaced later!*/ memcpy (&vertex->P, P, sizeof (vertex->P)); - return local_idx; + H5_CORE_API_RETURN (local_idx); } h5_err_t h5t_end_store_vertices ( h5_file_t* const f ) { + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; t->num_vertices[t->leaf_level] = t->last_stored_vid+1; - TRY( assign_global_vertex_indices (f) ); - TRY( h5tpriv_rebuild_vertex_indices_mapping (f) ); - return H5_SUCCESS; + TRY (assign_global_vertex_indices (f)); + TRY (h5tpriv_rebuild_vertex_indices_mapping (f)); + H5_CORE_API_RETURN (H5_SUCCESS); } /*! @@ -184,6 +186,7 @@ h5t_begin_store_elems ( h5_file_t* const f, const h5_size_t num ) { + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; size_t cur = t->leaf_level > 0 ? t->num_elems[t->leaf_level-1] : 0; @@ -198,8 +201,8 @@ h5t_begin_store_elems ( avoid resizing. */ size_t nel = 2097152 > 5*new ? 2097152 : 5*new; - TRY( h5tpriv_resize_te_htab (f, nel) ); - return h5tpriv_alloc_elems (f, cur, new); + TRY (h5tpriv_resize_te_htab (f, nel)); + H5_CORE_API_RETURN (h5tpriv_alloc_elems (f, cur, new)); } @@ -218,17 +221,20 @@ h5t_store_elem ( const h5_loc_idx_t parent_idx, const h5_loc_idx_t* vertex_indices ) { + H5_CORE_API_ENTER (h5_loc_idx_t); h5t_fdata_t* t = f->t; /* level set? */ if (t->leaf_level < 0) - return h5tpriv_error_undef_level(f); + H5_CORE_API_LEAVE ( + h5tpriv_error_undef_level()); /* more than allocated? */ if ( t->last_stored_eid+1 >= t->num_elems[t->leaf_level] ) - return HANDLE_H5_OVERFLOW_ERR( - f, h5tpriv_map_oid2str(t->mesh_type), - t->num_elems[t->leaf_level] ); + H5_CORE_API_LEAVE ( + HANDLE_H5_OVERFLOW_ERR( + h5tpriv_map_oid2str(t->mesh_type), + t->num_elems[t->leaf_level])); /* check parent id */ if ((t->leaf_level == 0 && parent_idx != -1) || @@ -236,8 +242,9 @@ h5t_store_elem ( (t->leaf_level > 0 && parent_idx >= t->num_elems[t->leaf_level-1]) ) { - return HANDLE_H5_PARENT_ID_ERR ( - f, h5tpriv_map_oid2str (t->mesh_type), parent_idx); + H5_CORE_API_LEAVE ( + HANDLE_H5_PARENT_ID_ERR ( + h5tpriv_map_oid2str (t->mesh_type), parent_idx)); } /* store elem data (but neighbors) */ @@ -259,31 +266,30 @@ h5t_store_elem ( int num_faces = h5tpriv_ref_elem_get_num_edges (t); for (face_idx = 0; face_idx < num_faces; face_idx++) { // add edges to neighbour struct - TRY( h5tpriv_search_te2 (f, face_idx, elem_idx, NULL) ); + TRY (h5tpriv_search_te2 (f, face_idx, elem_idx, NULL)); } - return elem_idx; + H5_CORE_API_RETURN (elem_idx); } h5_err_t h5t_end_store_elems ( h5_file_t* const f ) { - h5_debug (f, "%s ()", __func__); + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; t->num_elems[t->leaf_level] = t->last_stored_eid+1; /* assign global indices to new indices */ - TRY( assign_glb_elem_indices (f) ); + TRY (assign_glb_elem_indices (f)); /* rebuild map: global index -> local_index */ - TRY( h5tpriv_rebuild_elem_indices_mapping (f) ); + TRY (h5tpriv_rebuild_elem_indices_mapping (f)); /* mesh specific finalize */ - TRY( (t->methods.store->end_store_elems)(f) ); + TRY (t->methods.store->end_store_elems (f)); - h5_debug (f, "%s (): done", __func__); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } /* @@ -294,8 +300,9 @@ h5t_mark_entity ( h5_file_t* const f, const h5_loc_id_t entity_id ) { + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; - return h5priv_insert_idlist (f, &t->marked_entities, entity_id, -1); + H5_CORE_API_RETURN (h5priv_insert_idlist (f, &t->marked_entities, entity_id, -1)); } /* @@ -323,6 +330,7 @@ h5_err_t h5t_pre_refine ( h5_file_t* const f ) { + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; unsigned int num_elems_to_refine = t->marked_entities->num_items; unsigned int num_elems_to_add = 0; @@ -338,12 +346,12 @@ h5t_pre_refine ( num_elems_to_add = num_elems_to_refine*4; break; default: - return h5_error_internal (f, __FILE__, __func__, __LINE__); + H5_CORE_API_LEAVE (h5_error_internal (__FILE__, __func__, __LINE__)); } - TRY( h5t_begin_store_vertices (f, num_vertices_to_add) ); - TRY( h5t_begin_store_elems (f, num_elems_to_add) ); + TRY (h5t_begin_store_vertices (f, num_vertices_to_add)); + TRY (h5t_begin_store_elems (f, num_elems_to_add)); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } /* @@ -353,22 +361,24 @@ h5_err_t h5t_refine_marked_elems ( h5_file_t* const f ) { + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; int i; for (i = 0; i < t->marked_entities->num_items; i++) { - TRY( h5tpriv_refine_elem (f, t->marked_entities->items[i]) ); + TRY (h5tpriv_refine_elem (f, t->marked_entities->items[i])); } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t h5t_post_refine ( h5_file_t* const f ) { + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; - TRY( h5t_end_store_vertices (f) ); - TRY( h5t_end_store_elems (f) ); - return h5priv_free_idlist (f, &t->marked_entities); + TRY (h5t_end_store_vertices (f)); + TRY (h5t_end_store_elems (f)); + H5_CORE_API_RETURN (h5priv_free_idlist (f, &t->marked_entities)); } @@ -376,14 +386,15 @@ h5_err_t h5t_begin_refine_elems ( h5_file_t* const f ) { + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; /* Pre-allocate space for items to avoid allocating small pieces of memory. */ - TRY( h5priv_alloc_idlist (f, &t->marked_entities, 2048) ); - return H5_SUCCESS; + TRY (h5priv_alloc_idlist (f, &t->marked_entities, 2048)); + H5_CORE_API_RETURN (H5_SUCCESS); } @@ -391,30 +402,31 @@ h5_err_t h5t_end_refine_elems ( h5_file_t* const f ) { - TRY( h5t_pre_refine (f) ); - TRY( h5t_refine_marked_elems (f) ); - TRY( h5t_post_refine (f) ); - - return H5_SUCCESS; + H5_CORE_API_ENTER (h5_err_t); + TRY (h5t_pre_refine (f)); + TRY (h5t_refine_marked_elems (f)); + TRY (h5t_post_refine (f)); + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t h5t_create_index_set ( h5_file_t* const f ) { + H5_CORE_API_ENTER (h5_err_t); int codim; int dim = h5tpriv_ref_elem_get_dim (f->t); // todo: check tagset already exist - TRY( h5t_add_mtagset (f, "__IndexSet__", H5_INT64_T) ); + TRY (h5t_add_mtagset (f, "__IndexSet__", H5_INT64_T)); for (codim = 0; codim <= dim; codim++) { h5_glb_idx_t idx = 0; h5t_leaf_iterator_t it; h5_glb_id_t entity_id; - TRY( h5t_init_leaf_iterator (f, (h5t_iterator_t*)&it, codim) ); + TRY (h5t_init_leaf_iterator (f, (h5t_iterator_t*)&it, codim)); while ((entity_id = it.iter(f, (h5t_iterator_t*)&it)) >= 0) { - TRY( h5t_set_mtag_by_name (f, "__IndexSet__", entity_id, 1, &idx) ); + TRY (h5t_set_mtag_by_name (f, "__IndexSet__", entity_id, 1, &idx)); } } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5t_store_tetm.c b/src/h5core/h5t_store_tetm.c index ad68b29..583dfb7 100644 --- a/src/h5core/h5t_store_tetm.c +++ b/src/h5core/h5t_store_tetm.c @@ -9,11 +9,11 @@ alloc_tets ( const size_t cur, const size_t new ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t *t = f->t; /* alloc mem for local data of elements */ TRY ( t->loc_elems.tets = h5_alloc ( - f, t->loc_elems.tets, new * sizeof (t->loc_elems.tets[0]) ) ); memset ( @@ -24,7 +24,7 @@ alloc_tets ( /* alloc mem for global to local ID mapping */ TRY ( h5priv_alloc_idxmap ( f, &t->map_elem_g2l, new ) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -40,6 +40,7 @@ get_direct_children_of_edge ( h5_loc_idx_t elem_idx, h5_loc_id_t children[2] ) { + H5_PRIV_FUNC_ENTER (h5_err_t); /* Please read the note about the offsets in the corresponding file for triangle meshes. @@ -53,11 +54,12 @@ get_direct_children_of_edge ( }; h5_loc_idx_t num_faces = h5tpriv_ref_elem_get_num_edges (f->t); if ((face_idx < 0) || (face_idx >= num_faces)) { - return h5_error_internal (f, __FILE__, __func__, __LINE__); + H5_PRIV_FUNC_LEAVE ( + h5_error_internal (__FILE__, __func__, __LINE__)); } children[0] = h5tpriv_build_edge_id (face_idx, elem_idx+offs[face_idx][0]); children[1] = h5tpriv_build_edge_id (face_idx, elem_idx+offs[face_idx][1]); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /*! @@ -73,6 +75,7 @@ bisect_edge ( const h5_loc_idx_t face_idx, const h5_loc_idx_t elem_idx ) { + H5_PRIV_FUNC_ENTER (h5_loc_idx_t); h5t_fdata_t* t = f->t; h5_loc_idlist_t* retval; /* @@ -102,10 +105,11 @@ bisect_edge ( kids) ); TRY( h5t_get_vertex_indices_of_edge (f, kids[0], edge0) ); TRY( h5t_get_vertex_indices_of_edge (f, kids[1], edge1) ); - if ((edge0[0] == edge1[0]) || (edge0[0] == edge1[1])) - return edge0[0]; - else - return edge0[1]; + if ((edge0[0] == edge1[0]) || (edge0[0] == edge1[1])) { + H5_PRIV_FUNC_LEAVE (edge0[0]); // return idx of first vertex of edge + } else { + H5_PRIV_FUNC_LEAVE (edge0[1]); // return idx of second vertex of edge + } } } /* @@ -121,7 +125,7 @@ bisect_edge ( P[1] = (P0[1] + P1[1]) / 2.0; P[2] = (P0[2] + P1[2]) / 2.0; - return h5t_store_vertex (f, -1, P); + H5_PRIV_FUNC_RETURN (h5t_store_vertex (f, -1, P)); // return idx of new vertex } /*! @@ -134,17 +138,18 @@ refine_tet ( h5_file_t* const f, const h5_loc_idx_t elem_idx ) { + H5_PRIV_FUNC_ENTER (h5_loc_idx_t); h5t_fdata_t* t = f->t; h5_loc_idx_t vertices[10]; h5_loc_idx_t elem_idx_of_first_child; h5_loc_tet_t* el = &t->loc_elems.tets[elem_idx]; if ( el->child_idx >= 0 ) - return h5_error ( - f, - H5_ERR_INVAL, - "Tetrahedron %lld already refined.", - (long long)elem_idx ); + H5_PRIV_FUNC_LEAVE ( + h5_error ( + H5_ERR_INVAL, + "Tetrahedron %lld already refined.", + (long long)elem_idx )); vertices[0] = el->vertex_indices[0]; vertices[1] = el->vertex_indices[1]; vertices[2] = el->vertex_indices[2]; @@ -213,7 +218,7 @@ refine_tet ( t->loc_elems.tets[elem_idx].child_idx = elem_idx_of_first_child; t->num_elems_on_leaf_level[t->leaf_level]--; - return elem_idx_of_first_child; + H5_PRIV_FUNC_RETURN (elem_idx_of_first_child); } static inline h5_loc_idx_t @@ -222,7 +227,7 @@ compute_neighbor_of_face ( h5_loc_idx_t elem_idx, const h5_loc_idx_t face_idx ) { - + H5_PRIV_FUNC_ENTER (h5_loc_idx_t); h5t_fdata_t * const t = f->t; h5_loc_idlist_t* td; h5_loc_idx_t neighbor_idx = -2; @@ -234,8 +239,9 @@ compute_neighbor_of_face ( elem_idx, &td) ); if (td == NULL) { - return h5_error_internal ( - f, __FILE__, __func__, __LINE__); + H5_PRIV_FUNC_LEAVE ( + h5_error_internal ( + __FILE__, __func__, __LINE__)); } if (td->num_items == 1) { // neighbor is coarser or face is on the boundary @@ -253,11 +259,12 @@ compute_neighbor_of_face ( } } else { - return h5_error_internal ( - f, __FILE__, __func__, __LINE__); + H5_PRIV_FUNC_LEAVE ( + h5_error_internal ( + __FILE__, __func__, __LINE__)); } } while (neighbor_idx < -1); - return neighbor_idx; + H5_PRIV_FUNC_RETURN (neighbor_idx); } /* @@ -268,11 +275,16 @@ compute_neighbors_of_elems ( h5_file_t* const f, h5t_lvl_idx_t level ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t * const t = f->t; if (level < 0 || level >= t->num_leaf_levels) { - return h5_error (f, H5_ERR_INVAL, - "level idx %lld out of bound, must be in [%lld,%lld]", - (long long)level, (long long)0, (long long)t->num_leaf_levels); + H5_PRIV_FUNC_LEAVE ( + h5_error ( + H5_ERR_INVAL, + "level idx %lld out of bound, must be in [%lld,%lld]", + (long long)level, + (long long)0, + (long long)t->num_leaf_levels)); } h5_loc_idx_t elem_idx = level == 0 ? 0 : t->num_elems[level-1]; const h5_loc_idx_t last_idx = t->num_elems[level] - 1; @@ -287,18 +299,19 @@ compute_neighbors_of_elems ( el++; } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t end_store_elems ( h5_file_t* const f ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* const t = f->t; TRY( h5tpriv_update_adjacency_structs (f, t->leaf_level) ); TRY( compute_neighbors_of_elems (f, t->leaf_level) ); TRY( h5tpriv_init_geom_boundary_info (f, t->leaf_level) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } struct h5t_store_methods h5tpriv_tetm_store_methods = { diff --git a/src/h5core/h5t_store_trim.c b/src/h5core/h5t_store_trim.c index 4ef23aa..f88025a 100644 --- a/src/h5core/h5t_store_trim.c +++ b/src/h5core/h5t_store_trim.c @@ -1,4 +1,4 @@ -#include +#include #include "h5core/h5_core.h" #include "h5_core_private.h" @@ -9,11 +9,11 @@ alloc_triangles ( const size_t cur, const size_t new ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t *t = f->t; /* alloc mem for local data of elements */ TRY ( t->loc_elems.tris = h5_alloc ( - f, t->loc_elems.tris, new * sizeof (t->loc_elems.tris[0]) ) ); memset ( @@ -24,7 +24,7 @@ alloc_triangles ( /* alloc mem for global to local ID mapping */ TRY ( h5priv_alloc_idxmap ( f, &t->map_elem_g2l, new ) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t @@ -34,6 +34,7 @@ get_direct_children_of_edge ( const h5_loc_idx_t elem_idx, h5_loc_id_t children[2] ) { + H5_PRIV_FUNC_ENTER (h5_err_t); /* Please note: The face index of the children and the father is always the same. The only think we have to know, is the offset @@ -51,11 +52,12 @@ get_direct_children_of_edge ( }; h5_loc_idx_t num_faces = h5tpriv_ref_elem_get_num_edges (f->t); if ((face_idx < 0) || (face_idx >= num_faces)) { - return h5_error_internal (f, __FILE__, __func__, __LINE__); + H5_PRIV_FUNC_LEAVE ( + h5_error_internal (__FILE__, __func__, __LINE__)); } children[0] = h5tpriv_build_edge_id (face_idx, elem_idx+off[face_idx][0]); children[1] = h5tpriv_build_edge_id (face_idx, elem_idx+off[face_idx][1]); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -67,6 +69,7 @@ bisect_edge ( const h5_loc_idx_t face_idx, const h5_loc_idx_t elem_idx ) { + H5_PRIV_FUNC_ENTER (h5_loc_idx_t); h5t_fdata_t* const t = f->t; h5_loc_idlist_t* retval; /* @@ -95,10 +98,11 @@ bisect_edge ( h5_loc_idx_t edge0[2], edge1[2]; TRY( h5t_get_vertex_indices_of_edge ( f, kids[0], edge0 ) ); TRY( h5t_get_vertex_indices_of_edge ( f, kids[1], edge1 ) ); - if ((edge0[0] == edge1[0]) || (edge0[0] == edge1[1])) - return edge0[0]; - else - return edge0[1]; + if ((edge0[0] == edge1[0]) || (edge0[0] == edge1[1])) { + H5_PRIV_FUNC_LEAVE (edge0[0]); + } else { + H5_PRIV_FUNC_LEAVE (edge0[1]); + } } } /* @@ -114,7 +118,7 @@ bisect_edge ( P[1] = (P0[1] + P1[1]) / 2.0; P[2] = (P0[2] + P1[2]) / 2.0; - return h5t_store_vertex (f, -1, P); + H5_PRIV_FUNC_RETURN (h5t_store_vertex (f, -1, P)); } /*! @@ -127,18 +131,19 @@ refine_triangle ( h5_file_t* const f, const h5_loc_idx_t elem_idx ) { + H5_PRIV_FUNC_ENTER (h5_loc_idx_t); h5t_fdata_t* const t = f->t; h5_loc_idx_t vertices[6]; // local vertex indices h5_loc_idx_t elem_idx_of_first_child; h5_loc_triangle_t* el = &t->loc_elems.tris[elem_idx]; if (el->child_idx >= 0) - return h5_error ( - f, - H5_ERR_INVAL, - "Element %lld already refined.", - (long long)elem_idx); - + H5_PRIV_FUNC_LEAVE ( + h5_error ( + H5_ERR_INVAL, + "Element %lld already refined.", + (long long)elem_idx)); + vertices[0] = el->vertex_indices[0]; vertices[1] = el->vertex_indices[1]; vertices[2] = el->vertex_indices[2]; @@ -172,7 +177,7 @@ refine_triangle ( t->loc_elems.tris[elem_idx].child_idx = elem_idx_of_first_child; t->num_elems_on_leaf_level[t->leaf_level]--; - return elem_idx_of_first_child; + H5_PRIV_FUNC_RETURN (elem_idx_of_first_child); } static inline h5_loc_idx_t @@ -181,7 +186,7 @@ compute_neighbor_of_face ( h5_loc_idx_t elem_idx, const h5_loc_idx_t face_idx ) { - + H5_PRIV_FUNC_ENTER (h5_loc_idx_t); h5t_fdata_t * const t = f->t; h5_loc_idlist_t* te; h5_loc_idx_t neighbor_idx = -2; @@ -193,8 +198,8 @@ compute_neighbor_of_face ( elem_idx, &te) ); if (te == NULL) { - return h5_error_internal ( - f, __FILE__, __func__, __LINE__); + H5_PRIV_FUNC_LEAVE ( + h5_error_internal (__FILE__, __func__, __LINE__)); } if (te->num_items == 1) { // neighbor is coarser or face is on the boundary @@ -212,11 +217,11 @@ compute_neighbor_of_face ( } } else { - return h5_error_internal ( - f, __FILE__, __func__, __LINE__); + H5_PRIV_FUNC_LEAVE ( + h5_error_internal (__FILE__, __func__, __LINE__)); } } while (neighbor_idx < -1); - return neighbor_idx; + H5_PRIV_FUNC_RETURN (neighbor_idx); } /* @@ -227,12 +232,16 @@ compute_neighbors_of_elems ( h5_file_t* const f, h5t_lvl_idx_t level ) { - h5_debug (f, "%s()", __func__); + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t * const t = f->t; if (level < 0 || level >= t->num_leaf_levels) { - return h5_error (f, H5_ERR_INVAL, - "level idx %lld out of bound, must be in [%lld,%lld]", - (long long)level, (long long)0, (long long)t->num_leaf_levels); + H5_PRIV_FUNC_LEAVE ( + h5_error ( + H5_ERR_INVAL, + "level idx %lld out of bound, must be in [%lld,%lld]", + (long long)level, + (long long)0, + (long long)t->num_leaf_levels)); } h5_loc_idx_t elem_idx = level == 0 ? 0 : t->num_elems[level-1]; const h5_loc_idx_t last_idx = t->num_elems[level] - 1; @@ -247,20 +256,20 @@ compute_neighbors_of_elems ( el++; } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t end_store_elems ( h5_file_t* const f ) { - h5_debug (f, "%s()", __func__); + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; TRY( h5tpriv_update_adjacency_structs (f, t->leaf_level) ); TRY( compute_neighbors_of_elems (f, t->leaf_level) ); TRY( h5tpriv_init_geom_boundary_info (f, t->leaf_level) ); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } struct h5t_store_methods h5tpriv_trim_store_methods = { diff --git a/src/h5core/h5t_tags.c b/src/h5core/h5t_tags.c index 8de01d4..73d61f3 100644 --- a/src/h5core/h5t_tags.c +++ b/src/h5core/h5t_tags.c @@ -9,8 +9,6 @@ - read tagsets on demand */ - - /* Release a tag-set */ @@ -19,18 +17,19 @@ release_tagset ( h5_file_t* const f, h5t_tagset_t* tagset ) { + H5_PRIV_FUNC_ENTER (h5_err_t); unsigned int i; // release per element structures for (i = 0; i < tagset->num_elems; i++) { if (tagset->elems[i] != NULL) { - TRY( h5_free (f, tagset->elems[i]) ); + TRY (h5_free (tagset->elems[i])); } } // release other memory - TRY( h5_free (f, tagset->name) ); - TRY( h5_free (f, tagset->values) ); - TRY( h5_free (f, tagset) ); - return H5_SUCCESS; + TRY (h5_free (tagset->name)); + TRY (h5_free (tagset->values)); + TRY (h5_free (tagset)); + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -41,8 +40,9 @@ release_tagset2 ( h5_file_t* const f, const void* __tagset ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_tagset_t* tagset = *(h5t_tagset_t**)__tagset; - return release_tagset (f, tagset); + H5_PRIV_FUNC_RETURN (release_tagset (f, tagset)); } @@ -55,25 +55,28 @@ init_container ( const size_t ntags, h5t_tagcontainer_t* ctn ) { - ctn->names = h5_calloc (f, ntags, sizeof(char*)); - TRY( h5priv_hcreate_string_keyed (f, ntags, &ctn->sets, - release_tagset2) ); - return H5_SUCCESS; + H5_PRIV_FUNC_ENTER (h5_err_t); + TRY (ctn->names = h5_calloc (ntags, sizeof(char*))); + TRY (h5priv_hcreate_string_keyed (f, ntags, &ctn->sets, + release_tagset2)); + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* Release all sets in given container */ -static h5_err_t +static inline h5_err_t release_container ( h5_file_t* const f, h5t_tagcontainer_t* ctn ) { - if (ctn->num_sets == 0) return H5_SUCCESS; - TRY( h5priv_hdestroy (f, &ctn->sets) ); - TRY( h5_free (f, ctn->names) ); + H5_PRIV_FUNC_ENTER (h5_err_t); + if (ctn->num_sets == 0) + H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + TRY (h5priv_hdestroy (f, &ctn->sets)); + TRY (h5_free (ctn->names)); memset (ctn, 0, sizeof (*ctn)); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -83,10 +86,10 @@ h5_err_t h5tpriv_release_tags ( h5_file_t* const f ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; - TRY( release_container (f, &t->mtags) ); - - return H5_SUCCESS; + TRY (release_container (f, &t->mtags)); + H5_PRIV_API_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -95,9 +98,11 @@ tagset_exists ( h5t_tagcontainer_t* ctn, char* name ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_tagset_t tagset; tagset.name = name; - return h5priv_hsearch (f, &tagset, H5_FIND, NULL, &ctn->sets); + H5_PRIV_FUNC_RETURN ( + h5priv_hsearch (f, &tagset, H5_FIND, NULL, &ctn->sets)); } h5_err_t @@ -106,7 +111,8 @@ h5t_mtagset_exists ( h5t_tagcontainer_t* ctn, char* name ) { - return tagset_exists (f, &f->t->mtags, name); + H5_CORE_API_ENTER (h5_err_t); + H5_CORE_API_RETURN (tagset_exists (f, &f->t->mtags, name)); } /*! @@ -127,54 +133,58 @@ add_tagset ( h5_id_t type, h5t_tagset_t** rtagset ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; // Initialize data structure for m-tagsets, if not already done. if (ctn->names == NULL) { - TRY( init_container (f, 521, ctn) ); + TRY (init_container (f, 521, ctn)); } // TODO: Resize if we have more then 80% of 521 filled! // validate name if (name == NULL || name[0] == '\0') { - return h5_error (f, H5_ERR_INVAL, "Invalid name" ); + H5_PRIV_FUNC_LEAVE ( + h5_error (H5_ERR_INVAL, "Invalid name" )); } // validate type if (type != H5_INT64_T && type != H5_FLOAT64_T) { - return h5_error (f, H5_ERR_INVAL, "Unsupported data type." ); + H5_PRIV_FUNC_LEAVE ( + h5_error (H5_ERR_INVAL, "Unsupported data type." )); } // check if a tagset with given name already exists h5_err_t h5err; - TRY( h5err = tagset_exists (f, ctn, name) ); + TRY (h5err = tagset_exists (f, ctn, name) ); if (h5err == H5_SUCCESS) { - return h5_error (f, H5_ERR_INVAL, - "Tagset with name %s already exists!", - name); + H5_PRIV_FUNC_LEAVE ( + h5_error (H5_ERR_INVAL, + "Tagset with name %s already exists!", + name)); } // create new tagset h5t_tagset_t* tagset = NULL; size_t size = (t->num_elems[t->num_leaf_levels-1] - 1) * sizeof(*tagset->elems) + sizeof(*tagset); - TRY( tagset = h5_calloc (f, 1, size) ); + TRY (tagset = h5_calloc (1, size)); - TRY( tagset->name = h5priv_strdup (f, name) ); + TRY (tagset->name = h5priv_strdup (name)); tagset->type = type; tagset->num_elems = t->num_elems[t->num_leaf_levels-1]; tagset->scope.min_level = 32767; tagset->scope.max_level = -1; // add tagset to hash of tagsets - TRY( h5priv_hsearch (f, tagset, H5_ENTER, NULL, &ctn->sets) ); + TRY (h5priv_hsearch (f, tagset, H5_ENTER, NULL, &ctn->sets)); t->mtags.changed = 1; t->mtags.names[t->mtags.num_sets] = tagset->name; t->mtags.num_sets++; - if ( rtagset != NULL ) *rtagset = tagset; - return H5_SUCCESS; + if (rtagset != NULL) *rtagset = tagset; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } h5_err_t @@ -183,8 +193,9 @@ h5t_add_mtagset ( char* name, h5_id_t type ) { + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; - return add_tagset (f, &t->mtags, name, type, NULL); + H5_CORE_API_RETURN (add_tagset (f, &t->mtags, name, type, NULL)); } @@ -202,23 +213,26 @@ remove_tagset ( h5t_tagcontainer_t* ctn, const char name[] ) { + H5_PRIV_FUNC_ENTER (h5_err_t); // remove tagset with NAME from m-tagsets dictionary void* __retval = NULL; - TRY( h5priv_hsearch (f, &name, H5_REMOVE, &__retval, &ctn->sets) ); + TRY (h5priv_hsearch (f, &name, H5_REMOVE, &__retval, &ctn->sets)); h5t_tagset_t* tagset = (h5t_tagset_t*)__retval; - if (tagset == NULL) return H5_SUCCESS; - TRY( release_tagset (f, tagset) ); + if (tagset == NULL) { + H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + } + TRY (release_tagset (f, tagset)); // remove HDF5 datasets and group for this tagset hid_t loc_id; - TRY( loc_id = h5priv_open_group (f, ctn->group_id, name) ); - TRY( h5priv_delete_hdf5_link (f, loc_id, "elems", H5P_DEFAULT) ); - TRY( h5priv_delete_hdf5_link (f, loc_id, "entities", H5P_DEFAULT) ); - TRY( h5priv_delete_hdf5_link (f, loc_id, "values", H5P_DEFAULT) ); - TRY( h5priv_close_hdf5_group (f, loc_id) ); - TRY( h5priv_delete_hdf5_link (f, ctn->group_id, name, H5P_DEFAULT) ); + TRY (loc_id = h5priv_open_group (f, ctn->group_id, name)); + TRY (hdf5_delete_link (loc_id, "elems", H5P_DEFAULT)); + TRY (hdf5_delete_link (loc_id, "entities", H5P_DEFAULT)); + TRY (hdf5_delete_link (loc_id, "values", H5P_DEFAULT)); + TRY (hdf5_close_group (loc_id)); + TRY (hdf5_delete_link (ctn->group_id, name, H5P_DEFAULT)); - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /*! @@ -234,20 +248,21 @@ h5t_remove_mtagset ( h5_file_t* const f, const char name[] ) { + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; - - TRY( t->mtags.group_id = h5priv_open_group (f, t->mesh_gid, "Tags") ); - TRY( remove_tagset (f, &t->mtags, name) ); - TRY( h5priv_close_hdf5_group ( f, t->mtags.group_id) ); - return H5_SUCCESS; + TRY (t->mtags.group_id = h5priv_open_group (f, t->mesh_gid, "Tags")); + TRY (remove_tagset (f, &t->mtags, name)); + TRY (hdf5_close_group (t->mtags.group_id)); + H5_CORE_API_RETURN (H5_SUCCESS); } h5_ssize_t h5t_get_num_mtagsets ( h5_file_t* const f ) { + H5_CORE_API_ENTER (h5_ssize_t); h5t_fdata_t* t = f->t; - return t->mtags.num_sets; + H5_CORE_API_RETURN (t->mtags.num_sets); } /*! @@ -263,9 +278,10 @@ h5t_get_mtagsets ( h5_file_t* const f, char** names[] ) { + H5_CORE_API_ENTER (h5_ssize_t); h5t_fdata_t* t = f->t; *names = t->mtags.names; - return t->mtags.num_sets; + H5_CORE_API_RETURN (t->mtags.num_sets); } h5_err_t @@ -274,11 +290,12 @@ h5t_open_mtagset ( const char* name, h5t_tagset_t** retval ) { + H5_CORE_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; void* __retval = NULL; - TRY( h5priv_hsearch (f, &name, H5_FIND, &__retval, &t->mtags.sets) ); + TRY (h5priv_hsearch (f, &name, H5_FIND, &__retval, &t->mtags.sets)); *retval = (h5t_tagset_t*)__retval; - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } /*! @@ -294,9 +311,10 @@ h5t_get_mtagset_type_by_name ( h5_file_t* const f, char* name ) { + H5_CORE_API_ENTER (h5_id_t); h5t_tagset_t* tagset; - TRY( h5t_open_mtagset (f, name, &tagset) ); - return tagset->type; + TRY (h5t_open_mtagset (f, name, &tagset)); + H5_CORE_API_RETURN (tagset->type); } /*! @@ -314,14 +332,15 @@ h5t_get_mtagset_info ( char** name, h5_id_t* type ) { + H5_CORE_API_ENTER (h5_ssize_t); h5t_fdata_t* t = f->t; *name = t->mtags.names[idx]; void* __retval = NULL; - h5priv_hsearch (f, t->mtags.names[idx], H5_FIND, &__retval, - &t->mtags.sets); + TRY (h5priv_hsearch (f, t->mtags.names[idx], H5_FIND, &__retval, + &t->mtags.sets)); h5t_tagset_t* retval = (h5t_tagset_t*)__retval; *type = retval->type; - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } static int @@ -346,17 +365,18 @@ find_face_id ( return -(low+1); } -static inline void +static inline h5_err_t tag_nexists_warn ( h5_file_t* const f, const char* name, const h5_loc_idx_t face_id, const h5_loc_idx_t elem_idx ) { - h5_warn (f, "Tag %s not set for face %llx of element %lld", - name, - (long long)face_id, - (long long)elem_idx); + return h5_warn ( + "Tag %s not set for face %llx of element %lld", + name, + (long long)face_id, + (long long)elem_idx); } static h5_err_t @@ -366,16 +386,18 @@ remove_tag ( const h5_loc_idx_t face_id, const h5_loc_idx_t elem_idx ) { + H5_PRIV_FUNC_ENTER (h5_err_t); if (tagset->elems[elem_idx] == NULL) { - tag_nexists_warn (f, tagset->name, face_id, elem_idx); - return H5_NOK; + H5_PRIV_FUNC_LEAVE ( + tag_nexists_warn (f, tagset->name, face_id, elem_idx)); } h5t_tageleminfo_t* eleminfo = tagset->elems[elem_idx]; // remove values int idx = find_face_id (eleminfo, face_id); if (idx < 0) { - tag_nexists_warn (f, tagset->name, face_id, elem_idx); + H5_PRIV_FUNC_LEAVE ( + tag_nexists_warn (f, tagset->name, face_id, elem_idx)); } h5t_taginfo_t* ti = &eleminfo->ti[idx]; @@ -390,7 +412,7 @@ remove_tag ( (eleminfo->num_tags-idx-1)*sizeof (ti[0]) ); // we don't resize the eleminfo structure!!! - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } static h5_err_t @@ -403,13 +425,13 @@ add_tag ( const size_t dim, void* val ) { + H5_PRIV_FUNC_ENTER (h5_err_t); // insert new taginfo h5t_tageleminfo_t* eleminfo = tagset->elems[elem_idx]; - TRY( eleminfo = tagset->elems[elem_idx] = h5_alloc ( - f, - tagset->elems[elem_idx], - sizeof (*eleminfo) - + eleminfo->num_tags * sizeof (eleminfo->ti[0])) ); + TRY (eleminfo = tagset->elems[elem_idx] = h5_alloc ( + tagset->elems[elem_idx], + sizeof (*eleminfo) + + eleminfo->num_tags * sizeof (eleminfo->ti[0]))); h5t_taginfo_t* ti = &eleminfo->ti[idx]; memmove (ti + 1, ti, @@ -417,21 +439,20 @@ add_tag ( eleminfo->num_tags++; ti->face_id = face_id; ti->val_dim = dim; - + // append values - TRY( tagset->values = h5_alloc ( - f, - tagset->values, - (tagset->num_values+dim) * sizeof (*tagset->values)) ); + TRY (tagset->values = h5_alloc ( + tagset->values, + (tagset->num_values+dim) * sizeof (*tagset->values))); memcpy (tagset->values + tagset->num_values, val, dim*sizeof (*tagset->values)); ti->val_idx = tagset->num_values; tagset->num_values += dim; - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } -static h5_err_t +static inline h5_err_t overwrite_tag ( h5_file_t* const f, h5t_tagset_t* tagset, @@ -461,9 +482,10 @@ set_tag ( const size_t dim, void* val ) { + H5_PRIV_FUNC_ENTER (h5_err_t); if (tagset->elems[elem_idx] == NULL) { - TRY( tagset->elems[elem_idx] = h5_calloc ( - f, 1, sizeof (*tagset->elems)) ); + TRY (tagset->elems[elem_idx] = h5_calloc ( + 1, sizeof (*tagset->elems))); } h5t_tageleminfo_t* eleminfo = tagset->elems[elem_idx]; int i = find_face_id (eleminfo, face_id); @@ -473,12 +495,12 @@ set_tag ( This is a very unusual case! So the processing can be a bit more expensive ... */ - TRY( remove_tag (f, tagset, face_id, elem_idx) ); - TRY( add_tag (f, tagset, i, face_id, elem_idx, dim, val) ); + TRY (remove_tag (f, tagset, face_id, elem_idx)); + TRY (add_tag (f, tagset, i, face_id, elem_idx, dim, val)); } else if (i >= 0 && dim == ti->val_dim) { - TRY( overwrite_tag (f, tagset, i, elem_idx, val) ); + TRY (overwrite_tag (f, tagset, i, elem_idx, val)); } else { // i < 0 - TRY( add_tag (f, tagset, -i-1, face_id, elem_idx, dim, val) ); + TRY (add_tag (f, tagset, -i-1, face_id, elem_idx, dim, val)); tagset->num_entities++; } if (f->t->leaf_level < tagset->scope.min_level) { @@ -488,10 +510,10 @@ set_tag ( tagset->scope.max_level = f->t->leaf_level; } tagset->changed = 1; - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } -static h5_err_t +static inline h5_err_t get_idx_of_tagval ( const h5t_tagset_t* tagset, const h5_loc_idx_t face_id, @@ -508,7 +530,7 @@ get_idx_of_tagval ( return H5_SUCCESS; } -static h5_ssize_t +static inline h5_ssize_t get_tag ( h5_file_t* const f, const h5t_tagset_t *tagset, @@ -562,12 +584,12 @@ h5t_set_mtag_by_name ( const size_t dim, void* val ) { + H5_CORE_API_ENTER (h5_err_t); h5t_tagset_t* tagset; - TRY ( h5t_open_mtagset (f, name, &tagset) ); + TRY (h5t_open_mtagset (f, name, &tagset)); h5_loc_idx_t face_id = h5tpriv_get_face_id (entity_id); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); - - return set_tag (f, tagset, face_id, elem_idx, dim, val); + H5_CORE_API_RETURN (set_tag (f, tagset, face_id, elem_idx, dim, val)); } /*! Get tag for entity in given tagset. @@ -588,9 +610,10 @@ h5t_get_tag ( size_t* const dim, void* const vals ) { + H5_CORE_API_ENTER (h5_ssize_t); h5_loc_idx_t face_id = h5tpriv_get_face_id (entity_id); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); - return get_tag (f, tagset, face_id, elem_idx, dim, vals); + H5_CORE_API_RETURN (get_tag (f, tagset, face_id, elem_idx, dim, vals)); } /*! @@ -612,12 +635,12 @@ h5t_get_mtag_by_name ( size_t* dim, void* vals ) { + H5_CORE_API_ENTER (h5_ssize_t); h5t_tagset_t* tagset; - TRY( h5t_open_mtagset (f, name, &tagset) ); + TRY (h5t_open_mtagset (f, name, &tagset)); h5_loc_idx_t face_id = h5tpriv_get_face_id (entity_id); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); - - return get_tag (f, tagset, face_id, elem_idx, dim, vals); + H5_CORE_API_RETURN (get_tag (f, tagset, face_id, elem_idx, dim, vals)); } /*! @@ -633,10 +656,10 @@ h5t_remove_mtag ( h5t_tagset_t* tagset, const h5_loc_id_t entity_id ) { + H5_CORE_API_ENTER (h5_err_t); h5_loc_idx_t face_id = h5tpriv_get_face_id (entity_id); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); - - return remove_tag (f, tagset, face_id, elem_idx); + H5_CORE_API_RETURN (remove_tag (f, tagset, face_id, elem_idx)); } /*! @@ -652,12 +675,12 @@ h5t_remove_mtag_by_name ( const char name[], const h5_loc_id_t entity_id ) { + H5_CORE_API_ENTER (h5_err_t); h5t_tagset_t* tagset; - TRY( h5t_open_mtagset (f, name, &tagset) ); + TRY (h5t_open_mtagset (f, name, &tagset)); h5_loc_idx_t face_id = h5tpriv_get_face_id (entity_id); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); - - return remove_tag (f, tagset, face_id, elem_idx); + H5_CORE_API_RETURN (remove_tag (f, tagset, face_id, elem_idx)); } static hid_t @@ -679,6 +702,7 @@ write_tagset ( const hid_t loc_id, h5t_tagset_t* tagset ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; h5t_tageleminfo_t** eleminfos = tagset->elems; hid_t group_id; @@ -693,28 +717,23 @@ write_tagset ( h5_loc_idx_t entity_idx = 0; h5_loc_idx_t val_idx = 0; - h5_err_t h5err = H5_SUCCESS; - if (t->num_leaf_levels <= 0) { - goto cleanup; // nothing to do + H5_PRIV_FUNC_LEAVE (H5_SUCCESS); // nothing to do } num_elems = t->num_elems[t->num_leaf_levels-1]; if (num_elems == 0 || tagset->num_entities == 0) { - goto cleanup; // nothing to do + H5_PRIV_FUNC_LEAVE (H5_SUCCESS); // nothing to do } // allocate memory per element (plus 1) - TRY( elems = h5_calloc ( - f, num_elems+1, sizeof(*elems)) ); + TRY (elems = h5_calloc (num_elems+1, sizeof(*elems))); elem = elems; // allocate memory per entity (plus 1) - TRY( entities = h5_calloc ( - f, tagset->num_entities+1, sizeof(*entities)) ); + TRY (entities = h5_calloc (tagset->num_entities+1, sizeof(*entities)) ); entity = entities; // allocate memory for all values - TRY( values = h5_calloc ( - f, tagset->num_values, sizeof(*values)) ); + TRY (values = h5_calloc (tagset->num_values, sizeof(*values)) ); // build data structures in memory while (elem < elems+num_elems) { @@ -749,7 +768,7 @@ write_tagset ( tagset->num_values = entity->idx = val_idx; // write data - TRY( group_id = h5priv_open_group (f, loc_id, tagset->name) ); + TRY (group_id = h5priv_open_group (f, loc_id, tagset->name)); h5_dsinfo_t dsinfo; memset (&dsinfo, 0, sizeof(dsinfo)); dsinfo.rank = 1; @@ -760,49 +779,47 @@ write_tagset ( strcpy (dsinfo.name, "elems"); dsinfo.dims[0] = num_elems + 1; dsinfo.type_id = t->dtypes.h5t_glb_tag_idx_t; - TRY( dsinfo.create_prop = h5priv_create_hdf5_property (f, - H5P_DATASET_CREATE ) ); - TRY( h5priv_set_hdf5_chunk_property (f, dsinfo.create_prop, dsinfo.rank, - dsinfo.chunk_dims) ); + TRY (dsinfo.create_prop = hdf5_create_property (H5P_DATASET_CREATE)); + TRY (hdf5_set_chunk_property (dsinfo.create_prop, dsinfo.rank, + dsinfo.chunk_dims)); - TRY( h5priv_write_dataset_by_name ( - f, - group_id, - &dsinfo, - open_space_all, open_space_all, - elems) ); + TRY (h5priv_write_dataset_by_name ( + f, + group_id, + &dsinfo, + open_space_all, open_space_all, + elems)); strcpy (dsinfo.name, "entities"); dsinfo.dims[0] = tagset->num_entities + 1; - TRY( h5priv_write_dataset_by_name ( + TRY (h5priv_write_dataset_by_name ( f, group_id, &dsinfo, open_space_all, open_space_all, - entities) ); + entities)); strcpy (dsinfo.name, "values"); dsinfo.dims[0] = tagset->num_values; dsinfo.type_id = t->dtypes.h5_int64_t; - TRY( h5priv_write_dataset_by_name ( + TRY (h5priv_write_dataset_by_name ( f, group_id, &dsinfo, open_space_all, open_space_all, - values) ); + values)); h5_int64_t scope = tagset->scope.min_level; - TRY( h5priv_write_attrib (f, group_id, "__scope_min__", H5_INT64_T, &scope, 1) ); + TRY (h5priv_write_attrib (f, group_id, "__scope_min__", H5_INT64_T, &scope, 1)); scope = tagset->scope.max_level; - TRY( h5priv_write_attrib (f, group_id, "__scope_max__", H5_INT64_T, &scope, 1) ); -cleanup: - TRY( h5priv_close_hdf5_group (f, group_id) ); - TRY( h5_free (f, elems) ); - TRY( h5_free (f, entities) ); - TRY( h5_free (f, values) ); + TRY (h5priv_write_attrib (f, group_id, "__scope_max__", H5_INT64_T, &scope, 1)); - return h5err; + TRY (hdf5_close_group (group_id)); + TRY (h5_free (elems)); + TRY (h5_free (entities)); + TRY (h5_free (values)); + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } /* @@ -813,23 +830,24 @@ write_container ( h5_file_t* const f, h5t_tagcontainer_t* ctn ) { + H5_PRIV_FUNC_ENTER (h5_err_t); size_t idx; for (idx = 0; idx < ctn->num_sets; idx++) { void *__retval; - TRY( h5priv_hsearch ( f, + TRY (h5priv_hsearch ( f, &ctn->names[idx], H5_FIND, &__retval, - &ctn->sets) ); + &ctn->sets)); h5t_tagset_t *tagset = (h5t_tagset_t*)__retval; if (tagset->changed) { - TRY( write_tagset ( + TRY(write_tagset ( f, ctn->group_id, - tagset) ); + tagset)); } } - return H5_SUCCESS; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } @@ -840,11 +858,12 @@ h5_err_t h5tpriv_write_mtags ( h5_file_t* const f ) { + H5_PRIV_API_ENTER (h5_err_t); h5t_fdata_t* t = f->t; - TRY( t->mtags.group_id = h5priv_open_group (f, t->mesh_gid, "Tags") ); - TRY( write_container (f, &f->t->mtags) ); - TRY( h5priv_close_hdf5_group (f, t->mtags.group_id) ); - return H5_SUCCESS; + TRY (t->mtags.group_id = h5priv_open_group (f, t->mesh_gid, "Tags")); + TRY (write_container (f, &f->t->mtags)); + TRY (hdf5_close_group (t->mtags.group_id)); + H5_PRIV_API_RETURN (H5_SUCCESS); } static h5_err_t @@ -853,6 +872,7 @@ read_tagset ( h5t_tagcontainer_t* ctn, hsize_t idx ) { + H5_PRIV_FUNC_ENTER (h5_err_t); h5t_fdata_t* t = f->t; hid_t loc_id = ctn->group_id; char* name; @@ -860,71 +880,69 @@ read_tagset ( hid_t group_id; hid_t dset_id; ssize_t ssize; - TRY( (ssize = h5priv_get_hdf5_objname_by_idx (f, loc_id, idx, NULL, 0)) ); - TRY( (name = h5_calloc (f, 1, ++ssize)) ); - TRY( h5priv_get_hdf5_objname_by_idx (f, loc_id, idx, name, ssize) ); - TRY( group_id = h5priv_open_hdf5_group (f, loc_id, name) ); + TRY ((ssize = hdf5_get_objname_by_idx (loc_id, idx, NULL, 0))); + TRY ((name = h5_calloc (1, ++ssize))); + TRY (hdf5_get_objname_by_idx (loc_id, idx, name, ssize)); + TRY (group_id = hdf5_open_group (loc_id, name)); - /* - read datasets: "elems", "entities" and "values" - */ + // read datasets: "elems", "entities" and "values" h5t_glb_tag_idx_t* elems; size_t num_elems = 0; - TRY( dset_id = h5priv_open_hdf5_dataset (f, group_id, "elems") ); - TRY( num_elems = h5priv_get_npoints_of_hdf5_dataset (f, dset_id) ); - TRY( elems = h5_calloc (f, num_elems, sizeof(*elems)) ); + TRY (dset_id = hdf5_open_dataset (group_id, "elems")); + TRY (num_elems = hdf5_get_npoints_of_dataset (dset_id)); + TRY (elems = h5_calloc (num_elems, sizeof(*elems))); h5_dsinfo_t dsinfo; memset (&dsinfo, 0, sizeof (dsinfo)); dsinfo.type_id = t->dtypes.h5t_glb_tag_idx_t; - TRY( h5priv_read_dataset ( + TRY (h5priv_read_dataset ( f, dset_id, &dsinfo, open_space_all, open_space_all, - elems) ); - TRY( h5priv_close_hdf5_dataset (f, dset_id) ); + elems)); + TRY (hdf5_close_dataset (dset_id)); num_elems--; h5t_glb_tag_idx_t* entities; size_t ent_idx = 0; size_t num_entities = 0; - TRY( dset_id = h5priv_open_hdf5_dataset (f, group_id, "entities") ); - TRY( num_entities = h5priv_get_npoints_of_hdf5_dataset (f, dset_id) ); - TRY( entities = h5_calloc (f, num_entities, sizeof(*entities)) ); - TRY( h5priv_read_dataset ( + TRY (dset_id = hdf5_open_dataset (group_id, "entities")); + TRY (num_entities = hdf5_get_npoints_of_dataset (dset_id)); + TRY (entities = h5_calloc (num_entities, sizeof(*entities))); + TRY (h5priv_read_dataset ( f, dset_id, &dsinfo, open_space_all, open_space_all, - entities) ); - TRY( h5priv_close_hdf5_dataset (f, dset_id) ); + entities)); + TRY (hdf5_close_dataset (dset_id)); num_entities--; h5_int64_t* vals; size_t num_vals = 0; - TRY( dset_id = h5priv_open_hdf5_dataset (f, group_id, "values") ); - TRY( num_vals = h5priv_get_npoints_of_hdf5_dataset (f, dset_id) ); - TRY( vals = h5_calloc (f, num_vals, sizeof (*vals)) ); - TRY( dsinfo.type_id = h5priv_get_hdf5_dataset_type (f, dset_id) ); - TRY( h5priv_read_dataset ( + TRY (dset_id = hdf5_open_dataset (group_id, "values")); + TRY (num_vals = hdf5_get_npoints_of_dataset (dset_id)); + TRY (vals = h5_calloc (num_vals, sizeof (*vals))); + TRY (dsinfo.type_id = hdf5_get_dataset_type (dset_id)); + TRY (h5priv_read_dataset ( f, dset_id, &dsinfo, open_space_all, open_space_all, - vals) ); - TRY( h5priv_close_hdf5_dataset (f, dset_id )); + vals)); + TRY (hdf5_close_dataset (dset_id )); type = h5_normalize_h5_type (f, dsinfo.type_id); /* add tagset and set values */ h5t_tagset_t* tagset; - TRY( add_tagset (f, ctn, name, type, &tagset) ); + TRY (add_tagset (f, ctn, name, type, &tagset) ); h5_int64_t scope; - TRY( h5priv_read_attrib (f, group_id, "__scope_min__", H5_INT64_T, &scope) ); + TRY (h5priv_read_attrib (f, group_id, "__scope_min__", H5_INT64_T, &scope)); tagset->scope.min_level = scope; - TRY( h5priv_read_attrib (f, group_id, "__scope_max__", H5_INT64_T, &scope) ); + TRY (h5priv_read_attrib (f, group_id, "__scope_max__", H5_INT64_T, &scope)); tagset->scope.max_level = scope; for (ent_idx = 0; ent_idx < num_entities; ent_idx++) { @@ -934,18 +952,18 @@ read_tagset ( h5_loc_idx_t face_id; h5_loc_idx_t elem_idx; h5_glb_idx_t glb_elem_idx = h5tpriv_get_elem_idx (entity->eid); - TRY( elem_idx = h5t_map_glb_elem_idx2loc (f, glb_elem_idx) ); + TRY (elem_idx = h5t_map_glb_elem_idx2loc (f, glb_elem_idx)); face_id = h5tpriv_get_face_id (entity->eid); - TRY( set_tag ( + TRY (set_tag ( f, tagset, face_id, elem_idx, dim, - &vals[entity->idx] ) ); + &vals[entity->idx])); } - TRY( h5_free (f, name) ); - return H5_SUCCESS; + TRY (h5_free (name)); + H5_PRIV_FUNC_RETURN (H5_SUCCESS); } h5_err_t @@ -953,16 +971,16 @@ h5tpriv_read_tag_container ( h5_file_t* const f, h5t_tagcontainer_t* ctn ) { + H5_PRIV_API_ENTER (h5_err_t); size_t num_sets; - TRY( num_sets = h5priv_get_num_objs_in_hdf5_group ( - f, ctn->group_id) ); + TRY (num_sets = hdf5_get_num_objs_in_group (ctn->group_id)); hsize_t idx; for (idx = 0; idx < num_sets; idx++) { - TRY( read_tagset (f, ctn, idx) ); + TRY (read_tagset (f, ctn, idx)); } - return H5_SUCCESS; + H5_PRIV_API_RETURN (H5_SUCCESS); } /* @@ -990,6 +1008,7 @@ get_tagset_names_of_entity ( char* names[], h5_size_t dim ) { + H5_PRIV_FUNC_ENTER (h5_ssize_t); size_t idx; size_t _dim = 0; h5_loc_idx_t face_id = h5tpriv_get_face_id (entity_id); @@ -998,10 +1017,10 @@ get_tagset_names_of_entity ( for (idx = 0; idx < ctn->num_sets; idx++) { void* __retval; TRY (h5priv_hsearch (f, - &ctn->names[idx], - H5_FIND, - &__retval, - &ctn->sets)); + &ctn->names[idx], + H5_FIND, + &__retval, + &ctn->sets)); h5t_tagset_t* tagset = (h5t_tagset_t*)__retval; int tagset_idx = 0; h5_loc_idx_t val_idx; @@ -1015,7 +1034,7 @@ get_tagset_names_of_entity ( } _dim++; } - return _dim;; + H5_PRIV_FUNC_RETURN (_dim); } /* @@ -1028,5 +1047,7 @@ h5t_get_mtagset_names_of_entity ( char* names[], const h5_size_t dim ) { - return get_tagset_names_of_entity (f, &f->t->mtags, entity_id, names, dim); + H5_CORE_API_ENTER (h5_ssize_t); + H5_CORE_API_RETURN ( + get_tagset_names_of_entity (f, &f->t->mtags, entity_id, names, dim)); } diff --git a/src/h5core/h5u_model.c b/src/h5core/h5u_model.c index 85916bc..0fa1f2b 100644 --- a/src/h5core/h5u_model.c +++ b/src/h5core/h5u_model.c @@ -5,21 +5,21 @@ h5_ssize_t h5u_get_num_particles ( h5_file_t *const f /*!< [in] Handle to open file */ ) { + H5_CORE_API_ENTER (h5_ssize_t); h5_int64_t nparticles; /* if a view exists, use its size as the number of particles */ if ( h5u_has_view ( f ) ) { - TRY( nparticles = h5priv_get_selected_npoints_of_hdf5_dataspace( - f, - f->u->diskshape) ); - h5_debug(f, + TRY (nparticles = hdf5_get_selected_npoints_of_dataspace( + f->u->diskshape)); + h5_debug( "Found %lld particles in existing view.", (long long)nparticles ); } else if ( f->u->shape > 0 ) { - TRY( nparticles = h5priv_get_npoints_of_hdf5_dataspace(f, f->u->shape) ); - h5_debug(f, + TRY (nparticles = hdf5_get_npoints_of_dataspace (f->u->shape) ); + h5_debug( "Found %lld particles from previous H5PartSetNumParticles call.", (long long)nparticles ); } @@ -29,28 +29,27 @@ h5u_get_num_particles ( char dataset_name[H5_DATANAME_LEN]; dataset_name[0] = '\0'; h5_err_t exists = h5_get_hdf5_datasetname_by_idx( - f, f->step_gid, 0, dataset_name, H5_DATANAME_LEN); if ( exists < 0 ) - return h5_error(f, - H5_ERR_INVAL, - "Cannot determine the number of particles: " - "H5PartSetNumParticles has not been called, " - "no view has been set, and there are no " - "data sets for this time step!"); - TRY( nparticles = h5priv_get_npoints_of_hdf5_dataset_by_name( - f, + H5_CORE_API_LEAVE ( + h5_error( + H5_ERR_INVAL, + "Cannot determine the number of particles: " + "H5PartSetNumParticles has not been called, " + "no view has been set, and there are no " + "data sets for this time step!")); + TRY( nparticles = hdf5_get_npoints_of_dataset_by_name( f->step_gid, dataset_name) ); - h5_debug(f, + h5_debug( "Found %lld particles in the first data set of this time step.", (long long)nparticles ); } - return nparticles; + H5_CORE_API_RETURN (nparticles); } h5_err_t @@ -59,6 +58,7 @@ h5u_set_num_particles ( const h5_size_t nparticles, /*!< [in] Number of particles */ const h5_size_t stride /*!< [in] Stride of particles in memory */ ) { + H5_CORE_API_ENTER (h5_err_t); struct h5u_fdata *u = f->u; hsize_t hstride; @@ -68,14 +68,15 @@ h5u_set_num_particles ( hsize_t dmax = H5S_UNLIMITED; if ( nparticles <= 0 ) - return h5_error(f, + H5_CORE_API_LEAVE ( + h5_error( H5_ERR_INVAL, "Invalid number particles: %lld!\n", - (long long)nparticles); + (long long)nparticles)); hstride = (hsize_t)stride; if ( hstride > 1 ) - h5_debug( f, "Striding by %lld elements.", (long long)hstride); + h5_debug ("Striding by %lld elements.", (long long)hstride); #ifndef PARALLEL_IO /* @@ -85,20 +86,20 @@ h5u_set_num_particles ( we don't know if things have changed globally */ if ( u->nparticles == nparticles && stride == 1 ) { - return H5_SUCCESS; + H5_CORE_API_LEAVE (H5_SUCCESS); } #endif - TRY( h5u_reset_view(f) ); + TRY (h5u_reset_view(f)); - TRY( h5priv_close_hdf5_dataspace( f, u->shape ) ); + TRY (hdf5_close_dataspace (u->shape)); u->shape = H5S_ALL; u->nparticles = (hsize_t)nparticles; /* declare local memory datasize with striding */ count = u->nparticles * stride; - TRY( u->memshape = h5priv_create_hdf5_dataspace(f, 1, &count, &dmax) ); + TRY (u->memshape = hdf5_create_dataspace (1, &count, &dmax)); /* we need a hyperslab selection if there is striding * (otherwise, the default H5S_ALL selection is ok) @@ -107,17 +108,17 @@ h5u_set_num_particles ( { start = 0; count = u->nparticles; - TRY( h5priv_select_hyperslab_of_hdf5_dataspace(f, - u->memshape, - H5S_SELECT_SET, - &start, &hstride, &count, - NULL) ); + TRY (hdf5_select_hyperslab_of_dataspace( + u->memshape, + H5S_SELECT_SET, + &start, &hstride, &count, + NULL)); } #ifndef PARALLEL_IO UNUSED_ARGUMENT (total); count = u->nparticles; - TRY( u->shape = h5priv_create_hdf5_dataspace(f, 1, &count, NULL) ); + TRY( u->shape = hdf5_create_dataspace (1, &count, NULL)); u->viewstart = 0; u->viewend = nparticles - 1; // view range is *inclusive* #else /* PARALLEL_IO */ @@ -142,53 +143,53 @@ h5u_set_num_particles ( &(u->nparticles), &start, 1, MPI_LONG_LONG, f->comm ) ); start -= u->nparticles; - h5_debug(f, "Total particles across all processors: %lld.", - (long long)total); + h5_debug("Total particles across all processors: %lld.", (long long)total); u->viewstart = start; u->viewend = start + u->nparticles - 1; // view range is *inclusive* /* declare overall datasize */ count = total; - TRY( u->shape = h5priv_create_hdf5_dataspace(f, 1, &count, NULL) ); + TRY( u->shape = hdf5_create_dataspace(1, &count, NULL) ); /* declare overall data size but then will select a subset */ - TRY( u->diskshape = h5priv_create_hdf5_dataspace(f, 1, &count, NULL) ); + TRY( u->diskshape = hdf5_create_dataspace(1, &count, NULL) ); count = nparticles; hstride = 1; - TRY( h5priv_select_hyperslab_of_hdf5_dataspace(f, + TRY( hdf5_select_hyperslab_of_dataspace( u->diskshape, H5S_SELECT_SET, &start, &hstride, &count, NULL) ); #endif - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t h5u_has_view ( const h5_file_t *const f ) { - return ( f->u->viewindexed || ( f->u->viewstart >= 0 && f->u->viewend >= 0 )); + H5_CORE_API_ENTER (h5_err_t); + H5_CORE_API_RETURN (f->u->viewindexed || (f->u->viewstart >= 0 && f->u->viewend >= 0)); } h5_err_t h5u_reset_view ( h5_file_t *const f ) { - + H5_CORE_API_ENTER (h5_err_t); struct h5u_fdata *u = f->u; u->viewstart = -1; u->viewend = -1; u->viewindexed = 0; - TRY( h5priv_close_hdf5_dataspace( f, u->diskshape ) ); + TRY (hdf5_close_dataspace (u->diskshape)); u->diskshape = H5S_ALL; - TRY( h5priv_close_hdf5_dataspace( f, u->memshape ) ); + TRY (hdf5_close_dataspace (u->memshape)); u->memshape = H5S_ALL; - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -197,8 +198,7 @@ h5u_set_view ( h5_int64_t start, /*!< [in] Start particle */ h5_int64_t end /*!< [in] End particle */ ) { - - h5_int64_t herr = 0; + H5_CORE_API_ENTER (h5_err_t); hsize_t total; hsize_t stride = 1; hsize_t hstart; @@ -206,14 +206,13 @@ h5u_set_view ( struct h5u_fdata *u = f->u; h5_debug ( - f, "Set view (%lld,%lld).", (long long)start,(long long)end); - herr = h5u_reset_view ( f ); - if ( herr < 0 ) return herr; + TRY (h5u_reset_view (f)); - if ( start == -1 && end == -1 ) return H5_SUCCESS; + if (start == -1 && end == -1) + H5_CORE_API_LEAVE (H5_SUCCESS); /* View has been reset so H5PartGetNumParticles will tell @@ -227,7 +226,7 @@ h5u_set_view ( /* No datasets have been created yet and no veiws are set. * We have to leave the view empty because we don't know how * many particles there should be! */ - return H5_SUCCESS; + H5_CORE_API_LEAVE (H5_SUCCESS); } @@ -239,7 +238,6 @@ h5u_set_view ( */ if ( end < start ) { h5_warn ( - f, "Nonfatal error. " "End of view (%lld) is less than start (%lld).", (long long)end, (long long)start ); @@ -250,28 +248,25 @@ h5u_set_view ( u->viewend = end; u->nparticles = end - start + 1; - h5_debug (f, + h5_debug ( "This view selected %lld particles.", (long long)u->nparticles ); /* declare overall data size but then will select a subset */ - TRY ( u->diskshape = h5priv_create_hdf5_dataspace ( f, 1, &total, NULL ) ); + TRY (u->diskshape = hdf5_create_dataspace ( 1, &total, NULL )); total = (hsize_t)u->nparticles; hstart = (size_t)start; - TRY ( h5priv_select_hyperslab_of_hdf5_dataspace ( - f, - u->diskshape, - H5S_SELECT_SET, - &hstart, &stride, &total, - NULL ) ); + TRY (hdf5_select_hyperslab_of_dataspace ( + u->diskshape, + H5S_SELECT_SET, + &hstart, &stride, &total, + NULL)); /* declare local memory datasize */ - TRY ( u->memshape = h5priv_create_hdf5_dataspace ( - f, 1, &total, &dmax ) ); - - return H5_SUCCESS; + TRY (u->memshape = hdf5_create_dataspace (1, &total, &dmax)); + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -280,7 +275,7 @@ h5u_set_view_indices ( const h5_id_t *const indices, /*!< [in] List of indices */ const h5_size_t nelems /*!< [in] Size of list */ ) { - + H5_CORE_API_ENTER (h5_err_t); hsize_t total; hsize_t dmax = H5S_UNLIMITED; struct h5u_fdata *u = f->u; @@ -288,9 +283,8 @@ h5u_set_view_indices ( TRY ( h5u_reset_view ( f ) ); if ( indices == NULL ) { - h5_warn ( f, - "View indices array is null: reseting view." ); - return H5_SUCCESS; + h5_warn ("View indices array is null: reseting view."); + H5_CORE_API_LEAVE (H5_SUCCESS); } /* @@ -305,33 +299,28 @@ h5u_set_view_indices ( /* No datasets have been created yet and no veiws are set. * We have to leave the view empty because we don't know how * many particles there should be! */ - return H5_SUCCESS; + H5_CORE_API_LEAVE (H5_SUCCESS); } if ( total == 0 ) return H5_SUCCESS; u->nparticles = (hsize_t) nelems; - h5_debug (f, - "This view selected %lld particles.", - (long long)u->nparticles ); + h5_debug ("This view selected %lld particles.", (long long)u->nparticles ); /* declare overall data size but then will select a subset */ - TRY ( u->diskshape = h5priv_create_hdf5_dataspace ( f, 1, &total, NULL ) ); + TRY (u->diskshape = hdf5_create_dataspace (1, &total, NULL)); /* declare local memory datasize */ total = (size_t)u->nparticles; - TRY ( u->memshape = h5priv_create_hdf5_dataspace ( - f, 1, &total, &dmax ) ); - - TRY ( h5priv_select_elements_of_hdf5_dataspace ( - f, - u->diskshape, - H5S_SELECT_SET, - nelems, (hsize_t*)indices ) ); + TRY (u->memshape = hdf5_create_dataspace (1, &total, &dmax)); + TRY (hdf5_select_elements_of_dataspace ( + u->diskshape, + H5S_SELECT_SET, + nelems, (hsize_t*)indices ) ); u->viewindexed = 1; - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -340,14 +329,15 @@ h5u_get_view ( h5_int64_t *start, h5_int64_t *end ) { + H5_CORE_API_ENTER (h5_err_t); struct h5u_fdata *u = f->u; if ( u->viewindexed ) { - return h5_error ( - f, - H5_ERR_INVAL, - "The current view has an index selection, but " - "this function only works for ranged views." ); + H5_CORE_API_LEAVE ( + h5_error ( + H5_ERR_INVAL, + "The current view has an index selection, but " + "this function only works for ranged views." )); } h5_int64_t viewstart = 0; @@ -366,13 +356,14 @@ h5u_get_view ( if ( start ) *start = viewstart; if ( end ) *end = viewend; - return viewend - viewstart + 1; // view range is *inclusive* + H5_CORE_API_RETURN (viewend - viewstart + 1); // view range is *inclusive* } h5_int64_t h5u_set_canonical_view ( h5_file_t *const f ) { + H5_CORE_API_ENTER (h5_int64_t); TRY( h5u_reset_view ( f ) ); h5_int64_t start = 0; @@ -404,16 +395,15 @@ h5u_set_canonical_view ( TRY( h5u_set_view ( f, start, end ) ); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_ssize_t h5u_get_num_datasets ( h5_file_t *const f /*!< [in] Handle to open file */ ) { - ssize_t n; - TRY ( n = h5_get_num_hdf5_datasets(f, f->step_gid ) ); - return (h5_int64_t)n; + H5_CORE_API_ENTER (h5_ssize_t); + H5_CORE_API_RETURN (h5_get_num_hdf5_datasets (f->step_gid )); } /*! @@ -429,19 +419,17 @@ h5u_get_dataset_info ( h5_int64_t *type, /*!< [out] Type of data in dataset */ h5_size_t *nelem /*!< [out] Number of elements. */ ) { - - TRY( h5_get_hdf5_datasetname_by_idx ( - f, + H5_CORE_API_ENTER (h5_err_t); + TRY (h5_get_hdf5_datasetname_by_idx ( f->step_gid, idx, dataset_name, len_dataset_name) ); if ( nelem ) { h5_ssize_t nelem_; - TRY( nelem_ = h5priv_get_npoints_of_hdf5_dataset_by_name ( - f, - f->step_gid, - dataset_name) ); + TRY (nelem_ = hdf5_get_npoints_of_dataset_by_name ( + f->step_gid, + dataset_name) ); if ( nelem_ < 0 ) return nelem_; *nelem = nelem_; } @@ -451,7 +439,7 @@ h5u_get_dataset_info ( if ( *type < 0 ) return *type; } - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -459,20 +447,19 @@ h5u_set_chunk ( h5_file_t *const f, const h5_size_t size ) { - + H5_CORE_API_ENTER (h5_err_t); if ( size == 0 ) { - h5_info(f, "Disabling chunking" ); - TRY( h5priv_set_hdf5_layout_property(f, - f->u->dcreate_prop, H5D_CONTIGUOUS) ); + h5_info ("Disabling chunking" ); + TRY (hdf5_set_layout_property ( + f->u->dcreate_prop, H5D_CONTIGUOUS)); } else { - h5_info(f, "Setting chunk size to %lld particles", (long long)size); - TRY( h5priv_set_hdf5_chunk_property(f, - f->u->dcreate_prop, 1, (hsize_t*)&size) ); + h5_info ("Setting chunk size to %lld particles", (long long)size); + TRY (hdf5_set_chunk_property( + f->u->dcreate_prop, 1, (hsize_t*)&size)); } - - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -481,21 +468,20 @@ h5u_get_chunk ( const char *name, /*!< IN: name of dataset */ h5_size_t *size /*!< OUT: chunk size in particles */ ) { - + H5_CORE_API_ENTER (h5_err_t); hid_t dataset_id; hid_t plist_id; hsize_t hsize; - TRY( dataset_id = h5priv_open_hdf5_dataset(f, f->step_gid, name) ); - TRY( plist_id = h5priv_get_hdf5_dataset_create_plist(f, dataset_id) ); - TRY( h5priv_get_hdf5_chunk_property(f, plist_id, 1, &hsize) ); - TRY( h5priv_close_hdf5_property(f, plist_id) ); - TRY( h5priv_close_hdf5_dataset(f, dataset_id) ); + TRY (dataset_id = hdf5_open_dataset (f->step_gid, name) ); + TRY (plist_id = hdf5_get_dataset_create_plist (dataset_id) ); + TRY (hdf5_get_chunk_property (plist_id, 1, &hsize) ); + TRY (hdf5_close_property ( plist_id) ); + TRY (hdf5_close_dataset (dataset_id) ); *size = (h5_size_t)hsize; - h5_info(f, "Found chunk size of %lld particles", (long long)*size); - - return H5_SUCCESS; + h5_info ("Found chunk size of %lld particles", (long long)*size); + H5_CORE_API_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5u_readwrite.c b/src/h5core/h5u_readwrite.c index 6d001a3..ac2d607 100644 --- a/src/h5core/h5u_readwrite.c +++ b/src/h5core/h5u_readwrite.c @@ -8,8 +8,8 @@ h5u_read_data ( void *data, /*!< [out] Array of data */ const hid_t type ) { - - CHECK_TIMEGROUP( f ); + H5_CORE_API_ENTER (h5_err_t); + CHECK_TIMEGROUP (f); struct h5u_fdata *u = f->u; hid_t dataset_id; @@ -18,40 +18,39 @@ h5u_read_data ( hsize_t ndisk, nread, nmem; if ( f->step_gid < 0 ) { - TRY( h5_set_step ( f, f->step_idx ) ); + TRY (h5_set_step (f, f->step_idx)); } char name2[H5_DATANAME_LEN]; - TRY ( h5_normalize_dataset_name (f, name, name2) ); + TRY (h5_normalize_dataset_name (f, name, name2)); - TRY( (dataset_id = h5priv_open_hdf5_dataset ( f, f->step_gid, name2 ) ) ); + TRY (dataset_id = hdf5_open_dataset (f->step_gid, name2)); /* default spaces, if not using a view selection */ memspace_id = H5S_ALL; - TRY( space_id = h5priv_get_hdf5_dataset_space(f, dataset_id) ); + TRY (space_id = hdf5_get_dataset_space (dataset_id)); /* get the number of elements on disk for the datset */ - TRY ( ndisk = h5priv_get_npoints_of_hdf5_dataspace(f, space_id) ); + TRY (ndisk = hdf5_get_npoints_of_dataspace (space_id)); if (u->diskshape != H5S_ALL) { - TRY( nread = h5priv_get_npoints_of_hdf5_dataspace(f, u->diskshape) ); + TRY (nread = hdf5_get_npoints_of_dataspace(u->diskshape)); /* make sure the disk space selected by the view doesn't * exceed the size of the dataset */ if (nread <= ndisk) { /* we no longer need the dataset space... */ - TRY( h5priv_close_hdf5_dataspace(f, space_id) ); + TRY (hdf5_close_dataspace(space_id)); /* ...because it's safe to use the view selection */ space_id = f->u->diskshape; } else { /* the view selection is too big? * fall back to using the dataset space */ h5_warn ( - f, - "Ignoring view: dataset[%s] has fewer " - "elements on disk (%lld) than are selected " - "(%lld).", - name2, (long long)ndisk, (long long)nread ); + "Ignoring view: dataset[%s] has fewer " + "elements on disk (%lld) than are selected " + "(%lld).", + name2, (long long)ndisk, (long long)nread ); nread = ndisk; } } else { @@ -61,7 +60,7 @@ h5u_read_data ( } if (u->memshape != H5S_ALL) { - TRY( nmem = h5priv_get_npoints_of_hdf5_dataspace(f, u->memshape) ); + TRY (nmem = hdf5_get_npoints_of_dataspace (u->memshape)); /* make sure the memory space selected by the view has * enough capacity for the read */ @@ -71,31 +70,33 @@ h5u_read_data ( /* the view selection is too small? * fall back to using H5S_ALL */ h5_warn ( - f, - "Ignoring view: dataset[%s] has more " - "elements selected (%lld) than are available " - "in memory (%lld).", - name2, (long long)nread, (long long)nmem ); + "Ignoring view: dataset[%s] has more " + "elements selected (%lld) than are available " + "in memory (%lld).", + name2, (long long)nread, (long long)nmem ); memspace_id = H5S_ALL; } } - - TRY( h5priv_read_hdf5_dataset ( - f, - dataset_id, - type, - memspace_id, - space_id, - f->xfer_prop, - data ) ); - - if ( space_id != f->u->diskshape ) { - TRY( h5priv_close_hdf5_dataspace( f, space_id ) ); +#ifdef PARALLEL_IO + TRY (h5_start_throttle (f)); +#endif + TRY (hdf5_read_dataset ( + dataset_id, + type, + memspace_id, + space_id, + f->xfer_prop, + data )); +#ifdef PARALLEL_IO + TRY (h5_end_throttle (f)); +#endif + if (space_id != f->u->diskshape) { + TRY (hdf5_close_dataspace (space_id)); } - TRY( h5priv_close_hdf5_dataset ( f, dataset_id ) ); + TRY (hdf5_close_dataset (dataset_id)); - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t @@ -105,7 +106,7 @@ h5u_write_data ( const void *data, /*!< IN: Array to commit to disk */ const hid_t type /*!< IN: Type of data */ ) { - + H5_CORE_API_ENTER (h5_err_t); CHECK_TIMEGROUP( f ); CHECK_WRITABLE_MODE( f ); @@ -113,10 +114,10 @@ h5u_write_data ( hid_t dset_id; char name2[H5_DATANAME_LEN]; - TRY ( h5_normalize_dataset_name (f, name, name2) ); + TRY (h5_normalize_dataset_name (f, name, name2)); if ( u->shape == H5S_ALL ) - h5_warn(f, "The view is unset or invalid."); + h5_warn("The view is unset or invalid."); /* test for existing dataset */ H5E_BEGIN_TRY @@ -124,34 +125,36 @@ h5u_write_data ( H5E_END_TRY if (dset_id > 0) { - h5_warn( f, - "Dataset %s/%s already exists", + h5_warn("Dataset %s/%s already exists", h5_get_objname(f->step_gid), name2); } else { - TRY( dset_id = h5priv_create_hdf5_dataset ( - f, - f->step_gid, - name2, - type, - u->shape, - H5P_DEFAULT) ); + TRY (dset_id = hdf5_create_dataset ( + f->step_gid, + name2, + type, + u->shape, + H5P_DEFAULT)); } - h5_info (f, - "Writing dataset %s/%s.", +#ifdef PARALLEL_IO + TRY (h5_start_throttle (f)); +#endif + h5_info ("Writing dataset %s/%s.", h5_get_objname(f->step_gid), name2); - TRY( h5priv_write_hdf5_dataset ( - f, + TRY (hdf5_write_dataset ( dset_id, type, u->memshape, u->diskshape, f->xfer_prop, - data) ); - TRY( h5priv_close_hdf5_dataset (f, dset_id) ); + data)); +#ifdef PARALLEL_IO + TRY (h5_end_throttle (f)); +#endif + TRY (hdf5_close_dataset (dset_id)); f->empty = 0; - return H5_SUCCESS; + H5_CORE_API_RETURN (H5_SUCCESS); } diff --git a/src/include/H5.h b/src/include/H5.h index f11ba6c..4db566a 100644 --- a/src/include/H5.h +++ b/src/include/H5.h @@ -107,14 +107,12 @@ H5GetErrorHandler ( h5_err_t H5ReportErrorhandler ( - const h5_file_t * const f, const char *fmt, va_list ap ); h5_err_t H5AbortErrorhandler ( - const h5_file_t * const f, const char *fmt, va_list ap ); diff --git a/src/include/h5core/h5_core.h b/src/include/h5core/h5_core.h index f929f8d..24d9c6d 100644 --- a/src/include/h5core/h5_core.h +++ b/src/include/h5core/h5_core.h @@ -3,14 +3,127 @@ #define UNUSED_ARGUMENT(x) (void)x -#define TRY( func ) \ - if ((int64_t)(ptrdiff_t)(func) <= (int64_t)H5_ERR) \ - return H5_ERR; \ +#define H5_DEBUG_USER (1<<2) +#define H5_DEBUG_API (1<<3) +#define H5_DEBUG_CORE_API (1<<4) +#define H5_DEBUG_PRIV_API (1<<5) +#define H5_DEBUG_PRIV_FUNC (1<<6) +#define H5_DEBUG_HDF5 (1<<7) +#define H5_DEBUG_MALLOC (1<<8) +#define H5_DEBUG_CLIB (1<<9) +#define H5_DEBUG_ALL (-1) -#define TRY2( func ) \ - if ((int64_t)(ptrdiff_t)(func) <= (int64_t)H5_ERR) \ - goto done; \ +extern char* h5_rfmts[]; +#define __FUNC_ENTER(type) \ + h5_call_stack_push (__func__,e_##type); \ + type ret_value = (type)H5_ERR; +#define __FUNC_ARGS0(mask) \ + if (h5_debug_level & mask ) { \ + h5_debug ("(void)"); \ + } + +#define __FUNC_ARGS1(fmt, a1, mask) \ + if (h5_debug_level & mask ) { \ + h5_debug ("(" fmt ")", a1); \ + } + +#define __FUNC_ARGS2(fmt, a1, a2, mask) \ + if (h5_debug_level & mask ) { \ + h5_debug ("(" fmt ")", a1, a2); \ + } + +#define __FUNC_ARGS3(fmt, a1, a2, a3, mask) \ + if (h5_debug_level & mask ) { \ + h5_debug ("(" fmt ")", a1, a2, a3); \ + } + +#define __FUNC_ARGS4(fmt, a1, a2, a3, a4, mask) \ + if (h5_debug_level & mask ) { \ + h5_debug ("(" fmt ")", a1, a2, a3, a4); \ + } + +#define __FUNC_ARGS5(fmt, a1, a2, a3, a4, a5, mask) \ + if (h5_debug_level & mask ) { \ + h5_debug ("(" fmt ")", a1, a2, a3, a4, a5); \ + } + +#define __FUNC_ENTER0(type, mask) \ + __FUNC_ENTER(type); \ + __FUNC_ARGS0(mask); + +#define __FUNC_ENTER1(type, fmt, a1, mask) \ + __FUNC_ENTER(type); \ + __FUNC_ARGS1(fmt, a1, mask); + +#define __FUNC_ENTER2(type, fmt, a1, a2, mask) \ + __FUNC_ENTER(type); \ + __FUNC_ARGS2(fmt, a1, a2, mask); + +#define __FUNC_ENTER3(type, fmt, a1, a2, a3, mask) \ + __FUNC_ENTER(type); \ + __FUNC_ARGS3(fmt, a1, a2, a3, mask); + +#define __FUNC_ENTER4(type, fmt, a1, a2, a3, a4, mask) \ + __FUNC_ENTER(type); \ + __FUNC_ARGS4(fmt, a1, a2, a3, a4, mask); + +#define __FUNC_ENTER5(type, fmt, a1, a2, a3, a4, a5, mask) \ + __FUNC_ENTER(type); \ + __FUNC_ARGS5(fmt, a1, a2, a3, a4, a5, mask); + +#define __FUNC_LEAVE(expr) { \ + ret_value = expr; \ + goto done; \ +} + +#define __FUNC_RETURN(expr, mask) \ + ret_value = expr; \ + goto done; \ +done: \ + if (h5_debug_level & mask ) { \ + char fmt[256]; \ + snprintf (fmt, sizeof(fmt), "return: %s", \ + h5_rfmts[h5_call_stack_get_type()]); \ + h5_debug (fmt, ret_value); \ + } \ + h5_call_stack_pop(); \ + return ret_value; + + +#define H5_API_ENTER(type) \ + if (!h5_initialized) { \ + h5_initialize(); \ + } \ + __FUNC_ENTER(type); + +#define H5_API_ENTER1(type, fmt, a1) \ + H5_API_ENTER(type); \ + __FUNC_ARGS1(fmt, a1, H5_DEBUG_API) + +#define H5_API_ENTER2(type, fmt, a1, a2) \ + H5_API_ENTER(type); \ + __FUNC_ARGS2(fmt, a1,a2, H5_DEBUG_API) + +#define H5_API_ENTER3(type, fmt, a1, a2, a3) \ + H5_API_ENTER(type); \ + __FUNC_ARGS3(fmt, a1,a2,a3, H5_DEBUG_API) + +#define H5_API_LEAVE(expr) __FUNC_LEAVE(expr) +#define H5_API_RETURN(expr) __FUNC_RETURN(expr, H5_DEBUG_API); + + +#define TRY( func ) \ + if ((int64_t)(ptrdiff_t)(func) <= (int64_t)H5_ERR) { \ + ret_value = H5_ERR; \ + goto done; \ + } + +#define TRY2( func ) \ + if ((int64_t)(ptrdiff_t)(func) <= (int64_t)H5_ERR) { \ + ret_value = (void*) H5_ERR; \ + goto done; \ + } #include "h5_types.h" #include "h5_errno.h" diff --git a/src/include/h5core/h5_errorhandling.h b/src/include/h5core/h5_errorhandling.h index 639939f..48af9ca 100644 --- a/src/include/h5core/h5_errorhandling.h +++ b/src/include/h5core/h5_errorhandling.h @@ -1,44 +1,77 @@ #ifndef __H5_ERRORHANDLING_H #define __H5_ERRORHANDLING_H -extern h5_int32_t h5priv_debug_level; +enum h5_rtypes { + e_int = 0, + e_ssize_t, + e_char_p, + e_void_p, + e_h5_err_t, + e_h5_int64_t, + e_h5_id_t, + e_h5_ssize_t, + e_h5_errorhandler_t, + e_h5_file_p, + e_h5t_lvl_idx_t, + e_h5t_iterator_p, + e_h5_loc_id_t, + e_h5_loc_idx_t, + e_hid_t, + e_H5O_type_t, + e_herr_t +}; + +struct call_stack_entry { + char* name; + enum h5_rtypes type; +}; + +struct call_stack { + int level; + struct call_stack_entry entry[1024]; +}; + +extern h5_int32_t h5_debug_level; +extern int h5_initialized; +extern struct call_stack h5_call_stack; +extern h5_err_t h5_errno; + +void +h5_initialize ( + void + ); #define CHECK_FILEHANDLE( f ) \ if ( h5_check_filehandle ( f ) != H5_SUCCESS ) \ - return h5_get_errno( f ); + return h5_get_errno(); #define CHECK_WRITABLE_MODE( f ) \ if ( f->mode==H5_O_RDONLY ) \ return h5_error ( \ - f, \ H5_ERR_INVAL, \ "Attempting to write to read-only file" ); #define CHECK_READONLY_MODE( f ) \ if ( ! f->mode==H5_O_RDONLY ) \ return h5_error ( \ - f, \ H5_ERR_INVAL, \ "Operation is not allowed on writable files." ); #define CHECK_TIMEGROUP( f ) \ if ( f->step_gid <= 0 ) \ return h5_error ( \ - f, \ H5_ERR_INVAL, \ "Time step is invalid! Have you set the time step?"); -#define h5_error_not_implemented( f, file, func, lino ) \ +#define h5_error_not_implemented( file, func, lino ) \ h5_error( \ - f, \ H5_ERR_NOT_IMPLEMENTED, \ "%s: Function \"%s\", line %d not yet implemented!", \ file, func, lino ); -#define h5_error_internal( f, file, func, lino ) \ +#define h5_error_internal( file, func, lino ) \ h5_error( \ - f, \ H5_ERR_INTERNAL, \ "%s: Internal error: %s line %d!", \ file, func, lino ) @@ -66,25 +99,85 @@ h5_get_errorhandler ( h5_err_t h5_get_errno ( - const h5_file_t * const f + void ); void h5_set_errno ( - h5_file_t * const f, const h5_err_t h5_errno ); +static inline void +h5_call_stack_init ( + const char* fname, + enum h5_rtypes type + ) { + h5_call_stack.level = 0; + h5_call_stack.entry[0].name = (char *)fname; + h5_call_stack.entry[0].type = type; +} + +static inline void +h5_call_stack_push ( + const char* fname, + enum h5_rtypes type + ) { + h5_call_stack.entry[h5_call_stack.level].name = (char *)fname; + h5_call_stack.entry[h5_call_stack.level].type = type; + h5_call_stack.level++; +} + +static inline const char* +h5_call_stack_pop ( + void + ) { + return h5_call_stack.entry[--h5_call_stack.level].name; +} + +static inline const char* +h5_call_stack_get_name ( + void + ) { + return h5_call_stack.entry[h5_call_stack.level-1].name; +} + +static inline const char* +h5_get_funcname ( + void + ) { + return h5_call_stack.entry[0].name; +} + +static inline enum h5_rtypes +h5_call_stack_get_type ( + void + ) { + return h5_call_stack.entry[h5_call_stack.level-1].type; +} + +static inline int +h5_call_stack_get_level ( + void + ) { + return h5_call_stack.level; +} + +static inline const char* +h5_call_stack_reset ( + void + ) { + h5_call_stack.level = 0; + return h5_call_stack.entry[0].name; +} + h5_err_t h5_report_errorhandler ( - const h5_file_t * const f, const char *fmt, va_list ap ); h5_err_t h5_abort_errorhandler ( - const h5_file_t * const f, const char *fmt, va_list ap ); @@ -98,27 +191,19 @@ h5priv_vprintf ( va_list ap ); -const char * -h5_get_funcname ( - const h5_file_t * const f - ); - - h5_err_t h5_error ( - h5_file_t * const f, const h5_err_t error_no, const char *fmt, ... ) #ifdef __GNUC__ - __attribute__ ((format (printf, 3, 4))) + __attribute__ ((format (printf, 2, 3))) #endif ; void h5_verror ( - const h5_file_t* const f, const char* fmt, va_list ap ); @@ -129,28 +214,27 @@ h5_verror ( Print a warning message to \c stderr. */ -static inline void +static inline h5_err_t h5_warn ( - const h5_file_t * const f, const char *fmt, ... ) #ifdef __GNUC__ -__attribute__ ((format (printf, 2, 3))) +__attribute__ ((format (printf, 1, 2))) #endif ; -static inline void +static inline h5_err_t h5_warn ( - const h5_file_t* const f, const char* fmt, ... ) { - if (h5priv_debug_level >= 2) { + if (h5_debug_level >= 2) { va_list ap; va_start (ap, fmt); - h5priv_vprintf (stderr, "W", h5_get_funcname(f), fmt, ap); + h5priv_vprintf (stderr, "W", h5_get_funcname(), fmt, ap); va_end (ap); } + return H5_NOK; } /*! @@ -160,24 +244,22 @@ h5_warn ( */ static inline void h5_info ( - const h5_file_t * const f, const char *fmt, ... ) #ifdef __GNUC__ -__attribute__ ((format (printf, 2, 3))) +__attribute__ ((format (printf, 1, 2))) #endif ; static inline void h5_info ( - const h5_file_t* const f, const char* fmt, ... ) { - if (h5priv_debug_level >= 3) { + if (h5_debug_level >= 3) { va_list ap; va_start (ap, fmt); - h5priv_vprintf (stdout, "I", h5_get_funcname(f), fmt, ap); + h5priv_vprintf (stdout, "I", h5_get_funcname(), fmt, ap); va_end (ap); } } @@ -187,53 +269,32 @@ h5_info ( Print a debug message to \c stdout. */ -#if defined(HAVE__VA_ARGS__) -#define h5_debug(f, ...) \ - if (h5priv_debug_level >= 4) { \ - h5priv_vprintf (stdout, "D", h5_get_funcname(f), __VA_ARGS__); \ - } -#else static inline void h5_debug ( - const h5_file_t * const f, const char *fmt, ... ) #ifdef __GNUC__ -__attribute__ ((format (printf, 2, 3))) +__attribute__ ((format (printf, 1, 2))) #endif ; static inline void h5_debug ( - const h5_file_t * const f, const char *fmt, ... ) { - if (h5priv_debug_level >= 4) { + if (h5_debug_level >= 4) { + char prefix[256]; + snprintf (prefix, sizeof(prefix), "(%d) %s", + h5_call_stack_get_level(), + h5_call_stack_get_name()); va_list ap; va_start (ap, fmt); - h5priv_vprintf (stdout, "D", h5_get_funcname(f), fmt, ap); + h5priv_vprintf (stdout, "D", prefix, fmt, ap); va_end (ap); } } -#endif - -void -h5_set_funcname ( - h5_file_t * const f, - const char * const fname - ); - -#define H5_API_ENTER { \ - h5_set_funcname( f, __func__ ); \ - h5_debug (f, "%s", " "); \ - } \ - -#define H5_API_RETURN(retval) \ - \ - goto done; \ - done: \ - return retval; \ - + + #endif diff --git a/src/include/h5core/h5_hdf5.h b/src/include/h5core/h5_hdf5.h index ac359a4..43403a5 100644 --- a/src/include/h5core/h5_hdf5.h +++ b/src/include/h5core/h5_hdf5.h @@ -3,20 +3,17 @@ ssize_t h5_get_num_hdf5_groups ( - h5_file_t* const f, const hid_t loc_id ); ssize_t h5_get_num_hdf5_groups_matching_prefix ( - h5_file_t* const f, const hid_t loc_id, char* prefix ); h5_err_t h5_get_hdf5_groupname_by_idx ( - h5_file_t* const f, hid_t loc_id, hsize_t idx, char *name, @@ -25,13 +22,11 @@ h5_get_hdf5_groupname_by_idx ( ssize_t h5_get_num_hdf5_datasets ( - h5_file_t* const f, const hid_t loc_id ); h5_err_t h5_get_hdf5_datasetname_by_idx ( - h5_file_t* const f, hid_t loc_id, hsize_t idx, char *name, diff --git a/src/include/h5core/h5_openclose.h b/src/include/h5core/h5_openclose.h index ac0b6d3..dc2a92b 100644 --- a/src/include/h5core/h5_openclose.h +++ b/src/include/h5core/h5_openclose.h @@ -5,8 +5,7 @@ h5_file_t * h5_open_file ( const char *filename, h5_int32_t flags, - MPI_Comm comm, - const char *funcname + MPI_Comm comm ); h5_int64_t diff --git a/src/include/h5core/h5_syscall.h b/src/include/h5core/h5_syscall.h index 301d059..1e998bd 100644 --- a/src/include/h5core/h5_syscall.h +++ b/src/include/h5core/h5_syscall.h @@ -3,21 +3,18 @@ void* h5_alloc ( - h5_file_t* const f, void* ptr, const size_t size ); void* h5_calloc ( - h5_file_t* const f, const size_t count, const size_t size ); h5_err_t h5_free ( - h5_file_t* const f, void* ptr ); #endif diff --git a/src/include/h5core/h5_types.h b/src/include/h5core/h5_types.h index 50715cf..5152a60 100644 --- a/src/include/h5core/h5_types.h +++ b/src/include/h5core/h5_types.h @@ -51,6 +51,8 @@ typedef uint64_t h5_size_t; /* size in number of elements */ typedef int64_t h5_ssize_t; /* size in number of elements */ typedef int64_t h5_err_t; +typedef char* char_p; +typedef void* void_p; typedef double h5_float64_t; typedef float h5_float32_t; @@ -62,15 +64,15 @@ typedef h5_float64_t h5_coord3d_t[3]; struct h5_file; typedef struct h5_file h5_file_t; +typedef h5_file_t* h5_file_p; typedef h5_err_t (*h5_errorhandler_t)( - const h5_file_t * const, const char*, va_list ap ); #ifndef PARALLEL_IO -typedef unsigned long MPI_Comm; -typedef unsigned long MPI_Datatype; +typedef int MPI_Comm; +typedef int MPI_Datatype; #endif typedef struct h5_loc_idlist { diff --git a/src/include/h5core/h5t_inquiry.h b/src/include/h5core/h5t_inquiry.h index 631289d..2e45d0c 100644 --- a/src/include/h5core/h5t_inquiry.h +++ b/src/include/h5core/h5t_inquiry.h @@ -1,24 +1,24 @@ #ifndef __H5T_INQUIRY_H #define __H5T_INQUIRY_H -h5_size_t +h5_ssize_t h5t_get_num_meshes ( h5_file_t * const f, const enum h5_oid type ); -h5_size_t +h5_ssize_t h5t_get_num_leaf_levels ( h5_file_t * const f ); -h5_size_t +h5_ssize_t h5t_get_num_elems ( h5_file_t * const f, const h5_id_t cnode ); -h5_size_t +h5_ssize_t h5t_get_num_vertices ( h5_file_t * const f, const h5_id_t cnode diff --git a/src/include/h5core/h5t_retrieve.h b/src/include/h5core/h5t_retrieve.h index d8769ef..32750c1 100644 --- a/src/include/h5core/h5t_retrieve.h +++ b/src/include/h5core/h5t_retrieve.h @@ -45,6 +45,7 @@ typedef union h5t_iterator { h5t_generic_iterator_t generic; } h5t_iterator_t; +typedef h5t_iterator_t* h5t_iterator_p; h5_err_t h5t_init_leaf_iterator ( diff --git a/test/H5Fed/tetmesh_read_tags.c b/test/H5Fed/tetmesh_read_tags.c index 2121523..9ce2ed1 100644 --- a/test/H5Fed/tetmesh_read_tags.c +++ b/test/H5Fed/tetmesh_read_tags.c @@ -34,7 +34,7 @@ traverse_vertices ( h5t_iterator_t* iter = H5FedBeginTraverseEntities (f, 3 ); while ( (real_num < num) && ((local_id = H5FedTraverseEntities (f, iter)) >= 0) ) { - size_t size; + size_t size = 3; h5_int64_t retval[3]; H5FedGetMTag ( f, "testtag", local_id, &size, retval ); if ( (retval[0] != local_id) ||