summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Spoint.c163
-rw-r--r--src/H5Sprivate.h2
-rw-r--r--src/H5Spublic.h2
-rw-r--r--src/H5Sselect.c4
-rw-r--r--src/H5Ssimp.c2
-rw-r--r--src/H5public.h2
-rw-r--r--test/tselect.c145
7 files changed, 277 insertions, 43 deletions
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index 304ee00..e3fccd8 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -43,6 +43,9 @@ H5S_point_init (const struct H5O_layout_t __unused__ *layout,
assert (space && H5S_SEL_POINTS==space->select.type);
assert (sel_iter);
+#ifdef QAK
+printf("%s: check 1.0\n",FUNC);
+#endif /* QAK */
/* Initialize the number of points to iterate over */
sel_iter->pnt.elmt_left=space->select.num_elem;
@@ -71,9 +74,10 @@ H5S_point_init (const struct H5O_layout_t __unused__ *layout,
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-herr_t H5S_point_add (H5S_t *space, size_t num_elem, const hssize_t *coord[])
+herr_t H5S_point_add (H5S_t *space, size_t num_elem, const hssize_t **_coord)
{
H5S_pnt_node_t *top, *curr, *new; /* Point selection nodes */
+ const hssize_t *coord=(const hssize_t *)_coord; /* Pointer to the actual coordinates */
uintn i; /* Counter */
herr_t ret_value=FAIL; /* return value */
@@ -83,18 +87,39 @@ herr_t H5S_point_add (H5S_t *space, size_t num_elem, const hssize_t *coord[])
assert(num_elem>0);
assert(coord);
+#ifdef QAK
+printf("%s: check 1.0\n",FUNC);
+#endif /* QAK */
top=curr=NULL;
for(i=0; i<num_elem; i++) {
/* Allocate space for the new node */
if((new = H5MM_malloc(sizeof(H5S_pnt_node_t)))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
"can't allocate point node");
+
+#ifdef QAK
+printf("%s: check 1.1, rank=%d\n",FUNC,(int)space->extent.u.simple.rank);
+#endif /* QAK */
if((new->pnt = H5MM_malloc(space->extent.u.simple.rank*sizeof(hssize_t)))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
"can't allocate coordinate information");
+#ifdef QAK
+printf("%s: check 1.2\n",FUNC);
+#endif /* QAK */
/* Copy over the coordinates */
- HDmemcpy(new->pnt,coord[i],(space->extent.u.simple.rank*sizeof(hssize_t)));
+ HDmemcpy(new->pnt,coord+(i*space->extent.u.simple.rank),(space->extent.u.simple.rank*sizeof(hssize_t)));
+#ifdef QAK
+printf("%s: check 1.3\n",FUNC);
+ {
+ intn j;
+
+ for(j=0; j<space->extent.u.simple.rank; j++) {
+ printf("%s: pnt[%d]=%d\n",FUNC,(int)j,(int)new->pnt[j]);
+ printf("%s: coord[%d][%d]=%d\n",FUNC,(int)i,(int)j,(int)*(coord+(i*space->extent.u.simple.rank)+j));
+ }
+ }
+#endif /* QAK */
/* Link into list */
new->next=NULL;
@@ -104,6 +129,9 @@ herr_t H5S_point_add (H5S_t *space, size_t num_elem, const hssize_t *coord[])
curr->next=new;
curr=new;
} /* end for */
+#ifdef QAK
+printf("%s: check 2.0\n",FUNC);
+#endif /* QAK */
/* Append current list, if there is one */
if(space->select.sel_info.pnt_lst->head!=NULL)
@@ -112,7 +140,13 @@ herr_t H5S_point_add (H5S_t *space, size_t num_elem, const hssize_t *coord[])
/* Put new list in point selection */
space->select.sel_info.pnt_lst->head=top;
+ /* Add the number of elements in the new selection */
+ space->select.num_elem+=num_elem;
+
ret_value=SUCCEED;
+#ifdef QAK
+printf("%s: check 3.0\n",FUNC);
+#endif /* QAK */
done:
FUNC_LEAVE (ret_value);
@@ -141,6 +175,9 @@ H5S_point_favail (const H5S_t __unused__ *space, const H5S_sel_iter_t *sel_iter,
assert (space && H5S_SEL_POINTS==space->select.type);
assert (sel_iter);
+#ifdef QAK
+printf("%s: check 1.0, ret=%d\n",FUNC,(int)MIN(sel_iter->pnt.elmt_left,max));
+#endif /* QAK */
FUNC_LEAVE (MIN(sel_iter->pnt.elmt_left,max));
} /* H5S_point_favail() */
@@ -196,6 +233,9 @@ H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout,
assert (nelmts>0);
assert (buf);
+#ifdef QAK
+printf("%s: check 1.0\n",FUNC);
+#endif /* QAK */
/* initialize hyperslab size and offset in memory buffer */
for(i=0; i<layout->ndims; i++) {
hsize[i]=1; /* hyperslab size is 1, except for last element */
@@ -208,7 +248,7 @@ H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout,
while(num_read<nelmts) {
if(file_iter->pnt.elmt_left>0) {
/* Copy the location of the point to get */
- HDmemcpy(file_offset,file_iter->pnt.curr->pnt,layout->ndims);
+ HDmemcpy(file_offset,file_iter->pnt.curr->pnt,layout->ndims*sizeof(hssize_t));
file_offset[layout->ndims] = 0;
/* Go read the point */
@@ -217,6 +257,16 @@ H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout,
HRETURN_ERROR (H5E_DATASPACE, H5E_READERROR, 0, "read error");
}
+#ifdef QAK
+printf("%s: check 3.0\n",FUNC);
+ {
+ for(i=0; i<layout->ndims; i++) {
+ printf("%s: %d - pnt=%d\n",FUNC,(int)i,(int)file_iter->pnt.curr->pnt[i]);
+ printf("%s: %d - file_offset=%d\n",FUNC,(int)i,(int)file_offset[i]);
+ }
+printf("%s: *buf=%u\n",FUNC,(unsigned)*buf);
+ }
+#endif /* QAK */
/* Increment the offset of the buffer */
buf+=elmt_size;
@@ -279,6 +329,9 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout,
assert (nelmts>0);
assert (buf);
+#ifdef QAK
+printf("%s: check 1.0, layout->ndims=%d\n",FUNC,(int)layout->ndims);
+#endif /* QAK */
/* initialize hyperslab size and offset in memory buffer */
for(i=0; i<layout->ndims; i++) {
hsize[i]=1; /* hyperslab size is 1, except for last element */
@@ -288,30 +341,47 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout,
/* Walk though and request each element we need and put it into the buffer */
num_written=0;
- while(num_written<nelmts) {
- if(file_iter->pnt.elmt_left>0) {
- /* Copy the location of the point to get */
- HDmemcpy(file_offset,file_iter->pnt.curr->pnt,layout->ndims);
- file_offset[layout->ndims] = 0;
-
- /* Go read the point */
- if (H5F_arr_write (f, layout, comp, efl, hsize, hsize, zero, file_offset,
- xfer_mode, buf)<0) {
- HRETURN_ERROR (H5E_DATASPACE, H5E_READERROR, 0, "read error");
- }
-
- /* Increment the offset of the buffer */
- buf+=elmt_size;
-
- /* Increment the count read */
- num_written++;
-
- /* Advance the point iterator */
- file_iter->pnt.elmt_left--;
- file_iter->pnt.curr=file_iter->pnt.curr->next;
- } else {
- break; /* out of elements in the selection */
- } /* end else */
+ while(num_written<nelmts && file_iter->pnt.elmt_left>0) {
+#ifdef QAK
+printf("%s: check 2.0\n",FUNC);
+ {
+ for(i=0; i<layout->ndims; i++) {
+ printf("%s: %d - pnt=%d\n",FUNC,(int)i,(int)file_iter->pnt.curr->pnt[i]);
+ }
+ }
+#endif /* QAK */
+ /* Copy the location of the point to get */
+ HDmemcpy(file_offset,file_iter->pnt.curr->pnt,layout->ndims*sizeof(hssize_t));
+ file_offset[layout->ndims] = 0;
+
+#ifdef QAK
+printf("%s: check 3.0\n",FUNC);
+ {
+ for(i=0; i<layout->ndims; i++) {
+ printf("%s: %d - pnt=%d\n",FUNC,(int)i,(int)file_iter->pnt.curr->pnt[i]);
+ printf("%s: %d - file_offset=%d\n",FUNC,(int)i,(int)file_offset[i]);
+ }
+printf("%s: *buf=%u\n",FUNC,(unsigned)*buf);
+ }
+#endif /* QAK */
+ /* Go write the point */
+ if (H5F_arr_write (f, layout, comp, efl, hsize, hsize, zero, file_offset,
+ xfer_mode, buf)<0) {
+ HRETURN_ERROR (H5E_DATASPACE, H5E_WRITEERROR, 0, "write error");
+ }
+
+ /* Increment the offset of the buffer */
+ buf+=elmt_size;
+
+ /* Increment the count read */
+ num_written++;
+
+ /* Advance the point iterator */
+ file_iter->pnt.elmt_left--;
+ file_iter->pnt.curr=file_iter->pnt.curr->next;
+#ifdef QAK
+printf("%s: check 5.0, file_iter->pnt.curr=%p\n",FUNC,file_iter->pnt.curr);
+#endif
} /* end while */
FUNC_LEAVE (num_written);
@@ -345,7 +415,8 @@ H5S_point_mgath (const void *_buf, size_t elmt_size,
hsize_t mem_size[H5O_LAYOUT_NDIMS]; /*total size of app buf */
const uint8 *buf=(const uint8 *)_buf; /* Get local copies for address arithmetic */
uint8 *tconv_buf=(uint8 *)_tconv_buf;
- hsize_t acc; /*accumulator */
+ hsize_t acc; /* coordinate accumulator */
+ hsize_t off; /* coordinate offset */
intn space_ndims; /*dimensionality of space*/
intn i; /*counters */
size_t num_gath; /* number of elements gathered */
@@ -359,6 +430,9 @@ H5S_point_mgath (const void *_buf, size_t elmt_size,
assert (nelmts>0);
assert (tconv_buf);
+#ifdef QAK
+printf("%s: check 1.0\n",FUNC);
+#endif /* QAK */
if ((space_ndims=H5S_extent_dims (mem_space, mem_size, NULL))<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0,
"unable to retrieve data space dimensions");
@@ -367,11 +441,16 @@ H5S_point_mgath (const void *_buf, size_t elmt_size,
for(num_gath=0; num_gath<nelmts; num_gath++) {
if(mem_iter->pnt.elmt_left>0) {
/* Compute the location of the point to get */
- for(i=0,acc=0; i<space_ndims; i++)
- acc+=mem_size[i]*mem_iter->pnt.curr->pnt[i];
-
+ for(i=space_ndims-1,acc=1,off=0; i>=0; i--) {
+ off+=mem_iter->pnt.curr->pnt[i]*acc;
+ acc*=mem_size[i];
+ } /* end for */
+
+#ifdef QAK
+printf("%s: check 2.0, acc=%d, off=%d\n",FUNC,(int)acc,(int)off);
+#endif /* QAK */
/* Copy the elements into the type conversion buffer */
- *tconv_buf=*(buf+acc);
+ HDmemcpy(tconv_buf,buf+off,elmt_size);
/* Increment the offset of the buffers */
tconv_buf+=elmt_size;
@@ -414,8 +493,9 @@ H5S_point_mscat (const void *_tconv_buf, size_t elmt_size,
hsize_t mem_size[H5O_LAYOUT_NDIMS]; /*total size of app buf */
uint8 *buf=(uint8 *)_buf; /* Get local copies for address arithmetic */
const uint8 *tconv_buf=(const uint8 *)_tconv_buf;
- hsize_t acc; /*accumulator */
- intn space_ndims; /*dimensionality of space*/
+ hsize_t acc; /* coordinate accumulator */
+ hsize_t off; /* coordinate offset */
+ intn space_ndims; /*dimensionality of space*/
intn i; /*counters */
size_t num_scat; /* Number of elements scattered */
@@ -428,6 +508,9 @@ H5S_point_mscat (const void *_tconv_buf, size_t elmt_size,
assert (nelmts>0);
assert (buf);
+#ifdef QAK
+printf("%s: check 1.0\n",FUNC);
+#endif /* QAK */
/*
* Retrieve hyperslab information to determine what elements are being
* selected (there might be other selection methods in the future). We
@@ -442,11 +525,13 @@ H5S_point_mscat (const void *_tconv_buf, size_t elmt_size,
for(num_scat=0; num_scat<nelmts; num_scat++) {
if(mem_iter->pnt.elmt_left>0) {
/* Compute the location of the point to get */
- for(i=0,acc=0; i<space_ndims; i++)
- acc+=mem_size[i]*mem_iter->pnt.curr->pnt[i];
+ for(i=space_ndims-1,acc=1,off=0; i>=0; i--) {
+ off+=mem_iter->pnt.curr->pnt[i]*acc;
+ acc*=mem_size[i];
+ } /* end for */
/* Copy the elements into the type conversion buffer */
- *(buf+acc)=*tconv_buf;
+ HDmemcpy(buf+off,tconv_buf,elmt_size);
/* Increment the offset of the buffers */
tconv_buf+=elmt_size;
@@ -497,6 +582,9 @@ H5S_point_release (H5S_t *space)
curr=next;
} /* end while */
+ /* Reset the number of elements in the selection */
+ space->select.num_elem=0;
+
FUNC_LEAVE (SUCCEED);
} /* H5S_point_release() */
@@ -527,3 +615,4 @@ H5S_hyper_npoints (const H5S_t *space)
FUNC_LEAVE (space->select.num_elem);
} /* H5S_hyper_npoints() */
+
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index dcae464..2c0dfa2 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -281,7 +281,7 @@ size_t H5S_point_mgath (const void *_buf, size_t elmt_size,
herr_t H5S_point_mscat (const void *_tconv_buf, size_t elmt_size,
const H5S_t *mem_space, H5S_sel_iter_t *mem_iter,
size_t nelmts, void *_buf/*out*/);
-herr_t H5S_point_add (H5S_t *space, size_t num_elemn, const hssize_t *coord[]);
+herr_t H5S_point_add (H5S_t *space, size_t num_elemn, const hssize_t **coord);
herr_t H5S_point_release (H5S_t *space);
hsize_t H5S_point_npoints (const H5S_t *space);
diff --git a/src/H5Spublic.h b/src/H5Spublic.h
index e0cc272..022f108 100644
--- a/src/H5Spublic.h
+++ b/src/H5Spublic.h
@@ -58,7 +58,7 @@ herr_t H5Sselect_hyperslab (hid_t spaceid, H5S_seloper_t op,
const hssize_t *start, const hsize_t *_stride, const hsize_t *count,
const hsize_t *_block);
herr_t H5Sselect_elements (hid_t spaceid, H5S_seloper_t op, size_t num_elemn,
- const hssize_t *coord[]);
+ const hssize_t **coord);
#ifdef __cplusplus
}
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 83e6b38..28197a8 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -319,7 +319,7 @@ done:
hid_t dsid; IN: Dataspace ID of selection to modify
H5S_seloper_t op; IN: Operation to perform on current selection
size_t num_elem; IN: Number of elements in COORD array.
- const hssize_t *coord[]; IN: The location of each element selected
+ const hssize_t **coord; IN: The location of each element selected
RETURNS
SUCCEED/FAIL
DESCRIPTION
@@ -340,7 +340,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
herr_t H5Sselect_elements (hid_t spaceid, H5S_seloper_t op, size_t num_elem,
- const hssize_t *coord[])
+ const hssize_t **coord)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
herr_t ret_value=FAIL; /* return value */
diff --git a/src/H5Ssimp.c b/src/H5Ssimp.c
index fda83e1..8f1844c 100644
--- a/src/H5Ssimp.c
+++ b/src/H5Ssimp.c
@@ -251,7 +251,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, NULL)<0) {
+ if (H5S_extent_dims (mem_space, mem_size, NULL)<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
"unable to retrieve data space dimensions");
}
diff --git a/src/H5public.h b/src/H5public.h
index 3cd58df..c5a6661 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -27,7 +27,7 @@
/* Version numbers */
#define H5_VERS_MAJOR 1 /* For major interface changes */
#define H5_VERS_MINOR 0 /* For minor interface changes */
-#define H5_VERS_RELEASE 17 /* For interface tweaks & bug-fixes */
+#define H5_VERS_RELEASE 19 /* For interface tweaks & bug-fixes */
#define H5_VERS_PATCH 0 /* For small groups of bug fixes */
#define H5check() H5vers_check(H5_VERS_MAJOR,H5_VERS_MINOR,\
diff --git a/test/tselect.c b/test/tselect.c
index 3edd9b5..ce2c936 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -49,6 +49,9 @@ static char RcsId[] = "$Revision$";
#define SPACE3_DIM1 15
#define SPACE3_DIM2 26
+/* Element selection information */
+#define POINT1_NPOINTS 10
+
/****************************************************************
**
** test_select_hyper(): Test basic H5S (dataspace) selection code.
@@ -176,6 +179,147 @@ test_select_hyper(void)
/****************************************************************
**
+** test_select_point(): Test basic H5S (dataspace) selection code.
+** Tests element selections between dataspaces of various sizes
+** and dimensionalities.
+**
+****************************************************************/
+static void
+test_select_point(void)
+{
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1,sid2; /* Dataspace ID */
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
+ hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2};
+ hssize_t coord1[POINT1_NPOINTS][SPACE1_RANK]; /* Coordinates for point selection */
+ hssize_t coord2[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */
+ hssize_t coord3[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */
+ uint8 *wbuf, /* buffer to write to disk */
+ *rbuf, /* buffer read from disk */
+ *tbuf, /* temporary buffer pointer */
+ *tbuf2; /* temporary buffer pointer */
+ intn i,j; /* Counters */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Element Selection Functions\n"));
+
+ /* Allocate write & read buffers */
+ wbuf=malloc(sizeof(uint8)*SPACE2_DIM1*SPACE2_DIM2);
+ rbuf=calloc(sizeof(uint8),SPACE3_DIM1*SPACE3_DIM2);
+
+ /* Initialize write buffer */
+ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
+ for(j=0; j<SPACE2_DIM2; j++)
+ *tbuf++=(uint8)((i*SPACE2_DIM2)+j);
+
+ /* Create file */
+ fid1 = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create dataspace for dataset */
+ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create dataspace for write buffer */
+ sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
+ CHECK(sid2, FAIL, "H5Screate_simple");
+
+ /* Select sequence of ten points for disk dataset */
+ coord1[0][0]=0; coord1[0][1]=10; coord1[0][2]= 5;
+ coord1[1][0]=1; coord1[1][1]= 2; coord1[1][2]= 7;
+ coord1[2][0]=2; coord1[2][1]= 4; coord1[2][2]= 9;
+ coord1[3][0]=0; coord1[3][1]= 6; coord1[3][2]=11;
+ coord1[4][0]=1; coord1[4][1]= 8; coord1[4][2]=13;
+ coord1[5][0]=2; coord1[5][1]=12; coord1[5][2]= 0;
+ coord1[6][0]=0; coord1[6][1]=14; coord1[6][2]= 2;
+ coord1[7][0]=1; coord1[7][1]= 0; coord1[7][2]= 4;
+ coord1[8][0]=2; coord1[8][1]= 1; coord1[8][2]= 6;
+ coord1[9][0]=0; coord1[9][1]= 3; coord1[9][2]= 8;
+ ret = H5Sselect_elements(sid1,H5S_SELECT_SET,POINT1_NPOINTS,coord1);
+ CHECK(ret, FAIL, "H5Sselect_elements");
+
+ /* Select sequence of ten points for write dataset */
+ coord2[0][0]=12; coord2[0][1]= 3;
+ coord2[1][0]=15; coord2[1][1]=13;
+ coord2[2][0]= 7; coord2[2][1]=25;
+ coord2[3][0]= 0; coord2[3][1]= 6;
+ coord2[4][0]=13; coord2[4][1]= 0;
+ coord2[5][0]=24; coord2[5][1]=11;
+ coord2[6][0]=12; coord2[6][1]=21;
+ coord2[7][0]=29; coord2[7][1]= 4;
+ coord2[8][0]= 8; coord2[8][1]= 8;
+ coord2[9][0]=19; coord2[9][1]=17;
+ ret = H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,coord2);
+ CHECK(ret, FAIL, "H5Sselect_elements");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid1,"Dataset1",H5T_NATIVE_UCHAR,sid1,H5P_DEFAULT);
+
+ /* Write selection to disk */
+ ret=H5Dwrite(dataset,H5T_NATIVE_UCHAR,sid2,sid1,H5P_DEFAULT,wbuf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close memory dataspace */
+ ret = H5Sclose(sid2);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Create dataspace for reading buffer */
+ sid2 = H5Screate_simple(SPACE3_RANK, dims3, NULL);
+ CHECK(sid2, FAIL, "H5Screate_simple");
+
+ /* Select sequence of points for read dataset */
+ coord3[0][0]= 0; coord3[0][1]= 2;
+ coord3[1][0]= 4; coord3[1][1]= 8;
+ coord3[2][0]=13; coord3[2][1]=13;
+ coord3[3][0]=14; coord3[3][1]=25;
+ coord3[4][0]= 7; coord3[4][1]= 9;
+ coord3[5][0]= 2; coord3[5][1]= 0;
+ coord3[6][0]= 9; coord3[6][1]=19;
+ coord3[7][0]= 1; coord3[7][1]=22;
+ coord3[8][0]=12; coord3[8][1]=21;
+ coord3[9][0]=11; coord3[9][1]= 6;
+ ret = H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,coord3);
+ CHECK(ret, FAIL, "H5Sselect_elements");
+
+ /* Read selection from disk */
+ ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,H5P_DEFAULT,rbuf);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Compare data read with data written out */
+ for(i=0; i<POINT1_NPOINTS; i++) {
+ tbuf=wbuf+(coord2[i][0]*SPACE2_DIM2)+coord2[i][1];
+ tbuf2=rbuf+(coord3[i][0]*SPACE3_DIM2)+coord3[i][1];
+ if(*tbuf!=*tbuf2) {
+ printf("element values don't match!, i=%d\n",i);
+ } /* end if */
+ } /* end for */
+
+ /* Close memory dataspace */
+ ret = H5Sclose(sid2);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close disk dataspace */
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Free memory buffers */
+ free(wbuf);
+ free(rbuf);
+} /* test_select_point() */
+
+/****************************************************************
+**
** test_select(): Main H5S selection testing routine.
**
****************************************************************/
@@ -187,6 +331,7 @@ test_select(void)
/* These next two tests use the same file information */
test_select_hyper(); /* Test basic H5S hyperslab selection code */
+ test_select_point(); /* Test basic H5S element selection code */
} /* test_select() */