diff --git a/.gitattributes b/.gitattributes index 4b527c0..e1e7ba1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -358,6 +358,7 @@ src/H5Fed_map.c -text src/H5Fed_map.h -text src/H5Fed_retrieve.c -text src/H5Fed_store.c -text +src/H5Fed_store.h -text src/H5Part.c -text src/H5Part.h -text src/H5_inquiry.c -text diff --git a/src/H5.c b/src/H5.c index 08e2adc..24e1b7e 100644 --- a/src/H5.c +++ b/src/H5.c @@ -31,12 +31,9 @@ */ -/*! - \defgroup h5_c_api H5Fed C API -*/ /*! \ingroup h5_c_api - \defgroup h5_general + \defgroup h5_c_api_general */ @@ -48,7 +45,7 @@ /****** General routines *****************************************************/ /*! - \ingroup h5_general + \ingroup h5_c_api_general Open file with name \c filename. This function is available in the paralell and serial version. In the serial case \c comm may have any value. @@ -62,52 +59,51 @@ h5_file_t * H5OpenFile ( const char * filename, /*!< file name */ + const h5_int32_t oflag, /*!< file open flags */ const MPI_Comm comm /*!< MPI communicator */ ) { - SET_FNAME ( __func__ ); - return h5_open_file( filename, H5_O_RDWR, comm ); + + return h5_open_file( filename, H5_O_RDWR, comm, __func__ ); } /*! - \ingroup h5_general + \ingroup h5_c_api_general Close file. - \return value \c >=0 on success - \return -1 on error + \return \c H5_SUCCESS or error code */ h5_err_t H5CloseFile ( - h5_file_t * fh /*!< file handle */ + h5_file_t * const f /*!< file handle */ ) { - SET_FNAME ( __func__ ); - return h5_close_file ( fh ); + SET_FNAME ( f, __func__ ); + return h5_close_file ( f ); } /*! - \ingroup h5_general + \ingroup h5_c_api_general Define format of the step names. Example: ==H5FedDefineStepNameFormat( f, "Step", 6 )== defines step names like ==Step#000042==. - \return value \c >=0 on success - \return -1 on error + \return \c H5_SUCCESS or error code */ h5_err_t H5DefineStepNameFormat ( h5_file_t *f, /*!< Handle to file */ const char *name, /*!< Prefix */ - const h5_int64_t width /*!< Width of the number */ + const h5_int64_t width /*!< Width of the number */ ) { - SET_FNAME ( "H5PartDefineStepNameFormat" ); + SET_FNAME ( f, __func__ ); return h5_define_stepname_fmt( f, name, width ); } /*! - \ingroup h5_general + \ingroup h5_c_api_general Get format of the step names. @@ -121,13 +117,13 @@ H5GetStepNameFormat ( const h5_size_t l_name, /*!< length of buffer name */ h5_size_t *width /*!< OUT: Width of the number */ ) { - SET_FNAME ( "H5PartDefineStepNameFormat" ); + SET_FNAME ( f, __func__ ); return h5_get_stepname_fmt( f, name, l_name, width ); } /*! - \ingroup h5_general + \ingroup h5_c_api_general Set the current step. @@ -139,28 +135,28 @@ H5SetStep ( const h5_int64_t step /*!< [in] Step to set. */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5_set_step ( f, step ); } /*! - \ingroup h5_general + \ingroup h5_c_api_general Get current step. \return \c H5_SUCCESS or error code */ -h5_int64_t +h5_id_t H5GetStep ( h5_file_t *f /*!< Handle to open file */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5_get_step ( f ); } /*! - \ingroup h5_general + \ingroup h5_c_api_general Start traversing steps. @@ -171,13 +167,13 @@ H5StartTraverseSteps ( h5_file_t *f /*!< Handle to open file */ ) { - SET_FNAME ( "H5FedStartTraverseSteps" ); + SET_FNAME ( f, __func__ ); - return -1; + return h5_start_traverse_steps( f ); } /*! - \ingroup h5_general + \ingroup h5_c_api_general Traverse steps. @@ -188,7 +184,7 @@ H5TraverseSteps ( h5_file_t * f /*!< Handle to open file */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); - return -1; + return h5_traverse_steps( f ); } diff --git a/src/H5Block.c b/src/H5Block.c index 12cda26..d4af50c 100644 --- a/src/H5Block.c +++ b/src/H5Block.c @@ -77,16 +77,14 @@ \internal - Normalize partition. - - \e means that the start coordinates are less or equal the - end coordinates. + Normalize partition. In a normalized partition start coordinates are + less or equal end coordinates. */ static void _normalize_partition ( - struct H5BlockPartition *p /*!< IN/OUT: partition */ + struct h5b_partition *p /*!< IN/OUT: partition */ ) { - h5_int64_t x; + h5_size_t x; if ( p->i_start > p->i_end ) { x = p->i_start; @@ -112,29 +110,34 @@ _normalize_partition ( Gather layout to all processors + \par Errors + \c H5_ERR_MPI on MPI errors + \return H5_SUCCESS or error code */ #ifdef PARALLEL_IO -static h5_int64_t +static h5_err_t _allgather ( const h5_file *f /*!< IN: file handle */ ) { - struct H5BlockPartition *partition = &f->block->user_layout[f->myproc]; - struct H5BlockPartition *layout = f->block->user_layout; + struct h5b_partition *partition = &f->block->user_layout[f->myproc]; + struct h5b_partition *layout = f->b->user_layout; MPI_Datatype partition_m; - size_t n = sizeof (struct H5BlockPartition) / sizeof (h5_int64_t); + size_t n = sizeof (struct h5b_partition) / sizeof (h5_size_t); - MPI_Type_contiguous ( n, MPI_LONG_LONG, &partition_m ); - MPI_Type_commit ( &partition_m ); - - MPI_Allgather ( partition, 1, partition_m, layout, 1, partition_m, + int mpi_err = MPI_Type_contiguous ( n, MPI_LONG, &partition_m ); + if ( mpi_err != MPI_SUCCESS ) return H5_ERR_MPI; + mpi_err = MPI_Type_commit ( &partition_m ); + if ( mpi_err != MPI_SUCCESS ) return H5_ERR_MPI; + mpi_err = MPI_Allgather ( partition, 1, partition_m, layout, 1, partition_m, f->comm ); + if ( mpi_err != MPI_SUCCESS ) return H5_ERR_MPI; return H5_SUCCESS; } #else -static h5_int64_t +static h5_err_t _allgather ( const h5_file_t *f /*!< IN: file handle */ ) { @@ -156,8 +159,8 @@ _get_dimension_sizes ( h5_file_t *f /*!< IN: file handle */ ) { int proc; - struct h5b_fdata *b = f->block; - struct H5BlockPartition *partition = b->user_layout; + struct h5b_fdata *b = f->b; + struct h5b_partition *partition = b->user_layout; b->i_max = 0; b->j_max = 0; @@ -186,8 +189,8 @@ _get_dimension_sizes ( */ static int _have_ghostzone ( - const struct H5BlockPartition *p, /*!< IN: partition \c p */ - const struct H5BlockPartition *q /*!< IN: partition \c q */ + const struct h5b_partition *p, /*!< IN: partition \c p */ + const struct h5b_partition *q /*!< IN: partition \c q */ ) { return ( ! ( _NO_GHOSTZONE ( p, q ) || _NO_GHOSTZONE ( q, p ) ) ); } @@ -197,13 +200,13 @@ _have_ghostzone ( \internal - Calculate volume of partition. + Calculate "volume" of partition. \return volume */ static h5_int64_t _volume_of_partition ( - const struct H5BlockPartition *p /*!< IN: partition */ + const struct h5b_partition *p /*!< IN: partition */ ) { return (p->i_end - p->i_start) * (p->j_end - p->j_start) @@ -225,8 +228,8 @@ _volume_of_partition ( */ static h5_int64_t _volume_of_ghostzone ( - const struct H5BlockPartition *p, /*!< IN: ptr to first partition */ - const struct H5BlockPartition *q /*!< IN: ptr to second partition */ + const struct h5b_partition *p, /*!< IN: ptr to first partition */ + const struct h5b_partition *q /*!< IN: ptr to second partition */ ) { h5_int64_t dx = MIN ( p->i_end, q->i_end ) @@ -248,12 +251,12 @@ _volume_of_ghostzone ( if \c { p->i_start <= q->i_end <= p->i_end }. In this case \c -1 will be returned. - \return H5_SUCCESS or -1 + \return 0 or -1 */ -static h5_int64_t +static h5_err_t _dissolve_X_ghostzone ( - struct H5BlockPartition *p, /*!< IN/OUT: ptr to first partition */ - struct H5BlockPartition *q /*!< IN/OUT: ptr to second partition */ + struct h5b_partition *p, /*!< IN/OUT: ptr to first partition */ + struct h5b_partition *q /*!< IN/OUT: ptr to second partition */ ) { if ( p->i_start > q->i_start ) @@ -276,12 +279,12 @@ _dissolve_X_ghostzone ( if \c { p->j_start <= q->j_end <= p->j_end }. In this case \c -1 will be returned. - \return H5_SUCCESS or -1 + \return 0 or -1 */ -static h5_int64_t +static h5_err_t _dissolve_Y_ghostzone ( - struct H5BlockPartition *p, /*!< IN/OUT: ptr to first partition */ - struct H5BlockPartition *q /*!< IN/OUT: ptr to second partition */ + struct h5b_partition *p, /*!< IN/OUT: ptr to first partition */ + struct h5b_partition *q /*!< IN/OUT: ptr to second partition */ ) { if ( p->j_start > q->j_start ) @@ -304,12 +307,12 @@ _dissolve_Y_ghostzone ( if \c { p->k_start <= q->k_end <= p->k_end }. In this case \c -1 will be returned. - \return H5_SUCCESS or -1 + \return 0 or -1 */ -static h5_int64_t +static h5_err_t _dissolve_Z_ghostzone ( - struct H5BlockPartition *p, /*!< IN/OUT: ptr to first partition */ - struct H5BlockPartition *q /*!< IN/OUT: ptr to second partition */ + struct h5b_partition *p, /*!< IN/OUT: ptr to first partition */ + struct h5b_partition *q /*!< IN/OUT: ptr to second partition */ ) { if ( p->k_start > q->k_start ) @@ -335,18 +338,21 @@ _dissolve_Z_ghostzone ( to dissolve the ghost-zone. The "best" is the one with the largest remaining volume of the partitions. + \par Errors + \c H5_ERR_LAYOUT if dissolving gives a partition with empty "volume" + \return H5_SUCCESS or error code. */ -static h5_int64_t +static h5_err_t _dissolve_ghostzone ( - struct H5BlockPartition *p, /*!< IN/OUT: ptr to first partition */ - struct H5BlockPartition *q /*!< IN/OUT: ptr to second partition */ + struct h5b_partition *p, /*!< IN/OUT: ptr to first partition */ + struct h5b_partition *q /*!< IN/OUT: ptr to second partition */ ) { - struct H5BlockPartition p_; - struct H5BlockPartition q_; - struct H5BlockPartition p_best; - struct H5BlockPartition q_best; + struct h5b_partition p_; + struct h5b_partition q_; + struct h5b_partition p_best; + struct h5b_partition q_best; h5_int64_t vol; h5_int64_t max_vol = 0; @@ -386,7 +392,7 @@ _dissolve_ghostzone ( } } if ( max_vol <= 0 ) { - return H5PART_ERR_LAYOUT; + return H5_ERR_LAYOUT; } *p = p_best; *q = q_best; @@ -411,34 +417,34 @@ _dissolve_ghostzone ( May be we should check this and return an error in this case. Then the user have to decide to continue or to abort. - \b {Error Codes} - \b H5PART_NOMEM_ERR + \par Error Codes + \c H5_ERR_NOMEM \return H5_SUCCESS or error code. */ -static h5_int64_t +static h5_err_t _dissolve_ghostzones ( h5_file_t *f /*!< IN: file handle */ ) { - struct h5b_fdata *b = f->block; - struct H5BlockPartition *p; - struct H5BlockPartition *q; + struct h5b_fdata *b = f->b; + struct h5b_partition *p; + struct h5b_partition *q; int proc_p, proc_q; struct list { struct list *prev; struct list *next; - struct H5BlockPartition *p; - struct H5BlockPartition *q; + struct h5b_partition *p; + struct h5b_partition *q; h5_int64_t vol; } *p_begin, *p_el, *p_max, *p_end, *p_save; memcpy ( b->write_layout, b->user_layout, - f->nprocs * sizeof (*f->block->user_layout) ); + f->nprocs * sizeof (*f->b->user_layout) ); p_begin = p_max = p_end = (struct list*) malloc ( sizeof ( *p_begin ) ); - if ( p_begin == NULL ) return HANDLE_H5_NOMEM_ERR; + if ( p_begin == NULL ) return HANDLE_H5_NOMEM_ERR ( f ); memset ( p_begin, 0, sizeof ( *p_begin ) ); @@ -452,7 +458,7 @@ _dissolve_ghostzones ( if ( _have_ghostzone ( p, q ) ) { p_el = (struct list*) malloc ( sizeof ( *p_el ) ); if ( p_el == NULL ) - return HANDLE_H5_NOMEM_ERR; + return HANDLE_H5_NOMEM_ERR ( f ); p_el->p = p; p_el->q = q; @@ -472,7 +478,7 @@ _dissolve_ghostzones ( if ( p_max->next ) p_max->next->prev = p_max->prev; p_max->prev->next = p_max->next; - _dissolve_ghostzone ( p_max->p, p_max->q ); + _dissolve_ghostzone ( p_max->p, p_max->q ); /* should check error */ free ( p_max ); p_el = p_max = p_begin->next; @@ -496,11 +502,12 @@ _dissolve_ghostzones ( } free ( p_begin ); - h5_print_debug ("Layout defined by user:"); + h5_debug ( f, "Layout defined by user:"); for ( proc_p = 0, p = b->user_layout; proc_p < f->nprocs; proc_p++, p++ ) { - h5_print_debug ( + h5_debug ( + f, "PROC[%d]: proc[%d]: %lld:%lld, %lld:%lld, %lld:%lld ", f->myproc, proc_p, (long long)p->i_start, (long long)p->i_end, @@ -508,11 +515,12 @@ _dissolve_ghostzones ( (long long)p->k_start, (long long)p->k_end ); } - h5_print_debug ("Layout after dissolving ghost-zones:"); + h5_debug ( f, "Layout after dissolving ghost-zones:"); for ( proc_p = 0, p = b->write_layout; proc_p < f->nprocs; proc_p++, p++ ) { - h5_print_debug ( + h5_debug ( + f, "PROC[%d]: proc[%d]: %lld:%lld, %lld:%lld, %lld:%lld ", f->myproc, proc_p, (long long)p->i_start, (long long)p->i_end, @@ -524,30 +532,36 @@ _dissolve_ghostzones ( /*! \ingroup h5block_private -1 + \internal + Release previously defined hyperslab + + \par Errors + \c H5_ERR_HDF5 if one of the dataspaces couldn't be closed + + \return H5_SUCCESS or error code */ -h5_int64_t +h5_err_t _release_hyperslab ( h5_file_t *f /*!< IN: file handle */ ) { herr_t herr; - if ( f->block->shape > 0 ) { - herr = H5Sclose ( f->block->shape ); - if ( herr < 0 ) return H5PART_ERR_HDF5; - f->block->shape = -1; + if ( f->b->shape > 0 ) { + herr = H5Sclose ( f->b->shape ); + if ( herr < 0 ) return H5_ERR_HDF5; + f->b->shape = -1; } - if ( f->block->diskshape > 0 ) { - herr = H5Sclose ( f->block->diskshape ); - if ( herr < 0 ) return H5PART_ERR_HDF5; - f->block->diskshape = -1; + if ( f->b->diskshape > 0 ) { + herr = H5Sclose ( f->b->diskshape ); + if ( herr < 0 ) return H5_ERR_HDF5; + f->b->diskshape = -1; } - if ( f->block->memshape > 0 ) { - herr = H5Sclose ( f->block->memshape ); - if ( herr < 0 ) return H5PART_ERR_HDF5; - f->block->memshape = -1; + if ( f->b->memshape > 0 ) { + herr = H5Sclose ( f->b->memshape ); + if ( herr < 0 ) return H5_ERR_HDF5; + f->b->memshape = -1; } return H5_SUCCESS; } @@ -558,25 +572,28 @@ _release_hyperslab ( Define the field layout given the dense index space at the actual time step. - \return \c H5_SUCCESS on success
- \c H5PART_ERR_MPI
- \c H5PART_ERR_HDF5 + \par Errors + \c H5_ERR_MPI on MPI errors + \c H5_ERR_HDF5 on HDF5 errors + \c H5_ERR_NOMEM if we run out of memory + + \return \c H5PART_SUCCESS on success or error code */ -h5_int64_t +h5_err_t H5BlockDefine3DFieldLayout( h5_file_t *f, /*!< IN: File handle */ - const h5_int64_t i_start, /*!< OUT: start index of \c i */ - const h5_int64_t i_end, /*!< OUT: end index of \c i */ - const h5_int64_t j_start, /*!< OUT: start index of \c j */ - const h5_int64_t j_end, /*!< OUT: end index of \c j */ - const h5_int64_t k_start, /*!< OUT: start index of \c j */ - const h5_int64_t k_end /*!< OUT: end index of \c j */ + const h5_size_t i_start, /*!< OUT: start index of \c i */ + const h5_size_t i_end, /*!< OUT: end index of \c i */ + const h5_size_t j_start, /*!< OUT: start index of \c j */ + const h5_size_t j_end, /*!< OUT: end index of \c j */ + const h5_size_t k_start, /*!< OUT: start index of \c j */ + const h5_size_t k_end /*!< OUT: end index of \c j */ ) { - SET_FNAME ( "H5BlockDefine3DFieldLayout" ); + SET_FNAME ( f, __func__ ); - struct h5b_fdata *b = f->block; - struct H5BlockPartition *p = &b->user_layout[f->myproc]; + struct h5b_fdata *b = f->b; + struct h5b_partition *p = &b->user_layout[f->myproc]; p->i_start = i_start; p->i_end = i_end; p->j_start = j_start; @@ -587,49 +604,77 @@ H5BlockDefine3DFieldLayout( _normalize_partition( p ); h5_int64_t herr = _allgather ( f ); - if ( herr < 0 ) return HANDLE_MPI_ALLGATHER_ERR; + if ( herr < 0 ) return HANDLE_MPI_ALLGATHER_ERR ( f ); _get_dimension_sizes ( f ); herr = _dissolve_ghostzones ( f ); - if ( herr < 0 ) return HANDLE_H5_LAYOUT_ERR; + if ( herr < 0 ) return HANDLE_H5_LAYOUT_ERR ( f ); herr = _release_hyperslab ( f ); - if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR; + if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR ( f ); b->have_layout = 1; return H5_SUCCESS; } +/*! + \ingroup h5block_c_api + + Define the chunk dimensions and enable chunking in the underlying + HDF5 dataset. + + \return \c H5_SUCCESS +*/ +h5_err_t +H5BlockDefine3DChunk( + h5_file_t *f, /*!< IN: File handle */ + const h5_size_t *dims /*!< IN: array containing + the chunk dimensions */ + ) { + + SET_FNAME ( f, __func__ ); + + struct h5b_fdata *b = f->b; + + b->chunk[0] = dims[2]; + b->chunk[1] = dims[1]; + b->chunk[2] = dims[0]; + + return H5_SUCCESS; +} + /*! \ingroup h5block_c_api Return partition of processor \c proc as specified with \c H5BlockDefine3dLayout(). - \return \c H5_SUCCESS on success.
- \c H5PART_ERR_INVAL if proc is invalid. + \par Errors + \c H5_ERR_INVAL if proc is invalid. + + \return \c H5_SUCCESS on success or error code */ -h5_int64_t +h5_err_t H5Block3dGetPartitionOfProc ( h5_file_t *f, /*!< IN: File handle */ - const h5_int64_t proc, /*!< IN: Processor to get partition from */ - h5_int64_t *i_start, /*!< OUT: start index of \c i */ - h5_int64_t *i_end, /*!< OUT: end index of \c i */ - h5_int64_t *j_start, /*!< OUT: start index of \c j */ - h5_int64_t *j_end, /*!< OUT: end index of \c j */ - h5_int64_t *k_start, /*!< OUT: start index of \c k */ - h5_int64_t *k_end /*!< OUT: end index of \c k */ + const h5_id_t proc, /*!< IN: Processor to get partition from */ + h5_size_t *i_start, /*!< OUT: start index of \c i */ + h5_size_t *i_end, /*!< OUT: end index of \c i */ + h5_size_t *j_start, /*!< OUT: start index of \c j */ + h5_size_t *j_end, /*!< OUT: end index of \c j */ + h5_size_t *k_start, /*!< OUT: start index of \c k */ + h5_size_t *k_end /*!< OUT: end index of \c k */ ) { - SET_FNAME ( "H5Block3dGetProcOf" ); + SET_FNAME ( f, __func__ ); CHECK_LAYOUT ( f ); if ( ( proc < 0 ) || ( proc >= f->nprocs ) ) - return H5PART_ERR_INVAL; + return H5_ERR_INVAL; - struct H5BlockPartition *p = &f->block->user_layout[(size_t)proc]; + struct h5b_partition *p = &f->b->user_layout[(size_t)proc]; *i_start = p->i_start; *i_end = p->i_end; @@ -647,28 +692,31 @@ H5Block3dGetPartitionOfProc ( Return reduced (ghost-zone free) partition of processor \c proc as specified with \c H5BlockDefine3dLayout(). - \return \c H5_SUCCESS on success.
- \c H5PART_ERR_INVAL if proc is invalid. + \par Errors + \c H5_ERR_INVAL if proc is invalid. + \c H5_ERR_LAYOUT if partitioning not yet defined. + + \return \c H5_SUCCESS on success or error code */ -h5_int64_t +h5_err_t H5Block3dGetReducedPartitionOfProc ( h5_file_t *f, /*!< IN: File handle */ - h5_int64_t proc, /*!< IN: Processor to get partition from */ - h5_int64_t *i_start, /*!< OUT: start index of \c i */ - h5_int64_t *i_end, /*!< OUT: end index of \c i */ - h5_int64_t *j_start, /*!< OUT: start index of \c j */ - h5_int64_t *j_end, /*!< OUT: end index of \c j */ - h5_int64_t *k_start, /*!< OUT: start index of \c j */ - h5_int64_t *k_end /*!< OUT: end index of \c j */ + h5_id_t proc, /*!< IN: Processor to get partition from */ + h5_size_t *i_start, /*!< OUT: start index of \c i */ + h5_size_t *i_end, /*!< OUT: end index of \c i */ + h5_size_t *j_start, /*!< OUT: start index of \c j */ + h5_size_t *j_end, /*!< OUT: end index of \c j */ + h5_size_t *k_start, /*!< OUT: start index of \c j */ + h5_size_t *k_end /*!< OUT: end index of \c j */ ) { - SET_FNAME ( "H5Block3dGetProcOf" ); + SET_FNAME ( f, __func__ ); CHECK_LAYOUT ( f ); if ( ( proc < 0 ) || ( proc >= f->nprocs ) ) - return -1; + return H5_ERR_INVAL; - struct H5BlockPartition *p = &f->block->write_layout[(size_t)proc]; + struct h5b_partition *p = &f->b->write_layout[(size_t)proc]; *i_start = p->i_start; *i_end = p->i_end; @@ -687,30 +735,34 @@ H5Block3dGetReducedPartitionOfProc ( Returns the processor computing the reduced (ghostzone-free) partition given by the coordinates \c i, \c j and \c k. - \return \c H5_SUCCESS or error code + \par Errors + \c H5_ERR_LAYOUT if no partitioning defined + \c H5_ERR_INVAL if given point is not in a partition + + \return \c processor id or error code */ -h5_int64_t +h5_id_t H5Block3dGetProcOf ( h5_file_t *f, /*!< IN: File handle */ - h5_int64_t i, /*!< IN: \c i coordinate */ - h5_int64_t j, /*!< IN: \c j coordinate */ - h5_int64_t k /*!< IN: \c k coordinate */ + h5_size_t i, /*!< IN: \c i coordinate */ + h5_size_t j, /*!< IN: \c j coordinate */ + h5_size_t k /*!< IN: \c k coordinate */ ) { - SET_FNAME ( "H5Block3dGetProcOf" ); + SET_FNAME ( f, __func__ ); CHECK_LAYOUT ( f ); - struct H5BlockPartition *layout = f->block->write_layout; + struct h5b_partition *layout = f->b->write_layout; int proc; for ( proc = 0; proc < f->nprocs; proc++, layout++ ) { if ( (layout->i_start <= i) && (i <= layout->i_end) && (layout->j_start <= j) && (j <= layout->j_end) && (layout->k_start <= k) && (k <= layout->k_end) ) - return (h5_int64_t)proc; + return (h5_id_t)proc; } - return -1; + return H5_ERR_INVAL; } /********************** helper functions for reading and writing *************/ @@ -720,25 +772,29 @@ H5Block3dGetProcOf ( \internal + \par Errors + \c H5_ERR_HDF5 on HDF5 errors + \return \c H5_SUCCESS or error code */ -static h5_int64_t +static h5_err_t _open_block_group ( - const h5_file_t *f /*!< IN: file handle */ + h5_file_t * const f /*!< IN: file handle */ ) { - struct h5b_fdata *b = f->block; + struct h5b_fdata *b = f->b; if ( (f->step_idx != b->step_idx) && (b->blockgroup > 0) ) { herr_t herr = H5Gclose ( b->blockgroup ); - if ( herr < 0 ) return HANDLE_H5G_CLOSE_ERR; - f->block->blockgroup = -1; + if ( herr < 0 ) return HANDLE_H5G_CLOSE_ERR ( f ); + f->b->blockgroup = -1; } if ( b->blockgroup < 0 ) { hid_t herr = H5Gopen ( f->step_gid, H5BLOCK_GROUPNAME_BLOCK, H5P_DEFAULT ); if ( herr < 0 ) return HANDLE_H5G_OPEN_ERR ( + f, h5_get_objname(f->step_gid), H5BLOCK_GROUPNAME_BLOCK ); b->blockgroup = herr; @@ -756,7 +812,7 @@ _open_block_group ( \internal */ -static h5_int64_t +static h5_err_t _have_object ( const hid_t id, const char *name @@ -769,24 +825,31 @@ _have_object ( \internal + Open field with name \c name in current step. + + \par Errors + \c H5_ERR_NOENT if field with name \c name not defined. + \c H5_ERR_HDF5 on HDF5 errors. + \return \c H5_SUCCESS or error code */ -static h5_int64_t +static h5_err_t _open_field_group ( h5_file_t *f, /*!< IN: file handle */ const char *name ) { - struct h5b_fdata *b = f->block; + struct h5b_fdata *b = f->b; h5_int64_t h5err = _open_block_group ( f ); if ( h5err < 0 ) return h5err; if ( ! _have_object ( b->blockgroup, name ) ) - return HANDLE_H5_NOENT_ERR ( name ); + return HANDLE_H5_NOENT_ERR ( f, name ); herr_t herr = H5Gopen ( b->blockgroup, name, H5P_DEFAULT ); if ( herr < 0 ) return HANDLE_H5G_OPEN_ERR ( + f, h5_get_objname(b->blockgroup), name ); b->field_group_id = herr; @@ -799,15 +862,20 @@ _open_field_group ( \internal + Close current field group. + + \par Errors + \c H5_ERR_HDF5 + \return \c H5_SUCCESS or error code */ -h5_int64_t +h5_err_t _close_field_group ( h5_file_t *f /*!< IN: file handle */ ) { - herr_t herr = H5Gclose ( f->block->field_group_id ); - if ( herr < 0 ) return HANDLE_H5G_CLOSE_ERR; + herr_t herr = H5Gclose ( f->b->field_group_id ); + if ( herr < 0 ) return HANDLE_H5G_CLOSE_ERR ( f ); return H5_SUCCESS; } @@ -817,16 +885,23 @@ _close_field_group ( \internal + Set hyperslab for reading. + + \par Errors + \c H5_ERR_HDF5 on HDF5 errors. + \c H5_ERR_INVAL if rank of dataset != 3. + \c H5_ERR_LAYOUT if field dimensions don't fit. + \return \c H5_SUCCESS or error code */ -static h5_int64_t +static h5_err_t _select_hyperslab_for_reading ( h5_file_t *f, /*!< IN: file handle */ hid_t dataset ) { - struct h5b_fdata *b = f->block; - struct H5BlockPartition *p = &b->user_layout[f->myproc]; + struct h5b_fdata *b = f->b; + struct h5b_partition *p = &b->user_layout[f->myproc]; int rank; hsize_t field_dims[3]; hsize_t start[3] = { @@ -840,23 +915,24 @@ _select_hyperslab_for_reading ( p->i_end - p->i_start + 1 }; h5_int64_t herr = _release_hyperslab ( f ); - if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR; + if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR ( f ); b->diskshape = H5Dget_space ( dataset ); - if ( b->diskshape < 0 ) return HANDLE_H5D_GET_SPACE_ERR; + if ( b->diskshape < 0 ) return HANDLE_H5D_GET_SPACE_ERR ( f ); rank = H5Sget_simple_extent_dims ( b->diskshape, NULL, NULL ); - if ( rank < 0 ) return HANDLE_H5S_GET_SIMPLE_EXTENT_DIMS_ERR; - if ( rank != 3 ) return HANDLE_H5_DATASET_RANK_ERR ( rank, 3 ); + if ( rank < 0 ) return HANDLE_H5S_GET_SIMPLE_EXTENT_DIMS_ERR ( f ); + if ( rank != 3 ) return HANDLE_H5_DATASET_RANK_ERR ( f, rank, 3 ); rank = H5Sget_simple_extent_dims ( b->diskshape, field_dims, NULL ); - if ( rank < 0 ) return HANDLE_H5S_GET_SIMPLE_EXTENT_DIMS_ERR; + if ( rank < 0 ) return HANDLE_H5S_GET_SIMPLE_EXTENT_DIMS_ERR ( f ); 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 HANDLE_H5_LAYOUT_ERR; + (field_dims[2] < (hsize_t)b->i_max) ) return HANDLE_H5_LAYOUT_ERR ( f ); - h5_print_debug ( + h5_debug ( + f, "PROC[%d]: \n" "\tfield_dims: (%lld,%lld,%lld)", f->myproc, @@ -866,11 +942,11 @@ _select_hyperslab_for_reading ( b->diskshape = H5Screate_simple ( rank, field_dims,field_dims ); if ( b->diskshape < 0 ) - return HANDLE_H5S_CREATE_SIMPLE_3D_ERR ( field_dims ); + return HANDLE_H5S_CREATE_SIMPLE_3D_ERR ( f, field_dims ); - f->block->memshape = H5Screate_simple ( rank, part_dims, part_dims ); + f->b->memshape = H5Screate_simple ( rank, part_dims, part_dims ); if ( b->memshape < 0 ) - return HANDLE_H5S_CREATE_SIMPLE_3D_ERR ( part_dims ); + return HANDLE_H5S_CREATE_SIMPLE_3D_ERR ( f, part_dims ); herr = H5Sselect_hyperslab ( b->diskshape, @@ -879,23 +955,18 @@ _select_hyperslab_for_reading ( stride, part_dims, NULL ); - if ( herr < 0 ) return HANDLE_H5S_SELECT_HYPERSLAB_ERR; + if ( herr < 0 ) return HANDLE_H5S_SELECT_HYPERSLAB_ERR ( f ); - h5_print_debug ( + h5_debug ( + f, "PROC[%d]: Select hyperslab: \n" - "\tstart: (%lld,%lld,%lld)\n" - "\tstride: (%lld,%lld,%lld)\n" - "\tdims: (%lld,%lld,%lld)", + "\tstart: (%ld,%ld,%ld)\n" + "\tstride: (%ld,%ld,%ld)\n" + "\tdims: (%ld,%ld,%ld)", f->myproc, - (long long)start[2], - (long long)start[1], - (long long)start[0], - (long long)stride[2], - (long long)stride[1], - (long long)stride[0], - (long long)part_dims[2], - (long long)part_dims[1], - (long long)part_dims[0] ); + (long)start[2], (long)start[1], (long)start[0], + (long)stride[2], (long)stride[1], (long)stride[0], + (long)part_dims[2], (long)part_dims[1], (long)part_dims[0] ); return H5_SUCCESS; } @@ -905,34 +976,63 @@ _select_hyperslab_for_reading ( \internal + \par Errors + \c H5_ERR_HDF5 on HDF5 errors + \c H5_ERR_INVAL if rank of dataset != 3. + \c H5_ERR_LAYOUT if field dimensions don't fit. + \return \c H5_SUCCESS or error code */ -h5_int64_t +static h5_err_t _read_data ( h5_file_t *f, /*!< IN: file handle */ const char *name, /*!< IN: name of dataset to read */ - h5_float64_t *data /*!< OUT: ptr to read buffer */ + h5_float64_t *data, /*!< OUT: ptr to read buffer */ + hid_t type /*!< IN: data type */ ) { - struct h5b_fdata *b = f->block; + struct h5b_fdata *b = f->b; hid_t dataset_id = H5Dopen ( b->field_group_id, name, H5P_DEFAULT ); - if ( dataset_id < 0 ) return HANDLE_H5D_OPEN_ERR ( name ); + if ( dataset_id < 0 ) return HANDLE_H5D_OPEN_ERR ( f, name ); - h5_int64_t herr = _select_hyperslab_for_reading ( f, dataset_id ); + h5_err_t herr = _select_hyperslab_for_reading ( f, dataset_id ); if ( herr < 0 ) return herr; herr = H5Dread ( dataset_id, - H5T_NATIVE_DOUBLE, - f->block->memshape, - f->block->diskshape, + type, + f->b->memshape, + f->b->diskshape, H5P_DEFAULT, data ); - if ( herr < 0 ) return HANDLE_H5D_READ_ERR ( name ); + if ( herr < 0 ) return HANDLE_H5D_READ_ERR ( f, name ); herr = H5Dclose ( dataset_id ); - if ( herr < 0 ) return HANDLE_H5D_CLOSE_ERR; + if ( herr < 0 ) return HANDLE_H5D_CLOSE_ERR ( f ); + + return H5_SUCCESS; +} + +h5_err_t +h5b_read_scalar_field ( + h5_file_t *f, /*!< IN: file handle */ + const char *field_name, /*!< IN: field name */ + const char *dataset_name, /*!< IN: name of dataset to write */ + void *data, /*!< OUT: ptr to read buffer */ + const hid_t type /*!< IN: data type */ + ) { + CHECK_TIMEGROUP ( f ); + CHECK_LAYOUT ( f ); + + h5_err_t herr = _open_field_group ( f, field_name ); + if ( herr < 0 ) return herr; + + herr = _read_data ( f, dataset_name, data, type ); + if ( herr < 0 ) return herr; + + herr = _close_field_group ( f ); + if ( herr < 0 ) return herr; return H5_SUCCESS; } @@ -946,23 +1046,90 @@ _read_data ( You must use the FORTRAN indexing scheme to access items in \c data. + \par Errors + \c H5_ERR_LAYOUT if no partitioning defined or field dimensions don't fit.\n + \c H5_ERR_HDF5 on HDF5 errors\n + \c H5_ERR_INVAL if rank of dataset != 3.\n + ... + \return \c H5_SUCCESS or error code */ -h5_int64_t +h5_err_t H5Block3dReadScalarField ( h5_file_t *f, /*!< IN: file handle */ const char *name, /*!< IN: name of dataset to read */ h5_float64_t *data /*!< OUT: ptr to read buffer */ ) { - SET_FNAME ( "H5Block3dReadScalarField" ); + SET_FNAME ( f, __func__ ); + return h5b_read_scalar_field ( f, name, "0", data, H5T_NATIVE_DOUBLE ); +} + +h5_err_t +H5Block3dReadScalarFieldFloat64 ( + h5_file_t *f, /*!< IN: file handle */ + const char *name, /*!< IN: name of dataset to read */ + h5_float64_t *data /*!< OUT: ptr to read buffer */ + ) { + + SET_FNAME ( f, __func__ ); + return h5b_read_scalar_field ( f, name, "0", data, H5T_NATIVE_DOUBLE ); +} + + +h5_err_t +H5Block3dReadScalarFieldFloat32 ( + h5_file_t *f, /*!< IN: file handle */ + const char *name, /*!< IN: name of dataset to read */ + h5_float32_t *data /*!< OUT: ptr to read buffer */ + ) { + + SET_FNAME ( f, __func__ ); + return h5b_read_scalar_field ( f, name, "0", data, H5T_NATIVE_FLOAT ); +} + +h5_err_t +H5Block3dReadScalarFieldInt64 ( + h5_file_t *f, /*!< IN: file handle */ + const char *name, /*!< IN: name of dataset to read */ + h5_int64_t *data /*!< OUT: ptr to read buffer */ + ) { + + SET_FNAME ( f, __func__ ); + return h5b_read_scalar_field ( f, name, "0", data, H5T_NATIVE_INT64 ); +} + +h5_err_t +H5Block3dReadScalarFieldInt32 ( + h5_file_t *f, /*!< IN: file handle */ + const char *name, /*!< IN: name of dataset to read */ + h5_int32_t *data /*!< OUT: ptr to read buffer */ + ) { + + SET_FNAME ( f, __func__ ); + return h5b_read_scalar_field ( f, name, "0", data, H5T_NATIVE_INT32 ); +} + +h5_err_t +h5b_3d_read_3d_vectorfield ( + h5_file_t *f, /*!< IN: file handle */ + const char *name, /*!< IN: name of dataset to read */ + void *x_data, /*!< OUT: ptr to read buffer X axis */ + void *y_data, /*!< OUT: ptr to read buffer Y axis */ + void *z_data, /*!< OUT: ptr to read buffer Z axis */ + const hid_t type /*!< IN: data type */ + ) { CHECK_TIMEGROUP ( f ); CHECK_LAYOUT ( f ); h5_int64_t herr = _open_field_group ( f, name ); if ( herr < 0 ) return herr; - herr = _read_data ( f, "0", data ); + herr = _read_data ( f, "0", x_data, type ); + if ( herr < 0 ) return herr; + herr = _read_data ( f, "1", y_data, type ); + if ( herr < 0 ) return herr; + herr = _read_data ( f, "2", z_data, type ); if ( herr < 0 ) return herr; herr = _close_field_group ( f ); @@ -981,35 +1148,30 @@ H5Block3dReadScalarField ( You must use the FORTRAN indexing scheme to access items in the buffers. + \par Errors + \c H5_ERR_HDF5 on HDF5 errors.\n + \c H5_ERR_INVAL if rank of dataset != 3.\n + \c H5_ERR_LAYOUT if field dimensions don't fit.\n + \return \c H5_SUCCESS or error code */ -h5_int64_t +h5_err_t H5Block3dRead3dVectorField ( h5_file_t *f, /*!< IN: file handle */ const char *name, /*!< IN: name of dataset to read */ - h5_float64_t *x_data, /*!< OUT: ptr to read buffer X axis */ - h5_float64_t *y_data, /*!< OUT: ptr to read buffer Y axis */ - h5_float64_t *z_data /*!< OUT: ptr to read buffer Z axis */ + h5_float64_t *x_data, /*!< OUT: ptr to read buffer X axis */ + h5_float64_t *y_data, /*!< OUT: ptr to read buffer Y axis */ + h5_float64_t *z_data /*!< OUT: ptr to read buffer Z axis */ ) { - SET_FNAME ( "H5Block3dRead3dVectorField" ); - CHECK_TIMEGROUP ( f ); - CHECK_LAYOUT ( f ); - - h5_int64_t herr = _open_field_group ( f, name ); - if ( herr < 0 ) return herr; - - herr = _read_data ( f, "0", x_data ); - if ( herr < 0 ) return herr; - herr = _read_data ( f, "1", y_data ); - if ( herr < 0 ) return herr; - herr = _read_data ( f, "2", z_data ); - if ( herr < 0 ) return herr; - - herr = _close_field_group ( f ); - if ( herr < 0 ) return herr; - - return H5_SUCCESS; + SET_FNAME ( f, __func__ ); + return h5b_3d_read_3d_vectorfield ( + f, + name, + x_data, + y_data, + z_data, + H5T_NATIVE_DOUBLE ); } /********************** functions for writing ********************************/ @@ -1021,7 +1183,7 @@ H5Block3dRead3dVectorField ( \return \c H5_SUCCESS or error code */ -static h5_int64_t +static h5_err_t _select_hyperslab_for_writing ( h5_file_t *f /*!< IN: file handle */ ) { @@ -1029,12 +1191,12 @@ _select_hyperslab_for_writing ( /* re-use existing hyperslab */ - if ( f->block->shape >= 0 ) return H5_SUCCESS; + if ( f->b->shape >= 0 ) return H5_SUCCESS; herr_t herr; - struct h5b_fdata *b = f->block; - struct H5BlockPartition *p = &b->write_layout[f->myproc]; - struct H5BlockPartition *q = &b->user_layout[f->myproc]; + struct h5b_fdata *b = f->b; + struct h5b_partition *p = &b->write_layout[f->myproc]; + struct h5b_partition *q = &b->user_layout[f->myproc]; int rank = 3; @@ -1059,13 +1221,14 @@ _select_hyperslab_for_writing ( b->shape = H5Screate_simple ( rank, field_dims, field_dims ); if ( b->shape < 0 ) - return HANDLE_H5S_CREATE_SIMPLE_3D_ERR ( field_dims ); + return HANDLE_H5S_CREATE_SIMPLE_3D_ERR ( f, field_dims ); b->diskshape = H5Screate_simple ( rank, field_dims,field_dims ); if ( b->diskshape < 0 ) - return HANDLE_H5S_CREATE_SIMPLE_3D_ERR ( field_dims ); + return HANDLE_H5S_CREATE_SIMPLE_3D_ERR ( f, field_dims ); - h5_print_debug ( + h5_debug ( + f, "PROC[%d]: Select hyperslab on diskshape: \n" "\tstart: (%lld,%lld,%lld)\n" "\tstride: (%lld,%lld,%lld)\n" @@ -1088,21 +1251,22 @@ _select_hyperslab_for_writing ( stride, part_dims, NULL ); - if ( herr < 0 ) return HANDLE_H5S_SELECT_HYPERSLAB_ERR; + if ( herr < 0 ) return HANDLE_H5S_SELECT_HYPERSLAB_ERR ( f ); 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; - f->block->memshape = H5Screate_simple ( rank, field_dims, field_dims ); + f->b->memshape = H5Screate_simple ( rank, field_dims, field_dims ); if ( b->memshape < 0 ) - return HANDLE_H5S_CREATE_SIMPLE_3D_ERR ( part_dims ); + return HANDLE_H5S_CREATE_SIMPLE_3D_ERR ( f, part_dims ); 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_print_debug ( + h5_debug ( + f, "PROC[%d]: Select hyperslab on memshape: \n" "\tstart: (%lld,%lld,%lld)\n" "\tstride: (%lld,%lld,%lld)\n" @@ -1125,7 +1289,7 @@ _select_hyperslab_for_writing ( stride, part_dims, NULL ); - if ( herr < 0 ) return HANDLE_H5S_SELECT_HYPERSLAB_ERR; + if ( herr < 0 ) return HANDLE_H5S_SELECT_HYPERSLAB_ERR ( f ); return H5_SUCCESS; } @@ -1139,23 +1303,23 @@ _select_hyperslab_for_writing ( */ static h5_int64_t _create_block_group ( - const h5_file_t *f /*!< IN: file handle */ + h5_file_t * const f /*!< IN: file handle */ ) { herr_t herr; - struct h5b_fdata *b = f->block; + struct h5b_fdata *b = f->b; if ( b->blockgroup > 0 ) { herr = H5Gclose ( b->blockgroup ); - if ( herr < 0 ) return HANDLE_H5G_CLOSE_ERR; - f->block->blockgroup = -1; + if ( herr < 0 ) return HANDLE_H5G_CLOSE_ERR ( f ); + f->b->blockgroup = -1; } herr = H5Gcreate ( f->step_gid, H5BLOCK_GROUPNAME_BLOCK, 0, H5P_DEFAULT, H5P_DEFAULT ); - if ( herr < 0 ) return HANDLE_H5G_CREATE_ERR ( H5BLOCK_GROUPNAME_BLOCK ); + if ( herr < 0 ) return HANDLE_H5G_CREATE_ERR ( f, H5BLOCK_GROUPNAME_BLOCK ); - f->block->blockgroup = herr; + f->b->blockgroup = herr; return H5_SUCCESS; } @@ -1173,7 +1337,7 @@ _create_field_group ( ) { h5_int64_t h5err; - struct h5b_fdata *b = f->block; + struct h5b_fdata *b = f->b; if ( ! _have_object ( f->step_gid, H5BLOCK_GROUPNAME_BLOCK ) ) { @@ -1187,10 +1351,10 @@ _create_field_group ( if ( h5err < 0 ) return h5err; if ( _have_object ( b->blockgroup, name ) ) - return HANDLE_H5_GROUP_EXISTS_ERR ( name ); + return HANDLE_H5_GROUP_EXISTS_ERR ( f, name ); herr_t herr = H5Gcreate ( b->blockgroup, name, 0, H5P_DEFAULT, H5P_DEFAULT ); - if ( herr < 0 ) return HANDLE_H5G_CREATE_ERR ( name ); + if ( herr < 0 ) return HANDLE_H5G_CREATE_ERR ( f, name ); b->field_group_id = herr; return H5_SUCCESS; @@ -1203,14 +1367,14 @@ _create_field_group ( \return \c H5_SUCCESS or error code */ -static h5_int64_t +static h5_err_t _write_field_data ( h5_file_t *f, /*!< IN: file handle */ const char *name, /*!< IN: name of dataset to write */ const h5_float64_t *data /*!< IN: data to write */ ) { - struct h5b_fdata *b = f->block; + struct h5b_fdata *b = f->b; return h5_write_data ( f, @@ -1234,14 +1398,14 @@ _write_field_data ( \return \c H5_SUCCESS or error code */ -h5_int64_t +h5_err_t H5Block3dWriteScalarField ( h5_file_t *f, /*!< IN: file handle */ const char *name, /*!< IN: name of dataset to write */ const h5_float64_t *data /*!< IN: scalar data to write */ ) { - SET_FNAME ( "H5Block3dWriteScalarField" ); + SET_FNAME ( f, __func__ ); CHECK_WRITABLE_MODE ( f ); CHECK_TIMEGROUP ( f ); CHECK_LAYOUT ( f ); @@ -1273,7 +1437,7 @@ H5Block3dWriteScalarField ( \return \c H5_SUCCESS or error code */ -h5_int64_t +h5_err_t H5Block3dWrite3dVectorField ( h5_file_t *f, /*!< IN: file handle */ const char *name, /*!< IN: name of dataset to write */ @@ -1282,7 +1446,7 @@ H5Block3dWrite3dVectorField ( const h5_float64_t *z_data /*!< IN: Z axis data */ ) { - SET_FNAME ( "H5Block3dWrite3dVectorField" ); + SET_FNAME ( f, __func__ ); CHECK_WRITABLE_MODE ( f ); CHECK_TIMEGROUP ( f ); CHECK_LAYOUT ( f ); @@ -1312,18 +1476,19 @@ H5Block3dWrite3dVectorField ( \return \c H5_SUCCESS or error code */ -h5_int64_t +h5_id_t H5BlockGetNumFields ( h5_file_t *f /*!< IN: file handle */ ) { - SET_FNAME ( "H5BlockGetNumFields" ); + SET_FNAME ( f, __func__ ); CHECK_TIMEGROUP( f ); if ( ! _have_object ( f->step_gid, H5BLOCK_GROUPNAME_BLOCK ) ) return 0; - return h5_get_num_objects ( f->step_gid, H5BLOCK_GROUPNAME_BLOCK, H5G_GROUP ); + return hdf5_get_num_objects ( + f->step_gid, H5BLOCK_GROUPNAME_BLOCK, H5G_GROUP ); } /*! @@ -1333,52 +1498,53 @@ H5BlockGetNumFields ( \return \c H5_SUCCESS or error code */ -static h5_int64_t +static h5_err_t _get_field_info ( h5_file_t *f, /*!< IN: file handle */ const char *field_name, /*!< IN: field name to get info about */ - h5_int64_t *grid_rank, /*!< OUT: rank of grid */ + h5_int64_t *grid_rank, /*!< OUT: rank of grid */ h5_int64_t *grid_dims, /*!< OUT: dimensions of grid */ h5_int64_t *field_dims /*!< OUT: rank of field (1 or 3) */ ) { hsize_t dims[16]; - h5_int64_t i, j; + h5_id_t i, j; - h5_int64_t herr = _open_block_group ( f ); + h5_err_t herr = _open_block_group ( f ); if ( herr < 0 ) return herr; - hid_t group_id = H5Gopen ( f->block->blockgroup, field_name, + hid_t group_id = H5Gopen ( f->b->blockgroup, field_name, H5P_DEFAULT ); if ( group_id < 0 ) return HANDLE_H5G_OPEN_ERR ( - h5_get_objname(f->block->blockgroup), field_name ); + f, + hdf5_get_objname(f->b->blockgroup), field_name ); hid_t dataset_id = H5Dopen ( group_id, "0", H5P_DEFAULT ); - if ( dataset_id < 0 ) return HANDLE_H5D_OPEN_ERR ( "0" ); + if ( dataset_id < 0 ) return HANDLE_H5D_OPEN_ERR ( f, "0" ); hid_t dataspace_id = H5Dget_space ( dataset_id ); - if ( dataspace_id < 0 ) return HANDLE_H5D_GET_SPACE_ERR; + if ( dataspace_id < 0 ) return HANDLE_H5D_GET_SPACE_ERR ( f ); *grid_rank = H5Sget_simple_extent_dims ( dataspace_id, dims, NULL ); - if ( *grid_rank < 0 ) return HANDLE_H5S_GET_SIMPLE_EXTENT_DIMS_ERR; + if ( *grid_rank < 0 ) return HANDLE_H5S_GET_SIMPLE_EXTENT_DIMS_ERR ( f ); for ( i = 0, j = *grid_rank-1; i < *grid_rank; i++, j-- ) grid_dims[i] = (h5_int64_t)dims[j]; - *field_dims = h5_get_num_objects ( - f->block->blockgroup, + *field_dims = hdf5_get_num_objects ( + f->b->blockgroup, field_name, H5G_DATASET ); if ( *field_dims < 0 ) return *field_dims; herr = H5Sclose ( dataspace_id ); - if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR; + if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR ( f ); herr = H5Dclose ( dataset_id ); - if ( herr < 0 ) return HANDLE_H5D_CLOSE_ERR; + if ( herr < 0 ) return HANDLE_H5D_CLOSE_ERR ( f ); herr = H5Gclose ( group_id ); - if ( herr < 0 ) return HANDLE_H5G_CLOSE_ERR; + if ( herr < 0 ) return HANDLE_H5G_CLOSE_ERR ( f ); return H5_SUCCESS; } @@ -1396,21 +1562,21 @@ _get_field_info ( \return \c H5_SUCCESS or error code */ -h5_int64_t +h5_err_t H5BlockGetFieldInfo ( - h5_file_t *f, /*!< IN: file handle */ - const h5_int64_t idx, /*!< IN: index of field */ - char *field_name, /*!< OUT: field name */ - const h5_int64_t len_field_name, /*!< IN: buffer size */ + h5_file_t *f, /*!< IN: file handle */ + const h5_id_t idx, /*!< IN: index of field */ + char *field_name, /*!< OUT: field name */ + const h5_id_t len_field_name, /*!< IN: buffer size */ h5_int64_t *grid_rank, /*!< OUT: grid rank */ h5_int64_t *grid_dims, /*!< OUT: grid dimensions */ h5_int64_t *field_dims /*!< OUT: field rank */ ) { - SET_FNAME ( "H5BlockGetFieldInfo" ); + SET_FNAME ( f, __func__ ); CHECK_TIMEGROUP( f ); - h5_int64_t herr = h5_get_object_name ( + h5_int64_t herr = hdf5_get_object_name ( f->step_gid, H5BLOCK_GROUPNAME_BLOCK, H5G_GROUP, @@ -1434,12 +1600,12 @@ h5_int64_t H5BlockGetFieldInfoByName ( h5_file_t *f, /*!< IN: file handle */ const char *field_name, /*!< IN: field name */ - h5_int64_t *grid_rank, /*!< OUT: grid rank */ - h5_int64_t *grid_dims, /*!< OUT: grid dimensions */ - h5_int64_t *field_dims /*!< OUT: field rank */ + h5_int64_t *grid_rank, /*!< OUT: grid rank */ + h5_int64_t *grid_dims, /*!< OUT: grid dimensions */ + h5_int64_t *field_dims /*!< OUT: field rank */ ) { - SET_FNAME ( "H5BlockGetFieldInfo" ); + SET_FNAME ( f, __func__ ); CHECK_TIMEGROUP( f ); return _get_field_info ( @@ -1469,7 +1635,8 @@ _write_field_attrib ( if ( herr < 0 ) return herr; h5_write_attrib ( - f->block->field_group_id, + f, + f->b->field_group_id, attrib_name, attrib_type, attrib_value, @@ -1500,7 +1667,7 @@ H5BlockWriteFieldAttrib ( const h5_int64_t attrib_nelem /*!< IN: number of elements */ ) { - SET_FNAME ( "H5BlockWriteFieldAttrib" ); + SET_FNAME ( f, __func__ ); CHECK_WRITABLE_MODE( f ); CHECK_TIMEGROUP( f ); @@ -1527,7 +1694,7 @@ H5BlockWriteFieldAttribString ( const char *attrib_value /*!< IN: attribute value */ ) { - SET_FNAME ( "H5BlockWriteFieldAttribString" ); + SET_FNAME ( f, __func__ ); CHECK_WRITABLE_MODE( f ); CHECK_TIMEGROUP( f ); @@ -1551,15 +1718,15 @@ H5BlockGetNumFieldAttribs ( const char *field_name /*block->field_group_id ); - if ( nattribs < 0 ) HANDLE_H5A_GET_NUM_ATTRS_ERR; + f->b->field_group_id ); + if ( nattribs < 0 ) HANDLE_H5A_GET_NUM_ATTRS_ERR ( f ); herr = _close_field_group ( f ); if ( herr < 0 ) return herr; @@ -1588,14 +1755,15 @@ H5BlockGetFieldAttribInfo ( h5_int64_t *attrib_nelem /*!< OUT: number of elements */ ) { - SET_FNAME ( "H5BlockGetFieldAttribInfo" ); + SET_FNAME ( f, __func__ ); CHECK_TIMEGROUP( f ); h5_int64_t herr = _open_field_group ( f, field_name ); if ( herr < 0 ) return herr; herr = h5_get_attrib_info ( - f->block->field_group_id, + f, + f->b->field_group_id, attrib_idx, attrib_name, len_of_attrib_name, @@ -1626,12 +1794,13 @@ _read_field_attrib ( void *attrib_value /*!< OUT: value */ ) { - struct h5b_fdata *b = f->block; + struct h5b_fdata *b = f->b; h5_int64_t herr = _open_field_group ( f, field_name ); if ( herr < 0 ) return herr; herr = h5_read_attrib ( + f, b->field_group_id, attrib_name, attrib_value ); @@ -1658,7 +1827,7 @@ H5BlockReadFieldAttrib ( void *attrib_value /*!< OUT: value */ ) { - SET_FNAME ( "H5PartReadFieldAttrib" ); + SET_FNAME ( f, __func__ ); CHECK_TIMEGROUP( f ); return _read_field_attrib ( @@ -1685,7 +1854,7 @@ H5Block3dGetFieldOrigin ( h5_float64_t *z_origin /*!< OUT: Z origin */ ) { - SET_FNAME ( "H5BlockSetFieldOrigin" ); + SET_FNAME ( f, __func__ ); CHECK_TIMEGROUP( f ); h5_float64_t origin[3]; @@ -1718,7 +1887,7 @@ H5Block3dSetFieldOrigin ( const h5_float64_t z_origin /*!< IN: Z origin */ ) { - SET_FNAME ( "H5BlockSetFieldOrigin" ); + SET_FNAME ( f, __func__ ); CHECK_WRITABLE_MODE( f ); CHECK_TIMEGROUP( f ); @@ -1749,7 +1918,7 @@ H5Block3dGetFieldSpacing ( h5_float64_t *z_spacing /*!< OUT: Z spacing */ ) { - SET_FNAME ( "H5BlockGetFieldSpacing" ); + SET_FNAME ( f, __func__ ); CHECK_TIMEGROUP( f ); h5_float64_t spacing[3]; @@ -1782,7 +1951,7 @@ H5Block3dSetFieldSpacing ( const h5_float64_t z_spacing /*!< IN: Z spacing */ ) { - SET_FNAME ( "H5BlockSetFieldSpacing" ); + SET_FNAME ( f, __func__ ); CHECK_WRITABLE_MODE( f ); CHECK_TIMEGROUP( f ); @@ -1801,21 +1970,21 @@ H5Block3dSetFieldSpacing ( \ingroup h5block_c_api */ /* - Checks whether the current time-step has field data or not. + Checks whether the current step has field data or not. \return \c H5_SUCCESS if field data is available otherwise \c - H5PART_ERR_NOENTRY. + H5_ERR_NOENTRY. */ h5_int64_t H5BlockHasFieldData ( h5_file_t *f /*!< IN: file handle */ ) { - SET_FNAME ( "H5BlockHasFieldData" ); + SET_FNAME ( f, __func__ ); CHECK_TIMEGROUP( f ); if ( ! _have_object ( f->step_gid, H5BLOCK_GROUPNAME_BLOCK ) ) { - return H5PART_ERR_NOENTRY; + return H5_ERR_NOENTRY; } return H5_SUCCESS; } diff --git a/src/H5Fed.c b/src/H5Fed.c index 7823fe6..20b46d2 100644 --- a/src/H5Fed.c +++ b/src/H5Fed.c @@ -1,5 +1,5 @@ /* - Copyright 2007-2008 + Copyright 2007-2009 Paul Scherrer Institut, Villigen, Switzerland; Benedikt Oswald; Achim Gsell @@ -25,24 +25,15 @@ H5FedOpenMesh ( const h5_id_t id, const h5_oid_t type ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_open_mesh ( f, id, type ); } -h5_id_t -H5FedAddMesh ( - h5_file_t * f, - const h5_oid_t type - ) { - SET_FNAME ( __func__ ); - return h5t_open_mesh ( f, -1, type ); -} - h5_err_t H5FedSetLevel ( h5_file_t * f, const h5_id_t id ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_open_level ( f, id ); } diff --git a/src/H5Fed.h b/src/H5Fed.h index 7a405a7..48a617c 100644 --- a/src/H5Fed.h +++ b/src/H5Fed.h @@ -22,6 +22,7 @@ #include "H5.h" #include "H5Fed_boundaries.h" #include "H5Fed_map.h" +#include "H5Fed_store.h" /****** General routines *****************************************************/ @@ -37,12 +38,6 @@ H5FedOpenMesh ( const h5_id_t id, const h5_oid_t type ); -h5_id_t -H5FedAddMesh ( - h5_file_t * f, - const h5_oid_t type - ); - h5_size_t H5FedGetNumLevels ( h5_file_t * f @@ -59,22 +54,6 @@ H5FedGetLevel ( h5_file_t * f ); -h5_id_t -H5FedAddLevel ( - h5_file_t * f - ); - -h5_err_t -H5FedAddNumVertices ( - h5_file_t * f, - const h5_size_t num - ); - -h5_err_t -H5FedAddNumEntities ( - h5_file_t * f, - const h5_size_t num - ); /****** INQUIRY routines *****************************************************/ @@ -139,13 +118,6 @@ H5FedGetNumTetrahedraCnode ( /* vertices */ -h5_id_t -H5FedStoreVertex ( - h5_file_t * f, - const h5_id_t id, - const h5_float64_t P[3] - ); - h5_err_t H5FedStartTraverseVertices ( h5_file_t * f @@ -164,14 +136,6 @@ H5FedGetNumTriangles ( h5_file_t * f ); -h5_id_t -H5FedStoreTriangle ( - h5_file_t * f, - const h5_id_t id, - const h5_id_t parent_id, - h5_id_t vertex_ids[3] - ); - h5_err_t H5FedStartTraverseTriangles ( h5_file_t * f @@ -186,13 +150,6 @@ H5FedTraverseTriangles ( ); /* tetrahedra */ -h5_id_t -H5FedStoreTetrahedron ( - h5_file_t * f, - const h5_id_t id, - const h5_id_t parent_id, - const h5_id_t vertex_ids[4] - ); h5_err_t H5FedStartTraverseTetrahedra ( diff --git a/src/H5Fed_boundaries.c b/src/H5Fed_boundaries.c index eac68b5..a28ba33 100644 --- a/src/H5Fed_boundaries.c +++ b/src/H5Fed_boundaries.c @@ -23,7 +23,7 @@ h5_err_t H5FedAddBoundary ( h5_file_t * const f ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_open_boundary ( f, -1 ); } @@ -32,7 +32,7 @@ H5FedOpenBoundary ( h5_file_t * const f, const h5_id_t boundary_id ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_open_boundary ( f, boundary_id ); } @@ -40,7 +40,7 @@ h5_err_t H5FedCloseBoundary ( h5_file_t * const f ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_close_boundary ( f ); } @@ -49,7 +49,7 @@ H5FedAddNumBoundaryfaces ( h5_file_t * const f, const h5_id_t num_boundaryfaces ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_add_num_boundaryfaces ( f, num_boundaryfaces ); } @@ -58,7 +58,7 @@ H5FedStoreBoundaryface ( h5_file_t *f, h5_id_t *global_vids ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_store_boundaryface ( f, global_vids ); } @@ -67,7 +67,7 @@ H5FedStoreBoundaryfaceGlobalID ( h5_file_t *f, h5_id_t global_fid ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_store_boundaryface_global_id ( f, global_fid ); } @@ -76,7 +76,7 @@ H5FedStoreBoundaryfaceLocalID ( h5_file_t *f, h5_id_t local_fid ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_store_boundaryface_local_id ( f, local_fid ); } @@ -84,7 +84,7 @@ h5_err_t H5FedStartTraverseBoundaryfaces ( h5_file_t * const f ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_start_traverse_boundary_faces( f ); } @@ -96,6 +96,6 @@ H5FedTraverseBoundaryfaces ( \c >0 else \c -1 */ h5_id_t vertex_ids[3] /*!< OUT: vertex id's */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_traverse_boundary_faces( f, id, parent_id, vertex_ids ); } diff --git a/src/H5Fed_inquiry.c b/src/H5Fed_inquiry.c index 3f66782..8ae0f81 100644 --- a/src/H5Fed_inquiry.c +++ b/src/H5Fed_inquiry.c @@ -27,7 +27,7 @@ H5FedGetNumMeshes ( h5_file_t * f, /*!< file handle */ const h5_oid_t type ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_get_num_meshes ( f, type ); } @@ -41,26 +41,30 @@ H5FedGetNumMeshes ( */ h5_size_t H5FedGetNumLevels ( - h5_file_t * fh /*!< file handle */ + h5_file_t * const f /*!< file handle */ ) { - SET_FNAME ( __func__ ); - return h5t_get_num_levels ( fh ); + SET_FNAME ( f, __func__ ); + return h5t_get_num_levels ( f ); } h5_id_t H5FedGetLevel ( - h5_file_t * fh /*!< file handle */ + h5_file_t * const f /*!< file handle */ ) { - SET_FNAME ( __func__ ); - return h5t_get_level ( fh ); + SET_FNAME ( f, __func__ ); + return h5t_get_level ( f ); } +/*! + Get number of local vertices on current level. +*/ h5_size_t H5FedGetNumVertices ( - h5_file_t * fh /*!< file handle */ + h5_file_t * const f /*!< file handle */ ) { - SET_FNAME ( __func__ ); - return h5t_get_num_vertices_on_level ( fh ); + SET_FNAME ( f, __func__ ); + h5_id_t cur_level = h5t_get_level( f ); + return h5t_get_num_vertices ( f, f->myproc, cur_level ); } /*! @@ -74,10 +78,11 @@ H5FedGetNumVertices ( */ h5_size_t H5FedGetNumVerticesTotal( - h5_file_t * fh /*!< file handle */ + h5_file_t * const f /*!< file handle */ ) { - SET_FNAME ( __func__ ); - return h5t_get_num_vertices_on_level ( fh ); + SET_FNAME ( f, __func__ ); + h5_id_t cur_level = h5t_get_level( f ); + return h5t_get_num_vertices ( f, -1, cur_level ); } /*! @@ -90,19 +95,23 @@ H5FedGetNumVerticesTotal( q \return \c -1 on error. */ h5_size_t H5FedGetNumVerticesCnode ( - h5_file_t * fh, /*!< file handle */ + h5_file_t * const f, /*!< file handle */ const h5_id_t cnode /*!< compute node */ ) { - return -1; + SET_FNAME ( f, __func__ ); + h5_id_t cur_level = h5t_get_level( f ); + return h5t_get_num_vertices ( f, cnode, cur_level ); } /****** TRIANGLE statistics routines *****************************************/ h5_size_t H5FedGetNumTriangles ( - h5_file_t * fh /*!< file handle */ + h5_file_t * const f /*!< file handle */ ) { - return h5t_get_num_entities_on_level ( fh ); + SET_FNAME ( f, __func__ ); + h5_id_t cur_level = h5t_get_level( f ); + return h5t_get_num_entities ( f, f->myproc, cur_level ); } /*! @@ -116,9 +125,11 @@ H5FedGetNumTriangles ( */ h5_size_t H5FedGetNumTrianglesTotal ( - h5_file_t * fh /*!< file handle */ + h5_file_t * const f /*!< file handle */ ) { - return h5t_get_num_entities_on_level ( fh ); + SET_FNAME ( f, __func__ ); + h5_id_t cur_level = h5t_get_level( f ); + return h5t_get_num_entities ( f, -1, cur_level ); } @@ -133,10 +144,12 @@ H5FedGetNumTrianglesTotal ( */ h5_size_t H5FedGetNumTrianglesCnode ( - h5_file_t * fh, /*!< file handle */ + h5_file_t * const f, /*!< file handle */ const h5_id_t cnode /*!< compute node to query */ ) { - return -1; + SET_FNAME ( f, __func__ ); + h5_id_t cur_level = h5t_get_level( f ); + return h5t_get_num_entities ( f, cnode, cur_level ); } /****** TETRAHEDRON statistics routines **************************************/ @@ -145,17 +158,27 @@ H5FedGetNumTrianglesCnode ( \ingroup h5fed_mesh_inquiry Returns the number of tetrahedral elements present in the mesh at - level \c level in current step summed up over all compute nodes. + current \c level summed up over all compute nodes. \return number of tetrahedra \return \c -1 on error. */ h5_size_t -H5FedGetNumTetrahedraTotal( - h5_file_t * fh /*!< file handle */ +H5FedGetNumTetrahedra ( + h5_file_t * const f /*!< file handle */ ) { - SET_FNAME ( __func__ ); - return h5t_get_num_entities_on_level ( fh ); + SET_FNAME ( f, __func__ ); + h5_id_t cur_level = h5t_get_level( f ); + return h5t_get_num_entities ( f, f->myproc, cur_level ); +} + +h5_size_t +H5FedGetNumTetrahedraTotal ( + h5_file_t * const f /*!< file handle */ + ) { + SET_FNAME ( f, __func__ ); + h5_id_t cur_level = h5t_get_level( f ); + return h5t_get_num_entities ( f, -1, cur_level ); } /*! @@ -168,10 +191,12 @@ H5FedGetNumTetrahedraTotal( \return \c -1 on error. */ h5_size_t H5FedGetNumTetrahedraCnode ( - h5_file_t * fh, /*!< file handle */ - const h5_id_t level /*!< mesh level to query */ + h5_file_t * const f, /*!< file handle */ + const h5_id_t cnode /*!< compute node to query */ ) { - return -1; + SET_FNAME ( f, __func__ ); + h5_id_t cur_level = h5t_get_level( f ); + return h5t_get_num_entities ( f, cnode, cur_level ); } diff --git a/src/H5Fed_map.c b/src/H5Fed_map.c index 104dd1e..4d8e5fe 100644 --- a/src/H5Fed_map.c +++ b/src/H5Fed_map.c @@ -24,19 +24,19 @@ h5_id_t H5FedMapTet2GlobalID ( - h5_file_t *f, + h5_file_t * const f, h5_id_t * const global_vids ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_get_global_entity_id ( f, global_vids ); } h5_id_t H5FedMapTriangle2GlobalID ( - h5_file_t *f, + h5_file_t * const f, h5_id_t * const global_vids ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_get_global_triangle_id ( f, global_vids ); } diff --git a/src/H5Fed_retrieve.c b/src/H5Fed_retrieve.c index cab4ef3..cf4b51a 100644 --- a/src/H5Fed_retrieve.c +++ b/src/H5Fed_retrieve.c @@ -21,9 +21,9 @@ h5_err_t H5FedStartTraverseVertices ( - h5_file_t * f /*!< file handle */ + h5_file_t * const f /*!< file handle */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_start_traverse_vertices ( f ); } @@ -38,11 +38,11 @@ H5FedStartTraverseVertices ( */ h5_id_t H5FedTraverseVertices ( - h5_file_t * f, /*!< file handle */ + h5_file_t * const f, /*!< file handle */ h5_id_t * const id, /*!< OUT: global id */ h5_float64_t P[3] /*!< OUT: coordinates */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_traverse_vertices ( f, id, P ); } @@ -50,30 +50,30 @@ H5FedTraverseVertices ( h5_err_t H5FedStartTraverseTriangles ( - h5_file_t * f /*!< file handle */ + h5_file_t * const f /*!< file handle */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_start_traverse_triangles ( f ); } h5_id_t H5FedTraverseTriangles ( - h5_file_t * f, /*!< file handle */ + h5_file_t * const f, /*!< file handle */ h5_id_t * const id, /*!< OUT: global tetrahedron id */ h5_id_t * const parent_id, /*!< OUT: parent id if level \c >0 else \c -1 */ h5_id_t vertex_ids[3] /*!< OUT: vertex id's */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_traverse_triangles ( f, id, parent_id, vertex_ids ); } h5_err_t H5FedStartTraverseTetrahedra ( - h5_file_t * f /*!< file handle */ + h5_file_t * const f /*!< file handle */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_start_traverse_tets ( f ); } @@ -90,13 +90,13 @@ H5FedStartTraverseTetrahedra ( */ h5_id_t H5FedTraverseTetrahedra ( - h5_file_t * f, /*!< file handle */ + h5_file_t * const f, /*!< file handle */ h5_id_t * const id, /*!< OUT: global tetrahedron id */ h5_id_t * const parent_id, /*!< OUT: parent id if level \c >0 else \c -1 */ h5_id_t vertex_ids[4] /*!< OUT: vertex id's */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_traverse_tets ( f, id, parent_id, vertex_ids ); } diff --git a/src/H5Fed_store.c b/src/H5Fed_store.c index 55f75a5..b608ce1 100644 --- a/src/H5Fed_store.c +++ b/src/H5Fed_store.c @@ -18,9 +18,31 @@ #include "h5_core/h5_core.h" #include "H5Fed.h" + +h5_id_t +H5FedAddTetMesh ( + h5_file_t * const f, + ) { + SET_FNAME ( f, __func__ ); + return h5t_open_mesh ( f, -1, H5_OID_TETRAHEDRON ); +} + +h5_id_t +H5FedAddTriangleMesh ( + h5_file_t * const f + ) { + SET_FNAME ( f, __func__ ); + return h5t_open_mesh ( f, -1, H5_OID_TRIANGLE ); +} + + /*! + \ingroup h5fed_c_api + Add a new level. + \return ID of new level. + \note values for f->t.num_levels: \c -1 unknown: after opening the file. This is equivalent to @@ -28,53 +50,15 @@ \c 0 no levels: HDF5 group for meshes may already exist but must not! \c > 0 number of mesh levels - \note - write new level: - H5FedAddLevel( f ); - H5FedAddNumVertices( f, nv ); - H5FedAddNumEntities( f, ne ); */ - h5_id_t H5FedAddLevel ( - h5_file_t * f /*!< file handle */ + h5_file_t * const f /*!< file handle */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); return h5t_add_level ( f ); } -#if 0 -/*! - \ingroup h5fed_c_api - - Set number of additional vertices in current step and level - - ERRORS: - - H5_ERR_INVAL: It is not possible to add vertices to an existing mesh due - to limitation of the library - - H5_ERR_NOMEM: Couldn't allocate enough memory. - - \return number of vertices - \return errno on error -*/ -h5_err_t -H5FedAddNumVertices ( - h5_file_t * f, /*!< file handle */ - const h5_size_t num /*!< number of additional vertices */ - ) { - - SET_FNAME ( __func__ ); - if ( h5t_get_level ( f ) != 0 ) { - return h5_error ( - H5_ERR_INVAL, - "Vertices can be added to level 0 only!" ); - } - return h5t_add_num_vertices ( f, num ); -} -#endif - /*! \ingroup h5fed_c_api @@ -86,40 +70,29 @@ H5FedAddNumVertices ( */ h5_id_t H5FedStoreVertex ( - h5_file_t * f, /*!< file handle */ - const h5_id_t id, /*!< global vertex id or -1 */ + h5_file_t * const f, /*!< file handle */ + const h5_id_t id, /*!< id from mesher or -1 */ const h5_float64_t P[3] /*!< coordinates */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); if ( h5t_get_level ( f ) != 0 ) { return h5_error ( + f, H5_ERR_INVAL, "Vertices can be added to level 0 only!" ); } return h5t_store_vertex ( f, id, P ); } -/*** T E T R A H E D R A ****************************************************/ - h5_err_t -H5FedAddNumTets ( - h5_file_t * f, /*!< file handle */ +H5FedAddNumElements ( + h5_file_t * const f, /*!< file handle */ const h5_size_t num /*!< number of additional tets on current level */ ) { - SET_FNAME ( __func__ ); - return h5t_add_num_tets ( f, num ); -} - -h5_err_t -H5FedAddNumTriangles ( - h5_file_t * f, /*!< file handle */ - const h5_size_t num /*!< number of additional - triangle on current level */ - ) { - SET_FNAME ( __func__ ); - return h5t_add_num_triangles ( f, num ); + SET_FNAME ( f, __func__ ); + return h5t_add_num_elements ( f, num ); } /*! @@ -137,44 +110,25 @@ H5FedAddNumTriangles ( \return \c errno on error */ h5_id_t -H5FedStoreTetrahedron ( - h5_file_t * f, /*!< file handle */ - const h5_id_t id, /*!< global tetrahedron id */ - const h5_id_t parent_id, /*!< global parent id - if level \c >0 else \c -1 */ - const h5_id_t vertex_ids[4] /*!< tuple with vertex id's */ +H5FedStoreElement ( + h5_file_t * const f, /*!< file handle */ + const h5_id_t local_vids[] /*!< tuple with vertex id's */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); if ( h5t_get_level ( f ) != 0 ) { return h5_error ( + f, H5_ERR_INVAL, "Tetrahedra can be added to level 0 only!" ); } - return h5t_store_tet ( f, id, parent_id, vertex_ids ); + return h5t_store_element ( f, -1, local_vids ); } h5_id_t -H5FedRefineTetrahedron ( - h5_file_t * f, /*!< file handle */ - const h5_id_t id /*!< global tetrahedron id */ +H5FedRefineElement ( + h5_file_t * const f, /*!< file handle */ + const h5_id_t local_cid /*!< local element id */ ) { - SET_FNAME ( __func__ ); - return h5t_refine_tet ( f, id ); -} - -h5_id_t -H5FedStoreTriangle ( - h5_file_t * f, /*!< file handle */ - const h5_id_t id, /*!< global tetrahedron id */ - const h5_id_t parent_id, /*!< global parent id - if level \c >0 else \c -1 */ - h5_id_t vertex_ids[3] /*!< tuple with vertex id's */ - ) { - SET_FNAME ( __func__ ); - if ( h5t_get_level ( f ) != 0 ) { - return h5_error ( - H5_ERR_INVAL, - "Triangles can be added to level 0 only!" ); - } - return h5t_store_triangle ( f, id, parent_id, vertex_ids ); + SET_FNAME ( f, __func__ ); + return h5t_refine_element ( f, local_cid ); } diff --git a/src/H5Fed_store.h b/src/H5Fed_store.h new file mode 100644 index 0000000..ebfda85 --- /dev/null +++ b/src/H5Fed_store.h @@ -0,0 +1,63 @@ +/* + Header file for declaring the H5Fed application programming + interface (API) in the C language. + + Copyright 2006-2009 + Paul Scherrer Institut, Villigen, Switzerland; + Benedikt Oswald; + Achim Gsell + All rights reserved. + + Authors + Achim Gsell + + Warning + This code is under development. + + */ + +#ifndef __H5FED_STORE_H +#define __H5FED_STORE_H + +h5_id_t +H5FedAddTetMesh ( + h5_file_t * const f + ); + +h5_id_t +H5FedAddTriangleMesh ( + h5_file_t * const f + ); + +h5_id_t +H5FedAddLevel ( + h5_file_t * f + ); + +h5_err_t +H5FedAddNumVertices ( + h5_file_t * f, + const h5_size_t num + ); + +h5_err_t +H5FedAddNumElements ( + h5_file_t * f, + const h5_size_t num + ); + +h5_id_t +H5FedStoreVertex ( + h5_file_t * f, + const h5_id_t id, + const h5_float64_t P[3] + ); + +h5_id_t +H5FedStoreElement ( + h5_file_t * f, + h5_id_t *vertex_ids + ); + + +#endif diff --git a/src/H5Part.c b/src/H5Part.c index 20d05b3..433d836 100644 --- a/src/H5Part.c +++ b/src/H5Part.c @@ -1,78 +1,3 @@ -/*! \mainpage H5Part: A Portable High Performance Parallel Data Interface to HDF5 - -Particle based simulations of accelerator beam-lines, especially in -six dimensional phase space, generate vast amounts of data. Even -though a subset of statistical information regarding phase space or -analysis needs to be preserved, reading and writing such enormous -restart files on massively parallel supercomputing systems remains -challenging. - -H5Part consists of Particles and Block structured Fields. - -Developed by: - - - - -Papers: - - - -For further information contact: h5part - -Last modified on April 19, 2007. - -*/ - - -/*! - \defgroup h5part_c_api H5Part C API - -*/ -/*! - \ingroup h5part_c_api - \defgroup h5part_openclose File Opening and Closing -*/ -/*! - \ingroup h5part_c_api - \defgroup h5part_write File Writing -*/ -/*! - \ingroup h5part_c_api - \defgroup h5part_read File Reading -*/ -/*! - \ingroup h5part_c_api - \defgroup h5part_attrib Reading and Writing Attributes -*/ -/*! - \ingroup h5part_c_api - \defgroup h5part_errhandle Error Handling -*/ -/*! - \internal - \defgroup h5partkernel H5Part private functions -*/ - #include #include @@ -102,9 +27,13 @@ Last modified on April 19, 2007. /*========== File Opening/Closing ===============*/ +/*! + \ingroup h5part_c_api + \defgroup h5part_c_api_openclose File Opening and Closing +*/ /*! - \ingroup h5part_openclose + \ingroup h5part_c_api_openclose Opens file with specified filename. @@ -129,11 +58,11 @@ H5PartOpenFileParallel ( unsigned flags, /*!< [in] The access mode for the file. */ MPI_Comm comm /*!< [in] MPI communicator */ ) { - return h5_open_file ( filename, flags, comm ); + return h5_open_file ( filename, flags, comm, __func__ ); } /*! - \ingroup h5part_openclose + \ingroup h5part_c_api_openclose Opens file with specified filename. @@ -159,15 +88,13 @@ H5PartOpenFile ( unsigned flags /*!< [in] The access mode for the file. */ ) { - SET_FNAME ( "H5PartOpenFile" ); - MPI_Comm comm = 0; /* dummy */ - return h5_open_file ( filename, flags, comm ); + return h5_open_file ( filename, flags, comm, __func__ ); } /*! - \ingroup h5part_openclose + \ingroup h5part_c_api_openclose Closes an open file. @@ -178,26 +105,31 @@ H5PartCloseFile ( h5_file_t *f /*!< [in] filehandle of the file to close */ ) { - SET_FNAME ( "H5PartCloseFile" ); + SET_FNAME ( f, __func__ ); return h5_close_file( f ); } /*============== File Writing Functions ==================== */ +/*! + \ingroup h5part_c_api + \defgroup h5part_c_api_write File Writing +*/ + h5_int64_t H5PartDefineStepName ( h5_file_t *f, const char *name, const h5_int64_t width ) { - SET_FNAME ( "H5PartDefineStepName" ); + SET_FNAME ( f, __func__ ); return h5_define_stepname_fmt( f, name, width ); } /*! - \ingroup h5part_write + \ingroup h5part_c_api_write Set number of particles for current time-step. @@ -216,13 +148,13 @@ H5PartSetNumParticles ( h5_int64_t nparticles /*!< [in] Number of particles */ ) { - SET_FNAME ( "H5PartSetNumParticles" ); + SET_FNAME ( f, __func__ ); - return H5U_set_num_elements( f, nparticles ); + return h5u_set_num_elements( f, nparticles ); } /*! - \ingroup h5part_write + \ingroup h5part_c_api_write Write array of 64 bit floating point data to file. @@ -254,13 +186,13 @@ H5PartWriteDataFloat64 ( const h5_float64_t *array /*!< [in] Array to commit to disk */ ) { - SET_FNAME ( "H5PartWriteDataFloat64" ); + SET_FNAME ( f, __func__ ); - return H5U_write_data ( f, name, (void*)array, H5T_NATIVE_DOUBLE ); + return h5u_write_data ( f, name, (void*)array, H5T_NATIVE_DOUBLE ); } /*! - \ingroup h5part_write + \ingroup h5part_c_api_write Write array of 64 bit integer data to file. @@ -292,9 +224,9 @@ H5PartWriteDataInt64 ( const h5_int64_t *array /*!< [in] Array to commit to disk */ ) { - SET_FNAME ( "H5PartOpenWriteDataInt64" ); + SET_FNAME ( f, __func__ ); - return H5U_write_data ( f, name, (void*)array, H5T_NATIVE_INT64 ); + return h5u_write_data ( f, name, (void*)array, H5T_NATIVE_INT64 ); } /********************** reading and writing attribute ************************/ @@ -305,7 +237,12 @@ H5PartWriteDataInt64 ( /********************** attribute API ****************************************/ /*! - \ingroup h5part_attrib + \ingroup h5part_c_api + \defgroup h5part_c_api_attrib Reading and Writing Attributes +*/ + +/*! + \ingroup h5part_c_api_attrib Writes a string attribute bound to a file. @@ -325,12 +262,13 @@ H5PartWriteFileAttribString ( const char *attrib_value/*!< [in] Value of attribute */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno( f ); return h5_write_attrib ( + f, f->root_gid, attrib_name, H5T_NATIVE_CHAR, @@ -339,7 +277,7 @@ H5PartWriteFileAttribString ( } /*! - \ingroup h5part_attrib + \ingroup h5part_c_api_attrib Writes a string attribute bound to the current time-step. @@ -360,12 +298,13 @@ H5PartWriteStepAttribString ( const char *attrib_value/*!< [in] Value of attribute */ ) { - SET_FNAME ( "H5PartWriteStepAttribString" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno( f ); return h5_write_attrib ( + f, f->step_gid, attrib_name, H5T_NATIVE_CHAR, @@ -374,7 +313,7 @@ H5PartWriteStepAttribString ( } /*! - \ingroup h5part_attrib + \ingroup h5part_c_api_attrib Writes a attribute bound to the current time-step. @@ -401,12 +340,13 @@ H5PartWriteStepAttrib ( const h5_int64_t attrib_nelem/*!< [in] Number of elements */ ){ - SET_FNAME ( "H5PartWriteStepAttrib" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno( f ); return h5_write_attrib ( + f, f->step_gid, attrib_name, (const hid_t)attrib_type, @@ -415,7 +355,7 @@ H5PartWriteStepAttrib ( } /*! - \ingroup h5part_attrib + \ingroup h5part_c_api_attrib Writes a attribute bound to a file. @@ -442,12 +382,13 @@ H5PartWriteFileAttrib ( const h5_int64_t attrib_nelem/*!< [in] Number of elements */ ) { - SET_FNAME ( "H5PartWriteFileAttrib" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno( f ); return h5_write_attrib ( + f, f->root_gid, attrib_name, (const hid_t)attrib_type, @@ -456,7 +397,7 @@ H5PartWriteFileAttrib ( } /*! - \ingroup h5part_attrib + \ingroup h5part_c_api_attrib Gets the number of attributes bound to the current step. @@ -467,16 +408,16 @@ H5PartGetNumStepAttribs ( h5_file_t *f /*!< [in] Handle to open file */ ) { - SET_FNAME ( "H5PartGetNumStepAttribs" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno( f ); return h5_get_num_attribs ( f, f->step_gid ); } /*! - \ingroup h5part_attrib + \ingroup h5part_c_api_attrib Gets the number of attributes bound to the file. @@ -487,16 +428,16 @@ H5PartGetNumFileAttribs ( h5_file_t *f /*!< [in] Handle to open file */ ) { - SET_FNAME ( "H5PartGetNumFileAttribs" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno( f ); return h5_get_num_attribs ( f, f->root_gid ); } /*! - \ingroup h5part_attrib + \ingroup h5part_c_api_attrib Gets the name, type and number of elements of the step attribute specified by its index. @@ -521,12 +462,13 @@ H5PartGetStepAttribInfo ( h5_int64_t *attrib_nelem /*!< [out] Number of elements */ ) { - SET_FNAME ( "H5PartGetStepAttribInfo" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno( f ); return h5_get_attrib_info ( + f, f->step_gid, attrib_idx, attrib_name, @@ -536,7 +478,7 @@ H5PartGetStepAttribInfo ( } /*! - \ingroup h5part_attrib + \ingroup h5part_c_api_attrib Gets the name, type and number of elements of the file attribute specified by its index. @@ -561,12 +503,13 @@ H5PartGetFileAttribInfo ( h5_int64_t *attrib_nelem /*!< [out] Number of elements */ ) { - SET_FNAME ( "H5PartGetFileAttribInfo" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno ( f ); return h5_get_attrib_info ( + f, f->root_gid, attrib_idx, attrib_name, @@ -576,7 +519,7 @@ H5PartGetFileAttribInfo ( } /*! - \ingroup h5part_attrib + \ingroup h5part_c_api_attrib Reads an attribute bound to current time-step. @@ -589,16 +532,16 @@ H5PartReadStepAttrib ( void *attrib_value /*!< [out] Value of attribute */ ) { - SET_FNAME ( "H5PartReadStepAttrib" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno ( f ); - return h5_read_attrib ( f->step_gid, attrib_name, attrib_value ); + return h5_read_attrib ( f, f->step_gid, attrib_name, attrib_value ); } /*! - \ingroup h5part_attrib + \ingroup h5part_c_api_attrib Reads an attribute bound to file \c f. @@ -611,16 +554,22 @@ H5PartReadFileAttrib ( void *attrib_value ) { - SET_FNAME ( "H5PartReadFileAttrib" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno ( f ); - return h5_read_attrib ( f->root_gid, attrib_name, attrib_value ); + return h5_read_attrib ( f, f->root_gid, attrib_name, attrib_value ); } /*================== File Reading Routines =================*/ + +/*! + \ingroup h5part_c_api + \defgroup h5part_c_api_read File Reading +*/ + /* H5PartSetStep: @@ -633,7 +582,7 @@ H5PartReadFileAttrib ( */ /*! - \ingroup h5part_read + \ingroup h5part_c_api_read Set the current time-step. @@ -654,10 +603,10 @@ H5PartSetStep ( const h5_int64_t step /*!< [in] Time-step to set. */ ) { - SET_FNAME ( "H5PartSetStep" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno ( f ); return h5_set_step ( f, step ); } @@ -666,7 +615,7 @@ H5PartSetStep ( /*! - \ingroup h5part_read + \ingroup h5part_c_api_read Query whether a particular step already exists in the file \c f. @@ -681,16 +630,16 @@ H5PartHasStep ( h5_int64_t step /*!< [in] Step number to query */ ) { - SET_FNAME ( "H5PartHasStep" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno ( f ); return h5_has_step( f, step ); } /*! - \ingroup h5part_read + \ingroup h5part_c_api_read Get the number of time-steps that are currently stored in the file \c f. @@ -705,12 +654,12 @@ H5PartGetNumSteps ( h5_file_t *f /*!< [in] Handle to open file */ ) { - SET_FNAME ( "H5PartGetNumSteps" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno ( f ); - return h5_get_num_objects_matching_pattern ( + return hdf5_get_num_objects_matching_pattern ( f->file, "/", H5G_UNKNOWN, @@ -718,7 +667,7 @@ H5PartGetNumSteps ( } /*! - \ingroup h5part_read + \ingroup h5part_c_api_read Get the number of datasets that are stored at the current time-step. @@ -730,16 +679,16 @@ H5PartGetNumDatasets ( h5_file_t *f /*!< [in] Handle to open file */ ) { - SET_FNAME ( "H5PartGetNumDatasets" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno ( f ); - return h5_get_num_objects ( f->file, f->step_name, H5G_DATASET ); + return hdf5_get_num_objects ( f->file, f->step_name, H5G_DATASET ); } /*! - \ingroup h5part_read + \ingroup h5part_c_api_read This reads the name of a dataset specified by it's index in the current time-step. @@ -756,12 +705,12 @@ H5PartGetDatasetName ( const h5_int64_t len_of_name/*!< [in] Size of buffer \c name */ ) { - SET_FNAME ( "H5PartGetDatasetName" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno ( f ); - return h5_get_object_name ( + return hdf5_get_object_name ( f->file, f->step_name, H5G_DATASET, @@ -771,7 +720,7 @@ H5PartGetDatasetName ( } /*! - \ingroup h5part_read + \ingroup h5part_c_api_read Gets the name, type and number of elements of a dataset specified by it's index in the current time-step. @@ -791,17 +740,17 @@ H5PartGetDatasetInfo ( h5_int64_t *nelem /*!< [out] Number of elements. */ ) { - SET_FNAME ( "H5PartGetDatasetInfo" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno ( f ); - return H5U_get_dataset_info ( f, idx, - dataset_name, len_dataset_name, type, nelem ); + return h5u_get_dataset_info ( + f, idx, dataset_name, len_dataset_name, type, nelem ); } /*! - \ingroup h5part_read + \ingroup h5part_c_api_read This gets the number of particles stored in the current step. It will arbitrarily select a time-step if you haven't already set @@ -815,44 +764,44 @@ H5PartGetNumParticles ( h5_file_t *f /*!< [in] Handle to open file */ ) { - SET_FNAME ( "H5PartGetNumParticles" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno ( f ); if ( f->step_gid < 0 ) { h5_int64_t herr = h5_set_step ( f, 0 ); if ( herr < 0 ) return herr; } - return H5U_get_num_elems ( f ); + return h5u_get_num_elems ( f ); } /*! - \ingroup h5part_read + \ingroup h5part_c_api_read */ h5_int64_t H5PartResetView ( h5_file_t *f /*!< [in] Handle to open file */ ) { - SET_FNAME ( "H5PartResetView" ); + SET_FNAME ( f, __func__ ); if ( h5_check_filehandle ( f ) != H5_SUCCESS ) - return h5_get_errno(); + return h5_get_errno ( f ); CHECK_READONLY_MODE ( f ); - return H5U_reset_view ( f ); + return h5u_reset_view ( f ); } /*! - \ingroup h5part_read + \ingroup h5part_c_api_read */ h5_int64_t H5PartHasView ( h5_file_t *f /*!< [in] Handle to open file */ ) { - SET_FNAME ( __func__ ); + SET_FNAME ( f, __func__ ); CHECK_FILEHANDLE( f ); CHECK_READONLY_MODE ( f ); @@ -862,7 +811,7 @@ H5PartHasView ( /*! - \ingroup h5part_read + \ingroup h5part_c_api_read For parallel I/O or for subsetting operations on the datafile, the \c H5PartSetView() function allows you to define a subset of the total @@ -887,7 +836,7 @@ H5PartSetView ( const h5_int64_t end /*!< [in] End particle */ ) { - SET_FNAME ( "H5PartSetView" ); + SET_FNAME ( f, __func__ ); CHECK_FILEHANDLE( f ); CHECK_READONLY_MODE ( f ); @@ -897,11 +846,11 @@ H5PartSetView ( if ( herr < 0 ) return herr; } - return H5U_set_view ( f, start, end ); + return h5u_set_view ( f, start, end ); } /*! - \ingroup h5part_read + \ingroup h5part_c_api_read Allows you to query the current view. Start and End will be \c -1 if there is no current view established. @@ -917,7 +866,7 @@ H5PartGetView ( h5_int64_t *end /*!< [out] End particle */ ) { - SET_FNAME ( "H5PartGetView" ); + SET_FNAME ( f, __func__ ); CHECK_FILEHANDLE( f ); @@ -925,11 +874,11 @@ H5PartGetView ( h5_int64_t herr = h5_set_step ( f, 0 ); if ( herr < 0 ) return herr; } - return H5U_get_view( f, start, end ); + return h5u_get_view( f, start, end ); } /*! - \ingroup h5part_read + \ingroup h5part_c_api_read If it is too tedious to manually set the start and end coordinates for a view, the \c H5SetCanonicalView() will automatically select an @@ -950,7 +899,7 @@ H5PartSetCanonicalView ( h5_file_t *f /*!< [in] Handle to open file */ ) { - SET_FNAME ( "H5PartSetCanonicalView" ); + SET_FNAME ( f, __func__ ); h5_int64_t herr; @@ -962,11 +911,11 @@ H5PartSetCanonicalView ( if ( herr < 0 ) return herr; } - return H5U_set_canonical_view ( f ); + return h5u_set_canonical_view ( f ); } /*! - \ingroup h5part_read + \ingroup h5part_c_api_read Read array of 64 bit floating point data from file. @@ -984,15 +933,15 @@ H5PartReadDataFloat64 ( h5_float64_t *array /*!< [out] Array of data */ ) { - SET_FNAME ( "H5PartReadDataFloat64" ); + SET_FNAME ( f, __func__ ); CHECK_FILEHANDLE( f ); - return H5U_read_elems ( f, name, array, H5T_NATIVE_DOUBLE ); + return h5u_read_elems ( f, name, array, H5T_NATIVE_DOUBLE ); } /*! - \ingroup h5part_read + \ingroup h5part_c_api_read Read array of 64 bit floating point data from file. @@ -1010,15 +959,15 @@ H5PartReadDataInt64 ( h5_int64_t *array /*!< [out] Array of data */ ) { - SET_FNAME ( "H5PartReadDataInt64" ); + SET_FNAME ( f, __func__ ); CHECK_FILEHANDLE( f ); - return H5U_read_elems ( f, name, array, H5T_NATIVE_INT64 ); + return h5u_read_elems ( f, name, array, H5T_NATIVE_INT64 ); } /*! - \ingroup h5part_read + \ingroup h5part_c_api_read This is the mongo read function that pulls in all of the data for a given step in one shot. It also takes the step as an argument @@ -1044,7 +993,7 @@ H5PartReadParticleStep ( h5_int64_t *id /*!< [out] Buffer for dataset named "id" */ ) { - SET_FNAME ( "H5PartReadParticleStep" ); + SET_FNAME ( f, __func__ ); h5_int64_t herr; CHECK_FILEHANDLE( f ); @@ -1052,25 +1001,25 @@ H5PartReadParticleStep ( herr = h5_set_step ( f, step ); if ( herr < 0 ) return herr; - herr = H5U_read_elems ( f, "x", (void*)x, H5T_NATIVE_DOUBLE ); + herr = h5u_read_elems ( f, "x", (void*)x, H5T_NATIVE_DOUBLE ); if ( herr < 0 ) return herr; - herr = H5U_read_elems ( f, "y", (void*)y, H5T_NATIVE_DOUBLE ); + herr = h5u_read_elems ( f, "y", (void*)y, H5T_NATIVE_DOUBLE ); if ( herr < 0 ) return herr; - herr = H5U_read_elems ( f, "z", (void*)z, H5T_NATIVE_DOUBLE ); + herr = h5u_read_elems ( f, "z", (void*)z, H5T_NATIVE_DOUBLE ); if ( herr < 0 ) return herr; - herr = H5U_read_elems ( f, "px", (void*)px, H5T_NATIVE_DOUBLE ); + herr = h5u_read_elems ( f, "px", (void*)px, H5T_NATIVE_DOUBLE ); if ( herr < 0 ) return herr; - herr = H5U_read_elems ( f, "py", (void*)py, H5T_NATIVE_DOUBLE ); + herr = h5u_read_elems ( f, "py", (void*)py, H5T_NATIVE_DOUBLE ); if ( herr < 0 ) return herr; - herr = H5U_read_elems ( f, "pz", (void*)pz, H5T_NATIVE_DOUBLE ); + herr = h5u_read_elems ( f, "pz", (void*)pz, H5T_NATIVE_DOUBLE ); if ( herr < 0 ) return herr; - herr = H5U_read_elems ( f, "id", (void*)id, H5T_NATIVE_INT64 ); + herr = h5u_read_elems ( f, "id", (void*)id, H5T_NATIVE_INT64 ); if ( herr < 0 ) return herr; return H5_SUCCESS; @@ -1079,7 +1028,12 @@ H5PartReadParticleStep ( /****************** error handling ******************/ /*! - \ingroup h5part_errhandle + \ingroup h5part_c_api + \defgroup h5part_c_api_errhandling Error Handling +*/ + +/*! + \ingroup h5part_c_api_errhandling Set verbosity level to \c level. @@ -1094,7 +1048,7 @@ H5PartSetVerbosityLevel ( } /*! - \ingroup h5part_errhandle + \ingroup h5part_c_api_errhandling Set error handler to \c handler. @@ -1102,20 +1056,20 @@ H5PartSetVerbosityLevel ( */ h5_int64_t H5PartSetErrorHandler ( - h5_error_handler handler + h5_errorhandler_t handler ) { return h5_set_errorhandler( handler ); } /*! - \ingroup h5part_errhandle + \ingroup h5part_c_api_errhandling Get current error handler. \return Pointer to error handler. */ -h5_error_handler +h5_errorhandler_t H5PartGetErrorHandler ( void ) { @@ -1123,7 +1077,7 @@ H5PartGetErrorHandler ( } /*! - \ingroup h5part_errhandle + \ingroup h5part_c_api_errhandling Get last error code. @@ -1131,9 +1085,9 @@ H5PartGetErrorHandler ( */ h5_int64_t H5PartGetErrno ( - void + h5_file_t * const f ) { - return h5_get_errno(); + return h5_get_errno( f ); } /*! @} */ diff --git a/src/H5Part.h b/src/H5Part.h index 2d84584..f972fd9 100644 --- a/src/H5Part.h +++ b/src/H5Part.h @@ -279,31 +279,29 @@ H5PartSetVerbosityLevel ( h5_int64_t H5PartSetErrorHandler ( - const h5_error_handler handler + const h5_errorhandler_t handler ); h5_int64_t H5PartGetErrno ( - void + h5_file_t *f ); -h5_error_handler +h5_errorhandler_t H5PartGetErrorHandler ( void ); h5_int64_t H5PartReportErrorHandler ( - const char *funcname, - const h5_int64_t eno, + h5_file_t *f, const char *fmt, ... ); h5_int64_t H5PartAbortErrorHandler ( - const char *funcname, - const h5_int64_t eno, + h5_file_t *f, const char *fmt, ... );