//-------------------------------------------------------------------------- // Function: DSetCreatPropList::modifyFilter ///\brief Modifies the specified filter ///\param filter_id - IN: Filter to get ///\param flags - OUT: General properties of the filter ///\param cd_nelmts - IN: Number of elements in \a cd_values /// \n OUT: Number of values defined by the filter ///\param cd_values - OUT: Array to hold the data; allocated by the user ///\exception H5::PropListIException ///\par Description /// The \a flags argument is a bit vector of the field: /// \c H5Z_FLAG_OPTIONAL(0x0001) ///\par /// If this bit is set then the filter is optional. If the filter /// fails during a DataSet::write() operation then the filter /// is just excluded from the pipeline for the chunk for which it /// failed; the filter will not participate in the pipeline /// during a DataSet::read() of the chunk. If this bit is clear /// and the filter fails then the entire I/O operation fails. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void DSetCreatPropList::modifyFilter( H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[] ) const { herr_t ret_value = H5Pmodify_filter(id, filter_id, flags, cd_nelmts, cd_values); if( ret_value < 0 ) { throw PropListIException("DSetCreatPropList::modifyFilter", "H5Pmodify_filter failed"); } }
static herr_t H5Z_sz_set_local(hid_t dcpl_id, hid_t type_id, hid_t chunk_space_id) { //printf("start in H5Z_sz_set_local\n"); size_t r5=0,r4=0,r3=0,r2=0,r1=0, dsize; static char const *_funcname_ = "H5Z_sz_set_local"; int i, ndims, ndims_used = 0; hsize_t dims[H5S_MAX_RANK], dims_used[5] = {0,0,0,0,0}; herr_t retval = 0; H5T_class_t dclass; H5T_sign_t dsign; unsigned int flags = 0; //conf_params = H5Z_SZ_Init_Default(); H5Z_SZ_Init(cfgFile); int dataType = SZ_FLOAT; if (0 > (dclass = H5Tget_class(type_id))) H5Z_SZ_PUSH_AND_GOTO(H5E_ARGS, H5E_BADTYPE, -1, "not a datatype"); if (0 == (dsize = H5Tget_size(type_id))) H5Z_SZ_PUSH_AND_GOTO(H5E_ARGS, H5E_BADTYPE, -1, "size is smaller than 0!"); if (0 > (ndims = H5Sget_simple_extent_dims(chunk_space_id, dims, 0))) H5Z_SZ_PUSH_AND_GOTO(H5E_ARGS, H5E_BADTYPE, -1, "not a data space"); for (i = 0; i < ndims; i++) { if (dims[i] <= 1) continue; dims_used[ndims_used] = dims[i]; ndims_used++; } //printf("dclass=%d, H5T_FLOAT=%d, H5T_INTEGER=%d\n", dclass, H5T_FLOAT, H5T_INTEGER); if (dclass == H5T_FLOAT) dataType = dsize==4? SZ_FLOAT: SZ_DOUBLE; else if(dclass == H5T_INTEGER) { if (0 > (dsign = H5Tget_sign(type_id))) H5Z_SZ_PUSH_AND_GOTO(H5E_ARGS, H5E_BADTYPE, -1, "Error in calling H5Tget_sign(type_id)...."); if(dsign == H5T_SGN_NONE) //unsigned { switch(dsize) { case 1: dataType = SZ_UINT8; break; case 2: dataType = SZ_UINT16; break; case 4: dataType = SZ_UINT32; break; case 8: dataType = SZ_UINT64; break; } } else { switch(dsize) { case 1: dataType = SZ_INT8; break; case 2: dataType = SZ_INT16; break; case 4: dataType = SZ_INT32; break; case 8: dataType = SZ_INT64; break; } } } else { //printf("Error: dclass...\n"); H5Z_SZ_PUSH_AND_GOTO(H5E_PLINE, H5E_BADTYPE, 0, "datatype class must be H5T_FLOAT or H5T_INTEGER"); } switch(ndims_used) { case 1: r1 = dims_used[0]; break; case 2: r1 = dims_used[0]; r2 = dims_used[1]; break; case 3: r1 = dims_used[0]; r2 = dims_used[1]; r3 = dims_used[2]; break; case 4: r1 = dims_used[0]; r2 = dims_used[1]; r3 = dims_used[2]; r4 = dims_used[3]; break; default: H5Z_SZ_PUSH_AND_GOTO(H5E_PLINE, H5E_BADVALUE, 0, "requires chunks w/1,2,3 or 4 non-unity dims"); } size_t cd_nelmts = 0; unsigned int mem_cd_values[7]; unsigned int* cd_values; if (0 > H5Pget_filter_by_id(dcpl_id, H5Z_FILTER_SZ, &flags, &cd_nelmts, mem_cd_values, 0, NULL, NULL)) H5Z_SZ_PUSH_AND_GOTO(H5E_PLINE, H5E_CANTGET, 0, "unable to get current SZ cd_values"); SZ_metaDataToCdArray(&cd_nelmts, &cd_values, dataType, r5, r4, r3, r2, r1); /* Now, update cd_values for the filter */ if (0 > H5Pmodify_filter(dcpl_id, H5Z_FILTER_SZ, flags, cd_nelmts, cd_values)) H5Z_SZ_PUSH_AND_GOTO(H5E_PLINE, H5E_BADVALUE, 0, "failed to modify cd_values"); retval = 1; done: return retval; }