diff --git a/src/h5core/h5t_openclose.c b/src/h5core/h5t_openclose.c index c9e9e27..a5f67aa 100644 --- a/src/h5core/h5t_openclose.c +++ b/src/h5core/h5t_openclose.c @@ -20,10 +20,10 @@ static struct h5t_methods tri_funcs = { */ static h5_err_t _create_array_types ( - h5_file_t * f + h5_file_t* const f ) { - h5t_fdata_t *t = f->t; - h5_dtypes_t *dtypes = &(t->dtypes); + h5t_fdata_t* t = f->t; + h5_dtypes_t* dtypes = &(t->dtypes); hsize_t dims[1] = { 3 }; TRY( @@ -31,14 +31,14 @@ _create_array_types ( f, H5_FLOAT64_T, 1, - dims ) + dims) ); TRY( dtypes->h5_3id_t = h5priv_create_hdf5_array_type ( f, H5_ID_T, 1, - dims ) + dims) ); dims[0] = 4; TRY( @@ -46,7 +46,7 @@ _create_array_types ( f, H5_ID_T, 1, - dims ) + dims) ); return H5_SUCCESS; @@ -54,144 +54,144 @@ _create_array_types ( static h5_err_t _create_vertex_type ( - h5_file_t * f + h5_file_t* const f ) { - h5_dtypes_t *dtypes = &f->t->dtypes; + h5_dtypes_t* dtypes = &f->t->dtypes; TRY( dtypes->h5_vertex_t = h5priv_create_hdf5_type ( f, H5_COMPOUND_T, - sizeof(struct h5_vertex) ) ); + sizeof (struct h5_vertex)) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_vertex_t, "global_vid", - HOFFSET(struct h5_vertex, global_vid), - H5_ID_T ) ); + HOFFSET (struct h5_vertex, global_vid), + H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_vertex_t, "P", - HOFFSET(struct h5_vertex, P), - dtypes->h5_coord3d_t ) ); + HOFFSET (struct h5_vertex, P), + dtypes->h5_coord3d_t) ); return H5_SUCCESS; } static h5_err_t _create_triangle_type ( - h5_file_t * f + h5_file_t* const f ) { - h5_dtypes_t *dtypes = &f->t->dtypes; + h5_dtypes_t* dtypes = &f->t->dtypes; TRY( dtypes->h5_triangle_t = h5priv_create_hdf5_type ( f, H5_COMPOUND_T, - sizeof(struct h5_triangle) ) ); + sizeof (struct h5_triangle)) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, "global_eid", - HOFFSET(struct h5_triangle, global_eid), - H5_ID_T ) ); + HOFFSET (struct h5_triangle, global_eid), + H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, "global_parent_eid", - HOFFSET(struct h5_triangle, global_parent_eid), - H5_ID_T ) ); + HOFFSET (struct h5_triangle, global_parent_eid), + H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, "global_child_eid", HOFFSET(struct h5_triangle, global_child_eid), - H5_ID_T ) ); + H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, "global_vids", - HOFFSET(struct h5_triangle, global_vids), - dtypes->h5_3id_t ) ); + HOFFSET (struct h5_triangle, global_vids), + dtypes->h5_3id_t) ); return H5_SUCCESS; } static h5_err_t _create_tag_types ( - h5_file_t * f + h5_file_t* const f ) { - h5_dtypes_t *dtypes = &f->t->dtypes; + h5_dtypes_t* dtypes = &f->t->dtypes; TRY ( dtypes->h5t_tag_idx_t = h5priv_create_hdf5_type ( f, H5_COMPOUND_T, - sizeof(h5t_tag_idx_t) ) ); + sizeof (h5t_tag_idx_t)) ); TRY ( h5priv_insert_hdf5_type ( f, dtypes->h5t_tag_idx_t, "eid", - HOFFSET(h5t_tag_idx_t, eid), - H5_ID_T ) ); + HOFFSET (h5t_tag_idx_t, eid), + H5_ID_T) ); TRY ( h5priv_insert_hdf5_type ( f, dtypes->h5t_tag_idx_t, "idx", - HOFFSET(h5t_tag_idx_t, idx), - H5_ID_T ) ); + HOFFSET (h5t_tag_idx_t, idx), + H5_ID_T) ); return H5_SUCCESS; } static h5_err_t _create_tet_type ( - h5_file_t * f + h5_file_t* const f ) { - h5_dtypes_t *dtypes = &f->t->dtypes; + h5_dtypes_t* dtypes = &f->t->dtypes; TRY( dtypes->h5_tet_t = h5priv_create_hdf5_type ( f, H5_COMPOUND_T, - sizeof(struct h5_tetrahedron) ) ); + sizeof (struct h5_tetrahedron)) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, "global_eid", - HOFFSET(struct h5_tetrahedron, global_eid), - H5_ID_T ) ); + HOFFSET (struct h5_tetrahedron, global_eid), + H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, "global_parent_eid", - HOFFSET(struct h5_tetrahedron, global_parent_eid), - H5_ID_T ) ); + HOFFSET (struct h5_tetrahedron, global_parent_eid), + H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, "global_child_eid", - HOFFSET(struct h5_tetrahedron, global_child_eid), - H5T_NATIVE_INT32 ) ); + HOFFSET (struct h5_tetrahedron, global_child_eid), + H5T_NATIVE_INT32) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, "global_vids", - HOFFSET(struct h5_tetrahedron, global_vids), - dtypes->h5_4id_t ) ); + HOFFSET (struct h5_tetrahedron, global_vids), + dtypes->h5_4id_t) ); return H5_SUCCESS; } @@ -200,26 +200,25 @@ _create_tet_type ( #if 0 h5_err_t h5priv_set_dataset_properties ( - h5_dsinfo_t *dsinfo, - const char *name, + h5_dsinfo_t* dsinfo, + const char* name, const hid_t type, const int rank, - const hsize_t *dims, - const hsize_t *maxdims, + const hsize_t* dims, + const hsize_t* maxdims, const hsize_t chunk_dims ) { - return H5_SUCCESS; } #endif static h5_err_t _init_fdata ( - h5_file_t * f + h5_file_t* const f ) { - struct h5t_fdata * t = f->t; + h5t_fdata_t* t = f->t; - memset ( t->mesh_name, 0, sizeof ( t->mesh_name ) ); + memset (t->mesh_name, 0, sizeof (t->mesh_name)); t->num_meshes = -1; t->cur_mesh = -1; t->num_levels = -1; @@ -232,7 +231,7 @@ _init_fdata ( t->mesh_gid = -1; /* vertices */ - strcpy( t->dsinfo_vertices.name, "Vertices" ); + strcpy (t->dsinfo_vertices.name, "Vertices"); t->dsinfo_vertices.rank = 1; t->dsinfo_vertices.dims[0] = 0; t->dsinfo_vertices.max_dims[0] = H5S_UNLIMITED; @@ -240,12 +239,12 @@ _init_fdata ( t->dsinfo_vertices.type_id = t->dtypes.h5_vertex_t; TRY( t->dsinfo_vertices.create_prop = h5priv_create_hdf5_property ( f, - H5P_DATASET_CREATE ) ); + H5P_DATASET_CREATE) ); TRY( h5priv_set_hdf5_chunk_property ( f, t->dsinfo_vertices.create_prop, t->dsinfo_vertices.rank, - t->dsinfo_vertices.chunk_dims ) ); + t->dsinfo_vertices.chunk_dims) ); t->dsinfo_vertices.access_prop = H5P_DEFAULT; /* NumVertices */ @@ -257,32 +256,32 @@ _init_fdata ( t->dsinfo_num_vertices.type_id = t->dtypes.h5_id_t; TRY( t->dsinfo_num_vertices.create_prop = h5priv_create_hdf5_property ( f, - H5P_DATASET_CREATE ) ); + H5P_DATASET_CREATE) ); TRY( h5priv_set_hdf5_chunk_property ( f, t->dsinfo_num_vertices.create_prop, t->dsinfo_num_vertices.rank, - t->dsinfo_num_vertices.chunk_dims ) ); + t->dsinfo_num_vertices.chunk_dims) ); t->dsinfo_num_vertices.access_prop = H5P_DEFAULT; /* Elems */ - strcpy( t->dsinfo_elems.name, "Elems" ); + strcpy (t->dsinfo_elems.name, "Elems"); t->dsinfo_elems.rank = 1; 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, - H5P_DATASET_CREATE ) ); + H5P_DATASET_CREATE) ); TRY( h5priv_set_hdf5_chunk_property ( f, t->dsinfo_elems.create_prop, t->dsinfo_elems.rank, - t->dsinfo_elems.chunk_dims ) ); + t->dsinfo_elems.chunk_dims) ); t->dsinfo_elems.access_prop = H5P_DEFAULT; /* NumElems */ - strcpy( t->dsinfo_num_elems.name, "NumElems" ); + strcpy (t->dsinfo_num_elems.name, "NumElems"); t->dsinfo_num_elems.rank = 1; t->dsinfo_num_elems.dims[0] = 0; t->dsinfo_num_elems.max_dims[0] = H5S_UNLIMITED; @@ -290,16 +289,16 @@ _init_fdata ( t->dsinfo_num_elems.type_id = t->dtypes.h5_id_t; TRY( t->dsinfo_num_elems.create_prop = h5priv_create_hdf5_property ( f, - H5P_DATASET_CREATE ) ); + H5P_DATASET_CREATE) ); TRY( h5priv_set_hdf5_chunk_property ( f, t->dsinfo_num_elems.create_prop, t->dsinfo_num_elems.rank, - t->dsinfo_num_elems.chunk_dims ) ); + t->dsinfo_num_elems.chunk_dims) ); t->dsinfo_num_elems.access_prop = H5P_DEFAULT; /* NumElemsOnLevel */ - strcpy( t->dsinfo_num_elems_on_level.name, "NumElemsOnLevel" ); + strcpy (t->dsinfo_num_elems_on_level.name, "NumElemsOnLevel"); t->dsinfo_num_elems_on_level.rank = 1; t->dsinfo_num_elems_on_level.dims[0] = 0; t->dsinfo_num_elems_on_level.max_dims[0] = H5S_UNLIMITED; @@ -307,12 +306,12 @@ _init_fdata ( t->dsinfo_num_elems_on_level.type_id = t->dtypes.h5_id_t; TRY( t->dsinfo_num_elems_on_level.create_prop = h5priv_create_hdf5_property ( f, - H5P_DATASET_CREATE ) ); + H5P_DATASET_CREATE) ); TRY( h5priv_set_hdf5_chunk_property ( f, t->dsinfo_num_elems_on_level.create_prop, t->dsinfo_num_elems_on_level.rank, - t->dsinfo_num_elems_on_level.chunk_dims ) ); + t->dsinfo_num_elems_on_level.chunk_dims) ); t->dsinfo_num_elems_on_level.access_prop = H5P_DEFAULT; return H5_SUCCESS; @@ -330,22 +329,22 @@ _init_fdata ( */ h5_err_t h5tpriv_open_file ( - h5_file_t * f /*!< IN: file handle */ + h5_file_t* const f /*!< IN: file handle */ ) { - TRY( (f->t = h5priv_alloc ( f, NULL, sizeof(*f->t) ) ) ); - h5t_fdata_t *t = f->t; + TRY( (f->t = h5priv_alloc (f, NULL, sizeof (*f->t))) ); + h5t_fdata_t* t = f->t; t->dtypes.h5_id_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 ) ); + 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; } @@ -362,18 +361,17 @@ h5tpriv_open_file ( */ h5_err_t h5tpriv_close_file ( - h5_file_t *f /*!< IN: file handle */ + h5_file_t* const f /*!< IN: file handle */ ) { - TRY ( h5t_close_mesh ( f ) ); + TRY( h5t_close_mesh (f) ); return H5_SUCCESS; } h5_err_t h5tpriv_init_step ( - h5_file_t * const f + h5_file_t* const f ) { - return H5_SUCCESS; } @@ -384,7 +382,7 @@ h5tpriv_init_step ( */ h5_err_t h5tpriv_close_step ( - h5_file_t * f + h5_file_t* const f ) { return H5_SUCCESS; @@ -395,42 +393,42 @@ h5_err_t h5tpriv_open_topo_group ( h5_file_t * const f ) { - struct h5t_fdata *t = f->t; + h5t_fdata_t* t = f->t; - t->topo_gid = h5priv_open_group ( f, f->root_gid, H5T_CONTAINER_GRPNAME ); + t->topo_gid = h5priv_open_group (f, f->root_gid, H5T_CONTAINER_GRPNAME); return t->topo_gid; } h5_err_t h5tpriv_open_meshes_group ( - h5_file_t * const f + h5_file_t* const f ) { - h5t_fdata_t *t = f->t; + h5t_fdata_t* t = f->t; - if ( t->topo_gid < 0 ) { - TRY ( h5tpriv_open_topo_group ( f ) ); + if (t->topo_gid < 0) { + TRY( h5tpriv_open_topo_group (f) ); } - TRY ( (t->meshes_gid = h5priv_open_group ( - f, - t->topo_gid, - h5tpriv_meshes_grpnames[t->mesh_type] ) ) ); + TRY( (t->meshes_gid = h5priv_open_group ( + f, + t->topo_gid, + h5tpriv_meshes_grpnames[t->mesh_type])) ); return H5_SUCCESS; } h5_err_t h5tpriv_open_mesh_group ( - h5_file_t * const f + h5_file_t* const f ) { - h5t_fdata_t *t = f->t; + h5t_fdata_t* t = f->t; - if ( t->meshes_gid < 0 ) { - TRY ( h5tpriv_open_meshes_group ( f ) ); + if (t->meshes_gid < 0) { + TRY( h5tpriv_open_meshes_group (f) ); } - TRY ( ( t->mesh_gid = h5priv_open_group ( - f, - t->meshes_gid, - t->mesh_name ) ) ); + TRY( (t->mesh_gid = h5priv_open_group ( + f, + t->meshes_gid, + t->mesh_name)) ); return H5_SUCCESS; } @@ -439,28 +437,28 @@ h5tpriv_open_mesh_group ( */ h5_err_t h5t_open_mesh ( - h5_file_t * const f, + h5_file_t* const f, h5_id_t id, const h5_oid_t type ) { - h5t_fdata_t *t = f->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 ); - t->num_meshes = ( result > 0 ? result : 0 ); + if (t->num_meshes < 0) { + h5_size_t result = h5t_get_num_meshes (f, type); + t->num_meshes = (result > 0 ? result : 0); } - if ( (id < -1) || (id >= t->num_meshes) ) { - return HANDLE_H5_OUT_OF_RANGE_ERR( f, "mesh", id ); + if ((id < -1) || (id >= t->num_meshes)) { + return HANDLE_H5_OUT_OF_RANGE_ERR (f, "mesh", id); } - if ( id == -1 ) { /* append new mesh */ + if (id == -1) { /* append new mesh */ id = t->num_meshes; } t->mesh_type = type; - snprintf ( t->mesh_name, sizeof (t->mesh_name), "%lld", id ); + snprintf (t->mesh_name, sizeof (t->mesh_name), "%lld", id); - switch( type ) { + switch (type) { case H5_OID_TETRAHEDRON: t->dsinfo_elems.type_id = t->dtypes.h5_tet_t; t->methods = tet_funcs; @@ -472,15 +470,15 @@ h5t_open_mesh ( t->ref_element = &h5t_tri_ref_element; break; default: - return h5_error_internal ( f, __FILE__, __func__, __LINE__ ); + return h5_error_internal (f, __FILE__, __func__, __LINE__); } - TRY( h5tpriv_open_mesh_group ( f ) ); + TRY( h5tpriv_open_mesh_group (f) ); t->cur_mesh = id; - if ( id != t->num_meshes ) { /* open existing */ - TRY ( h5tpriv_read_mesh ( f ) ); + if (id != t->num_meshes) { /* open existing */ + TRY( h5tpriv_read_mesh (f) ); } else { /* append new */ t->num_meshes++; @@ -491,30 +489,29 @@ h5t_open_mesh ( return H5_SUCCESS; } - static h5_err_t _release_elems ( - h5_file_t * const f + h5_file_t* const f ) { - h5t_fdata_t *t = f->t; - TRY ( h5priv_free ( f, t->elems.data ) ); - TRY( h5priv_free ( f, t->num_elems ) ); - TRY ( h5priv_free ( f, t->elems_ldta ) ); - TRY ( h5priv_free ( f, t->num_elems_on_level ) ); - TRY ( h5priv_free ( f, t->map_elem_g2l.items ) ); + h5t_fdata_t* t = f->t; + TRY( h5priv_free (f, t->elems.data) ); + TRY( h5priv_free (f, t->num_elems) ); + TRY( h5priv_free (f, t->elems_ldta) ); + TRY( h5priv_free (f, t->num_elems_on_level) ); + TRY( h5priv_free (f, t->map_elem_g2l.items) ); return H5_SUCCESS; } static h5_err_t _release_vertices ( - h5_file_t * const f + h5_file_t* const f ) { - h5t_fdata_t *t = f->t; - TRY ( h5priv_free ( f, t->vertices ) ); - TRY ( h5priv_free ( f, t->vertices_data ) ); - TRY ( h5priv_free ( f, t->num_vertices ) ); - TRY ( h5priv_free ( f, t->map_vertex_g2l.items ) ); + h5t_fdata_t* t = f->t; + TRY( h5priv_free (f, t->vertices) ); + TRY( h5priv_free (f, t->vertices_data) ); + TRY( h5priv_free (f, t->num_vertices) ); + TRY( h5priv_free (f, t->map_vertex_g2l.items) ); return H5_SUCCESS; } @@ -535,51 +532,42 @@ _release_memory ( h5_err_t h5t_close_mesh ( - h5_file_t * const f + h5_file_t* const f ) { - TRY( h5tpriv_write_mesh ( f ) ); - TRY( _release_memory ( f ) ); - TRY( _init_fdata ( f ) ); + TRY( h5tpriv_write_mesh (f) ); + TRY( _release_memory (f) ); + TRY( _init_fdata (f) ); return H5_SUCCESS; } h5_err_t h5t_open_level ( - h5_file_t * const f, + h5_file_t* const f, const h5_id_t id ) { - struct h5t_fdata *t = f->t; + h5t_fdata_t* t = f->t; - if ( (id < 0) || (id >= t->num_levels) ) - return HANDLE_H5_OUT_OF_RANGE_ERR ( f, "Level", id ); + if ((id < 0) || (id >= t->num_levels)) + return HANDLE_H5_OUT_OF_RANGE_ERR (f, "Level", id); t->cur_level = id; return H5_SUCCESS; } -herr_t -h5priv_set_hdf5_chunk_property ( - h5_file_t * const f, - hid_t plist, - int ndims, - const hsize_t * dim - ); - - h5_err_t h5tpriv_alloc_num_vertices ( - h5_file_t * const f, + h5_file_t* const f, const h5_size_t num_vertices ) { - h5t_fdata_t *t = f->t; + h5t_fdata_t* t = f->t; - ssize_t size = num_vertices * sizeof ( t->vertices[0] ); - TRY ( t->vertices = h5priv_alloc ( f, t->vertices, size ) ); - size = num_vertices * sizeof ( t->vertices_data[0] ); - TRY ( t->vertices_data = h5priv_alloc ( f, t->vertices_data, size ) ); - TRY( h5priv_alloc_idmap ( f, &t->map_vertex_g2l, num_vertices ) ); - TRY( h5priv_alloc_idlist_items ( f, &t->sorted_lvertices, num_vertices ) ); + ssize_t size = num_vertices * sizeof (t->vertices[0]); + TRY( t->vertices = h5priv_alloc (f, t->vertices, size) ); + size = num_vertices * sizeof (t->vertices_data[0]); + TRY( t->vertices_data = h5priv_alloc (f, t->vertices_data, size) ); + TRY( h5priv_alloc_idmap (f, &t->map_vertex_g2l, num_vertices) ); + TRY( h5priv_alloc_idlist_items (f, &t->sorted_lvertices, num_vertices) ); return H5_SUCCESS; }