diff options
Diffstat (limited to 'src/H5Sselect.c')
-rw-r--r-- | src/H5Sselect.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 8c45deb..83e6b38 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -311,6 +311,98 @@ done: /*-------------------------------------------------------------------------- NAME + H5Sselect_elements + PURPOSE + Specify a series of elements in the dataspace to select + USAGE + herr_t H5Sselect_elements(dsid, op, num_elem, coord) + hid_t dsid; IN: Dataspace ID of selection to modify + H5S_seloper_t op; IN: Operation to perform on current selection + size_t num_elem; IN: Number of elements in COORD array. + const hssize_t *coord[]; IN: The location of each element selected + RETURNS + SUCCEED/FAIL + DESCRIPTION + This function selects array elements to be included in the selection for + the dataspace. The COORD array is a 2-D array of size <dataspace rank> + by NUM_ELEM (ie. a list of coordinates in the dataspace). The order of + the element coordinates in the COORD array specifies the order that the + array elements are iterated through when I/O is performed. Duplicate + coordinates are not checked for. The selection operator, OP, determines + how the new selection is to be combined with the existing selection for + the dataspace. Currently, only H5S_SELECT_SET is supported, which replaces + the existing selection with the one defined in this call. When operators + other than H5S_SELECT_SET are used to combine a new selection with an + existing selection, the selection ordering is reset to 'C' array ordering. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t H5Sselect_elements (hid_t spaceid, H5S_seloper_t op, size_t num_elem, + const hssize_t *coord[]) +{ + H5S_t *space = NULL; /* Dataspace to modify selection of */ + herr_t ret_value=FAIL; /* return value */ + + FUNC_ENTER (H5Sselect_elements, FAIL); + + /* Check args */ + if (H5_DATASPACE != H5I_group(spaceid) || + NULL == (space=H5I_object(spaceid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + } + if(coord==NULL || num_elem==0) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "elements not specified"); + } /* end if */ + if(op!=H5S_SELECT_SET) { + HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, + "operations other than H5S_SELECT_SET not supported currently"); + } /* end if */ + +#ifdef QAK +printf("%s: check 1.0\n",FUNC); +#endif /* QAK */ + /* If we are setting a new selection, remove current selection first */ + if(op==H5S_SELECT_SET) { + if(H5S_select_release(space)<0) { + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, + "can't release hyperslab"); + } /* end if */ + } /* end if */ + +#ifdef QAK +printf("%s: check 2.0\n",FUNC); +#endif /* QAK */ + /* Allocate space for the point selection information if necessary */ + if(space->select.type!=H5S_SEL_POINTS || space->select.sel_info.pnt_lst==NULL) { + if((space->select.sel_info.pnt_lst = H5MM_calloc(sizeof(H5S_pnt_list_t)))==NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "can't allocate element information"); + } /* end if */ + +#ifdef QAK +printf("%s: check 3.0\n",FUNC); +#endif /* QAK */ + /* Add points to selection */ + if(H5S_point_add(space,num_elem,coord)<0) { + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, + "can't insert elements"); + } + + /* Set selection type */ + space->select.type=H5S_SEL_POINTS; + ret_value=SUCCEED; +#ifdef QAK +printf("%s: check 4.0\n",FUNC); +#endif /* QAK */ + +done: + FUNC_LEAVE (ret_value); +} /* H5Sselect_elements() */ + +/*-------------------------------------------------------------------------- + NAME H5Sselect_npoints PURPOSE Get the number of elements in current selection |