summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-01-22 15:27:29 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-01-22 15:27:29 (GMT)
commitfdfb6dfd26410b931b4452f832b5a4aedec283e0 (patch)
tree052c551e3cb4f99b2c77af519dce3d3d6ae7429c /src
parent851b17c87ad6f841efb5a5ba1b90b8c6636a2ffd (diff)
downloadhdf5-fdfb6dfd26410b931b4452f832b5a4aedec283e0.zip
hdf5-fdfb6dfd26410b931b4452f832b5a4aedec283e0.tar.gz
hdf5-fdfb6dfd26410b931b4452f832b5a4aedec283e0.tar.bz2
[svn-r163] Changes since 19980121
---------------------- ./Makefile.in Added more dependencies to .PHONY. ./src/H5D.c The write side of the I/O pipeline is implemented now too. Things are looking good for the prototype and it's just a matter of populating the library with the data type and data space conversion functions. ./src/H5Farray.c ./src/H5Fprivate.h ./test/istore.c Changed the order of the arguments for H5F_arr_read() and H5F_arr_write(). ./src/H5P.c ./src/H5Pprivate.h Changed the names of the arguments of H5P_find(). Fleshed out the mgath and fscat callback types. ./src/H5Psimp.c Added stubs for H5P_simp_mgath() and H5P_simp_fscat() that operate on the entire data space. Quincey, once you have the data space hyperslab stuff in place let me know and I'll finish the H5P_simp_*() functions to do partial I/O. Or you can take a look at it too if you like; there's some comments in there for you. ./src/H5V.c ./src/H5Vprivate.h Changed dimensionality arguments from `size_t' to `intn' to be consistent with the rest of the library and to get rid of warnings on 64-bit Irix.
Diffstat (limited to 'src')
-rw-r--r--src/H5D.c168
-rw-r--r--src/H5Farray.c16
-rw-r--r--src/H5Fprivate.h8
-rw-r--r--src/H5P.c15
-rw-r--r--src/H5Pprivate.h20
-rw-r--r--src/H5Psimp.c100
-rw-r--r--src/H5V.c22
-rw-r--r--src/H5Vprivate.h22
8 files changed, 229 insertions, 142 deletions
diff --git a/src/H5D.c b/src/H5D.c
index 869e79f..0e0a13b 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -235,9 +235,9 @@ H5Dcreate(hid_t file_id, const char *name, hid_t type_id, hid_t space_id,
hid_t
H5Dopen(hid_t file_id, const char *name)
{
- H5F_t *file = NULL; /*file holding the dataset */
- H5D_t *dataset = NULL; /*the dataset */
- hid_t ret_value = FAIL;
+ H5F_t *file = NULL; /*file holding the dataset */
+ H5D_t *dataset = NULL; /*the dataset */
+ hid_t ret_value = FAIL;
FUNC_ENTER(H5Dopen, FAIL);
H5ECLEAR;
@@ -250,10 +250,12 @@ H5Dopen(hid_t file_id, const char *name)
if (!name || !*name) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
}
+
/* Find the dataset */
if (NULL == (dataset = H5D_open(file, name))) {
HRETURN_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "dataset not found");
}
+
/* Create an atom for the dataset */
if ((ret_value = H5Aregister_atom(H5_DATASET, dataset)) < 0) {
H5D_close(dataset);
@@ -262,7 +264,7 @@ H5Dopen(hid_t file_id, const char *name)
}
FUNC_LEAVE(ret_value);
}
-
+
/*-------------------------------------------------------------------------
* Function: H5Dclose
*
@@ -395,14 +397,15 @@ H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
if (!buf) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer");
}
+
/* read raw data */
if (H5D_read(dataset, mem_type, mem_space, file_space, xfer_parms,
- buf /*out */ ) < 0) {
+ buf/*out*/) < 0) {
HRETURN_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data");
}
FUNC_LEAVE(SUCCEED);
}
-
+
/*-------------------------------------------------------------------------
* Function: H5Dwrite
*
@@ -484,6 +487,7 @@ H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
if (!buf) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer");
}
+
/* write raw data */
if (H5D_write(dataset, mem_type, mem_space, file_space, xfer_parms,
buf) < 0) {
@@ -491,7 +495,7 @@ H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
}
FUNC_LEAVE(SUCCEED);
}
-
+
/*-------------------------------------------------------------------------
* Function: H5D_find_name
*
@@ -517,7 +521,7 @@ H5D_find_name(hid_t file_id, group_t UNUSED, const char *name)
{
return H5Dopen(file_id, name);
}
-
+
/*-------------------------------------------------------------------------
* Function: H5D_create
*
@@ -544,7 +548,7 @@ H5D_find_name(hid_t file_id, group_t UNUSED, const char *name)
*
*-------------------------------------------------------------------------
*/
-H5D_t *
+H5D_t *
H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
const H5D_create_t *create_parms)
{
@@ -582,6 +586,7 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
"can't update type or space header messages");
}
+
/* Total raw data size */
nbytes = H5T_get_size(type) * H5P_get_npoints(space);
new_dset->layout.type = new_dset->create_parms.layout;
@@ -620,10 +625,12 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
"unable to initialize storage");
}
+
/* Give the dataset a name */
if (H5G_insert(name, &(new_dset->ent)) < 0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset");
}
+
/* Success */
ret_value = new_dset;
@@ -641,7 +648,7 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
}
FUNC_LEAVE(ret_value);
}
-
+
/*-------------------------------------------------------------------------
* Function: H5D_open
*
@@ -664,9 +671,9 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
H5D_t *
H5D_open(H5F_t *f, const char *name)
{
- H5D_t *dataset = NULL; /*the dataset which was found */
- H5D_t *ret_value = NULL; /*return value */
- intn i;
+ H5D_t *dataset = NULL; /*the dataset which was found */
+ H5D_t *ret_value = NULL; /*return value */
+ intn i;
FUNC_ENTER(H5D_open, NULL);
@@ -686,10 +693,10 @@ H5D_open(H5F_t *f, const char *name)
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 = H5P_read(f, &(dataset->ent)))) {
+ if (NULL==(dataset->type=H5O_read(&(dataset->ent), H5O_DTYPE, 0, NULL)) ||
+ NULL==(dataset->space=H5P_read(f, &(dataset->ent)))) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
- "can't load type of space info from dataset header");
+ "unable to load type or space info from dataset header");
}
/*
* Get the raw data layout info. It's actually stored in two locations:
@@ -697,7 +704,7 @@ H5D_open(H5F_t *f, const char *name)
* values are copied to the dataset create template so the user can query
* them.
*/
- if (H5O_read(&(dataset->ent), H5O_LAYOUT, 0, &(dataset->layout)) < 0) {
+ if (NULL==H5O_read(&(dataset->ent), H5O_LAYOUT, 0, &(dataset->layout))) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
"unable to read data layout message");
}
@@ -741,7 +748,7 @@ H5D_open(H5F_t *f, const char *name)
}
FUNC_LEAVE(ret_value);
}
-
+
/*-------------------------------------------------------------------------
* Function: H5D_close
*
@@ -774,9 +781,6 @@ H5D_close(H5D_t *dataset)
/* check args */
assert(dataset && dataset->ent.file);
- /* Close the dataset object */
- H5O_close(&(dataset->ent));
-
/*
* Release dataset type and space - there isn't much we can do if one of
* these fails, so we just continue.
@@ -784,6 +788,9 @@ H5D_close(H5D_t *dataset)
free_failed = (H5T_close(dataset->type) < 0 ||
H5P_close(dataset->space) < 0);
+ /* Close the dataset object */
+ H5O_close(&(dataset->ent));
+
/*
* Free memory. Before freeing the memory set the file pointer to NULL.
* We always check for a null file pointer in other H5D functions to be
@@ -823,13 +830,13 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
const H5P_t *file_space, const H5D_xfer_t *xfer_parms,
void *buf/*out*/)
{
- size_t nelmts, src_size, dst_size;
- herr_t ret_value = FAIL;
+ size_t nelmts ; /*number of elements */
uint8 *tconv_buf = NULL; /*data type conv buffer */
H5T_conv_t tconv_func = NULL; /*conversion function */
hid_t src_id = -1, dst_id = -1;/*temporary type atoms */
const H5P_conv_t *sconv_func = NULL; /*space conversion funcs*/
H5P_number_t numbering; /*element numbering info*/
+ herr_t ret_value = FAIL;
FUNC_ENTER(H5D_read, FAIL);
@@ -840,6 +847,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
assert(buf);
if (!file_space) file_space = dataset->space;
if (!mem_space) mem_space = file_space;
+ assert (H5P_get_npoints (mem_space)==H5P_get_npoints (file_space));
/*
* Convert data types to atoms because the conversion functions are
@@ -852,16 +860,16 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
}
/*
- * Locate the type conversion function, data space conversion, and set up
- * the element numbering information.
+ * Locate the type conversion function and data space conversion
+ * functions, and set up the element numbering information.
*/
if (NULL == (tconv_func = H5T_find(dataset->type, mem_type))) {
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
"unable to convert between src and dest data types");
}
- if (NULL==(sconv_func=H5P_find (file_space, mem_space))) {
+ if (NULL==(sconv_func=H5P_find (mem_space, file_space))) {
HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "unable to convert between src and dest data spaces");
+ "unable to convert from file to memory data space");
}
if (sconv_func->init &&
(sconv_func->init)(&(dataset->layout), mem_space, file_space,
@@ -875,15 +883,17 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
/*
* Compute the size of the request and allocate scratch buffers.
*/
+ nelmts = H5P_get_npoints(mem_space);
#ifndef LATER
/*
* Note: this prototype version allocates a buffer large enough to
* satisfy the entire request; strip mining is not implemented.
*/
- nelmts = H5P_get_npoints(dataset->space);
- src_size = nelmts * H5T_get_size(dataset->type);
- dst_size = nelmts * H5T_get_size(mem_type);
- tconv_buf = H5MM_xmalloc(MAX(src_size, dst_size));
+ {
+ size_t src_size = nelmts * H5T_get_size(dataset->type);
+ size_t dst_size = nelmts * H5T_get_size(mem_type);
+ tconv_buf = H5MM_xmalloc(MAX(src_size, dst_size));
+ }
#endif
/*
@@ -892,7 +902,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
if ((sconv_func->fgath)(dataset->ent.file, &(dataset->layout),
H5T_get_size (dataset->type), file_space,
&numbering, 0, nelmts,
- tconv_buf/*out*/)<0) {
+ tconv_buf/*out*/)!=nelmts) {
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "gather failed");
}
@@ -942,15 +952,13 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
const H5P_t *file_space, const H5D_xfer_t *xfer_parms,
const void *buf)
{
- size_t nelmts, src_size, dst_size;
- size_t offset[H5O_LAYOUT_NDIMS];
- size_t size[H5O_LAYOUT_NDIMS];
- size_t zero[H5O_LAYOUT_NDIMS];
- intn i;
- herr_t ret_value = FAIL;
- uint8 *tconv_buf = NULL; /*data type conversion buffer */
- H5T_conv_t tconv_func = NULL; /*data type conversion function */
- hid_t src_id = -1, dst_id = -1; /*temporary type atoms */
+ size_t nelmts;
+ uint8 *tconv_buf = NULL; /*data type conv buffer */
+ H5T_conv_t tconv_func = NULL; /*conversion function */
+ hid_t src_id = -1, dst_id = -1;/*temporary type atoms */
+ const H5P_conv_t *sconv_func = NULL; /*space conversion funcs*/
+ H5P_number_t numbering; /*element numbering info*/
+ herr_t ret_value = FAIL;
FUNC_ENTER(H5D_write, FAIL);
@@ -959,17 +967,9 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
assert(mem_type);
assert(xfer_parms);
assert(buf);
-
- if (H5D_CONTIGUOUS != dataset->create_parms.layout) {
- HRETURN_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "layout is not supported yet");
- }
- if ((mem_space && H5P_cmp(mem_space, dataset->space)) ||
- (file_space && H5P_cmp(file_space, dataset->space))) {
- HRETURN_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "space conversion not supported yet");
- }
- assert (!mem_space || H5P_SIMPLE==mem_space->type);
+ if (!file_space) file_space = dataset->space;
+ if (!mem_space) mem_space = file_space;
+ assert (H5P_get_npoints (mem_space)==H5P_get_npoints (file_space));
/*
* Convert data types to atoms because the conversion functions are
@@ -982,31 +982,50 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
}
/*
+ * Locate the type conversion function and data space conversion
+ * functions, and set up the element numbering information.
+ */
+ if (NULL == (tconv_func = H5T_find(mem_type, dataset->type))) {
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "unable to convert between src and dest data types");
+ }
+ if (NULL==(sconv_func=H5P_find (mem_space, file_space))) {
+ HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "unable to convert from memory to file data space");
+ }
+ if (sconv_func->init &&
+ (sconv_func->init)(&(dataset->layout), mem_space, file_space,
+ &numbering/*out*/)<=0) {
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL,
+ "unable to initialize element numbering information");
+ } else {
+ HDmemset (&numbering, 0, sizeof numbering);
+ }
+
+ /*
* Compute the size of the request and allocate scratch buffers.
*/
+ nelmts = H5P_get_npoints(dataset->space);
#ifndef LATER
/*
* Note: This prototype version allocates a buffer large enough to
* satisfy the entire request; strip mining is not implemented.
*/
- nelmts = H5P_get_npoints(dataset->space);
- src_size = nelmts * H5T_get_size(mem_type);
- dst_size = nelmts * H5T_get_size(dataset->type);
- tconv_buf = H5MM_xmalloc(MAX(src_size, dst_size));
+ {
+ size_t src_size = nelmts * H5T_get_size(mem_type);
+ size_t dst_size = nelmts * H5T_get_size(dataset->type);
+ tconv_buf = H5MM_xmalloc(MAX(src_size, dst_size));
+ }
#endif
- /*
- * Locate the type conversion function.
- */
- if (NULL == (tconv_func = H5T_find(mem_type, dataset->type))) {
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "unable to convert between src and dest data types");
- }
/*
* Gather data into the data type conversion buffer.
*/
- HDmemcpy(tconv_buf, buf, src_size);
+ if ((sconv_func->mgath)(buf, H5T_get_size (mem_type), mem_space,
+ &numbering, 0, nelmts, tconv_buf/*out*/)!=nelmts) {
+ HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "gather failed");
+ }
/*
* Perform data type conversion.
@@ -1019,23 +1038,10 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
/*
* Scatter the data out to the file.
*/
-#ifndef LATER
- /*
- * Note: We only support complete writes currently. That si, the
- * hyperslab must begin at zero in memory and on disk and the size
- * of the hyperslab must be the same as the array on disk.
- */
- for (i = 0; i < dataset->layout.ndims; i++) {
- zero[i] = 0;
- offset[i] = 0;
- }
- i = H5P_get_dims (dataset->space, size);
- assert (i+1==dataset->layout.ndims);
- size[i] = H5T_get_size (dataset->type);
-#endif
- if (H5F_arr_write(dataset->ent.file, &(dataset->layout), size, offset,
- zero, size, tconv_buf) < 0) {
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write failed");
+ if ((sconv_func->fscat)(dataset->ent.file, &(dataset->layout),
+ H5T_get_size (dataset->type), file_space,
+ &numbering, 0, nelmts, tconv_buf)<0) {
+ HGOTO_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed");
}
ret_value = SUCCEED;
diff --git a/src/H5Farray.c b/src/H5Farray.c
index 8f5e3b4..0bbb355 100644
--- a/src/H5Farray.c
+++ b/src/H5Farray.c
@@ -112,13 +112,13 @@ H5F_arr_create (H5F_t *f, struct H5O_layout_t *layout/*in,out*/)
*/
herr_t
H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
- const size_t _hslab_size[], const size_t file_offset[],
- const size_t mem_offset[], const size_t mem_size[],
+ const size_t _hslab_size[], const size_t mem_size[],
+ const size_t mem_offset[], const size_t file_offset[],
void *_buf/*out*/)
{
uint8 *buf = (uint8 *)_buf; /*cast for arithmetic */
- size_t file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */
- size_t mem_stride[H5O_LAYOUT_NDIMS]; /*strides through memory*/
+ intn file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */
+ intn 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 */
@@ -247,13 +247,13 @@ H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
*/
herr_t
H5F_arr_write (H5F_t *f, const struct H5O_layout_t *layout,
- const size_t _hslab_size[], const size_t file_offset[],
- const size_t mem_offset[], const size_t mem_size[],
+ const size_t _hslab_size[], const size_t mem_size[],
+ const size_t mem_offset[], const size_t file_offset[],
const void *_buf)
{
const uint8 *buf = (const uint8 *)_buf; /*cast for arithmetic */
- size_t file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */
- size_t mem_stride[H5O_LAYOUT_NDIMS]; /*strides through memory*/
+ intn file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */
+ intn 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 ec3bb94..b9cea0b 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -408,12 +408,12 @@ herr_t H5F_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
/* Functions that operate on array storage */
herr_t H5F_arr_create(H5F_t *f, struct H5O_layout_t *layout /*in,out */ );
herr_t H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
- const size_t _hslab_size[], const size_t file_offset[],
- const size_t mem_offset[], const size_t mem_size[],
+ const size_t _hslab_size[], const size_t mem_size[],
+ const size_t mem_offset[], const size_t file_offset[],
void *_buf/*out*/);
herr_t H5F_arr_write (H5F_t *f, const struct H5O_layout_t *layout,
- const size_t _hslab_size[], const size_t file_offset[],
- const size_t mem_offset[], const size_t mem_size[],
+ const size_t _hslab_size[], const size_t mem_size[],
+ const size_t mem_offset[], const size_t file_offset[],
const void *_buf);
/* Functions that operate on indexed storage */
diff --git a/src/H5P.c b/src/H5P.c
index f6b0ff1..1524bac 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -896,9 +896,10 @@ H5Pset_space(hid_t sid, intn rank, const size_t *dims)
/*-------------------------------------------------------------------------
* Function: H5P_find
*
- * Purpose: Given source and destination data spaces (SRC and DST) this
+ * Purpose: Given two data spaces (MEM_SPACE and FILE_SPACE) this
* function locates the data space conversion functions and
- * initializes CONV to point to them.
+ * initializes CONV to point to them. The CONV contains
+ * function pointers for converting in either direction.
*
* Return: Success: Pointer to a data space conversion callback
* list.
@@ -913,7 +914,7 @@ H5Pset_space(hid_t sid, intn rank, const size_t *dims)
*-------------------------------------------------------------------------
*/
const H5P_conv_t *
-H5P_find (const H5P_t *src, const H5P_t *dst)
+H5P_find (const H5P_t *mem_space, const H5P_t *file_space)
{
static H5P_conv_t _conv;
static const H5P_conv_t *conv = NULL;
@@ -921,16 +922,16 @@ H5P_find (const H5P_t *src, const H5P_t *dst)
FUNC_ENTER (H5P_find, NULL);
/* Check args */
- assert (src && H5P_SIMPLE==src->type);
- assert (dst && H5P_SIMPLE==dst->type);
+ assert (mem_space && H5P_SIMPLE==mem_space->type);
+ assert (file_space && H5P_SIMPLE==file_space->type);
/*
* We can't do conversion if the source and destination select a
* different number of data points.
*/
- if (H5P_get_npoints (src) != H5P_get_npoints (dst)) {
+ if (H5P_get_npoints (mem_space) != H5P_get_npoints (file_space)) {
HRETURN_ERROR (H5E_DATASPACE, H5E_BADRANGE, NULL,
- "src and dest data spaces are different sizes");
+ "memory and file data spaces are different sizes");
}
/*
diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h
index e5dca7e..8b323b2 100644
--- a/src/H5Pprivate.h
+++ b/src/H5Pprivate.h
@@ -72,10 +72,15 @@ typedef struct H5P_tconv_t {
intn start, intn nelmts, void *buf/*out*/);
/* Gather elements from app buffer to type conversion buffer */
- size_t (*mgath)(void /*fill out later*/);
+ size_t (*mgath)(const void *buf, size_t elmt_size,
+ const H5P_t *mem_space, const H5P_number_t *numbering,
+ intn start, intn nelmts, void *tconv_buf/*out*/);
/* Scatter elements from type conversion buffer to disk */
- herr_t (*fscat)(void /*fill out later*/);
+ herr_t (*fscat)(H5F_t *f, const struct H5O_layout_t *layout,
+ size_t elmt_size, const H5P_t *file_space,
+ const H5P_number_t *numbering, intn start, intn nelmts,
+ const void *tconv_buf);
} H5P_conv_t;
H5P_t *H5P_copy (const H5P_t *src);
@@ -88,7 +93,7 @@ H5P_t *H5P_read (H5F_t *f, H5G_entry_t *ent);
intn H5P_cmp (const H5P_t *ds1, const H5P_t *ds2);
hbool_t H5P_is_simple (const H5P_t *sdim);
uintn H5P_nelem (const H5P_t *space);
-const H5P_conv_t *H5P_find (const H5P_t *src, const H5P_t *dst);
+const H5P_conv_t *H5P_find (const H5P_t *mem_space, const H5P_t *file_space);
/* Conversion functions for simple data spaces */
size_t H5P_simp_init (const struct H5O_layout_t *layout,
@@ -101,7 +106,12 @@ size_t H5P_simp_fgath (H5F_t *f, const struct H5O_layout_t *layout,
herr_t H5P_simp_mscat (const void *tconv_buf, size_t elmt_size,
const H5P_t *mem_space, const H5P_number_t *numbering,
intn start, intn nelmts, void *buf/*out*/);
-size_t H5P_simp_mgath (void);
-herr_t H5P_simp_fscat (void);
+size_t H5P_simp_mgath (const void *buf, size_t elmt_size,
+ const H5P_t *mem_space, const H5P_number_t *numbering,
+ intn start, intn nelmts, void *tconv_buf/*out*/);
+herr_t H5P_simp_fscat (H5F_t *f, const struct H5O_layout_t *layout,
+ size_t elmt_size, const H5P_t *file_space,
+ const H5P_number_t *numbering, intn start, intn nelmts,
+ const void *tconv_buf);
#endif
diff --git a/src/H5Psimp.c b/src/H5Psimp.c
index a5dd7ec..1cd46c4 100644
--- a/src/H5Psimp.c
+++ b/src/H5Psimp.c
@@ -124,7 +124,7 @@ H5P_simp_fgath (H5F_t *f, const struct H5O_layout_t *layout,
/*
* Gather from file.
*/
- if (H5F_arr_read (f, layout, size, offset, offset, size, buf/*out*/)<0) {
+ if (H5F_arr_read (f, layout, size, size, offset, offset, buf/*out*/)<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_READERROR, 0, "read error");
}
@@ -175,7 +175,8 @@ H5P_simp_mscat (const void *tconv_buf, size_t elmt_size,
/*
* Quincey, this is where we look at the hyperslab spec of MEM_SPACE to
- * figure out how to scatter. For now we just assume that data points
+ * figure out how to scatter. You'll probably end up calling
+ * H5V_hyper_copy(), but for now we just assume that data points
* are copied directly from TCONV_BUF to BUF.
*/
HDmemcpy (buf, tconv_buf, nelmts*elmt_size);
@@ -186,9 +187,14 @@ H5P_simp_mscat (const void *tconv_buf, size_t elmt_size,
/*-------------------------------------------------------------------------
* Function: H5P_simp_mgath
*
- * Purpose: Gathers dataset elements from application memory and copies
- * them into the data type conversion buffer. NOT IMPLEMENTED
- * YET.
+ * Purpose: Gathers dataset elements from application memory BUF and
+ * copies them into the data type conversion buffer TCONV_BUF.
+ * Each element is ELMT_SIZE bytes and arranged in application
+ * memory according to MEM_SPACE. The elements selected from
+ * BUF by MEM_SPACE are numbered according to NUMBERING and the
+ * caller is requesting that at most NELMTS be gathered
+ * beginning with number START. The elements are packed into
+ * TCONV_BUF in order of their NUMBERING.
*
* Return: Success: Number of elements copied.
*
@@ -202,21 +208,47 @@ H5P_simp_mscat (const void *tconv_buf, size_t elmt_size,
*-------------------------------------------------------------------------
*/
size_t
-H5P_simp_mgath (void)
+H5P_simp_mgath (const void *buf, size_t elmt_size,
+ const H5P_t *mem_space, const H5P_number_t *numbering,
+ intn start, intn nelmts, void *tconv_buf/*out*/)
{
FUNC_ENTER (H5P_simp_mgath, 0);
- HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, 0,
- "not implemented yet");
+ /* Check args */
+ assert (buf);
+ assert (elmt_size>0);
+ assert (mem_space && H5P_SIMPLE==mem_space->type);
+ assert (numbering);
+ assert (nelmts>0);
+ assert (tconv_buf);
+
+ /*
+ * The prototype doesn't support strip mining.
+ */
+ assert (0==start);
+ assert (nelmts==H5P_get_npoints (mem_space));
+
+ /*
+ * Quincey, this is where we look at the hyperslab spec of MEM_SPACE to
+ * figure out how to gather. You'll probably end up calling
+ * H5V_hyper_copy(), but for now we just assume that data points are
+ * copied directly from BUF to TCONV_BUF.
+ */
+ HDmemcpy (tconv_buf, buf, nelmts*elmt_size);
- FUNC_LEAVE (0);
+ FUNC_LEAVE (nelmts);
}
/*-------------------------------------------------------------------------
* Function: H5P_simp_fscat
*
- * Purpose: Scatters dataset elements from the type conversion buffer to
- * the file. NOT IMPLEMENTED YET.
+ * Purpose: Scatters dataset elements from the type conversion buffer BUF
+ * to the file F where the data points are arranged according to
+ * the file data space FILE_SPACE and stored according to
+ * LAYOUT. Each element is ELMT_SIZE bytes and has a unique
+ * number according to NUMBERING. The caller is requesting that
+ * NELMTS elements are coppied beginning with element number
+ * START.
*
* Return: Success: SUCCEED
*
@@ -230,12 +262,50 @@ H5P_simp_mgath (void)
*-------------------------------------------------------------------------
*/
herr_t
-H5P_simp_fscat (void)
+H5P_simp_fscat (H5F_t *f, const struct H5O_layout_t *layout,
+ size_t elmt_size, const H5P_t *file_space,
+ const H5P_number_t *numbering, intn start, intn nelmts,
+ const void *buf)
{
+ size_t offset[H5O_LAYOUT_NDIMS]; /*offset of hyperslab */
+ size_t size[H5O_LAYOUT_NDIMS]; /*size of hyperslab */
+ intn i; /*counters */
+
FUNC_ENTER (H5P_simp_fscat, FAIL);
- HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "not implemented yet");
+ /* Check args */
+ assert (f);
+ assert (layout);
+ assert (elmt_size>0);
+ assert (file_space);
+ assert (numbering);
+ assert (nelmts>0);
+ assert (buf);
+
+ /*
+ * The prototype doesn't support strip mining.
+ */
+ assert (0==start);
+ assert (nelmts==H5P_get_npoints (file_space));
+
+ /*
+ * Quincey, this is where we look at FILE_SPACE to decide what the
+ * hyperslab is to read from disk. For now, since the H5P interface
+ * doesn't support hyperslabs, we'll assume the caller is asking for the
+ * entire array. --RPM
+ */
+ assert (nelmts == H5P_get_npoints (file_space));
+ for (i=0; i<layout->ndims; i++) offset[i] = 0;
+ i = H5P_get_dims (file_space, size);
+ assert (i+1 == layout->ndims);
+ size[i] = elmt_size;
+
+ /*
+ * Scatter to file.
+ */
+ if (H5F_arr_write (f, layout, size, size, offset, offset, buf/*out*/)<0) {
+ HRETURN_ERROR (H5E_DATASPACE, H5E_WRITEERROR, 0, "write error");
+ }
- FUNC_LEAVE (FAIL);
+ FUNC_LEAVE (SUCCEED);
}
diff --git a/src/H5V.c b/src/H5V.c
index cd199a0..6b092a5 100644
--- a/src/H5V.c
+++ b/src/H5V.c
@@ -40,7 +40,7 @@ static hbool_t interface_initialize_g = TRUE;
*-------------------------------------------------------------------------
*/
herr_t
-H5V_stride_optimize1(size_t *np, size_t *elmt_size, size_t *size,
+H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size,
intn *stride1)
{
FUNC_ENTER(H5V_stride_optimize1, FAIL);
@@ -87,7 +87,7 @@ H5V_stride_optimize1(size_t *np, size_t *elmt_size, size_t *size,
*-------------------------------------------------------------------------
*/
herr_t
-H5V_stride_optimize2(size_t *np, size_t *elmt_size, size_t *size,
+H5V_stride_optimize2(intn *np, size_t *elmt_size, size_t *size,
intn *stride1, intn *stride2)
{
FUNC_ENTER(H5V_stride_optimize2, FAIL);
@@ -143,7 +143,7 @@ H5V_stride_optimize2(size_t *np, size_t *elmt_size, size_t *size,
*-------------------------------------------------------------------------
*/
size_t
-H5V_hyper_stride(size_t n, const size_t *size,
+H5V_hyper_stride(intn n, const size_t *size,
const size_t *total_size, const size_t *offset,
intn *stride/*out*/)
{
@@ -196,7 +196,7 @@ H5V_hyper_stride(size_t n, const size_t *size,
*-------------------------------------------------------------------------
*/
hbool_t
-H5V_hyper_eq(size_t n,
+H5V_hyper_eq(intn n,
const size_t *offset1, const size_t *size1,
const size_t *offset2, const size_t *size2)
{
@@ -238,7 +238,7 @@ H5V_hyper_eq(size_t n,
*-------------------------------------------------------------------------
*/
hbool_t
-H5V_hyper_disjointp(size_t n,
+H5V_hyper_disjointp(intn n,
const size_t *offset1, const size_t *size1,
const size_t *offset2, const size_t *size2)
{
@@ -282,7 +282,7 @@ H5V_hyper_disjointp(size_t n,
*-------------------------------------------------------------------------
*/
herr_t
-H5V_hyper_fill(size_t n, const size_t *_size,
+H5V_hyper_fill(intn n, const size_t *_size,
const size_t *total_size, const size_t *offset, void *_dst,
uint8 fill_value)
{
@@ -358,7 +358,7 @@ H5V_hyper_fill(size_t n, const size_t *_size,
*-------------------------------------------------------------------------
*/
herr_t
-H5V_hyper_copy(size_t n, const size_t *_size,
+H5V_hyper_copy(intn n, const size_t *_size,
/*destination*/
const size_t *dst_size, const size_t *dst_offset,
@@ -433,7 +433,7 @@ H5V_hyper_copy(size_t n, const size_t *_size,
*-------------------------------------------------------------------------
*/
herr_t
-H5V_stride_fill(size_t n, size_t elmt_size, const size_t *size,
+H5V_stride_fill(intn n, size_t elmt_size, const size_t *size,
const intn *stride, void *_dst, uint8 fill_value)
{
uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */
@@ -489,7 +489,7 @@ H5V_stride_fill(size_t n, size_t elmt_size, const size_t *size,
*-------------------------------------------------------------------------
*/
herr_t
-H5V_stride_copy(size_t n, size_t elmt_size, const size_t *size,
+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)
{
@@ -545,11 +545,11 @@ herr_t
H5V_stride_copy2(size_t nelmts, size_t elmt_size,
/* destination */
- size_t dst_n, const size_t *dst_size, const intn *dst_stride,
+ intn dst_n, const size_t *dst_size, const intn *dst_stride,
void *_dst,
/* source */
- size_t src_n, const size_t *src_size, const intn *src_stride,
+ intn src_n, const size_t *src_size, const intn *src_stride,
const void *_src)
{
uint8 *dst = (uint8 *) _dst;
diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h
index 34d1993..870b415 100644
--- a/src/H5Vprivate.h
+++ b/src/H5Vprivate.h
@@ -28,31 +28,31 @@
/* A null pointer is equivalent to a zero vector */
#define H5V_ZERO NULL
-size_t H5V_hyper_stride(size_t n, const size_t *size, const size_t *total_size,
+size_t H5V_hyper_stride(intn n, const size_t *size, const size_t *total_size,
const size_t *offset, intn *stride);
-hbool_t H5V_hyper_disjointp(size_t n, const size_t *offset1,
+hbool_t H5V_hyper_disjointp(intn n, const size_t *offset1,
const size_t *size1, const size_t *offset2,
const size_t *size2);
-hbool_t H5V_hyper_eq(size_t n, const size_t *offset1, const size_t *size1,
+hbool_t H5V_hyper_eq(intn n, const size_t *offset1, const size_t *size1,
const size_t *offset2, const size_t *size2);
-herr_t H5V_hyper_fill(size_t n, const size_t *total_size, const size_t *offset,
+herr_t H5V_hyper_fill(intn n, const size_t *total_size, const size_t *offset,
const size_t *size, void *buf, uint8 val);
-herr_t H5V_hyper_copy(size_t n, const size_t *size,
+herr_t H5V_hyper_copy(intn n, const size_t *size,
const size_t *dst_total_size, const size_t *dst_offset,
void *_dst, const size_t *src_total_size,
const size_t *src_offset, const void *_src);
-herr_t H5V_stride_fill(size_t n, size_t elmt_size, 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);
-herr_t H5V_stride_copy(size_t 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);
-herr_t H5V_stride_copy2(size_t nelmts, size_t elmt_size, size_t dst_n,
+herr_t H5V_stride_copy2(size_t nelmts, size_t elmt_size, intn dst_n,
const size_t *dst_size, const intn *dst_stride,
- void *_dst, size_t src_n, const size_t *src_size,
+ void *_dst, intn src_n, const size_t *src_size,
const intn *src_stride, const void *_src);
-herr_t H5V_stride_optimize1(size_t *np, size_t *elmt_size, size_t *size,
+herr_t H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size,
intn *stride1);
-herr_t H5V_stride_optimize2(size_t *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);