summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-03-04 16:20:23 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-03-04 16:20:23 (GMT)
commit7bdea74ca98dbdc90877790d4bc9c1f71f6697b7 (patch)
tree90c2b29eb5397154f1cd586b962854bb5985c31d
parent808a5e6be1b7f1025c6b1182e160cefbce0f8e68 (diff)
downloadhdf5-7bdea74ca98dbdc90877790d4bc9c1f71f6697b7.zip
hdf5-7bdea74ca98dbdc90877790d4bc9c1f71f6697b7.tar.gz
hdf5-7bdea74ca98dbdc90877790d4bc9c1f71f6697b7.tar.bz2
[svn-r303] Changes since 19980228
---------------------- ./html/Dataspaces.html ./html/Errors.html ./html/Files.html ./html/H5.api.html ./html/review1.html ./src/H5private.h ./src/H5public.h ./test/dsets.c ./test/dtypes.c Removed all the types like `int32' and `intn' into private headers since they violate the naming scheme and pollute application name space. Besides, our test files only use them in a handful of places and it's probably useless to export them to the app. The app is always written in terms of standard numeric types or its own numeric types and probably never in terms of HDF5 numeric types. If it were, then the user would have to copy from their type to hdf5 type for almost every hdf5 API function call! Same goes for return values. I also removed SUCCEED/FAIL from the API since apps should be checking against zero anyway. if (FAIL==(space=H5Screate_simple(...))) /*wrong*/ if ((space=H5Fcreate_simple(...)<0)) /*right*/ ./src/H5.c Changed arguments of H5version() from `uintn' to `unsigned'. ./src/H5Tpublic.h ./src/H5T.c Changed return type of H5Tget_nmembers() from `intn' to `int' ./src/H5A.c ./src/H5Aprivate.h ./src/H5Apublic.h Changed `H5Asearch_func_t' to `H5A_search_func_t' and moved its definition from the public to the private header file. ./html/H5.format.html Documented changes made to the external file list (H5O_EFL) message. ./src/H5D.c ./src/H5Dprivate.h ./src/H5E.c ./src/H5Epublic.h ./src/H5O.c ./src/H5Oefl.c ./src/H5Oprivate.h ./src/H5P.c ./src/H5Ppublic.h Added partial support for external raw data files. HDF5 can now describe external raw data files by listing the file names, offsets, and size for a dataset. However, we will restrict a dataset to be stored "contiguously" when the external file list is viewed as a single address space. The current implementation is unable to read/write to external files--that will come later this week as will documentation. For now, take a look at ./test/external.c, particularly the calls to H5Pset_external(). ./test/Makefile.in ./test/external.c [NEW] ./MANIFEST Added tests for external storage. Note: the read test is supposed to fail at this point since reading external datasets is not implemented yet. There is no write test. ./src/H5S.c ./src/H5Sprivate.h ./src/H5Ssimp.c Added H5S_get_npoints_max() to return the maximum possible number of data points in a data space. Added an extra argument to H5S_get_dims() which returns the maximum dims. ./src/H5F.c ./src/H5Fprivate.h ./src/H5Fpublic.h ./src/H5M.c [DEPRICATED] ./src/H5Mpublic.h [DEPRICATED] Changed `template' to `property list' in lots of places. ./src/H5Osdspace.c Removed an extra `\n' from a print statement. ./src/H5S_public.h Changed H5S_UNLIMITED to the maximum size_t value. ./test/extend.c "Extendable" is spelled "extendible". ./src/H5Farray.c ./src/H5V.c ./src/H5Vprivate.h ./test/hyperslab.c Strides are now type ssize_t instead of int. These have nothing to do with the sample granularity arguments for hyperslabs, which are also called "strides" in the code. ./test/tstab.c Changed assumptions about default address and length sizes.
-rw-r--r--MANIFEST1
-rw-r--r--src/H5.c62
-rw-r--r--src/H5A.c2
-rw-r--r--src/H5Aprivate.h5
-rw-r--r--src/H5Apublic.h5
-rw-r--r--src/H5D.c253
-rw-r--r--src/H5Dprivate.h11
-rw-r--r--src/H5E.c1
-rw-r--r--src/H5Epublic.h3
-rw-r--r--src/H5F.c14
-rw-r--r--src/H5Farray.c8
-rw-r--r--src/H5Fprivate.h8
-rw-r--r--src/H5Fpublic.h8
-rw-r--r--src/H5M.c3
-rw-r--r--src/H5Mpublic.h4
-rw-r--r--src/H5O.c4
-rw-r--r--src/H5Oefl.c322
-rw-r--r--src/H5Oprivate.h40
-rw-r--r--src/H5Osdspace.c2
-rw-r--r--src/H5P.c1013
-rw-r--r--src/H5Ppublic.h6
-rw-r--r--src/H5S.c813
-rw-r--r--src/H5Sprivate.h4
-rw-r--r--src/H5Spublic.h2
-rw-r--r--src/H5Ssimp.c4
-rw-r--r--src/H5T.c2
-rw-r--r--src/H5Tpublic.h2
-rw-r--r--src/H5V.c50
-rw-r--r--src/H5Vprivate.h16
-rw-r--r--src/H5private.h75
-rw-r--r--src/H5public.h85
-rw-r--r--test/Makefile.in10
-rw-r--r--test/dsets.c42
-rw-r--r--test/dtypes.c16
-rw-r--r--test/extend.c4
-rw-r--r--test/external.c550
-rw-r--r--test/hyperslab.c1369
-rw-r--r--test/testhdf5.c2
-rw-r--r--test/tfile.c4
39 files changed, 2969 insertions, 1856 deletions
diff --git a/MANIFEST b/MANIFEST
index c113a1c..7623f84 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -165,6 +165,7 @@
./test/dspace.c
./test/dtypes.c
./test/extend.c
+./test/external.c
./test/hyperslab.c
./test/istore.c
./test/testhdf5.c
diff --git a/src/H5.c b/src/H5.c
index 0286f47..90ea07c 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -272,45 +272,45 @@ H5dont_atexit(void)
FUNC_LEAVE(SUCCEED);
} /* end H5dont_atexit() */
-/*--------------------------------------------------------------------------
-NAME
- H5version -- Checks the version of the library
-USAGE
- herr_t H5version(majnum, minnum, relnum, patnum)
- uintn *majnum; OUT: The major revision number of the HDF5 library
- uintn *minnum; OUT: The minor revision number of the HDF5 library
- uintn *relnum; OUT: The release revision number of the HDF5 library
- uintn *patnum; OUT: The patch revision number of the HDF5 library
-
-RETURNS
- SUCCEED/FAIL
-DESCRIPTION
- Checks the version numbers of the library.
-
---------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------
+ * Function: H5version
+ *
+ * Purpose: Returns the library version numbers through arguments. MAJNUM
+ * will be the major revision number of the library, MINNUM the
+ * minor revision number, RELNUM the release revision number,
+ * and PATNUM the patch revision number.
+ *
+ * Note: When printing an HDF5 version number it should be printed as
+ * `printf ("HDF5-%d.%d.%d%c", maj, min, rel, 'a'+patch)'.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Unknown
+ *
+ * Modifications:
+ * Robb Matzke, 4 Mar 1998
+ * Now use "normal" data types for the interface. Any of the arguments
+ * may be null pointers
+ *
+ *-------------------------------------------------------------------------
+ */
herr_t
-H5version(uintn *majnum, uintn *minnum, uintn *relnum, uintn *patnum)
+H5version(unsigned *majnum, unsigned *minnum, unsigned *relnum,
+ unsigned *patnum)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER(H5version, FAIL);
- /* Check args and all the boring stuff. */
- if (majnum == NULL || minnum == NULL || relnum == NULL || patnum == NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
- "null pointer argument");
-
/* Set the version information */
- *majnum = HDF5_MAJOR_VERSION;
- *minnum = HDF5_MINOR_VERSION;
- *relnum = HDF5_RELEASE_VERSION;
- *patnum = HDF5_PATCH_VERSION;
-
- done:
- if (ret_value == FAIL) { /* Error condition cleanup */
+ if (majnum) *majnum = HDF5_MAJOR_VERSION;
+ if (minnum) *minnum = HDF5_MINOR_VERSION;
+ if (relnum) *relnum = HDF5_RELEASE_VERSION;
+ if (patnum) *patnum = HDF5_PATCH_VERSION;
- } /* end if */
- /* Normal function cleanup */
FUNC_LEAVE(ret_value);
}
diff --git a/src/H5A.c b/src/H5A.c
index 988c881..09c1fab 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -671,7 +671,7 @@ H5A_dec_ref(hid_t atm)
*******************************************************************************/
void *
H5A_search(group_t grp, /* IN: Group to search for the object in */
- H5Asearch_func_t func, /* IN: Ptr to the comparison function */
+ H5A_search_func_t func, /* IN: Ptr to the comparison function */
const void *key /* IN: pointer to key to compare against */
)
{
diff --git a/src/H5Aprivate.h b/src/H5Aprivate.h
index e4e654f..db7ca4d 100644
--- a/src/H5Aprivate.h
+++ b/src/H5Aprivate.h
@@ -89,6 +89,9 @@ typedef struct atom_group_struct_tag {
atom_info_t **atom_list; /*pointer to an array of ptrs to atoms */
} atom_group_t;
+/* Type of the function to compare objects & keys */
+typedef intn (*H5A_search_func_t) (const void * obj, const void * key);
+
/* Private Functions in H5A.c */
intn H5A_init_group (group_t grp, intn hash_size, uintn reserved,
herr_t (*free_func)(void *));
@@ -97,7 +100,7 @@ hid_t H5A_register (group_t grp, void *object);
void *H5A_object (hid_t atm);
group_t H5A_group (hid_t atm);
void *H5A_remove (hid_t atm);
-void *H5A_search (group_t grp, H5Asearch_func_t func, const void *key);
+void *H5A_search (group_t grp, H5A_search_func_t func, const void *key);
void H5A_term_interface (void);
intn H5A_dec_ref (hid_t atm);
hid_t H5A_inc_ref (hid_t atm);
diff --git a/src/H5Apublic.h b/src/H5Apublic.h
index 7bc14c9..648e852 100644
--- a/src/H5Apublic.h
+++ b/src/H5Apublic.h
@@ -44,10 +44,7 @@ typedef enum {
} group_t;
/* Type of atoms to return to users */
-typedef int32 hid_t;
-
-/* Type of the function to compare objects & keys */
-typedef intn (*H5Asearch_func_t) (const void * obj, const void * key);
+typedef int hid_t;
/* # of bits to use for Group ID in each atom (change if MAXGROUP>16) */
#define GROUP_BITS 8
diff --git a/src/H5D.c b/src/H5D.c
index c7ac56b..a3694ee 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -16,18 +16,19 @@ static char RcsId[] = "@(#)$Revision$";
/* $Id$ */
-#include <H5private.h> /* Generic Functions */
-#include <H5Aprivate.h> /* Atoms */
-#include <H5ACprivate.h> /* Cache */
-#include <H5Pprivate.h> /* Templates */
-#include <H5Dprivate.h> /* Dataset functions */
-#include <H5Eprivate.h> /* Error handling */
-#include <H5Gprivate.h> /* Group headers */
-#include <H5Mprivate.h> /* Meta data */
-#include <H5MFprivate.h> /* File space allocation header */
-#include <H5MMprivate.h> /* Memory management */
-#include <H5Mprivate.h> /* Meta-Object API */
-#include <H5Oprivate.h> /* Object headers */
+#include <H5private.h> /* Generic Functions */
+#include <H5Aprivate.h> /* Atoms */
+#include <H5ACprivate.h> /* Cache */
+#include <H5Dprivate.h> /* Dataset functions */
+#include <H5Eprivate.h> /* Error handling */
+#include <H5Gprivate.h> /* Group headers */
+#include <H5Hprivate.h> /* Name heap */
+#include <H5Mprivate.h> /* Meta data */
+#include <H5MFprivate.h> /* File space allocation header */
+#include <H5MMprivate.h> /* Memory management */
+#include <H5Mprivate.h> /* Meta-Object API */
+#include <H5Oprivate.h> /* Object headers */
+#include <H5Pprivate.h> /* Property lists */
#define PABLO_MASK H5D_mask
@@ -35,35 +36,37 @@ static char RcsId[] = "@(#)$Revision$";
* A dataset is the following struct.
*/
struct H5D_t {
- H5G_entry_t ent; /*cached object header stuff */
- H5T_t *type; /*datatype of this dataset */
- H5S_t *space; /*dataspace of this dataset */
- H5D_create_t create_parms; /*creation parameters */
- H5O_layout_t layout; /*data layout */
+ H5G_entry_t ent; /*cached object header stuff */
+ H5T_t *type; /*datatype of this dataset */
+ H5S_t *space; /*dataspace of this dataset */
+ H5D_create_t *create_parms; /*creation parameters */
+ H5O_layout_t layout; /*data layout */
};
-/* Default dataset creation template */
-const H5D_create_t H5D_create_dflt =
-{
+/* Default dataset creation property list */
+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, /*...produce fewer, but larger I/O...... */
+ {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, /*...produce fewer, but larger I/O......*/
1, 1, 1, 1, 1, 1, 1, 1}, /*...requests. */
+ {H5F_ADDR_UNDEF, /* External file list heap address */
+ 0, /*...slots allocated */
+ 0, /*...slots used */
+ NULL} /*...slot array */
};
-/* Default dataset transfer template */
-const H5D_xfer_t H5D_xfer_dflt =
-{
+/* Default dataset transfer property list */
+const H5D_xfer_t H5D_xfer_dflt = {
0, /* Place holder - remove this later */
};
/* Interface initialization? */
-static hbool_t interface_initialize_g = FALSE;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT H5D_init_interface
-static herr_t H5D_init_interface(void);
-static void H5D_term_interface(void);
+static herr_t H5D_init_interface(void);
+static void H5D_term_interface(void);
/*--------------------------------------------------------------------------
@@ -143,7 +146,7 @@ H5D_term_interface(void)
*
* Errors:
* ARGS BADTYPE Not a data space.
- * ARGS BADTYPE Not a dataset creation template.
+ * ARGS BADTYPE Not a dataset creation plist.
* ARGS BADTYPE Not a file.
* ARGS BADTYPE Not a type.
* ARGS BADVALUE No name.
@@ -190,7 +193,7 @@ H5Dcreate(hid_t file_id, const char *name, hid_t type_id, hid_t space_id,
if (H5P_DATASET_CREATE != H5Pget_class(create_parms_id) ||
NULL == (create_parms = H5A_object(create_parms_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a dataset creation template");
+ "not a dataset creation property list");
}
} else {
create_parms = &H5D_create_dflt;
@@ -198,13 +201,14 @@ H5Dcreate(hid_t file_id, const char *name, hid_t type_id, hid_t space_id,
/* build and open the new dataset */
if (NULL == (new_dset = H5D_create(f, name, type, space, create_parms))) {
- HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create dataset");
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
+ "unable to create dataset");
}
/* Register the new datatype and get an ID for it */
if ((ret_value = H5A_register(H5_DATASET, new_dset)) < 0) {
H5D_close(new_dset);
HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
- "can't register dataset");
+ "unable to register dataset");
}
FUNC_LEAVE(ret_value);
}
@@ -322,7 +326,7 @@ H5Dclose(hid_t dataset_id)
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Wednesday, January 28, 1998
+ * Wednesday, January 28, 1998
*
* Modifications:
*
@@ -364,14 +368,14 @@ H5Dget_space (hid_t dataset_id)
*
* Purpose: Returns a copy of the file data type for a dataset.
*
- * Return: Success: ID for a copy of the data type. The data
+ * Return: Success: ID for a copy of the data type. The data
* type should be released by calling
* H5Tclose().
*
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Tuesday, February 3, 1998
+ * Tuesday, February 3, 1998
*
* Modifications:
*
@@ -411,16 +415,16 @@ H5Dget_type (hid_t dataset_id)
/*-------------------------------------------------------------------------
* Function: H5Dget_create_parms
*
- * Purpose: Returns a copy of the dataset creation template.
+ * Purpose: Returns a copy of the dataset creation property list.
*
* Return: Success: ID for a copy of the dataset creation
- * template. The template should be released by
- * calling H5Pclose().
+ * property list. The template should be
+ * released by calling H5Pclose().
*
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Tuesday, February 3, 1998
+ * Tuesday, February 3, 1998
*
* Modifications:
*
@@ -441,18 +445,18 @@ H5Dget_create_parms (hid_t dataset_id)
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
}
- /* Copy the creation template */
+ /* Copy the creation property list */
if (NULL==(copied_parms=H5P_copy (H5P_DATASET_CREATE,
- &(dataset->create_parms)))) {
+ dataset->create_parms))) {
HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL,
- "unable to copy the creation template");
+ "unable to copy the creation property list");
}
/* Create an atom */
if ((ret_value=H5A_register ((group_t)(H5_TEMPLATE_0+H5P_DATASET_CREATE),
copied_parms))<0) {
HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to register creation template");
+ "unable to register creation property list");
}
FUNC_LEAVE (ret_value);
@@ -653,7 +657,7 @@ H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Friday, January 30, 1998
+ * Friday, January 30, 1998
*
* Modifications:
*
@@ -740,9 +744,9 @@ H5D_t *
H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space,
const H5D_create_t *create_parms)
{
- H5D_t *new_dset = NULL;
- H5D_t *ret_value = NULL;
- intn i;
+ H5D_t *new_dset = NULL;
+ H5D_t *ret_value = NULL;
+ intn i;
FUNC_ENTER(H5D_create, NULL);
@@ -758,43 +762,41 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space,
H5F_addr_undef(&(new_dset->ent.header));
new_dset->type = H5T_copy(type);
new_dset->space = H5S_copy(space);
- new_dset->create_parms = *create_parms;
-
- /*
- * Create (open for write access) an object header.
- */
- if (H5O_create(f, 0, &(new_dset->ent)) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
- "unable to create dataset object header");
- }
- /* Update the type and space header messages */
- if (H5O_modify(&(new_dset->ent), H5O_DTYPE, 0, 0, new_dset->type) < 0 ||
- H5S_modify(&(new_dset->ent), new_dset->space) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
- "can't update type or space header messages");
- }
+ new_dset->create_parms = H5P_copy (H5P_DATASET_CREATE, create_parms);
/* Total raw data size */
- new_dset->layout.type = new_dset->create_parms.layout;
+ new_dset->layout.type = new_dset->create_parms->layout;
new_dset->layout.ndims = H5S_get_ndims(space) + 1;
assert(new_dset->layout.ndims <= NELMTS(new_dset->layout.dim));
new_dset->layout.dim[new_dset->layout.ndims - 1] = H5T_get_size(type);
- switch (new_dset->create_parms.layout) {
+ switch (new_dset->create_parms->layout) {
case H5D_CONTIGUOUS:
- if (H5S_get_dims(space, new_dset->layout.dim) < 0) {
+ if (H5S_get_dims(space, new_dset->layout.dim, NULL) < 0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
"unable to initialize contiguous storage");
}
+ if (new_dset->create_parms->efl.nused>0) {
+ size_t max_points = H5S_get_npoints_max (space);
+ if (max_points*H5T_get_size (type) >
+ H5O_efl_total_size (&(new_dset->create_parms->efl))) {
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
+ "max size exceeds external storage size");
+ }
+ }
break;
case H5D_CHUNKED:
- if (new_dset->create_parms.chunk_ndims != H5S_get_ndims(space)) {
+ if (new_dset->create_parms->chunk_ndims != H5S_get_ndims(space)) {
HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL,
"dimensionality of chunks doesn't match the data space");
}
+ if (new_dset->create_parms->efl.nused>0) {
+ HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, NULL,
+ "external storage not supported with chunked layout");
+ }
for (i = 0; i < new_dset->layout.ndims - 1; i++) {
- new_dset->layout.dim[i] = new_dset->create_parms.chunk_size[i];
+ new_dset->layout.dim[i] = new_dset->create_parms->chunk_size[i];
}
break;
@@ -802,14 +804,52 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space,
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet");
}
- /*
- * Initialize storage
- */
- if (H5F_arr_create(f, &(new_dset->layout)) < 0 ||
- H5O_modify(&(new_dset->ent), H5O_LAYOUT, 0, 0,
- &(new_dset->layout)) < 0) {
+ /* Create (open for write access) an object header */
+ if (H5O_create(f, 0, &(new_dset->ent)) < 0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
- "unable to initialize storage");
+ "unable to create dataset object header");
+ }
+
+ /* Update the type and space header messages */
+ if (H5O_modify(&(new_dset->ent), H5O_DTYPE, 0, H5O_FLAG_CONSTANT,
+ new_dset->type) < 0 ||
+ H5S_modify(&(new_dset->ent), new_dset->space) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "can't update type or space header messages");
+ }
+
+ /* Initialize storage */
+ if (0==new_dset->create_parms->efl.nused) {
+ if (H5F_arr_create(f, &(new_dset->layout)) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "unable to initialize storage");
+ }
+ } else {
+ H5F_addr_undef (&(new_dset->layout.addr));
+ }
+ if (H5O_modify (&(new_dset->ent), H5O_LAYOUT, 0, H5O_FLAG_CONSTANT,
+ &(new_dset->layout)) < 0) {
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
+ "unable to update layout message");
+ }
+ if (new_dset->create_parms->efl.nused>0) {
+ size_t heap_size = H5H_ALIGN (1);
+ for (i=0; i<new_dset->create_parms->efl.nused; i++) {
+ size_t n = strlen (new_dset->create_parms->efl.slot[i].name)+1;
+ heap_size += H5H_ALIGN (n);
+ }
+ if (H5H_create (f, H5H_LOCAL, heap_size,
+ &(new_dset->create_parms->efl.heap_addr))<0 ||
+ H5H_insert (f, &(new_dset->create_parms->efl.heap_addr),
+ 1, "")<0) {
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
+ "unable to create external file list name heap");
+ }
+ if (H5O_modify (&(new_dset->ent), H5O_EFL, 0, H5O_FLAG_CONSTANT,
+ &(new_dset->create_parms->efl))<0) {
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
+ "unable to update external file list message");
+ }
}
/* Give the dataset a name */
@@ -822,10 +862,12 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space,
done:
if (!ret_value && new_dset) {
- if (new_dset->type)
- H5T_close(new_dset->type);
- if (new_dset->space)
- H5S_close(new_dset->space);
+ if (new_dset->type) H5T_close(new_dset->type);
+ if (new_dset->space) H5S_close(new_dset->space);
+ if (new_dset->create_parms) {
+ H5P_close (H5P_DATASET_CREATE, new_dset->create_parms);
+ new_dset->create_parms = NULL;
+ }
if (H5F_addr_defined(&(new_dset->ent.header))) {
H5O_close(&(new_dset->ent));
}
@@ -854,7 +896,7 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space,
*
*-------------------------------------------------------------------------
*/
-H5D_t *
+H5D_t *
H5D_open(H5F_t *f, const char *name)
{
H5D_t *dataset = NULL; /*the dataset which was found */
@@ -868,7 +910,7 @@ H5D_open(H5F_t *f, const char *name)
assert(name && *name);
dataset = H5MM_xcalloc(1, sizeof(H5D_t));
- dataset->create_parms = H5D_create_dflt;
+ dataset->create_parms = H5P_copy (H5P_DATASET_CREATE, &H5D_create_dflt);
H5F_addr_undef(&(dataset->ent.header));
/* Open the dataset object */
@@ -878,16 +920,18 @@ H5D_open(H5F_t *f, const char *name)
if (H5O_open(f, &(dataset->ent)) < 0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open");
}
+
/* Get the type and space */
if (NULL==(dataset->type=H5O_read(&(dataset->ent), H5O_DTYPE, 0, NULL)) ||
NULL==(dataset->space=H5S_read(f, &(dataset->ent)))) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
"unable to load type or space info from dataset header");
}
+
/*
* Get the raw data layout 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
+ * values are copied to the dataset create plist so the user can query
* them.
*/
if (NULL==H5O_read(&(dataset->ent), H5O_LAYOUT, 0, &(dataset->layout))) {
@@ -896,19 +940,19 @@ H5D_open(H5F_t *f, const char *name)
}
switch (dataset->layout.type) {
case H5D_CONTIGUOUS:
- dataset->create_parms.layout = H5D_CONTIGUOUS;
+ dataset->create_parms->layout = H5D_CONTIGUOUS;
break;
case H5D_CHUNKED:
/*
- * Chunked storage. The creation template's dimension is one less than
+ * Chunked storage. The creation plist's dimension is one less than
* the chunk dimension because the chunk includes a dimension for the
* individual bytes of the data type.
*/
- dataset->create_parms.layout = H5D_CHUNKED;
- dataset->create_parms.chunk_ndims = dataset->layout.ndims - 1;
+ dataset->create_parms->layout = H5D_CHUNKED;
+ dataset->create_parms->chunk_ndims = dataset->layout.ndims - 1;
for (i = 0; i < dataset->layout.ndims - 1; i++) {
- dataset->create_parms.chunk_size[i] = dataset->layout.dim[i];
+ dataset->create_parms->chunk_size[i] = dataset->layout.dim[i];
}
break;
@@ -917,6 +961,14 @@ H5D_open(H5F_t *f, const char *name)
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet");
}
+ /* Get the external file list message, which might not exist */
+ if (!H5F_addr_defined (&(dataset->layout.addr)) &&
+ NULL==H5O_read (&(dataset->ent), H5O_EFL, 0,
+ &(dataset->create_parms->efl))) {
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
+ "storage address is undefined an no external file list");
+ }
+
/* Success */
ret_value = dataset;
@@ -925,10 +977,15 @@ H5D_open(H5F_t *f, const char *name)
if (H5F_addr_defined(&(dataset->ent.header))) {
H5O_close(&(dataset->ent));
}
- if (dataset->type)
+ if (dataset->type) {
H5T_close(dataset->type);
- if (dataset->space)
+ }
+ if (dataset->space) {
H5S_close(dataset->space);
+ }
+ if (dataset->create_parms) {
+ H5P_close (H5P_DATASET_CREATE, dataset->create_parms);
+ }
dataset->ent.file = NULL;
H5MM_xfree(dataset);
}
@@ -972,7 +1029,8 @@ H5D_close(H5D_t *dataset)
* these fails, so we just continue.
*/
free_failed = (H5T_close(dataset->type) < 0 ||
- H5S_close(dataset->space) < 0);
+ H5S_close(dataset->space) < 0 ||
+ H5P_close (H5P_DATASET_CREATE, dataset->create_parms));
/* Close the dataset object */
H5O_close(&(dataset->ent));
@@ -1070,6 +1128,10 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
"src and dest data spaces have different sizes");
}
+ if (dataset->create_parms->efl.nused>0) {
+ HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "reading externally-stored data is not implemented yet");
+ }
/*
* Compute the size of the request and allocate scratch buffers.
@@ -1213,6 +1275,10 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
"src and dest data spaces have different sizes");
}
+ if (dataset->create_parms->efl.nused>0) {
+ HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "writing externally-stored data is not implemente yet");
+ }
/*
* Compute the size of the request and allocate scratch buffers.
@@ -1290,7 +1356,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Friday, January 30, 1998
+ * Friday, January 30, 1998
*
* Modifications:
*
@@ -1307,6 +1373,11 @@ H5D_extend (H5D_t *dataset, const size_t *size)
assert (dataset);
assert (size);
+ if (dataset->create_parms->efl.nused>0) {
+ HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "extending externally-stored data is not implemente yet");
+ }
+
/* This is only allowed for data spaces with chunked layout */
if (H5D_CHUNKED!=dataset->layout.type) {
HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL,
diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h
index d4360d4..fc6eeb4 100644
--- a/src/H5Dprivate.h
+++ b/src/H5Dprivate.h
@@ -31,14 +31,15 @@
/* Set the minimum object header size to create objects with */
#define H5D_MINHDR_SIZE 512
-/* Dataset creation template */
+/* Dataset creation property list */
typedef struct H5D_create_t {
- H5D_layout_t layout;
- intn chunk_ndims;
- size_t chunk_size[32];
+ H5D_layout_t layout; /*storage layout */
+ intn chunk_ndims; /*chunk dimensionality */
+ size_t chunk_size[32]; /*chunk size if chunked storage */
+ H5O_efl_t efl; /*external file list */
} H5D_create_t;
-/* Dataset transfer template */
+/* Dataset transfer property list */
typedef struct H5D_xfer_t {
int _placeholder; /*unused--delete this later */
} H5D_xfer_t;
diff --git a/src/H5E.c b/src/H5E.c
index 2737e34..c68f10c 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -54,6 +54,7 @@ static const H5E_major_mesg_t H5E_major_mesg_g[] = {
{H5E_DATASET, "Dataset interface"},
{H5E_STORAGE, "Data storage layer"},
{H5E_TEMPLATE, "Property list interface"},
+ {H5E_EFL, "External file list"},
};
static const H5E_minor_mesg_t H5E_minor_mesg_g[] = {
diff --git a/src/H5Epublic.h b/src/H5Epublic.h
index 2ceb9a3..78af952 100644
--- a/src/H5Epublic.h
+++ b/src/H5Epublic.h
@@ -45,7 +45,8 @@ typedef enum H5E_major_t {
H5E_DATASPACE, /*Dataspace */
H5E_DATASET, /*Dataset */
H5E_STORAGE, /*data storage */
- H5E_TEMPLATE /*Templates */
+ H5E_TEMPLATE, /*Property lists */
+ H5E_EFL /*External file list */
} H5E_major_t;
/* Declare an enumerated type which holds all the valid minor HDF error codes */
diff --git a/src/H5F.c b/src/H5F.c
index da58e8c..ab536b0 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -40,11 +40,11 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5private.h> /*library functions */
#include <H5Aprivate.h> /*atoms */
#include <H5ACprivate.h> /*cache */
-#include <H5Pprivate.h> /*templates */
-#include <H5Eprivate.h> /*error handling */
+#include <H5Eprivate.h> /*error handling */
#include <H5Gprivate.h> /*symbol tables */
#include <H5Mprivate.h> /*meta data */
-#include <H5MMprivate.h> /*core memory management */
+#include <H5MMprivate.h> /*core memory management */
+#include <H5Pprivate.h> /*property lists */
#include <ctype.h>
#include <sys/types.h>
@@ -62,7 +62,7 @@ static char RcsId[] = "@(#)$Revision$";
/*-------------------- Locally scoped variables -----------------------------*/
/*
- * Define the default file creation template.
+ * Define the default file creation property list.
*/
const H5F_create_t H5F_create_dflt = {
0, /* Default user-block size */
@@ -87,8 +87,8 @@ const H5F_create_t H5F_create_dflt = {
};
/*
- * Define the default file access template. The template is initialized by
- * H5F_init_interface().
+ * Define the default file access property list. The template is initialized
+ * by H5F_init_interface().
*/
H5F_access_t H5F_access_dflt;
@@ -141,7 +141,7 @@ H5F_init_interface(void)
"unable to initialize interface");
}
- /* Initialize the default file access template */
+ /* Initialize the default file access property list */
H5F_access_dflt.driver = H5F_LOW_DFLT;
#if (H5F_LOW_DFLT == H5F_LOW_SEC2)
/* Nothing to initialize */
diff --git a/src/H5Farray.c b/src/H5Farray.c
index cfe79d9..7deeead 100644
--- a/src/H5Farray.c
+++ b/src/H5Farray.c
@@ -116,8 +116,8 @@ H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
void *_buf/*out*/)
{
uint8 *buf = (uint8 *)_buf; /*cast for arithmetic */
- intn file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */
- intn mem_stride[H5O_LAYOUT_NDIMS]; /*strides through memory*/
+ ssize_t file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */
+ ssize_t mem_stride[H5O_LAYOUT_NDIMS]; /*strides through memory*/
size_t hslab_size[H5O_LAYOUT_NDIMS]; /*hyperslab size */
size_t idx[H5O_LAYOUT_NDIMS]; /*multi-dim counter */
size_t mem_start, file_start; /*byte offsets to start */
@@ -250,8 +250,8 @@ H5F_arr_write (H5F_t *f, const struct H5O_layout_t *layout,
const void *_buf)
{
const uint8 *buf = (const uint8 *)_buf; /*cast for arithmetic */
- intn file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */
- intn mem_stride[H5O_LAYOUT_NDIMS]; /*strides through memory*/
+ ssize_t file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */
+ ssize_t mem_stride[H5O_LAYOUT_NDIMS]; /*strides through memory*/
size_t hslab_size[H5O_LAYOUT_NDIMS]; /*hyperslab size */
size_t idx[H5O_LAYOUT_NDIMS]; /*multi-dim counter */
size_t mem_start, file_start; /*byte offsets to start */
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 7a9e593..4700bae 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -209,7 +209,7 @@
#define NBYTEDECODE(s, d, n) { HDmemcpy(d,s,n); p+=n }
/*
- * File-creation template.
+ * File-creation property list.
*/
typedef struct H5F_create_t {
size_t userblock_size; /* Size of the file user block in bytes */
@@ -225,7 +225,7 @@ typedef struct H5F_create_t {
} H5F_create_t;
/*
- * File-access template.
+ * File-access property list.
*/
typedef struct H5F_access_t {
H5F_driver_t driver; /* Low level file driver */
@@ -391,8 +391,8 @@ typedef struct H5F_file_t {
haddr_t freespace_addr; /* Relative address of free-space info */
haddr_t hdf5_eof; /* Relative addr of end of all hdf5 data*/
struct H5AC_t *cache; /* The object cache */
- H5F_create_t create_parms; /* File-creation template */
- H5F_access_t access_parms; /* File-access template */
+ H5F_create_t create_parms; /* File-creation property list */
+ H5F_access_t access_parms; /* File-access property list */
struct H5G_entry_t *root_ent; /* Root symbol table entry */
} H5F_file_t;
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index 27745cd..d4a869b 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -58,6 +58,8 @@ typedef enum H5F_driver_t {
H5F_LOW_FAMILY = 5 /*split addr space over many files */
} H5F_driver_t;
+/* Unlimited file size for H5Pset_external() */
+#define H5F_UNLIMITED ((size_t)(-1L))
/* Parallel styles passed to H5Pset_mpi() */
#ifdef HAVE_PARALLEL
@@ -71,9 +73,9 @@ extern "C" {
/* Functions in H5F.c */
hbool_t H5Fis_hdf5 (const char *filename);
-hid_t H5Fcreate (const char *filename, uintn flags, hid_t create_template,
- hid_t access_template);
-hid_t H5Fopen (const char *filename, uintn flags, hid_t access_template);
+hid_t H5Fcreate (const char *filename, unsigned flags, hid_t create_plist,
+ hid_t access_plist);
+hid_t H5Fopen (const char *filename, unsigned flags, hid_t access_plist);
herr_t H5Fclose (hid_t fid);
hid_t H5Fget_create_template (hid_t fid);
hid_t H5Fget_access_template (hid_t file_id);
diff --git a/src/H5M.c b/src/H5M.c
index 5078950..5a08307 100644
--- a/src/H5M.c
+++ b/src/H5M.c
@@ -45,13 +45,12 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5private.h> /* Generic functions */
#include <H5Aprivate.h> /* Atom interface */
-#include <H5Pprivate.h> /* Template interface */
#include <H5Dprivate.h> /* Dataset interface */
#include <H5Eprivate.h> /*error handling */
#include <H5Sprivate.h> /* Dataspace functions */
#include <H5Tprivate.h> /* Datatype interface */
#include <H5Mprivate.h> /* Meta-object interface */
-#include <H5Pprivate.h> /* Template interface */
+#include <H5Pprivate.h> /* Property list interface */
#define PABLO_MASK H5M_mask
diff --git a/src/H5Mpublic.h b/src/H5Mpublic.h
index 1f5e582..d17dedd 100644
--- a/src/H5Mpublic.h
+++ b/src/H5Mpublic.h
@@ -28,11 +28,11 @@ extern "C" {
hid_t H5Maccess (hid_t oid);
hid_t H5Mcopy (hid_t oid);
hid_t H5Mfind_name (hid_t oid, group_t type, const char *name);
-uint32 H5Mname_len (hid_t oid);
+unsigned H5Mname_len (hid_t oid);
herr_t H5Mget_name (hid_t oid, char *name);
herr_t H5Mset_name (hid_t oid, const char *name);
hid_t H5Msearch (hid_t oid, group_t type, const char *name);
-hid_t H5Mindex (hid_t oid, group_t type, uint32 idx);
+hid_t H5Mindex (hid_t oid, group_t type, unsigned idx);
hid_t H5Mflush (hid_t oid);
herr_t H5Mdelete (hid_t oid);
hid_t H5Mget_file (hid_t oid);
diff --git a/src/H5O.c b/src/H5O.c
index 06f61da..2c12ea2 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -57,9 +57,9 @@ static const H5O_class_t *const message_type_g[] = {
NULL, /*0x0004 Not assigned */
NULL, /*0x0005 Not assigned */
NULL, /*0x0006 Data storage -- compact object */
- NULL, /*0x0007 Data storage -- external object */
+ H5O_EFL, /*0x0007 Data storage -- external data files */
H5O_LAYOUT, /*0x0008 Data Layout */
- H5O_EFL, /*0x0009 External File List */
+ NULL, /*0x0009 Not assigned */
NULL, /*0x000A Not assigned */
NULL, /*0x000B Data storage -- compressed object */
NULL, /*0x000C Attribute list */
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index 49c6c44..eb82c30 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -1,16 +1,17 @@
/*
* Copyright (C) 1997 NCSA
- * All rights reserved.
+ * All rights reserved.
*
* Programmer: Robb Matzke <matzke@llnl.gov>
- * Tuesday, November 25, 1997
+ * Tuesday, November 25, 1997
*/
#include <H5private.h>
#include <H5Eprivate.h>
+#include <H5Hprivate.h>
#include <H5MMprivate.h>
#include <H5Oprivate.h>
-#define PABLO_MASK H5O_efl_mask
+#define PABLO_MASK H5O_efl_mask
/* PRIVATE PROTOTYPES */
static void *H5O_efl_decode(H5F_t *f, size_t raw_size, const uint8 *p);
@@ -23,34 +24,35 @@ static herr_t H5O_efl_debug(H5F_t *f, const void *_mesg, FILE * stream,
intn indent, intn fwidth);
/* This message derives from H5O */
-const H5O_class_t H5O_EFL[1] = {{
- H5O_EFL_ID, /*message id number */
+const H5O_class_t H5O_EFL[1] = {{
+ H5O_EFL_ID, /*message id number */
"external file list", /*message name for debugging */
- sizeof(H5O_efl_t), /*native message size */
- H5O_efl_decode, /*decode message */
- H5O_efl_encode, /*encode message */
- H5O_efl_copy, /*copy native value */
- H5O_efl_size, /*size of message on disk */
- H5O_efl_reset, /*reset method */
- H5O_efl_debug, /*debug the message */
+ sizeof(H5O_efl_t), /*native message size */
+ H5O_efl_decode, /*decode message */
+ H5O_efl_encode, /*encode message */
+ H5O_efl_copy, /*copy native value */
+ H5O_efl_size, /*size of message on disk */
+ H5O_efl_reset, /*reset method */
+ H5O_efl_debug, /*debug the message */
}};
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
+#define INTERFACE_INIT NULL
+
/*-------------------------------------------------------------------------
- * Function: H5O_efl_decode
+ * Function: H5O_efl_decode
*
- * Purpose: Decode an external file list message and return a pointer to
- * the message (and some other data).
+ * Purpose: Decode an external file list message and return a pointer to
+ * the message (and some other data).
*
- * Return: Success: Ptr to a new message struct.
+ * Return: Success: Ptr to a new message struct.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * Tuesday, November 25, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, November 25, 1997
*
* Modifications:
*
@@ -59,42 +61,61 @@ static hbool_t interface_initialize_g = FALSE;
static void *
H5O_efl_decode(H5F_t *f, size_t raw_size, const uint8 *p)
{
- H5O_efl_t *mesg = NULL;
- int i;
+ H5O_efl_t *mesg = NULL;
+ int i;
+ const char *s = NULL;
FUNC_ENTER(H5O_efl_decode, NULL);
- /* check args */
+ /* Check args */
assert(f);
assert(p);
- /* decode */
+ /* Decode the header */
mesg = H5MM_xcalloc(1, sizeof(H5O_efl_t));
H5F_addr_decode(f, &p, &(mesg->heap_addr));
- UINT32DECODE(p, mesg->nalloc);
- assert(mesg->nalloc > 0);
- UINT32DECODE(p, mesg->nused);
+#ifndef NDEBUG
+ assert (H5F_addr_defined (&(mesg->heap_addr)));
+ s = H5H_peek (f, &(mesg->heap_addr), 0);
+ assert (s && !*s);
+#endif
+ UINT16DECODE(p, mesg->nalloc);
+ assert(mesg->nalloc>0);
+ UINT16DECODE(p, mesg->nused);
assert(mesg->nused <= mesg->nalloc);
+ p += 4; /*reserved*/
- mesg->offset = H5MM_xmalloc(mesg->nalloc * sizeof(size_t));
- for (i = 0; i < mesg->nused; i++) {
- UINT32DECODE(p, mesg->offset[i]);
+ /* Decode the file list */
+ mesg->slot = H5MM_xcalloc(mesg->nalloc, sizeof(H5O_efl_entry_t));
+ for (i=0; i<mesg->nused; i++) {
+ /* Name */
+ H5F_decode_length (f, p, mesg->slot[i].name_offset);
+ s = H5H_peek (f, &(mesg->heap_addr), mesg->slot[i].name_offset);
+ assert (s && *s);
+ mesg->slot[i].name = H5MM_xstrdup (s);
+
+ /* File offset */
+ H5F_decode_length (f, p, mesg->slot[i].offset);
+
+ /* Size */
+ H5F_decode_length (f, p, mesg->slot[i].size);
+ assert (mesg->slot[i].size>0);
}
FUNC_LEAVE(mesg);
}
/*-------------------------------------------------------------------------
- * Function: H5O_efl_encode
+ * Function: H5O_efl_encode
*
- * Purpose: Encodes a message
+ * Purpose: Encodes a message.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Tuesday, November 25, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, November 25, 1997
*
* Modifications:
*
@@ -103,8 +124,10 @@ H5O_efl_decode(H5F_t *f, size_t raw_size, const uint8 *p)
static herr_t
H5O_efl_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
{
- const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg;
- int i;
+ const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg;
+ int i;
+ size_t offset;
+
FUNC_ENTER(H5O_efl_encode, FAIL);
@@ -114,76 +137,106 @@ H5O_efl_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
assert(raw_size == H5O_ALIGN (H5O_efl_size(f, _mesg)));
assert(p);
- /* encode */
+ /* Encode header */
+ assert (H5F_addr_defined (&(mesg->heap_addr)));
H5F_addr_encode(f, &p, &(mesg->heap_addr));
- UINT32ENCODE(p, mesg->nalloc);
- UINT32ENCODE(p, mesg->nused);
- for (i = 0; i < mesg->nused; i++) {
- UINT32ENCODE(p, mesg->offset[i]);
+ assert (mesg->nalloc>0);
+ UINT16ENCODE(p, mesg->nused); /*yes, twice*/
+ assert (mesg->nused>0 && mesg->nused<=mesg->nalloc);
+ UINT16ENCODE(p, mesg->nused);
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 0;
+
+ /* Encode file list */
+ for (i=0; i<mesg->nused; i++) {
+ /*
+ * If the name has not been added to the heap yet then do so now.
+ */
+ if (0==mesg->slot[i].name_offset) {
+ offset = H5H_insert (f, &(mesg->heap_addr),
+ strlen (mesg->slot[i].name)+1,
+ mesg->slot[i].name);
+ if ((size_t)(-1)==offset) {
+ HRETURN_ERROR (H5E_EFL, H5E_CANTINIT, FAIL,
+ "unable to insert URL into name heap");
+ }
+ mesg->slot[i].name_offset = offset;
+ }
+
+ /* Encode the file info */
+ H5F_encode_length (f, p, mesg->slot[i].name_offset);
+ H5F_encode_length (f, p, mesg->slot[i].offset);
+ H5F_encode_length (f, p, mesg->slot[i].size);
}
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
- * Function: H5O_efl_copy
+ * Function: H5O_efl_copy
*
- * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
- * necessary.
+ * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
+ * necessary.
*
- * Return: Success: Ptr to _DEST
+ * Return: Success: Ptr to _DEST
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * Tuesday, November 25, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, November 25, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static void *
+static void *
H5O_efl_copy(const void *_mesg, void *_dest)
{
- const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg;
- H5O_efl_t *dest = (H5O_efl_t *) _dest;
- int i;
+ const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg;
+ H5O_efl_t *dest = (H5O_efl_t *) _dest;
+ int i;
FUNC_ENTER(H5O_efl_copy, NULL);
/* check args */
assert(mesg);
if (!dest) {
- dest = H5MM_xcalloc(1, sizeof(H5O_efl_t));
- dest->offset = H5MM_xmalloc(mesg->nalloc * sizeof(size_t));
- } else if (dest->nalloc < mesg->nalloc) {
- H5MM_xfree(dest->offset);
- dest->offset = H5MM_xmalloc(mesg->nalloc * sizeof(size_t));
+ dest = H5MM_xcalloc(1, sizeof(H5O_efl_t));
+ dest->slot = H5MM_xmalloc(mesg->nalloc * sizeof(H5O_efl_entry_t));
+ } else if (NULL==dest->slot || dest->nalloc<mesg->nalloc) {
+ H5MM_xfree(dest->slot);
+ dest->slot = H5MM_xmalloc(mesg->nalloc * sizeof(H5O_efl_entry_t));
}
dest->heap_addr = mesg->heap_addr;
dest->nalloc = mesg->nalloc;
dest->nused = mesg->nused;
for (i = 0; i < mesg->nused; i++) {
- dest->offset[i] = mesg->offset[i];
+ dest->slot[i] = mesg->slot[i];
+ dest->slot[i].name = H5MM_xstrdup (mesg->slot[i].name);
}
- FUNC_LEAVE((void *) dest);
+ FUNC_LEAVE((void *)dest);
}
+
/*-------------------------------------------------------------------------
- * Function: H5O_efl_size
+ * Function: H5O_efl_size
*
- * Purpose: Returns the size of the raw message in bytes not counting the
- * message type or size fields, but only the data fields. This
- * function doesn't take into account message alignment.
+ * Purpose: Returns the size of the raw message in bytes not counting the
+ * message type or size fields, but only the data fields. This
+ * function doesn't take into account message alignment. This
+ * function doesn't count unused slots.
*
- * Return: Success: Message data size in bytes.
+ * Return: Success: Message data size in bytes.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Tuesday, November 25, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, November 25, 1997
*
* Modifications:
*
@@ -192,8 +245,8 @@ H5O_efl_copy(const void *_mesg, void *_dest)
static size_t
H5O_efl_size(H5F_t *f, const void *_mesg)
{
- const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg;
- size_t ret_value = FAIL;
+ const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg;
+ size_t ret_value = FAIL;
FUNC_ENTER(H5O_efl_size, FAIL);
@@ -201,26 +254,30 @@ H5O_efl_size(H5F_t *f, const void *_mesg)
assert(f);
assert(mesg);
- ret_value = H5F_SIZEOF_ADDR(f) + /*heap address */
- 4 + /*num slots allocated */
- 4 + /*num slots used */
- mesg->nalloc * 4; /*name offsets in heap */
+ ret_value = H5F_SIZEOF_ADDR(f) + /*heap address */
+ 2 + /*slots allocated*/
+ 2 + /*num slots used*/
+ 4 + /*reserved */
+ mesg->nused * (H5F_SIZEOF_SIZE(f) + /*name offset */
+ H5F_SIZEOF_SIZE(f) + /*file offset */
+ H5F_SIZEOF_SIZE(f)); /*file size */
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
- * Function: H5O_efl_reset
+ * Function: H5O_efl_reset
*
- * Purpose: Frees internal pointers and resets the message to an
- * initialial state.
+ * Purpose: Frees internal pointers and resets the message to an
+ * initialial state.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Tuesday, November 25, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, November 25, 1997
*
* Modifications:
*
@@ -229,7 +286,9 @@ H5O_efl_size(H5F_t *f, const void *_mesg)
static herr_t
H5O_efl_reset(void *_mesg)
{
- H5O_efl_t *mesg = (H5O_efl_t *) _mesg;
+ H5O_efl_t *mesg = (H5O_efl_t *) _mesg;
+ int i;
+
FUNC_ENTER(H5O_efl_reset, FAIL);
@@ -237,23 +296,70 @@ H5O_efl_reset(void *_mesg)
assert(mesg);
/* reset */
+ for (i=0; i<mesg->nused; i++) {
+ mesg->slot[i].name = H5MM_xfree (mesg->slot[i].name);
+ }
+ H5F_addr_undef (&(mesg->heap_addr));
mesg->nused = mesg->nalloc = 0;
- mesg->offset = H5MM_xfree(mesg->offset);
+ mesg->slot = H5MM_xfree(mesg->slot);
FUNC_LEAVE(SUCCEED);
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_efl_total_size
+ *
+ * Purpose: Return the total size of the external file list by summing
+ * the sizes of all of the files.
+ *
+ * Return: Success: Total reserved size for external data.
+ *
+ * Failure: 0
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, March 3, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+size_t
+H5O_efl_total_size (H5O_efl_t *efl)
+{
+ int i;
+ size_t ret_value = 0, tmp;
+
+ FUNC_ENTER (H5O_efl_total_size, 0);
+
+ if (efl->nused>0 &&
+ H5O_EFL_UNLIMITED==efl->slot[efl->nused-1].size) {
+ ret_value = H5O_EFL_UNLIMITED;
+ } else {
+ for (i=0; i<efl->nused; i++, ret_value=tmp) {
+ tmp = ret_value + efl->slot[i].size;
+ if (tmp<=ret_value) {
+ HRETURN_ERROR (H5E_EFL, H5E_OVERFLOW, 0,
+ "total external storage size overflowed");
+ }
+ }
+ }
+
+ FUNC_LEAVE (ret_value);
+}
+
/*-------------------------------------------------------------------------
- * Function: H5O_efl_debug
+ * Function: H5O_efl_debug
*
- * Purpose: Prints debugging info for a message.
+ * Purpose: Prints debugging info for a message.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Tuesday, November 25, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, November 25, 1997
*
* Modifications:
*
@@ -261,11 +367,11 @@ H5O_efl_reset(void *_mesg)
*/
static herr_t
H5O_efl_debug(H5F_t *f, const void *_mesg, FILE * stream, intn indent,
- intn fwidth)
+ intn fwidth)
{
- const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg;
- char buf[64];
- intn i;
+ const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg;
+ char buf[64];
+ intn i;
FUNC_ENTER(H5O_efl_debug, FAIL);
@@ -277,19 +383,33 @@ H5O_efl_debug(H5F_t *f, const void *_mesg, FILE * stream, intn indent,
assert(fwidth >= 0);
fprintf(stream, "%*s%-*s ", indent, "", fwidth,
- "Heap address:");
+ "Heap address:");
H5F_addr_print(stream, &(mesg->heap_addr));
fprintf(stream, "\n");
fprintf(stream, "%*s%-*s %u/%u\n", indent, "", fwidth,
- "Slots used/allocated:",
- mesg->nused, mesg->nalloc);
+ "Slots used/allocated:",
+ mesg->nused, mesg->nalloc);
for (i = 0; i < mesg->nused; i++) {
- sprintf(buf, "Name %d:", i + 1);
- fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
- buf,
- (unsigned long) (mesg->offset[i]));
+ sprintf (buf, "File %d", i);
+ fprintf (stream, "%*s%s:\n", indent, "", buf);
+
+ fprintf(stream, "%*s%-*s \"%s\"\n", indent+3, "", MAX (fwidth-3, 0),
+ "Name:",
+ mesg->slot[i].name);
+
+ fprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0),
+ "Name offset:",
+ (unsigned long)(mesg->slot[i].name_offset));
+
+ fprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0),
+ "Offset of data in file:",
+ (unsigned long)(mesg->slot[i].offset));
+
+ fprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0),
+ "Bytes reserved for data:",
+ (unsigned long)(mesg->slot[i].size));
}
FUNC_LEAVE(SUCCEED);
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 0d3b2f7..f7dafb8 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -127,6 +127,28 @@ extern const H5O_class_t H5O_DTYPE[1];
/* operates on an H5T_t struct */
/*
+ * External File List Message
+ */
+#define H5O_EFL_ID 0x0007 /*external file list id */
+#define H5O_EFL_ALLOC 16 /*number of slots to alloc at once */
+#define H5O_EFL_UNLIMITED H5F_UNLIMITED /*max possible file size */
+extern const H5O_class_t H5O_EFL[1]; /*external file list class */
+
+typedef struct H5O_efl_entry_t {
+ size_t name_offset; /*offset of name within heap */
+ char *name; /*malloc'd name */
+ size_t offset; /*offset of data within file */
+ size_t size; /*size allocated within file */
+} H5O_efl_entry_t;
+
+typedef struct H5O_efl_t {
+ haddr_t heap_addr; /*address of name heap */
+ uintn nalloc; /*number of slots allocated */
+ uintn nused; /*number of slots used */
+ H5O_efl_entry_t *slot; /*array of external file entries */
+} H5O_efl_t;
+
+/*
* Data Layout Message
*/
#define H5O_LAYOUT_ID 0x0008
@@ -141,19 +163,6 @@ typedef struct H5O_layout_t {
} H5O_layout_t;
/*
- * External File List Message
- */
-#define H5O_EFL_ID 0x0009
-extern const H5O_class_t H5O_EFL[1];
-
-typedef struct H5O_efl_t {
- haddr_t heap_addr; /*address of name heap */
- uintn nalloc; /*number of slots allocated */
- uintn nused; /*number of slots used */
- size_t *offset; /*array of name offsets in heap */
-} H5O_efl_t;
-
-/*
* Object name message.
*/
#define H5O_NAME_ID 0x000d
@@ -191,6 +200,7 @@ typedef struct H5O_stab_t {
haddr_t heap_addr; /*address of name heap */
} H5O_stab_t;
+/* General message operators */
herr_t H5O_create (H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/);
herr_t H5O_open (H5F_t *f, H5G_entry_t *ent);
herr_t H5O_close (H5G_entry_t *ent);
@@ -203,4 +213,8 @@ herr_t H5O_remove (H5G_entry_t *ent, const H5O_class_t *type, intn sequence);
herr_t H5O_reset (const H5O_class_t *type, void *native);
herr_t H5O_debug (H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
intn fwidth);
+
+/* EFL operators */
+size_t H5O_efl_total_size (H5O_efl_t *efl);
+
#endif
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 7957122..f4a690e 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -296,7 +296,7 @@ H5O_sdspace_debug(H5F_t *f, const void *mesg, FILE * stream,
if (H5S_UNLIMITED==sdim->max[u]) {
fprintf (stream, "%sINF", u?", ":"");
} else {
- fprintf (stream, "%s%lu\n", u?", ":"",
+ fprintf (stream, "%s%lu", u?", ":"",
(unsigned long) (sdim->max[u]));
}
}
diff --git a/src/H5P.c b/src/H5P.c
index 89cadcf..2bf839b4 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -1,17 +1,17 @@
/****************************************************************************
-* NCSA HDF *
-* Software Development Group *
-* National Center for Supercomputing Applications *
-* University of Illinois at Urbana-Champaign *
-* 605 E. Springfield, Champaign IL 61820 *
-* *
-* For conditions of distribution and use, see the accompanying *
-* hdf/COPYING file. *
-* *
+* NCSA HDF *
+* Software Development Group *
+* National Center for Supercomputing Applications *
+* University of Illinois at Urbana-Champaign *
+* 605 E. Springfield, Champaign IL 61820 *
+* *
+* For conditions of distribution and use, see the accompanying *
+* hdf/COPYING file. *
+* *
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
@@ -19,23 +19,23 @@ static char RcsId[] = "@(#)$Revision$";
#include <stdarg.h>
/* Private header files */
-#include <H5private.h> /* Generic Functions */
-#include <H5Aprivate.h> /* Atoms */
-#include <H5Bprivate.h> /* B-tree subclass names */
-#include <H5Pprivate.h> /* Template information */
-#include <H5Dprivate.h> /* Datasets */
-#include <H5Eprivate.h> /* Error handling */
-#include <H5MMprivate.h> /* Memory management */
+#include <H5private.h> /* Generic Functions */
+#include <H5Aprivate.h> /* Atoms */
+#include <H5Bprivate.h> /* B-tree subclass names */
+#include <H5Dprivate.h> /* Datasets */
+#include <H5Eprivate.h> /* Error handling */
+#include <H5MMprivate.h> /* Memory management */
+#include <H5Pprivate.h> /* Property lists */
-#define PABLO_MASK H5P_mask
+#define PABLO_MASK H5P_mask
/* Is the interface initialized? */
-static hbool_t interface_initialize_g = FALSE;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT H5P_init_interface
-static herr_t H5P_init_interface(void);
+static herr_t H5P_init_interface(void);
/* PRIVATE PROTOTYPES */
-static void H5P_term_interface(void);
+static void H5P_term_interface(void);
/*--------------------------------------------------------------------------
NAME
@@ -52,9 +52,9 @@ DESCRIPTION
static herr_t
H5P_init_interface(void)
{
- herr_t ret_value = SUCCEED;
- intn i;
- herr_t status;
+ herr_t ret_value = SUCCEED;
+ intn i;
+ herr_t status;
FUNC_ENTER(H5P_init_interface, FAIL);
@@ -76,21 +76,21 @@ H5P_init_interface(void)
* atom groups aren't.
*/
for (i = 0; i < H5P_NCLASSES; i++) {
- status = H5A_init_group((group_t)(H5_TEMPLATE_0 +i),
+ status = H5A_init_group((group_t)(H5_TEMPLATE_0 +i),
H5A_TEMPID_HASHSIZE, 0, NULL);
- if (status < 0) ret_value = FAIL;
+ if (status < 0) ret_value = FAIL;
}
if (ret_value < 0) {
- HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL,
- "unable to initialize atom group");
+ HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL,
+ "unable to initialize atom group");
}
/*
* Register cleanup function.
*/
if (H5_add_exit(H5P_term_interface) < 0) {
- HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
- "unable to install atexit function");
+ HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
+ "unable to install atexit function");
}
FUNC_LEAVE(ret_value);
@@ -116,10 +116,10 @@ H5P_init_interface(void)
static void
H5P_term_interface(void)
{
- intn i;
+ intn i;
for (i = 0; i < H5P_NCLASSES; i++) {
- H5A_destroy_group((group_t)(H5_TEMPLATE_0 + i));
+ H5A_destroy_group((group_t)(H5_TEMPLATE_0 + i));
}
}
@@ -130,13 +130,13 @@ H5P_term_interface(void)
Returns a copy of the default template for some class of templates.
USAGE
herr_t H5Pcreate (type)
- H5P_class_t type; IN: Template class whose default is desired.
+ H5P_class_t type; IN: Template class whose default is desired.
RETURNS
Template ID or FAIL
ERRORS
- ARGS BADVALUE Unknown template class.
- ATOM CANTINIT Can't register template.
+ ARGS BADVALUE Unknown template class.
+ ATOM CANTINIT Can't register template.
INTERNAL UNSUPPORTED Not implemented yet.
DESCRIPTION
@@ -145,8 +145,8 @@ H5P_term_interface(void)
hid_t
H5Pcreate(H5P_class_t type)
{
- hid_t ret_value = FAIL;
- void *tmpl = NULL;
+ hid_t ret_value = FAIL;
+ void *tmpl = NULL;
FUNC_ENTER(H5Pcreate, FAIL);
@@ -154,50 +154,50 @@ H5Pcreate(H5P_class_t type)
switch (type) {
case H5P_FILE_CREATE:
tmpl = H5MM_xmalloc(sizeof(H5F_create_t));
- memcpy(tmpl, &H5F_create_dflt, sizeof(H5F_create_t));
- break;
+ memcpy(tmpl, &H5F_create_dflt, sizeof(H5F_create_t));
+ break;
case H5P_FILE_ACCESS:
- tmpl = H5MM_xmalloc(sizeof(H5F_access_t));
- memcpy(tmpl, &H5F_access_dflt, sizeof(H5F_access_t));
- break;
+ tmpl = H5MM_xmalloc(sizeof(H5F_access_t));
+ memcpy(tmpl, &H5F_access_dflt, sizeof(H5F_access_t));
+ break;
case H5P_DATASET_CREATE:
- tmpl = H5MM_xmalloc(sizeof(H5D_create_t));
- memcpy(tmpl, &H5D_create_dflt, sizeof(H5D_create_t));
- break;
+ tmpl = H5MM_xmalloc(sizeof(H5D_create_t));
+ memcpy(tmpl, &H5D_create_dflt, sizeof(H5D_create_t));
+ break;
case H5P_DATASET_XFER:
- tmpl = H5MM_xmalloc(sizeof(H5D_xfer_t));
- memcpy(tmpl, &H5D_xfer_dflt, sizeof(H5D_xfer_t));
- break;
+ tmpl = H5MM_xmalloc(sizeof(H5D_xfer_t));
+ memcpy(tmpl, &H5D_xfer_dflt, sizeof(H5D_xfer_t));
+ break;
default:
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "unknown template class");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "unknown template class");
}
/* Atomize the new template */
if ((ret_value = H5P_create(type, tmpl)) < 0) {
- HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL,
- "can't register template");
+ HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL,
+ "can't register template");
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * Function: H5P_create
+ * Function: H5P_create
*
- * Purpose: Given a pointer to some template struct, atomize the template
- * and return its ID. The template memory is not copied, so the
- * caller should not free it; it will be freed by H5P_release().
+ * Purpose: Given a pointer to some template struct, atomize the template
+ * and return its ID. The template memory is not copied, so the
+ * caller should not free it; it will be freed by H5P_release().
*
- * Return: Success: A new template ID.
+ * Return: Success: A new template ID.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Wednesday, December 3, 1997
+ * Programmer: Robb Matzke
+ * Wednesday, December 3, 1997
*
* Modifications:
*
@@ -216,8 +216,8 @@ H5P_create(H5P_class_t type, void *tmpl)
/* Atomize the new template */
if ((ret_value=H5A_register((group_t)(H5_TEMPLATE_0+type), tmpl)) < 0) {
- HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL,
- "can't register template");
+ HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL,
+ "can't register template");
}
FUNC_LEAVE(ret_value);
@@ -230,24 +230,24 @@ H5P_create(H5P_class_t type, void *tmpl)
Release access to a template object.
USAGE
herr_t H5Pclose(oid)
- hid_t oid; IN: Template object to release access to
+ hid_t oid; IN: Template object to release access to
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function releases access to a template object
+ This function releases access to a template object
--------------------------------------------------------------------------*/
herr_t
H5Pclose(hid_t tid)
{
H5P_class_t type;
- void *tmpl = NULL;
+ void *tmpl = NULL;
FUNC_ENTER(H5Pclose, FAIL);
/* Check arguments */
if ((type=H5Pget_class (tid))<0 ||
NULL==(tmpl=H5A_object (tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
}
/*
@@ -273,7 +273,7 @@ H5Pclose(hid_t tid)
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Wednesday, February 18, 1998
+ * Wednesday, February 18, 1998
*
* Modifications:
*
@@ -283,6 +283,7 @@ herr_t
H5P_close (H5P_class_t type, void *tmpl)
{
H5F_access_t *fa_list = (H5F_access_t*)tmpl;
+ H5D_create_t *dc_list = (H5D_create_t*)tmpl;
FUNC_ENTER (H5P_close, FAIL);
@@ -323,7 +324,13 @@ H5P_close (H5P_class_t type, void *tmpl)
break;
case H5P_FILE_CREATE:
+ /*nothing to do*/
+ break;
+
case H5P_DATASET_CREATE:
+ H5O_reset (H5O_EFL, &(dc_list->efl));
+ break;
+
case H5P_DATASET_XFER:
/*nothing to do*/
break;
@@ -340,16 +347,16 @@ H5P_close (H5P_class_t type, void *tmpl)
/*-------------------------------------------------------------------------
- * Function: H5Pget_class
+ * Function: H5Pget_class
*
- * Purpose: Returns the class identifier for a template.
+ * Purpose: Returns the class identifier for a template.
*
- * Return: Success: A template class
+ * Return: Success: A template class
*
- * Failure: H5P_NO_CLASS (-1)
+ * Failure: H5P_NO_CLASS (-1)
*
- * Programmer: Robb Matzke
- * Wednesday, December 3, 1997
+ * Programmer: Robb Matzke
+ * Wednesday, December 3, 1997
*
* Modifications:
*
@@ -358,43 +365,43 @@ H5P_close (H5P_class_t type, void *tmpl)
H5P_class_t
H5Pget_class(hid_t tid)
{
- group_t group;
- H5P_class_t ret_value = H5P_NO_CLASS;
+ group_t group;
+ H5P_class_t ret_value = H5P_NO_CLASS;
FUNC_ENTER(H5Pget_class, H5P_NO_CLASS);
if ((group = H5A_group(tid)) < 0 ||
#ifndef NDEBUG
- group >= H5_TEMPLATE_MAX ||
+ group >= H5_TEMPLATE_MAX ||
#endif
- group < H5_TEMPLATE_0) {
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, H5P_NO_CLASS, "not a template");
+ group < H5_TEMPLATE_0) {
+ HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, H5P_NO_CLASS, "not a template");
}
ret_value = (H5P_class_t)(group - H5_TEMPLATE_0);
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * Function: H5Pget_version
+ * Function: H5Pget_version
*
- * Purpose: Retrieves version information for various parts of a file.
+ * Purpose: Retrieves version information for various parts of a file.
*
- * BOOT: The file boot block.
- * HEAP: The global heap.
- * FREELIST: The global free list.
- * STAB: The root symbol table entry.
- * SHHDR: Shared object headers.
+ * BOOT: The file boot block.
+ * HEAP: The global heap.
+ * FREELIST: The global free list.
+ * STAB: The root symbol table entry.
+ * SHHDR: Shared object headers.
*
- * Any (or even all) of the output arguments can be null
- * pointers.
+ * Any (or even all) of the output arguments can be null
+ * pointers.
*
- * Return: Success: SUCCEED, version information is returned
- * through the arguments.
+ * Return: Success: SUCCEED, version information is returned
+ * through the arguments.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Wednesday, January 7, 1998
+ * Programmer: Robb Matzke
+ * Wednesday, January 7, 1998
*
* Modifications:
*
@@ -402,44 +409,44 @@ H5Pget_class(hid_t tid)
*/
herr_t
H5Pget_version(hid_t tid, int *boot /*out */ , int *heap /*out */ ,
- int *freelist /*out */ , int *stab /*out */ , int *shhdr /*out */ )
+ int *freelist /*out */ , int *stab /*out */ , int *shhdr /*out */ )
{
- H5F_create_t *tmpl = NULL;
+ H5F_create_t *tmpl = NULL;
FUNC_ENTER(H5Pget_version, FAIL);
/* Check arguments */
if (H5P_FILE_CREATE != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
}
/* Get values */
if (boot)
- *boot = tmpl->bootblock_ver;
+ *boot = tmpl->bootblock_ver;
if (heap)
- *heap = tmpl->smallobject_ver;
+ *heap = tmpl->smallobject_ver;
if (freelist)
- *freelist = tmpl->freespace_ver;
+ *freelist = tmpl->freespace_ver;
if (stab)
- *stab = tmpl->objectdir_ver;
+ *stab = tmpl->objectdir_ver;
if (shhdr)
- *shhdr = tmpl->sharedheader_ver;
+ *shhdr = tmpl->sharedheader_ver;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5Pset_userblock
+ * Function: H5Pset_userblock
*
- * Purpose: Sets the userblock size field of a file creation template.
+ * Purpose: Sets the userblock size field of a file creation template.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Tuesday, January 6, 1998
+ * Programmer: Robb Matzke
+ * Tuesday, January 6, 1998
*
* Modifications:
*
@@ -448,25 +455,25 @@ H5Pget_version(hid_t tid, int *boot /*out */ , int *heap /*out */ ,
herr_t
H5Pset_userblock(hid_t tid, size_t size)
{
- intn i;
- H5F_create_t *tmpl = NULL;
+ intn i;
+ H5F_create_t *tmpl = NULL;
FUNC_ENTER(H5Pset_userblock, FAIL);
/* Check arguments */
if (H5P_FILE_CREATE != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
}
for (i = 8; i < 8 * sizeof(int); i++) {
- uintn p2 = 8 == i ? 0 : 1 << i;
- if (size == p2)
- break;
+ uintn p2 = 8 == i ? 0 : 1 << i;
+ if (size == p2)
+ break;
}
if (i >= 8 * sizeof(int)) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "userblock size is not valid");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "userblock size is not valid");
}
/* Set value */
tmpl->userblock_size = size;
@@ -475,16 +482,16 @@ H5Pset_userblock(hid_t tid, size_t size)
}
/*-------------------------------------------------------------------------
- * Function: H5Pget_userblock
+ * Function: H5Pget_userblock
*
- * Purpose: Queries the size of a user block in a file creation template.
+ * Purpose: Queries the size of a user block in a file creation template.
*
- * Return: Success: SUCCEED, size returned through SIZE argument.
+ * Return: Success: SUCCEED, size returned through SIZE argument.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Wednesday, January 7, 1998
+ * Programmer: Robb Matzke
+ * Wednesday, January 7, 1998
*
* Modifications:
*
@@ -493,36 +500,36 @@ H5Pset_userblock(hid_t tid, size_t size)
herr_t
H5Pget_userblock(hid_t tid, size_t *size)
{
- H5F_create_t *tmpl = NULL;
+ H5F_create_t *tmpl = NULL;
FUNC_ENTER(H5Pget_userblock, FAIL);
/* Check args */
if (H5P_FILE_CREATE != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
}
/* Get value */
if (size)
- *size = tmpl->userblock_size;
+ *size = tmpl->userblock_size;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5Pset_sizes
+ * Function: H5Pset_sizes
*
- * Purpose: Sets file size-of addresses and sizes. TEMPLATE
- * should be a file creation template. A value of zero causes
- * the property to not change.
+ * Purpose: Sets file size-of addresses and sizes. TEMPLATE
+ * should be a file creation template. A value of zero causes
+ * the property to not change.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Tuesday, January 6, 1998
+ * Programmer: Robb Matzke
+ * Tuesday, January 6, 1998
*
* Modifications:
*
@@ -531,52 +538,52 @@ H5Pget_userblock(hid_t tid, size_t *size)
herr_t
H5Pset_sizes(hid_t tid, size_t sizeof_addr, size_t sizeof_size)
{
- H5F_create_t *tmpl = NULL;
+ H5F_create_t *tmpl = NULL;
FUNC_ENTER(H5Pset_sizeof_addr, FAIL);
/* Check arguments */
if (H5P_FILE_CREATE != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
}
if (sizeof_addr) {
- if (sizeof_addr != 2 && sizeof_addr != 4 &&
- sizeof_addr != 8 && sizeof_addr != 16) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "file haddr_t size is not valid");
- }
+ if (sizeof_addr != 2 && sizeof_addr != 4 &&
+ sizeof_addr != 8 && sizeof_addr != 16) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "file haddr_t size is not valid");
+ }
}
if (sizeof_size) {
- if (sizeof_size != 2 && sizeof_size != 4 &&
- sizeof_size != 8 && sizeof_size != 16) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "file size_t size is not valid");
- }
+ if (sizeof_size != 2 && sizeof_size != 4 &&
+ sizeof_size != 8 && sizeof_size != 16) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "file size_t size is not valid");
+ }
}
/* Set value */
if (sizeof_addr)
- tmpl->sizeof_addr = sizeof_addr;
+ tmpl->sizeof_addr = sizeof_addr;
if (sizeof_size)
- tmpl->sizeof_size = sizeof_size;
+ tmpl->sizeof_size = sizeof_size;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5Pget_sizes
+ * Function: H5Pget_sizes
*
- * Purpose: Returns the size of address and size quantities stored in a
- * file according to a file creation template. Either (or even
- * both) SIZEOF_ADDR and SIZEOF_SIZE may be null pointers.
+ * Purpose: Returns the size of address and size quantities stored in a
+ * file according to a file creation template. Either (or even
+ * both) SIZEOF_ADDR and SIZEOF_SIZE may be null pointers.
*
- * Return: Success: SUCCEED, sizes returned through arguments.
+ * Return: Success: SUCCEED, sizes returned through arguments.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Wednesday, January 7, 1998
+ * Programmer: Robb Matzke
+ * Wednesday, January 7, 1998
*
* Modifications:
*
@@ -584,51 +591,51 @@ H5Pset_sizes(hid_t tid, size_t sizeof_addr, size_t sizeof_size)
*/
herr_t
H5Pget_sizes(hid_t tid,
- size_t *sizeof_addr /*out */ , size_t *sizeof_size /*out */ )
+ size_t *sizeof_addr /*out */ , size_t *sizeof_size /*out */ )
{
- H5F_create_t *tmpl = NULL;
+ H5F_create_t *tmpl = NULL;
FUNC_ENTER(H5Pget_sizes, FAIL);
/* Check args */
if (H5P_FILE_CREATE != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
}
/* Get values */
if (sizeof_addr)
- *sizeof_addr = tmpl->sizeof_addr;
+ *sizeof_addr = tmpl->sizeof_addr;
if (sizeof_size)
- *sizeof_size = tmpl->sizeof_size;
+ *sizeof_size = tmpl->sizeof_size;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5Pset_sym_k
+ * Function: H5Pset_sym_k
*
- * Purpose: IK is one half the rank of a tree that stores a symbol
- * table for a group. 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 of IK.
+ * Purpose: IK is one half the rank of a tree that stores a symbol
+ * table for a group. 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 of IK.
*
- * LK is 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 inserted 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 LK.
+ * LK is 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 inserted 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 LK.
*
- * Either (or even both) of IK and LK can be zero in which case
- * that value is left unchanged.
+ * Either (or even both) of IK and LK can be zero in which case
+ * that value is left unchanged.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Tuesday, January 6, 1998
+ * Programmer: Robb Matzke
+ * Tuesday, January 6, 1998
*
* Modifications:
*
@@ -637,40 +644,40 @@ H5Pget_sizes(hid_t tid,
herr_t
H5Pset_sym_k(hid_t tid, int ik, int lk)
{
- H5F_create_t *tmpl = NULL;
+ H5F_create_t *tmpl = NULL;
FUNC_ENTER(H5Pset_sym_k, FAIL);
/* Check arguments */
if (H5P_FILE_CREATE != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
}
/* Set values */
if (ik > 0) {
- tmpl->btree_k[H5B_SNODE_ID] = ik;
+ tmpl->btree_k[H5B_SNODE_ID] = ik;
}
if (lk > 0) {
- tmpl->sym_leaf_k = lk;
+ tmpl->sym_leaf_k = lk;
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5Pget_sym_k
+ * Function: H5Pget_sym_k
*
- * Purpose: Retrieves the symbol table B-tree 1/2 rank (IK) and the
- * symbol table leaf node 1/2 size (LK). See H5Pset_sym_k() for
- * details. Either (or even both) IK and LK may be null
- * pointers.
+ * Purpose: Retrieves the symbol table B-tree 1/2 rank (IK) and the
+ * symbol table leaf node 1/2 size (LK). See H5Pset_sym_k() for
+ * details. Either (or even both) IK and LK may be null
+ * pointers.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Wednesday, January 7, 1998
+ * Programmer: Robb Matzke
+ * Wednesday, January 7, 1998
*
* Modifications:
*
@@ -679,38 +686,38 @@ H5Pset_sym_k(hid_t tid, int ik, int lk)
herr_t
H5Pget_sym_k(hid_t tid, int *ik /*out */ , int *lk /*out */ )
{
- H5F_create_t *tmpl = NULL;
+ H5F_create_t *tmpl = NULL;
FUNC_ENTER(H5Pget_sym_k, FAIL);
/* Check arguments */
if (H5P_FILE_CREATE != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
}
/* Get values */
if (ik)
- *ik = tmpl->btree_k[H5B_SNODE_ID];
+ *ik = tmpl->btree_k[H5B_SNODE_ID];
if (lk)
- *lk = tmpl->sym_leaf_k;
+ *lk = tmpl->sym_leaf_k;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5Pset_istore_k
+ * 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.
+ * 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: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Tuesday, January 6, 1998
+ * Programmer: Robb Matzke
+ * Tuesday, January 6, 1998
*
* Modifications:
*
@@ -719,19 +726,19 @@ H5Pget_sym_k(hid_t tid, int *ik /*out */ , int *lk /*out */ )
herr_t
H5Pset_istore_k(hid_t tid, int ik)
{
- H5F_create_t *tmpl = NULL;
+ H5F_create_t *tmpl = NULL;
FUNC_ENTER(H5Pset_istore_k, FAIL);
/* Check arguments */
if (H5P_FILE_CREATE != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
}
if (ik <= 0) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "istore IK value must be positive");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "istore IK value must be positive");
}
/* Set value */
tmpl->btree_k[H5B_ISTORE_ID] = ik;
@@ -740,18 +747,18 @@ H5Pset_istore_k(hid_t tid, int ik)
}
/*-------------------------------------------------------------------------
- * Function: H5Pget_istore_k
+ * 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.
+ * 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: SUCCEED, size returned through IK
+ * Return: Success: SUCCEED, size returned through IK
*
- * Failure:
+ * Failure:
*
- * Programmer: Robb Matzke
- * Wednesday, January 7, 1998
+ * Programmer: Robb Matzke
+ * Wednesday, January 7, 1998
*
* Modifications:
*
@@ -760,34 +767,34 @@ H5Pset_istore_k(hid_t tid, int ik)
herr_t
H5Pget_istore_k(hid_t tid, int *ik /*out */ )
{
- H5F_create_t *tmpl = NULL;
+ H5F_create_t *tmpl = NULL;
FUNC_ENTER(H5Pget_istore_k, FAIL);
/* Check arguments */
if (H5P_FILE_CREATE != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
}
/* Get value */
if (ik)
- *ik = tmpl->btree_k[H5B_ISTORE_ID];
+ *ik = tmpl->btree_k[H5B_ISTORE_ID];
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5Pset_layout
+ * Function: H5Pset_layout
*
- * Purpose: Sets the layout of raw data in the file.
+ * Purpose: Sets the layout of raw data in the file.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Tuesday, January 6, 1998
+ * Programmer: Robb Matzke
+ * Tuesday, January 6, 1998
*
* Modifications:
*
@@ -796,19 +803,19 @@ H5Pget_istore_k(hid_t tid, int *ik /*out */ )
herr_t
H5Pset_layout(hid_t tid, H5D_layout_t layout)
{
- H5D_create_t *tmpl = NULL;
+ H5D_create_t *tmpl = NULL;
FUNC_ENTER(H5Pset_layout, FAIL);
/* Check arguments */
if (H5P_DATASET_CREATE != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a dataset creation template");
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a dataset creation template");
}
if (layout < 0 || layout >= H5D_NLAYOUTS) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
- "raw data layout method is not valid");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
+ "raw data layout method is not valid");
}
/* Set value */
tmpl->layout = layout;
@@ -817,16 +824,16 @@ H5Pset_layout(hid_t tid, H5D_layout_t layout)
}
/*-------------------------------------------------------------------------
- * Function: H5Pget_layout
+ * Function: H5Pget_layout
*
- * Purpose: Retrieves layout type of a dataset creation template.
+ * Purpose: Retrieves layout type of a dataset creation template.
*
- * Return: Success: The layout type
+ * Return: Success: The layout type
*
- * Failure: H5D_LAYOUT_ERROR (-1, same as FAIL)
+ * Failure: H5D_LAYOUT_ERROR (-1, same as FAIL)
*
- * Programmer: Robb Matzke
- * Wednesday, January 7, 1998
+ * Programmer: Robb Matzke
+ * Wednesday, January 7, 1998
*
* Modifications:
*
@@ -835,35 +842,35 @@ H5Pset_layout(hid_t tid, H5D_layout_t layout)
H5D_layout_t
H5Pget_layout(hid_t tid)
{
- H5D_create_t *tmpl = NULL;
+ H5D_create_t *tmpl = NULL;
FUNC_ENTER(H5Pget_layout, H5D_LAYOUT_ERROR);
/* Check arguments */
if (H5P_DATASET_CREATE != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5D_LAYOUT_ERROR,
- "not a dataset creation template");
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5D_LAYOUT_ERROR,
+ "not a dataset creation template");
}
FUNC_LEAVE(tmpl->layout);
}
/*-------------------------------------------------------------------------
- * Function: H5Pset_chunk
+ * Function: H5Pset_chunk
*
- * Purpose: Sets the number of dimensions and the size of each chunk to
- * the values specified. The dimensionality of the chunk should
- * match the dimensionality of the data space.
+ * Purpose: Sets the number of dimensions and the size of each chunk to
+ * the values specified. The dimensionality of the chunk should
+ * match the dimensionality of the data space.
*
- * As a side effect, the layout method is changed to
- * H5D_CHUNKED.
+ * As a side effect, the layout method is changed to
+ * H5D_CHUNKED.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Tuesday, January 6, 1998
+ * Programmer: Robb Matzke
+ * Tuesday, January 6, 1998
*
* Modifications:
*
@@ -872,59 +879,59 @@ H5Pget_layout(hid_t tid)
herr_t
H5Pset_chunk(hid_t tid, int ndims, const size_t dim[])
{
- int i;
- H5D_create_t *tmpl = NULL;
+ int i;
+ H5D_create_t *tmpl = NULL;
FUNC_ENTER(H5Pset_chunk, FAIL);
/* Check arguments */
if (H5P_DATASET_CREATE != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a dataset creation template");
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a dataset creation template");
}
if (ndims <= 0) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
- "chunk dimensionality must be positive");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
+ "chunk dimensionality must be positive");
}
if (ndims > NELMTS(tmpl->chunk_size)) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
- "chunk dimensionality is too large");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
+ "chunk dimensionality is too large");
}
if (!dim) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "no chunk dimensions specified");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "no chunk dimensions specified");
}
for (i = 0; i < ndims; i++) {
- if (dim[i] <= 0) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
- "all chunk dimensions must be positive");
- }
+ if (dim[i] <= 0) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
+ "all chunk dimensions must be positive");
+ }
}
/* Set value */
tmpl->layout = H5D_CHUNKED;
tmpl->chunk_ndims = ndims;
for (i = 0; i < ndims; i++)
- tmpl->chunk_size[i] = dim[i];
+ tmpl->chunk_size[i] = dim[i];
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5Pget_chunk
+ * Function: H5Pget_chunk
*
- * Purpose: Retrieves the chunk size of chunked layout. The chunk
- * dimensionality is returned and the chunk size in each
- * dimension is returned through the DIM argument. At most
- * MAX_NDIMS elements of DIM will be initialized.
+ * Purpose: Retrieves the chunk size of chunked layout. The chunk
+ * dimensionality is returned and the chunk size in each
+ * dimension is returned through the DIM argument. At most
+ * MAX_NDIMS elements of DIM will be initialized.
*
- * Return: Success: Positive Chunk dimensionality.
+ * Return: Success: Positive Chunk dimensionality.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Wednesday, January 7, 1998
+ * Programmer: Robb Matzke
+ * Wednesday, January 7, 1998
*
* Modifications:
*
@@ -933,23 +940,23 @@ H5Pset_chunk(hid_t tid, int ndims, const size_t dim[])
int
H5Pget_chunk(hid_t tid, int max_ndims, size_t dim[] /*out */ )
{
- int i;
- H5D_create_t *tmpl = NULL;
+ int i;
+ H5D_create_t *tmpl = NULL;
FUNC_ENTER(H5Pget_chunk, FAIL);
/* Check arguments */
if (H5P_DATASET_CREATE != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a dataset creation template");
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a dataset creation template");
}
if (H5D_CHUNKED != tmpl->layout) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "not a chunked storage layout");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "not a chunked storage layout");
}
for (i = 0; i < tmpl->chunk_ndims && i < max_ndims && dim; i++) {
- dim[i] = tmpl->chunk_size[i];
+ dim[i] = tmpl->chunk_size[i];
}
FUNC_LEAVE(tmpl->chunk_ndims);
@@ -957,6 +964,182 @@ H5Pget_chunk(hid_t tid, int max_ndims, size_t dim[] /*out */ )
/*-------------------------------------------------------------------------
+ * Function: H5Pset_external
+ *
+ * Purpose: Adds an external file to the list of external files. PLIST_ID
+ * should be an object ID for a dataset creation property list.
+ * NAME is the name of an external file, OFFSET is the location
+ * where the data starts in that file, and SIZE is the number of
+ * bytes reserved in the file for the data.
+ *
+ * If a dataset is split across multiple files then the files
+ * should be defined in order. The total size of the dataset is
+ * the sum of the SIZE arguments for all the external files. If
+ * the total size is larger than the size of a dataset then the
+ * dataset can be extended (provided the data space also allows
+ * the extending).
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, March 3, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pset_external (hid_t plist_id, const char *name, size_t offset, size_t size)
+{
+ int idx;
+ size_t total, tmp;
+ H5D_create_t *plist = NULL;
+
+ FUNC_ENTER(H5Pset_external, FAIL);
+
+ /* Check arguments */
+ if (H5P_DATASET_CREATE != H5Pget_class(plist_id) ||
+ NULL == (plist = H5A_object(plist_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a dataset creation property list");
+ }
+ if (!name || !*name) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
+ "no name given");
+ }
+ if (size<=0) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
+ "zero size");
+ }
+ if (plist->efl.nused>0 &&
+ H5O_EFL_UNLIMITED==plist->efl.slot[plist->efl.nused-1].size) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
+ "previous file size is unlimited");
+ }
+ if (H5O_EFL_UNLIMITED!=size) {
+ for (idx=0, total=size; idx<plist->efl.nused; idx++, total=tmp) {
+ tmp = total + plist->efl.slot[idx].size;
+ if (tmp <= total) {
+ HRETURN_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL,
+ "total external data size overflowed");
+ }
+ }
+ }
+
+ /* Add to the list */
+ if (plist->efl.nused>=plist->efl.nalloc) {
+ plist->efl.nalloc += H5O_EFL_ALLOC;
+ plist->efl.slot = H5MM_xrealloc (plist->efl.slot,
+ (plist->efl.nalloc *
+ sizeof(H5O_efl_entry_t)));
+ }
+ idx = plist->efl.nused;
+ plist->efl.slot[idx].name_offset = 0; /*not entered into heap yet*/
+ plist->efl.slot[idx].name = H5MM_xstrdup (name);
+ plist->efl.slot[idx].offset = offset;
+ plist->efl.slot[idx].size = size;
+ plist->efl.nused++;
+
+ FUNC_LEAVE(SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_external_count
+ *
+ * Purpose: Returns the number of external files for this dataset.
+ *
+ * Return: Success: Number of external files
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, March 3, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+H5Pget_external_count (hid_t plist_id)
+{
+ H5D_create_t *plist = NULL;
+
+ FUNC_ENTER (H5Pget_external_count, FAIL);
+
+ /* Check arguments */
+ if (H5P_DATASET_CREATE != H5Pget_class(plist_id) ||
+ NULL == (plist = H5A_object(plist_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a dataset creation property list");
+ }
+
+ /* Return */
+ FUNC_LEAVE (plist->efl.nused);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_external
+ *
+ * Purpose: Returns information about an external file. External files
+ * are numbered from zero to N-1 where N is the value returned
+ * by H5Pget_external_count(). At most NAME_SIZE characters are
+ * copied into the NAME array. If the external file name is
+ * longer than NAME_SIZE with the null terminator, then the
+ * return value is not null terminated (similar to strncpy()).
+ *
+ * If NAME_SIZE is zero or NAME is the null pointer then the
+ * external file name is not returned. If OFFSET or SIZE are
+ * null pointers then the corresponding information is not
+ * returned.
+ *
+ * See Also: H5Pset_external()
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, March 3, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pget_external (hid_t plist_id, int idx, size_t name_size, char *name/*out*/,
+ size_t *offset/*out*/, size_t *size/*out*/)
+{
+ H5D_create_t *plist = NULL;
+
+ FUNC_ENTER (H5Pget_external, FAIL);
+
+ /* Check arguments */
+ if (H5P_DATASET_CREATE != H5Pget_class(plist_id) ||
+ NULL == (plist = H5A_object(plist_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a dataset creation property list");
+ }
+ if (idx<0 || idx>=plist->efl.nused) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL,
+ "external file index is out of range");
+ }
+
+ /* Return values */
+ if (name_size>0 && name) {
+ strncpy (name, plist->efl.slot[idx].name, name_size);
+ }
+ if (offset) *offset = plist->efl.slot[idx].offset;
+ if (size) *size = plist->efl.slot[idx].size;
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: H5Pget_driver
*
* Purpose: Return the ID of the low-level file driver. TID should be a
@@ -967,7 +1150,7 @@ H5Pget_chunk(hid_t tid, int max_ndims, size_t dim[] /*out */ )
* Failure: H5F_LOW_ERROR (a negative value)
*
* Programmer: Robb Matzke
- * Thursday, February 26, 1998
+ * Thursday, February 26, 1998
*
* Modifications:
*
@@ -1003,7 +1186,7 @@ H5Pget_driver (hid_t tid)
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Thursday, February 19, 1998
+ * Thursday, February 19, 1998
*
* Modifications:
*
@@ -1018,8 +1201,8 @@ H5Pset_stdio (hid_t tid)
/* Check arguments */
if (H5P_FILE_ACCESS != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a file access template");
}
@@ -1035,7 +1218,7 @@ H5Pset_stdio (hid_t tid)
*
* Purpose: If the file access property list is set to the stdio driver
* then this function returns zero; otherwise it returns a
- * negative value. In the future, additional arguments may be
+ * negative value. In the future, additional arguments may be
* added to this function to match those added to H5Pset_stdio().
*
* Return: Success: SUCCEED
@@ -1043,7 +1226,7 @@ H5Pset_stdio (hid_t tid)
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Thursday, February 26, 1998
+ * Thursday, February 26, 1998
*
* Modifications:
*
@@ -1083,7 +1266,7 @@ H5Pget_stdio (hid_t tid)
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Thursday, February 19, 1998
+ * Thursday, February 19, 1998
*
* Modifications:
*
@@ -1098,8 +1281,8 @@ H5Pset_sec2 (hid_t tid)
/* Check arguments */
if (H5P_FILE_ACCESS != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a file access template");
}
@@ -1115,7 +1298,7 @@ H5Pset_sec2 (hid_t tid)
*
* Purpose: If the file access property list is set to the sec2 driver
* then this function returns zero; otherwise it returns a
- * negative value. In the future, additional arguments may be
+ * negative value. In the future, additional arguments may be
* added to this function to match those added to H5Pset_sec2().
*
* Return: Success: SUCCEED
@@ -1123,7 +1306,7 @@ H5Pset_sec2 (hid_t tid)
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Thursday, February 26, 1998
+ * Thursday, February 26, 1998
*
* Modifications:
*
@@ -1167,7 +1350,7 @@ H5Pget_sec2 (hid_t tid)
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Thursday, February 19, 1998
+ * Thursday, February 19, 1998
*
* Modifications:
*
@@ -1182,8 +1365,8 @@ H5Pset_core (hid_t tid, size_t increment)
/* Check arguments */
if (H5P_FILE_ACCESS != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a file access template");
}
if (increment<1) {
@@ -1204,7 +1387,7 @@ H5Pset_core (hid_t tid, size_t increment)
*
* Purpose: If the file access property list is set to the core driver
* then this function returns zero; otherwise it returns a
- * negative value. On success, the block size is returned
+ * negative value. On success, the block size is returned
* through the INCREMENT argument if it isn't the null pointer.
* In the future, additional arguments may be added to this
* function to match those added to H5Pset_core().
@@ -1214,7 +1397,7 @@ H5Pset_core (hid_t tid, size_t increment)
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Thursday, February 26, 1998
+ * Thursday, February 26, 1998
*
* Modifications:
*
@@ -1258,7 +1441,7 @@ H5Pget_core (hid_t tid, size_t *increment/*out*/)
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Thursday, February 19, 1998
+ * Thursday, February 19, 1998
*
* Modifications:
*
@@ -1276,20 +1459,20 @@ H5Pset_split (hid_t tid, const char *meta_ext, hid_t meta_tid,
/* Check arguments */
if (H5P_FILE_ACCESS != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a file access template");
}
if (H5P_DEFAULT!=meta_tid &&
(H5P_FILE_ACCESS != H5Pget_class(meta_tid) ||
NULL == (tmpl = H5A_object(meta_tid)))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a file access template");
}
if (H5P_DEFAULT!=raw_tid &&
(H5P_FILE_ACCESS != H5Pget_class(raw_tid) ||
NULL == (tmpl = H5A_object(raw_tid)))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a file access template");
}
@@ -1309,12 +1492,12 @@ H5Pset_split (hid_t tid, const char *meta_ext, hid_t meta_tid,
*
* Purpose: If the file access property list is set to the sec2 driver
* then this function returns zero; otherwise it returns a
- * negative value. On success, at most META_EXT_SIZE characters
+ * negative value. On success, at most META_EXT_SIZE characters
* are copied to the META_EXT buffer if non-null and at most
* RAW_EXT_SIZE characters are copied to the RAW_EXT buffer if
* non-null. If the actual extension is larger than the number
* of characters requested then the buffer will not be null
- * terminated (that is, behavior like strncpy()). In addition,
+ * terminated (that is, behavior like strncpy()). In addition,
* if META_PROPERTIES and/or RAW_PROPERTIES are non-null then
* the file access property list of the meta file and/or raw
* file is copied and its OID returned through these arguments.
@@ -1329,7 +1512,7 @@ H5Pset_split (hid_t tid, const char *meta_ext, hid_t meta_tid,
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Thursday, February 26, 1998
+ * Thursday, February 26, 1998
*
* Modifications:
*
@@ -1403,7 +1586,7 @@ H5Pget_split (hid_t tid, size_t meta_ext_size, char *meta_ext/*out*/,
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Thursday, February 19, 1998
+ * Thursday, February 19, 1998
*
* Modifications:
*
@@ -1420,14 +1603,14 @@ H5Pset_family (hid_t tid, hid_t memb_tid)
/* Check arguments */
if (H5P_FILE_ACCESS != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a file access template");
}
if (H5P_DEFAULT!=memb_tid &&
(H5P_FILE_ACCESS != H5Pget_class(memb_tid) ||
NULL == (tmpl = H5A_object(memb_tid)))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a file access template");
}
@@ -1444,7 +1627,7 @@ H5Pset_family (hid_t tid, hid_t memb_tid)
*
* Purpose: If the file access property list is set to the family driver
* then this function returns zero; otherwise it returns a
- * negative value. On success, if MEMB_TID is a non-null
+ * negative value. On success, if MEMB_TID is a non-null
* pointer it will be initialized with the OID of a copy of the
* file access template used for the family members. If the
* family members have no file access template (that is, they
@@ -1458,7 +1641,7 @@ H5Pset_family (hid_t tid, hid_t memb_tid)
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Thursday, February 26, 1998
+ * Thursday, February 26, 1998
*
* Modifications:
*
@@ -1496,50 +1679,50 @@ H5Pget_family (hid_t tid, hid_t *memb_tid)
/*-------------------------------------------------------------------------
- * Function: H5Pset_mpi
+ * Function: H5Pset_mpi
*
- * Signature: herr_t H5Pset_mpi(hid_t tid, MPI_Comm comm, MPI_Info info,
- * uintn access_mode)
+ * Signature: herr_t H5Pset_mpi(hid_t tid, MPI_Comm comm, MPI_Info info,
+ * uintn access_mode)
*
- * Purpose: Store the access mode for MPIO call and the user supplied
- * communicator and info in the access template which can then
- * be used to open file. This function is available only in the
- * parallel HDF5 library and is not a collective function.
+ * Purpose: Store the access mode for MPIO call and the user supplied
+ * communicator and info in the access template which can then
+ * be used to open file. This function is available only in the
+ * parallel HDF5 library and is not a collective function.
*
* Parameters:
- * hid_t tid
- * ID of template to modify
- * MPI_Comm comm
- * MPI communicator to be used for file open as defined in
- * MPI_FILE_OPEN of MPI-2. This function does not make a
- * duplicated communicator. Any modification to comm after
- * this function call returns may have undetermined effect
- * to the access template. Users should call this function
- * again to setup the template.
- * MPI_Info info
- * MPI info object to be used for file open as defined in
- * MPI_FILE_OPEN of MPI-2. This function does not make a
- * duplicated info. Any modification to info after
- * this function call returns may have undetermined effect
- * to the access template. Users should call this function
- * again to setup the template.
- * uintn access_mode
- * File data access modes:
- * H5ACC_INDEPENDENT
- * Allow independent datasets access.
- * H5ACC_COLLECTIVE
- * Allow only collective datasets access.
- *
- * Return: Success: SUCCEED
- *
- * Failure: FAIL
- *
- * Programmer: Albert Cheng
- * Feb 3, 1998
+ * hid_t tid
+ * ID of template to modify
+ * MPI_Comm comm
+ * MPI communicator to be used for file open as defined in
+ * MPI_FILE_OPEN of MPI-2. This function does not make a
+ * duplicated communicator. Any modification to comm after
+ * this function call returns may have undetermined effect
+ * to the access template. Users should call this function
+ * again to setup the template.
+ * MPI_Info info
+ * MPI info object to be used for file open as defined in
+ * MPI_FILE_OPEN of MPI-2. This function does not make a
+ * duplicated info. Any modification to info after
+ * this function call returns may have undetermined effect
+ * to the access template. Users should call this function
+ * again to setup the template.
+ * uintn access_mode
+ * File data access modes:
+ * H5ACC_INDEPENDENT
+ * Allow independent datasets access.
+ * H5ACC_COLLECTIVE
+ * Allow only collective datasets access.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Albert Cheng
+ * Feb 3, 1998
*
* Modifications:
*
- * Robb Matzke, 18 Feb 1998
+ * Robb Matzke, 18 Feb 1998
* Check all arguments before the template is updated so we don't leave
* the template in a bad state if something goes wrong. Also, the
* template data type changed to allow more generality so all the
@@ -1552,7 +1735,7 @@ H5Pget_family (hid_t tid, hid_t *memb_tid)
herr_t
H5Pset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode)
{
- H5F_access_t *tmpl = NULL;
+ H5F_access_t *tmpl = NULL;
MPI_Comm lcomm;
int mrc; /* MPI return code */
@@ -1560,8 +1743,8 @@ H5Pset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode)
/* Check arguments */
if (H5P_FILE_ACCESS != H5Pget_class(tid) ||
- NULL == (tmpl = H5A_object(tid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ NULL == (tmpl = H5A_object(tid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a file access template");
}
@@ -1594,8 +1777,8 @@ H5Pset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode)
* after this call.
*/
if ((mrc = MPI_Comm_dup(comm, &lcomm)) != MPI_SUCCESS) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "failure to duplicate communicator");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "failure to duplicate communicator");
}
tmpl->u.mpio.comm = comm;
@@ -1614,7 +1797,7 @@ H5Pset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode)
*
* Purpose: If the file access property list is set to the mpi driver
* then this function returns zero; otherwise it returns a
- * negative value. In the future, additional arguments may be
+ * negative value. In the future, additional arguments may be
* added to this function to match those added to H5Pset_mpi().
*
* Return: Success: SUCCEED
@@ -1622,7 +1805,7 @@ H5Pset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode)
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Thursday, February 26, 1998
+ * Thursday, February 26, 1998
*
* Modifications:
*
@@ -1664,16 +1847,16 @@ H5Pget_mpi (hid_t tid, MPI_Comm *comm, MPI_Info *info, uintn *access_mode)
Copy a template
USAGE
hid_t H5P_copy(tid)
- hid_t tid; IN: Template object to copy
+ hid_t tid; IN: Template object to copy
RETURNS
Returns template ID (atom) on success, FAIL on failure
ERRORS
- ARGS BADRANGE Unknown template class.
- ATOM BADATOM Can't unatomize template.
+ ARGS BADRANGE Unknown template class.
+ ATOM BADATOM Can't unatomize template.
ATOM CANTREGISTER Register the atom for the new template.
INTERNAL UNSUPPORTED Dataset transfer properties are not implemented
- yet.
+ yet.
INTERNAL UNSUPPORTED File access properties are not implemented yet.
DESCRIPTION
@@ -1683,20 +1866,20 @@ H5Pget_mpi (hid_t tid, MPI_Comm *comm, MPI_Info *info, uintn *access_mode)
hid_t
H5Pcopy(hid_t tid)
{
- const void *tmpl = NULL;
- void *new_tmpl = NULL;
- H5P_class_t type;
- hid_t ret_value = FAIL;
- group_t group;
+ const void *tmpl = NULL;
+ void *new_tmpl = NULL;
+ H5P_class_t type;
+ hid_t ret_value = FAIL;
+ group_t group;
FUNC_ENTER(H5Pcopy, FAIL);
/* Check args */
if (NULL == (tmpl = H5A_object(tid)) ||
- (type = H5Pget_class(tid)) < 0 ||
- (group = H5A_group(tid)) < 0) {
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL,
- "can't unatomize template");
+ (type = H5Pget_class(tid)) < 0 ||
+ (group = H5A_group(tid)) < 0) {
+ HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL,
+ "can't unatomize template");
}
/* Copy it */
@@ -1707,8 +1890,8 @@ H5Pcopy(hid_t tid)
/* Register the atom for the new template */
if ((ret_value = H5A_register(group, new_tmpl)) < 0) {
- HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to atomize template pointer");
+ HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
+ "unable to atomize template pointer");
}
FUNC_LEAVE(ret_value);
}
@@ -1724,7 +1907,7 @@ H5Pcopy(hid_t tid)
* Failure: NULL
*
* Programmer: Robb Matzke
- * Tuesday, February 3, 1998
+ * Tuesday, February 3, 1998
*
* Modifications:
*
@@ -1733,37 +1916,71 @@ H5Pcopy(hid_t tid)
void *
H5P_copy (H5P_class_t type, const void *src)
{
- size_t size;
- void *dst = NULL;
+ size_t size;
+ void *dst = NULL;
+ int i;
+ const H5D_create_t *dc_src = NULL;
+ H5D_create_t *dc_dst = NULL;
FUNC_ENTER (H5P_copy, NULL);
/* How big is the template */
switch (type) {
case H5P_FILE_CREATE:
- size = sizeof(H5F_create_t);
- break;
+ size = sizeof(H5F_create_t);
+ break;
case H5P_FILE_ACCESS:
size = sizeof(H5F_access_t);
break;
case H5P_DATASET_CREATE:
- size = sizeof(H5D_create_t);
- break;
+ size = sizeof(H5D_create_t);
+ break;
case H5P_DATASET_XFER:
- size = sizeof(H5D_xfer_t);
- break;
+ size = sizeof(H5D_xfer_t);
+ break;
default:
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL,
- "unknown template class");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL,
+ "unknown template class");
}
/* Create the new template */
dst = H5MM_xmalloc(size);
HDmemcpy(dst, src, size);
+ /* Deep-copy pointers */
+ switch (type) {
+ case H5P_FILE_CREATE:
+ break;
+
+ case H5P_FILE_ACCESS:
+ break;
+
+ case H5P_DATASET_CREATE:
+ dc_src = (const H5D_create_t*)src;
+ dc_dst = (H5D_create_t*)dst;
+
+ if (dc_src->efl.nalloc>0) {
+ dc_dst->efl.slot = H5MM_xmalloc (dc_dst->efl.nalloc *
+ sizeof(H5O_efl_entry_t));
+ for (i=0; i<dc_src->efl.nused; i++) {
+ char *s = H5MM_xstrdup (dc_src->efl.slot[i].name);
+ dc_dst->efl.slot[i] = dc_src->efl.slot[i];
+ dc_dst->efl.slot[i].name = s;
+ }
+ }
+ break;
+
+ case H5P_DATASET_XFER:
+ break;
+
+ default:
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL,
+ "unknown template class");
+ }
+
FUNC_LEAVE (dst);
}
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index b57b8e1..c5cbef8 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -62,6 +62,12 @@ herr_t H5Pset_layout (hid_t tid, H5D_layout_t layout);
H5D_layout_t H5Pget_layout (hid_t tid);
herr_t H5Pset_chunk (hid_t tid, int ndims, const size_t dim[]);
int H5Pget_chunk (hid_t tid, int max_ndims, size_t dim[]/*out*/);
+herr_t H5Pset_external (hid_t plist_id, const char *name, size_t offset,
+ size_t size);
+int H5Pget_external_count (hid_t plist_id);
+herr_t H5Pget_external (hid_t plist_id, int idx, size_t name_size,
+ char *name/*out*/, size_t *offset/*out*/,
+ size_t *size/*out*/);
H5F_driver_t H5Pget_driver (hid_t tid);
herr_t H5Pset_stdio (hid_t tid);
herr_t H5Pget_stdio (hid_t tid);
diff --git a/src/H5S.c b/src/H5S.c
index c6f03b2..d3a1ff9 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -1,34 +1,34 @@
/****************************************************************************
-* NCSA HDF *
-* Software Development Group *
-* National Center for Supercomputing Applications *
-* University of Illinois at Urbana-Champaign *
-* 605 E. Springfield, Champaign IL 61820 *
-* *
-* For conditions of distribution and use, see the accompanying *
-* hdf/COPYING file. *
-* *
+* NCSA HDF *
+* Software Development Group *
+* National Center for Supercomputing Applications *
+* University of Illinois at Urbana-Champaign *
+* 605 E. Springfield, Champaign IL 61820 *
+* *
+* For conditions of distribution and use, see the accompanying *
+* hdf/COPYING file. *
+* *
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
-#include <H5private.h> /* Generic Functions */
-#include <H5Aprivate.h> /* Atom Functions */
-#include <H5Eprivate.h> /* Error handling */
-#include <H5MMprivate.h> /* Memory Management functions */
-#include <H5Oprivate.h> /*object headers */
-#include <H5Sprivate.h> /* Data-space functions */
+#include <H5private.h> /* Generic Functions */
+#include <H5Aprivate.h> /* Atom Functions */
+#include <H5Eprivate.h> /* Error handling */
+#include <H5MMprivate.h> /* Memory Management functions */
+#include <H5Oprivate.h> /*object headers */
+#include <H5Sprivate.h> /* Data-space functions */
/* Interface initialization */
-#define PABLO_MASK H5S_mask
-#define INTERFACE_INIT H5S_init_interface
-static intn interface_initialize_g = FALSE;
-static herr_t H5S_init_interface(void);
-static void H5S_term_interface(void);
+#define PABLO_MASK H5S_mask
+#define INTERFACE_INIT H5S_init_interface
+static intn interface_initialize_g = FALSE;
+static herr_t H5S_init_interface(void);
+static void H5S_term_interface(void);
/*--------------------------------------------------------------------------
@@ -46,14 +46,14 @@ DESCRIPTION
static herr_t
H5S_init_interface(void)
{
- herr_t ret_value = SUCCEED;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER(H5S_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
if ((ret_value = H5A_init_group(H5_DATASPACE, H5A_DATASPACEID_HASHSIZE,
H5S_RESERVED_ATOMS,
(herr_t (*)(void *)) H5S_close)) != FAIL) {
- ret_value = H5_add_exit(&H5S_term_interface);
+ ret_value = H5_add_exit(&H5S_term_interface);
}
FUNC_LEAVE(ret_value);
}
@@ -83,25 +83,25 @@ H5S_term_interface(void)
}
/*-------------------------------------------------------------------------
- * Function: H5Screate_simple
+ * Function: H5Screate_simple
*
- * Purpose: Creates a new simple data space object and opens it for
+ * Purpose: Creates a new simple data space object and opens it for
* access. The DIMS argument is the size of the simple dataset
* and the MAXDIMS argument is the upper limit on the size of
* the dataset. MAXDIMS may be the null pointer in which case
* the upper limit is the same as DIMS. If an element of
- * MAXDIMS is zero then the corresponding dimension is unlimited,
- * otherwise no element of MAXDIMS should be smaller than the
- * corresponding element of DIMS.
+ * MAXDIMS is H5S_UNLIMITED then the corresponding dimension is
+ * unlimited, otherwise no element of MAXDIMS should be smaller
+ * than the corresponding element of DIMS.
*
- * Return: Success: The ID for the new simple data space object.
+ * Return: Success: The ID for the new simple data space object.
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
*
- * Programmer: Quincey Koziol
- * Tuesday, January 27, 1998
+ * Programmer: Quincey Koziol
+ * Tuesday, January 27, 1998
*
* Modifications:
*
@@ -110,8 +110,8 @@ H5S_term_interface(void)
hid_t
H5Screate_simple(int rank, const size_t *dims, const size_t *maxdims)
{
- H5S_t *ds = NULL;
- hid_t ret_value = FAIL;
+ H5S_t *ds = NULL;
+ hid_t ret_value = FAIL;
int i;
FUNC_ENTER(H5Screate, FAIL);
@@ -127,7 +127,7 @@ H5Screate_simple(int rank, const size_t *dims, const size_t *maxdims)
}
if (maxdims) {
for (i=0; i<rank; i++) {
- if (maxdims[i] && maxdims[i]<dims[i]) {
+ if (H5S_UNLIMITED!=maxdims[i] && maxdims[i]<dims[i]) {
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
"maxdims is smaller than dims");
}
@@ -137,56 +137,56 @@ H5Screate_simple(int rank, const size_t *dims, const size_t *maxdims)
/* Create a new data space */
ds = H5MM_xcalloc(1, sizeof(H5S_t));
#ifdef LATER /* QAK */
- if(rank>0) /* for creating simple dataspace */
+ if(rank>0) /* for creating simple dataspace */
{
#endif /* LATER */
- ds->type = H5S_SIMPLE;
- ds->hslab_def = FALSE; /* no hyperslab defined currently */
+ ds->type = H5S_SIMPLE;
+ ds->hslab_def = FALSE; /* no hyperslab defined currently */
- /* Initialize rank and dimensions */
- ds->u.simple.rank = rank;
+ /* Initialize rank and dimensions */
+ ds->u.simple.rank = rank;
- ds->u.simple.size = H5MM_xcalloc(1, rank*sizeof(size_t));
- HDmemcpy(ds->u.simple.size, dims, rank*sizeof(size_t));
+ ds->u.simple.size = H5MM_xcalloc(1, rank*sizeof(size_t));
+ HDmemcpy(ds->u.simple.size, dims, rank*sizeof(size_t));
- if (maxdims) {
- ds->u.simple.max = H5MM_xcalloc(1, rank*sizeof(size_t));
- HDmemcpy (ds->u.simple.max, maxdims, rank*sizeof(size_t));
- }
+ if (maxdims) {
+ ds->u.simple.max = H5MM_xcalloc(1, rank*sizeof(size_t));
+ HDmemcpy (ds->u.simple.max, maxdims, rank*sizeof(size_t));
+ }
#ifdef LATER /* QAK */
} /* end if */
else /* rank==0, for scalar data space */
{
- ds->type = H5S_SCALAR;
+ ds->type = H5S_SCALAR;
} /* end else */
#endif /* LATER */
/* Register the new data space and get an ID for it */
if ((ret_value = H5A_register(H5_DATASPACE, ds)) < 0) {
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to register data space for ID");
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
+ "unable to register data space for ID");
}
done:
if (ret_value < 0) {
- H5MM_xfree(ds);
+ H5MM_xfree(ds);
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * Function: H5Sclose
+ * Function: H5Sclose
*
- * Purpose: Release access to a data space object.
+ * Purpose: Release access to a data space object.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
*
- * Programmer: Robb Matzke
- * Tuesday, December 9, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
*
* Modifications:
*
@@ -199,27 +199,27 @@ H5Sclose(hid_t space_id)
/* Check args */
if (H5_DATASPACE != H5A_group(space_id) ||
- NULL == H5A_object(space_id)) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ NULL == H5A_object(space_id)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
}
/* When the reference count reaches zero the resources are freed */
if (H5A_dec_ref(space_id) < 0) {
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id");
+ HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id");
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5S_close
+ * Function: H5S_close
*
- * Purpose: Releases all memory associated with a data space.
+ * Purpose: Releases all memory associated with a data space.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Tuesday, December 9, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
*
* Modifications:
*
@@ -234,27 +234,27 @@ H5S_close(H5S_t *ds)
switch (ds->type) {
case H5S_SCALAR:
- /*void */
- break;
+ /*void */
+ break;
case H5S_SIMPLE:
- H5MM_xfree(ds->u.simple.size);
- H5MM_xfree(ds->u.simple.max);
- H5MM_xfree(ds->u.simple.perm);
- break;
+ H5MM_xfree(ds->u.simple.size);
+ H5MM_xfree(ds->u.simple.max);
+ H5MM_xfree(ds->u.simple.perm);
+ break;
case H5S_COMPLEX:
- /* nothing */
- break;
+ /* nothing */
+ break;
default:
- assert("unknown data space type" && 0);
- break;
+ assert("unknown data space type" && 0);
+ break;
}
if(ds->hslab_def==TRUE) {
- H5MM_xfree(ds->h.start);
- H5MM_xfree(ds->h.count);
- H5MM_xfree(ds->h.stride);
+ H5MM_xfree(ds->h.start);
+ H5MM_xfree(ds->h.count);
+ H5MM_xfree(ds->h.stride);
} /* end if */
H5MM_xfree(ds);
@@ -271,7 +271,7 @@ H5S_close(H5S_t *ds)
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Friday, January 30, 1998
+ * Friday, January 30, 1998
*
* Modifications:
*
@@ -309,16 +309,16 @@ H5Scopy (hid_t space_id)
/*-------------------------------------------------------------------------
- * Function: H5S_copy
+ * Function: H5S_copy
*
- * Purpose: Copies a data space.
+ * Purpose: Copies a data space.
*
- * Return: Success: A pointer to a new copy of SRC
+ * Return: Success: A pointer to a new copy of SRC
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
*
* Modifications:
*
@@ -327,8 +327,8 @@ H5Scopy (hid_t space_id)
H5S_t *
H5S_copy(const H5S_t *src)
{
- H5S_t *dst = NULL;
- int i;
+ H5S_t *dst = NULL;
+ int i;
FUNC_ENTER(H5S_copy, NULL);
@@ -337,56 +337,56 @@ H5S_copy(const H5S_t *src)
switch (dst->type) {
case H5S_SCALAR:
- /*void */
- break;
+ /*void */
+ break;
case H5S_SIMPLE:
- if (dst->u.simple.size) {
- dst->u.simple.size = H5MM_xmalloc(dst->u.simple.rank *
- sizeof(dst->u.simple.size[0]));
- for (i = 0; i < dst->u.simple.rank; i++) {
- dst->u.simple.size[i] = src->u.simple.size[i];
- }
- }
- if (dst->u.simple.max) {
- dst->u.simple.max = H5MM_xmalloc(dst->u.simple.rank *
- sizeof(dst->u.simple.max[0]));
- for (i = 0; i < dst->u.simple.rank; i++) {
- dst->u.simple.max[i] = src->u.simple.max[i];
- }
- }
- if (dst->u.simple.perm) {
- dst->u.simple.perm = H5MM_xmalloc(dst->u.simple.rank *
- sizeof(dst->u.simple.perm[0]));
- for (i = 0; i < dst->u.simple.rank; i++) {
- dst->u.simple.perm[i] = src->u.simple.perm[i];
- }
- }
- break;
+ if (dst->u.simple.size) {
+ dst->u.simple.size = H5MM_xmalloc(dst->u.simple.rank *
+ sizeof(dst->u.simple.size[0]));
+ for (i = 0; i < dst->u.simple.rank; i++) {
+ dst->u.simple.size[i] = src->u.simple.size[i];
+ }
+ }
+ if (dst->u.simple.max) {
+ dst->u.simple.max = H5MM_xmalloc(dst->u.simple.rank *
+ sizeof(dst->u.simple.max[0]));
+ for (i = 0; i < dst->u.simple.rank; i++) {
+ dst->u.simple.max[i] = src->u.simple.max[i];
+ }
+ }
+ if (dst->u.simple.perm) {
+ dst->u.simple.perm = H5MM_xmalloc(dst->u.simple.rank *
+ sizeof(dst->u.simple.perm[0]));
+ for (i = 0; i < dst->u.simple.rank; i++) {
+ dst->u.simple.perm[i] = src->u.simple.perm[i];
+ }
+ }
+ break;
case H5S_COMPLEX:
- /*void */
- break;
+ /*void */
+ break;
default:
- assert("unknown data space type" && 0);
- break;
+ assert("unknown data space type" && 0);
+ break;
}
FUNC_LEAVE(dst);
}
/*-------------------------------------------------------------------------
- * Function: H5Sget_npoints
+ * Function: H5Sget_npoints
*
- * Purpose: Determines how many data points a data set has.
+ * Purpose: Determines how many data points a data set has.
*
- * Return: Success: Number of data points in the data set.
+ * Return: Success: Number of data points in the data set.
*
- * Failure: 0
+ * Failure: 0
*
- * Programmer: Robb Matzke
- * Tuesday, December 9, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
*
* Modifications:
*
@@ -395,32 +395,33 @@ H5S_copy(const H5S_t *src)
size_t
H5Sget_npoints(hid_t space_id)
{
- H5S_t *ds = NULL;
- size_t ret_value = 0;
+ H5S_t *ds = NULL;
+ size_t ret_value = 0;
FUNC_ENTER(H5Sget_npoints, 0);
/* Check args */
if (H5_DATASPACE != H5A_group(space_id) ||
- NULL == (ds = H5A_object(space_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space");
+ NULL == (ds = H5A_object(space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space");
}
ret_value = H5S_get_npoints(ds);
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
- * Function: H5S_get_npoints
+ * Function: H5S_get_npoints
*
- * Purpose: Determines how many data points a data set has.
+ * Purpose: Determines how many data points a data set has.
*
- * Return: Success: Number of data points in the data set.
+ * Return: Success: Number of data points in the data set.
*
- * Failure: 0
+ * Failure: 0
*
- * Programmer: Robb Matzke
- * Tuesday, December 9, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
*
* Modifications:
*
@@ -429,8 +430,8 @@ H5Sget_npoints(hid_t space_id)
size_t
H5S_get_npoints(const H5S_t *ds)
{
- size_t ret_value = 0;
- intn i;
+ size_t ret_value = 0;
+ intn i;
FUNC_ENTER(H5S_get_npoints, 0);
@@ -439,8 +440,8 @@ H5S_get_npoints(const H5S_t *ds)
switch (ds->type) {
case H5S_SCALAR:
- ret_value = 1;
- break;
+ ret_value = 1;
+ break;
case H5S_SIMPLE:
/*
@@ -455,33 +456,100 @@ H5S_get_npoints(const H5S_t *ds)
for (ret_value=1, i=0; i<ds->u.simple.rank; i++) {
ret_value *= ds->u.simple.size[i];
}
- }
- break;
+ }
+ break;
case H5S_COMPLEX:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0,
- "complex data spaces are not supported yet");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0,
+ "complex data spaces are not supported yet");
default:
- assert("unknown data space class" && 0);
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0,
- "internal error (unknown data space class)");
+ assert("unknown data space class" && 0);
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0,
+ "internal error (unknown data space class)");
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * Function: H5Sget_ndims
+ * Function: H5S_get_npoints_max
*
- * Purpose: Determines the dimensionality of a data space.
+ * Purpose: Determines the maximum number of data points a data space may
+ * have. If the `max' array is null then the maximum number of
+ * data points is the same as the current number of data points
+ * without regard to the hyperslab. If any element of the `max'
+ * array is zero then the maximum possible size is returned.
*
- * Return: Success: The number of dimensions in a data space.
+ * Return: Success: Maximum number of data points the data space
+ * may have.
*
- * Failure: FAIL
+ * Failure: 0
*
- * Programmer: Robb Matzke
- * Thursday, December 11, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+size_t
+H5S_get_npoints_max(const H5S_t *ds)
+{
+ size_t ret_value = 0;
+ intn i;
+
+ FUNC_ENTER(H5S_get_npoints_max, 0);
+
+ /* check args */
+ assert(ds);
+
+ switch (ds->type) {
+ case H5S_SCALAR:
+ ret_value = 1;
+ break;
+
+ case H5S_SIMPLE:
+ if (ds->u.simple.max) {
+ for (ret_value=1, i=0; i<ds->u.simple.rank; i++) {
+ if (H5S_UNLIMITED==ds->u.simple.max[i]) {
+ ret_value = (size_t)(-1L);
+ break;
+ } else {
+ ret_value *= ds->u.simple.max[i];
+ }
+ }
+ } else {
+ for (ret_value=1, i=0; i<ds->u.simple.rank; i++) {
+ ret_value *= ds->u.simple.size[i];
+ }
+ }
+ break;
+
+ case H5S_COMPLEX:
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0,
+ "complex data spaces are not supported yet");
+
+ default:
+ assert("unknown data space class" && 0);
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0,
+ "internal error (unknown data space class)");
+ }
+
+ FUNC_LEAVE(ret_value);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: H5Sget_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:
*
@@ -490,15 +558,15 @@ H5S_get_npoints(const H5S_t *ds)
int
H5Sget_ndims(hid_t space_id)
{
- H5S_t *ds = NULL;
- intn ret_value = 0;
+ H5S_t *ds = NULL;
+ intn ret_value = 0;
FUNC_ENTER(H5Sget_ndims, FAIL);
/* Check args */
if (H5_DATASPACE != H5A_group(space_id) ||
- NULL == (ds = H5A_object(space_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ NULL == (ds = H5A_object(space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
}
ret_value = H5S_get_ndims(ds);
@@ -506,17 +574,17 @@ H5Sget_ndims(hid_t space_id)
}
/*-------------------------------------------------------------------------
- * Function: H5S_get_ndims
+ * Function: H5S_get_ndims
*
- * Purpose: Returns the number of dimensions in a data space.
+ * Purpose: Returns the number of dimensions in a data space.
*
- * Return: Success: Non-negative number of dimensions. Zero
- * implies a scalar.
+ * Return: Success: Non-negative number of dimensions. Zero
+ * implies a scalar.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Thursday, December 11, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 11, 1997
*
* Modifications:
*
@@ -525,7 +593,7 @@ H5Sget_ndims(hid_t space_id)
intn
H5S_get_ndims(const H5S_t *ds)
{
- intn ret_value = FAIL;
+ intn ret_value = FAIL;
FUNC_ENTER(H5S_get_ndims, FAIL);
@@ -534,39 +602,39 @@ H5S_get_ndims(const H5S_t *ds)
switch (ds->type) {
case H5S_SCALAR:
- ret_value = 0;
- break;
+ ret_value = 0;
+ break;
case H5S_SIMPLE:
- ret_value = ds->u.simple.rank;
- break;
+ ret_value = ds->u.simple.rank;
+ break;
case H5S_COMPLEX:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "complex data spaces are not supported yet");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "complex data spaces are not supported yet");
default:
- assert("unknown data space class" && 0);
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "internal error (unknown data space class)");
+ assert("unknown data space class" && 0);
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "internal error (unknown data space class)");
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * Function: H5Sget_dims
+ * Function: H5Sget_dims
*
- * Purpose: Returns the size in each dimension of a data space DS through
- * the DIMS argument.
+ * 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 H5Sget_ndims().
+ * Return: Success: Number of dimensions, the same value as
+ * returned by H5Sget_ndims().
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Thursday, December 11, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 11, 1997
*
* Modifications:
*
@@ -576,46 +644,46 @@ int
H5Sget_dims(hid_t space_id, size_t dims[]/*out*/)
{
- H5S_t *ds = NULL;
- intn ret_value = 0;
+ H5S_t *ds = NULL;
+ intn ret_value = 0;
FUNC_ENTER(H5Sget_dims, FAIL);
/* Check args */
if (H5_DATASPACE != H5A_group(space_id) ||
- NULL == (ds = H5A_object(space_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ NULL == (ds = H5A_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");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer");
}
- ret_value = H5S_get_dims(ds, dims);
+ ret_value = H5S_get_dims(ds, dims, NULL);
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * Function: H5S_get_dims
+ * Function: H5S_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.
+ * 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.
+ * Return: Success: Number of dimensions. Zero implies scalar.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Thursday, December 11, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 11, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
intn
-H5S_get_dims(const H5S_t *ds, size_t dims[])
+H5S_get_dims(const H5S_t *ds, size_t dims[], size_t max_dims[])
{
- intn ret_value = FAIL;
- intn i;
+ intn ret_value = FAIL;
+ intn i;
FUNC_ENTER(H5S_get_dims, FAIL);
@@ -625,41 +693,48 @@ H5S_get_dims(const H5S_t *ds, size_t dims[])
switch (ds->type) {
case H5S_SCALAR:
- ret_value = 0;
- break;
+ ret_value = 0;
+ break;
case H5S_SIMPLE:
- ret_value = ds->u.simple.rank;
- for (i = 0; i < ret_value; i++) {
- dims[i] = ds->u.simple.size[i];
- }
- break;
+ ret_value = ds->u.simple.rank;
+ for (i=0; i<ret_value; i++) {
+ if (dims) dims[i] = ds->u.simple.size[i];
+ if (max_dims) {
+ if (ds->u.simple.max) {
+ max_dims[i] = ds->u.simple.max[i];
+ } else {
+ max_dims[i] = ds->u.simple.size[i];
+ }
+ }
+ }
+ break;
case H5S_COMPLEX:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "complex data spaces are not supported yet");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "complex data spaces are not supported yet");
default:
- assert("unknown data space class" && 0);
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "internal error (unknown data space class)");
+ assert("unknown data space class" && 0);
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "internal error (unknown data space class)");
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * Function: H5S_modify
+ * Function: H5S_modify
*
- * Purpose: Updates a data space by writing a message to an object
- * header.
+ * Purpose: Updates a data space by writing a message to an object
+ * header.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Tuesday, December 9, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
*
* Modifications:
*
@@ -675,39 +750,39 @@ H5S_modify(H5G_entry_t *ent, const H5S_t *ds)
switch (ds->type) {
case H5S_SCALAR:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "scalar data spaces are not implemented yet");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "scalar data spaces are not implemented yet");
case H5S_SIMPLE:
- if (H5O_modify(ent, H5O_SDSPACE, 0, 0, &(ds->u.simple)) < 0) {
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL,
- "can't update simple data space message");
- }
- break;
+ if (H5O_modify(ent, H5O_SDSPACE, 0, 0, &(ds->u.simple)) < 0) {
+ HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL,
+ "can't update simple data space message");
+ }
+ break;
case H5S_COMPLEX:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "complex data spaces are not implemented yet");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "complex data spaces are not implemented yet");
default:
- assert("unknown data space class" && 0);
- break;
+ assert("unknown data space class" && 0);
+ break;
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5S_read
+ * Function: H5S_read
*
- * Purpose: Reads the data space from an object header.
+ * Purpose: Reads the data space from an object header.
*
- * Return: Success: Pointer to a new data space.
+ * Return: Success: Pointer to a new data space.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * Tuesday, December 9, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
*
* Modifications:
*
@@ -716,7 +791,7 @@ H5S_modify(H5G_entry_t *ent, const H5S_t *ds)
H5S_t *
H5S_read(H5F_t *f, H5G_entry_t *ent)
{
- H5S_t *ds = NULL;
+ H5S_t *ds = NULL;
FUNC_ENTER(H5S_read, NULL);
@@ -727,28 +802,28 @@ H5S_read(H5F_t *f, H5G_entry_t *ent)
ds = H5MM_xcalloc(1, sizeof(H5S_t));
if (H5O_read(ent, H5O_SDSPACE, 0, &(ds->u.simple))) {
- ds->type = H5S_SIMPLE;
+ ds->type = H5S_SIMPLE;
} else {
- ds->type = H5S_SCALAR;
+ ds->type = H5S_SCALAR;
}
FUNC_LEAVE(ds);
}
/*-------------------------------------------------------------------------
- * Function: H5S_cmp
+ * Function: H5S_cmp
*
- * Purpose: Compares two data spaces.
+ * Purpose: Compares two data spaces.
*
- * Return: Success: 0 if DS1 and DS2 are the same.
- * <0 if DS1 is less than DS2.
- * >0 if DS1 is greater than DS2.
+ * Return: Success: 0 if DS1 and DS2 are the same.
+ * <0 if DS1 is less than DS2.
+ * >0 if DS1 is greater than DS2.
*
- * Failure: 0, never fails
+ * Failure: 0, never fails
*
- * Programmer: Robb Matzke
- * Wednesday, December 10, 1997
+ * Programmer: Robb Matzke
+ * Wednesday, December 10, 1997
*
* Modifications:
*
@@ -757,7 +832,7 @@ H5S_read(H5F_t *f, H5G_entry_t *ent)
intn
H5S_cmp(const H5S_t *ds1, const H5S_t *ds2)
{
- intn i;
+ intn i;
FUNC_ENTER(H5S_cmp, 0);
@@ -767,60 +842,60 @@ H5S_cmp(const H5S_t *ds1, const H5S_t *ds2)
/* compare */
if (ds1->type < ds2->type)
- HRETURN(-1);
+ HRETURN(-1);
if (ds1->type > ds2->type)
- HRETURN(1);
+ HRETURN(1);
switch (ds1->type) {
case H5S_SIMPLE:
- if (ds1->u.simple.rank < ds2->u.simple.rank)
- HRETURN(-1);
- if (ds1->u.simple.rank > ds2->u.simple.rank)
- HRETURN(1);
-
- for (i = 0; i < ds1->u.simple.rank; i++) {
- if (ds1->u.simple.size[i] < ds2->u.simple.size[i])
- HRETURN(-1);
- if (ds1->u.simple.size[i] > ds2->u.simple.size[i])
- HRETURN(1);
- }
-
- /* don't compare max dimensions */
-
- for (i = 0; i < ds1->u.simple.rank; i++) {
- if ((ds1->u.simple.perm ? ds1->u.simple.perm[i] : i) <
- (ds2->u.simple.perm ? ds2->u.simple.perm[i] : i))
- HRETURN(-1);
- if ((ds1->u.simple.perm ? ds2->u.simple.perm[i] : i) >
- (ds2->u.simple.perm ? ds2->u.simple.perm[i] : i))
- HRETURN(1);
- }
-
- /* Check if we should compare hyperslab definitions */
- if(ds1->hslab_def==TRUE && ds2->hslab_def==TRUE) {
- for (i = 0; i < ds1->u.simple.rank; i++) {
- if (ds1->h.start[i] < ds2->h.start[i])
- HRETURN(-1);
- if (ds1->h.start[i] > ds2->h.start[i])
- HRETURN(1);
- if (ds1->h.count[i] < ds2->h.count[i])
- HRETURN(-1);
- if (ds1->h.count[i] > ds2->h.count[i])
- HRETURN(1);
- if (ds1->h.stride[i] < ds2->h.stride[i])
- HRETURN(-1);
- if (ds1->h.stride[i] > ds2->h.stride[i])
- HRETURN(1);
- }
+ if (ds1->u.simple.rank < ds2->u.simple.rank)
+ HRETURN(-1);
+ if (ds1->u.simple.rank > ds2->u.simple.rank)
+ HRETURN(1);
+
+ for (i = 0; i < ds1->u.simple.rank; i++) {
+ if (ds1->u.simple.size[i] < ds2->u.simple.size[i])
+ HRETURN(-1);
+ if (ds1->u.simple.size[i] > ds2->u.simple.size[i])
+ HRETURN(1);
+ }
+
+ /* don't compare max dimensions */
+
+ for (i = 0; i < ds1->u.simple.rank; i++) {
+ if ((ds1->u.simple.perm ? ds1->u.simple.perm[i] : i) <
+ (ds2->u.simple.perm ? ds2->u.simple.perm[i] : i))
+ HRETURN(-1);
+ if ((ds1->u.simple.perm ? ds2->u.simple.perm[i] : i) >
+ (ds2->u.simple.perm ? ds2->u.simple.perm[i] : i))
+ HRETURN(1);
+ }
+
+ /* Check if we should compare hyperslab definitions */
+ if(ds1->hslab_def==TRUE && ds2->hslab_def==TRUE) {
+ for (i = 0; i < ds1->u.simple.rank; i++) {
+ if (ds1->h.start[i] < ds2->h.start[i])
+ HRETURN(-1);
+ if (ds1->h.start[i] > ds2->h.start[i])
+ HRETURN(1);
+ if (ds1->h.count[i] < ds2->h.count[i])
+ HRETURN(-1);
+ if (ds1->h.count[i] > ds2->h.count[i])
+ HRETURN(1);
+ if (ds1->h.stride[i] < ds2->h.stride[i])
+ HRETURN(-1);
+ if (ds1->h.stride[i] > ds2->h.stride[i])
+ HRETURN(1);
+ }
} else {
- if(ds1->hslab_def!=ds2->hslab_def)
- HRETURN(ds1->hslab_def==TRUE ? 1 : -1);
+ if(ds1->hslab_def!=ds2->hslab_def)
+ HRETURN(ds1->hslab_def==TRUE ? 1 : -1);
}
- break;
+ break;
default:
- assert("not implemented yet" && 0);
+ assert("not implemented yet" && 0);
}
FUNC_LEAVE(0);
@@ -834,17 +909,17 @@ H5S_cmp(const H5S_t *ds1, const H5S_t *ds2)
Check if a dataspace is simple (internal)
USAGE
hbool_t H5S_is_simple(sdim)
- H5S_t *sdim; IN: Pointer to dataspace object to query
+ H5S_t *sdim; IN: Pointer to dataspace object to query
RETURNS
TRUE/FALSE/FAIL
DESCRIPTION
- This function determines the if a dataspace is "simple". ie. if it
+ This function determines the if a dataspace is "simple". ie. if it
has orthogonal, evenly spaced dimensions.
--------------------------------------------------------------------------*/
hbool_t
H5S_is_simple(const H5S_t *sdim)
{
- hbool_t ret_value = FAIL;
+ hbool_t ret_value = FAIL;
FUNC_ENTER(H5S_is_simple, FAIL);
@@ -863,31 +938,31 @@ H5S_is_simple(const H5S_t *sdim)
Check if a dataspace is simple
USAGE
hbool_t H5Sis_simple(sid)
- hid_t sid; IN: ID of dataspace object to query
+ hid_t sid; IN: ID of dataspace object to query
RETURNS
TRUE/FALSE/FAIL
DESCRIPTION
- This function determines the if a dataspace is "simple". ie. if it
+ This function determines the if a dataspace is "simple". ie. if it
has orthogonal, evenly spaced dimensions.
--------------------------------------------------------------------------*/
hbool_t
H5Sis_simple(hid_t sid)
{
- H5S_t *space = NULL; /* dataspace to modify */
- hbool_t ret_value = FAIL;
+ H5S_t *space = NULL; /* dataspace to modify */
+ hbool_t ret_value = FAIL;
FUNC_ENTER(H5Sis_simple, FAIL);
/* Check args and all the boring stuff. */
if ((space = H5A_object(sid)) == NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
ret_value = H5S_is_simple(space);
done:
if (ret_value == FAIL) { /* Error condition cleanup */
- } /* end if */
+ } /* end if */
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
}
@@ -900,14 +975,14 @@ H5Sis_simple(hid_t sid)
Determine the size of a dataspace
USAGE
herr_t H5Sset_space(sid, rank, dims)
- hid_t sid; IN: Dataspace object to query
- intn rank; IN: # of dimensions for the dataspace
- const size_t *dims; IN: Size of each dimension for the dataspace
+ hid_t sid; IN: Dataspace object to query
+ intn rank; IN: # of dimensions for the dataspace
+ const size_t *dims; IN: Size of each dimension for the dataspace
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function sets the number and size of each dimension in the
- dataspace. Setting RANK to a value of zero allows scalar objects to be
+ This function sets the number and size of each dimension in the
+ dataspace. Setting RANK to a value of zero allows scalar objects to be
created. Dimensions are specified from slowest to fastest changing in the
DIMS array (i.e. 'C' order). Setting the size of a dimension to zero
indicates that the dimension is of unlimited size and should be allowed to
@@ -917,17 +992,17 @@ H5Sis_simple(hid_t sid)
herr_t
H5Sset_space(hid_t sid, int rank, const size_t *dims)
{
- H5S_t *space = NULL; /* dataspace to modify */
- intn u; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ H5S_t *space = NULL; /* dataspace to modify */
+ intn u; /* local counting variable */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER(H5Sset_space, FAIL);
/* Check args */
if ((space = H5A_object(sid)) == NULL)
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
+ HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
if (rank > 0 && dims == NULL)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified");
if (rank<0)
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank");
if (dims) {
@@ -943,52 +1018,52 @@ H5Sset_space(hid_t sid, int rank, const size_t *dims)
switch (space->type) {
case H5S_SCALAR:
case H5S_SIMPLE:
- /* do nothing */
- break;
+ /* do nothing */
+ break;
case H5S_COMPLEX:
- /*
- * eventually this will destroy whatever "complex" dataspace info
- * is retained, right now it's an error
- */
- /* Fall through to report error */
+ /*
+ * eventually this will destroy whatever "complex" dataspace info
+ * is retained, right now it's an error
+ */
+ /* Fall through to report error */
default:
- HRETURN_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL,
+ HRETURN_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL,
"unknown data space class");
}
space->type = H5S_SIMPLE;
/* Reset hyperslab definition, if one is defined */
if(space->hslab_def==TRUE) {
- H5MM_xfree(space->h.start);
- H5MM_xfree(space->h.count);
- H5MM_xfree(space->h.stride);
- space->hslab_def=FALSE;
+ H5MM_xfree(space->h.start);
+ H5MM_xfree(space->h.count);
+ H5MM_xfree(space->h.stride);
+ space->hslab_def=FALSE;
}
- if (rank == 0) { /* scalar variable */
- space->type = H5S_SCALAR;
- space->u.simple.rank = 0; /* set to scalar rank */
- if (space->u.simple.size != NULL)
- space->u.simple.size = H5MM_xfree(space->u.simple.size);
- if (space->u.simple.max != NULL)
- space->u.simple.max = H5MM_xfree(space->u.simple.max);
- if (space->u.simple.perm != NULL)
- space->u.simple.max = H5MM_xfree(space->u.simple.perm);
+ if (rank == 0) { /* scalar variable */
+ space->type = H5S_SCALAR;
+ space->u.simple.rank = 0; /* set to scalar rank */
+ if (space->u.simple.size != NULL)
+ space->u.simple.size = H5MM_xfree(space->u.simple.size);
+ if (space->u.simple.max != NULL)
+ space->u.simple.max = H5MM_xfree(space->u.simple.max);
+ if (space->u.simple.perm != NULL)
+ space->u.simple.max = H5MM_xfree(space->u.simple.perm);
} else {
- /* Free the old space for now */
- if (space->u.simple.size != NULL)
- space->u.simple.size = H5MM_xfree(space->u.simple.size);
- if (space->u.simple.max != NULL)
- space->u.simple.max = H5MM_xfree(space->u.simple.max);
- if (space->u.simple.perm != NULL)
- space->u.simple.perm = H5MM_xfree(space->u.simple.perm);
-
- /* Set the rank and copy the dims */
- space->u.simple.rank = rank;
- space->u.simple.size = H5MM_xcalloc(rank, sizeof(size_t));
- HDmemcpy(space->u.simple.size, dims, sizeof(size_t) * rank);
+ /* Free the old space for now */
+ if (space->u.simple.size != NULL)
+ space->u.simple.size = H5MM_xfree(space->u.simple.size);
+ if (space->u.simple.max != NULL)
+ space->u.simple.max = H5MM_xfree(space->u.simple.max);
+ if (space->u.simple.perm != NULL)
+ space->u.simple.perm = H5MM_xfree(space->u.simple.perm);
+
+ /* Set the rank and copy the dims */
+ space->u.simple.rank = rank;
+ space->u.simple.size = H5MM_xcalloc(rank, sizeof(size_t));
+ HDmemcpy(space->u.simple.size, dims, sizeof(size_t) * rank);
}
FUNC_LEAVE(ret_value);
@@ -1001,14 +1076,14 @@ H5Sset_space(hid_t sid, int rank, const size_t *dims)
Select a hyperslab from a simple dataspace
USAGE
herr_t H5Sset_hyperslab(sid, start, count, stride)
- hid_t sid; IN: Dataspace object to select hyperslab from
- const int *start; IN: Starting location for hyperslab to select
- const size_t *count; IN: Number of elements in hyperslab
- const size_t *stride; IN: Packing of elements in hyperslab
+ hid_t sid; IN: Dataspace object to select hyperslab from
+ const int *start; IN: Starting location for hyperslab to select
+ const size_t *count; IN: Number of elements in hyperslab
+ const size_t *stride; IN: Packing of elements in hyperslab
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function selects a hyperslab from a simple dataspace. The stride
+ This function selects a hyperslab from a simple dataspace. The stride
array may be used to sub-sample the hyperslab chosen, a value of 1 in each
position of the stride array selects contiguous elements in the array,
a value of 2 selects every other element, etc. If the stride parameter is
@@ -1019,63 +1094,63 @@ H5Sset_space(hid_t sid, int rank, const size_t *dims)
herr_t
H5Sset_hyperslab(hid_t sid, const int *start, const size_t *count, const size_t *stride)
{
- H5S_t *space = NULL; /* dataspace to modify */
- size_t *tmp_stride=NULL; /* temp. copy of stride */
- intn u; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ H5S_t *space = NULL; /* dataspace to modify */
+ size_t *tmp_stride=NULL; /* temp. copy of stride */
+ intn u; /* local counting variable */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER(H5Sset_hyperslab, FAIL);
/* Get the object */
if (H5_DATASPACE != H5A_group(sid) || (space = H5A_object(sid)) == NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
if (start == NULL || count==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"invalid hyperslab selected");
/* We can't modify other types of dataspaces currently, so error out */
if (space->type!=H5S_SIMPLE)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL,
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL,
"unknown dataspace type");
/* Set up stride values for later use */
tmp_stride= H5MM_xmalloc(space->u.simple.rank*sizeof(tmp_stride[0]));
for (u=0; u<space->u.simple.rank; u++) {
- tmp_stride[u] = stride ? stride[u] : 1;
+ tmp_stride[u] = stride ? stride[u] : 1;
}
/* Range check arguments */
for (u=0; u<space->u.simple.rank; u++) {
- if (start[u]<0 || start[u]>=space->u.simple.size[u]) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL,
+ if (start[u]<0 || start[u]>=space->u.simple.size[u]) {
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL,
"hyperslab bounds out of range");
}
if (start[u]<0 ||
start[u]+(count[u]*tmp_stride[u])>space->u.simple.size[u]) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL,
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL,
"hyperslab bounds out of range");
}
}
/* Allocate space for the hyperslab information */
if (NULL==space->h.start) {
- space->h.start= H5MM_xcalloc(space->u.simple.rank,sizeof(intn));
- space->h.count= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t));
- space->h.stride= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t));
+ space->h.start= H5MM_xcalloc(space->u.simple.rank,sizeof(intn));
+ space->h.count= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t));
+ space->h.stride= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t));
}
/* Build hyperslab */
for(u=0; u<space->u.simple.rank; u++) {
- space->h.start[u] = start[u];
- space->h.count[u] = count[u];
- space->h.stride[u] = tmp_stride[u];
+ space->h.start[u] = start[u];
+ space->h.count[u] = count[u];
+ space->h.stride[u] = tmp_stride[u];
}
space->hslab_def=TRUE;
done:
- if (ret_value == FAIL) { /* Error condition cleanup */
+ if (ret_value == FAIL) { /* Error condition cleanup */
- } /* end if */
+ } /* end if */
/* Normal function cleanup */
H5MM_xfree(tmp_stride);
@@ -1086,7 +1161,7 @@ done:
* Function: H5Sget_hyperslab
*
* Purpose: Retrieves information about the hyperslab from a simple data
- * space. If no hyperslab has been defined then the hyperslab
+ * space. If no hyperslab has been defined then the hyperslab
* is the same as the entire array.
*
* Return: Success: Hyperslab dimensionality.
@@ -1094,7 +1169,7 @@ done:
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Wednesday, January 28, 1998
+ * Wednesday, January 28, 1998
*
* Modifications:
*
@@ -1127,7 +1202,7 @@ H5Sget_hyperslab (hid_t sid, int offset[]/*out*/, size_t size[]/*out*/,
* Function: H5S_get_hyperslab
*
* Purpose: Retrieves information about the hyperslab from a simple data
- * space. If no hyperslab has been defined then the hyperslab
+ * space. If no hyperslab has been defined then the hyperslab
* is the same as the entire array.
*
* Return: Success: Hyperslab dimensionality.
@@ -1135,7 +1210,7 @@ H5Sget_hyperslab (hid_t sid, int offset[]/*out*/, size_t size[]/*out*/,
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Wednesday, January 28, 1998
+ * Wednesday, January 28, 1998
*
* Modifications:
*
@@ -1197,7 +1272,7 @@ H5S_get_hyperslab (const H5S_t *ds, int offset[]/*out*/,
* Failure: NULL
*
* Programmer: Robb Matzke
- * Wednesday, January 21, 1998
+ * Wednesday, January 21, 1998
*
* Modifications:
*
@@ -1207,7 +1282,7 @@ const H5S_conv_t *
H5S_find (const H5S_t *mem_space, const H5S_t *file_space)
{
static H5S_conv_t _conv;
- static const H5S_conv_t *conv = NULL;
+ static const H5S_conv_t *conv = NULL;
FUNC_ENTER (H5S_find, NULL);
@@ -1251,7 +1326,7 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space)
* Failure: FAIL
*
* Programmer: Robb Matzke
- * Friday, January 30, 1998
+ * Friday, January 30, 1998
*
* Modifications:
*
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index 25e758e..79d7bf2 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -93,8 +93,10 @@ typedef struct H5S_tconv_t {
H5S_t *H5S_copy (const H5S_t *src);
herr_t H5S_close (H5S_t *ds);
size_t H5S_get_npoints (const H5S_t *ds);
+size_t H5S_get_npoints_max(const H5S_t *ds);
intn H5S_get_ndims (const H5S_t *ds);
-intn H5S_get_dims (const H5S_t *ds, size_t dims[]/*out*/);
+intn H5S_get_dims (const H5S_t *ds, size_t dims[]/*out*/,
+ size_t max_dims[]/*out*/);
herr_t H5S_modify (H5G_entry_t *ent, const H5S_t *space);
H5S_t *H5S_read (H5F_t *f, H5G_entry_t *ent);
intn H5S_cmp (const H5S_t *ds1, const H5S_t *ds2);
diff --git a/src/H5Spublic.h b/src/H5Spublic.h
index 3fe0a31..784ca53 100644
--- a/src/H5Spublic.h
+++ b/src/H5Spublic.h
@@ -22,7 +22,7 @@
/* Define atomic datatypes */
#define H5S_ALL (-2)
-#define H5S_UNLIMITED 0
+#define H5S_UNLIMITED ((size_t)(-1L))
/* Different types of dataspaces */
typedef enum H5S_class_t {
diff --git a/src/H5Ssimp.c b/src/H5Ssimp.c
index 99900c2..6f4dd4f 100644
--- a/src/H5Ssimp.c
+++ b/src/H5Ssimp.c
@@ -243,7 +243,7 @@ H5S_simp_mscat (const void *tconv_buf, size_t elmt_size,
"hyperslab sampling is not implemented yet");
}
}
- if (H5S_get_dims (mem_space, mem_size)<0) {
+ if (H5S_get_dims (mem_space, mem_size, NULL)<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
"unable to retrieve data space dimensions");
}
@@ -348,7 +348,7 @@ H5S_simp_mgath (const void *buf, size_t elmt_size,
"hyperslab sampling is not implemented yet");
}
}
- if (H5S_get_dims (mem_space, mem_size)<0) {
+ if (H5S_get_dims (mem_space, mem_size, NULL)<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0,
"unable to retrieve data space dimensions");
}
diff --git a/src/H5T.c b/src/H5T.c
index d7fca16..6a3e2e0 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -1774,7 +1774,7 @@ H5Tset_strpad(hid_t type_id, H5T_str_t strpad)
*
*-------------------------------------------------------------------------
*/
-intn
+int
H5Tget_nmembers(hid_t type_id)
{
diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h
index 665295a..db72bab 100644
--- a/src/H5Tpublic.h
+++ b/src/H5Tpublic.h
@@ -206,7 +206,7 @@ size_t H5Tget_ebias (hid_t type_id);
H5T_norm_t H5Tget_norm (hid_t type_id);
H5T_pad_t H5Tget_inpad (hid_t type_id);
H5T_str_t H5Tget_strpad (hid_t type_id);
-intn H5Tget_nmembers (hid_t type_id);
+int H5Tget_nmembers (hid_t type_id);
char *H5Tget_member_name (hid_t type_id, int membno);
size_t H5Tget_member_offset (hid_t type_id, int membno);
int H5Tget_member_dims (hid_t type_id, int membno, size_t dims[]/*out*/,
diff --git a/src/H5V.c b/src/H5V.c
index 41ed33a..e686e29 100644
--- a/src/H5V.c
+++ b/src/H5V.c
@@ -41,7 +41,7 @@ static hbool_t interface_initialize_g = TRUE;
*/
herr_t
H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size,
- intn *stride1)
+ ssize_t *stride1)
{
FUNC_ENTER(H5V_stride_optimize1, FAIL);
@@ -54,10 +54,10 @@ H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size,
/*
* Combine adjacent memory accesses
*/
- while (*np && stride1[*np - 1] == *elmt_size) {
- *elmt_size *= size[*np - 1];
+ while (*np && stride1[*np-1] == *elmt_size) {
+ *elmt_size *= size[*np-1];
if (--*np) {
- stride1[*np - 1] += size[*np] * stride1[*np];
+ stride1[*np-1] += size[*np] * stride1[*np];
}
}
@@ -88,7 +88,7 @@ H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size,
*/
herr_t
H5V_stride_optimize2(intn *np, size_t *elmt_size, size_t *size,
- intn *stride1, intn *stride2)
+ ssize_t *stride1, ssize_t *stride2)
{
FUNC_ENTER(H5V_stride_optimize2, FAIL);
@@ -101,12 +101,12 @@ H5V_stride_optimize2(intn *np, size_t *elmt_size, size_t *size,
/*
* Combine adjacent memory accesses
*/
- while (*np && stride1[*np - 1] == *elmt_size &&
- stride2[*np - 1] == *elmt_size) {
- *elmt_size *= size[*np - 1];
+ while (*np && stride1[*np-1] == *elmt_size &&
+ stride2[*np-1] == *elmt_size) {
+ *elmt_size *= size[*np-1];
if (--*np) {
- stride1[*np - 1] += size[*np] * stride1[*np];
- stride2[*np - 1] += size[*np] * stride2[*np];
+ stride1[*np-1] += size[*np] * stride1[*np];
+ stride2[*np-1] += size[*np] * stride2[*np];
}
}
@@ -145,7 +145,7 @@ H5V_stride_optimize2(intn *np, size_t *elmt_size, size_t *size,
size_t
H5V_hyper_stride(intn n, const size_t *size,
const size_t *total_size, const size_t *offset,
- intn *stride/*out*/)
+ ssize_t *stride/*out*/)
{
size_t skip; /*starting point byte offset */
size_t acc; /*accumulator */
@@ -165,9 +165,9 @@ H5V_hyper_stride(intn n, const size_t *size,
/* others */
for (i = n - 2, acc = 1; i >= 0; --i) {
size_t tmp = acc * (total_size[i+1] - size[i+1]);
- assert (tmp<((size_t)1<<(8*sizeof(intn)-1)));
- stride[i] = (intn)tmp;
- acc *= total_size[i + 1];
+ assert (tmp<((size_t)1<<(8*sizeof(ssize_t)-1)));
+ stride[i] = (size_t)tmp; /*overflow checked*/
+ acc *= total_size[i+1];
skip += acc * (offset ? offset[i] : 0);
}
@@ -290,7 +290,7 @@ H5V_hyper_fill(intn n, const size_t *_size,
{
uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */
size_t size[H5V_HYPER_NDIMS]; /*a modifiable copy of _size */
- intn dst_stride[H5V_HYPER_NDIMS]; /*destination stride info */
+ ssize_t dst_stride[H5V_HYPER_NDIMS]; /*destination stride info */
size_t dst_start; /*byte offset to start of stride*/
size_t elmt_size = 1; /*bytes per element */
herr_t status; /*function return status */
@@ -373,8 +373,8 @@ H5V_hyper_copy(intn n, const size_t *_size,
const uint8 *src = (const uint8 *)_src; /*cast for ptr arithmtc */
uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmtc */
size_t size[H5V_HYPER_NDIMS]; /*a modifiable _size */
- intn src_stride[H5V_HYPER_NDIMS]; /*source stride info */
- intn dst_stride[H5V_HYPER_NDIMS]; /*dest stride info */
+ ssize_t src_stride[H5V_HYPER_NDIMS]; /*source stride info */
+ ssize_t dst_stride[H5V_HYPER_NDIMS]; /*dest stride info */
size_t dst_start, src_start; /*offset to start at */
size_t elmt_size = 1; /*element size in bytes */
herr_t status; /*return status */
@@ -436,7 +436,7 @@ H5V_hyper_copy(intn n, const size_t *_size,
*/
herr_t
H5V_stride_fill(intn n, size_t elmt_size, const size_t *size,
- const intn *stride, void *_dst, uint8 fill_value)
+ const ssize_t *stride, void *_dst, uint8 fill_value)
{
uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */
size_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */
@@ -457,10 +457,8 @@ H5V_stride_fill(intn n, size_t elmt_size, const size_t *size,
for (j = n - 1, carry = TRUE; j >= 0 && carry; --j) {
dst += stride[j];
- if (--idx[j])
- carry = FALSE;
- else
- idx[j] = size[j];
+ if (--idx[j]) carry = FALSE;
+ else idx[j] = size[j];
}
}
@@ -492,8 +490,8 @@ H5V_stride_fill(intn n, size_t elmt_size, const size_t *size,
*/
herr_t
H5V_stride_copy(intn n, size_t elmt_size, const size_t *size,
- const intn *dst_stride, void *_dst,
- const intn *src_stride, const void *_src)
+ const ssize_t *dst_stride, void *_dst,
+ const ssize_t *src_stride, const void *_src)
{
uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic*/
const uint8 *src = (const uint8 *) _src; /*cast for ptr arithmetic*/
@@ -547,11 +545,11 @@ herr_t
H5V_stride_copy2(size_t nelmts, size_t elmt_size,
/* destination */
- intn dst_n, const size_t *dst_size, const intn *dst_stride,
+ intn dst_n, const size_t *dst_size, const ssize_t *dst_stride,
void *_dst,
/* source */
- intn src_n, const size_t *src_size, const intn *src_stride,
+ intn src_n, const size_t *src_size, const ssize_t *src_stride,
const void *_src)
{
uint8 *dst = (uint8 *) _dst;
diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h
index f0cda44..863fd2e 100644
--- a/src/H5Vprivate.h
+++ b/src/H5Vprivate.h
@@ -29,7 +29,7 @@
#define H5V_ZERO NULL
size_t H5V_hyper_stride(intn n, const size_t *size, const size_t *total_size,
- const size_t *offset, intn *stride);
+ const size_t *offset, ssize_t *stride);
hbool_t H5V_hyper_disjointp(intn n, const size_t *offset1,
const size_t *size1, const size_t *offset2,
const size_t *size2);
@@ -42,18 +42,18 @@ herr_t H5V_hyper_copy(intn n, const size_t *size,
void *_dst, const size_t *src_total_size,
const size_t *src_offset, const void *_src);
herr_t H5V_stride_fill(intn n, size_t elmt_size, const size_t *size,
- const intn *stride, void *_dst, uint8 fill_value);
+ const ssize_t *stride, void *_dst, uint8 fill_value);
herr_t H5V_stride_copy(intn n, size_t elmt_size, const size_t *_size,
- const intn *dst_stride, void *_dst,
- const intn *src_stride, const void *_src);
+ const ssize_t *dst_stride, void *_dst,
+ const ssize_t *src_stride, const void *_src);
herr_t H5V_stride_copy2(size_t nelmts, size_t elmt_size, intn dst_n,
- const size_t *dst_size, const intn *dst_stride,
+ const size_t *dst_size, const ssize_t *dst_stride,
void *_dst, intn src_n, const size_t *src_size,
- const intn *src_stride, const void *_src);
+ const ssize_t *src_stride, const void *_src);
herr_t H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size,
- intn *stride1);
+ ssize_t *stride1);
herr_t H5V_stride_optimize2(intn *np, size_t *elmt_size, size_t *size,
- intn *stride1, intn *stride2);
+ ssize_t *stride1, ssize_t *stride2);
/*-------------------------------------------------------------------------
diff --git a/src/H5private.h b/src/H5private.h
index 49437cc..10f5161 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -107,12 +107,87 @@
#endif
/*
+ * Numeric data types
+ */
+typedef char char8;
+typedef signed char int8;
+typedef unsigned char uchar8, uint8;
+
+#if SIZEOF_SHORT==2
+typedef short int16;
+typedef unsigned short uint16;
+#else
+typedef int int16; /*not really */
+typedef unsigned uint16; /*not really */
+#endif
+
+#if SIZEOF_INT==4
+typedef int int32;
+typedef unsigned int uint32;
+#elif SIZEOF_LONG==4
+typedef long int32;
+typedef unsigned long uint32;
+#else
+typedef int int32; /*not really */
+typedef unsigned uint32; /*not really */
+#endif
+
+#if SIZEOF_INT==8
+typedef int int64;
+typedef unsigned uint64;
+#elif SIZEOF_LONG==8
+typedef long int64;
+typedef unsigned long uint64;
+#elif SIZEOF_LONG_LONG==8
+typedef long long int64;
+typedef unsigned long long uint64;
+#else
+# error "no 64-bit integer type"
+#endif
+
+#if SIZEOF_FLOAT==4
+typedef float float32;
+#else
+typedef float float32; /*not really */
+#endif
+
+#if SIZEOF_FLOAT==8
+typedef float float64;
+#elif SIZEOF_DOUBLE==8
+typedef double float64;
+#else
+# error "no 64-bit floating point type"
+#endif
+
+/*
+ * Define a type for generic integers. Use this instead of `int' to
+ * show that some thought went into the algorithm.
+ */
+typedef int intn;
+typedef unsigned uintn;
+
+/*
+ * Status return values for the `herr_t' type.
+ * Since some unix/c routines use 0 and -1 (or more precisely, non-negative
+ * vs. negative) as their return code, and some assumption had been made in
+ * the code about that, it is important to keep these constants the same
+ * values. When checking the success or failure of an integer-valued
+ * function, remember to compare against zero and not one of these two
+ * values.
+ */
+#define SUCCEED 0
+#define FAIL (-1)
+#define UFAIL (unsigned)(-1)
+
+/*
* File addresses.
*/
typedef struct {
uint64 offset; /*offset within an HDF5 file */
} haddr_t;
+#define H5F_ADDR_UNDEF {((uint64)(-1L))}
+
/*
* Some compilers have problems declaring auto variables that point
* to string constants. Use the CONSTR() macro so it's easy to fix
diff --git a/src/H5public.h b/src/H5public.h
index ed7933f..912d935 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -24,79 +24,17 @@
#endif
/*
- * Data types
+ * Status return values. Failed integer functions in HDF5 result almost
+ * always in a negative value (unsigned failing functions sometimes return
+ * zero for failure) while successfull return is non-negative (often zero).
+ * The negative failure value is most commonly -1, but don't bet on it. The
+ * proper way to detect failure is something like:
+ *
+ * if ((dset = H5Dopen (file, name))<0) {
+ * fprintf (stderr, "unable to open the requested dataset\n");
+ * }
*/
-typedef char char8;
-typedef signed char int8;
-typedef unsigned char uchar8, uint8;
-
-#if SIZEOF_SHORT==2
-typedef short int16;
-typedef unsigned short uint16;
-#else
-typedef int int16; /*not really */
-typedef unsigned uint16; /*not really */
-#endif
-
-#if SIZEOF_INT==4
-typedef int int32;
-typedef unsigned int uint32;
-#elif SIZEOF_LONG==4
-typedef long int32;
-typedef unsigned long uint32;
-#else
-typedef int int32; /*not really */
-typedef unsigned uint32; /*not really */
-#endif
-
-#if SIZEOF_INT==8
-typedef int int64;
-typedef unsigned uint64;
-#elif SIZEOF_LONG==8
-typedef long int64;
-typedef unsigned long uint64;
-#elif SIZEOF_LONG_LONG==8
-typedef long long int64;
-typedef unsigned long long uint64;
-#else
-# error "no 64-bit integer type"
-#endif
-
-#if SIZEOF_FLOAT==4
-typedef float float32;
-#else
-typedef float float32; /*not really */
-#endif
-
-#if SIZEOF_FLOAT==8
-typedef float float64;
-#elif SIZEOF_DOUBLE==8
-typedef double float64;
-#else
-# error "no 64-bit floating point type"
-#endif
-
-/*
- * Define a type for generic integers. Use this instead of `int' to
- * show that some thought went into the algorithm.
- */
-typedef int intn;
-typedef unsigned uintn;
-
-/*
- * Status return values.
- * Since some unix/c routines use 0 and -1 (or more precisely, non-negative
- * vs. negative) as their return code, and some assumption had been made in
- * the code about that, it is important to keep these constants the same
- * values. When checking the success or failure of an integer-valued
- * function, remember to compare against zero and not one of these two
- * values.
- */
-typedef intn herr_t;
-
-#define SUCCEED 0
-#define FAIL (-1)
-#define UFAIL (unsigned)(-1)
+typedef int herr_t;
/*
* Boolean type.
@@ -111,7 +49,8 @@ extern "C" {
herr_t H5open (void);
herr_t H5close (void);
herr_t H5dont_atexit (void);
-herr_t H5version (uintn *majnum, uintn *minnum, uintn *relnum, uintn *patnum);
+herr_t H5version (unsigned *majnum, unsigned *minnum, unsigned *relnum,
+ unsigned *patnum);
#ifdef __cplusplus
}
diff --git a/test/Makefile.in b/test/Makefile.in
index 3c61e91..826ad23 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -11,7 +11,7 @@ CPPFLAGS=-I. -I../src @CPPFLAGS@
# These are our main targets. They should be listed in the order to be
# executed, generally most specific tests to least specific tests.
-PROGS=testhdf5 hyperslab istore dtypes dsets cmpd_dset extend
+PROGS=testhdf5 hyperslab istore dtypes dsets cmpd_dset extend external
TESTS=$(PROGS)
# Temporary files
@@ -23,7 +23,7 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \
# other source lists are for the individual tests, the files of which may
# overlap with other tests.
PROG_SRC=testhdf5.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c dtypes.c \
- hyperslab.c istore.c dsets.c cmpd_dset.c extend.c
+ hyperslab.c istore.c dsets.c cmpd_dset.c extend.c external.c
PROG_OBJ=$(PROG_SRC:.c=.o)
TESTHDF5_SRC=testhdf5.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c
@@ -47,6 +47,9 @@ CMPD_DSET_OBJ=$(CMPD_DSET_SRC:.c=.o)
EXTEND_SRC=extend.c
EXTEND_OBJ=$(EXTEND_SRC:.c=.o)
+EXTERNAL_SRC=external.c
+EXTERNAL_OBJ=$(EXTERNAL_SRC:.c=.o)
+
# Private header files (not to be installed)...
PRIVATE_HDR=testhdf5.h
@@ -72,4 +75,7 @@ cmpd_dset: $(CMPD_DSET_OBJ) ../src/libhdf5.a
extend: $(EXTEND_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(EXTEND_OBJ) ../src/libhdf5.a $(LIBS)
+external: $(EXTERNAL_OBJ) ../src/libhdf5.a
+ $(CC) $(CFLAGS) -o $@ $(EXTERNAL_OBJ) ../src/libhdf5.a $(LIBS)
+
@CONCLUDE@
diff --git a/test/dsets.c b/test/dsets.c
index 8b373b0..df19ba1 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -31,9 +31,9 @@
*
* Purpose: Attempts to create a dataset.
*
- * Return: Success: SUCCEED
+ * Return: Success: 0
*
- * Failure: FAIL
+ * Failure: -1
*
* Programmer: Robb Matzke
* Tuesday, December 9, 1997
@@ -56,7 +56,7 @@ test_create(hid_t file)
dims[0] = 256;
dims[1] = 512;
space = H5Screate_simple(2, dims, NULL);
- assert(space != FAIL);
+ assert(space>=0);
/*
* Create a dataset using the default dataset creation properties. We're
@@ -171,10 +171,10 @@ test_create(hid_t file)
goto error;
}
puts(" PASSED");
- return SUCCEED;
+ return 0;
error:
- return FAIL;
+ return -1;
}
/*-------------------------------------------------------------------------
@@ -184,9 +184,9 @@ test_create(hid_t file)
* multi-dimensional array without data type or data space
* conversions, without compression, and stored contiguously.
*
- * Return: Success: SUCCEED
+ * Return: Success: 0
*
- * Failure: FAIL
+ * Failure: -1
*
* Programmer: Robb Matzke
* Wednesday, December 10, 1997
@@ -217,7 +217,7 @@ test_simple_io(hid_t file)
dims[0] = 100;
dims[1] = 200;
space = H5Screate_simple(2, dims, NULL);
- assert(space != FAIL);
+ assert(space>=0);
/* Create the dataset */
dataset = H5Dcreate(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space,
@@ -264,10 +264,10 @@ test_simple_io(hid_t file)
H5Dclose(dataset);
puts(" PASSED");
- return SUCCEED;
+ return 0;
error:
- return FAIL;
+ return -1;
}
/*-------------------------------------------------------------------------
@@ -275,9 +275,9 @@ test_simple_io(hid_t file)
*
* Purpose: Test some simple data type conversion stuff.
*
- * Return: Success: SUCCEED
+ * Return: Success: 0
*
- * Failure: FAIL
+ * Failure: -1
*
* Programmer: Robb Matzke
* Wednesday, January 14, 1998
@@ -289,8 +289,8 @@ test_simple_io(hid_t file)
static herr_t
test_tconv(hid_t file)
{
- uint8 *out=NULL, *in=NULL;
- intn i;
+ char *out=NULL, *in=NULL;
+ int i;
size_t dims[1];
hid_t space, dataset, type;
herr_t status;
@@ -303,13 +303,17 @@ test_tconv(hid_t file)
printf("%-70s", "Testing data type conversion");
/* Initialize the dataset */
- for (i = 0; i < 1000000; i++)
- ((int32 *) out)[i] = 0x11223344;
+ for (i = 0; i < 1000000; i++) {
+ out[i*4+0] = 0x11;
+ out[i*4+1] = 0x22;
+ out[i*4+2] = 0x33;
+ out[i*4+3] = 0x44;
+ }
/* Create the data space */
dims[0] = 1000000;
space = H5Screate_simple (1, dims, NULL);
- assert(space != FAIL);
+ assert(space >= 0);
/* Create the data set */
dataset = H5Dcreate(file, DSET_TCONV_NAME, H5T_NATIVE_INT32, space,
@@ -351,7 +355,7 @@ test_tconv(hid_t file)
H5Tclose(type);
puts(" PASSED");
- return SUCCEED;
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -375,7 +379,7 @@ main(void)
{
hid_t file;
herr_t status;
- intn nerrors = 0;
+ int nerrors = 0;
status = H5open ();
assert (status>=0);
diff --git a/test/dtypes.c b/test/dtypes.c
index da0076a..0b4ae7b 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -89,7 +89,10 @@ test_classes(void)
static herr_t
test_copy(void)
{
- hid_t a_copy;
+ hid_t a_copy;
+ herr_t status;
+ herr_t (*func)(void*) = NULL;
+ void *client_data = NULL;
printf("%-70s", "Testing H5Tcopy()");
@@ -109,7 +112,14 @@ test_copy(void)
}
goto error;
}
- if (H5Tclose(H5T_NATIVE_CHAR) >= 0) {
+
+ /* Temporarily turn off error reporting. */
+ H5Eget_auto (&func, &client_data);
+ H5Eset_auto (NULL, NULL);
+ status = H5Tclose (H5T_NATIVE_CHAR);
+ H5Eset_auto (func, client_data);
+
+ if (status >= 0) {
puts("*FAILED*");
if (!isatty(1)) {
AT();
@@ -159,7 +169,7 @@ test_compound(void)
}
goto error;
}
- /* Add a coupld fields */
+ /* Add a couple fields */
status = H5Tinsert(complex_id, "real", HOFFSET(tmp, re),
H5T_NATIVE_DOUBLE);
if (status < 0) {
diff --git a/test/extend.c b/test/extend.c
index 2cadb1c..7b6ba60 100644
--- a/test/extend.c
+++ b/test/extend.c
@@ -5,7 +5,7 @@
* Programmer: Robb Matzke <matzke@llnl.gov>
* Friday, January 30, 1998
*
- * Purpose: Tests extendable datasets.
+ * Purpose: Tests extendible datasets.
*/
#include <assert.h>
#include <hdf5.h>
@@ -17,7 +17,7 @@
/*-------------------------------------------------------------------------
* Function: main
*
- * Purpose: Tests extendable datasets
+ * Purpose: Tests extendible datasets
*
* Return: Success: exit(0)
*
diff --git a/test/external.c b/test/external.c
new file mode 100644
index 0000000..36c9cdf
--- /dev/null
+++ b/test/external.c
@@ -0,0 +1,550 @@
+/*
+ * Copyright (C) 1998 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Tuesday, March 3, 1998
+ *
+ * Purpose: Tests datasets stored in external raw files.
+ */
+#include <assert.h>
+#include <fcntl.h>
+#include <hdf5.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+/*-------------------------------------------------------------------------
+ * Function: display_error_cb
+ *
+ * Purpose: Displays the error stack after printing "*FAILED*".
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, March 4, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+display_error_cb (void *client_data)
+{
+ puts ("*FAILED*");
+ H5Eprint (stdout);
+ return 0;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_1
+ *
+ * Purpose: Describes various external datasets in an HDF5 file without
+ * actually creating the external raw files.
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, March 3, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_1 (void)
+{
+ hid_t file, plist, space, dset, grp;
+ herr_t status;
+ size_t size[2], max_size[2];
+ herr_t (*func)(void*) = NULL;
+ void *client_data = NULL;
+ int n;
+
+
+ /*
+ * Create the file and an initial group. This causes messages about
+ * debugging to be emitted before we start playing games with what the
+ * output looks like.
+ */
+ file = H5Fcreate ("extern_1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ assert (file>=0);
+ grp = H5Gcreate (file, "emit-diagnostics", 8);
+ H5Gclose (grp);
+
+ printf ("Testing external storage descriptions...\n");
+
+ /*
+ * A single external file for a non-extendible dataset.
+ */
+ do {
+ printf ("%-70s", "...fixed-size data space, exact storage");
+ fflush (stdout);
+ plist = H5Pcreate (H5P_DATASET_CREATE);
+ assert (plist>=0);
+ status = H5Pset_external (plist, "ext1.data", 0, 400);
+ assert (status>=0);
+
+ size[0] = max_size[0] = 100;
+ space = H5Screate_simple (1, size, max_size);
+ assert (space>=0);
+
+ /* Create the dataset, the `dset1' name is used later too */
+ dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT32, space, plist);
+ if (dset<0) break;
+ H5Dclose (dset);
+ puts (" PASSED");
+ } while (0);
+ H5Sclose (space);
+ H5Pclose (plist);
+
+ /*
+ * A single external file which is too small to represent all the data.
+ */
+ do {
+ printf ("%-70s", "...external storage is too small");
+ fflush (stdout);
+ plist = H5Pcreate (H5P_DATASET_CREATE);
+ assert (plist>=0);
+ status = H5Pset_external (plist, "ext1.data", 0, 399);
+ assert (status>=0);
+
+ size[0] = max_size[0] = 100;
+ space = H5Screate_simple (1, size, max_size);
+ assert (space>=0);
+
+ H5Eget_auto (&func, &client_data);
+ H5Eset_auto (NULL, NULL);
+ dset = H5Dcreate (file, "dset2", H5T_NATIVE_INT32, space, plist);
+ H5Eset_auto (func, client_data);
+
+ if (dset>=0) {
+ puts ("*FAILED*");
+ printf (" Small external file succeeded instead of failing\n");
+ H5Dclose (dset);
+ break;
+ }
+ puts (" PASSED");
+ } while (0);
+ H5Sclose (space);
+ H5Pclose (plist);
+
+ /*
+ * A single external file which is large enough to represent the current
+ * data and large enough to represent the eventual size of the data.
+ */
+ do {
+ printf ("%-70s", "...extendible dataspace, exact external size");
+ fflush (stdout);
+ plist = H5Pcreate (H5P_DATASET_CREATE);
+ assert (plist>=0);
+ status = H5Pset_external (plist, "ext1.data", 0, 800);
+ assert (status>=0);
+
+ size[0] = 100;
+ max_size[0] = 200;
+ space = H5Screate_simple (1, size, max_size);
+ assert (space>=0);
+
+ dset = H5Dcreate (file, "dset3", H5T_NATIVE_INT32, space, plist);
+ if (dset<0) break;
+ H5Dclose (dset);
+ puts (" PASSED");
+ } while (0);
+ H5Sclose (space);
+ H5Pclose (plist);
+
+
+ /*
+ * A single external file which is large enough for the current data size
+ * but not large enough for the eventual size.
+ */
+ do {
+ printf ("%-70s", "...extendible dataspace, "
+ "external storage is too small");
+ fflush (stdout);
+ plist = H5Pcreate (H5P_DATASET_CREATE);
+ assert (plist>=0);
+ status = H5Pset_external (plist, "ext1.data", 0, 799);
+ assert (status>=0);
+
+ size[0] = 100;
+ max_size[0] = 200;
+ space = H5Screate_simple (1, size, max_size);
+ assert (space>=0);
+
+ H5Eget_auto (&func, &client_data);
+ H5Eset_auto (NULL, NULL);
+ dset = H5Dcreate (file, "dset4", H5T_NATIVE_INT32, space, plist);
+ H5Eset_auto (func, client_data);
+
+ if (dset>=0) {
+ puts ("*FAILED*");
+ printf (" Small external file succeeded instead of failing\n");
+ H5Dclose (dset);
+ break;
+ }
+ puts (" PASSED");
+ } while (0);
+ H5Sclose (space);
+ H5Pclose (plist);
+
+ /*
+ * A single external file of unlimited size and an unlimited data space.
+ */
+ do {
+ printf ("%-70s", "...unlimited dataspace, unlimited external storage");
+ fflush (stdout);
+ plist = H5Pcreate (H5P_DATASET_CREATE);
+ assert (plist>=0);
+ status = H5Pset_external (plist, "ext1.data", 0, H5F_UNLIMITED);
+ assert (status>=0);
+
+ size[0] = 100;
+ max_size[0] = H5S_UNLIMITED;
+ space = H5Screate_simple (1, size, max_size);
+ assert (space>=0);
+
+ /* Create the dataset, the `dset5' name is used later too */
+ dset = H5Dcreate (file, "dset5", H5T_NATIVE_INT32, space, plist);
+ if (dset<0) break;
+ H5Dclose (dset);
+ puts (" PASSED");
+ } while (0);
+ H5Sclose (space);
+ H5Pclose (plist);
+
+ /*
+ * Open one of the previous datasets and make sure it looks the same as
+ * when we wrote it.
+ */
+ do {
+ char name[256];
+ size_t file_offset;
+ size_t file_size;
+
+ printf ("%-70s", "...opening a dataset and reading the storage info");
+ fflush (stdout);
+
+ dset = H5Dopen (file, "dset1");
+ assert (dset>=0);
+ plist = H5Dget_create_parms (dset);
+ assert (plist>=0);
+
+ n = H5Pget_external_count (plist);
+ if (n<0) break;
+ if (1!=n) {
+ puts ("*FAILED*");
+ printf (" Returned external count is wrong.\n");
+ break;
+ }
+ strcpy (name+sizeof(name)-4, "...");
+ status = H5Pget_external (plist, 0, sizeof(name)-4, name,
+ &file_offset, &file_size);
+ if (status<0) {
+ printf (" Unable to read first extern file info.\n");
+ break;
+ } else if (file_offset!=0) {
+ puts ("*FAILED*");
+ printf (" Wrong file offset.\n");
+ break;
+ } else if (file_size!=400) {
+ puts ("*FAILED*");
+ printf (" Wrong file size.\n");
+ break;
+ }
+ puts (" PASSED");
+ } while (0);
+ H5Pclose (plist);
+ H5Dclose (dset);
+
+ /*
+ * Open one of the previous unlimited datasets and make sure it looks the
+ * same as when we wrote it.
+ */
+ do {
+ char name[256];
+ size_t file_offset;
+ size_t file_size;
+
+ printf ("%-70s", "...opening an unlimited dataset and reading the "
+ "storage info");
+ fflush (stdout);
+
+ dset = H5Dopen (file, "dset5");
+ assert (dset>=0);
+ plist = H5Dget_create_parms (dset);
+ assert (plist>=0);
+
+ n = H5Pget_external_count (plist);
+ if (n<0) break;
+ if (1!=n) {
+ puts ("*FAILED*");
+ printf (" Returned external count is wrong.\n");
+ break;
+ }
+ strcpy (name+sizeof(name)-4, "...");
+ status = H5Pget_external (plist, 0, sizeof(name)-4, name,
+ &file_offset, &file_size);
+ if (status<0) {
+ printf (" Unable to read first extern file info.\n");
+ break;
+ } else if (file_offset!=0) {
+ puts ("*FAILED*");
+ printf (" Wrong file offset.\n");
+ break;
+ } else if (H5F_UNLIMITED!=file_size) {
+ puts ("*FAILED*");
+ printf (" Wrong file size.\n");
+ break;
+ }
+ puts (" PASSED");
+ } while (0);
+ H5Pclose (plist);
+ H5Dclose (dset);
+
+ /*
+ * Multiple external files for a dataset.
+ */
+ do {
+ printf ("%-70s", "...multiple external files");
+ fflush (stdout);
+ plist = H5Pcreate (H5P_DATASET_CREATE);
+ assert (plist>=0);
+ status = H5Pset_external (plist, "ext1.data", 0, 100);
+ assert (status>=0);
+ status = H5Pset_external (plist, "ext2.data", 0, 100);
+ assert (status>=0);
+ status = H5Pset_external (plist, "ext3.data", 0, 100);
+ assert (status>=0);
+ status = H5Pset_external (plist, "ext4.data", 0, 100);
+ assert (status>=0);
+
+ size[0] = max_size[0] = 100;
+ space = H5Screate_simple (1, size, max_size);
+ assert (space>=0);
+
+ dset = H5Dcreate (file, "dset6", H5T_NATIVE_INT32, space, plist);
+ if (dset<0) break;
+ H5Dclose (dset);
+ puts (" PASSED");
+ } while (0);
+ H5Sclose (space);
+ H5Pclose (plist);
+
+ /*
+ * It should be impossible to define an unlimited external file and then
+ * follow it with another external file.
+ */
+ do {
+ printf ("%-70s", "...external file following unlimited file");
+ fflush (stdout);
+ plist = H5Pcreate (H5P_DATASET_CREATE);
+ assert (plist>=0);
+ status = H5Pset_external (plist, "ext1.data", 0, H5F_UNLIMITED);
+ assert (status>=0);
+
+ /* Next function should fail */
+ H5Eget_auto (&func, &client_data);
+ H5Eset_auto (NULL, NULL);
+ status = H5Pset_external (plist, "ext2.data", 0, 100);
+ H5Eset_auto (func, client_data);
+ if (status>=0) {
+ puts ("*FAILED*");
+ puts (" H5Pset_external() succeeded when it should have failed");
+ break;
+ }
+
+ /* Check the number of files */
+ n = H5Pget_external_count (plist);
+ if (n<0) break;
+ if (1!=n) {
+ puts ("*FAILED*");
+ puts (" Wrong external file count returned.");
+ }
+ puts (" PASSED");
+ } while (0);
+ H5Pclose (plist);
+
+ /*
+ * It should be impossible to create a set of external files whose total
+ * size overflows a size_t integer.
+ */
+ do {
+ printf ("%-70s", "...address overflow in external files");
+ fflush (stdout);
+ plist = H5Pcreate (H5P_DATASET_CREATE);
+ assert (plist>=0);
+ status = H5Pset_external (plist, "ext1.data", 0, H5F_UNLIMITED-1);
+ assert (status>=0);
+
+ /* Next function should fail */
+ H5Eget_auto (&func, &client_data);
+ H5Eset_auto (NULL, NULL);
+ status = H5Pset_external (plist, "ext2.data", 0, 100);
+ H5Eset_auto (func, client_data);
+ if (status>=0) {
+ puts ("*FAILED*");
+ puts (" H5Pset_external() succeeded when it should have failed");
+ break;
+ }
+ puts (" PASSED");
+ } while (0);
+ H5Pclose (plist);
+
+
+
+ /* END OF TESTS */
+ H5Fclose (file);
+ return 0;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_2
+ *
+ * Purpose: Tests reading from an external file set.
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, March 4, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_2 (void)
+{
+ hid_t file, plist, space, dset, grp;
+ herr_t status;
+ int fd,i, j;
+ ssize_t n;
+ char fname[64];
+ int part[25], whole[100];
+ size_t size;
+
+ /* Write the data to external files */
+ printf ("Writing external data...\n");
+ for (i=0; i<4; i++) {
+ for (j=0; j<25; j++) {
+ part[j] = i*25+j;
+ }
+
+ sprintf (fname, "extern_%d.raw", i+1);
+ fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ assert (fd>=0);
+ n = write (fd, part, sizeof(part));
+ assert (n==sizeof(part));
+ close (fd);
+ }
+
+ /*
+ * Create the file and an initial group. This causes messages about
+ * debugging to be emitted before we start playing games with what the
+ * output looks like.
+ */
+ file = H5Fcreate ("extern_2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ assert (file>=0);
+ grp = H5Gcreate (file, "emit-diagnostics", 8);
+ H5Gclose (grp);
+ printf ("Testing external data reading...\n");
+
+ /* Create the external file list */
+ plist = H5Pcreate (H5P_DATASET_CREATE);
+ assert (plist>=0);
+ status = H5Pset_external (plist, "extern_1.raw", 0, sizeof(part));
+ assert (status>=0);
+ status = H5Pset_external (plist, "extern_2.raw", 0, sizeof(part));
+ assert (status>=0);
+ status = H5Pset_external (plist, "extern_3.raw", 0, sizeof(part));
+ assert (status>=0);
+ status = H5Pset_external (plist, "extern_4.raw", 0, sizeof(part));
+ assert (status>=0);
+
+ /* Create the data space */
+ size = 100;
+ space = H5Screate_simple (1, &size, NULL);
+ assert (space>=0);
+
+ /* Create the dataset */
+ dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, space, plist);
+ assert (dset>=0);
+
+ /*
+ * Read the entire dataset and compare with the original
+ */
+ do {
+ /* Read from the dataset */
+ printf ("%-70s", "...reading entire dataset");
+ fflush (stdout);
+ status = H5Dread (dset, H5T_NATIVE_INT, space, space,
+ H5P_DEFAULT, whole);
+ if (status<0) {
+ puts (" Failed to read dataset");
+ break;
+ }
+
+ for (i=0; i<100; i++) {
+ if (whole[i]!=i) {
+ puts ("*FAILED*");
+ puts (" Incorrect value(s) read.");
+ break;
+ }
+ }
+ puts (" PASSED");
+ } while (0);
+
+ H5Dclose (dset);
+ H5Pclose (plist);
+ H5Sclose (space);
+ H5Fclose (file);
+ return 0;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Runs external dataset tests.
+ *
+ * Return: Success: exit(0)
+ *
+ * Failure: exit(non-zero)
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, March 3, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main (void)
+{
+ herr_t status;
+ int nerrors=0;
+
+ H5Eset_auto (display_error_cb, NULL);
+
+ status = test_1 ();
+ nerrors += (status<0 ? 1 : 0);
+
+ status = test_2 ();
+ nerrors += (status<0 ? 1 : 0);
+
+ if (0==nerrors) {
+ printf ("All external storage tests passed.\n");
+ }
+
+ exit (nerrors?1:0);
+}
diff --git a/test/hyperslab.c b/test/hyperslab.c
index 2cc7660..0f9f431 100644
--- a/test/hyperslab.c
+++ b/test/hyperslab.c
@@ -1,15 +1,15 @@
/*
* Copyright (C) 1997 NCSA
- * All rights reserved.
+ * All rights reserved.
*
- * Programmer: Robb Matzke <matzke@llnl.gov>
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Friday, October 10, 1997
*
- * Purpose: Hyperslab operations are rather complex, so this file
- * attempts to test them extensively so we can be relatively
- * sure they really work. We only test 1d, 2d, and 3d cases
- * because testing general dimensionalities would require us to
- * rewrite much of the hyperslab stuff.
+ * Purpose: Hyperslab operations are rather complex, so this file
+ * attempts to test them extensively so we can be relatively
+ * sure they really work. We only test 1d, 2d, and 3d cases
+ * because testing general dimensionalities would require us to
+ * rewrite much of the hyperslab stuff.
*/
#include <H5private.h>
#include <H5MMprivate.h>
@@ -19,24 +19,24 @@
#undef __FUNCTION__
#define __FUNCTION__ ""
#endif
-#define AT() printf (" at %s:%d in %s()\n",__FILE__,__LINE__,__FUNCTION__);
+#define AT() printf (" at %s:%d in %s()\n",__FILE__,__LINE__,__FUNCTION__);
-#define TEST_SMALL 0x0001
-#define TEST_MEDIUM 0x0002
+#define TEST_SMALL 0x0001
+#define TEST_MEDIUM 0x0002
-#define VARIABLE_SRC 0
-#define VARIABLE_DST 1
-#define VARIABLE_BOTH 2
+#define VARIABLE_SRC 0
+#define VARIABLE_DST 1
+#define VARIABLE_BOTH 2
/*-------------------------------------------------------------------------
- * Function: init_full
+ * Function: init_full
*
- * Purpose: Initialize full array.
+ * Purpose: Initialize full array.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke
+ * Friday, October 10, 1997
*
* Modifications:
*
@@ -45,30 +45,30 @@
static uintn
init_full(uint8 *array, size_t nx, size_t ny, size_t nz)
{
- int i, j, k;
- uint8 acc = 128;
- uintn total = 0;
+ int i, j, k;
+ uint8 acc = 128;
+ uintn total = 0;
for (i = 0; i < nx; i++) {
- for (j = 0; j < ny; j++) {
- for (k = 0; k < nz; k++) {
- total += acc;
- *array++ = acc++;
- }
- }
+ for (j = 0; j < ny; j++) {
+ for (k = 0; k < nz; k++) {
+ total += acc;
+ *array++ = acc++;
+ }
+ }
}
return total;
}
/*-------------------------------------------------------------------------
- * Function: print_array
+ * Function: print_array
*
- * Purpose: Prints the values in an array
+ * Purpose: Prints the values in an array
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke
+ * Friday, October 10, 1997
*
* Modifications:
*
@@ -77,39 +77,39 @@ init_full(uint8 *array, size_t nx, size_t ny, size_t nz)
static void
print_array(uint8 *array, size_t nx, size_t ny, size_t nz)
{
- int i, j, k;
+ int i, j, k;
for (i = 0; i < nx; i++) {
- if (nz > 1) {
- printf("i=%d:\n", i);
- } else {
- printf("%03d:", i);
- }
-
- for (j = 0; j < ny; j++) {
- if (nz > 1)
- printf("%03d:", j);
- for (k = 0; k < nz; k++) {
- printf(" %3d", *array++);
- }
- if (nz > 1)
- printf("\n");
- }
- printf("\n");
+ if (nz > 1) {
+ printf("i=%d:\n", i);
+ } else {
+ printf("%03d:", i);
+ }
+
+ for (j = 0; j < ny; j++) {
+ if (nz > 1)
+ printf("%03d:", j);
+ for (k = 0; k < nz; k++) {
+ printf(" %3d", *array++);
+ }
+ if (nz > 1)
+ printf("\n");
+ }
+ printf("\n");
}
}
/*-------------------------------------------------------------------------
- * Function: print_ref
+ * Function: print_ref
*
- * Purpose: Prints the reference value
+ * Purpose: Prints the reference value
*
- * Return: Success: 0
+ * Return: Success: 0
*
- * Failure:
+ * Failure:
*
- * Programmer: Robb Matzke
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke
+ * Friday, October 10, 1997
*
* Modifications:
*
@@ -118,7 +118,7 @@ print_array(uint8 *array, size_t nx, size_t ny, size_t nz)
static void
print_ref(size_t nx, size_t ny, size_t nz)
{
- uint8 *array;
+ uint8 *array;
array = H5MM_xcalloc(nx * ny * nz, sizeof(uint8));
@@ -128,16 +128,16 @@ print_ref(size_t nx, size_t ny, size_t nz)
}
/*-------------------------------------------------------------------------
- * Function: test_fill
+ * Function: test_fill
*
- * Purpose: Tests the H5V_hyper_fill() function.
+ * Purpose: Tests the H5V_hyper_fill() function.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
@@ -145,40 +145,40 @@ print_ref(size_t nx, size_t ny, size_t nz)
*/
static herr_t
test_fill(size_t nx, size_t ny, size_t nz,
- size_t di, size_t dj, size_t dk,
- size_t ddx, size_t ddy, size_t ddz)
+ size_t di, size_t dj, size_t dk,
+ size_t ddx, size_t ddy, size_t ddz)
{
- uint8 *dst = NULL; /*destination array */
- size_t hs_size[3]; /*hyperslab size */
- size_t dst_size[3]; /*destination total size */
- size_t dst_offset[3]; /*offset of hyperslab in dest */
- uintn ref_value; /*reference value */
- uintn acc; /*accumulator */
- int i, j, k, dx, dy, dz; /*counters */
- size_t u, v, w;
- int ndims; /*hyperslab dimensionality */
- char dim[64], s[256]; /*temp string */
- uintn fill_value; /*fill value */
+ uint8 *dst = NULL; /*destination array */
+ size_t hs_size[3]; /*hyperslab size */
+ size_t dst_size[3]; /*destination total size */
+ size_t dst_offset[3]; /*offset of hyperslab in dest */
+ uintn ref_value; /*reference value */
+ uintn acc; /*accumulator */
+ int i, j, k, dx, dy, dz; /*counters */
+ size_t u, v, w;
+ int ndims; /*hyperslab dimensionality */
+ char dim[64], s[256]; /*temp string */
+ uintn fill_value; /*fill value */
/*
* Dimensionality.
*/
if (0 == nz) {
- if (0 == ny) {
- ndims = 1;
- ny = nz = 1;
- sprintf(dim, "%lu", (unsigned long) nx);
- } else {
- ndims = 2;
- nz = 1;
- sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
- }
+ if (0 == ny) {
+ ndims = 1;
+ ny = nz = 1;
+ sprintf(dim, "%lu", (unsigned long) nx);
+ } else {
+ ndims = 2;
+ nz = 1;
+ sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ }
} else {
- ndims = 3;
- sprintf(dim, "%lux%lux%lu",
- (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
+ ndims = 3;
+ sprintf(dim, "%lux%lux%lu",
+ (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
}
- sprintf(s, "Testing hyperslab fill %-11s variable hyperslab ", dim);
+ sprintf(s, "Testing hyperslab fill %-11s variable hyperslab", dim);
printf("%-70s", s);
fflush(stdout);
@@ -187,79 +187,87 @@ test_fill(size_t nx, size_t ny, size_t nz,
init_full(dst, nx, ny, nz);
for (i = 0; i < nx; i += di) {
- for (j = 0; j < ny; j += dj) {
- for (k = 0; k < nz; k += dk) {
- for (dx = 1; dx <= nx - i; dx += ddx) {
- for (dy = 1; dy <= ny - j; dy += ddy) {
- for (dz = 1; dz <= nz - k; dz += ddz) {
-
- /* Describe the hyperslab */
- dst_size[0] = nx;
- dst_size[1] = ny;
- dst_size[2] = nz;
- dst_offset[0] = i;
- dst_offset[1] = j;
- dst_offset[2] = k;
- hs_size[0] = dx;
- hs_size[1] = dy;
- hs_size[2] = dz;
-
- for (fill_value = 0; fill_value < 256; fill_value += 64) {
- /*
- * Initialize the full array, then subtract the
- * original * fill values and add the new ones.
- */
- ref_value = init_full(dst, nx, ny, nz);
- for (u = dst_offset[0]; u < dst_offset[0] + dx; u++) {
- for (v = dst_offset[1]; v < dst_offset[1] + dy; v++) {
- for (w = dst_offset[2]; w < dst_offset[2] + dz; w++) {
- ref_value -= dst[u * ny * nz + v * nz + w];
- }
- }
- }
- ref_value += fill_value * dx * dy * dz;
-
- /* Fill the hyperslab with some value */
- H5V_hyper_fill(ndims, hs_size, dst_size, dst_offset,
- dst, fill_value);
-
- /*
- * Sum the array and compare it to the reference
- * value.
- */
- acc = 0;
- for (u = 0; u < nx; u++) {
- for (v = 0; v < ny; v++) {
- for (w = 0; w < nz; w++) {
- acc += dst[u * ny * nz + v * nz + w];
- }
- }
- }
-
- if (acc != ref_value) {
- puts("*FAILED*");
- if (!isatty(1)) {
- /*
- * Print debugging info unless output is going
- * directly to a terminal.
- */
- AT();
- printf(" acc != ref_value\n");
- printf(" i=%d, j=%d, k=%d, "
- "dx=%d, dy=%d, dz=%d, fill=%d\n",
- i, j, k, dx, dy, dz, fill_value);
- print_ref(nx, ny, nz);
- printf("\n Result is:\n");
- print_array(dst, nx, ny, nz);
- }
- goto error;
- }
- }
- }
- }
- }
- }
- }
+ for (j = 0; j < ny; j += dj) {
+ for (k = 0; k < nz; k += dk) {
+ for (dx = 1; dx <= nx - i; dx += ddx) {
+ for (dy = 1; dy <= ny - j; dy += ddy) {
+ for (dz = 1; dz <= nz - k; dz += ddz) {
+
+ /* Describe the hyperslab */
+ dst_size[0] = nx;
+ dst_size[1] = ny;
+ dst_size[2] = nz;
+ dst_offset[0] = i;
+ dst_offset[1] = j;
+ dst_offset[2] = k;
+ hs_size[0] = dx;
+ hs_size[1] = dy;
+ hs_size[2] = dz;
+
+ for (fill_value=0;
+ fill_value<256;
+ fill_value+=64) {
+ /*
+ * Initialize the full array, then subtract the
+ * original * fill values and add the new ones.
+ */
+ ref_value = init_full(dst, nx, ny, nz);
+ for (u=dst_offset[0];
+ u<dst_offset[0]+dx;
+ u++) {
+ for (v = dst_offset[1];
+ v < dst_offset[1] + dy;
+ v++) {
+ for (w = dst_offset[2];
+ w < dst_offset[2] + dz;
+ w++) {
+ ref_value -= dst[u*ny*nz+v*nz+w];
+ }
+ }
+ }
+ ref_value += fill_value * dx * dy * dz;
+
+ /* Fill the hyperslab with some value */
+ H5V_hyper_fill(ndims, hs_size, dst_size,
+ dst_offset, dst, fill_value);
+
+ /*
+ * Sum the array and compare it to the
+ * reference value.
+ */
+ acc = 0;
+ for (u = 0; u < nx; u++) {
+ for (v = 0; v < ny; v++) {
+ for (w = 0; w < nz; w++) {
+ acc += dst[u*ny*nz + v*nz + w];
+ }
+ }
+ }
+
+ if (acc != ref_value) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ /*
+ * Print debugging info unless output
+ * is going directly to a terminal.
+ */
+ AT();
+ printf(" acc != ref_value\n");
+ printf(" i=%d, j=%d, k=%d, "
+ "dx=%d, dy=%d, dz=%d, fill=%d\n",
+ i, j, k, dx, dy, dz, fill_value);
+ print_ref(nx, ny, nz);
+ printf("\n Result is:\n");
+ print_array(dst, nx, ny, nz);
+ }
+ goto error;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
puts(" PASSED");
H5MM_xfree(dst);
@@ -271,28 +279,28 @@ test_fill(size_t nx, size_t ny, size_t nz,
}
/*-------------------------------------------------------------------------
- * Function: test_copy
+ * Function: test_copy
*
- * Purpose: Tests H5V_hyper_copy().
+ * Purpose: Tests H5V_hyper_copy().
*
- * The NX, NY, and NZ arguments are the size for the source and
- * destination arrays. You map pass zero for NZ or for NY and
- * NZ to test the 2-d and 1-d cases respectively.
+ * The NX, NY, and NZ arguments are the size for the source and
+ * destination arrays. You map pass zero for NZ or for NY and
+ * NZ to test the 2-d and 1-d cases respectively.
*
- * A hyperslab is copied from/to (depending on MODE) various
- * places in SRC and DST beginning at 0,0,0 and increasing
- * location by DI,DJ,DK in the x, y, and z directions.
+ * A hyperslab is copied from/to (depending on MODE) various
+ * places in SRC and DST beginning at 0,0,0 and increasing
+ * location by DI,DJ,DK in the x, y, and z directions.
*
- * For each hyperslab location, various sizes of hyperslabs are
- * tried beginning with 1x1x1 and increasing the size in each
- * dimension by DDX,DDY,DDZ.
+ * For each hyperslab location, various sizes of hyperslabs are
+ * tried beginning with 1x1x1 and increasing the size in each
+ * dimension by DDX,DDY,DDZ.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke
+ * Friday, October 10, 1997
*
* Modifications:
*
@@ -300,69 +308,69 @@ test_fill(size_t nx, size_t ny, size_t nz,
*/
static herr_t
test_copy(int mode,
- size_t nx, size_t ny, size_t nz,
- size_t di, size_t dj, size_t dk,
- size_t ddx, size_t ddy, size_t ddz)
+ size_t nx, size_t ny, size_t nz,
+ size_t di, size_t dj, size_t dk,
+ size_t ddx, size_t ddy, size_t ddz)
{
- uint8 *src = NULL; /*source array */
- uint8 *dst = NULL; /*destination array */
- size_t hs_size[3]; /*hyperslab size */
- size_t dst_size[3]; /*destination total size */
- size_t src_size[3]; /*source total size */
- size_t dst_offset[3]; /*offset of hyperslab in dest */
- size_t src_offset[3]; /*offset of hyperslab in source */
- uintn ref_value; /*reference value */
- uintn acc; /*accumulator */
- int i, j, k, dx, dy, dz; /*counters */
+ uint8 *src = NULL; /*source array */
+ uint8 *dst = NULL; /*destination array */
+ size_t hs_size[3]; /*hyperslab size */
+ size_t dst_size[3]; /*destination total size */
+ size_t src_size[3]; /*source total size */
+ size_t dst_offset[3]; /*offset of hyperslab in dest */
+ size_t src_offset[3]; /*offset of hyperslab in source */
+ uintn ref_value; /*reference value */
+ uintn acc; /*accumulator */
+ int i, j, k, dx, dy, dz; /*counters */
size_t u, v, w;
- int ndims; /*hyperslab dimensionality */
- char dim[64], s[256]; /*temp string */
- const char *sub;
+ int ndims; /*hyperslab dimensionality */
+ char dim[64], s[256]; /*temp string */
+ const char *sub;
/*
* Dimensionality.
*/
if (0 == nz) {
- if (0 == ny) {
- ndims = 1;
- ny = nz = 1;
- sprintf(dim, "%lu", (unsigned long) nx);
- } else {
- ndims = 2;
- nz = 1;
- sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
- }
+ if (0 == ny) {
+ ndims = 1;
+ ny = nz = 1;
+ sprintf(dim, "%lu", (unsigned long) nx);
+ } else {
+ ndims = 2;
+ nz = 1;
+ sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ }
} else {
- ndims = 3;
- sprintf(dim, "%lux%lux%lu",
- (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
+ ndims = 3;
+ sprintf(dim, "%lux%lux%lu",
+ (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
}
switch (mode) {
case VARIABLE_SRC:
- /*
- * The hyperslab "travels" through the source array but the
- * destination hyperslab is always at the origin of the destination
- * array.
- */
- sub = "variable source";
- break;
+ /*
+ * The hyperslab "travels" through the source array but the
+ * destination hyperslab is always at the origin of the destination
+ * array.
+ */
+ sub = "variable source";
+ break;
case VARIABLE_DST:
- /*
- * We always read a hyperslab from the origin of the source and copy it
- * to a hyperslab at various locations in the destination.
- */
- sub = "variable destination";
- break;
+ /*
+ * We always read a hyperslab from the origin of the source and copy it
+ * to a hyperslab at various locations in the destination.
+ */
+ sub = "variable destination";
+ break;
case VARIABLE_BOTH:
- /*
- * We read the hyperslab from various locations in the source and copy
- * it to the same location in the destination.
- */
- sub = "sync source & dest ";
- break;
+ /*
+ * We read the hyperslab from various locations in the source and copy
+ * it to the same location in the destination.
+ */
+ sub = "sync source & dest ";
+ break;
default:
- abort();
+ abort();
}
sprintf(s, "Testing hyperslab copy %-11s %s", dim, sub);
@@ -377,151 +385,159 @@ test_copy(int mode,
init_full(src, nx, ny, nz);
for (i = 0; i < nx; i += di) {
- for (j = 0; j < ny; j += dj) {
- for (k = 0; k < nz; k += dk) {
- for (dx = 1; dx <= nx - i; dx += ddx) {
- for (dy = 1; dy <= ny - j; dy += ddy) {
- for (dz = 1; dz <= nz - k; dz += ddz) {
-
- /*
- * Describe the source and destination hyperslabs and the
- * arrays to which they belong.
- */
- hs_size[0] = dx;
- hs_size[1] = dy;
- hs_size[2] = dz;
- dst_size[0] = src_size[0] = nx;
- dst_size[1] = src_size[1] = ny;
- dst_size[2] = src_size[2] = nz;
- switch (mode) {
- case VARIABLE_SRC:
- dst_offset[0] = 0;
- dst_offset[1] = 0;
- dst_offset[2] = 0;
- src_offset[0] = i;
- src_offset[1] = j;
- src_offset[2] = k;
- break;
- case VARIABLE_DST:
- dst_offset[0] = i;
- dst_offset[1] = j;
- dst_offset[2] = k;
- src_offset[0] = 0;
- src_offset[1] = 0;
- src_offset[2] = 0;
- break;
- case VARIABLE_BOTH:
- dst_offset[0] = i;
- dst_offset[1] = j;
- dst_offset[2] = k;
- src_offset[0] = i;
- src_offset[1] = j;
- src_offset[2] = k;
- break;
- default:
- abort();
- }
-
- /*
- * Sum the main array directly to get a reference value
- * to compare against later.
- */
- ref_value = 0;
- for (u = src_offset[0]; u < src_offset[0] + dx; u++) {
- for (v = src_offset[1]; v < src_offset[1] + dy; v++) {
- for (w = src_offset[2]; w < src_offset[2] + dz; w++) {
- ref_value += src[u * ny * nz + v * nz + w];
- }
- }
- }
-
- /*
- * Set all loc values to 1 so we can detect writing
- * outside the hyperslab.
- */
- for (u = 0; u < nx; u++) {
- for (v = 0; v < ny; v++) {
- for (w = 0; w < nz; w++) {
- dst[u * ny * nz + v * nz + w] = 1;
- }
- }
- }
-
- /*
- * Copy a hyperslab from the global array to the local
- * array.
- */
- H5V_hyper_copy(ndims, hs_size,
- dst_size, dst_offset, dst,
- src_size, src_offset, src);
-
- /*
- * Sum the destination hyperslab. It should be the same
- * as the reference value.
- */
- acc = 0;
- for (u = dst_offset[0]; u < dst_offset[0] + dx; u++) {
- for (v = dst_offset[1]; v < dst_offset[1] + dy; v++) {
- for (w = dst_offset[2]; w < dst_offset[2] + dz; w++) {
- acc += dst[u * ny * nz + v * nz + w];
- }
- }
- }
- if (acc != ref_value) {
- puts("*FAILED*");
- if (!isatty(1)) {
- /*
- * Print debugging info unless output is going
- * directly to a terminal.
- */
- AT();
- printf(" acc != ref_value\n");
- printf(" i=%d, j=%d, k=%d, "
- "dx=%d, dy=%d, dz=%d\n",
- i, j, k, dx, dy, dz);
- print_ref(nx, ny, nz);
- printf("\n Destination array is:\n");
- print_array(dst, nx, ny, nz);
- }
- goto error;
- }
- /*
- * Sum the entire array. It should be a fixed amount
- * larger than the reference value since we added the
- * border of 1's to the hyperslab.
- */
- acc = 0;
- for (u = 0; u < nx; u++) {
- for (v = 0; v < ny; v++) {
- for (w = 0; w < nz; w++) {
- acc += dst[u * ny * nz + v * nz + w];
- }
- }
- }
- if (acc != ref_value + nx * ny * nz - dx * dy * dz) {
- puts("*FAILED*");
- if (!isatty(1)) {
- /*
- * Print debugging info unless output is going
- * directly to a terminal.
- */
- AT();
- printf(" acc != ref_value + nx*ny*nz - "
- "dx*dy*dz\n");
- printf(" i=%d, j=%d, k=%d, "
- "dx=%d, dy=%d, dz=%d\n",
- i, j, k, dx, dy, dz);
- print_ref(nx, ny, nz);
- printf("\n Destination array is:\n");
- print_array(dst, nx, ny, nz);
- }
- goto error;
- }
- }
- }
- }
- }
- }
+ for (j = 0; j < ny; j += dj) {
+ for (k = 0; k < nz; k += dk) {
+ for (dx = 1; dx <= nx - i; dx += ddx) {
+ for (dy = 1; dy <= ny - j; dy += ddy) {
+ for (dz = 1; dz <= nz - k; dz += ddz) {
+
+ /*
+ * Describe the source and destination hyperslabs
+ * and the arrays to which they belong.
+ */
+ hs_size[0] = dx;
+ hs_size[1] = dy;
+ hs_size[2] = dz;
+ dst_size[0] = src_size[0] = nx;
+ dst_size[1] = src_size[1] = ny;
+ dst_size[2] = src_size[2] = nz;
+ switch (mode) {
+ case VARIABLE_SRC:
+ dst_offset[0] = 0;
+ dst_offset[1] = 0;
+ dst_offset[2] = 0;
+ src_offset[0] = i;
+ src_offset[1] = j;
+ src_offset[2] = k;
+ break;
+ case VARIABLE_DST:
+ dst_offset[0] = i;
+ dst_offset[1] = j;
+ dst_offset[2] = k;
+ src_offset[0] = 0;
+ src_offset[1] = 0;
+ src_offset[2] = 0;
+ break;
+ case VARIABLE_BOTH:
+ dst_offset[0] = i;
+ dst_offset[1] = j;
+ dst_offset[2] = k;
+ src_offset[0] = i;
+ src_offset[1] = j;
+ src_offset[2] = k;
+ break;
+ default:
+ abort();
+ }
+
+ /*
+ * Sum the main array directly to get a reference
+ * value to compare against later.
+ */
+ ref_value = 0;
+ for (u=src_offset[0]; u<src_offset[0]+dx; u++) {
+ for (v=src_offset[1];
+ v<src_offset[1]+dy;
+ v++) {
+ for (w=src_offset[2];
+ w<src_offset[2]+dz;
+ w++) {
+ ref_value += src[u*ny*nz + v*nz + w];
+ }
+ }
+ }
+
+ /*
+ * Set all loc values to 1 so we can detect writing
+ * outside the hyperslab.
+ */
+ for (u = 0; u < nx; u++) {
+ for (v = 0; v < ny; v++) {
+ for (w = 0; w < nz; w++) {
+ dst[u * ny * nz + v * nz + w] = 1;
+ }
+ }
+ }
+
+ /*
+ * Copy a hyperslab from the global array to the
+ * local array.
+ */
+ H5V_hyper_copy(ndims, hs_size,
+ dst_size, dst_offset, dst,
+ src_size, src_offset, src);
+
+ /*
+ * Sum the destination hyperslab. It should be
+ * the same as the reference value.
+ */
+ acc = 0;
+ for (u=dst_offset[0]; u<dst_offset[0]+dx; u++) {
+ for (v=dst_offset[1];
+ v<dst_offset[1]+dy;
+ v++) {
+ for (w = dst_offset[2];
+ w < dst_offset[2] + dz;
+ w++) {
+ acc += dst[u * ny * nz + v * nz + w];
+ }
+ }
+ }
+ if (acc != ref_value) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ /*
+ * Print debugging info unless output is
+ * going directly to a terminal.
+ */
+ AT();
+ printf(" acc != ref_value\n");
+ printf(" i=%d, j=%d, k=%d, "
+ "dx=%d, dy=%d, dz=%d\n",
+ i, j, k, dx, dy, dz);
+ print_ref(nx, ny, nz);
+ printf("\n Destination array is:\n");
+ print_array(dst, nx, ny, nz);
+ }
+ goto error;
+ }
+ /*
+ * Sum the entire array. It should be a fixed
+ * amount larger than the reference value since
+ * we added the border of 1's to the hyperslab.
+ */
+ acc = 0;
+ for (u = 0; u < nx; u++) {
+ for (v = 0; v < ny; v++) {
+ for (w = 0; w < nz; w++) {
+ acc += dst[u * ny * nz + v * nz + w];
+ }
+ }
+ }
+ if (acc != ref_value + nx*ny*nz - dx*dy*dz) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ /*
+ * Print debugging info unless output is
+ * going directly to a terminal.
+ */
+ AT();
+ printf(" acc != ref_value + nx*ny*nz - "
+ "dx*dy*dz\n");
+ printf(" i=%d, j=%d, k=%d, "
+ "dx=%d, dy=%d, dz=%d\n",
+ i, j, k, dx, dy, dz);
+ print_ref(nx, ny, nz);
+ printf("\n Destination array is:\n");
+ print_array(dst, nx, ny, nz);
+ }
+ goto error;
+ }
+ }
+ }
+ }
+ }
+ }
}
puts(" PASSED");
H5MM_xfree(src);
@@ -535,20 +551,20 @@ test_copy(int mode,
}
/*-------------------------------------------------------------------------
- * Function: test_multifill
+ * Function: test_multifill
*
- * Purpose: Tests the H5V_stride_copy() function by using it to fill a
- * hyperslab by replicating a multi-byte sequence. This might
- * be useful to initialize an array of structs with a default
- * struct value, or to initialize an array of floating-point
- * values with a default bit-pattern.
+ * Purpose: Tests the H5V_stride_copy() function by using it to fill a
+ * hyperslab by replicating a multi-byte sequence. This might
+ * be useful to initialize an array of structs with a default
+ * struct value, or to initialize an array of floating-point
+ * values with a default bit-pattern.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
@@ -557,17 +573,17 @@ test_copy(int mode,
static herr_t
test_multifill(int nx)
{
- int i, j;
- size_t size;
- intn src_stride;
- intn dst_stride;
- char s[64];
+ int i, j;
+ size_t size;
+ ssize_t src_stride;
+ ssize_t dst_stride;
+ char s[64];
struct a_struct {
- int left;
- double mid;
- int right;
- } fill , *src = NULL, *dst = NULL;
+ int left;
+ double mid;
+ int right;
+ } fill , *src = NULL, *dst = NULL;
printf("%-70s", "Testing multi-byte fill value");
fflush(stdout);
@@ -576,16 +592,16 @@ test_multifill(int nx)
src = H5MM_xmalloc(nx * sizeof(*src));
dst = H5MM_xmalloc(nx * sizeof(*dst));
for (i = 0; i < nx; i++) {
- src[i].left = 1111111;
- src[i].mid = 12345.6789;
- src[i].right = 2222222;
- dst[i].left = 3333333;
- dst[i].mid = 98765.4321;
- dst[i].right = 4444444;
+ src[i].left = 1111111;
+ src[i].mid = 12345.6789;
+ src[i].right = 2222222;
+ dst[i].left = 3333333;
+ dst[i].mid = 98765.4321;
+ dst[i].right = 4444444;
}
/*
- * Describe the fill value. The zero stride says to read the same thing
+ * Describe the fill value. The zero stride says to read the same thing
* over and over again.
*/
fill.left = 55555555;
@@ -603,38 +619,38 @@ test_multifill(int nx)
*/
size = nx;
H5V_stride_copy(1, sizeof(double), &size,
- &dst_stride, & (dst[0].mid), &src_stride, &(fill.mid));
+ &dst_stride, &(dst[0].mid), &src_stride, &(fill.mid));
/*
* Check
*/
s[0] = '\0';
for (i = 0; i < nx; i++) {
- if (dst[i].left != 3333333) {
- sprintf(s, "bad dst[%d].left", i);
- } else if (dst[i].mid != fill.mid) {
- sprintf(s, "bad dst[%d].mid", i);
- } else if (dst[i].right != 4444444) {
- sprintf(s, "bad dst[%d].right", i);
- }
- if (s[0]) {
- puts("*FAILED*");
- if (!isatty(1)) {
- AT();
- printf(" fill={%d,%g,%d}\n ",
- fill.left, fill.mid, fill.right);
- for (j = 0; j < sizeof(fill); j++) {
- printf(" %02x", ((uint8 *) &fill)[j]);
- }
- printf("\n dst[%d]={%d,%g,%d}\n ",
- i, dst[i].left, dst[i].mid, dst[i].right);
- for (j = 0; j < sizeof(dst[i]); j++) {
- printf(" %02x", ((uint8 *) (dst + i))[j]);
- }
- printf("\n");
- }
- goto error;
- }
+ if (dst[i].left != 3333333) {
+ sprintf(s, "bad dst[%d].left", i);
+ } else if (dst[i].mid != fill.mid) {
+ sprintf(s, "bad dst[%d].mid", i);
+ } else if (dst[i].right != 4444444) {
+ sprintf(s, "bad dst[%d].right", i);
+ }
+ if (s[0]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" fill={%d,%g,%d}\n ",
+ fill.left, fill.mid, fill.right);
+ for (j = 0; j < sizeof(fill); j++) {
+ printf(" %02x", ((uint8 *) &fill)[j]);
+ }
+ printf("\n dst[%d]={%d,%g,%d}\n ",
+ i, dst[i].left, dst[i].mid, dst[i].right);
+ for (j = 0; j < sizeof(dst[i]); j++) {
+ printf(" %02x", ((uint8 *) (dst + i))[j]);
+ }
+ printf("\n");
+ }
+ goto error;
+ }
}
puts(" PASSED");
@@ -649,18 +665,18 @@ test_multifill(int nx)
}
/*-------------------------------------------------------------------------
- * Function: test_endian
+ * Function: test_endian
*
- * Purpose: Tests the H5V_stride_copy() function by using it to copy an
- * array of integers and swap the byte ordering from little
- * endian to big endian or vice versa depending on the hardware.
+ * Purpose: Tests the H5V_stride_copy() function by using it to copy an
+ * array of integers and swap the byte ordering from little
+ * endian to big endian or vice versa depending on the hardware.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
@@ -669,12 +685,12 @@ test_multifill(int nx)
static herr_t
test_endian(size_t nx)
{
- uint8 *src = NULL; /*source array */
- uint8 *dst = NULL; /*destination array */
- intn src_stride[2]; /*source strides */
- intn dst_stride[2]; /*destination strides */
- size_t size[2]; /*size vector */
- int i, j;
+ uint8 *src = NULL; /*source array */
+ uint8 *dst = NULL; /*destination array */
+ ssize_t src_stride[2]; /*source strides */
+ ssize_t dst_stride[2]; /*destination strides */
+ size_t size[2]; /*size vector */
+ int i, j;
printf("%-70s", "Testing endian conversion by stride");
fflush(stdout);
@@ -697,24 +713,24 @@ test_endian(size_t nx)
/* Compare */
for (i = 0; i < nx; i++) {
- for (j = 0; j < 4; j++) {
- if (src[i * 4 + j] != dst[i * 4 + 3 - j]) {
- puts("*FAILED*");
- if (!isatty(1)) {
- /*
- * Print debugging info unless output is going directly to a
- * terminal.
- */
- AT();
- printf(" i=%d, j=%d\n", i, j);
- printf(" Source array is:\n");
- print_array(src, nx, 4, 1);
- printf("\n Result is:\n");
- print_array(dst, nx, 4, 1);
- }
- goto error;
- }
- }
+ for (j = 0; j < 4; j++) {
+ if (src[i * 4 + j] != dst[i * 4 + 3 - j]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ /*
+ * Print debugging info unless output is going directly
+ * to a terminal.
+ */
+ AT();
+ printf(" i=%d, j=%d\n", i, j);
+ printf(" Source array is:\n");
+ print_array(src, nx, 4, 1);
+ printf("\n Result is:\n");
+ print_array(dst, nx, 4, 1);
+ }
+ goto error;
+ }
+ }
}
puts(" PASSED");
@@ -729,17 +745,17 @@ test_endian(size_t nx)
}
/*-------------------------------------------------------------------------
- * Function: test_transpose
+ * Function: test_transpose
*
- * Purpose: Copy a 2d array from here to there and transpose the elements
- * as it's copied.
+ * Purpose: Copy a 2d array from here to there and transpose the elements
+ * as it's copied.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
@@ -748,24 +764,24 @@ test_endian(size_t nx)
static herr_t
test_transpose(size_t nx, size_t ny)
{
- intn *src = NULL;
- intn *dst = NULL;
- int i, j;
- intn src_stride[2], dst_stride[2];
- size_t size[2];
- char s[256];
+ intn *src = NULL;
+ intn *dst = NULL;
+ int i, j;
+ ssize_t src_stride[2], dst_stride[2];
+ size_t size[2];
+ char s[256];
sprintf(s, "Testing 2d transpose by stride %4lux%-lud",
- (unsigned long) nx, (unsigned long) ny);
+ (unsigned long) nx, (unsigned long) ny);
printf("%-70s", s);
fflush(stdout);
/* Initialize */
src = H5MM_xmalloc(nx * ny * sizeof(*src));
for (i = 0; i < nx; i++) {
- for (j = 0; j < ny; j++) {
- src[i * ny + j] = (intn)(i * ny + j);
- }
+ for (j = 0; j < ny; j++) {
+ src[i * ny + j] = (intn)(i * ny + j);
+ }
}
dst = H5MM_xcalloc(nx * ny, sizeof(*dst));
@@ -774,48 +790,48 @@ test_transpose(size_t nx, size_t ny)
size[1] = ny;
src_stride[0] = 0;
src_stride[1] = sizeof(*src);
- dst_stride[0] = (intn)((1 - nx * ny) * sizeof(*src));
- dst_stride[1] = (intn)(nx * sizeof(*src));
+ dst_stride[0] = (1 - nx * ny) * sizeof(*src);
+ dst_stride[1] = nx * sizeof(*src);
/* Copy and transpose */
if (nx == ny) {
- H5V_stride_copy(2, sizeof(*src), size,
- dst_stride, dst,
- src_stride, src);
+ H5V_stride_copy(2, sizeof(*src), size,
+ dst_stride, dst,
+ src_stride, src);
} else {
- H5V_stride_copy(2, sizeof(*src), size,
- dst_stride, dst,
- src_stride, src);
+ H5V_stride_copy(2, sizeof(*src), size,
+ dst_stride, dst,
+ src_stride, src);
}
/* Check */
for (i = 0; i < nx; i++) {
- for (j = 0; j < ny; j++) {
- if (src[i * ny + j] != dst[j * nx + i]) {
- puts("*FAILED*");
- if (!isatty(1)) {
- AT();
- printf(" diff at i=%d, j=%d\n", i, j);
- printf(" Source is:\n");
- for (i = 0; i < nx; i++) {
- printf("%3d:", i);
- for (j = 0; j < ny; j++) {
- printf(" %6d", src[i * ny + j]);
- }
- printf("\n");
- }
- printf("\n Destination is:\n");
- for (i = 0; i < ny; i++) {
- printf("%3d:", i);
- for (j = 0; j < nx; j++) {
- printf(" %6d", dst[i * nx + j]);
- }
- printf("\n");
- }
- }
- goto error;
- }
- }
+ for (j = 0; j < ny; j++) {
+ if (src[i * ny + j] != dst[j * nx + i]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" diff at i=%d, j=%d\n", i, j);
+ printf(" Source is:\n");
+ for (i = 0; i < nx; i++) {
+ printf("%3d:", i);
+ for (j = 0; j < ny; j++) {
+ printf(" %6d", src[i * ny + j]);
+ }
+ printf("\n");
+ }
+ printf("\n Destination is:\n");
+ for (i = 0; i < ny; i++) {
+ printf("%3d:", i);
+ for (j = 0; j < nx; j++) {
+ printf(" %6d", dst[i * nx + j]);
+ }
+ printf("\n");
+ }
+ }
+ goto error;
+ }
+ }
}
puts(" PASSED");
@@ -830,19 +846,19 @@ test_transpose(size_t nx, size_t ny)
}
/*-------------------------------------------------------------------------
- * Function: test_sub_super
+ * Function: test_sub_super
*
- * Purpose: Tests H5V_stride_copy() to reduce the resolution of an image
- * by copying half the pixels in the X and Y directions. Then
- * we use the small image and duplicate every pixel to result in
- * a 2x2 square.
+ * Purpose: Tests H5V_stride_copy() to reduce the resolution of an image
+ * by copying half the pixels in the X and Y directions. Then
+ * we use the small image and duplicate every pixel to result in
+ * a 2x2 square.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Monday, October 13, 1997
+ * Programmer: Robb Matzke
+ * Monday, October 13, 1997
*
* Modifications:
*
@@ -851,18 +867,18 @@ test_transpose(size_t nx, size_t ny)
static herr_t
test_sub_super(size_t nx, size_t ny)
{
- uint8 *full = NULL; /*original image */
- uint8 *half = NULL; /*image at 1/2 resolution */
- uint8 *twice = NULL; /*2x2 pixels */
- intn src_stride[4]; /*source stride info */
- intn dst_stride[4]; /*destination stride info */
- size_t size[4]; /*number of sample points */
- int i, j;
- char s[256];
+ uint8 *full = NULL; /*original image */
+ uint8 *half = NULL; /*image at 1/2 resolution */
+ uint8 *twice = NULL; /*2x2 pixels */
+ ssize_t src_stride[4]; /*source stride info */
+ ssize_t dst_stride[4]; /*destination stride info */
+ size_t size[4]; /*number of sample points */
+ int i, j;
+ char s[256];
sprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ",
- (unsigned long) (2 * nx), (unsigned long) (2 * ny),
- (unsigned long) nx, (unsigned long) ny);
+ (unsigned long) (2 * nx), (unsigned long) (2 * ny),
+ (unsigned long) nx, (unsigned long) ny);
printf("%-70s", s);
fflush(stdout);
@@ -875,31 +891,32 @@ test_sub_super(size_t nx, size_t ny)
/* Setup */
size[0] = nx;
size[1] = ny;
- src_stride[0] = (intn)(2 * ny);
+ src_stride[0] = 2 * ny;
src_stride[1] = 2;
dst_stride[0] = 0;
dst_stride[1] = 1;
/* Copy */
H5V_stride_copy(2, sizeof(uint8), size,
- dst_stride, half, src_stride, full);
+ dst_stride, half, src_stride, full);
/* Check */
for (i = 0; i < nx; i++) {
- for (j = 0; j < ny; j++) {
- if (full[4 * i * ny + 2 * j] != half[i * ny + j]) {
- puts("*FAILED*");
- if (!isatty(1)) {
- AT();
- printf(" full[%d][%d] != half[%d][%d]\n", i * 2, j * 2, i, j);
- printf(" full is:\n");
- print_array(full, 2 * nx, 2 * ny, 1);
- printf("\n half is:\n");
- print_array(half, nx, ny, 1);
- }
- goto error;
- }
- }
+ for (j = 0; j < ny; j++) {
+ if (full[4 * i * ny + 2 * j] != half[i * ny + j]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" full[%d][%d] != half[%d][%d]\n",
+ i*2, j*2, i, j);
+ printf(" full is:\n");
+ print_array(full, 2 * nx, 2 * ny, 1);
+ printf("\n half is:\n");
+ print_array(half, nx, ny, 1);
+ }
+ goto error;
+ }
+ }
}
puts(" PASSED");
@@ -908,8 +925,8 @@ test_sub_super(size_t nx, size_t ny)
* dimension.
*/
sprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ",
- (unsigned long) nx, (unsigned long) ny,
- (unsigned long) (2 * nx), (unsigned long) (2 * ny));
+ (unsigned long) nx, (unsigned long) ny,
+ (unsigned long) (2 * nx), (unsigned long) (2 * ny));
printf("%-70s", s);
fflush(stdout);
@@ -922,40 +939,44 @@ test_sub_super(size_t nx, size_t ny)
src_stride[1] = 1;
src_stride[2] = 0;
src_stride[3] = 0;
- dst_stride[0] = (intn)(2 * ny);
- dst_stride[1] = (intn)(2 * sizeof(uint8) - 4 * ny);
- dst_stride[2] = (intn)(2 * ny - 2 * sizeof(uint8));
+ dst_stride[0] = 2 * ny;
+ dst_stride[1] = 2 * sizeof(uint8) - 4 * ny;
+ dst_stride[2] = 2 * ny - 2 * sizeof(uint8);
dst_stride[3] = sizeof(uint8);
/* Copy */
H5V_stride_copy(4, sizeof(uint8), size,
- dst_stride, twice, src_stride, half);
+ dst_stride, twice, src_stride, half);
/* Check */
s[0] = '\0';
for (i = 0; i < nx; i++) {
- for (j = 0; j < ny; j++) {
- if (half[i * ny + j] != twice[4 * i * ny + 2 * j]) {
- sprintf(s, "half[%d][%d] != twice[%d][%d]", i, j, 2 * i, 2 * j);
- } else if (half[i * ny + j] != twice[4 * i * ny + 2 * j + 1]) {
- sprintf(s, "half[%d][%d] != twice[%d][%d]", i, j, 2 * i, 2 * j + 1);
- } else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j]) {
- sprintf(s, "half[%d][%d] != twice[%d][%d]", i, j, 2 * i + 1, 2 * j);
- } else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j + 1]) {
- sprintf(s, "half[%d][%d] != twice[%d][%d]", i, j, 2 * i + 1, 2 * j + 1);
- }
- if (s[0]) {
- puts("*FAILED*");
- if (!isatty(1)) {
- AT();
- printf(" %s\n Half is:\n", s);
- print_array(half, nx, ny, 1);
- printf("\n Twice is:\n");
- print_array(twice, 2 * nx, 2 * ny, 1);
- }
- goto error;
- }
- }
+ for (j = 0; j < ny; j++) {
+ if (half[i*ny+j] != twice[4*i*ny + 2*j]) {
+ sprintf(s, "half[%d][%d] != twice[%d][%d]",
+ i, j, 2 * i, 2 * j);
+ } else if (half[i*ny + j] != twice[4*i*ny + 2*j + 1]) {
+ sprintf(s, "half[%d][%d] != twice[%d][%d]",
+ i, j, 2 * i, 2 * j + 1);
+ } else if (half[i*ny + j] != twice[(2*i +1)*2*ny + 2*j]) {
+ sprintf(s, "half[%d][%d] != twice[%d][%d]",
+ i, j, 2 * i + 1, 2 * j);
+ } else if (half[i*ny + j] != twice[(2*i+1)*2*ny + 2*j+1]) {
+ sprintf(s, "half[%d][%d] != twice[%d][%d]",
+ i, j, 2 * i + 1, 2 * j + 1);
+ }
+ if (s[0]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" %s\n Half is:\n", s);
+ print_array(half, nx, ny, 1);
+ printf("\n Twice is:\n");
+ print_array(twice, 2 * nx, 2 * ny, 1);
+ }
+ goto error;
+ }
+ }
}
puts(" PASSED");
@@ -972,18 +993,18 @@ test_sub_super(size_t nx, size_t ny)
}
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Purpose: Test various hyperslab operations. Give the words
- * `small' and/or `medium' on the command line or only `small'
- * is assumed.
+ * Purpose: Test various hyperslab operations. Give the words
+ * `small' and/or `medium' on the command line or only `small'
+ * is assumed.
*
- * Return: Success: exit(0)
+ * Return: Success: exit(0)
*
- * Failure: exit(non-zero)
+ * Failure: exit(non-zero)
*
- * Programmer: Robb Matzke
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke
+ * Friday, October 10, 1997
*
* Modifications:
*
@@ -992,31 +1013,31 @@ test_sub_super(size_t nx, size_t ny)
int
main(int argc, char *argv[])
{
- herr_t status;
- int nerrors = 0;
- uintn size_of_test;
+ herr_t status;
+ int nerrors = 0;
+ uintn size_of_test;
/* Parse arguments or assume `small' */
if (1 == argc) {
- size_of_test = TEST_SMALL;
+ size_of_test = TEST_SMALL;
} else {
- intn i;
- for (i = 1, size_of_test = 0; i < argc; i++) {
- if (!strcmp(argv[i], "small")) {
- size_of_test |= TEST_SMALL;
- } else if (!strcmp(argv[i], "medium")) {
- size_of_test |= TEST_MEDIUM;
- } else {
- printf("unrecognized argument: %s\n", argv[i]);
- exit(1);
- }
- }
+ intn i;
+ for (i = 1, size_of_test = 0; i < argc; i++) {
+ if (!strcmp(argv[i], "small")) {
+ size_of_test |= TEST_SMALL;
+ } else if (!strcmp(argv[i], "medium")) {
+ size_of_test |= TEST_MEDIUM;
+ } else {
+ printf("unrecognized argument: %s\n", argv[i]);
+ exit(1);
+ }
+ }
}
printf("Test sizes: ");
if (size_of_test & TEST_SMALL)
- printf(" SMALL");
+ printf(" SMALL");
if (size_of_test & TEST_MEDIUM)
- printf(" MEDIUM");
+ printf(" MEDIUM");
printf("\n");
/*
@@ -1025,20 +1046,20 @@ main(int argc, char *argv[])
*------------------------------
*/
if (size_of_test & TEST_SMALL) {
- status = test_fill(11, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_fill(11, 10, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_fill(3, 5, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_fill(11, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_fill(11, 10, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_fill(3, 5, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_fill(113, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_fill(15, 11, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_fill(5, 7, 7, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_fill(113, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_fill(15, 11, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_fill(5, 7, 7, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
/*------------------------------
* TEST HYPERSLAB COPY OPERATION
@@ -1047,63 +1068,63 @@ main(int argc, char *argv[])
/* exhaustive, one-dimensional test */
if (size_of_test & TEST_SMALL) {
- status = test_copy(VARIABLE_SRC, 11, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 11, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 11, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 11, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 11, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 11, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_copy(VARIABLE_SRC, 179, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 179, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 179, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 179, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 179, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 179, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
/* exhaustive, two-dimensional test */
if (size_of_test & TEST_SMALL) {
- status = test_copy(VARIABLE_SRC, 11, 10, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 11, 10, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 11, 10, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 11, 10, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 11, 10, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 11, 10, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_copy(VARIABLE_SRC, 13, 19, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 13, 19, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 13, 19, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 13, 19, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 13, 19, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 13, 19, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
/* sparse, two-dimensional test */
if (size_of_test & TEST_MEDIUM) {
- status = test_copy(VARIABLE_SRC, 73, 67, 0, 7, 11, 1, 13, 11, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 73, 67, 0, 7, 11, 1, 13, 11, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 73, 67, 0, 7, 11, 1, 13, 11, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 73, 67, 0, 7, 11, 1, 13, 11, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 73, 67, 0, 7, 11, 1, 13, 11, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 73, 67, 0, 7, 11, 1, 13, 11, 1);
+ nerrors += status < 0 ? 1 : 0;
}
/* exhaustive, three-dimensional test */
if (size_of_test & TEST_SMALL) {
- status = test_copy(VARIABLE_SRC, 3, 5, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 3, 5, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 3, 5, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 3, 5, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 3, 5, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 3, 5, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_copy(VARIABLE_SRC, 7, 9, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 7, 9, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 7, 9, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 7, 9, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 7, 9, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 7, 9, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
/*---------------------
* TEST MULTI-BYTE FILL
@@ -1111,12 +1132,12 @@ main(int argc, char *argv[])
*/
if (size_of_test & TEST_SMALL) {
- status = test_multifill(10);
- nerrors += status < 0 ? 1 : 0;
+ status = test_multifill(10);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_multifill(500000);
- nerrors += status < 0 ? 1 : 0;
+ status = test_multifill(500000);
+ nerrors += status < 0 ? 1 : 0;
}
/*---------------------------
* TEST TRANSLATION OPERATORS
@@ -1124,20 +1145,20 @@ main(int argc, char *argv[])
*/
if (size_of_test & TEST_SMALL) {
- status = test_endian(10);
- nerrors += status < 0 ? 1 : 0;
- status = test_transpose(9, 9);
- nerrors += status < 0 ? 1 : 0;
- status = test_transpose(3, 11);
- nerrors += status < 0 ? 1 : 0;
+ status = test_endian(10);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_transpose(9, 9);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_transpose(3, 11);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_endian(800000);
- nerrors += status < 0 ? 1 : 0;
- status = test_transpose(1200, 1200);
- nerrors += status < 0 ? 1 : 0;
- status = test_transpose(800, 1800);
- nerrors += status < 0 ? 1 : 0;
+ status = test_endian(800000);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_transpose(1200, 1200);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_transpose(800, 1800);
+ nerrors += status < 0 ? 1 : 0;
}
/*-------------------------
* TEST SAMPLING OPERATIONS
@@ -1145,23 +1166,23 @@ main(int argc, char *argv[])
*/
if (size_of_test & TEST_SMALL) {
- status = test_sub_super(5, 10);
- nerrors += status < 0 ? 1 : 0;
+ status = test_sub_super(5, 10);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_sub_super(480, 640);
- nerrors += status < 0 ? 1 : 0;
+ status = test_sub_super(480, 640);
+ nerrors += status < 0 ? 1 : 0;
}
/*--- END OF TESTS ---*/
if (nerrors) {
- printf("***** %d HYPERSLAB TEST%s FAILED! *****\n",
- nerrors, 1 == nerrors ? "" : "S");
- if (isatty(1)) {
- printf("(Redirect output to a pager or a file to see "
- "debug output)\n");
- }
- exit(1);
+ printf("***** %d HYPERSLAB TEST%s FAILED! *****\n",
+ nerrors, 1 == nerrors ? "" : "S");
+ if (isatty(1)) {
+ printf("(Redirect output to a pager or a file to see "
+ "debug output)\n");
+ }
+ exit(1);
}
printf("All hyperslab tests passed.\n");
return 0;
diff --git a/test/testhdf5.c b/test/testhdf5.c
index 40abfb5..85cc2bf 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -171,7 +171,7 @@ main(int argc, char *argv[])
H5version(&major, &minor, &release, &patch);
print_func("\nFor help use: testhdf5 -help\n");
- print_func("Linked with HDF %u.%u.%u%c\n\n", (unsigned) major,
+ print_func("Linked with hdf5-%u.%u.%u%c\n\n", (unsigned) major,
(unsigned) minor, (unsigned) release, 'a' + patch);
for (CLLoop = 1; CLLoop < argc; CLLoop++) {
if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-verbose") == 0) ||
diff --git a/test/tfile.c b/test/tfile.c
index 1daca76..ffb399e 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -32,8 +32,8 @@ static char RcsId[] = "$Revision$";
#include <H5Mprivate.h>
#define F1_USERBLOCK_SIZE 0
-#define F1_OFFSET_SIZE 4
-#define F1_LENGTH_SIZE 4
+#define F1_OFFSET_SIZE sizeof(size_t)
+#define F1_LENGTH_SIZE sizeof(size_t)
#define F1_SYM_LEAF_K 4
#define F1_SYM_INTERN_K 16
#define FILE1 "tfile1.h5"