summaryrefslogtreecommitdiffstats
path: root/src/H5Shyper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Shyper.c')
-rw-r--r--src/H5Shyper.c856
1 files changed, 0 insertions, 856 deletions
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 && op<H5S_SELECT_INVALID);
-
- /* Free the current selection for the result space */
- if((*result->select.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 && op<H5S_SELECT_INVALID);
- assert(start);
- assert(_stride);
- assert(_count);
- assert(_block);
-
- /* Optimize hyperslab selection to merge contiguous blocks */
- for(u=0; u<space->extent.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 && op<H5S_SELECT_INVALID);
-
- /* Fill in the correct stride values */
- if(stride==NULL) {
- hsize_t fill=1;
-
- H5V_array_fill(_stride,&fill,sizeof(hssize_t),space->extent.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; u<space->extent.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; u<space->extent.u.simple.rank; u++) {
- if(count[u]>1 && stride[u]<block[u])
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab blocks overlap");
- } /* end for */
-
- /* If we are setting a new selection, remove current selection first */
- if((*space->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; u<space->extent.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 && op<H5S_SELECT_INVALID))
- HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
- if(stride!=NULL) {
- /* Check for 0-sized strides */
- for(u=0; u<space->extent.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; u<space->extent.u.simple.rank; u++) {
- if(count[u]>1 && stride[u]<block[u])
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid stride<block value");
- } /* end for */
- } /* end if */
- } /* end if */
-
- if (H5S_select_hyperslab(space, op, start, stride, count, block)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection");
-
-done:
- FUNC_LEAVE_API(ret_value);
-} /* end H5Sselect_hyperslab() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5Scombine_hyperslab
- PURPOSE
- Specify a hyperslab to combine with the current hyperslab selection and
- return a new dataspace with the combined selection as the selection in the
- new dataspace.
- USAGE
- hid_t H5Srefine_hyperslab(dsid, op, start, stride, count, block)
- hid_t dsid; IN: Dataspace ID of selection to use
- 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
- Dataspace ID on success/Negative on failure
- DESCRIPTION
- Combines a hyperslab selection with the current selection for a dataspace,
- creating a new dataspace to return the generated selection.
- 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
---------------------------------------------------------------------------*/
-hid_t
-H5Scombine_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 */
- H5S_t *new_space = NULL; /* New dataspace created */
- hid_t ret_value;
-
- FUNC_ENTER_API(H5Scombine_hyperslab, FAIL);
- H5TRACE6("i","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(start==NULL || count==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified");
-
- if(!(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID))
- HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
-
- /* Copy the first dataspace */
- if (NULL==(new_space=H5S_copy (space)))
- HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to copy data space");
-
- /* Go modify the selection in the new dataspace */
- if (H5S_select_hyperslab(new_space, op, start, stride, count, block)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set 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_hyperslab() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5S_combine_select
- *
- * Purpose: Internal version of H5Scombine_select().
- *
- * Return: New dataspace on success/NULL on failure
- *
- * Programmer: Quincey Koziol
- * Tuesday, October 30, 2001
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static H5S_t *
-H5S_combine_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2)
-{
- H5S_t *new_space=NULL; /* New dataspace generated */
- H5S_t *ret_value; /* return value */
-
- FUNC_ENTER_NOAPI_NOINIT(H5S_combine_select);
-
- /* Check args */
- assert(space1);
- assert(space2);
- assert(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID);
-
- /* Copy the first dataspace */
- if (NULL==(new_space=H5S_copy (space1)))
- HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to copy data space");
-
- /* Combine space1 & space2, with the result in new_space */
- if(H5S_operate_hyperslab(new_space,space1->select.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 && op<H5S_SELECT_INVALID))
- HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
-
- /* Check that both dataspaces have the same rank */
- if(space1->extent.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 && op<H5S_SELECT_INVALID);
-
- /* Copy the first dataspace */
- if (NULL==(tmp_spans=H5S_hyper_copy_span(space1->select.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 && op<H5S_SELECT_INVALID))
- HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
-
- /* Check that both dataspaces have the same rank */
- if(space1->extent.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 */
/*--------------------------------------------------------------------------