summaryrefslogtreecommitdiffstats
path: root/src/H5Shyper.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2007-12-20 21:09:58 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2007-12-20 21:09:58 (GMT)
commit837780443693fc562725f57e874312120cde32d8 (patch)
tree6dd4f227df6bce6c87bce962f67e5505c44d8291 /src/H5Shyper.c
parent6878261a432d9cc8c705aa6c4f85450b29b37150 (diff)
downloadhdf5-837780443693fc562725f57e874312120cde32d8.zip
hdf5-837780443693fc562725f57e874312120cde32d8.tar.gz
hdf5-837780443693fc562725f57e874312120cde32d8.tar.bz2
[svn-r14354] Bug fix for #956 where the element coordinates went wrong for dataspace selection. Added a test
for it, too. This round of checkin isn't well tarnished yet. I'll come back to work on Jan. 8. I'll revise it then. Tested it on kagiso, smirom, linew.
Diffstat (limited to 'src/H5Shyper.c')
-rw-r--r--src/H5Shyper.c58
1 files changed, 57 insertions, 1 deletions
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 8c56056..7e3b30c 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -280,8 +280,10 @@ H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
if(iter->elmt_size>0) {
/* Check for any "contiguous" blocks that can be flattened */
for(u=rank-1; u>0; u--) {
- if(tdiminfo[u].count==1 && tdiminfo[u].block==mem_size[u])
+ if(tdiminfo[u].count==1 && tdiminfo[u].block==mem_size[u]) {
cont_dim++;
+ iter->dims_flatten[u] = TRUE;
+ }
} /* end for */
} /* end if */
@@ -418,6 +420,7 @@ H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
*
*-------------------------------------------------------------------------
*/
+#ifdef TMP
static herr_t
H5S_hyper_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords)
{
@@ -434,15 +437,25 @@ H5S_hyper_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords)
/* Check if this is a "flattened" regular hyperslab selection */
if(iter->u.hyp.iter_rank!=0 && iter->u.hyp.iter_rank<iter->rank) {
unsigned flat_dim; /* The rank of the flattened dimension */
+ unsigned dim = iter->rank - iter->u.hyp.iter_rank;
/* Get the rank of the flattened dimension */
flat_dim=iter->u.hyp.iter_rank-1;
/* Copy the coordinates up to where things got flattened */
+#ifdef TMP
HDmemcpy(coords,iter->u.hyp.off,sizeof(hsize_t)*flat_dim);
/* Compute the coordinates for the flattened dimensions */
H5V_array_calc(iter->u.hyp.off[flat_dim],iter->rank-flat_dim,&(iter->dims[flat_dim]),&(coords[flat_dim]));
+#else
+ /* Compute the coords for the flattened dimensions */
+ H5V_array_calc(iter->u.hyp.off[0],dim+1,iter->dims,coords);
+
+ /* Copy the coords for the unflattened dimensions */
+ if(dim+1 < iter->rank)
+ HDmemcpy(&(coords[dim+1]),&(iter->u.hyp.off[1]),sizeof(hsize_t)*(iter->u.hyp.iter_rank -1));
+#endif
} /* end if */
else
HDmemcpy(coords,iter->u.hyp.off,sizeof(hsize_t)*iter->rank);
@@ -452,6 +465,49 @@ H5S_hyper_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords)
FUNC_LEAVE_NOAPI(SUCCEED);
} /* H5S_hyper_iter_coords() */
+#else
+static herr_t
+H5S_hyper_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_iter_coords);
+
+ /* Check args */
+ assert (iter);
+ assert (coords);
+
+ /* Copy the offset of the current point */
+
+ /* Check for a single "regular" hyperslab */
+ if(iter->u.hyp.diminfo_valid) {
+ /* Check if this is a "flattened" regular hyperslab selection */
+ if(iter->u.hyp.iter_rank!=0 && iter->u.hyp.iter_rank<iter->rank) {
+ unsigned dim = iter->rank - iter->u.hyp.iter_rank;
+ int u, v;
+ int begin = -1;
+
+ for(u=iter->rank-1, v=iter->u.hyp.iter_rank-1; u>=0, v>=0; u--) {
+ if(!iter->dims_flatten[u]) {
+ if(begin > 0) {
+ /* Compute the coords for the flattened dimensions */
+ H5V_array_calc(iter->u.hyp.off[v],begin-u+1,&(iter->dims[u]),&(coords[u]));
+ begin = -1;
+ } else
+ HDmemcpy(&(coords[u]), &(iter->u.hyp.off[v]), sizeof(hsize_t));
+ v--;
+ }
+ else if(iter->dims_flatten[u] && (begin == -1))
+ begin = u;
+ }
+ } /* end if */
+ else
+ HDmemcpy(coords,iter->u.hyp.off,sizeof(hsize_t)*iter->rank);
+ } /* end if */
+ else
+ HDmemcpy(coords,iter->u.hyp.off,sizeof(hsize_t)*iter->rank);
+
+ FUNC_LEAVE_NOAPI(SUCCEED);
+} /* H5S_hyper_iter_coords() */
+#endif
/*-------------------------------------------------------------------------