From efc14a5341042f5d04f0578bd9820495f1e11d79 Mon Sep 17 00:00:00 2001 From: Robb Matzke Date: Thu, 11 Dec 1997 13:49:02 -0500 Subject: [svn-r142] ./src/H5C.c ./src/H5Cprivate.h Changed H5Csetparm() to H5Cset_prop() and changed it to pass property values by value instead of reference. Changed H5Cgetparm() to H5Cget_prop(). Changed data types of file creation properties so the application can use `int' or `size_t' for most properties. Properties and their types are documented in H5Cget_prop(). Changed H5C_class() to H5Cget_class() to make the naming more uniform across packages. ./src/H5Cpublic.h Changed names of properties to make them more uniform across packages: H5F_USERBLOCK_SIZE became H5F_SIZEOF_USERBLOCK, H5F_OFFSET_SIZE became H5F_SIZEOF_ADDR, H5F_LENGTH_SIZE became H5F_SIZEOF_SIZE. ./src/H5D.c ./src/H5Dprivate.h Added support for chunked data storage. There still isn't any support for data type conversion or data space conversion, so chunked storage doesn't do much at this time. ./src/H5E.c ./src/H5Epublic.h Added the H5E_TEMPLATE major error number. I'm about the change the HGOTO_ERROR() and HRETURN_ERROR() macros to take an error string as an additional argument instead of specifying it as a comment. ./src/H5Fistore.c Added `const' to the `buf' argument of H5F_istore_write() although this temporarily causes a compiler warning. ./src/H5Fprivate.h Changed data types of certain file-related variables from types like `uint8' to `uintn' since the library data types should not depend on the file data types. ./src/H5P.c ./src/H5Pprivate.h ./src/H5Ppublic.h Moved H5Pget_lrank() to H5Pget_ndims(), and H5Pget_ldims() to H5Pget_dims() to make naming more uniform. Dimensions should always be of type `size_t'. Similarly for H5P_get_lrank() and H5P_get_ldims(). --- src/H5C.c | 491 ++++++++++++++++++++++++++++++++++--------------------- src/H5Cprivate.h | 1 - src/H5Cpublic.h | 11 +- src/H5D.c | 192 ++++++++++++++++------ src/H5Distore.c | 5 +- src/H5Dprivate.h | 2 + src/H5E.c | 3 +- src/H5Epublic.h | 37 +++-- src/H5Fistore.c | 5 +- src/H5Fprivate.h | 22 +-- src/H5P.c | 359 ++++++++++++++++++++-------------------- src/H5Pprivate.h | 8 +- src/H5Ppublic.h | 4 +- 13 files changed, 684 insertions(+), 456 deletions(-) diff --git a/src/H5C.c b/src/H5C.c index d65e4b7..ad18406 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -16,21 +16,7 @@ static char RcsId[] = "@(#)$Revision$"; /* $Id$ */ -/*LINTLIBRARY */ -/*+ - FILE - hdf5file.c - HDF5 "personality template" routines - - EXPORTED ROUTINES - H5Csetparm -- Set a parameter for a template - H5Cgetparm -- Get a parameter for a template - - LIBRARY-SCOPED ROUTINES - - LOCAL ROUTINES - H5C_init_interface -- initialize the interface - + */ +#include /* Private header files */ #include /* Generic Functions */ @@ -253,7 +239,7 @@ H5Cclose (hid_t template) /*------------------------------------------------------------------------- - * Function: H5C_class + * Function: H5Cget_class * * Purpose: Returns the class identifier for a template. * @@ -269,12 +255,12 @@ H5Cclose (hid_t template) *------------------------------------------------------------------------- */ H5C_class_t -H5C_class (hid_t template) +H5Cget_class (hid_t template) { group_t group; H5C_class_t ret_value = H5C_NO_CLASS; - FUNC_ENTER (H5C_class, H5C_NO_CLASS); + FUNC_ENTER (H5Cget_class, H5C_NO_CLASS); if ((group = H5Aatom_group (template))<0 || group=H5_TEMPLATE_MAX) { @@ -286,110 +272,210 @@ H5C_class (hid_t template) FUNC_LEAVE (ret_value); } -/*-------------------------------------------------------------------------- - NAME - H5Cgetparm - PURPOSE - Get a property value from a template - USAGE - herr_t H5Cgetparm(tid, parm, buf) - hid_t tid; IN: Template object to retrieve parameter from - file_create_param_t parm; IN: Paramter to retrieve - VOIDP buf; OUT: Pointer to buffer to store parameter in - RETURNS - SUCCEED/FAIL - - ERRORS - ARGS BADRANGE No result buffer argument supplied. - ARGS BADRANGE Unknown property for dataset create template. - ARGS BADRANGE Unknown property for dataset transfer template. - ARGS BADRANGE Unknown property for file access template. - ARGS BADRANGE Unknown property for file create template. - ARGS BADRANGE Unknown template class. - ATOM BADTYPE Can't unatomize template. - - DESCRIPTION - This function retrieves the value of a specific parameter from a - template - - MODIFICATIONS - Robb Matzke, 13 Aug 1997 - Removed H5_BTREE_SIZE and replaced it with H5_SYM_LEAF_K and - H5_SYM_INTERN_K. - - Robb Matzke, 17 Oct 1997 - Added H5_ISTORE_K. ---------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------- + * Function: H5Cget_prop + * + * Purpose: Retrieves a property value from a template. The value is + * returned through an argument, BUF, of the appropriate pointer + * type. + * + * Properties of H5C_FILE_CREATE templates and the type for the + * return argument(s): + * + * H5F_USERBLOCK_SIZE (size_t*) + * Size of the initial part of the file that is not used + * by HDF5 and may contain user-defined data. + * + * H5F_SIZEOF_ADDR (size_t*) + * Size in bytes of addresses stored in the file. This + * is similar in nature to the `off_t' type in memory. + * + * H5F_SIZEOF_SIZE (size_t*) + * Size in bytes of fields that contains object sizes in + * the file. This is similar in nature to the `size_t' + * type in memory. + * + * H5F_SYM_LEAF_K (int*) + * One half of the number of symbols that can be stored + * in a symbol table node. A symbol table node is the + * leaf of a symbol table tree which is used to store a + * group. When symbols are insterted randomly into a + * group, the group's symbol table nodes are 75% full on + * average. That is, they contain 1.5 times the number + * of symbols specified by this property. + * + * H5F_SYM_INTERN_K (int*) + * One half the rank of a tree that stores a symbol + * table. Internal nodes of the symbol table are on + * average 75% full. That is, the average rank of the + * tree is 1.5 times the value specified for this + * property. + * + * H5F_ISTORE_K (int*) + * 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 specified + * for this property. + * + * H5F_BOOTBLOCK_VER (int*) + * The version number of the file boot block. This is a + * read-only property. + * + * H5F_SMALLOBJECT_VER (int*) + * The version number of the global heap. This is a + * read-only property. + * + * H5F_FREESPACE_VER (int*) + * The version number of the free list. This is a + * read-only property. + * + * H5F_OBJECTDIR_VER (int*) + * The version number of the root symbol table entry. + * This is a read-only property. + * + * H5F_SHAREDHEADER_VER (int*) + * The version number for shared object header messages. + * This is a read-only property. + * + * Properties of H5C_FILE_ACCESS templates and the type for the + * return argument(s): + * + * ** None defined yet ** + * + * Properties of H5C_DATASET_CREATE templates and the type for + * the return argument(s): + * + * H5D_LAYOUT (H5D_layout_t*) + * The layout of raw data on disk. + * + * H5D_CHUNK_NDIMS (int*) + * The number of dimensions per chunk. This is actually + * one less than the real number of dimensions since the + * real chunk dimensions also include the data type + * itself. The number of dimensions returned here + * should be the same as the number of dimensions + * returned by H5Pget_ndims(). + * + * H5D_CHUNK_SIZE (size_t[]) + * An array that specifies the chunk size in each + * dimension. The actual dimension list omits the final + * dimension corresponding to the data type and returns + * only the dimensions corresponding to the data space. + * The array should be large enough to hold at least the + * number of dimension sizes returned by the + * H5D_CHUNK_NDIMS property. + * + * H5D_COMPRESS (H5D_compress_t*) + * The raw data compression algorithm. + * + * H5D_PRE_OFFSET (double*) + * The value which is added to each data point before + * compression or subtracted from each data point after + * uncompression. + * + * H5D_PRE_SCALE (double*) + * The value by which each data point is multiplied + * before compression or divided after uncompression. + * + * Properties of H5C_DATASET_XFER templates and the type for + * the return argument(s): + * + * ** None defined yet ** + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Errors: + * ARGS BADRANGE Unknown property for dataset create + * template. + * ARGS BADRANGE Unknown property for dataset transfer + * template. + * ARGS BADRANGE Unknown property for file access + * template. + * ARGS BADRANGE Unknown property for file create + * template. + * ARGS BADRANGE Unknown template class. + * ARGS BADTYPE Not a template. + * INTERNAL UNSUPPORTED Not implemented yet. + * TEMPLATE UNINITIALIZED Chunk dimensionality is not initialized + * TEMPLATE UNINITIALIZED Chunk size is not initialized. + * + * Programmer: Robb Matzke + * Thursday, December 11, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ herr_t -H5Cgetparm (hid_t template, H5C_prop_t prop, void *buf) +H5Cget_prop (hid_t template, H5C_prop_t prop, void *buf/*out*/) { + const void *tmpl = NULL; + const H5F_create_t *file_create = NULL; + const H5D_create_t *dset_create = NULL; H5C_class_t type; - - const void *tmpl=NULL; - const H5F_create_t *file_create=NULL; - const H5D_create_t *dset_create=NULL; - - FUNC_ENTER (H5Cgetparm, FAIL); + intn i; + + FUNC_ENTER (H5Cget_prop, FAIL); H5ECLEAR; + /* check args */ - if (NULL==(tmpl = H5Aatom_object (template)) || - (type=H5C_class (template))<0) { - /* Can't unatomize template */ - HRETURN_ERROR (H5E_ATOM, H5E_BADTYPE, FAIL); - } - if (!buf) { - /* No result buffer argument supplied */ - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); + if ((type=H5Cget_class (template))<0 || + NULL==(tmpl=H5Aatom_object (template))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a template*/ } /* Handle each class of template */ switch (type) { case H5C_FILE_CREATE: file_create = (const H5F_create_t *)tmpl; + switch (prop) { - case H5F_USERBLOCK_SIZE: - *(uintn *)buf=file_create->userblock_size; + case H5F_SIZEOF_USERBLOCK: + *(size_t *)buf = file_create->userblock_size; break; - case H5F_OFFSET_SIZE: - *(uint8 *)buf=file_create->sizeof_addr; + case H5F_SIZEOF_ADDR: + *(size_t *)buf = file_create->sizeof_addr; break; - case H5F_LENGTH_SIZE: - *(uint8 *)buf=file_create->sizeof_size; + case H5F_SIZEOF_SIZE: + *(size_t *)buf = file_create->sizeof_size; break; case H5F_SYM_LEAF_K: - *(uintn *)buf=file_create->sym_leaf_k; + *(int *)buf=file_create->sym_leaf_k; break; case H5F_SYM_INTERN_K: - *(uintn *)buf = file_create->btree_k[H5B_SNODE_ID]; + *(int *)buf = file_create->btree_k[H5B_SNODE_ID]; break; case H5F_ISTORE_K: - *(uintn *)buf = file_create->btree_k[H5B_ISTORE_ID]; + *(int *)buf = file_create->btree_k[H5B_ISTORE_ID]; break; case H5F_BOOTBLOCK_VER: - *(uint8 *)buf=file_create->bootblock_ver; + *(int *)buf=file_create->bootblock_ver; break; case H5F_SMALLOBJECT_VER: - *(uint8 *)buf=file_create->smallobject_ver; + *(int *)buf=file_create->smallobject_ver; break; case H5F_FREESPACE_VER: - *(uint8 *)buf=file_create->freespace_ver; + *(int *)buf=file_create->freespace_ver; break; case H5F_OBJECTDIR_VER: - *(uint8 *)buf=file_create->objectdir_ver; + *(int *)buf=file_create->objectdir_ver; break; case H5F_SHAREDHEADER_VER: - *(uint8 *)buf=file_create->sharedheader_ver; + *(int *)buf=file_create->sharedheader_ver; break; default: @@ -410,7 +496,25 @@ H5Cgetparm (hid_t template, H5C_prop_t prop, void *buf) break; case H5D_CHUNK_NDIMS: + if (H5D_CHUNKED==dset_create->layout) { + *(int*)buf = dset_create->chunk_ndims; + } else { + /* Chunk dimensionality is not initialized */ + HRETURN_ERROR (H5E_TEMPLATE, H5E_UNINITIALIZED, FAIL); + } + break; + case H5D_CHUNK_SIZE: + if (H5D_CHUNKED==dset_create->layout) { + for (i=0; ichunk_ndims; i++) { + ((size_t*)buf)[i] = dset_create->chunk_size[i]; + } + } else { + /* Chunk size is not initialized */ + HRETURN_ERROR (H5E_TEMPLATE, H5E_UNINITIALIZED, FAIL); + } + break; + case H5D_COMPRESS: case H5D_PRE_OFFSET: case H5D_PRE_SCALE: @@ -434,80 +538,52 @@ H5Cgetparm (hid_t template, H5C_prop_t prop, void *buf) FUNC_LEAVE (SUCCEED); } -/*-------------------------------------------------------------------------- - NAME - H5Csetparm - PURPOSE - Set a parameter from a template - USAGE - herr_t H5Csetparm(tid, parm, buf) - hid_t tid; IN: Template object to store parameter in - file_create_param_t parm; IN: Parameter to store - const VOIDP buf; IN: Pointer to parameter buffer - RETURNS - SUCCEED/FAIL - - ERRORS - ARGS BADRANGE Indexed storage internal node 1/2 rank is not - valid. - ARGS BADRANGE No buffer argument specified. - ARGS BADRANGE Symbol internal node 1/2 rank is not valid. - ARGS BADRANGE Symbol leaf node 1/2 rank is not valid. - ARGS BADRANGE This is a read-only property. - ARGS BADRANGE Unknown file creation property. - ARGS BADRANGE Unknown property for dataset create template. - ARGS BADRANGE Unknown property for dataset transfer template. - ARGS BADRANGE Unknown property for file access template. - ARGS BADRANGE Unknown template class. - ARGS BADVALUE File haddr_t size is not valid. - ARGS BADVALUE File size_t size is not valid. - ARGS BADVALUE Userblock size is not valid. - ATOM BADTYPE Can't unatomize template. - - DESCRIPTION - This function stores the value of a specific parameter for a template - - MODIFICATIONS - Robb Matzke, 13 Aug 1997 - Removed H5_BTREE_SIZE and replaced it with H5_SYM_LEAF_K and - H5_SYM_INTERN_K. - - Robb Matzke, 26 Aug 1997 - Changed `hash_size' to `val' in two places. - - Robb Matzke, 15 Sep 1997 - The H5_OFFSET_SIZE and H5_LENGTH_SIZE parameters should be passed - a uint8 pointer for the BUF value. - - Robb Matzke, 15 Sep 1997 - Fixed the power-of-two test to work with any size integer. - - Robb Matzke, 17 Oct 1997 - Added H5_ISTORE_K. ---------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------- + * Function: H5Cset_prop + * + * Purpose: Sets a property, PROP, to a specified value in a TEMPLATE. + * The value data type depends on the property being set and is + * documented in H5Cget_prop(). The data type does not include + * the pointer (that is, property values are passed by value, + * not reference). + * + * Note: Not all properties that can be queried with H5Cget_prop() can + * be set to a value with H5Cset_prop(). Such properties are + * documented as read-only in H5Cget_prop(). + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, December 11, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ herr_t -H5Csetparm (hid_t template, H5C_prop_t prop, const void *buf) +H5Cset_prop (hid_t template, H5C_prop_t prop, ...) { - void *tmpl = NULL; - H5F_create_t *file_create = NULL; - H5D_create_t *dset_create = NULL; - H5C_class_t type; - H5D_layout_t layout; - uintn val; - intn i; + void *tmpl = NULL; + H5F_create_t *file_create = NULL; + H5D_create_t *dset_create = NULL; + H5C_class_t type; + H5D_layout_t layout; + size_t size, *dims = NULL; + intn i, n; + va_list ap; + herr_t ret_value = FAIL; - FUNC_ENTER (H5Csetparm, FAIL); + FUNC_ENTER (H5Cset_prop, FAIL); H5ECLEAR; - /* check args */ - if (NULL==(tmpl = H5Aatom_object (template)) || - (type = H5C_class (template))<0) { - /* Can't unatomize template */ - HRETURN_ERROR (H5E_ATOM, H5E_BADTYPE, FAIL); - } - if (!buf) { - /* No buffer argument specified */ - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); + va_start (ap, prop); + + if ((type=H5Cget_class (template))<0 || + NULL==(tmpl=H5Aatom_object (template))) { + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a template*/ } /* Handle each class of template */ @@ -516,62 +592,62 @@ H5Csetparm (hid_t template, H5C_prop_t prop, const void *buf) file_create = (H5F_create_t *)tmpl; switch (prop) { - case H5F_USERBLOCK_SIZE: - val = *(const uintn *)buf; + case H5F_SIZEOF_USERBLOCK: + size = va_arg (ap, size_t); for (i=8; i<8*sizeof(int); i++) { uintn p2 = 8==i ? 0 :1<=8*sizeof(int)) { /* Userblock size is not valid */ - HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); } - file_create->userblock_size=val; + file_create->userblock_size = size; break; - case H5F_OFFSET_SIZE: - val = *(const uint8 *)buf; - if (val!=2 && val!=4 && val!=8 && val!=16) { + case H5F_SIZEOF_ADDR: + size = va_arg (ap, size_t); + if (size!=2 && size!=4 && size!=8 && size!=16) { /* file haddr_t size is not valid */ - HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); } - file_create->sizeof_addr=val; + file_create->sizeof_addr = size; break; - case H5F_LENGTH_SIZE: - val = *(const uint8 *)buf; - if(val!=2 && val!=4 && val!=8 && val!=16) { + case H5F_SIZEOF_SIZE: + size = va_arg (ap, size_t); + if (size!=2 && size!=4 && size!=8 && size!=16) { /* file size_t size is not valid */ - HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); } - file_create->sizeof_size=val; + file_create->sizeof_size = size; break; case H5F_SYM_LEAF_K: - val = *(const uintn *)buf; - if (val<2) { + n = va_arg (ap, int); + if (n<2) { /* Symbol leaf node 1/2 rank is not valid */ - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); + HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); } - file_create->sym_leaf_k = val; + file_create->sym_leaf_k = n; break; case H5F_SYM_INTERN_K: - val = *(const uintn *)buf; - if (val<2) { + n = va_arg (ap, int); + if (n<2) { /* Symbol internal node 1/2 rank is not valid */ - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); + HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); } - file_create->btree_k[H5B_SNODE_ID] = val; + file_create->btree_k[H5B_SNODE_ID] = n; break; case H5F_ISTORE_K: - val = *(const uintn *)buf; - if (val<2) { + n = va_arg (ap, int); + if (n<2) { /* Indexed storage internal node 1/2 rank is not valid */ - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); + HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); } - file_create->btree_k[H5B_ISTORE_ID] = val; + file_create->btree_k[H5B_ISTORE_ID] = n; break; case H5F_BOOTBLOCK_VER: @@ -580,54 +656,91 @@ H5Csetparm (hid_t template, H5C_prop_t prop, const void *buf) case H5F_OBJECTDIR_VER: case H5F_SHAREDHEADER_VER: /* This is a read-only property */ - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); + HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); default: /* Unknown file creation property */ - HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL); + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL); } break; case H5C_FILE_ACCESS: /* Unknown property for file access template */ - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); + HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); case H5C_DATASET_CREATE: dset_create = (H5D_create_t *)tmpl; + switch (prop) { case H5D_LAYOUT: - layout = *(const H5D_layout_t*)buf; + layout = va_arg (ap, H5D_layout_t); if (layout<0 || layout>=H5D_NLAYOUTS) { /* Raw data layout method is not valid */ - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); + HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); } dset_create->layout = layout; break; case H5D_CHUNK_NDIMS: + n = va_arg (ap, int); + if (H5D_CHUNKED!=dset_create->layout) { + /* Not a chunked layout template */ + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); + } + if (n<=0 || n>NELMTS (dset_create->chunk_size)) { + /* Invalid number of dimensions */ + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); + } + dset_create->chunk_ndims = n; + for (i=0; ichunk_size[i] = 1; + break; + case H5D_CHUNK_SIZE: + dims = va_arg (ap, size_t*); + if (H5D_CHUNKED!=dset_create->layout) { + /* Not a chunked layout template */ + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); + } + if (!dims) { + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); /*no dims*/ + } + for (i=0; ichunk_ndims; i++) { + if (dims[i]<=0) { + /* Invalid dimension size */ + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); + } + } + for (i=0; ichunk_ndims; i++) { + dset_create->chunk_size[i] = dims[i]; + } + break; + case H5D_COMPRESS: case H5D_PRE_OFFSET: case H5D_PRE_SCALE: /* Not implemented yet */ - HRETURN_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL); + HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL); default: /* Unknown property for dataset create template */ - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); + HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); } break; case H5C_DATASET_XFER: /* Unknown property for dataset transfer template */ - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); + HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); default: /* Unknown template class */ - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); + HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL); } - - FUNC_LEAVE (SUCCEED); + + ret_value = SUCCEED; + + done: + va_end (ap); + FUNC_LEAVE (ret_value); } /*-------------------------------------------------------------------------- @@ -668,7 +781,7 @@ H5Ccopy (hid_t template) /* check args */ if (NULL==(tmpl=H5Aatom_object (template)) || - (type=H5C_class (template))<0 || + (type=H5Cget_class (template))<0 || (group=H5Aatom_group (template))<0) { /* Can't unatomize template */ HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, FAIL); diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 2253dd2..7a184f6 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -25,6 +25,5 @@ #include hid_t H5C_create (H5C_class_t type, void *tmpl); -H5C_class_t H5C_class (hid_t template); #endif diff --git a/src/H5Cpublic.h b/src/H5Cpublic.h index dcadcdd..c0bc55d 100644 --- a/src/H5Cpublic.h +++ b/src/H5Cpublic.h @@ -39,9 +39,9 @@ typedef enum H5C_class_t { typedef enum H5C_prop_t { /* File Creation Properties */ - H5F_USERBLOCK_SIZE, /* Size of the user block in the file in bytes */ - H5F_OFFSET_SIZE, /* Number of bytes for offsets */ - H5F_LENGTH_SIZE, /* Number of bytes for lengths */ + H5F_SIZEOF_USERBLOCK,/* Size of the user block in the file in bytes */ + H5F_SIZEOF_ADDR, /* Number of bytes for addresses */ + H5F_SIZEOF_SIZE, /* Number of bytes for sizes */ H5F_SYM_LEAF_K, /* 1/2 rank for symbol table leaf nodes */ H5F_SYM_INTERN_K, /* 1/2 rank for symbol table internal nodes */ H5F_ISTORE_K, /* 1/2 rank for indexed storage nodes */ @@ -75,8 +75,9 @@ extern "C" { hid_t H5Ccreate (H5C_class_t type); herr_t H5Cclose (hid_t template); hid_t H5Ccopy (hid_t template); -herr_t H5Cgetparm (hid_t template, H5C_prop_t prop, void *buf); -herr_t H5Csetparm (hid_t template, H5C_prop_t prop, const void *buf); +herr_t H5Cget_prop (hid_t template, H5C_prop_t prop, void *buf); +herr_t H5Cset_prop (hid_t template, H5C_prop_t prop, ...); +H5C_class_t H5Cget_class (hid_t template); #ifdef __cplusplus } diff --git a/src/H5D.c b/src/H5D.c index 73f4933..9aad6a4 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -36,17 +36,25 @@ static char RcsId[] = "@(#)$Revision$"; * A dataset is the following struct. */ struct H5D_t { - H5F_t *file; /* File store for this object */ - H5G_entry_t *ent; /* Cached object header stuff */ - H5T_t *type; /* Datatype of this dataset */ - H5P_t *space; /* Dataspace of this dataset */ - H5D_create_t create_parms; /* Creation parameters */ - haddr_t data_addr; /* Raw data storage address */ + H5F_t *file; /*file store for this object */ + H5G_entry_t *ent; /*cached object header stuff */ + H5T_t *type; /*datatype of this dataset */ + H5P_t *space; /*dataspace of this dataset */ + H5D_create_t create_parms; /*creation parameters */ + union { + H5O_cstore_t cstore; /*contiguous storage info */ + H5O_istore_t istore; /*chunked storage info */ + } storage; }; /* Default dataset creation template */ const H5D_create_t H5D_create_dflt = { H5D_CONTIGUOUS, /* Layout */ + 1, /* Chunk dimensions */ + {1, 1, 1, 1, 1, 1, 1, 1, /* Chunk size. These default values....*/ + 1, 1, 1, 1, 1, 1, 1, 1, /*...are quite useless. Larger chunks..*/ + 1, 1, 1, 1, 1, 1, 1, 1, /*...produces fewer, but larger I/O.....*/ + 1, 1, 1, 1, 1, 1, 1, 1}, /*...requests. */ }; /* Default dataset transfer template */ @@ -185,7 +193,7 @@ H5Dcreate (hid_t file_id, const char *name, hid_t type_id, hid_t space_id, HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a data space */ } if (create_parms_id>=0) { - if (H5C_DATASET_CREATE!=H5C_class (create_parms_id) || + if (H5C_DATASET_CREATE!=H5Cget_class (create_parms_id) || NULL==(create_parms=H5Aatom_object (create_parms_id))) { /* Not a dataset creation template */ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); @@ -385,7 +393,7 @@ H5Dread (hid_t dataset_id, hid_t type_id, hid_t space_id, } if (H5C_DEFAULT==xfer_parms_id) { xfer_parms = &H5D_xfer_dflt; - } else if (H5C_DATASET_XFER!=H5C_class (xfer_parms_id) || + } else if (H5C_DATASET_XFER!=H5Cget_class (xfer_parms_id) || NULL==(xfer_parms=H5Aatom_object (xfer_parms_id))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not xfer parms*/ } @@ -465,7 +473,7 @@ H5Dwrite (hid_t dataset_id, hid_t type_id, hid_t space_id, } if (H5C_DEFAULT==xfer_parms_id) { xfer_parms = &H5D_xfer_dflt; - } else if (H5C_DATASET_XFER!=H5C_class (xfer_parms_id) || + } else if (H5C_DATASET_XFER!=H5Cget_class (xfer_parms_id) || NULL==(xfer_parms=H5Aatom_object (xfer_parms_id))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not xfer parms*/ } @@ -553,7 +561,8 @@ H5D_create (H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space, { H5D_t *new_dset = NULL; H5D_t *ret_value = NULL; - H5O_cstore_t cstore; /*contiguous storage message */ + size_t nbytes; + intn ndims; FUNC_ENTER (H5D_create, NULL); @@ -570,7 +579,6 @@ H5D_create (H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space, new_dset->type = H5T_copy (type); new_dset->space = H5P_copy (space); new_dset->create_parms = *create_parms; - H5F_addr_undef (&(new_dset->data_addr)); /* No data yet */ /* * Open (and create) a new file object and update the object header @@ -592,21 +600,52 @@ H5D_create (H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space, HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL); } - /* Update layout message */ + /* Total raw data size */ + nbytes = H5T_get_size (type) * H5P_get_npoints (space); + + /* Initialize storage */ switch (new_dset->create_parms.layout) { case H5D_CONTIGUOUS: - cstore.size = H5T_get_size (type) * H5P_get_npoints (space); - if (H5MF_alloc (f, H5MF_RAW, cstore.size, &(cstore.addr))<0) { + new_dset->storage.cstore.size = nbytes; + if (H5MF_alloc (f, H5MF_RAW, nbytes, + &(new_dset->storage.cstore.addr))<0) { /* Can't allocate raw file storage */ HGOTO_ERROR (H5E_DATASET, H5E_NOSPACE, NULL); } - if (H5O_modify (f, NO_ADDR, new_dset->ent, H5O_CSTORE, 0, &cstore)<0) { + if (H5O_modify (f, NO_ADDR, new_dset->ent, H5O_CSTORE, 0, + &(new_dset->storage.cstore))<0) { /* Can't update dataset object header */ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL); } - new_dset->data_addr = cstore.addr; break; + case H5D_CHUNKED: + /* + * The dimensionality of the chunk should match the dimensionality of + * the data space. We will add one more dimension here though, to + * describe the individual bytes of a data point. Therefore, there + * must be room in the template for one more dimension size. + */ + ndims = new_dset->create_parms.chunk_ndims; + if (ndims != H5P_get_ndims (space)) { + /* Dimensionality of chunks doesn't match the data space */ + HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, NULL); + } + assert (ndimscreate_parms.chunk_size)); + new_dset->create_parms.chunk_size[ndims] = H5T_get_size (type); + + if (H5F_istore_create (f, &(new_dset->storage.istore), ndims+1, + new_dset->create_parms.chunk_size)<0) { + /* Can't initialize chunked storage */ + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL); + } + if (H5O_modify (f, NO_ADDR, new_dset->ent, H5O_ISTORE, 0, + &(new_dset->storage.istore))<0) { + /* Can't update dataset object header */ + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL); + } + break; + default: assert ("not implemented yet" && 0); HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL); @@ -653,7 +692,8 @@ H5D_open (H5F_t *f, const char *name) { H5D_t *dataset = NULL; /*the dataset which was found */ H5D_t *ret_value = NULL; /*return value */ - H5O_cstore_t cstore; /*contiguous storage message */ + H5O_istore_t *istore = NULL; + intn i; FUNC_ENTER (H5D_open, NULL); @@ -663,6 +703,7 @@ H5D_open (H5F_t *f, const char *name) dataset = H5MM_xcalloc (1, sizeof(H5D_t)); dataset->file = f; + dataset->create_parms = H5D_create_dflt; /* Open the dataset object */ if (NULL==(dataset->ent=H5G_open (f, name))) { @@ -676,32 +717,33 @@ H5D_open (H5F_t *f, const char *name) /* Can't load type of space info from dataset header */ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL); } - -#if 0 - if((type=HDcalloc(1,sizeof(H5T_t)))==NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL); - if (NULL==H5O_read (dset->file, NO_ADDR, dset->ent, H5O_SIM_DTYPE, 0, - type)) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL); - if((dset->tid=H5Aregister_atom(H5_DATATYPE, (const VOIDP)type))==FAIL) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL); - - /* Get the dataset's dimensionality (currently only simple dataspaces) */ - if((dim=HDcalloc(1,sizeof(H5P_t)))==NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL); - dim->type=H5P_TYPE_SIMPLE; /* for now... */ - if (NULL==(dim->s=H5O_read (dset->file, NO_ADDR, dset->ent, - H5O_SDSPACE, 0, NULL))) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL); - if((dset->sid=H5Aregister_atom(H5_DATASPACE, (const VOIDP)dim))==FAIL) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL); -#endif - /* Get the raw data storage info */ + /* + * Get the raw data storage info. It's actually stored in two locations: + * the storage message of the dataset (dataset->storage) and certain + * values are copied to the dataset create template so the user can query + * them. + */ if (H5O_read (dataset->file, NO_ADDR, dataset->ent, H5O_CSTORE, 0, - &cstore)) { + &(dataset->storage.cstore))) { + /* Contiguous storage */ dataset->create_parms.layout = H5D_CONTIGUOUS; - dataset->data_addr = cstore.addr; + + } else if (H5O_read (dataset->file, NO_ADDR, dataset->ent, H5O_ISTORE, 0, + &(dataset->storage.istore))) { + /* + * Chunked storage. The creation template's dimension is one less than + * the chunk dimension because the chunk includes a dimension for the + * individual bytes of the data type. + */ + istore = &(dataset->storage.istore); + dataset->create_parms.layout = H5D_CHUNKED; + dataset->create_parms.chunk_ndims = istore->ndims - 1; + assert (istore->ndims<=NELMTS (dataset->create_parms.chunk_size)); + for (i=0; indims-1; i++) { + dataset->create_parms.chunk_size[i] = istore->alignment[i]; + } + } else { assert ("not implemented yet" && 0); HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL); @@ -811,6 +853,9 @@ H5D_read (H5D_t *dataset, const H5T_t *type, const H5P_t *space, const H5D_xfer_t *xfer_parms, void *buf/*out*/) { size_t nbytes; + size_t offset[H5O_ISTORE_NDIMS]; + size_t size[H5O_ISTORE_NDIMS]; + intn i; FUNC_ENTER (H5D_read, FAIL); @@ -836,9 +881,33 @@ H5D_read (H5D_t *dataset, const H5T_t *type, const H5P_t *space, /* Compute the size of the request */ nbytes = H5T_get_size (dataset->type) * H5P_get_npoints (dataset->space); - /* Read the data from disk */ - if (H5F_block_read (dataset->file, &(dataset->data_addr), nbytes, buf)<0) { - HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL); /*read failed*/ + switch (dataset->create_parms.layout) { + case H5D_CONTIGUOUS: + /* + * Read a block of contiguous data. + */ + if (H5F_block_read (dataset->file, &(dataset->storage.cstore.addr), + nbytes, buf)<0) { + HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL); /*read failed*/ + } + break; + + case H5D_CHUNKED: + /* + * Read one or more chunks from indexed storage. + */ + for (i=0; istorage.istore.ndims; i++) offset[i] = 0; + H5P_get_dims (dataset->space, size); + size[dataset->storage.istore.ndims-1] = H5T_get_size (dataset->type); + if (H5F_istore_read (dataset->file, &(dataset->storage.istore), + offset, size, buf)<0) { + HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL); /*read failed*/ + } + break; + + default: + assert ("not implemented yet" && 0); + HRETURN_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL); } FUNC_LEAVE (SUCCEED); @@ -872,6 +941,9 @@ H5D_write (H5D_t *dataset, const H5T_t *type, const H5P_t *space, const H5D_xfer_t *xfer_parms, const void *buf) { size_t nbytes; + size_t offset[H5O_ISTORE_NDIMS]; + size_t size[H5O_ISTORE_NDIMS]; + intn i; FUNC_ENTER (H5D_write, FAIL); @@ -897,12 +969,36 @@ H5D_write (H5D_t *dataset, const H5T_t *type, const H5P_t *space, /* Compute the size of the request */ nbytes = H5T_get_size (dataset->type) * H5P_get_npoints (dataset->space); - - /* Write the data out to disk */ - if (H5F_block_write (dataset->file, &(dataset->data_addr), nbytes, buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL); /*write failed*/ - } + switch (dataset->create_parms.layout) { + case H5D_CONTIGUOUS: + /* + * Write a contiguous chunk of data. + */ + if (H5F_block_write (dataset->file, &(dataset->storage.cstore.addr), + nbytes, buf)<0) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL); /*write failed*/ + } + break; + + case H5D_CHUNKED: + /* + * Write one or more chunks to indexed storage. + */ + for (i=0; istorage.istore.ndims; i++) offset[i] = 0; + H5P_get_dims (dataset->space, size); + size[dataset->storage.istore.ndims-1] = H5T_get_size (dataset->type); + if (H5F_istore_write (dataset->file, &(dataset->storage.istore), + offset, size, buf)<0) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL); /*write failed*/ + } + break; + + default: + assert ("not implemented yet" && 0); + HRETURN_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL); + } + FUNC_LEAVE (SUCCEED); } diff --git a/src/H5Distore.c b/src/H5Distore.c index d506665..8684465 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -801,7 +801,8 @@ H5F_istore_read (H5F_t *f, const H5O_istore_t *istore, */ herr_t H5F_istore_write (H5F_t *f, const H5O_istore_t *istore, - const size_t offset[], const size_t size[], void *buf) + const size_t offset[], const size_t size[], + const void *buf) { FUNC_ENTER (H5F_istore_write, FAIL); @@ -846,7 +847,7 @@ H5F_istore_write (H5F_t *f, const H5O_istore_t *istore, *------------------------------------------------------------------------- */ herr_t -H5F_istore_create (H5F_t *f, struct H5O_istore_t *istore, +H5F_istore_create (H5F_t *f, struct H5O_istore_t *istore/*out*/, uintn ndims, const size_t alignment[]) { H5F_istore_ud1_t udata; diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index b079c89..9c4ffeb 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -36,6 +36,8 @@ /* Dataset creation template */ typedef struct H5D_create_t { H5D_layout_t layout; + intn chunk_ndims; + size_t chunk_size[32]; } H5D_create_t; /* Dataset transfer template */ diff --git a/src/H5E.c b/src/H5E.c index c77c61b..f14195f 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -59,7 +59,8 @@ static const hdf_maj_error_messages_t hdf_maj_error_messages[] = {H5E_DATATYPE, "Datatype"}, {H5E_DATASPACE, "Dataspace"}, {H5E_DATASET, "Dataset"}, - {H5E_STORAGE, "Data Storage"}, + {H5E_STORAGE, "Data Storage"}, + {H5E_TEMPLATE, "Template"}, }; static const hdf_min_error_messages_t hdf_min_error_messages[] = diff --git a/src/H5Epublic.h b/src/H5Epublic.h index 79337e7..8f85551 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -25,23 +25,26 @@ /* Declare an enumerated type which holds all the valid major HDF error codes */ typedef enum { - H5E_NONE_MAJOR = 0, /* special zero, no error */ - H5E_ARGS, /* Invalid arguments to routine */ - H5E_RESOURCE, /* Resource unavailable */ - H5E_INTERNAL, /* Internal error (too specific to document in detail) */ - H5E_FILE, /* File Accessability */ - H5E_IO, /* Low-level I/O */ - H5E_FUNC, /* Function Entry/Exit */ - H5E_ATOM, /* Object Atom */ - H5E_CACHE, /* Object Cache */ - H5E_BTREE, /* B-Tree Node */ - H5E_SYM, /* Symbol Table */ - H5E_HEAP, /* Heap */ - H5E_OHDR, /* Object Header */ - H5E_DATATYPE, /* Datatype */ - H5E_DATASPACE, /* Dataspace */ - H5E_DATASET, /* Dataset */ - H5E_STORAGE /* Data storage */ + H5E_NONE_MAJOR = 0, /* special zero, no error */ + H5E_ARGS, /* Invalid arguments to routine */ + H5E_RESOURCE, /* Resource unavailable */ + H5E_INTERNAL, /* Internal error (too specific to document + * in detail) + */ + H5E_FILE, /* File Accessability */ + H5E_IO, /* Low-level I/O */ + H5E_FUNC, /* Function Entry/Exit */ + H5E_ATOM, /* Object Atom */ + H5E_CACHE, /* Object Cache */ + H5E_BTREE, /* B-Tree Node */ + H5E_SYM, /* Symbol Table */ + H5E_HEAP, /* Heap */ + H5E_OHDR, /* Object Header */ + H5E_DATATYPE, /* Datatype */ + H5E_DATASPACE, /* Dataspace */ + H5E_DATASET, /* Dataset */ + H5E_STORAGE, /* Data storage */ + H5E_TEMPLATE /* Templates */ } hdf_maj_err_code_t; diff --git a/src/H5Fistore.c b/src/H5Fistore.c index d506665..8684465 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -801,7 +801,8 @@ H5F_istore_read (H5F_t *f, const H5O_istore_t *istore, */ herr_t H5F_istore_write (H5F_t *f, const H5O_istore_t *istore, - const size_t offset[], const size_t size[], void *buf) + const size_t offset[], const size_t size[], + const void *buf) { FUNC_ENTER (H5F_istore_write, FAIL); @@ -846,7 +847,7 @@ H5F_istore_write (H5F_t *f, const H5O_istore_t *istore, *------------------------------------------------------------------------- */ herr_t -H5F_istore_create (H5F_t *f, struct H5O_istore_t *istore, +H5F_istore_create (H5F_t *f, struct H5O_istore_t *istore/*out*/, uintn ndims, const size_t alignment[]) { H5F_istore_ud1_t udata; diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 31748b2..250c152 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -213,16 +213,16 @@ * File-creation template. */ typedef struct H5F_create_t { - uintn userblock_size; /* Size of the file user block in bytes */ - uintn sym_leaf_k; /* 1/2 rank for symbol table leaf nodes */ - uintn btree_k[8]; /* 1/2 rank for btree internal nodes */ - uint8 sizeof_addr; /* Number of bytes in an address */ - uint8 sizeof_size; /* Number of bytes for obj sizes */ - uint8 bootblock_ver; /* Version # of the bootblock */ - uint8 smallobject_ver; /* Version # of the small-object heap */ - uint8 freespace_ver; /* Version # of the free-space information */ - uint8 objectdir_ver; /* Version # of the object directory format */ - uint8 sharedheader_ver; /* Version # of the shared header format */ + size_t userblock_size; /* Size of the file user block in bytes */ + intn sym_leaf_k; /* 1/2 rank for symbol table leaf nodes */ + intn btree_k[8]; /* 1/2 rank for btree internal nodes */ + size_t sizeof_addr; /* Number of bytes in an address */ + size_t sizeof_size; /* Number of bytes for obj sizes */ + intn bootblock_ver; /* Version # of the bootblock */ + intn smallobject_ver; /* Version # of the small-object heap */ + intn freespace_ver; /* Version # of the free-space information */ + intn objectdir_ver; /* Version # of the object directory format */ + intn sharedheader_ver; /* Version # of the shared header format */ } H5F_create_t; /* @@ -416,7 +416,7 @@ herr_t H5F_istore_read (H5F_t *f, const struct H5O_istore_t *mesg, void *buf); herr_t H5F_istore_write (H5F_t *f, const struct H5O_istore_t *mesg, const size_t offset[], const size_t size[], - void *buf); + const void *buf); /* Functions that operate on contiguous storage wrt boot block */ herr_t H5F_block_read (H5F_t *f, const haddr_t *addr, size_t size, void *buf); diff --git a/src/H5P.c b/src/H5P.c index 716f874..243cff1 100644 --- a/src/H5P.c +++ b/src/H5P.c @@ -379,7 +379,7 @@ H5P_get_npoints (const H5P_t *ds) HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, 0); default: - /* unknown data space class */ + assert ("unknown data space class" && 0); HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, 0); } @@ -388,6 +388,190 @@ H5P_get_npoints (const H5P_t *ds) /*------------------------------------------------------------------------- + * Function: H5Pget_ndims + * + * Purpose: Determines the dimensionality of a data space. + * + * Return: Success: The number of dimensions in a data space. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, December 11, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +intn +H5Pget_ndims (hid_t space_id) +{ + H5P_t *ds = NULL; + size_t ret_value = 0; + + FUNC_ENTER(H5Pget_ndims, FAIL); + H5ECLEAR; + + /* check args */ + if (H5_DATASPACE!=H5Aatom_group (space_id) || + NULL==(ds=H5Aatom_object (space_id))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a data space*/ + } + + ret_value = H5P_get_ndims (ds); + + FUNC_LEAVE (ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5P_get_ndims + * + * Purpose: Returns the number of dimensions in a data space. + * + * Return: Success: Non-negative number of dimensions. Zero + * implies a scalar. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, December 11, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +intn +H5P_get_ndims (const H5P_t *ds) +{ + intn ret_value = FAIL; + + FUNC_ENTER (H5P_get_ndims, FAIL); + + /* check args */ + assert (ds); + + switch (ds->type) { + case H5P_SCALAR: + ret_value = 0; + break; + + case H5P_SIMPLE: + ret_value = ds->u.simple.rank; + break; + + case H5P_COMPLEX: + /* complex data spaces are not supported yet */ + HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL); + + default: + assert ("unknown data space class" && 0); + HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL); + } + + FUNC_LEAVE (ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5Pget_dims + * + * Purpose: Returns the size in each dimension of a data space DS through + * the DIMS argument. + * + * Return: Success: Number of dimensions, the same value as + * returned by H5Pget_ndims(). + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, December 11, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +intn +H5Pget_dims (hid_t space_id, size_t dims[]/*out*/) +{ + + H5P_t *ds = NULL; + size_t ret_value = 0; + + FUNC_ENTER(H5Pget_dims, FAIL); + H5ECLEAR; + + /* check args */ + if (H5_DATASPACE!=H5Aatom_group (space_id) || + NULL==(ds=H5Aatom_object (space_id))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a data space*/ + } + if (!dims) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); /*no output buffer*/ + } + + + ret_value = H5P_get_dims (ds, dims); + + FUNC_LEAVE (ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5P_get_dims + * + * Purpose: Returns the size in each dimension of a data space. This + * function may not be meaningful for all types of data spaces. + * + * Return: Success: Number of dimensions. Zero implies scalar. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, December 11, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +intn +H5P_get_dims (const H5P_t *ds, size_t dims[]) +{ + intn ret_value = FAIL; + intn i; + + FUNC_ENTER (H5P_get_dims, FAIL); + + /* check args */ + assert (ds); + assert (dims); + + switch (ds->type) { + case H5P_SCALAR: + ret_value = 0; + break; + + case H5P_SIMPLE: + ret_value = ds->u.simple.rank; + for (i=0; iu.simple.size[i]; + } + break; + + case H5P_COMPLEX: + /* complex data spaces are not supported yet */ + HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL); + + default: + assert ("unknown data space class" && 0); + HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL); + } + + FUNC_LEAVE (ret_value); +} + + +/*------------------------------------------------------------------------- * Function: H5P_modify * * Purpose: Updates a data space by writing a message to an object @@ -542,179 +726,6 @@ H5P_cmp (const H5P_t *ds1, const H5P_t *ds2) FUNC_LEAVE (0); } -/*-------------------------------------------------------------------------- - NAME - H5P_get_lrank - PURPOSE - Return the logical rank of a dataspace (internal) - USAGE - intn H5P_get_lrank(sdim) - H5P_t *sdim; IN: Pointer to dataspace object to query - RETURNS - The logical rank of a dataspace on success, UFAIL on failure - DESCRIPTION - This function determines the number of logical dimensions in a - dataspace. The logical rank is the actual number of dimensions of the - dataspace, not the dimensionality of the space its embedded in. - UFAIL is returned on an error, otherwise the rank is returned. ---------------------------------------------------------------------------*/ -intn -H5P_get_lrank (const H5P_simple_t *sdim) -{ - intn ret_value = UFAIL; - - FUNC_ENTER(H5P_get_lrank, UFAIL); - - /* Clear errors and check args and all the boring stuff. */ - H5ECLEAR; - - assert(sdim); - ret_value=sdim->rank; - -#ifdef LATER -done: -#endif /* LATER */ - if(ret_value == UFAIL) - { /* Error condition cleanup */ - - } /* end if */ - - /* Normal function cleanup */ - - FUNC_LEAVE(ret_value); -} - -/*-------------------------------------------------------------------------- - NAME - H5Pget_lrank - PURPOSE - Return the logical rank of a dataspace - USAGE - intn H5P_get_lrank(sid) - hid_t sid; IN: ID of dataspace object to query - RETURNS - The logical rank of a dataspace on success, UFAIL on failure - DESCRIPTION - This function determines the number of logical dimensions in a - dataspace. The logical rank is the actual number of dimensions of the - dataspace, not the dimensionality of the space its embedded in. - UFAIL is returned on an error, otherwise the rank is returned. ---------------------------------------------------------------------------*/ -intn -H5Pget_lrank (hid_t sid) -{ - H5P_t *space=NULL; /* dataspace to modify */ - intn ret_value = UFAIL; - - FUNC_ENTER(H5Pget_lrank, UFAIL); - - /* Clear errors and check args and all the boring stuff. */ - H5ECLEAR; - - if((space=H5Aatom_object(sid))==NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); - - ret_value=H5P_get_lrank(&(space->u.simple)); - -done: - if(ret_value == UFAIL) - { /* Error condition cleanup */ - - } /* end if */ - - /* Normal function cleanup */ - - FUNC_LEAVE(ret_value); -} - -/*-------------------------------------------------------------------------- - NAME - H5P_get_ldims - PURPOSE - Return the logical dimensions of a dataspace (internal) - USAGE - herr_t H5P_get_ldims(sdim, dims) - H5P_simple_t *sdim; IN: Pointer to dataspace object to query - intn *dims; OUT: Pointer to array to store dimensions in - RETURNS - SUCCEED/FAIL - DESCRIPTION - This function determines the sizes of the logical dimensions in a - dataspace. The logical dimensions are the actual sizes of the - dataspace, not the size of the space it is embedded in. ---------------------------------------------------------------------------*/ -herr_t -H5P_get_ldims (const H5P_simple_t *sdim, intn *dims) -{ - herr_t ret_value = FAIL; - - FUNC_ENTER(H5P_get_ldims, UFAIL); - - /* Clear errors and check args and all the boring stuff. */ - H5ECLEAR; - - assert(sdim); - assert(dims); - HDmemcpy(dims, sdim->size,sdim->rank*sizeof(intn)); - ret_value=SUCCEED; - -#ifdef LATER -done: -#endif /* LATER */ - if(ret_value == FAIL) - { /* Error condition cleanup */ - - } /* end if */ - - /* Normal function cleanup */ - - FUNC_LEAVE(ret_value); -} - -/*-------------------------------------------------------------------------- - NAME - H5P_get_ldims - PURPOSE - Return the logical dimensions of a dataspace - USAGE - herr_t H5P_get_ldims(sdim, dims) - hid_t sid; IN: ID of dataspace object to query - intn *dims; OUT: Pointer to array to store dimensions in - RETURNS - SUCCEED/FAIL - DESCRIPTION - This function determines the sizes of the logical dimensions in a - dataspace. The logical dimensions are the actual sizes of the - dataspace, not the size of the space it is embedded in. ---------------------------------------------------------------------------*/ -herr_t H5Pget_ldims(hid_t sid, intn *dims) -{ - H5P_t *space=NULL; /* dataspace to modify */ - intn ret_value = UFAIL; - - FUNC_ENTER(H5Pget_lrank, UFAIL); - - /* Clear errors and check args and all the boring stuff. */ - H5ECLEAR; - - if((space=H5Aatom_object(sid))==NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); - - if(dims==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL); - - ret_value=H5P_get_ldims(&(space->u.simple),dims); - -done: - if(ret_value == FAIL) - { /* Error condition cleanup */ - - } /* end if */ - - /* Normal function cleanup */ - - FUNC_LEAVE(ret_value); -} /*-------------------------------------------------------------------------- NAME diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 161fcf5..2f530f9 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -31,8 +31,8 @@ typedef struct H5P_simple_t { intn rank; /*number of dimensions */ intn dim_flags; /*dimension flags */ - intn *size; /*dimension sizes */ - intn *max; /*maximum dimension sizes */ + size_t *size; /*dimension sizes */ + size_t *max; /*maximum dimension sizes */ intn *perm; /*dimension permutations */ } H5P_simple_t; @@ -48,12 +48,12 @@ typedef struct { H5P_t *H5P_copy (const H5P_t *src); herr_t H5P_close (H5P_t *ds); size_t H5P_get_npoints (const H5P_t *ds); +intn H5P_get_ndims (const H5P_t *ds); +intn H5P_get_dims (const H5P_t *ds, size_t dims[]/*out*/); herr_t H5P_modify (H5F_t *f, H5G_entry_t *ent, const H5P_t *space); H5P_t *H5P_read (H5F_t *f, H5G_entry_t *ent); intn H5P_cmp (const H5P_t *ds1, const H5P_t *ds2); -intn H5P_get_lrank (const H5P_simple_t *sdim); -herr_t H5P_get_ldims (const H5P_simple_t *sdim, intn *dims); hbool_t H5P_is_simple (const H5P_t *sdim); uintn H5P_nelem (const H5P_t *space); diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 5a8a0b0..6cffdea 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -43,9 +43,9 @@ extern "C" { hid_t H5Pcreate (H5P_class_t type); herr_t H5Pclose (hid_t space_id); size_t H5Pget_npoints (hid_t space_id); +intn H5Pget_ndims (hid_t space_id); +intn H5Pget_dims (hid_t space_id, size_t dims[]); -intn H5Pget_lrank(hid_t space_id); -herr_t H5Pget_ldims(hid_t space_id, intn *dims); hbool_t H5Pis_simple(hid_t space_id); herr_t H5Pset_space(hid_t space_id, intn rank, const intn *dims); -- cgit v0.12