/*------------------------------------------------------------------------- * Function: H5Tset_cset * * Purpose: HDF5 is able to distinguish between character sets of * different nationalities and to convert between them to the * extent possible. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 9, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived data types. * *------------------------------------------------------------------------- */ herr_t H5Tset_cset(hid_t type_id, H5T_cset_t cset) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tset_cset, FAIL) H5TRACE2("e","iTc",type_id,cset); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (cset < H5T_CSET_ASCII || cset >= H5T_NCSET) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal character set type") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for data type class") /* Commit */ if(H5T_IS_FIXED_STRING(dt->shared)) dt->shared->u.atomic.u.s.cset = cset; else dt->shared->u.vlen.cset = cset; done: FUNC_LEAVE_API(ret_value) }
/*------------------------------------------------------------------------- * Function: H5Tset_sign * * Purpose: Sets the sign property for an integer. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived datatypes. * *------------------------------------------------------------------------- */ herr_t H5Tset_sign(hid_t type_id, H5T_sign_t sign) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTs", type_id, sign); /* Check args */ if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer datatype") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (sign < H5T_SGN_NONE || sign >= H5T_NSGN) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal sign type") if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if (H5T_INTEGER!=dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.i.sign = sign; done: FUNC_LEAVE_API(ret_value) }
/*------------------------------------------------------------------------- * Function: H5Pset_istore_k * * Purpose: IK is one half the rank of a tree that stores chunked raw * data. On average, such a tree will be 75% full, or have an * average rank of 1.5 times the value of IK. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, January 6, 1998 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_istore_k(hid_t plist_id, unsigned ik) { unsigned btree_k[H5B_NUM_BTREE_ID]; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pset_istore_k, FAIL); H5TRACE2("e","iIu",plist_id,ik); /* Check arguments */ if (ik == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "istore IK value must be positive"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set value */ if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree interanl nodes"); btree_k[H5B_ISTORE_ID] = ik; if(H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for btree interanl nodes"); done: FUNC_LEAVE_API(ret_value); }
/*------------------------------------------------------------------------- * Function: H5Pset_userblock * * Purpose: Sets the userblock size field of a file creation property * list. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, January 6, 1998 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pset_userblock(hid_t plist_id, hsize_t size) { unsigned i; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_userblock, FAIL); H5TRACE2("e","ih",plist_id,size); /* Check that the userblock size is a power of two */ for (i=8; i<8*sizeof(hsize_t); i++) { hsize_t p2 = 8==i ? 0 : ((hsize_t)1<<i); if (size == p2) break; } if (i>=8*sizeof(hsize_t)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is not valid"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set value */ if(H5P_set(plist, H5F_CRT_USER_BLOCK_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set user block"); done: FUNC_LEAVE_API(ret_value); }
/*------------------------------------------------------------------------- * Function: H5Tset_inpad * * Purpose: If any internal bits of a floating point type are unused * (that is, those significant bits which are not part of the * sign, exponent, or mantissa) then they will be filled * according to the value of this property. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 9, 1998 * *------------------------------------------------------------------------- */ herr_t H5Tset_inpad(hid_t type_id, H5T_pad_t pad) { H5T_t *dt; /* Datatype */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTp", type_id, pad); /* Check args */ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") if(pad < H5T_PAD_ZERO || pad >= H5T_NPAD) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal internal pad type") while(dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if(H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.f.pad = pad; done: FUNC_LEAVE_API(ret_value) } /* end H5Tset_inpad() */
/*------------------------------------------------------------------------- * Function: H5Tset_norm * * Purpose: Sets the mantissa normalization method for a floating point * datatype. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * *------------------------------------------------------------------------- */ herr_t H5Tset_norm(hid_t type_id, H5T_norm_t norm) { H5T_t *dt; /* Datatype */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTn", type_id, norm); /* Check args */ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") if(norm < H5T_NORM_IMPLIED || norm > H5T_NORM_NONE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization") while(dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if(H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.f.norm = norm; done: FUNC_LEAVE_API(ret_value) } /* end H5Tset_norm() */
/*------------------------------------------------------------------------- * Function: H5Tset_ebias * * Purpose: Sets the exponent bias of a floating-point type. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived datatypes. * *------------------------------------------------------------------------- */ herr_t H5Tset_ebias(hid_t type_id, size_t ebias) { H5T_t *dt; /* Datatype */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", type_id, ebias); /* Check args */ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") while(dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ if(H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.f.ebias = ebias; done: FUNC_LEAVE_API(ret_value) } /* end H5Tset_ebias() */
/*------------------------------------------------------------------------- * Function: H5Tset_strpad * * Purpose: The method used to store character strings differs with the * programming language: C usually null terminates strings while * Fortran left-justifies and space-pads strings. This property * defines the storage mechanism for the string. * * When converting from a long string to a short string if the * short string is H5T_STR_NULLPAD or H5T_STR_SPACEPAD then the * string is simply truncated; otherwise if the short string is * H5T_STR_NULLTERM it will be truncated and a null terminator * is appended. * * When converting from a short string to a long string, the * long string is padded on the end by appending nulls or * spaces. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 9, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works for derived datatypes. * *------------------------------------------------------------------------- */ herr_t H5Tset_strpad(hid_t type_id, H5T_str_t strpad) { H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTz", type_id, strpad); /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (strpad < H5T_STR_NULLTERM || strpad >= H5T_NSTR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal string pad type") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for datatype class") /* Commit */ if(H5T_IS_FIXED_STRING(dt->shared)) dt->shared->u.atomic.u.s.pad = strpad; else dt->shared->u.vlen.pad = strpad; done: FUNC_LEAVE_API(ret_value) }
/*------------------------------------------------------------------------- * Function: H5Pget_hyper_vector_size * * Purpose: Reads values previously set with H5Pset_hyper_vector_size(). * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Monday, July 9, 2001 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pget_hyper_vector_size(hid_t plist_id, size_t *vector_size/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_hyper_vector_size, FAIL); H5TRACE2("e","ix",plist_id,vector_size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Return values */ if (vector_size) if (H5P_get(plist,H5D_XFER_HYPER_VECTOR_SIZE_NAME,vector_size)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_hyper_vector_size() */
/*------------------------------------------------------------------------- * Function: H5Pget_userblock * * Purpose: Queries the size of a user block in a file creation property * list. * * Return: Success: Non-negative, size returned through SIZE argument. * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_userblock(hid_t plist_id, hsize_t *size) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_userblock, FAIL); H5TRACE2("e","i*h",plist_id,size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ if (size) if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL,"can't get user block"); done: FUNC_LEAVE_API(ret_value); }
/*------------------------------------------------------------------------- * Function: H5Pset_preserve * * Purpose: When reading or writing compound data types and the * destination is partially initialized and the read/write is * intended to initialize the other members, one must set this * property to TRUE. Otherwise the I/O pipeline treats the * destination datapoints as completely uninitialized. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, March 17, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_preserve(hid_t plist_id, hbool_t status) { H5T_bkg_t need_bkg; /* Value for background buffer type */ H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_preserve, FAIL); H5TRACE2("e","ib",plist_id,status); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Update property list */ need_bkg = status ? H5T_BKG_YES : H5T_BKG_NO; if (H5P_set(plist,H5D_XFER_BKGR_BUF_TYPE_NAME,&need_bkg)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value"); done: FUNC_LEAVE_API(ret_value); }
/*------------------------------------------------------------------------- * Function: H5Fget_info1 * * Purpose: Gets general information about the file, including: * 1. Get storage size for superblock extension if there is one. * 2. Get the amount of btree and heap storage for entries * in the SOHM table if there is one. * 3. The amount of free space tracked in the file. * * Return: Success: non-negative on success * Failure: Negative * * Programmer: Vailin Choi * July 11, 2007 * *------------------------------------------------------------------------- */ herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo) { H5F_t *f; /* Top file in mount hierarchy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", obj_id, finfo); /* Check args */ if(!finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") /* For file IDs, get the file object directly */ /* (This prevents the H5G_loc() call from returning the file pointer for * the top file in a mount hierarchy) */ if(H5I_get_type(obj_id) == H5I_FILE ) { if(NULL == (f = (H5F_t *)H5I_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") } /* end if */ else {
/*------------------------------------------------------------------------- * Function: H5Pset_hyper_vector_size * * Purpose: Given a dataset transfer property list, set the number of * "I/O vectors" (offset and length pairs) which are to be * accumulated in memory before being issued to the lower levels * of the library for reading or writing the actual data. * Increasing the number should give better performance, but use * more memory during hyperslab I/O. The vector size must be * greater than 1. * * The default is to use 1024 vectors for I/O during hyperslab * reading/writing. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Monday, July 9, 2001 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_hyper_vector_size(hid_t plist_id, size_t vector_size) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_hyper_vector_size, FAIL); H5TRACE2("e","iz",plist_id,vector_size); /* Check arguments */ if (vector_size<1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "vector size too small"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Update property list */ if (H5P_set(plist,H5D_XFER_HYPER_VECTOR_SIZE_NAME,&vector_size)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value"); done: FUNC_LEAVE_API(ret_value); } /* end H5Pset_hyper_vector_size() */
/*------------------------------------------------------------------------- * Function: H5Pset_edc_check * * Purpose: Enable or disable error-detecting for a dataset reading * process. This error-detecting algorithm is whichever * user chooses earlier. This function cannot control * writing process. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Jan 3, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_edc_check, FAIL); H5TRACE2("e","iZe",plist_id,check); /* Check argument */ if (check != H5Z_ENABLE_EDC && check != H5Z_DISABLE_EDC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid value"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Update property list */ if (H5P_set(plist,H5D_XFER_EDC_NAME,&check)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value"); done: FUNC_LEAVE_API(ret_value); }
/*------------------------------------------------------------------------- * Function: H5Pget_istore_k * * Purpose: Queries the 1/2 rank of an indexed storage B-tree. See * H5Pset_istore_k() for details. The argument IK may be the * null pointer. * * Return: Success: Non-negative, size returned through IK * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out */ ) { unsigned btree_k[H5B_NUM_BTREE_ID]; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_istore_k, FAIL); H5TRACE2("e","ix",plist_id,ik); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ if (ik) { if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree interanl nodes"); *ik = btree_k[H5B_ISTORE_ID]; } done: FUNC_LEAVE_API(ret_value); }