summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-06-04 15:22:23 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-06-04 15:22:23 (GMT)
commitbb042d83c73df85f30c7103e9ff93b5cc630fced (patch)
tree5638b25ee89850f8066baadb25d24a7f5e688f6c
parent112aff61caec385132f05fc50efe8d3ce3357929 (diff)
downloadhdf5-bb042d83c73df85f30c7103e9ff93b5cc630fced.zip
hdf5-bb042d83c73df85f30c7103e9ff93b5cc630fced.tar.gz
hdf5-bb042d83c73df85f30c7103e9ff93b5cc630fced.tar.bz2
[svn-r6950] Purpose:
API tweak. Description: The H5Sget_select_bounds() API call was using hsize_t arrays for retrieving the 'start' and 'end' coordinates, which is counter to the rest of the dataspace API. Solution: Change the arrays to be hssize_t instead. Platforms tested: FreeBSD 4.8 (sleipnir) w/C++ FreeBSD 4.8 (sleipnir) w/parallel h5committested Misc. update: Updated all docs for this change. Added 1.4 compatibility #ifdef's
-rw-r--r--c++/src/H5DataSpace.cpp2
-rw-r--r--c++/src/H5DataSpace.h2
-rwxr-xr-xdoc/html/ADGuide/Changes.html4
-rw-r--r--doc/html/Intro/IntroExamples.html4
-rw-r--r--doc/html/RM_H5S.html8
-rw-r--r--doc/html/Tutor/examples/h5_ref2regr.c4
-rw-r--r--doc/html/fortran/h5s_FORTRAN.html4
-rw-r--r--fortran/src/H5Sf.c12
-rw-r--r--fortran/src/H5Sff.f908
-rw-r--r--fortran/src/H5f90proto.h2
-rw-r--r--fortran/test/tH5Sselect.f904
-rw-r--r--release_docs/RELEASE.txt3
-rw-r--r--src/H5Spublic.h4
-rw-r--r--src/H5Sselect.c426
-rw-r--r--test/trefer.c9
15 files changed, 379 insertions, 117 deletions
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp
index 091fa10..c6c64a8 100644
--- a/c++/src/H5DataSpace.cpp
+++ b/c++/src/H5DataSpace.cpp
@@ -266,7 +266,7 @@ void DataSpace::getSelectElemPointlist ( hsize_t startpoint, hsize_t numpoints,
}
// Gets the bounding box containing the current selection
-void DataSpace::getSelectBounds ( hsize_t* start, hsize_t* end ) const
+void DataSpace::getSelectBounds ( hssize_t* start, hssize_t* end ) const
{
herr_t ret_value = H5Sget_select_bounds( id, start, end );
if( ret_value < 0 )
diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h
index 2515ef0..87b5a81 100644
--- a/c++/src/H5DataSpace.h
+++ b/c++/src/H5DataSpace.h
@@ -81,7 +81,7 @@ class H5_DLLCPP DataSpace : public IdComponent {
void getSelectElemPointlist( hsize_t startpoint, hsize_t numpoints, hsize_t *buf ) const;
// Gets the bounding box containing the current selection.
- void getSelectBounds( hsize_t* start, hsize_t* end ) const;
+ void getSelectBounds( hssize_t* start, hssize_t* end ) const;
// Selects array elements to be included in the selection for
// this dataspace.
diff --git a/doc/html/ADGuide/Changes.html b/doc/html/ADGuide/Changes.html
index 47a4369..79df8e7 100755
--- a/doc/html/ADGuide/Changes.html
+++ b/doc/html/ADGuide/Changes.html
@@ -97,6 +97,10 @@ H5function6
following the call to "flush". Actions in the "flush" call
that are duplicated in the VFL "close" call may be omitted by
the VFL driver.
+ <dt><code>H5Sget_select_bounds</code>
+ <dd>The 'start' and 'end' parameters have changed from
+ <code>'hsize_t *'</code>
+ to <code>'hssize_t *'</code> to better match the rest of the dataspace API.
<dt><code>H5function</code>
<dd>Description of change
</dl>
diff --git a/doc/html/Intro/IntroExamples.html b/doc/html/Intro/IntroExamples.html
index a3bd8dd..b5be1af 100644
--- a/doc/html/Intro/IntroExamples.html
+++ b/doc/html/Intro/IntroExamples.html
@@ -1970,8 +1970,8 @@ main(void)
hid_t sid1, /* Dataspace ID #1 */
sid2; /* Dataspace ID #2 */
hsize_t * coords; /* Coordinate buffer */
- hsize_t low[SPACE2_RANK]; /* Selection bounds */
- hsize_t high[SPACE2_RANK]; /* Selection bounds */
+ hssize_t low[SPACE2_RANK]; /* Selection bounds */
+ hssize_t high[SPACE2_RANK]; /* Selection bounds */
hdset_reg_ref_t *rbuf; /* buffer to to read disk */
int *drbuf; /* Buffer for reading numeric data from disk */
int i, j; /* counting variables */
diff --git a/doc/html/RM_H5S.html b/doc/html/RM_H5S.html
index 9b29d93..ec39de2 100644
--- a/doc/html/RM_H5S.html
+++ b/doc/html/RM_H5S.html
@@ -1165,8 +1165,8 @@ of the <cite>HDF5 User's Guide.</cite>.
<dt><strong>Name:</strong> <a name="Dataspace-SelectBounds">H5Sget_select_bounds</a>
<dt><strong>Signature:</strong>
<dd><em>herr_t </em><code>H5Sget_select_bounds</code>(<em>hid_t </em><code>space_id</code>,
- <em>hsize_t *</em><code>start</code>,
- <em>hsize_t *</em><code>end</code>
+ <em>hssize_t *</em><code>start</code>,
+ <em>hssize_t *</em><code>end</code>
)
<dt><strong>Purpose:</strong>
<dd>Gets the bounding box containing the current selection.
@@ -1192,9 +1192,9 @@ of the <cite>HDF5 User's Guide.</cite>.
<dl>
<dt><em>hid_t</em> <code>space_id</code>
<dd>IN: Identifier of dataspace to query.
- <dt><em>hsize_t *</em><code>start</code>
+ <dt><em>hssize_t *</em><code>start</code>
<dd>OUT: Starting coordinates of the bounding box.
- <dt><em>hsize_t *</em><code>end</code>
+ <dt><em>hssize_t *</em><code>end</code>
<dd>OUT: Ending coordinates of the bounding box,
i.e., the coordinates of the diagonally opposite corner.
</dl>
diff --git a/doc/html/Tutor/examples/h5_ref2regr.c b/doc/html/Tutor/examples/h5_ref2regr.c
index 9f747ae..26b5daf 100644
--- a/doc/html/Tutor/examples/h5_ref2regr.c
+++ b/doc/html/Tutor/examples/h5_ref2regr.c
@@ -24,8 +24,8 @@ main(void)
hid_t sid1, /* Dataspace ID #1 */
sid2; /* Dataspace ID #2 */
hsize_t * coords; /* Coordinate buffer */
- hsize_t low[SPACE2_RANK]; /* Selection bounds */
- hsize_t high[SPACE2_RANK]; /* Selection bounds */
+ hssize_t low[SPACE2_RANK]; /* Selection bounds */
+ hssize_t high[SPACE2_RANK]; /* Selection bounds */
hdset_reg_ref_t *rbuf; /* buffer to to read disk */
int *drbuf; /* Buffer for reading numeric data from disk */
int i, j; /* counting variables */
diff --git a/doc/html/fortran/h5s_FORTRAN.html b/doc/html/fortran/h5s_FORTRAN.html
index b71b459..731233b 100644
--- a/doc/html/fortran/h5s_FORTRAN.html
+++ b/doc/html/fortran/h5s_FORTRAN.html
@@ -795,9 +795,9 @@ FORTRAN Dataspace API -- h5s
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: space_id ! Dataspace identifier
- INTEGER(HSIZE_T), DIMENSION(*), INTENT(OUT) :: start
+ INTEGER(HSSIZE_T), DIMENSION(*), INTENT(OUT) :: start
! Starting coordinate of the bounding box
- INTEGER(HSIZE_T), DIMENSION(*), INTENT(OUT) ::end
+ INTEGER(HSSIZE_T), DIMENSION(*), INTENT(OUT) ::end
! Ending coordinate (opposite corner)
! of the bounding box
INTEGER, INTENT(OUT) :: hdferr ! Error code
diff --git a/fortran/src/H5Sf.c b/fortran/src/H5Sf.c
index a6a793e..c9cc66b 100644
--- a/fortran/src/H5Sf.c
+++ b/fortran/src/H5Sf.c
@@ -246,28 +246,28 @@ nh5sget_select_hyper_blocklist_c( hid_t_f *space_id ,hsize_t_f * startblock,
*---------------------------------------------------------------------------*/
int_f
-nh5sget_select_bounds_c( hid_t_f *space_id , hsize_t_f * start, hsize_t_f * end)
+nh5sget_select_bounds_c( hid_t_f *space_id , hssize_t_f * start, hssize_t_f * end)
{
int ret_value = -1;
hid_t c_space_id;
- hsize_t* c_start, *c_end;
+ hssize_t* c_start, *c_end;
int i, rank;
c_space_id = *space_id;
rank = H5Sget_simple_extent_ndims(c_space_id);
if (rank < 0 ) return ret_value;
- c_start =(hsize_t*) malloc(sizeof(hsize_t)*rank);
+ c_start =(hssize_t*) malloc(sizeof(hssize_t)*rank);
if (!c_start) return ret_value;
- c_end = (hsize_t*)malloc(sizeof(hsize_t)*rank);
+ c_end = (hssize_t*)malloc(sizeof(hssize_t)*rank);
if(!c_end) return ret_value;
ret_value = H5Sget_select_bounds(c_space_id, c_start, c_end);
for(i = 0; i < rank; i++)
{
- start[i] = (hsize_t_f)(c_start[i]+1);
- end[i] = (hsize_t_f)(c_end[i]+1);
+ start[i] = (hssize_t_f)(c_start[i]+1);
+ end[i] = (hssize_t_f)(c_end[i]+1);
}
if (ret_value >= 0 ) ret_value = 0;
diff --git a/fortran/src/H5Sff.f90 b/fortran/src/H5Sff.f90
index a938947..9f854f5 100644
--- a/fortran/src/H5Sff.f90
+++ b/fortran/src/H5Sff.f90
@@ -436,9 +436,9 @@
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: space_id ! Dataspace identifier
- INTEGER(HSIZE_T), DIMENSION(*), INTENT(OUT) :: start
+ INTEGER(HSSIZE_T), DIMENSION(*), INTENT(OUT) :: start
!Starting coordinates of the bounding box.
- INTEGER(HSIZE_T), DIMENSION(*), INTENT(OUT) :: end
+ INTEGER(HSSIZE_T), DIMENSION(*), INTENT(OUT) :: end
!Ending coordinates of the bounding box,
!i.e., the coordinates of the diagonally
!opposite corner
@@ -454,8 +454,8 @@
!MS$ATTRIBUTES C,reference,alias:'_H5SGET_SELECT_BOUNDS_C'::h5sget_select_bounds_c
!DEC$ ENDIF
INTEGER(HID_T), INTENT(IN) :: space_id
- INTEGER(HSIZE_T), DIMENSION(*), INTENT(OUT) :: start
- INTEGER(HSIZE_T), DIMENSION(*), INTENT(OUT) :: end
+ INTEGER(HSSIZE_T), DIMENSION(*), INTENT(OUT) :: start
+ INTEGER(HSSIZE_T), DIMENSION(*), INTENT(OUT) :: end
END FUNCTION h5sget_select_bounds_c
END INTERFACE
diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h
index 2272bce..eb36088 100644
--- a/fortran/src/H5f90proto.h
+++ b/fortran/src/H5f90proto.h
@@ -159,7 +159,7 @@ H5_DLL int_f nh5scopy_c ( hid_t_f *space_id , hid_t_f *new_space_id);
H5_DLL int_f nh5sget_select_hyper_nblocks_c( hid_t_f *space_id , hssize_t_f * num_blocks);
H5_DLL int_f nh5sget_select_hyper_blocklist_c( hid_t_f *space_id ,hsize_t_f * startblock, hsize_t_f * num_blocks, hsize_t_f * buf);
-H5_DLL int_f nh5sget_select_bounds_c( hid_t_f *space_id , hsize_t_f * start, hsize_t_f * end);
+H5_DLL int_f nh5sget_select_bounds_c( hid_t_f *space_id , hssize_t_f * start, hssize_t_f * end);
H5_DLL int_f nh5sget_select_elem_npoints_c( hid_t_f *space_id , hssize_t_f * num_points);
diff --git a/fortran/test/tH5Sselect.f90 b/fortran/test/tH5Sselect.f90
index 8b2e281..0e3ed9e 100644
--- a/fortran/test/tH5Sselect.f90
+++ b/fortran/test/tH5Sselect.f90
@@ -792,9 +792,9 @@
INTEGER(HSIZE_T), ALLOCATABLE, DIMENSION(:) :: pointlist
!
- !start and end bounds in the current dataspac selection
+ !start and end bounds in the current dataspace selection
!
- INTEGER(HSIZE_T), DIMENSION(RANK) :: startout, endout
+ INTEGER(HSSIZE_T), DIMENSION(RANK) :: startout, endout
!
!data to write
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 773a586..8bae635 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -58,6 +58,9 @@ Library:
Complete list of changes:
+ * Changed H5Sget_select_bounds to use 'hssize_t *' for start and end
+ parameters, instead of 'hsize_t *', to better match other parts of the
+ dataspace API. QAK - 2003/06/04
* Changed raw data I/O to only access each chunk once, improving performance
in many situations with hyperslabs and large chunks or chunks with
filters. These improvements are currently limited to serial I/O, with
diff --git a/src/H5Spublic.h b/src/H5Spublic.h
index 869a43c..8272dfa 100644
--- a/src/H5Spublic.h
+++ b/src/H5Spublic.h
@@ -136,7 +136,11 @@ H5_DLL hssize_t H5Sget_select_hyper_nblocks(hid_t spaceid);
H5_DLL hssize_t H5Sget_select_elem_npoints(hid_t spaceid);
H5_DLL herr_t H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numblocks, hsize_t *buf);
H5_DLL herr_t H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, hsize_t numpoints, hsize_t *buf);
+#ifdef H5_WANT_H5_V1_4_COMPAT
H5_DLL herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t *start, hsize_t *end);
+#else /* H5_WANT_H5_V1_4_COMPAT */
+H5_DLL herr_t H5Sget_select_bounds(hid_t spaceid, hssize_t *start, hssize_t *end);
+#endif /* H5_WANT_H5_V1_4_COMPAT */
H5_DLL H5S_sel_type H5Sget_select_type(hid_t spaceid);
#ifdef __cplusplus
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 6c3d42d..944e5c6 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -28,11 +28,18 @@
#include "H5Spkg.h" /* Dataspace functions */
#include "H5Vprivate.h" /* Vector functions */
-/* Interface initialization */
+/* Pablo mask */
#define PABLO_MASK H5Sselect_mask
+
+/* Interface initialization */
#define INTERFACE_INIT NULL
static int interface_initialize_g = 0;
+/* Local functions */
+static herr_t H5S_select_iter_block (const H5S_sel_iter_t *iter, hssize_t *start, hssize_t *end);
+static htri_t H5S_select_iter_has_next_block (const H5S_sel_iter_t *iter);
+static herr_t H5S_select_iter_next_block(H5S_sel_iter_t *iter);
+
/* Declare external the free list for hssize_t arrays */
H5FL_ARR_EXTERN(hssize_t);
@@ -208,7 +215,7 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src)
break;
default:
- assert("unknown data space type" && 0);
+ assert("unknown dataspace type" && 0);
break;
} /* end switch */
@@ -280,7 +287,7 @@ H5Sget_select_npoints(hid_t spaceid)
/* Check args */
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace");
ret_value = H5S_get_select_npoints(space);
@@ -354,7 +361,7 @@ H5Sselect_valid(hid_t spaceid)
/* Check args */
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataspace");
ret_value = H5S_select_valid(space);
@@ -468,8 +475,8 @@ done:
USAGE
herr_t H5S_get_select_bounds(space, start, end)
hid_t dsid; IN: Dataspace ID of selection to query
- hsize_t *start; OUT: Starting coordinate of bounding box
- hsize_t *end; OUT: Opposite coordinate of bounding box
+ hssize_t *start; OUT: Starting coordinate of bounding box
+ hssize_t *end; OUT: Opposite coordinate of bounding box
RETURNS
Non-negative on success, negative on failure
DESCRIPTION
@@ -487,9 +494,42 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
+#ifdef H5_WANT_H5_V1_4_COMPAT
herr_t
H5Sget_select_bounds(hid_t spaceid, hsize_t *start, hsize_t *end)
{
+ hssize_t tstart[H5O_LAYOUT_NDIMS]; /* Temporary starting coordinates */
+ hssize_t tend[H5O_LAYOUT_NDIMS]; /* Temporary ending coordinates */
+ H5S_t *space = NULL; /* Dataspace to modify selection of */
+ unsigned u; /* Local index variable */
+ herr_t ret_value; /* return value */
+
+ FUNC_ENTER_API(H5Sget_select_bounds, FAIL);
+ H5TRACE3("e","i*h*h",spaceid,start,end);
+
+ /* Check args */
+ if(start==NULL || end==NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
+ if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace");
+
+ ret_value = H5S_get_select_bounds(space,tstart,tend);
+
+ if(ret_value>=0) {
+ /* Copy over the start & end values */
+ for(u=0; u<space->extent.u.simple.rank; u++) {
+ H5_ASSIGN_OVERFLOW(start[u],tstart[u],hssize_t,hsize_t);
+ H5_ASSIGN_OVERFLOW(end[u],tend[u],hssize_t,hsize_t);
+ } /* end for */
+ } /* end if */
+
+done:
+ FUNC_LEAVE_API(ret_value);
+} /* H5Sget_select_bounds() */
+#else /* H5_WANT_H5_V1_4_COMPAT */
+herr_t
+H5Sget_select_bounds(hid_t spaceid, hssize_t *start, hssize_t *end)
+{
H5S_t *space = NULL; /* Dataspace to modify selection of */
herr_t ret_value; /* return value */
@@ -500,13 +540,14 @@ H5Sget_select_bounds(hid_t spaceid, hsize_t *start, hsize_t *end)
if(start==NULL || end==NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace");
ret_value = H5S_get_select_bounds(space,start,end);
done:
FUNC_LEAVE_API(ret_value);
} /* H5Sget_select_bounds() */
+#endif /* H5_WANT_H5_V1_4_COMPAT */
/*--------------------------------------------------------------------------
@@ -517,8 +558,8 @@ done:
USAGE
herr_t H5S_get_select_bounds(space, start, end)
H5S_t *space; IN: Dataspace ID of selection to query
- hsize_t *start; OUT: Starting coordinate of bounding box
- hsize_t *end; OUT: Opposite coordinate of bounding box
+ hssize_t *start; OUT: Starting coordinate of bounding box
+ hssize_t *end; OUT: Opposite coordinate of bounding box
RETURNS
Non-negative on success, negative on failure
DESCRIPTION
@@ -537,7 +578,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
+H5S_get_select_bounds(const H5S_t *space, hssize_t *start, hssize_t *end)
{
herr_t ret_value; /* return value */
@@ -582,7 +623,6 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_s
/* Check args */
assert(sel_iter);
assert(space);
- assert(elmt_size>0);
/* Initialize common information */
@@ -644,6 +684,45 @@ done:
/*--------------------------------------------------------------------------
NAME
+ H5S_select_iter_block
+ PURPOSE
+ Get the block of the current iterator position
+ USAGE
+ herr_t H5S_select_iter_block(sel_iter,start,end)
+ const H5S_sel_iter_t *sel_iter; IN: Selection iterator to query
+ hssize_t *start; OUT: Array to place iterator start block coordinates
+ hssize_t *end; OUT: Array to place iterator end block coordinates
+ RETURNS
+ Non-negative on success, negative on failure.
+ DESCRIPTION
+ The current location of the iterator within the selection is placed in
+ the COORDS array.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S_select_iter_block (const H5S_sel_iter_t *iter, hssize_t *start, hssize_t *end)
+{
+ herr_t ret_value; /* return value */
+
+ FUNC_ENTER_NOINIT(H5S_select_iter_block);
+
+ /* Check args */
+ assert(iter);
+ assert(start);
+ assert(end);
+
+ /* Call iter_block routine for selection type */
+ ret_value = (*iter->iter_block)(iter,start,end);
+
+ FUNC_LEAVE_NOAPI(ret_value);
+} /* H5S_select_iter_block() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5S_select_iter_nelmts
PURPOSE
Get the number of elements left to iterate over in selection
@@ -679,9 +758,44 @@ done:
/*--------------------------------------------------------------------------
NAME
+ H5S_select_iter_has_next_block
+ PURPOSE
+ Check if there is another block available in the selection iterator
+ USAGE
+ htri_t H5S_select_iter_has_next_block(sel_iter)
+ const H5S_sel_iter_t *sel_iter; IN: Selection iterator to query
+ RETURNS
+ Non-negative on success, negative on failure.
+ DESCRIPTION
+ Check if there is another block available to advance to in the selection
+ iterator.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static htri_t
+H5S_select_iter_has_next_block (const H5S_sel_iter_t *iter)
+{
+ herr_t ret_value; /* return value */
+
+ FUNC_ENTER_NOINIT(H5S_select_iter_has_next_block);
+
+ /* Check args */
+ assert(iter);
+
+ /* Call iter_has_next_block routine for selection type */
+ ret_value = (*iter->iter_has_next_block)(iter);
+
+ FUNC_LEAVE_NOAPI(ret_value);
+} /* H5S_select_iter_has_next_block() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5S_select_iter_next
PURPOSE
- Advance seletion iterator
+ Advance selection iterator to next element
USAGE
herr_t H5S_select_iter_next(iter, nelem)
H5S_sel_iter_t *iter; IN/OUT: Selection iterator to change
@@ -707,7 +821,7 @@ H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem)
assert(iter);
assert(nelem>0);
- /* Call iter_coords routine for selection type */
+ /* Call iter_next routine for selection type */
ret_value = (*iter->iter_next)(iter,nelem);
/* Decrement the number of elements left in selection */
@@ -720,6 +834,42 @@ done:
/*--------------------------------------------------------------------------
NAME
+ H5S_select_iter_next_block
+ PURPOSE
+ Advance selection iterator to next block
+ USAGE
+ herr_t H5S_select_iter_next(iter)
+ H5S_sel_iter_t *iter; IN/OUT: Selection iterator to change
+ RETURNS
+ Non-negative on success, negative on failure.
+ DESCRIPTION
+ Move the current element for the selection iterator to the next
+ block in the selection.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ Doesn't maintain the 'elmt_left' field of the selection iterator.
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S_select_iter_next_block(H5S_sel_iter_t *iter)
+{
+ herr_t ret_value; /* return value */
+
+ FUNC_ENTER_NOINIT(H5S_select_iter_next_block);
+
+ /* Check args */
+ assert(iter);
+
+ /* Call iter_next_block routine for selection type */
+ ret_value = (*iter->iter_next_block)(iter);
+
+ FUNC_LEAVE_NOAPI(ret_value);
+} /* H5S_select_iter_next_block() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5S_select_iter_release
PURPOSE
Release a selection iterator's resources.
@@ -945,7 +1095,7 @@ H5Sget_select_type(hid_t space_id)
/* Check args */
if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5S_SEL_ERROR, "not a data space");
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5S_SEL_ERROR, "not a dataspace");
/* Set return value */
ret_value=H5S_get_select_type(space);
@@ -1012,98 +1162,180 @@ done:
htri_t
H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
{
- H5S_hyper_span_t *span1=NULL,*span2=NULL; /* Hyperslab span node */
- hsize_t elmts1=0,elmts2=0; /* Number of elements in each dimension of selection */
+ H5S_sel_iter_t iter1; /* Selection #1 iteration info */
+ H5S_sel_iter_t iter2; /* Selection #2 iteration info */
+ hbool_t iter1_init=0; /* Selection #1 iteration info has been initialized */
+ hbool_t iter2_init=0; /* Selection #2 iteration info has been initialized */
unsigned u; /* Index variable */
htri_t ret_value=TRUE; /* return value */
FUNC_ENTER_NOAPI(H5S_select_shape_same, FAIL);
+#ifdef QAK
+HDfprintf(stderr,"%s: Entering\n",FUNC);
+#endif /* QAK */
/* Check args */
assert(space1);
assert(space2);
+ /* Check for different dimensionality */
if (space1->extent.u.simple.rank!=space2->extent.u.simple.rank)
HGOTO_DONE(FALSE);
- /* Get information about memory and file */
- for (u=0; u<space1->extent.u.simple.rank; u++) {
- switch(space1->select.type) {
- case H5S_SEL_HYPERSLABS:
- /* Check size hyperslab selection in this dimension */
- if(space1->select.sel_info.hslab.diminfo != NULL) {
- elmts1=space1->select.sel_info.hslab.diminfo[u].block;
- } /* end if */
- else {
- /* Check for the first dimension */
- if(span1==NULL)
- span1=space1->select.sel_info.hslab.span_lst->head;
-
- /* Get the number of elements in the span */
- elmts1=(span1->high-span1->low)+1;
-
- /* Advance to the next dimension */
- span1=span1->down->head;
- } /* end else */
- break;
+ /* Check for different number of elements selected */
+ if(H5S_get_select_npoints(space1)!=H5S_get_select_npoints(space2))
+ HGOTO_DONE(FALSE);
- case H5S_SEL_ALL:
- elmts1=space1->extent.u.simple.size[u];
- break;
+ /* Check for "easy" cases before getting into generalized block iteration code */
+ if(space1->select.type==H5S_SEL_ALL && space2->select.type==H5S_SEL_ALL) {
+ hsize_t dims1[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #1 */
+ hsize_t dims2[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #2 */
- case H5S_SEL_POINTS:
- elmts1=1;
- break;
+ if(H5S_get_simple_extent_dims(space1, dims1, NULL)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality");
+ if(H5S_get_simple_extent_dims(space2, dims2, NULL)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality");
- case H5S_SEL_NONE:
- elmts1=0;
- break;
+ /* Check that the sizes are the same */
+ for (u=0; u<space1->extent.u.simple.rank; u++)
+ if(dims1[u]!=dims2[u])
+ HGOTO_DONE(FALSE);
+ } /* end if */
+ else if(space1->select.type==H5S_SEL_NONE || space2->select.type==H5S_SEL_NONE) {
+ HGOTO_DONE(TRUE);
+ } /* end if */
+ else if((space1->select.type==H5S_SEL_HYPERSLABS && space1->select.sel_info.hslab.diminfo)
+ && (space2->select.type==H5S_SEL_HYPERSLABS && space2->select.sel_info.hslab.diminfo)) {
+
+ /* Check that the shapes are the same */
+ for (u=0; u<space1->extent.u.simple.rank; u++) {
+ if(space1->select.sel_info.hslab.diminfo[u].stride!=space2->select.sel_info.hslab.diminfo[u].stride)
+ HGOTO_DONE(FALSE);
+ if(space1->select.sel_info.hslab.diminfo[u].count!=space2->select.sel_info.hslab.diminfo[u].count)
+ HGOTO_DONE(FALSE);
+ if(space1->select.sel_info.hslab.diminfo[u].block!=space2->select.sel_info.hslab.diminfo[u].block)
+ HGOTO_DONE(FALSE);
+ } /* end for */
+ } /* end if */
+ /* Iterate through all the blocks in the selection */
+ else {
+ hssize_t start1[H5O_LAYOUT_NDIMS]; /* Start point of selection block in dataspace #1 */
+ hssize_t start2[H5O_LAYOUT_NDIMS]; /* Start point of selection block in dataspace #2 */
+ hssize_t end1[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #1 */
+ hssize_t end2[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #2 */
+ hssize_t off1[H5O_LAYOUT_NDIMS]; /* Offset of selection #1 blocks */
+ hssize_t off2[H5O_LAYOUT_NDIMS]; /* Offset of selection #2 blocks */
+ htri_t status1,status2; /* Status from next block checks */
+ unsigned first_block=1; /* Flag to indicate the first block */
+#ifdef QAK
+HDfprintf(stderr,"%s: Check 10.0\n",FUNC);
+#endif /* QAK */
- default:
- assert(0 && "Invalid selection type!");
- } /* end switch */
-
- switch(space2->select.type) {
- case H5S_SEL_HYPERSLABS:
- /* Check size hyperslab selection in this dimension */
- if(space2->select.sel_info.hslab.diminfo != NULL) {
- elmts2=space2->select.sel_info.hslab.diminfo[u].block;
- } /* end if */
- else {
- /* Check for the first dimension */
- if(span2==NULL)
- span2=space2->select.sel_info.hslab.span_lst->head;
-
- /* Get the number of elements in the span */
- elmts2=(span2->high-span2->low)+1;
-
- /* Advance to the next dimension */
- span2=span2->down->head;
- } /* end else */
- break;
+ /* Initialize iterator for each dataspace selection
+ * Use '0' for element size instead of actual element size to indicate
+ * that the selection iterator shouldn't be "flattened", since we
+ * aren't actually going to be doing I/O with the iterators.
+ */
+ if (H5S_select_iter_init(&iter1, space1, 0)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator");
+ iter1_init=1;
+ if (H5S_select_iter_init(&iter2, space2, 0)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator");
+ iter2_init=1;
+
+ /* Iterate over all the blocks in each selection */
+ while(1) {
+ /* Get the current block for each selection iterator */
+ if(H5S_select_iter_block(&iter1,start1,end1)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get iterator block");
+#ifdef QAK
+{
+ HDfprintf(stderr,"%s: iter1 start={",FUNC);
+ for(u=0; u<space1->extent.u.simple.rank; u++)
+ HDfprintf(stderr,"%Hd%s",start1[u],(u<(space1->extent.u.simple.rank-1) ? ", " : "}\n"));
+ HDfprintf(stderr,"%s: iter1 end={",FUNC);
+ for(u=0; u<space1->extent.u.simple.rank; u++)
+ HDfprintf(stderr,"%Hd%s",end1[u],(u<(space1->extent.u.simple.rank-1) ? ", " : "}\n"));
+}
+#endif /* QAK */
+ if(H5S_select_iter_block(&iter2,start2,end2)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get iterator block");
+#ifdef QAK
+{
+ HDfprintf(stderr,"%s: iter2 start={",FUNC);
+ for(u=0; u<space1->extent.u.simple.rank; u++)
+ HDfprintf(stderr,"%Hd%s",start2[u],(u<(space1->extent.u.simple.rank-1) ? ", " : "}\n"));
+ HDfprintf(stderr,"%s: iter2 end={",FUNC);
+ for(u=0; u<space1->extent.u.simple.rank; u++)
+ HDfprintf(stderr,"%Hd%s",end2[u],(u<(space1->extent.u.simple.rank-1) ? ", " : "}\n"));
+}
+#endif /* QAK */
- case H5S_SEL_ALL:
- elmts2=space2->extent.u.simple.size[u];
- break;
+ /* The first block only compares the sizes and sets the relative offsets for later blocks */
+ if(first_block) {
+ /* If the block sizes from each selection doesn't match, get out */
+ for (u=0; u<space1->extent.u.simple.rank; u++) {
+ if((end1[u]-start1[u])!=(end2[u]-start2[u]))
+ HGOTO_DONE(FALSE);
- case H5S_SEL_POINTS:
- elmts2=1;
- break;
+ /* Set the relative locations of the selections */
+ off1[u]=start1[u];
+ off2[u]=start2[u];
+ } /* end for */
- case H5S_SEL_NONE:
- elmts2=0;
- break;
+ /* Reset "first block" flag */
+ first_block=0;
+ } /* end if */
+ else {
+ /* Check over the blocks for each selection */
+ for (u=0; u<space1->extent.u.simple.rank; u++) {
+ /* Check if the blocks are in the same relative location */
+ if((start1[u]-off1[u])!=(start2[u]-off2[u]))
+ HGOTO_DONE(FALSE);
+
+ /* If the block sizes from each selection doesn't match, get out */
+ if((end1[u]-start1[u])!=(end2[u]-start2[u]))
+ HGOTO_DONE(FALSE);
+ } /* end for */
+ } /* end else */
- default:
- assert(0 && "Invalid selection type!");
- } /* end switch */
+ /* Check if we are able to advance to the next selection block */
+ if((status1=H5S_select_iter_has_next_block(&iter1))<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to check iterator block");
+ if((status2=H5S_select_iter_has_next_block(&iter2))<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to check iterator block");
+#ifdef QAK
+HDfprintf(stderr,"%s: status1=%d, status2=%d\n",FUNC,(int)status1,(int)status2);
+#endif /* QAK */
- /* Make certaint the selections have the same number of elements in this dimension */
- if (elmts1!=elmts2)
- HGOTO_DONE(FALSE);
- } /* end for */
+ /* Did we run out of blocks at the same time? */
+ if(status1==FALSE && status2==FALSE)
+ break;
+ else if(status1!=status2) {
+ HGOTO_DONE(FALSE);
+ } /* end if */
+ else {
+ /* Advance to next block in selection iterators */
+ if(H5S_select_iter_next_block(&iter1)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to advance to next iterator block");
+ if(H5S_select_iter_next_block(&iter2)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to advance to next iterator block");
+ } /* end else */
+ } /* end while */
+ } /* end else */
done:
+ if(iter1_init) {
+ if (H5S_select_iter_release(&iter1)<0)
+ HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator");
+ } /* end if */
+ if(iter2_init) {
+ if (H5S_select_iter_release(&iter2)<0)
+ HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator");
+ } /* end if */
+#ifdef QAK
+HDfprintf(stderr,"%s: Leaving, ret_value=%d\n",FUNC,ret_value);
+#endif /* QAK */
FUNC_LEAVE_NOAPI(ret_value);
} /* H5S_select_shape_same() */
@@ -1232,7 +1464,7 @@ done:
*
* 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
+ * the file dataspace FILE_SPACE and stored according to
* LAYOUT and EFL. Each element is ELMT_SIZE bytes.
* The caller is requesting that NELMTS elements are copied.
*
@@ -1330,7 +1562,7 @@ done:
* how the data is stored on disk and EFL describes how the data
* is organized in external files. ELMT_SIZE is the size in
* bytes of a datum which this function treats as opaque.
- * FILE_SPACE describes the data space of the dataset on disk
+ * FILE_SPACE describes the dataspace of the dataset on disk
* and the elements that have been selected for reading (via
* hyperslab, etc). This function will copy at most NELMTS
* elements.
@@ -1842,6 +2074,15 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, H5P_genplist_t *dc_plist,
/* Loop, until all bytes are processed */
while(maxbytes>0) {
/* Check if more file sequences are needed */
+#ifdef QAK
+{
+ int mpi_rank;
+ double time;
+ MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
+ time = MPI_Wtime();
+ HDfprintf(stderr,"%s: rank=%d - Before file sequence time=%f\n",FUNC,mpi_rank,time);
+}
+#endif /* QAK */
if(curr_file_seq>=file_nseq) {
/* Get sequences for file selection */
if((*file_space->select.get_seq_list)(file_space,H5S_GET_SEQ_LIST_SORTED,&file_iter,elmt_size,(size_t)vector_size,maxbytes,&file_nseq,&file_nbytes,file_off,file_len)<0)
@@ -1850,6 +2091,15 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, H5P_genplist_t *dc_plist,
/* Start at the beginning of the sequences again */
curr_file_seq=0;
} /* end if */
+#ifdef QAK
+{
+ int mpi_rank;
+ double time;
+ MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
+ time = MPI_Wtime();
+ HDfprintf(stderr,"%s: rank=%d - After file sequence time=%f\n",FUNC,mpi_rank,time);
+}
+#endif /* QAK */
/* Check if more memory sequences are needed */
if(curr_mem_seq>=mem_nseq) {
@@ -1867,11 +2117,7 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, H5P_genplist_t *dc_plist,
double time;
MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
time = MPI_Wtime();
- HDfprintf(stderr,"%s: rank=%d - time=%f\n",FUNC,mpi_rank,time);
- HDfprintf(stderr,"%s: rank=%d - curr_file_seq=%Zu, file_nseq=%Zu\n",FUNC,mpi_rank,curr_file_seq,file_nseq);
- HDfprintf(stderr,"%s: rank=%d - curr_mem_seq=%Zu, mem_nseq=%Zu\n",FUNC,mpi_rank,curr_mem_seq,mem_nseq);
- HDfprintf(stderr,"%s: rank=%d - file_off[%Zu]=%Hu, file_len[%Zu]=%Zu\n",FUNC,mpi_rank,curr_file_seq,file_off[curr_file_seq],curr_file_seq,file_len[curr_file_seq]);
- HDfprintf(stderr,"%s: rank=%d - mem_off[%Zu]=%Hu, mem_len[%Zu]=%Zu\n",FUNC,mpi_rank,curr_mem_seq,mem_off[curr_mem_seq],curr_mem_seq,mem_len[curr_mem_seq]);
+ HDfprintf(stderr,"%s: rank=%d - After memory sequence time=%f\n",FUNC,mpi_rank,time);
}
#endif /* QAK */
#ifdef QAK
diff --git a/test/trefer.c b/test/trefer.c
index 7b1b296..bb67a61 100644
--- a/test/trefer.c
+++ b/test/trefer.c
@@ -326,8 +326,13 @@ test_reference_region(void)
hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */
hssize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */
hsize_t * coords; /* Coordinate buffer */
+#ifdef H5_WANT_H5_V1_4_COMPAT
hsize_t low[SPACE2_RANK]; /* Selection bounds */
hsize_t high[SPACE2_RANK]; /* Selection bounds */
+#else /* H5_WANT_H5_V1_4_COMPAT */
+ hssize_t low[SPACE2_RANK]; /* Selection bounds */
+ hssize_t high[SPACE2_RANK]; /* Selection bounds */
+#endif /* H5_WANT_H5_V1_4_COMPAT */
hdset_reg_ref_t *wbuf, /* buffer to write to disk */
*rbuf; /* buffer read from disk */
uint8_t *dwbuf, /* Buffer for writing numeric data to disk */
@@ -587,8 +592,8 @@ test_reference_region_1D(void)
hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */
hssize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */
hsize_t * coords; /* Coordinate buffer */
- hsize_t low[SPACE3_RANK]; /* Selection bounds */
- hsize_t high[SPACE3_RANK]; /* Selection bounds */
+ hssize_t low[SPACE3_RANK]; /* Selection bounds */
+ hssize_t high[SPACE3_RANK]; /* Selection bounds */
hdset_reg_ref_t *wbuf, /* buffer to write to disk */
*rbuf; /* buffer read from disk */
uint8_t *dwbuf, /* Buffer for writing numeric data to disk */