[svn-r185] Changes since 19980128

----------------------

./src/H5D.c
./src/H5Dpublic.c
	Added H5Dget_space().

./src/H5Gstab.c
./src/H5H.c
	Fixed a comparison with size_t against <0.

./src/H5P.c
./src/H5Pprivate.h
./src/H5Ppublic.h
	Changed `intn' to `int' for public function args and
	returns. H5Pget_hyperslab() returns the dimensionality.

./test/testhdf5.h
	Clears error stack more frequently.

./src/H5Psimp.c
./test/cmpd_dset.c
	Impelementing data space conversion.
This commit is contained in:
Robb Matzke 1998-01-28 11:50:09 -05:00
parent 538069b3e0
commit c0cfc4421a
11 changed files with 766 additions and 537 deletions

View File

@ -38,7 +38,7 @@ struct H5D_t {
H5G_entry_t ent; /*cached object header stuff */
H5T_t *type; /*datatype of this dataset */
H5P_t *space; /*dataspace of this dataset */
H5D_create_t create_parms; /*creation parameters */
H5D_create_t create_parms; /*creation parameters */
H5O_layout_t layout; /*data layout */
};
@ -313,6 +313,54 @@ H5Dclose(hid_t dataset_id)
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Dget_space
*
* Purpose: Returns a copy of the file data space for a dataset.
*
* Return: Success: ID for a copy of the data space. The data
* space should be released by calling
* H5Dclose().
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 28, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
hid_t
H5Dget_space (hid_t dataset_id)
{
H5D_t *dataset = NULL;
H5P_t *copied_space = NULL;
hid_t ret_value = FAIL;
FUNC_ENTER (H5Dget_space, FAIL);
/* Check args */
if (H5_DATASET!=H5A_group (dataset_id) ||
NULL==(dataset=H5A_object (dataset_id))) {
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
}
/* Copy the data space */
if (NULL==(copied_space=H5P_copy (dataset->space))) {
HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL,
"unable to copy the data space");
}
/* Create an atom */
if ((ret_value=H5A_register (H5_DATASPACE, copied_space))<0) {
HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL,
"unable to register data space");
}
FUNC_LEAVE (ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Dread
*

View File

@ -39,6 +39,7 @@ hid_t H5Dcreate (hid_t file_id, const char *name, hid_t type_id,
hid_t space_id, hid_t create_parms_id);
hid_t H5Dopen (hid_t file_id, const char *name);
herr_t H5Dclose (hid_t dataset_id);
hid_t H5Dget_space (hid_t dataset_id);
herr_t H5Dread (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t xfer_parms_id, void *buf/*out*/);
herr_t H5Dwrite (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,

File diff suppressed because it is too large Load Diff

View File

@ -65,9 +65,11 @@ H5G_stab_create(H5F_t *f, size_t init, H5G_entry_t *self /*out */ )
if (H5H_create(f, H5H_LOCAL, init, &(stab.heap_addr) /*out */ ) < 0) {
HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create heap");
}
if ((name = H5H_insert(f, &(stab.heap_addr), 1, "") < 0)) {
name = H5H_insert(f, &(stab.heap_addr), 1, "");
if ((size_t)(-1)==name) {
HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't initialize heap");
}
/*
* B-tree's won't work if the first name isn't at the beginning
* of the heap.

View File

@ -529,7 +529,7 @@ H5H_remove_free(H5H_t *heap, H5H_free_t *fl)
*
* Return: Success: Offset of new item within heap.
*
* Failure: FAIL
* Failure: (size_t)(-1)
*
* Programmer: Robb Matzke
* matzke@llnl.gov
@ -551,18 +551,17 @@ H5H_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
static nmessages = 0;
#endif
FUNC_ENTER(H5H_insert, FAIL);
FUNC_ENTER(H5H_insert, (size_t)(-1));
/* check arguments */
assert(f);
if (!addr)
addr = &(f->shared->smallobj_addr);
if (!addr) addr = &(f->shared->smallobj_addr);
assert(H5F_addr_defined(addr));
assert(buf_size > 0);
assert(buf);
if (NULL == (heap = H5AC_find(f, H5AC_HEAP, addr, NULL, NULL))) {
HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL,
HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, (size_t)(-1),
"unable to load heap");
}
heap->dirty += 1;
@ -579,7 +578,8 @@ H5H_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
* leave zero or at least H5G_SIZEOF_FREE bytes left over.
*/
for (fl = heap->freelist, found = FALSE; fl; fl = fl->next) {
if (fl->size > need_size && fl->size - need_size >= H5H_SIZEOF_FREE(f)) {
if (fl->size > need_size &&
fl->size - need_size >= H5H_SIZEOF_FREE(f)) {
/* a bigger free block was found */
offset = fl->offset;
fl->offset += need_size;
@ -622,8 +622,8 @@ H5H_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
fprintf(stderr, "H5H_insert: lost %lu bytes at line %d\n",
(unsigned long) (max_fl->size), __LINE__);
if (0 == nmessages++) {
fprintf(stderr, "Messages from H5H_insert() will go away "
"when assertions are turned off.\n");
fprintf(stderr, "Messages from H5H_insert() will go "
"away when assertions are turned off.\n");
}
}
#endif

View File

@ -102,7 +102,7 @@ H5P_term_interface(void)
*-------------------------------------------------------------------------
*/
hid_t
H5Pcreate_simple(intn rank, size_t dims[])
H5Pcreate_simple(int rank, size_t dims[])
{
H5P_t *ds = NULL;
hid_t ret_value = FAIL;
@ -301,7 +301,7 @@ H5P_close(H5P_t *ds)
*
*-------------------------------------------------------------------------
*/
H5P_t *
H5P_t *
H5P_copy(const H5P_t *src)
{
H5P_t *dst = NULL;
@ -421,8 +421,18 @@ H5P_get_npoints(const H5P_t *ds)
break;
case H5P_SIMPLE:
for (ret_value = 1, i = 0; i < ds->u.simple.rank; i++) {
ret_value *= ds->u.simple.size[i];
/*
* Count the elements selected by the hypeslab if there is one,
* otherwise count all the elements.
*/
if (ds->hslab_def) {
for (ret_value=1, i=0; i<ds->u.simple.rank; i++) {
ret_value *= ds->h.count[i];
}
} else {
for (ret_value=1, i=0; i<ds->u.simple.rank; i++) {
ret_value *= ds->u.simple.size[i];
}
}
break;
@ -455,7 +465,7 @@ H5P_get_npoints(const H5P_t *ds)
*
*-------------------------------------------------------------------------
*/
intn
int
H5Pget_ndims(hid_t space_id)
{
H5P_t *ds = NULL;
@ -541,8 +551,8 @@ H5P_get_ndims(const H5P_t *ds)
*
*-------------------------------------------------------------------------
*/
intn
H5Pget_dims(hid_t space_id, size_t dims[] /*out */ )
int
H5Pget_dims(hid_t space_id, size_t dims[]/*out*/)
{
H5P_t *ds = NULL;
@ -684,7 +694,7 @@ H5P_modify(H5F_t *f, H5G_entry_t *ent, const H5P_t *ds)
*
*-------------------------------------------------------------------------
*/
H5P_t *
H5P_t *
H5P_read(H5F_t *f, H5G_entry_t *ent)
{
H5P_t *ds = NULL;
@ -895,7 +905,7 @@ H5Pis_simple(hid_t sid)
be unlimited in size.
--------------------------------------------------------------------------*/
herr_t
H5Pset_space(hid_t sid, intn rank, const size_t *dims)
H5Pset_space(hid_t sid, int rank, const size_t *dims)
{
H5P_t *space = NULL; /* dataspace to modify */
intn u; /* local counting variable */
@ -1087,7 +1097,7 @@ done:
* space. If no hyperslab has been defined then the hyperslab
* is the same as the entire array.
*
* Return: Success: SUCCEED
* Return: Success: Hyperslab dimensionality.
*
* Failure: FAIL
*
@ -1098,11 +1108,12 @@ done:
*
*-------------------------------------------------------------------------
*/
herr_t
int
H5Pget_hyperslab (hid_t sid, size_t offset[]/*out*/, size_t size[]/*out*/,
size_t stride[]/*out*/)
{
H5P_t *ds = NULL;
const H5P_t *ds = NULL;
intn ret_value = FAIL;
FUNC_ENTER (H5Pget_hyperslab, FAIL);
H5ECLEAR;
@ -1113,12 +1124,12 @@ H5Pget_hyperslab (hid_t sid, size_t offset[]/*out*/, size_t size[]/*out*/,
}
/* Get hyperslab info */
if (H5P_get_hyperslab (ds, offset, size, stride)<0) {
if ((ret_value=H5P_get_hyperslab (ds, offset, size, stride))<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
"unable to retrieve hyperslab information");
}
FUNC_LEAVE (SUCCEED);
FUNC_LEAVE (ret_value);
}
/*-------------------------------------------------------------------------
@ -1128,7 +1139,7 @@ H5Pget_hyperslab (hid_t sid, size_t offset[]/*out*/, size_t size[]/*out*/,
* space. If no hyperslab has been defined then the hyperslab
* is the same as the entire array.
*
* Return: Success: SUCCEED
* Return: Success: Hyperslab dimensionality.
*
* Failure: FAIL
*
@ -1139,11 +1150,12 @@ H5Pget_hyperslab (hid_t sid, size_t offset[]/*out*/, size_t size[]/*out*/,
*
*-------------------------------------------------------------------------
*/
herr_t
H5P_get_hyperslab (H5P_t *ds, size_t offset[]/*out*/, size_t size[]/*out*/,
size_t stride[]/*out*/)
intn
H5P_get_hyperslab (const H5P_t *ds, size_t offset[]/*out*/,
size_t size[]/*out*/, size_t stride[]/*out*/)
{
intn i;
intn ret_value = FAIL;
FUNC_ENTER (H5P_get_hyperslab, FAIL);
@ -1167,6 +1179,7 @@ H5P_get_hyperslab (H5P_t *ds, size_t offset[]/*out*/, size_t size[]/*out*/,
if (stride) stride[i] = 1;
}
}
ret_value = ds->u.simple.rank;
break;
case H5P_COMPLEX: /*fall through*/
@ -1175,7 +1188,7 @@ H5P_get_hyperslab (H5P_t *ds, size_t offset[]/*out*/, size_t size[]/*out*/,
"hyperslabs not supported for this type of space");
}
FUNC_LEAVE (SUCCEED);
FUNC_LEAVE (ret_value);
}

View File

@ -102,8 +102,8 @@ 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 *mem_space, const H5P_t *file_space);
herr_t H5P_get_hyperslab (H5P_t *ds, size_t offset[]/*out*/,
size_t size[]/*out*/, size_t stride[]/*out*/);
intn H5P_get_hyperslab (const H5P_t *ds, size_t offset[]/*out*/,
size_t size[]/*out*/, size_t stride[]/*out*/);
/* Conversion functions for simple data spaces */
size_t H5P_simp_init (const struct H5O_layout_t *layout,

View File

@ -39,17 +39,17 @@ extern "C" {
#ifdef OLD_WAY
hid_t H5Pcreate (H5P_class_t type);
#endif /* OLD_WAY */
hid_t H5Pcreate_simple (intn rank, size_t dims[]);
hid_t H5Pcreate_simple (int rank, size_t dims[]);
herr_t H5Pclose (hid_t space_id);
size_t H5Pget_npoints (hid_t space_id);
intn H5Pget_ndims (hid_t space_id);
intn H5Pget_dims (hid_t space_id, size_t dims[]);
int H5Pget_ndims (hid_t space_id);
int H5Pget_dims (hid_t space_id, size_t dims[]);
hbool_t H5Pis_simple (hid_t space_id);
herr_t H5Pset_space (hid_t space_id, intn rank, const size_t *dims);
herr_t H5Pset_space (hid_t space_id, int rank, const size_t *dims);
herr_t H5Pset_hyperslab(hid_t sid, const size_t *start, const size_t *count,
const size_t *stride);
herr_t H5Pget_hyperslab (hid_t sid, size_t offset[]/*out*/,
size_t size[]/*out*/, size_t stride[]/*out*/);
int H5Pget_hyperslab (hid_t sid, size_t offset[]/*out*/,
size_t size[]/*out*/, size_t stride[]/*out*/);
#ifdef __cplusplus
}

View File

@ -10,6 +10,7 @@
#include <H5private.h>
#include <H5Eprivate.h>
#include <H5Pprivate.h>
#include <H5Vprivate.h>
/* Interface initialization */
#define PABLO_MASK H5P_simp_mask
@ -88,8 +89,11 @@ H5P_simp_fgath (H5F_t *f, const struct H5O_layout_t *layout,
const H5P_number_t *numbering, intn start, intn nelmts,
void *buf/*out*/)
{
size_t offset[H5O_LAYOUT_NDIMS]; /*offset of hyperslab */
size_t size[H5O_LAYOUT_NDIMS]; /*size of hyperslab */
size_t file_offset[H5O_LAYOUT_NDIMS]; /*offset of slab in file*/
size_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */
size_t zero[H5O_LAYOUT_NDIMS]; /*zero */
size_t sample[H5O_LAYOUT_NDIMS]; /*hyperslab sampling */
intn space_ndims; /*dimensionality of space*/
intn i; /*counters */
FUNC_ENTER (H5P_simp_fgath, 0);
@ -108,23 +112,34 @@ H5P_simp_fgath (H5F_t *f, const struct H5O_layout_t *layout,
*/
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
* Get hyperslab information to determine what elements are being
* selected (there might eventually be other selection methods too).
* We only support hyperslabs with unit sample because there's no way to
* currently pass sample information into H5F_arr_read() much less
* H5F_istore_read().
*/
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;
if ((space_ndims=H5P_get_hyperslab (file_space, file_offset, hsize,
sample))<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0,
"unable to retrieve hyperslab parameters");
}
for (i=0; i<space_ndims; i++) {
if (sample[i]!=1) {
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, 0,
"hyperslab sampling is not implemented yet");
}
}
file_offset[space_ndims] = 0;
hsize[space_ndims] = elmt_size;
HDmemset (zero, 0, layout->ndims*sizeof(size_t));
/*
* Gather from file.
*/
if (H5F_arr_read (f, layout, size, size, offset, offset, buf/*out*/)<0) {
if (H5F_arr_read (f, layout, hsize, hsize, zero, file_offset,
buf/*out*/)<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_READERROR, 0, "read error");
}
@ -157,6 +172,14 @@ 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 mem_offset[H5O_LAYOUT_NDIMS]; /*slab offset in app buf*/
size_t mem_size[H5O_LAYOUT_NDIMS]; /*total size of app buf */
size_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */
size_t zero[H5O_LAYOUT_NDIMS]; /*zero */
size_t sample[H5O_LAYOUT_NDIMS]; /*hyperslab sampling */
intn space_ndims; /*dimensionality of space*/
intn i; /*counters */
FUNC_ENTER (H5P_simp_mscat, FAIL);
/* Check args */
@ -174,12 +197,39 @@ H5P_simp_mscat (const void *tconv_buf, size_t elmt_size,
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 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.
* Retrieve hyperslab information to determine what elements are being
* selected (there might be other selection methods in the future). We
* only handle hyperslabs with unit sample because there's currently no
* way to pass sample information to H5V_hyper_copy().
*/
HDmemcpy (buf, tconv_buf, nelmts*elmt_size);
if ((space_ndims=H5P_get_hyperslab (mem_space, mem_offset, hsize,
sample))<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
"unable to retrieve hyperslab parameters");
}
for (i=0; i<space_ndims; i++) {
if (sample[i]!=1) {
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
"hyperslab sampling is not implemented yet");
}
}
if (H5P_get_dims (mem_space, mem_size)<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
"unable to retrieve data space dimensions");
}
mem_offset[space_ndims] = 0;
mem_size[space_ndims] = elmt_size;
hsize[space_ndims] = elmt_size;
HDmemset (zero, 0, (space_ndims+1)*sizeof(size_t));
/*
* Scatter from conversion buffer to application memory.
*/
if (H5V_hyper_copy (space_ndims+1, hsize, mem_size, mem_offset, buf,
hsize, zero, tconv_buf)<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
"unable to scatter data to memory");
}
FUNC_LEAVE (SUCCEED);
}
@ -212,6 +262,14 @@ 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*/)
{
size_t mem_offset[H5O_LAYOUT_NDIMS]; /*slab offset in app buf*/
size_t mem_size[H5O_LAYOUT_NDIMS]; /*total size of app buf */
size_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */
size_t zero[H5O_LAYOUT_NDIMS]; /*zero */
size_t sample[H5O_LAYOUT_NDIMS]; /*hyperslab sampling */
intn space_ndims; /*dimensionality of space*/
intn i; /*counters */
FUNC_ENTER (H5P_simp_mgath, 0);
/* Check args */
@ -229,12 +287,39 @@ H5P_simp_mgath (const void *buf, size_t elmt_size,
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.
* Retrieve hyperslab information to determine what elements are being
* selected (there might be other selection methods in the future). We
* only handle hyperslabs with unit sample because there's currently no
* way to pass sample information to H5V_hyper_copy().
*/
HDmemcpy (tconv_buf, buf, nelmts*elmt_size);
if ((space_ndims=H5P_get_hyperslab (mem_space, mem_offset, hsize,
sample))<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0,
"unable to retrieve hyperslab parameters");
}
for (i=0; i<space_ndims; i++) {
if (sample[i]!=1) {
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, 0,
"hyperslab sampling is not implemented yet");
}
}
if (H5P_get_dims (mem_space, mem_size)<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0,
"unable to retrieve data space dimensions");
}
mem_offset[space_ndims] = 0;
mem_size[space_ndims] = elmt_size;
hsize[space_ndims] = elmt_size;
HDmemset (zero, 0, (space_ndims+1)*sizeof(size_t));
/*
* Scatter from conversion buffer to application memory.
*/
if (H5V_hyper_copy (space_ndims+1, hsize, hsize, zero, tconv_buf,
mem_size, mem_offset, buf)<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0,
"unable to scatter data to memory");
}
FUNC_LEAVE (nelmts);
}
@ -267,8 +352,11 @@ H5P_simp_fscat (H5F_t *f, const struct H5O_layout_t *layout,
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 */
size_t file_offset[H5O_LAYOUT_NDIMS]; /*offset of hyperslab */
size_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */
size_t zero[H5O_LAYOUT_NDIMS]; /*zero vector */
size_t sample[H5O_LAYOUT_NDIMS]; /*hyperslab sampling */
intn space_ndims; /*space dimensionality */
intn i; /*counters */
FUNC_ENTER (H5P_simp_fscat, FAIL);
@ -289,22 +377,32 @@ H5P_simp_fscat (H5F_t *f, const struct H5O_layout_t *layout,
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
* Get hyperslab information to determine what elements are being
* selected (there might eventually be other selection methods too).
* We only support hyperslabs with unit sample because there's no way to
* currently pass sample information into H5F_arr_read() much less
* H5F_istore_read().
*/
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;
if ((space_ndims=H5P_get_hyperslab (file_space, file_offset, hsize,
sample))<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
"unable to retrieve hyperslab parameters");
}
for (i=0; i<space_ndims; i++) {
if (sample[i]!=1) {
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
"hyperslab sampling is not implemented yet");
}
}
file_offset[space_ndims] = 0;
hsize[space_ndims] = elmt_size;
HDmemset (zero, 0, layout->ndims*sizeof(size_t));
/*
* 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");
if (H5F_arr_write (f, layout, hsize, hsize, zero, file_offset, buf)<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error");
}
FUNC_LEAVE (SUCCEED);

View File

@ -95,11 +95,24 @@ main (void)
static s5_t s5[NX*NY];
hid_t s5_tid;
/* Sixth dataset */
/* Seventh dataset */
hid_t s7_sid;
/* Eighth dataset */
s1_t *s8 = NULL;
hid_t s8_f_sid; /*file data space */
hid_t s8_m_sid; /*memory data space */
/* Other variables */
int i;
hid_t file, dataset, space;
herr_t status;
static size_t dim[] = {NX, NY};
size_t f_offset[2]; /*offset of hyperslab in file */
size_t h_size[2]; /*size of hyperslab */
size_t h_sample[2]; /*hyperslab sampling */
/* Create the file */
file = H5Fcreate ("cmpd_dset.h5", H5ACC_OVERWRITE,
@ -123,9 +136,9 @@ STEP 1: Initialize dataset `s1' and store it on disk in native order.\n");
/* Initialize the dataset */
for (i=0; i<NX*NY; i++) {
s1[i].a = 5*i+0;
s1[i].b = 5*i+1;
s1[i].b = 2000*2*i;
s1[i].c = 5*i+2;
s1[i].d = 5*i+3;
s1[i].d = 2001+2*i;
s1[i].e = 5*i+4;
}
@ -297,8 +310,8 @@ STEP 6: Update fields `b' and `d' on the file, leaving the other fields\n\
/* Initialize `s4' with new values */
for (i=0; i<NX*NY; i++) {
s4[i].b = 2000+2*i;
s4[i].d = 2001+2*i;
s4[i].b = 5*i+1;
s4[i].d = 5*i+3;
}
/* Write the data to file */
@ -306,23 +319,75 @@ STEP 6: Update fields `b' and `d' on the file, leaving the other fields\n\
assert (status>=0);
/* Read the data back */
status = H5Dread (dataset, s2_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s2);
status = H5Dread (dataset, s1_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s1);
assert (status>=0);
/* Compare */
for (i=0; i<NX*NY; i++) {
assert (s1[i].a == 5*i+0);
assert (s1[i].b == 5*i+1);
assert (s1[i].c == 5*i+2);
assert (s1[i].d == 5*i+3);
assert (s1[i].e == 5*i+4);
}
/*
*######################################################################
* STEP 7. Read the original dataset with an explicit data space. Even
* though these data spaces are equal it tests a different part of the
* library.
*/
printf ("\
STEP 7: Reading original dataset with explicit data space.\n");
fflush (stdout);
/* Create the data space */
s7_sid = H5Pcreate_simple (2, dim);
assert (s7_sid>=0);
/* Read the dataset */
status = H5Dread (dataset, s2_tid, s7_sid, H5P_ALL, H5C_DEFAULT, s2);
assert (status>=0);
/* Compare */
for (i=0; i<NX*NY; i++) {
assert (s2[i].a == s1[i].a);
assert (s2[i].b == s4[i].b);
assert (s2[i].b == s1[i].b);
assert (s2[i].c == s1[i].c);
assert (s2[i].d == s4[i].d);
assert (s2[i].d == s1[i].d);
assert (s2[i].e == s1[i].e);
}
/*
*######################################################################
* STEP 8. Read a hyperslab of the file into a complete array in memory.
* The hyperslab is the middle third of the array.
*/
printf ("\
STEP 8: Read middle third hyperslab into memory array.\n");
fflush (stdout);
/* Create the file data space */
s8_f_sid = H5Dget_space (dataset);
assert (s8_f_sid>=0);
f_offset[0] = NX/3;
f_offset[1] = NY/3;
h_size[0] = 2*NX/3 - f_offset[0];
h_size[1] = 2*NY/3 - f_offset[0];
h_sample[0] = 1;
h_sample[1] = 1;
status = H5Pset_hyperslab (s8_f_sid, f_offset, h_size, h_sample);
assert (status>=0);
/* Create memory data space */
s8_m_sid = H5Pcreate_simple (2, h_size);
assert (s8_m_sid>=0);
/* Read the dataset */
s8 = calloc (h_size[0]*h_size[1], sizeof(s1_t));
status = H5Dread (dataset, s1_tid, s8_m_sid, s8_f_sid, H5C_DEFAULT, s8);
assert (status>=0);
/*

View File

@ -33,7 +33,7 @@ extern int Verbosity;
/* Used to make certain a return value _is_not_ a value */
#define CHECK(ret, val, where) \
do {if (Verbosity>9) print_func(" Call to routine: %15s at line %4d in %s returned %ld \n",where,(int)__LINE__,__FILE__,(long)ret);\
if(ret == val) {print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d in %s\n", where, (long)ret, (int)__LINE__,__FILE__); num_errs++;H5Eprint (H5E_thrdid_g, stdout);} \
if(ret == val) {print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d in %s\n", where, (long)ret, (int)__LINE__,__FILE__); num_errs++;H5Eprint (H5E_thrdid_g, stdout);} H5Eclear(H5E_thrdid_g);\
} while(0)
#define CHECK_I(ret,where) { \
@ -47,6 +47,7 @@ if(ret == val) {print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d in
H5Eprint (H5E_thrdid_g, stdout); \
num_errs++; \
} \
H5Eclear (H5E_thrdid_g); \
}
#define CHECK_PTR(ret,where) { \
@ -60,12 +61,13 @@ if(ret == val) {print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d in
H5Eprint (H5E_thrdid_g, stdout); \
num_errs++; \
} \
H5Eclear (H5E_thrdid_g); \
}
/* Used to make certain a return value _is_ a value */
#define VERIFY(x, val, where) \
do {if (Verbosity>9) print_func(" Call to routine: %15s at line %4d in %s had value %ld \n",where,(int)__LINE__,__FILE__,(long)x);\
if(x != val) {print_func("*** UNEXPECTED VALUE from %s is %ld at line %4d in %s\n", where, (long)x,(int)__LINE__,__FILE__); H5Eprint (H5E_thrdid_g, stdout); num_errs++;} \
if(x != val) {print_func("*** UNEXPECTED VALUE from %s is %ld at line %4d in %s\n", where, (long)x,(int)__LINE__,__FILE__); H5Eprint (H5E_thrdid_g, stdout);num_errs++;}H5Eclear(H5E_thrdid_g); \
} while(0)
/* Used to document process through a test and to check for errors */
@ -73,7 +75,7 @@ if(x != val) {print_func("*** UNEXPECTED VALUE from %s is %ld at line %4d in %s\
do { \
if (Verbosity>8) print_func(" Call to routine: %15s at line %4d in %s returned %ld \n",func,(int)__LINE__,__FILE__,(long)ret); \
if (Verbosity>9) HEprint(stdout,0); \
if(ret == FAIL) {print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d in %s\n", func, (long)ret,(int)__LINE__,__FILE__); H5Eprint (H5E_thrdid_g, stdout); num_errs++;} \
if(ret == FAIL) {print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d in %s\n", func, (long)ret,(int)__LINE__,__FILE__); H5Eprint (H5E_thrdid_g, stdout); num_errs++;} H5Eclear(H5E_thrdid_g);\
} while(0)
/* Used to document process through a test */