diff options
Diffstat (limited to 'src/H5Sselect.c')
-rw-r--r-- | src/H5Sselect.c | 416 |
1 files changed, 247 insertions, 169 deletions
diff --git a/src/H5Sselect.c b/src/H5Sselect.c index ea10517..24586de 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -17,9 +17,16 @@ * Purpose: Dataspace selection functions. */ +/****************/ +/* Module Setup */ +/****************/ + #include "H5Smodule.h" /* This source code file is part of the H5S module */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ @@ -27,16 +34,40 @@ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Spkg.h" /* Dataspaces */ -#include "H5VMprivate.h" /* Vector and array functions */ -#include "H5WBprivate.h" /* Wrapped Buffers */ +#include "H5VMprivate.h" /* Vector and array functions */ + + +/****************/ +/* Local Macros */ +/****************/ + + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ -/* Local functions */ #ifdef LATER static herr_t H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static htri_t H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter); static herr_t H5S_select_iter_next_block(H5S_sel_iter_t *iter); #endif /* LATER */ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + /* Declare a free list to manage the H5S_sel_iter_t struct */ H5FL_DEFINE(H5S_sel_iter_t); @@ -47,6 +78,11 @@ H5FL_SEQ_EXTERN(size_t); H5FL_SEQ_EXTERN(hsize_t); +/*******************/ +/* Local Variables */ +/*******************/ + + /*-------------------------------------------------------------------------- NAME @@ -78,13 +114,56 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset) HDassert(offset); /* Copy the offset over */ - HDmemcpy(space->select.offset, offset, sizeof(hssize_t)*space->extent.rank); + HDmemcpy(space->select.offset, offset, sizeof(hssize_t) * space->extent.rank); /* Indicate that the offset was changed */ space->select.offset_changed = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_select_offset() */ +} /* end H5S_select_offset() */ + + +/*-------------------------------------------------------------------------- + NAME + H5Soffset_simple + PURPOSE + Changes the offset of a selection within a simple dataspace extent + USAGE + herr_t H5Soffset_simple(space_id, offset) + hid_t space_id; IN: Dataspace object to reset + const hssize_t *offset; IN: Offset to position the selection at + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + This function creates an offset for the selection within an extent, allowing + the same shaped selection to be moved to different locations within a + dataspace without requiring it to be re-defined. +--------------------------------------------------------------------------*/ +herr_t +H5Soffset_simple(hid_t space_id, const hssize_t *offset) +{ + H5S_t *space; /* Dataspace to query */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*Hs", space_id, offset); + + /* Check args */ + if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") + if(space->extent.rank == 0 || (H5S_GET_EXTENT_TYPE(space) == H5S_SCALAR + || H5S_GET_EXTENT_TYPE(space) == H5S_NULL)) + HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar or null dataspace") + if(offset == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified") + + /* Set the selection offset */ + if(H5S_select_offset(space, offset) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set offset") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Soffset_simple() */ /*-------------------------------------------------------------------------- @@ -139,9 +218,10 @@ done: PURPOSE Copy a selection from one dataspace to another USAGE - herr_t H5S_select_copy(dst, src) + herr_t H5S_select_copy(dst, src, share_selection) H5S_t *dst; OUT: Pointer to the destination dataspace H5S_t *src; IN: Pointer to the source dataspace + hbool_t; IN: Whether to share the selection between the dataspaces RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -177,7 +257,7 @@ H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_copy() */ +} /* end H5S_select_copy() */ /*------------------------------------------------------------------------- @@ -211,44 +291,7 @@ H5S_select_release(H5S_t *ds) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_select_release() */ - - -/*------------------------------------------------------------------------- - * Function: H5S_select_get_seq_list - * - * Purpose: Retrieves the next sequence of offset/length pairs for an - * iterator on a dataspace - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Tuesday, May 18, 2004 - * - * Note: This routine participates in the "Inlining C function pointers" - * pattern, don't call it directly, use the appropriate macro - * defined in H5Sprivate.h. - * - *------------------------------------------------------------------------- - */ -herr_t -H5S_select_get_seq_list(const H5S_t *space, unsigned flags, - H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, - size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len) -{ - herr_t ret_value = FAIL; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - HDassert(space); - - /* Call the selection type's get_seq_list function */ - if((ret_value = (*space->select.type->get_seq_list)(space, flags, iter, maxseq, maxbytes, nseq, nbytes, off, len)) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get selection sequence list") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_select_get_seq_list() */ +} /* end H5S_select_release() */ /*------------------------------------------------------------------------- @@ -278,10 +321,10 @@ H5S_select_serial_size(const H5S_t *space) HDassert(space); /* Call the selection type's serial_size function */ - ret_value=(*space->select.type->serial_size)(space); + ret_value = (*space->select.type->serial_size)(space); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_select_serial_size() */ +} /* end H5S_select_serial_size() */ /*-------------------------------------------------------------------------- @@ -311,7 +354,7 @@ H5S_select_serial_size(const H5S_t *space) herr_t H5S_select_serialize(const H5S_t *space, uint8_t **p) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -319,10 +362,10 @@ H5S_select_serialize(const H5S_t *space, uint8_t **p) HDassert(p); /* Call the selection type's serialize function */ - ret_value=(*space->select.type->serialize)(space,p); + ret_value = (*space->select.type->serialize)(space, p); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_select_serialize() */ +} /* end H5S_select_serialize() */ /*-------------------------------------------------------------------------- @@ -359,7 +402,7 @@ H5Sget_select_npoints(hid_t spaceid) done: FUNC_LEAVE_API(ret_value) -} /* H5Sget_select_npoints() */ +} /* H5Sget_select_npoints() */ /*-------------------------------------------------------------------------- @@ -382,7 +425,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -hssize_t +H5_ATTR_PURE hssize_t H5S_get_select_npoints(const H5S_t *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -391,7 +434,7 @@ H5S_get_select_npoints(const H5S_t *space) HDassert(space); FUNC_LEAVE_NOAPI((hssize_t)space->select.num_elem) -} /* H5S_get_select_npoints() */ +} /* end H5S_get_select_npoints() */ /*-------------------------------------------------------------------------- @@ -413,8 +456,6 @@ H5S_get_select_npoints(const H5S_t *space) COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG - Christian Chilan 01/17/2007 - Changed the error return value from 0 to FAIL. --------------------------------------------------------------------------*/ htri_t H5Sselect_valid(hid_t spaceid) @@ -433,7 +474,7 @@ H5Sselect_valid(hid_t spaceid) done: FUNC_LEAVE_API(ret_value) -} /* H5Sselect_valid() */ +} /* end H5Sselect_valid() */ /*-------------------------------------------------------------------------- @@ -471,7 +512,7 @@ H5S_select_valid(const H5S_t *space) ret_value = (*space->select.type->is_valid)(space); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_valid() */ +} /* end H5S_select_valid() */ /*-------------------------------------------------------------------------- @@ -584,7 +625,7 @@ H5S_select_deserialize(H5S_t **space, const uint8_t **p) default: break; - } + } /* end switch */ if(ret_value < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "can't deserialize selection") @@ -599,7 +640,7 @@ done: HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_deserialize() */ +} /* end H5S_select_deserialize() */ /*-------------------------------------------------------------------------- @@ -651,7 +692,7 @@ H5Sget_select_bounds(hid_t spaceid, hsize_t start[], hsize_t end[]) done: FUNC_LEAVE_API(ret_value) -} /* H5Sget_select_bounds() */ +} /* end H5Sget_select_bounds() */ /*-------------------------------------------------------------------------- @@ -693,10 +734,10 @@ H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) HDassert(start); HDassert(end); - ret_value = (*space->select.type->bounds)(space,start,end); + ret_value = (*space->select.type->bounds)(space, start, end); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_get_select_bounds() */ +} /* end H5S_get_select_bounds() */ /*-------------------------------------------------------------------------- @@ -736,7 +777,7 @@ H5S_get_select_offset(const H5S_t *space, hsize_t *offset) ret_value = (*space->select.type->offset)(space, offset); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_get_select_offset() */ +} /* end H5S_get_select_offset() */ /*-------------------------------------------------------------------------- @@ -774,7 +815,7 @@ H5S_get_select_unlim_dim(const H5S_t *space) ret_value = (*space->select.type->unlim_dim)(space); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_get_select_unlim_dim() */ +} /* end H5S_get_select_unlim_dim() */ /*-------------------------------------------------------------------------- @@ -819,7 +860,7 @@ H5S_get_select_num_elem_non_unlim(const H5S_t *space, done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_get_select_unlim_dim() */ +} /* end H5S_get_select_unlim_dim() */ /*-------------------------------------------------------------------------- @@ -856,7 +897,7 @@ H5S_select_is_contiguous(const H5S_t *space) ret_value = (*space->select.type->is_contiguous)(space); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_is_contiguous() */ +} /* end H5S_select_is_contiguous() */ /*-------------------------------------------------------------------------- @@ -893,7 +934,7 @@ H5S_select_is_single(const H5S_t *space) ret_value = (*space->select.type->is_single)(space); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_is_single() */ +} /* end H5S_select_is_single() */ /*-------------------------------------------------------------------------- @@ -930,7 +971,7 @@ H5S_select_is_regular(const H5S_t *space) ret_value = (*space->select.type->is_regular)(space); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_is_regular() */ +} /* end H5S_select_is_regular() */ /*-------------------------------------------------------------------------- @@ -968,7 +1009,7 @@ H5S_select_adjust_u(H5S_t *space, const hsize_t *offset) ret_value = (*space->select.type->adjust_u)(space, offset); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_adjust_u() */ +} /* end H5S_select_adjust_u() */ /*-------------------------------------------------------------------------- @@ -1007,7 +1048,7 @@ H5S_select_project_scalar(const H5S_t *space, hsize_t *offset) ret_value = (*space->select.type->project_scalar)(space, offset); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_project_scalar() */ +} /* end H5S_select_project_scalar() */ /*-------------------------------------------------------------------------- @@ -1048,7 +1089,7 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset) ret_value = (*space->select.type->project_simple)(space, new_space, offset); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_project_simple() */ +} /* end H5S_select_project_simple() */ /*-------------------------------------------------------------------------- @@ -1098,7 +1139,7 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_s HDassert(sel_iter->type); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_init() */ +} /* end H5S_select_iter_init() */ /*-------------------------------------------------------------------------- @@ -1135,10 +1176,10 @@ H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords) HDassert(coords); /* Call iter_coords routine for selection type */ - ret_value = (*sel_iter->type->iter_coords)(sel_iter,coords); + ret_value = (*sel_iter->type->iter_coords)(sel_iter, coords); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_coords() */ +} /* end H5S_select_iter_coords() */ #ifdef LATER @@ -1170,7 +1211,7 @@ H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { herr_t ret_value; /* return value */ - FUNC_ENTER_NOAPI_NOINIT_NOINIT_NOERR + FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(iter); @@ -1178,10 +1219,10 @@ H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) HDassert(end); /* Call iter_block routine for selection type */ - ret_value = (*iter->type->iter_block)(iter,start,end); + ret_value = (*iter->type->iter_block)(iter, start, end); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_block() */ +} /* end H5S_select_iter_block() */ #endif /* LATER */ @@ -1219,7 +1260,7 @@ H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter) ret_value = (*sel_iter->type->iter_nelmts)(sel_iter); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_nelmts() */ +} /* end H5S_select_iter_nelmts() */ #ifdef LATER @@ -1249,7 +1290,7 @@ H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter) { herr_t ret_value; /* return value */ - FUNC_ENTER_NOAPI_NOINIT_NOINIT_NOERR + FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(iter); @@ -1258,7 +1299,7 @@ H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter) ret_value = (*iter->type->iter_has_next_block)(iter); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_has_next_block() */ +} /* end H5S_select_iter_has_next_block() */ #endif /* LATER */ @@ -1296,13 +1337,13 @@ H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem) HDassert(nelem>0); /* Call iter_next routine for selection type */ - ret_value = (*iter->type->iter_next)(iter,nelem); + ret_value = (*iter->type->iter_next)(iter, nelem); /* Decrement the number of elements left in selection */ iter->elmt_left-=nelem; FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_next() */ +} /* end H5S_select_iter_next() */ #ifdef LATER @@ -1343,10 +1384,48 @@ H5S_select_iter_next_block(H5S_sel_iter_t *iter) ret_value = (*iter->type->iter_next_block)(iter); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_next_block() */ +} /* end H5S_select_iter_next_block() */ #endif /* LATER */ +/*------------------------------------------------------------------------- + * Function: H5S_select_get_seq_list + * + * Purpose: Retrieves the next sequence of offset/length pairs for an + * iterator on a dataspace + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Tuesday, May 18, 2004 + * + * Note: This routine participates in the "Inlining C function pointers" + * pattern, don't call it directly, use the appropriate macro + * defined in H5Sprivate.h. + * + *------------------------------------------------------------------------- + */ +herr_t +H5S_select_get_seq_list(const H5S_t *space, unsigned flags, + H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, + size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len) +{ + herr_t ret_value = FAIL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Sanity check */ + HDassert(space); + + /* Call the selection type's get_seq_list function */ + if((ret_value = (*space->select.type->get_seq_list)(space, flags, iter, maxseq, maxbytes, nseq, nbytes, off, len)) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get selection sequence list") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5S_select_get_seq_list() */ + + /*-------------------------------------------------------------------------- NAME H5S_select_iter_release @@ -1381,7 +1460,7 @@ H5S_select_iter_release(H5S_sel_iter_t *sel_iter) ret_value = (*sel_iter->type->iter_release)(sel_iter); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_release() */ +} /* end H5S_select_iter_release() */ /*-------------------------------------------------------------------------- @@ -1421,7 +1500,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, hsize_t *off = NULL; /* Array to store sequence offsets */ size_t *len = NULL; /* Array to store sequence lengths */ hssize_t nelmts; /* Number of elements in selection */ - hsize_t space_size[H5O_LAYOUT_NDIMS]; /* Dataspace size */ + hsize_t space_size[H5S_MAX_RANK]; /* Dataspace size */ size_t max_elem; /* Maximum number of elements allowed in sequences */ size_t elmt_size; /* Datatype size */ unsigned ndims; /* Number of dimensions in dataspace */ @@ -1495,7 +1574,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, /* Loop, while bytes left in sequence */ while(curr_len > 0 && user_ret == 0) { - hsize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of element in dataspace */ + hsize_t coords[H5S_MAX_RANK]; /* Coordinates of element in dataspace */ hsize_t tmp_off; /* Temporary offset within sequence */ uint8_t *loc; /* Current element location in buffer */ int i; /* Local Index variable */ @@ -1515,14 +1594,20 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, /* Make the application callback */ user_ret = (op->u.app_op.op)(loc, op->u.app_op.type_id, ndims, coords, op_data); break; + case H5S_SEL_ITER_OP_LIB: /* Call the library's callback */ user_ret = (op->u.lib_op)(loc, type, ndims, coords, op_data); break; + default: HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unsupported op type") } /* end switch */ + /* Check for error return from iterator */ + if(user_ret < 0) + HERROR(H5E_DATASPACE, H5E_CANTNEXT, "iteration operator failed"); + /* Increment offset in dataspace */ curr_off += elmt_size; @@ -1552,7 +1637,7 @@ done: iter = H5FL_FREE(H5S_sel_iter_t, iter); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_select_iterate() */ +} /* end H5S_select_iterate() */ /*-------------------------------------------------------------------------- @@ -1588,7 +1673,7 @@ H5Sget_select_type(hid_t space_id) done: FUNC_LEAVE_API(ret_value) -} /* end H5Sget_select_type() */ +} /* end H5Sget_select_type() */ /*-------------------------------------------------------------------------- @@ -1610,7 +1695,7 @@ done: pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. --------------------------------------------------------------------------*/ -H5S_sel_type +H5_ATTR_PURE H5S_sel_type H5S_get_select_type(const H5S_t *space) { H5S_sel_type ret_value = H5S_SEL_ERROR; /* Return value */ @@ -1621,10 +1706,10 @@ H5S_get_select_type(const H5S_t *space) HDassert(space); /* Set return value */ - ret_value=H5S_GET_SELECT_TYPE(space); + ret_value = H5S_GET_SELECT_TYPE(space); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_get_select_type() */ +} /* end H5S_get_select_type() */ /*-------------------------------------------------------------------------- @@ -1647,17 +1732,15 @@ H5S_get_select_type(const H5S_t *space) Assumes that there is only a single "block" for hyperslab selections. EXAMPLES REVISION LOG - Modified function to view identical shapes with different dimensions - as being the same under some circumstances. --------------------------------------------------------------------------*/ htri_t H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) { H5S_sel_iter_t *iter_a = NULL; /* Selection a iteration info */ H5S_sel_iter_t *iter_b = NULL; /* Selection b iteration info */ - hbool_t iter_a_init = FALSE; /* Selection a iteration info has been initialized */ - hbool_t iter_b_init = FALSE; /* Selection b iteration info has been initialized */ - htri_t ret_value = TRUE; /* Return value */ + hbool_t iter_a_init = FALSE; /* Selection a iteration info has been initialized */ + hbool_t iter_b_init = FALSE; /* Selection b iteration info has been initialized */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1677,20 +1760,19 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) unsigned space_a_rank; /* Number of dimensions of dataspace A */ unsigned space_b_rank; /* Number of dimensions of dataspace B */ - /* need to be able to handle spaces of different rank: + /* Need to be able to handle spaces of different rank: * * To simplify logic, let space_a point to the element of the set - * {space1, space2} with the largest rank or space1 if the ranks + * {space1, space2} with the largest rank or space1 if the ranks * are identical. * * Similarly, let space_b point to the element of {space1, space2} * with the smallest rank, or space2 if they are identical. * - * Let: space_a_rank be the rank of space_a, + * Let: space_a_rank be the rank of space_a, * space_b_rank be the rank of space_b, - * delta_rank = space_a_rank - space_b_rank. * - * Set all this up below. + * Set all this up here. */ if(space1->extent.rank >= space2->extent.rank) { space_a = space1; @@ -1709,10 +1791,6 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) HDassert(space_a_rank >= space_b_rank); HDassert(space_b_rank > 0); - /* Check for different number of elements selected */ - if(H5S_GET_SELECT_NPOINTS(space_a) != H5S_GET_SELECT_NPOINTS(space_b)) - HGOTO_DONE(FALSE) - /* Check for "easy" cases before getting into generalized block iteration code */ if((H5S_GET_SELECT_TYPE(space_a) == H5S_SEL_ALL) && (H5S_GET_SELECT_TYPE(space_b) == H5S_SEL_ALL)) { hsize_t dims1[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #1 */ @@ -1833,11 +1911,11 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) space_a_dim = (int)space_a_rank - 1; space_b_dim = (int)space_b_rank - 1; - /* The first block only compares the sizes and sets the - * relative offsets for later blocks + /* The first block only compares the sizes and sets the + * relative offsets for later blocks */ if(first_block) { - /* If the block sizes in the common dimensions from + /* If the block sizes in the common dimensions from * each selection don't match, get out */ while(space_b_dim >= 0) { @@ -1853,7 +1931,7 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) space_b_dim--; } /* end while */ - /* similarly, if the block size in any dimension that appears only + /* Similarly, if the block size in any dimension that appears only * in space_a is not equal to 1, get out. */ while(space_a_dim >= 0) { @@ -1871,7 +1949,7 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) } /* end if */ /* Check over the blocks for each selection */ else { - /* for dimensions that space_a and space_b have in common: */ + /* For dimensions that space_a and space_b have in common: */ while(space_b_dim >= 0) { /* Check if the blocks are in the same relative location */ if((start_a[space_a_dim] - off_a[space_a_dim]) != @@ -1932,7 +2010,7 @@ done: iter_b = H5FL_FREE(H5S_sel_iter_t, iter_b); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_shape_same() */ +} /* end H5S_select_shape_same() */ /*-------------------------------------------------------------------------- @@ -1941,24 +2019,24 @@ done: PURPOSE Given a dataspace a of rank n with some selection, construct a new - dataspace b of rank m (m != n), with the selection in a being - topologically identical to that in b (as verified by + dataspace b of rank m (m != n), with the selection in a being + topologically identical to that in b (as verified by H5S_select_shape_same(). - This function exists, as some I/O code chokes on topologically - identical selections with different ranks. At least to begin + This function exists, as some I/O code chokes on topologically + identical selections with different ranks. At least to begin with, we will deal with the issue by constructing projections - of the memory dataspace with ranks equaling those of the file + of the memory dataspace with ranks equaling those of the file dataspace. - Note that if m > n, it is possible that the starting point in the - buffer associated with the memory dataspace will have to be + Note that if m > n, it is possible that the starting point in the + buffer associated with the memory dataspace will have to be adjusted to match the projected dataspace. If the buf parameter is not NULL, the function must return an adjusted buffer base address in *adj_buf_ptr. USAGE - htri_t H5S_select_construct_projection(base_space, + htri_t H5S_select_construct_projection(base_space, new_space_ptr, new_space_rank, buf, @@ -1967,30 +2045,30 @@ done: H5S_t ** new_space_ptr; OUT: Ptr to location in which to return the address of the projected space int new_space_rank; IN: Rank of the projected space. - const void * buf; IN: Base address of the buffer + const void * buf; IN: Base address of the buffer associated with the base space. May be NULL. void ** adj_buf_ptr; OUT: If buf != NULL, store the base - address of the section of buf + address of the section of buf that is described by *new_space_ptr in *adj_buf_ptr. - + RETURNS Non-negative on success/Negative on failure. DESCRIPTION - Construct a new dataspace and associated selection which is a - projection of the supplied dataspace and associated selection into + Construct a new dataspace and associated selection which is a + projection of the supplied dataspace and associated selection into the specified rank. Return it in *new_space_ptr. - If buf is supplied, computes the base address of the projected + If buf is supplied, computes the base address of the projected selection in buf, and stores the base address in *adj_buf_ptr. - + GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS - The selection in the supplied base_space has thickness 1 in all + The selection in the supplied base_space has thickness 1 in all dimensions greater than new_space_rank. Note that here we count - dimensions from the fastest changing coordinate to the slowest + dimensions from the fastest changing coordinate to the slowest changing changing coordinate. EXAMPLES REVISION LOG @@ -2036,28 +2114,28 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, /* Create new scalar dataspace */ if(NULL == (new_space = H5S_create(H5S_SCALAR))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create scalar dataspace") - + /* No need to register the dataspace(i.e. get an ID) as * we will just be discarding it shortly. */ - /* Selection for the new space will be either all or + /* Selection for the new space will be either all or * none, depending on whether the base space has 0 or * 1 elements selected. * - * Observe that the base space can't have more than + * Observe that the base space can't have more than * one selected element, since its selection has the - * same shape as the file dataspace, and that data + * same shape as the file dataspace, and that data * space is scalar. */ if(1 == npoints) { /* Assuming that the selection in the base dataspace is not - * empty, we must compute the offset of the selected item in + * empty, we must compute the offset of the selected item in * the buffer associated with the base dataspace. * - * Since the new space rank is zero, we know that the - * the base space must have rank at least 1 -- and - * hence it is a simple dataspace. However, the + * Since the new space rank is zero, we know that the + * the base space must have rank at least 1 -- and + * hence it is a simple dataspace. However, the * selection, may be either point, hyperspace, or all. * */ @@ -2075,25 +2153,25 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, hsize_t new_space_dims[H5S_MAX_RANK]; /* Current dimensions for new dataspace */ hsize_t new_space_maxdims[H5S_MAX_RANK];/* Maximum dimensions for new dataspace */ unsigned rank_diff; /* Difference in ranks */ - + /* Set up the dimensions of the new, projected dataspace. * - * How we do this depends on whether we are projecting up into - * increased dimensions, or down into a reduced number of + * How we do this depends on whether we are projecting up into + * increased dimensions, or down into a reduced number of * dimensions. * - * If we are projecting up (the first half of the following - * if statement), we copy the dimensions of the base data - * space into the fastest changing dimensions of the new + * If we are projecting up (the first half of the following + * if statement), we copy the dimensions of the base data + * space into the fastest changing dimensions of the new * projected dataspace, and set the remaining dimensions to * one. * * If we are projecting down (the second half of the following - * if statement), we just copy the dimensions with the most + * if statement), we just copy the dimensions with the most * quickly changing dimensions into the dims for the projected * data set. * - * This works, because H5S_select_shape_same() will return + * This works, because H5S_select_shape_same() will return * true on selections of different rank iff: * * 1) the selection in the lower rank dataspace matches that @@ -2101,13 +2179,13 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * the larger rank dataspace, and * * 2) the selection has thickness 1 in all ranks that appear - * only in the higher rank dataspace (i.e. those with + * only in the higher rank dataspace (i.e. those with * more slowly changing indicies). - */ + */ if(new_space_rank > base_space_rank) { hsize_t tmp_dim_size = 1; /* Temporary dimension value, for filling arrays */ - /* we must copy the dimensions of the base space into + /* we must copy the dimensions of the base space into * the fastest changing dimensions of the new space, * and set the remaining dimensions to 1 */ @@ -2118,7 +2196,7 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, HDmemcpy(&new_space_maxdims[rank_diff], base_space_maxdims, sizeof(new_space_maxdims[0]) * base_space_rank); } /* end if */ else { /* new_space_rank < base_space_rank */ - /* we must copy the fastest changing dimension of the + /* we must copy the fastest changing dimension of the * base space into the dimensions of the new space. */ rank_diff = base_space_rank - new_space_rank; @@ -2126,12 +2204,12 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, HDmemcpy(new_space_maxdims, &base_space_maxdims[rank_diff], sizeof(new_space_maxdims[0]) * new_space_rank); } /* end else */ - /* now have the new space rank and dimensions set up -- + /* now have the new space rank and dimensions set up -- * so we can create the new simple dataspace. */ if(NULL == (new_space = H5S_create_simple(new_space_rank, new_space_dims, new_space_maxdims))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") - + /* No need to register the dataspace(i.e. get an ID) as * we will just be discarding it shortly. */ @@ -2142,13 +2220,13 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, */ if(H5S_SELECT_PROJECT_SIMPLE(base_space, new_space, &projected_space_element_offset) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to project simple selection") - + /* If we get this far, we have created the new dataspace, and projected * the selection in the base dataspace into the new dataspace. * - * If the base dataspace is simple, check to see if the - * offset_changed flag on the base selection has been set -- if so, - * project the offset into the new dataspace and set the + * If the base dataspace is simple, check to see if the + * offset_changed flag on the base selection has been set -- if so, + * project the offset into the new dataspace and set the * offset_changed flag. */ if(H5S_GET_EXTENT_TYPE(base_space) == H5S_SIMPLE && base_space->select.offset_changed) { @@ -2180,12 +2258,12 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * Since we can't do pointer arithmetic on void pointers, we first * cast buf to a pointer to byte -- i.e. uint8_t. * - * We then multiply the projected space element offset we - * calculated earlier by the supplied element size, add this - * value to the type cast buf pointer, cast the result back + * We then multiply the projected space element offset we + * calculated earlier by the supplied element size, add this + * value to the type cast buf pointer, cast the result back * to a pointer to void, and assign the result to *adj_buf_ptr. */ - *adj_buf_ptr = (const void *)(((const uint8_t *)buf) + + *adj_buf_ptr = (const void *)(((const uint8_t *)buf) + ((size_t)(projected_space_element_offset * element_size))); } /* end if */ else @@ -2200,7 +2278,7 @@ done: HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_construct_projection() */ +} /* end H5S_select_construct_projection() */ /*-------------------------------------------------------------------------- @@ -2231,7 +2309,7 @@ herr_t H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_buf) { H5S_sel_iter_t *iter = NULL; /* Selection iteration info */ - hbool_t iter_init = 0; /* Selection iteration info has been initialized */ + hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ hsize_t *off = NULL; /* Array to store sequence offsets */ size_t *len = NULL; /* Array to store sequence lengths */ hssize_t nelmts; /* Number of elements in selection */ @@ -2253,7 +2331,7 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b /* Initialize iterator */ if(H5S_select_iter_init(iter, space, fill_size) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - iter_init = 1; /* Selection iteration info has been initialized */ + iter_init = TRUE; /* Selection iteration info has been initialized */ /* Get the number of elements in selection */ if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) @@ -2308,7 +2386,7 @@ done: iter = H5FL_FREE(H5S_sel_iter_t, iter); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_fill() */ +} /* end H5S_select_fill() */ /*-------------------------------------------------------------------------- @@ -2335,7 +2413,7 @@ done: src_intersect_space within the selection of src_space as a selection within the selection of dst_space. The result is placed in the selection of new_space_ptr. - + GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES @@ -2359,7 +2437,7 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Create new space, using dst extent. Start with "all" selection. */ if(NULL == (new_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create output dataspace") - if(H5S_extent_copy_real(&new_space->extent, &dst_space->extent, TRUE) < 0) + if(H5S__extent_copy_real(&new_space->extent, &dst_space->extent, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy destination space extent") /* If the intersecting space is "all", the intersection must be equal to the @@ -2377,14 +2455,14 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, if(H5S_select_none(new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") } /* end if */ - /* If any of the spaces use point selection, fall back to general algorithm - */ + /* If any of the spaces use point selection, fall back to general algorithm */ else if((src_intersect_space->select.type->type == H5S_SEL_POINTS) || (src_space->select.type->type == H5S_SEL_POINTS) || (dst_space->select.type->type == H5S_SEL_POINTS)) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported") else { HDassert(src_intersect_space->select.type->type == H5S_SEL_HYPERSLABS); + /* Intersecting space is hyperslab selection. Call the hyperslab * routine to project to another hyperslab selection. */ if(H5S__hyper_project_intersection(src_space, dst_space, src_intersect_space, new_space) < 0) @@ -2401,7 +2479,7 @@ done: HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_project_intersection() */ +} /* end H5S_select_project_intersection() */ /*-------------------------------------------------------------------------- @@ -2423,7 +2501,7 @@ done: Removes any and all portions of space that are also present in subtract_space. In essence, performs an A_NOT_B operation with the two selections. - + GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES @@ -2491,5 +2569,5 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_subtract() */ +} /* end H5S_select_subtract() */ |