diff options
Diffstat (limited to 'src/H5Pdcpl.c')
-rw-r--r-- | src/H5Pdcpl.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 7e995ef..d7f8809 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -751,6 +751,61 @@ done: FUNC_LEAVE(ret_value); } + +/*------------------------------------------------------------------------- + * Function: H5Pset_shuffle + * + * Purpose: Sets the shuffling method for a permanent + * filter + * to H5Z_FILTER_SHUFFLE + * and bytes of the datatype of the array to be shuffled + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Wednesday, April 15, 1998 + * + * Modifications: + * + * Raymond Lu + * Tuesday, October 2, 2001 + * Changed the way to check parameter and set property for + * generic property list. + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_shuffle(hid_t plist_id, unsigned bytes_of_type) +{ + H5O_pline_t pline; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value=SUCCEED; /* return value */ + + FUNC_ENTER_API(H5Pset_shuffle, FAIL); + H5TRACE2("e","iIu",plist_id,bytes_of_type); + + /* Check arguments */ + if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); + if (bytes_of_type == 0) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "number of bytes of datatype cannot be 0"); + + /* Get the plist structure */ + if(NULL == (plist = H5I_object(plist_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + /* Add the filter */ + if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline"); + if (H5Z_append(&pline, H5Z_FILTER_SHUFFLE, H5Z_FLAG_OPTIONAL, 1, &bytes_of_type)<0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to shuffle the data"); + if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline"); + +done: + FUNC_LEAVE(ret_value); +} + /*------------------------------------------------------------------------- * Function: H5Pset_fill_value |