summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1998-07-15 21:23:25 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1998-07-15 21:23:25 (GMT)
commitc40c53d0af09a8453df6d1a46f37de593d23f0d0 (patch)
treeb28dc7838e2a7738402d7ebad9cff011abbca0cb
parent077d7c8c864c5452911117ee6b97c855487ff4cd (diff)
downloadhdf5-c40c53d0af09a8453df6d1a46f37de593d23f0d0.zip
hdf5-c40c53d0af09a8453df6d1a46f37de593d23f0d0.tar.gz
hdf5-c40c53d0af09a8453df6d1a46f37de593d23f0d0.tar.bz2
[svn-r512] Tracked down some problems with the number of dimensions used for point/element
selections and also fixed part of the problem with scalar dataspaces being written/read from the file.
-rw-r--r--src/H5Sall.c103
-rw-r--r--src/H5Shyper.c30
-rw-r--r--src/H5Spoint.c26
-rw-r--r--src/H5Sselect.c8
-rw-r--r--test/tselect.c2
5 files changed, 106 insertions, 63 deletions
diff --git a/src/H5Sall.c b/src/H5Sall.c
index 8af7a18..076e8ee 100644
--- a/src/H5Sall.c
+++ b/src/H5Sall.c
@@ -157,20 +157,23 @@ H5S_all_fgath (H5F_t *f, const struct H5O_layout_t *layout,
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0,
"unable to retrieve hyperslab parameters");
}
- HDmemset(file_offset,0,sizeof(hssize_t)*space_ndims);
- /* Adjust the slowest varying dimension to take care of strip mining */
- for (i=1, acc=1; i<space_ndims; i++)
- acc *= hsize[i];
- assert (0==file_iter->all.offset % acc);
- assert (0==nelmts % acc);
- file_offset[0] += file_iter->all.offset / acc;
- hsize[0] = nelmts / acc;
+ if(space_ndims>0) {
+ HDmemset(file_offset,0,sizeof(hssize_t)*space_ndims);
+
+ /* Adjust the slowest varying dimension to take care of strip mining */
+ for (i=1, acc=1; i<space_ndims; i++)
+ acc *= hsize[i];
+ assert (0==file_iter->all.offset % acc);
+ assert (0==nelmts % acc);
+ file_offset[0] += file_iter->all.offset / acc;
+ hsize[0] = nelmts / acc;
+ } /* end if */
/* The fastest varying dimension is for the data point itself */
file_offset[space_ndims] = 0;
hsize[space_ndims] = elmt_size;
- HDmemset (zero, 0, layout->ndims*sizeof(*zero));
+ HDmemset (zero, 0, (space_ndims+1)*sizeof(*zero));
/*
* Gather from file.
@@ -240,20 +243,23 @@ H5S_all_fscat (H5F_t *f, const struct H5O_layout_t *layout,
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
"unable to retrieve hyperslab parameters");
}
- HDmemset(file_offset,0,sizeof(hssize_t)*space_ndims);
-
- /* Adjust the slowest varying dimension to account for strip mining */
- for (i=1, acc=1; i<space_ndims; i++)
- acc *= hsize[i];
- assert (0==file_iter->all.offset % acc);
- assert (0==nelmts % acc);
- file_offset[0] += file_iter->all.offset / acc;
- hsize[0] = nelmts / acc;
+
+ if(space_ndims>0) {
+ HDmemset(file_offset,0,sizeof(hssize_t)*space_ndims);
+
+ /* Adjust the slowest varying dimension to account for strip mining */
+ for (i=1, acc=1; i<space_ndims; i++)
+ acc *= hsize[i];
+ assert (0==file_iter->all.offset % acc);
+ assert (0==nelmts % acc);
+ file_offset[0] += file_iter->all.offset / acc;
+ hsize[0] = nelmts / acc;
+ } /* end if */
/* The fastest varying dimension is for the data point itself */
file_offset[space_ndims] = 0;
hsize[space_ndims] = elmt_size;
- HDmemset (zero, 0, layout->ndims*sizeof(*zero));
+ HDmemset (zero, 0, (space_ndims+1)*sizeof(*zero));
/*
* Scatter to file.
@@ -322,20 +328,22 @@ H5S_all_mgath (const void *_buf, size_t elmt_size,
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0,
"unable to retrieve hyperslab parameters");
}
- HDmemset(mem_offset,0,sizeof(hssize_t)*space_ndims);
-
- if (H5S_extent_dims (mem_space, mem_size, NULL)<0) {
- HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0,
- "unable to retrieve data space dimensions");
- }
-
- /* Adjust the slowest varying dimension to account for strip mining */
- for (i=1, acc=1; i<space_ndims; i++)
- acc *= hsize[i];
- assert (0==mem_iter->all.offset % acc);
- assert (0==nelmts % acc);
- mem_offset[0] += mem_iter->all.offset / acc;
- hsize[0] = nelmts / acc;
+ if(space_ndims>0) {
+ HDmemset(mem_offset,0,sizeof(hssize_t)*space_ndims);
+
+ if (H5S_extent_dims (mem_space, mem_size, NULL)<0) {
+ HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0,
+ "unable to retrieve data space dimensions");
+ }
+
+ /* Adjust the slowest varying dimension to account for strip mining */
+ for (i=1, acc=1; i<space_ndims; i++)
+ acc *= hsize[i];
+ assert (0==mem_iter->all.offset % acc);
+ assert (0==nelmts % acc);
+ mem_offset[0] += mem_iter->all.offset / acc;
+ hsize[0] = nelmts / acc;
+ } /* end if */
/* The fastest varying dimension is for the data point itself */
mem_offset[space_ndims] = 0;
@@ -410,20 +418,23 @@ H5S_all_mscat (const void *_tconv_buf, size_t elmt_size,
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
"unable to retrieve hyperslab parameters");
}
- HDmemset(mem_offset,0,sizeof(hssize_t)*space_ndims);
-
- if (H5S_extent_dims (mem_space, mem_size, NULL)<0) {
- HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
- "unable to retrieve data space dimensions");
- }
- /* Adjust the slowest varying dimension to take care of strip mining */
- for (i=1, acc=1; i<space_ndims; i++)
- acc *= hsize[i];
- assert (0==mem_iter->all.offset % acc);
- assert (0==nelmts % acc);
- mem_offset[0] += mem_iter->all.offset / acc;
- hsize[0] = nelmts / acc;
+ if(space_ndims>0) {
+ HDmemset(mem_offset,0,sizeof(hssize_t)*space_ndims);
+
+ if (H5S_extent_dims (mem_space, mem_size, NULL)<0) {
+ HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
+ "unable to retrieve data space dimensions");
+ }
+
+ /* Adjust the slowest varying dimension to take care of strip mining */
+ for (i=1, acc=1; i<space_ndims; i++)
+ acc *= hsize[i];
+ assert (0==mem_iter->all.offset % acc);
+ assert (0==nelmts % acc);
+ mem_offset[0] += mem_iter->all.offset / acc;
+ hsize[0] = nelmts / acc;
+ } /* end if */
/* The fastest varying dimension is for the data point itself */
mem_offset[space_ndims] = 0;
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 9eef5ba..cf8b66d 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -196,6 +196,15 @@ printf("%s: check 2.0, bound_count=%d\n",FUNC,bound_count);
next_dim=dim+1;
for(i=0; i<bound_count; i++) {
+#ifdef QAK
+printf("%s: check 2.1, num_reg=%d, pos[%d]=%d\n",FUNC,(int)num_reg,next_dim,(int)pos[next_dim]);
+ {
+ intn j;
+ for(j=next_dim; j>=0; j--)
+ printf("%s: lo_bound[%d][%d]=%d, hi_bound[%d][%d]=%d\n",
+ FUNC,j,i,(int)lo_bounds[j][i].bound,j,i,(int)hi_bounds[j][i].bound);
+ }
+#endif /* QAK */
/* Check if each boundary overlaps in the higher dimensions */
temp_dim=dim;
while(temp_dim>=0 && pos[temp_dim]>=lo_bounds[temp_dim][i].bound &&
@@ -204,8 +213,14 @@ printf("%s: check 2.0, bound_count=%d\n",FUNC,bound_count);
/* Yes, all previous positions match, this is a valid region */
if(temp_dim<0) {
+#ifdef QAK
+printf("%s: check 3.0\n",FUNC);
+#endif /* QAK */
/* Check if we've allocated the array yet */
if(num_reg==0) {
+#ifdef QAK
+printf("%s: check 3.1\n",FUNC);
+#endif /* QAK */
/* Allocate array */
ret_value=H5MM_malloc(sizeof(H5S_hyper_region_t));
@@ -217,9 +232,16 @@ printf("%s: check 2.0, bound_count=%d\n",FUNC,bound_count);
num_reg++;
} else {
/* Check if we should merge this region into the current region */
- if(lo_bounds[next_dim][i].bound<ret_value[curr_reg].end)
+ if(lo_bounds[next_dim][i].bound<ret_value[curr_reg].end) {
+#ifdef QAK
+printf("%s: check 4.1\n",FUNC);
+#endif /* QAK */
ret_value[curr_reg].end=MAX(hi_bounds[next_dim][i].bound,ret_value[curr_reg].end);
+ }
else { /* no overlap with previous region, add new region */
+#ifdef QAK
+printf("%s: check 4.2\n",FUNC);
+#endif /* QAK */
/* Enlarge array */
ret_value=H5MM_realloc(ret_value,sizeof(H5S_hyper_region_t)*(num_reg+1));
@@ -1061,9 +1083,15 @@ printf("%s: check 3.0\n",FUNC);
/* Increment the dimension we are working with */
dim++;
+#ifdef QAK
+printf("%s: check 6.0, num_regions=%d\n",FUNC,(int)num_regions);
+#endif /* QAK */
/* Step through each region in this dimension */
for(i=0; i<num_regions && fhyper_info->nelmts>0; i++) {
/* Step through each location in each region */
+#ifdef QAK
+printf("%s: check 7.0, start[%d]=%d, end[%d]=%d, nelmts=%d\n",FUNC,i,(int)regions[i].start,i,(int)regions[i].end,(int)fhyper_info->nelmts);
+#endif /* QAK */
for(j=regions[i].start; j<=regions[i].end && fhyper_info->nelmts>0; j++) {
/* If we are moving to a new position in this dim, reset the next lower dim. location */
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index e3fccd8..925f7b4 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -219,6 +219,7 @@ H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout,
hsize_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */
hssize_t zero[H5O_LAYOUT_NDIMS]; /*zero */
uint8 *buf=(uint8 *)_buf; /* Alias for pointer arithmetic */
+ uintn ndims; /* Number of dimensions of dataset */
intn i; /*counters */
size_t num_read; /* number of elements read into buffer */
@@ -236,20 +237,21 @@ H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout,
#ifdef QAK
printf("%s: check 1.0\n",FUNC);
#endif /* QAK */
+ ndims=file_space->extent.u.simple.rank;
/* initialize hyperslab size and offset in memory buffer */
- for(i=0; i<layout->ndims; i++) {
+ for(i=0; i<(int)(ndims+1); i++) {
hsize[i]=1; /* hyperslab size is 1, except for last element */
zero[i]=0; /* memory offset is 0 */
} /* end for */
- hsize[layout->ndims] = elmt_size;
+ hsize[ndims] = elmt_size;
/* Walk though and request each element we need and put it into the buffer */
num_read=0;
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*sizeof(hssize_t));
- file_offset[layout->ndims] = 0;
+ HDmemcpy(file_offset,file_iter->pnt.curr->pnt,ndims*sizeof(hssize_t));
+ file_offset[ndims] = 0;
/* Go read the point */
if (H5F_arr_read (f, layout, comp, efl, hsize, hsize, zero, file_offset,
@@ -260,7 +262,7 @@ printf("%s: check 1.0\n",FUNC);
#ifdef QAK
printf("%s: check 3.0\n",FUNC);
{
- for(i=0; i<layout->ndims; i++) {
+ for(i=0; i<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]);
}
@@ -315,6 +317,7 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout,
hsize_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */
hssize_t zero[H5O_LAYOUT_NDIMS]; /*zero vector */
const uint8 *buf=(const uint8 *)_buf; /* Alias for pointer arithmetic */
+ uintn ndims; /* Number of dimensions of dataset */
intn i; /*counters */
size_t num_written; /* number of elements written from buffer */
@@ -332,12 +335,13 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout,
#ifdef QAK
printf("%s: check 1.0, layout->ndims=%d\n",FUNC,(int)layout->ndims);
#endif /* QAK */
+ ndims=file_space->extent.u.simple.rank;
/* initialize hyperslab size and offset in memory buffer */
- for(i=0; i<layout->ndims; i++) {
+ for(i=0; i<(int)(ndims+1); i++) {
hsize[i]=1; /* hyperslab size is 1, except for last element */
zero[i]=0; /* memory offset is 0 */
} /* end for */
- hsize[layout->ndims] = elmt_size;
+ hsize[ndims] = elmt_size;
/* Walk though and request each element we need and put it into the buffer */
num_written=0;
@@ -345,19 +349,19 @@ printf("%s: check 1.0, layout->ndims=%d\n",FUNC,(int)layout->ndims);
#ifdef QAK
printf("%s: check 2.0\n",FUNC);
{
- for(i=0; i<layout->ndims; i++) {
+ for(i=0; i<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;
+ HDmemcpy(file_offset,file_iter->pnt.curr->pnt,ndims*sizeof(hssize_t));
+ file_offset[ndims] = 0;
#ifdef QAK
printf("%s: check 3.0\n",FUNC);
{
- for(i=0; i<layout->ndims; i++) {
+ for(i=0; i<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]);
}
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 28197a8..c8ddd4b 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -125,7 +125,7 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src)
herr_t
H5S_select_release (H5S_t *space)
{
- herr_t ret_value; /* return value */
+ herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER (H5S_select_release, FAIL);
@@ -185,8 +185,8 @@ H5Sselect_hyperslab (hid_t spaceid, H5S_seloper_t op,
const hsize_t *_block)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
- hsize_t *stride, /* Stride array */
- *block; /* Block size array */
+ hsize_t *stride, /* Stride array */
+ *block=NULL; /* Block size array */
uintn contig; /* whether selection is contiguous or not */
int i; /* Counters */
herr_t ret_value=FAIL; /* return value */
@@ -506,7 +506,7 @@ H5S_select_npoints (const H5S_t *space)
herr_t
H5S_sel_iter_release (const H5S_t *space, H5S_sel_iter_t *sel_iter)
{
- herr_t ret_value; /* Return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER (H5S_sel_iter_release, FAIL);
diff --git a/test/tselect.c b/test/tselect.c
index a488e7a..aebd7f3 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -447,7 +447,7 @@ test_select_combo(void)
/* Free memory buffers */
free(wbuf);
free(rbuf);
-} /* test_select_point() */
+} /* test_select_combo() */
/****************************************************************
**