From 7bb809474551f6c2f1db817eb87b70796315a622 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 23 Apr 2004 22:50:22 -0500 Subject: [svn-r8417] Purpose: Code cleanup Description: Remove "NEW_HYPERSLAB_API" code from release branch, since it was leftover from when we branched the 1.6 branch from the main development trunk and will never be activated in the 1.6 branch. (And I'm tired of maintaining it in both branches when I'm optimizing the library :-) Platforms tested: FreeBSD 4.9 (sleipnir) Linux 2.4 (verbena) w/FORTRAN too minor to require full h5committest --- fortran/src/H5Sf.c | 135 -------- fortran/src/H5Sff.f90 | 302 ----------------- fortran/src/H5f90proto.h | 12 - src/H5I.c | 3 +- src/H5Shyper.c | 856 ----------------------------------------------- test/tselect.c | 361 -------------------- 6 files changed, 2 insertions(+), 1667 deletions(-) diff --git a/fortran/src/H5Sf.c b/fortran/src/H5Sf.c index ae3a201..25d8585 100644 --- a/fortran/src/H5Sf.c +++ b/fortran/src/H5Sf.c @@ -810,141 +810,6 @@ DONE: if(c_block != NULL) HDfree(c_block); return ret_value; } -#ifdef NEW_HYPERSLAB_API -/*---------------------------------------------------------------------------- - * Name: h5scombine_hyperslab_c - * Purpose: Call H5Scombine_hyperslab - * Inputs: space_id - identifier of the dataspace - * operator - defines how the new selection is combined - * start - offset of start of hyperslab - * count - number of blocks included in the hyperslab - * stride - hyperslab stride (interval between blocks) - * block - size of block in the hyperslab - * Outputs: hyper_id - identifier for the new dataspace - * Returns: 0 on success, -1 on failure - * Programmer: Elena Pourmal - * Monday, October 7, 2002 - * Modifications: - *---------------------------------------------------------------------------*/ - -int_f -nh5scombine_hyperslab_c ( hid_t_f *space_id , int_f *op, hssize_t_f *start, hsize_t_f *count, hsize_t_f *stride, hsize_t_f *block, hid_t_f *hyper_id) -{ - int ret_value = -1; - hid_t c_space_id; - hid_t c_hyper_id; - hssize_t *c_start = NULL; - hsize_t *c_count = NULL; - hsize_t *c_stride = NULL; - hsize_t *c_block = NULL; - - H5S_seloper_t c_op; - herr_t status; - int rank; - int i; - - rank = H5Sget_simple_extent_ndims(*space_id); - if (rank < 0 ) return ret_value; - c_start = (hssize_t *)HDmalloc(sizeof(hssize_t)*rank); - if (c_start == NULL) goto DONE; - - c_count = (hsize_t *)HDmalloc(sizeof(hsize_t)*rank); - if (c_count == NULL) goto DONE; - - c_stride = (hsize_t *)HDmalloc(sizeof(hsize_t)*rank); - if (c_stride == NULL) goto DONE; - - c_block = (hsize_t *)HDmalloc(sizeof(hsize_t)*rank); - if (c_block == NULL) goto DONE; - - - /* - * Reverse dimensions due to C-FORTRAN storage order. - */ - - for (i=0; i < rank; i++) { - int t= (rank - i) - 1; - c_start[i] = (hssize_t)start[t]; - c_count[i] = (hsize_t)count[t]; - c_stride[i] = (hsize_t)stride[t]; - c_block[i] = (hsize_t)block[t]; - } - - c_op = (H5S_seloper_t)*op; - - c_space_id = (hid_t)*space_id; - c_hyper_id = H5Scombine_hyperslab(c_space_id, c_op, c_start, c_stride, c_count, c_block); - if ( c_hyper_id < 0 ) goto DONE; - *hyper_id = (hid_t_f)c_hyper_id; - ret_value = 0; -DONE: - if(c_start != NULL) HDfree(c_start); - if(c_count != NULL) HDfree(c_count); - if(c_stride!= NULL) HDfree(c_stride); - if(c_block != NULL) HDfree(c_block); - return ret_value; -} -/*---------------------------------------------------------------------------- - * Name: h5scombine_select_c - * Purpose: Call H5Scombine_ select - * Inputs: space1_id - identifier of the first dataspace - * operator - defines how the new selection is combined - * space2_id - identifier of the second dataspace - * Outputs: ds_id - identifier for the new dataspace - * Returns: 0 on success, -1 on failure - * Programmer: Elena Pourmal - * Monday, October 7, 2002 - * Modifications: - *---------------------------------------------------------------------------*/ - -int_f -nh5scombine_select_c ( hid_t_f *space1_id , int_f *op, hid_t_f *space2_id, hid_t_f *ds_id) -{ - int ret_value = -1; - hid_t c_space1_id; - hid_t c_space2_id; - hid_t c_ds_id; - H5S_seloper_t c_op; - - c_op = (H5S_seloper_t)*op; - - c_space1_id = (hid_t)*space1_id; - c_space2_id = (hid_t)*space2_id; - c_ds_id = H5Scombine_select(c_space1_id, c_op, c_space2_id); - if ( c_ds_id < 0 ) return ret_value; - *ds_id = (hid_t_f)c_ds_id; - ret_value = 0; - return ret_value; -} -/*---------------------------------------------------------------------------- - * Name: h5sselect_select_c - * Purpose: Call H5Sselect_ select - * Inputs: space1_id - identifier of the first dataspace to modify - * operator - defines how the new selection is combined - * space2_id - identifier of the second dataspace - * Returns: 0 on success, -1 on failure - * Programmer: Elena Pourmal - * Monday, October 7, 2002 - * Modifications: - *---------------------------------------------------------------------------*/ - -int_f -nh5sselect_select_c ( hid_t_f *space1_id , int_f *op, hid_t_f *space2_id) -{ - int ret_value = -1; - hid_t c_space1_id; - hid_t c_space2_id; - H5S_seloper_t c_op; - - c_op = (H5S_seloper_t)*op; - - c_space1_id = (hid_t)*space1_id; - c_space2_id = (hid_t)*space2_id; - if( H5Sselect_select(c_space1_id, c_op, c_space2_id)< 0) return ret_value; - ret_value = 0; - return ret_value; -} -#endif /*NEW_HYPERSLAB_API*/ /*---------------------------------------------------------------------------- * Name: h5sget_select_type_c * Purpose: Call H5Sget_select_type diff --git a/fortran/src/H5Sff.f90 b/fortran/src/H5Sff.f90 index 1657b39..9f96dc9 100644 --- a/fortran/src/H5Sff.f90 +++ b/fortran/src/H5Sff.f90 @@ -1577,308 +1577,6 @@ END SUBROUTINE h5sselect_hyperslab_f !---------------------------------------------------------------------- -! Name: h5scombine_hyperslab_f -! -! Purpose: Combine a hyperslab selection with the current -! selection for a dataspace -! -! Inputs: -! space_id - dataspace of selection to use -! operator - flag, valid values are: -! H5S_SELECT_NOOP_F -! H5S_SELECT_SET_F -! H5S_SELECT_OR_F -! H5S_SELECT_AND_F -! H5S_SELECT_XOR_F -! H5S_SELECT_NOTB_F -! H5S_SELECT_NOTA_F -! H5S_SELECT_APPEND_F -! H5S_SELECT_PREPEND_F -! start - array with hyperslab offsets -! count - number of blocks included in the -! hyperslab -! Outputs: -! hyper_id - identifier for the new hyperslab -! hdferr: - error code -! Success: 0 -! Failure: -1 -! Optional parameters: -! stride - array with hyperslab strides -! block - array with hyperslab block sizes -! -! Programmer: Elena Pourmal -! October 7, 2002 -! -! Modifications: -! -! Comment: Commented out until 1.6 ? 10/08/2002 -!---------------------------------------------------------------------- - -! SUBROUTINE h5scombine_hyperslab_f(space_id, operator, start, count, & -! hyper_id, hdferr, stride, block) -! -!This definition is needed for Windows DLLs -!DEC$if defined(BUILD_HDF5_DLL) -!DEC$attributes dllexport :: h5scombine_hyperslab_f -!DEC$endif -! -! IMPLICIT NONE -! INTEGER(HID_T), INTENT(IN) :: space_id ! Dataspace identifier -! INTEGER, INTENT(IN) :: operator ! Flag, valid values are: - ! H5S_SELECT_NOOP_F - ! H5S_SELECT_SET_F - ! H5S_SELECT_OR_F - ! H5S_SELECT_AND_F - ! H5S_SELECT_XOR_F - ! H5S_SELECT_NOTB_F - ! H5S_SELECT_NOTA_F - ! H5S_SELECT_APPEND_F - ! H5S_SELECT_PREPEND_F - ! -! INTEGER(HSSIZE_T), DIMENSION(*), INTENT(IN) :: start - ! Starting coordinates of the hyperslab -! INTEGER(HSIZE_T), DIMENSION(*), INTENT(IN) :: count - ! Number of blocks to select - ! from dataspace -! INTEGER(HID_T), INTENT(OUT) :: hyper_id ! New hyperslab identifier -! INTEGER, INTENT(OUT) :: hdferr ! Error code -! INTEGER(HSIZE_T), DIMENSION(:), OPTIONAL, INTENT(IN) :: stride - ! Array of how many elements to move - ! in each direction -! INTEGER(HSIZE_T), DIMENSION(:), OPTIONAL, INTENT(IN) :: block - ! Sizes of element block -! INTEGER(HSIZE_T), DIMENSION(:), ALLOCATABLE :: def_block -! INTEGER(HSIZE_T), DIMENSION(:), ALLOCATABLE :: def_stride -! INTEGER :: rank -! INTEGER :: error1, error2 - -! INTERFACE -! INTEGER FUNCTION h5scombine_hyperslab_c(space_id, operator, & -! start, count, stride, block, hyper_id) -! USE H5GLOBAL - !DEC$ IF DEFINED(HDF5F90_WINDOWS) - !MS$ATTRIBUTES C,reference,alias:'_H5SCOMBINE_HYPERSLAB_C'::h5scombine_hyperslab_c - !DEC$ ENDIF -! INTEGER(HID_T), INTENT(IN) :: space_id -! INTEGER, INTENT(IN) :: operator -! INTEGER(HSSIZE_T), DIMENSION(*), INTENT(IN) :: start -! INTEGER(HSIZE_T), DIMENSION(*), INTENT(IN) :: count -! INTEGER(HSIZE_T), DIMENSION(*), OPTIONAL, INTENT(IN) :: stride -! INTEGER(HSIZE_T), DIMENSION(*), OPTIONAL, INTENT(IN) :: block -! INTEGER(HID_T), INTENT(OUT) :: hyper_id -! END FUNCTION h5scombine_hyperslab_c -! END INTERFACE - -! if (present(stride).and. present(block)) then -! hdferr = h5scombine_hyperslab_c(space_id, operator, start, count, & -! stride, block, hyper_id) -! return -! endif - ! Case of optional parameters. - ! - ! Find the rank of the dataspace to allocate memery for - ! default stride and block arrays. - ! -! CALL h5sget_simple_extent_ndims_f(space_id, rank, hdferr) -! if( hdferr .EQ. -1) return - ! -! if (present(stride).and. .not.present(block)) then -! allocate(def_block(rank), stat=error1) -! if (error1.NE.0) then -! hdferr = -1 -! return -! endif -! def_block = 1 -! hdferr = h5scombine_hyperslab_c(space_id, operator, start, count, & -! stride, def_block, hyper_id) -! deallocate(def_block) -! return -! endif - -! if (.not.present(stride).and. present(block)) then -! allocate(def_stride(rank), stat=error2) -! if (error2.NE.0) then -! hdferr = -1 -! return -! endif -! def_stride = 1 -! hdferr = h5scombine_hyperslab_c(space_id, operator, start, count, & -! def_stride, block, hyper_id) -! deallocate(def_stride) -! return -! endif -! allocate(def_block(rank), stat=error1) -! allocate(def_stride(rank), stat=error2) -! if ((error1.NE.0) .OR. (error2.NE.0)) then -! hdferr = -1 -! return -! endif -! def_block = 1 -! def_stride = 1 -! hdferr = h5scombine_hyperslab_c(space_id, operator, start, count, & -! def_stride, def_block, hyper_id) -! deallocate(def_block) -! deallocate(def_stride) - -! END SUBROUTINE h5scombine_hyperslab_f - -!---------------------------------------------------------------------- -! Name: h5scombine_select_f -! -! Purpose: Combine two hyperslab selections with an operation -! and return a dataspace with resulting selection. -! -! Inputs: -! space1_id - dataspace of selection to use -! operator - flag, valid values are: -! H5S_SELECT_NOOP_F -! H5S_SELECT_SET_F -! H5S_SELECT_OR_F -! H5S_SELECT_AND_F -! H5S_SELECT_XOR_F -! H5S_SELECT_NOTB_F -! H5S_SELECT_NOTA_F -! H5S_SELECT_APPEND_F -! H5S_SELECT_PREPEND_F -! space2_id - dataspace of selection to use -! Outputs: -! ds_id - idataspace identifier with the new selection -! hdferr: - error code -! Success: 0 -! Failure: -1 -! Optional parameters: - NONE -! -! Programmer: Elena Pourmal -! October 7, 2002 -! -! Modifications: -! -! Comment: commented out until 1.6 release(?) 10/08/2002 -!---------------------------------------------------------------------- - -! SUBROUTINE h5scombine_select_f(space1_id, operator, space2_id, & -! ds_id, hdferr) -! -!This definition is needed for Windows DLLs -!DEC$if defined(BUILD_HDF5_DLL) -!DEC$attributes dllexport :: h5scombine_select_f -!DEC$endif -! -! IMPLICIT NONE -! INTEGER(HID_T), INTENT(IN) :: space1_id ! First dataspace identifier -! INTEGER(HID_T), INTENT(IN) :: space2_id ! Second dataspace identifier -! INTEGER, INTENT(IN) :: operator ! Flag, valid values are: - ! H5S_SELECT_NOOP_F - ! H5S_SELECT_SET_F - ! H5S_SELECT_OR_F - ! H5S_SELECT_AND_F - ! H5S_SELECT_XOR_F - ! H5S_SELECT_NOTB_F - ! H5S_SELECT_NOTA_F - ! H5S_SELECT_APPEND_F - ! H5S_SELECT_PREPEND_F - ! -! INTEGER(HID_T), INTENT(OUT) :: ds_id ! New dataspace identifier -! INTEGER, INTENT(OUT) :: hdferr ! Error code -! -! INTERFACE -! INTEGER FUNCTION h5scombine_select_c(space1_id, operator, & -! space2_id, ds_id) -! USE H5GLOBAL - !DEC$ IF DEFINED(HDF5F90_WINDOWS) - !MS$ATTRIBUTES C,reference,alias:'_H5SCOMBINE_SELECT_C'::h5scombine_select_c - !DEC$ ENDIF -! INTEGER(HID_T), INTENT(IN) :: space1_id -! INTEGER(HID_T), INTENT(IN) :: space2_id -! INTEGER, INTENT(IN) :: operator -! INTEGER(HID_T), INTENT(OUT) :: ds_id -! END FUNCTION h5scombine_select_c -! END INTERFACE - -! hdferr = h5scombine_select_c(space1_id, operator, space2_id, & -! ds_id) -! return - -! END SUBROUTINE h5scombine_select_f - -!---------------------------------------------------------------------- -! Name: h5sselect_select_f -! -! Purpose: Refine a hyperslab selection with an operation -! using second hyperslab -! -! Inputs: -! space1_id - dataspace of selection to modify -! operator - flag, valid values are: -! H5S_SELECT_NOOP_F -! H5S_SELECT_SET_F -! H5S_SELECT_OR_F -! H5S_SELECT_AND_F -! H5S_SELECT_XOR_F -! H5S_SELECT_NOTB_F -! H5S_SELECT_NOTA_F -! H5S_SELECT_APPEND_F -! H5S_SELECT_PREPEND_F -! space2_id - dataspace of selection to use -! -! Outputs: -! hdferr: - error code -! Success: 0 -! Failure: -1 -! Optional parameters: - NONE -! -! Programmer: Elena Pourmal -! October 7, 2002 -! -! Modifications: -! -! Comment:Commented out until 1.6 release(?) 10/08/2002 EIP -!---------------------------------------------------------------------- - -! SUBROUTINE h5sselect_select_f(space1_id, operator, space2_id, & -! hdferr) -! -!This definition is needed for Windows DLLs -!DEC$if defined(BUILD_HDF5_DLL) -!DEC$attributes dllexport :: h5sselect_select_f -!DEC$endif -! -! IMPLICIT NONE -! INTEGER(HID_T), INTENT(INOUT) :: space1_id ! Dataspace identifier to - ! modify -! INTEGER(HID_T), INTENT(IN) :: space2_id ! Second dataspace identifier -! INTEGER, INTENT(IN) :: operator ! Flag, valid values are: - ! H5S_SELECT_NOOP_F - ! H5S_SELECT_SET_F - ! H5S_SELECT_OR_F - ! H5S_SELECT_AND_F - ! H5S_SELECT_XOR_F - ! H5S_SELECT_NOTB_F - ! H5S_SELECT_NOTA_F - ! H5S_SELECT_APPEND_F - ! H5S_SELECT_PREPEND_F - ! -! INTEGER, INTENT(OUT) :: hdferr ! Error code - -! INTERFACE -! INTEGER FUNCTION h5sselect_select_c(space1_id, operator, & -! space2_id) -! USE H5GLOBAL - !DEC$ IF DEFINED(HDF5F90_WINDOWS) - !MS$ATTRIBUTES C,reference,alias:'_H5SSELECT_SELECT_C'::h5sselect_select_c - !DEC$ ENDIF -! INTEGER(HID_T), INTENT(INOUT) :: space1_id -! INTEGER(HID_T), INTENT(IN) :: space2_id -! INTEGER, INTENT(IN) :: operator -! END FUNCTION h5sselect_select_c -! END INTERFACE - -! hdferr = h5sselect_select_c(space1_id, operator, space2_id) -! return - -! END SUBROUTINE h5sselect_select_f - -!---------------------------------------------------------------------- ! Name: h5sget_select_type_f ! ! Purpose: Retrieve the type of selection diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h index e5c0a9c..d4d9be2 100644 --- a/fortran/src/H5f90proto.h +++ b/fortran/src/H5f90proto.h @@ -113,9 +113,6 @@ H5_DLL int_f nh5fflush_c (hid_t_f *obj_id, int_f *scope); # define nh5sextent_copy_c FNAME(H5SEXTENT_COPY_C) # define nh5sset_extent_none_c FNAME(H5SSET_EXTENT_NONE_C) # define nh5sselect_hyperslab_c FNAME(H5SSELECT_HYPERSLAB_C) -# define nh5scombine_hyperslab_c FNAME(H5SCOMBINE_HYPERSLAB_C) -# define nh5scombine_select_c FNAME(H5SCOMBINE_SELECT_C) -# define nh5sselect_select_c FNAME(H5SSELECT_SELECT_C) # define nh5sget_select_type_c FNAME(H5SGET_SELECT_TYPE_C) # define nh5sselect_elements_c FNAME(H5SSELECT_ELEMENTS_C) #else /* !DF_CAPFNAMES */ @@ -143,9 +140,6 @@ H5_DLL int_f nh5fflush_c (hid_t_f *obj_id, int_f *scope); # define nh5sextent_copy_c FNAME(h5sextent_copy_c) # define nh5sset_extent_none_c FNAME(h5sset_extent_none_c) # define nh5sselect_hyperslab_c FNAME(h5sselect_hyperslab_c) -# define nh5scombine_hyperslab_c FNAME(h5scombine_hyperslab_c) -# define nh5scombine_select_c FNAME(h5scombine_select_c) -# define nh5sselect_select_c FNAME(h5sselect_select_c) # define nh5sget_select_type_c FNAME(h5sget_select_type_c) # define nh5sselect_elements_c FNAME(h5sselect_elements_c) #endif /* DF_CAPFNAMES */ @@ -197,12 +191,6 @@ H5_DLL int_f nh5sset_extent_none_c ( hid_t_f *space_id ); H5_DLL int_f nh5sselect_hyperslab_c ( hid_t_f *space_id , int_f *op, hssize_t_f *start, hsize_t_f *count, hsize_t_f *stride, hsize_t_f *block); -H5_DLL int_f nh5scombine_hyperslab_c ( hid_t_f *space_id , int_f *op, hssize_t_f *start, hsize_t_f *count, hsize_t_f *stride, hsize_t_f *block, hid_t_f *hyper_id); - -H5_DLL int_f nh5scombine_select_c ( hid_t_f *space1_id , int_f *op, hid_t_f *space2_id, hid_t_f *ds_id); - -H5_DLL int_f nh5sselect_select_c ( hid_t_f *space1_id , int_f *op, hid_t_f *space2_id); - H5_DLL int_f nh5sget_select_type_c ( hid_t_f *space_id , int_f *op); H5_DLL int_f nh5sselect_elements_c ( hid_t_f *space_id , int_f *op, size_t_f *nelements, hssize_t_f *coord); diff --git a/src/H5I.c b/src/H5I.c index f92e2cc..79aa81f 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -1526,4 +1526,5 @@ H5I_get_file_id(hid_t obj_id) done: FUNC_LEAVE_NOAPI(ret_value); -} \ No newline at end of file +} + diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 9c0dcf6..c025dc8 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -44,10 +44,6 @@ static herr_t H5S_hyper_free_span (H5S_hyper_span_t *span); static H5S_hyper_span_info_t *H5S_hyper_copy_span (H5S_hyper_span_info_t *spans); static herr_t H5S_hyper_span_scratch (H5S_hyper_span_info_t *spans, void *scr_value); static herr_t H5S_hyper_span_precompute (H5S_hyper_span_info_t *spans, size_t elmt_size); -/* Needed for use in hyperslab code (H5Shyper.c) */ -#ifdef NEW_HYPERSLAB_API -static herr_t H5S_select_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2); -#endif /*NEW_HYPERSLAB_API*/ static herr_t H5S_hyper_iter_coords(const H5S_sel_iter_t *iter, hssize_t *coords); static herr_t H5S_hyper_iter_block(const H5S_sel_iter_t *iter, hssize_t *start, hssize_t *end); static hsize_t H5S_hyper_iter_nelmts(const H5S_sel_iter_t *iter); @@ -5297,7 +5293,6 @@ H5S_hyper_rebuild (H5S_t *space) FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_rebuild() */ -#ifndef NEW_HYPERSLAB_API /*------------------------------------------------------------------------- * Function: H5S_generate_hyperlab @@ -5838,857 +5833,6 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[], done: FUNC_LEAVE_API(ret_value); } /* end H5Sselect_hyperslab() */ -#else /* NEW_HYPERSLAB_API */ /* Works */ - -/*------------------------------------------------------------------------- - * Function: H5S_operate_hyperslab - * - * Purpose: Combines two hyperslabs with an operation, putting the - * result into a third hyperslab selection - * - * Return: non-negative on success/NULL on failure - * - * Programmer: Quincey Koziol - * Tuesday, October 30, 2001 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -H5S_operate_hyperslab (H5S_t *result, H5S_hyper_span_info_t *spans1, H5S_seloper_t op, H5S_hyper_span_info_t *spans2) -{ - H5S_hyper_span_info_t *a_not_b=NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */ - H5S_hyper_span_info_t *a_and_b=NULL; /* Span tree for hyperslab spans in both old and new span trees */ - H5S_hyper_span_info_t *b_not_a=NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */ - hssize_t nelem; /* Number of elements in hyperslab span tree */ - htri_t status; /* Status from internal calls */ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5S_operate_hyperslab); - - /* Check args */ - assert(result); - assert(spans2); - assert(op>H5S_SELECT_NOOP && opselect.release)(result)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release result selection"); - - /* Just copy the selection from spans2 if we are setting the selection */ - /* ('space1' to 'result' aliasing happens at the next layer up) */ - if(op==H5S_SELECT_SET) { - if(H5S_hyper_merge_spans(result,spans2)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); - - /* Update the number of elements in current selection */ - if((nelem=H5S_hyper_spans_nelem(spans2))<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't count hyperslab span elements"); - result->select.num_elem=nelem; - } /* end if */ - else { - assert(spans1); - - /* Generate lists of spans which overlap and don't overlap */ - if(H5S_hyper_clip_spans(spans1,spans2,&a_not_b,&a_and_b,&b_not_a)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information"); - - /* Switch on the operation */ - switch(op) { - case H5S_SELECT_OR: - /* Copy spans from spans1 to current selection */ - if(spans1!=NULL) { - if(H5S_hyper_merge_spans(result,spans1)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); - - /* Update the number of elements in current selection */ - if((nelem=H5S_hyper_spans_nelem(spans1))<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't count hyperslab span elements"); - result->select.num_elem=nelem; - } /* end if */ - - /* Add any new spans from spans2 to current selection */ - if(b_not_a!=NULL) { - if(H5S_hyper_merge_spans(result,b_not_a)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); - - /* Update the number of elements in current selection */ - if((nelem=H5S_hyper_spans_nelem(b_not_a))<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't count hyperslab span elements"); - result->select.num_elem+=nelem; - } /* end if */ - break; - - case H5S_SELECT_AND: - /* Check if there are any overlapped selections */ - if(a_and_b!=NULL) { - if(H5S_hyper_merge_spans(result,a_and_b)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); - - /* Update the number of elements in current selection */ - if((nelem=H5S_hyper_spans_nelem(a_and_b))<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't count hyperslab span elements"); - result->select.num_elem=nelem; - } /* end if */ - break; - - case H5S_SELECT_XOR: - /* Check if there are any non-overlapped selections */ - if(a_not_b!=NULL) { - if(H5S_hyper_merge_spans(result,a_not_b)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); - - /* Update the number of elements in current selection */ - if((nelem=H5S_hyper_spans_nelem(a_not_b))<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't count hyperslab span elements"); - result->select.num_elem=nelem; - } /* end if */ - if(b_not_a!=NULL) { - if(H5S_hyper_merge_spans(result,b_not_a)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); - - /* Update the number of elements in current selection */ - if((nelem=H5S_hyper_spans_nelem(b_not_a))<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't count hyperslab span elements"); - result->select.num_elem+=nelem; - } /* end if */ - break; - - case H5S_SELECT_NOTB: - /* Check if there are any non-overlapped selections */ - if(a_not_b!=NULL) { - if(H5S_hyper_merge_spans(result,a_not_b)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); - - /* Update the number of elements in current selection */ - if((nelem=H5S_hyper_spans_nelem(a_not_b))<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't count hyperslab span elements"); - result->select.num_elem=nelem; - } /* end if */ - break; - - case H5S_SELECT_NOTA: - /* Check if there are any non-overlapped selections */ - if(b_not_a!=NULL) { - if(H5S_hyper_merge_spans(result,b_not_a)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs"); - - /* Update the number of elements in current selection */ - if((nelem=H5S_hyper_spans_nelem(b_not_a))<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't count hyperslab span elements"); - result->select.num_elem=nelem; - } /* end if */ - break; - - default: - HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); - } /* end switch */ - - /* Free the hyperslab trees generated from the clipping algorithm */ - if(a_not_b) - H5S_hyper_free_span_info(a_not_b); - if(a_and_b) - H5S_hyper_free_span_info(a_and_b); - if(b_not_a) - H5S_hyper_free_span_info(b_not_a); - - /* Check if the resulting hyperslab span tree is empty */ - if(space->select.sel_info.hslab.span_lst==NULL) { - H5S_hyper_span_info_t *spans; /* Empty hyperslab span tree */ - - /* Sanity check */ - assert(space->select.num_elem==0); - - /* Allocate a span info node */ - if((spans = H5FL_MALLOC(H5S_hyper_span_info_t))==NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span"); - - /* Set the reference count */ - spans->count=1; - - /* Reset the scratch pad space */ - spans->scratch=0; - - /* Set to empty tree */ - spans->head=NULL; - - /* Set pointer to empty span tree */ - space->select.sel_info.hslab.span_lst=spans; - } /* end if */ - else { - /* Check if the resulting hyperslab span tree can be used to re-build - * "optimized" start/stride/count/block information. - */ - status=H5S_hyper_can_rebuild(result); - if(status<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't check for rebuilding hyperslab info"); - if(status>0) - if(H5S_hyper_rebuild(result)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't rebuild hyperslab info"); - } /* end else */ - } /* end else */ - - /* Set selection type */ - result->select.type=H5S_SEL_HYPERSLABS; - - /* Set selection methods */ - result->select.get_seq_list=H5S_hyper_get_seq_list; - result->select.get_npoints=H5S_hyper_npoints; - result->select.release=H5S_hyper_release; - result->select.is_valid=H5S_hyper_is_valid; - result->select.serial_size=H5S_hyper_serial_size; - result->select.serialize=H5S_hyper_serialize; - result->select.bounds=H5S_hyper_bounds; - result->select.is_contiguous=H5S_hyper_is_contiguous; - result->select.is_single=H5S_hyper_is_single; - result->select.is_regular=H5S_hyper_is_regular; - result->select.iter_init=H5S_hyper_iter_init; - -done: - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5S_operate_hyperslab() */ - - -/*------------------------------------------------------------------------- - * Function: H5S_generate_hyperlab - * - * Purpose: Generate hyperslab information from H5S_select_hyperslab() - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol (split from HS_select_hyperslab()). - * Tuesday, September 12, 2000 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, - const hssize_t start[], - const hsize_t _stride[], - const hsize_t _count[], - const hsize_t _block[]) -{ - hsize_t stride[H5O_LAYOUT_NDIMS]; /* Optimized stride information */ - hsize_t count[H5O_LAYOUT_NDIMS]; /* Optimized count information */ - hsize_t block[H5O_LAYOUT_NDIMS]; /* Optimized block information */ - H5S_hyper_span_info_t *new_spans=NULL; /* Span tree for new hyperslab */ - H5S_hyper_span_info_t *tmp_spans=NULL; /* Temporary copy of selection */ - unsigned u; /* Counters */ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5S_generate_hyperslab); - - /* Check args */ - assert(space); - assert(op>H5S_SELECT_NOOP && opextent.u.simple.rank; u++) { - /* contiguous hyperslabs have the block size equal to the stride */ - if(_stride[u]==_block[u]) { - count[u]=1; - stride[u]=1; - block[u]=_block[u]*_count[u]; - } - else { - if(_count[u]==1) - stride[u]=1; - else { - assert(_stride[u]>_block[u]); - stride[u]=_stride[u]; - } /* end else */ - count[u]=_count[u]; - block[u]=_block[u]; - } /* end if */ - } /* end for */ - - /* Generate span tree for new hyperslab information */ - if((new_spans=H5S_hyper_make_spans(space->extent.u.simple.rank,start,stride,count,block))==NULL) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't create hyperslab information"); - - /* Copy the original dataspace */ - if(space->select.sel_info.hslab.span_lst!=NULL) - if (NULL==(tmp_spans=H5S_hyper_copy_span(space->select.sel_info.hslab.span_lst))) - HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy data space"); - - /* Combine tmp_space (really space) & new_space, with the result in space */ - if(H5S_operate_hyperslab(space,tmp_spans,op,new_spans)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information"); - -done: - /* Free temporary data structures */ - if(tmp_spans!=NULL) - if(H5S_hyper_free_span_info(tmp_spans)<0) - HDONE_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release temporary hyperslab spans"); - if(new_spans!=NULL) - if(H5S_hyper_free_span_info(new_spans)<0) - HDONE_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release temporary hyperslab spans"); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5S_generate_hyperslab() */ - - -/*------------------------------------------------------------------------- - * Function: H5S_select_hyperslab - * - * Purpose: Internal version of H5Sselect_hyperslab(). - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Wednesday, January 10, 2001 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, - const hssize_t start[], - const hsize_t *stride, - const hsize_t count[], - const hsize_t *block) -{ - hsize_t _stride[H5O_LAYOUT_NDIMS]; /* Stride array */ - hsize_t _block[H5O_LAYOUT_NDIMS]; /* Block size array */ - unsigned u; /* Counters */ - H5S_hyper_dim_t *diminfo; /* per-dimension info for the selection */ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI (H5S_select_hyperslab, FAIL); - - /* Check args */ - assert(space); - assert(start); - assert(count); - assert(op>H5S_SELECT_NOOP && opextent.u.simple.rank); - stride = _stride; - } /* end if */ - - /* Fill in the correct block values */ - if(block==NULL) { - hsize_t fill=1; - - H5V_array_fill(_block,&fill,sizeof(hssize_t),space->extent.u.simple.rank); - block = _block; - } /* end if */ - - /* Fixup operation for non-hyperslab selections */ - switch(space->select.type) { - case H5S_SEL_NONE: /* No elements selected in dataspace */ - switch(op) { - case H5S_SELECT_SET: /* Select "set" operation */ - /* Change "none" selection to hyperslab selection */ - break; - - case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ - case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ - case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ - op=H5S_SELECT_SET; /* Maps to "set" operation when applied to "none" selection */ - break; - - case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ - case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ - HGOTO_DONE(SUCCEED); /* Selection stays "none" */ - - default: - HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); - } /* end switch */ - break; - - case H5S_SEL_ALL: /* All elements selected in dataspace */ - switch(op) { - case H5S_SELECT_SET: /* Select "set" operation */ - /* Change "all" selection to hyperslab selection */ - break; - - case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ - HGOTO_DONE(SUCCEED); /* Selection stays "all" */ - - case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ - op=H5S_SELECT_SET; /* Maps to "set" operation when applied to "none" selection */ - break; - - case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ - case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ - /* Convert current "all" selection to "real" hyperslab selection */ - /* Then allow operation to proceed */ - { - hssize_t tmp_start[H5O_LAYOUT_NDIMS]; /* Temporary start information */ - hsize_t tmp_stride[H5O_LAYOUT_NDIMS]; /* Temporary stride information */ - hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary count information */ - hsize_t tmp_block[H5O_LAYOUT_NDIMS]; /* Temporary block information */ - - /* Fill in temporary information for the dimensions */ - for(u=0; uextent.u.simple.rank; u++) { - tmp_start[u]=0; - tmp_stride[u]=1; - tmp_count[u]=1; - tmp_block[u]=space->extent.u.simple.size[u]; - } /* end for */ - - /* Convert to hyperslab selection */ - if(H5S_select_hyperslab(space,H5S_SELECT_SET,tmp_start,tmp_stride,tmp_count,tmp_block)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection"); - } /* end case */ - break; - - case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ - /* Convert to "none" selection */ - if(H5S_select_none(space)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection"); - HGOTO_DONE(SUCCEED); - - default: - HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); - } /* end switch */ - break; - - case H5S_SEL_HYPERSLABS: - /* Hyperslab operation on hyperslab selection, OK */ - break; - - case H5S_SEL_POINTS: /* Can't combine hyperslab operations and point selections currently */ - if(op==H5S_SELECT_SET) /* Allow only "set" operation to proceed */ - break; - /* Else fall through to error */ - - default: - HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); - } /* end switch */ - - - if(op==H5S_SELECT_SET) { - /* - * Check for overlapping hyperslab blocks in new selection. - */ - for(u=0; uextent.u.simple.rank; u++) { - if(count[u]>1 && stride[u]select.release)(space)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release hyperslab"); - - /* Save the diminfo */ - diminfo=space->select.sel_info.hslab.diminfo; - for(u=0; uextent.u.simple.rank; u++) { - space->select.sel_info.hslab.app_diminfo[u].start = start[u]; - space->select.sel_info.hslab.app_diminfo[u].stride = stride[u]; - space->select.sel_info.hslab.app_diminfo[u].count = count[u]; - space->select.sel_info.hslab.app_diminfo[u].block = block[u]; - - /* Optimize the hyperslab selection to detect contiguously selected block/stride information */ - /* Modify the stride, block & count for contiguous hyperslab selections */ - - /* Starting location doesn't get optimized */ - diminfo[u].start = start[u]; - - /* contiguous hyperslabs have the block size equal to the stride */ - if(stride[u]==block[u]) { - diminfo[u].stride=1; - diminfo[u].count=1; - diminfo[u].block=count[u]*block[u]; - } /* end if */ - else { - if(count[u]==1) - diminfo[u].stride=1; - else { - assert(stride[u]>block[u]); - diminfo[u].stride=stride[u]; - } /* end else */ - diminfo[u].count=count[u]; - diminfo[u].block=block[u]; - } /* end else */ - } /* end for */ - - /* Indicate that the dimension information is valid */ - space->select.sel_info.hslab.diminfo_valid=TRUE; - - /* Build the hyperslab information also */ - if(H5S_generate_hyperslab (space, H5S_SELECT_SET, start, stride, count, block)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs"); - } /* end if */ - else if(op>=H5S_SELECT_OR && op<=H5S_SELECT_NOTA) { - /* Sanity check */ - assert(space->select.type==H5S_SEL_HYPERSLABS); - - /* Indicate that the regular dimensions are no longer valid */ - space->select.sel_info.hslab.diminfo_valid=FALSE; - - /* Add in the new hyperslab information */ - if(H5S_generate_hyperslab (space, op, start, stride, count, block)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs"); - } /* end if */ - else - HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); - -done: - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5S_select_hyperslab() */ - - -/*-------------------------------------------------------------------------- - NAME - H5Sselect_hyperslab - PURPOSE - Specify a hyperslab to combine with the current hyperslab selection - USAGE - herr_t H5Sselect_hyperslab(dsid, op, start, stride, count, block) - hid_t dsid; IN: Dataspace ID of selection to modify - H5S_seloper_t op; IN: Operation to perform on current selection - const hssize_t *start; IN: Offset of start of hyperslab - const hssize_t *stride; IN: Hyperslab stride - const hssize_t *count; IN: Number of blocks included in hyperslab - const hssize_t *block; IN: Size of block in hyperslab - RETURNS - Non-negative on success/Negative on failure - DESCRIPTION - Combines a hyperslab selection with the current selection for a dataspace. - If the current selection is not a hyperslab, it is freed and the hyperslab - parameters passed in are combined with the H5S_SEL_ALL hyperslab (ie. a - selection composing the entire current extent). If STRIDE or BLOCK is - NULL, they are assumed to be set to all '1'. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[], - const hsize_t stride[], const hsize_t count[], const hsize_t block[]) -{ - H5S_t *space = NULL; /* Dataspace to modify selection of */ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_API(H5Sselect_hyperslab, FAIL); - H5TRACE6("e","iSs*Hs*h*h*h",space_id,op,start,stride,count,block); - - /* Check args */ - if (NULL == (space=H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - if (H5S_SCALAR==H5S_get_simple_extent_type(space)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_SCALAR space"); - if(start==NULL || count==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified"); - if(!(op>H5S_SELECT_NOOP && opextent.u.simple.rank; u++) { - if(stride[u]==0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid stride==0 value"); - } /* end for */ - if(block!=NULL) { - /* Check for strides smaller than blocks */ - for(u=0; uextent.u.simple.rank; u++) { - if(count[u]>1 && stride[u]H5S_SELECT_NOOP && opH5S_SELECT_NOOP && opselect.sel_info.hslab.span_lst,op,space2->select.sel_info.hslab.span_lst)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, NULL, "can't clip hyperslab information"); - - /* Set return value */ - ret_value=new_space; - -done: - if(ret_value==NULL && new_space!=NULL) - H5S_close(new_space); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5S_combine_select() */ - - -/*-------------------------------------------------------------------------- - NAME - H5Scombine_select - PURPOSE - Combine two hyperslab selections with an operation, returning a dataspace - with the resulting selection. - USAGE - hid_t H5Scombine_select(space1, op, space2) - hid_t space1; IN: First Dataspace ID - H5S_seloper_t op; IN: Selection operation - hid_t space2; IN: Second Dataspace ID - RETURNS - Dataspace ID on success/Negative on failure - DESCRIPTION - Combine two existing hyperslab selections with an operation, returning - a new dataspace with the resulting selection. The dataspace extent from - space1 is copied for the dataspace extent of the newly created dataspace. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -hid_t -H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) -{ - H5S_t *space1; /* First Dataspace */ - H5S_t *space2; /* Second Dataspace */ - H5S_t *new_space = NULL; /* New Dataspace */ - hid_t ret_value; - - FUNC_ENTER_API(H5Scombine_select, FAIL); - H5TRACE3("i","iSsi",space1_id,op,space2_id); - - /* Check args */ - if (NULL == (space1=H5I_object_verify(space1_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - if (NULL == (space2=H5I_object_verify(space2_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - if(!(op>H5S_SELECT_NOOP && opextent.u.simple.rank!=space2->extent.u.simple.rank) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces not same rank"); - - /* Check that both dataspaces have hyperslab selections */ - if(space1->select.type!=H5S_SEL_HYPERSLABS || space2->select.type!=H5S_SEL_HYPERSLABS) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces don't have hyperslab selections"); - - /* Go combine the dataspaces */ - if ((new_space=H5S_combine_select(space1, op, space2))==NULL) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to create hyperslab selection"); - - /* Atomize */ - if ((ret_value=H5I_register (H5I_DATASPACE, new_space))<0) - HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom"); - -done: - if (ret_value<0 && new_space) - H5S_close(new_space); - - FUNC_LEAVE_API(ret_value); -} /* end H5Scombine_select() */ - - -/*------------------------------------------------------------------------- - * Function: H5S_select_select - * - * Purpose: Internal version of H5Sselect_select(). - * - * Return: New dataspace on success/NULL on failure - * - * Programmer: Quincey Koziol - * Tuesday, October 30, 2001 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -H5S_select_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2) -{ - H5S_hyper_span_info_t *tmp_spans=NULL; /* Temporary copy of selection */ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5S_select_select); - - /* Check args */ - assert(space1); - assert(space2); - assert(op>H5S_SELECT_NOOP && opselect.sel_info.hslab.span_lst))) - HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy data space"); - - /* Combine tmp_spans (from space1) & spans from space2, with the result in space1 */ - if(H5S_operate_hyperslab(space1,tmp_spans,op,space2->select.sel_info.hslab.span_lst)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information"); - -done: - if(tmp_spans!=NULL) - H5S_hyper_free_span_info(tmp_spans); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5S_select_select() */ - - -/*-------------------------------------------------------------------------- - NAME - H5Sselect_select - PURPOSE - Refine a hyperslab selection with an operation using a second hyperslab - to modify it. - USAGE - herr_t H5Sselect_select(space1, op, space2) - hid_t space1; IN/OUT: First Dataspace ID - H5S_seloper_t op; IN: Selection operation - hid_t space2; IN: Second Dataspace ID - RETURNS - Non-negative on success/Negative on failure - DESCRIPTION - Refine an existing hyperslab selection with an operation, using a second - hyperslab. The first selection is modified to contain the result of - space1 operated on by space2. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5Sselect_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) -{ - H5S_t *space1; /* First Dataspace */ - H5S_t *space2; /* Second Dataspace */ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_API(H5Sselect_select, FAIL); - H5TRACE3("e","iSsi",space1_id,op,space2_id); - - /* Check args */ - if (NULL == (space1=H5I_object_verify(space1_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - if (NULL == (space2=H5I_object_verify(space2_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - if(!(op>H5S_SELECT_NOOP && opextent.u.simple.rank!=space2->extent.u.simple.rank) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces not same rank"); - - /* Check that both dataspaces have hyperslab selections */ - if(space1->select.type!=H5S_SEL_HYPERSLABS || space2->select.type!=H5S_SEL_HYPERSLABS) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces don't have hyperslab selections"); - - /* Go refine the first selection */ - if (H5S_select_select(space1, op, space2)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to modify hyperslab selection"); - -done: - FUNC_LEAVE_API(ret_value); -} /* end H5Sselect_select() */ -#endif /* NEW_HYPERSLAB_API */ /* Works */ /*-------------------------------------------------------------------------- diff --git a/test/tselect.c b/test/tselect.c index 9dc4261..bea1e89 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -2806,363 +2806,6 @@ test_select_hyper_union(void) free(rbuf); } /* test_select_hyper_union() */ -#ifdef NEW_HYPERSLAB_API -/**************************************************************** -** -** test_select_hyper_union_stagger(): Test basic H5S (dataspace) selection code. -** Tests unions of staggered hyperslabs. (Uses H5Scombine_hyperslab -** and H5Sselect_select instead of H5Sselect_hyperslab) -** -****************************************************************/ -static void -test_select_hyper_union_stagger(void) -{ - hid_t file_id; /* File ID */ - hid_t dset_id; /* Dataset ID */ - hid_t dataspace; /* File dataspace ID */ - hid_t memspace; /* Memory dataspace ID */ - hid_t tmp_space; /* Temporary dataspace ID */ - hid_t tmp2_space; /* Another emporary dataspace ID */ - hsize_t dimsm[2]={7,7}; /* Memory array dimensions */ - hsize_t dimsf[2]={6,5}; /* File array dimensions */ - hsize_t count[2]={3,1}; /* 1st Hyperslab size */ - hsize_t count2[2]={3,1}; /* 2nd Hyperslab size */ - hsize_t count3[2]={2,1}; /* 3rd Hyperslab size */ - hssize_t offset[2]={0,0}; /* 1st Hyperslab offset */ - hssize_t offset2[2]={2,1}; /* 2nd Hyperslab offset */ - hssize_t offset3[2]={4,2}; /* 3rd Hyperslab offset */ - hsize_t count_out[2]={4,2}; /* Hyperslab size in memory */ - hssize_t offset_out[2]={0,3}; /* Hyperslab offset in memory */ - int data[6][5]; /* Data to write */ - int data_out[7][7]; /* Data read in */ - int input_loc[8][2]={{0,0}, - {1,0}, - {2,0}, - {2,1}, - {3,1}, - {4,1}, - {4,2}, - {5,2}}; - int output_loc[8][2]={{0,3}, - {0,4}, - {1,3}, - {1,4}, - {2,3}, - {2,4}, - {3,3}, - {3,4}}; - int dsetrank=2; /* File Dataset rank */ - int memrank=2; /* Memory Dataset rank */ - int i,j; /* Local counting variables */ - herr_t error; - hsize_t stride[2]={1,1}; - hsize_t block[2]={1,1}; - - /* Initialize data to write */ - for(i=0; i<6; i++) - for(j=0; j<5; j++) - data[i][j] = j*10 + i; - - /* Create file */ - file_id=H5Fcreate(FILENAME,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT); - CHECK(file_id, FAIL, "H5Fcreate"); - - /* Create File Dataspace */ - dataspace=H5Screate_simple(dsetrank,dimsf,NULL); - CHECK(dataspace, FAIL, "H5Screate_simple"); - - /* Create File Dataset */ - dset_id=H5Dcreate(file_id,"IntArray",H5T_NATIVE_INT,dataspace,H5P_DEFAULT); - CHECK(dset_id, FAIL, "H5Dcreate"); - - /* Write File Dataset */ - error=H5Dwrite(dset_id,H5T_NATIVE_INT,dataspace,dataspace,H5P_DEFAULT,data); - CHECK(error, FAIL, "H5Dwrite"); - - /* Close things */ - error=H5Sclose(dataspace); - CHECK(error, FAIL, "H5Sclose"); - error=H5Dclose(dset_id); - CHECK(error, FAIL, "H5Dclose"); - error=H5Fclose(file_id); - CHECK(error, FAIL, "H5Fclose"); - - /* Initialize intput buffer */ - memset(data_out,0,7*7*sizeof(int)); - - /* Open file */ - file_id=H5Fopen(FILENAME,H5F_ACC_RDONLY,H5P_DEFAULT); - CHECK(file_id, FAIL, "H5Fopen"); - - /* Open dataset */ - dset_id=H5Dopen(file_id,"IntArray"); - CHECK(dset_id, FAIL, "H5Dopen"); - - /* Get the dataspace */ - dataspace=H5Dget_space(dset_id); - CHECK(dataspace, FAIL, "H5Dget_space"); - - /* Select the hyperslabs */ - error=H5Sselect_hyperslab(dataspace,H5S_SELECT_SET,offset,stride,count,block); - CHECK(error, FAIL, "H5Sselect_hyperslab"); - tmp_space=H5Scombine_hyperslab(dataspace,H5S_SELECT_OR,offset2,stride,count2,block); - CHECK(tmp_space, FAIL, "H5Scombine_hyperslab"); - - /* Copy the file dataspace and select hyperslab */ - tmp2_space=H5Scopy(dataspace); - CHECK(tmp2_space, FAIL, "H5Scopy"); - error=H5Sselect_hyperslab(tmp2_space,H5S_SELECT_SET,offset3,stride,count3,block); - CHECK(error, FAIL, "H5Sselect_hyperslab"); - - /* Combine the copied dataspace with the temporary dataspace */ - error=H5Sselect_select(tmp_space,H5S_SELECT_OR,tmp2_space); - CHECK(error, FAIL, "H5Sselect_select"); - - /* Create Memory Dataspace */ - memspace=H5Screate_simple(memrank,dimsm,NULL); - CHECK(memspace, FAIL, "H5Screate_simple"); - - /* Select hyperslab in memory */ - error=H5Sselect_hyperslab(memspace,H5S_SELECT_SET,offset_out,stride,count_out,block); - CHECK(error, FAIL, "H5Sselect_hyperslab"); - - /* Read File Dataset */ - error=H5Dread(dset_id,H5T_NATIVE_INT,memspace,tmp_space,H5P_DEFAULT,data_out); - CHECK(error, FAIL, "H5Dread"); - - /* Verify input data */ - for(i=0; i<8; i++) { - if(data[input_loc[i][0]][input_loc[i][1]]!=data_out[output_loc[i][0]][output_loc[i][1]]) { - printf("input data #%d is wrong!\n",i); - printf("input_loc=[%d][%d]\n",input_loc[i][0],input_loc[i][1]); - printf("output_loc=[%d][%d]\n",output_loc[i][0],output_loc[i][1]); - printf("data=%d\n",data[input_loc[i][0]][input_loc[i][1]]); - TestErrPrintf("data_out=%d\n",data_out[output_loc[i][0]][output_loc[i][1]]); - } /* end if */ - } /* end for */ - - /* Close things */ - error=H5Sclose(tmp2_space); - CHECK(error, FAIL, "H5Sclose"); - error=H5Sclose(tmp_space); - CHECK(error, FAIL, "H5Sclose"); - error=H5Sclose(dataspace); - CHECK(error, FAIL, "H5Sclose"); - error=H5Sclose(memspace); - CHECK(error, FAIL, "H5Sclose"); - error=H5Dclose(dset_id); - CHECK(error, FAIL, "H5Dclose"); - error=H5Fclose(file_id); - CHECK(error, FAIL, "H5Fclose"); -} - -/**************************************************************** -** -** test_select_hyper_union_3d(): Test basic H5S (dataspace) selection code. -** Tests unions of hyperslabs in 3-D (Uses H5Scombine_hyperslab -** and H5Scombine_select instead of H5Sselect_hyperslab) -** -****************************************************************/ -static void -test_select_hyper_union_3d(void) -{ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hid_t tmp_space; /* Temporary Dataspace ID */ - hid_t tmp2_space; /* Another temporary Dataspace ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {SPACE4_DIM1, SPACE4_DIM2, SPACE4_DIM3}; - hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2}; - hssize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ - struct row_list { - size_t z; - size_t y; - size_t x; - size_t l; - } rows[]= { /* Array of x,y,z coordinates & length for each row written from memory */ - {0,0,0,6}, /* 1st face of 3-D object */ - {0,1,0,6}, - {0,2,0,6}, - {0,3,0,6}, - {0,4,0,6}, - {1,0,0,6}, /* 2nd face of 3-D object */ - {1,1,0,6}, - {1,2,0,6}, - {1,3,0,6}, - {1,4,0,6}, - {2,0,0,6}, /* 3rd face of 3-D object */ - {2,1,0,10}, - {2,2,0,10}, - {2,3,0,10}, - {2,4,0,10}, - {2,5,2,8}, - {2,6,2,8}, - {3,0,0,6}, /* 4th face of 3-D object */ - {3,1,0,10}, - {3,2,0,10}, - {3,3,0,10}, - {3,4,0,10}, - {3,5,2,8}, - {3,6,2,8}, - {4,0,0,6}, /* 5th face of 3-D object */ - {4,1,0,10}, - {4,2,0,10}, - {4,3,0,10}, - {4,4,0,10}, - {4,5,2,8}, - {4,6,2,8}, - {5,1,2,8}, /* 6th face of 3-D object */ - {5,2,2,8}, - {5,3,2,8}, - {5,4,2,8}, - {5,5,2,8}, - {5,6,2,8}, - {6,1,2,8}, /* 7th face of 3-D object */ - {6,2,2,8}, - {6,3,2,8}, - {6,4,2,8}, - {6,5,2,8}, - {6,6,2,8}, - {7,1,2,8}, /* 8th face of 3-D object */ - {7,2,2,8}, - {7,3,2,8}, - {7,4,2,8}, - {7,5,2,8}, - {7,6,2,8}}; - uint8_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf, /* temporary buffer pointer */ - *tbuf2; /* temporary buffer pointer */ - int i,j,k; /* Counters */ - herr_t ret; /* Generic return value */ - hsize_t npoints; /* Number of elements in selection */ - - /* Output message about test being performed */ - MESSAGE(5, ("Testing Hyperslab Selection Functions with unions of 3-D hyperslabs\n")); - - /* Allocate write & read buffers */ - wbuf=malloc(sizeof(uint8_t)*SPACE4_DIM1*SPACE4_DIM2*SPACE4_DIM3); - rbuf=calloc(sizeof(uint8_t),SPACE3_DIM1*SPACE3_DIM2); - - /* Initialize write buffer */ - for(i=0, tbuf=wbuf; i