mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-18 15:15:56 +08:00
[svn-r14437] bug fix for h5dump subsetting (deal with blocks)and new test runs
add a check for block overlap after the command line parsing * Algorithm * * In a inner loop, the parameters from SSET are translated into temporary * variables so that 1 row is printed at a time (getting the coordinate indices * at each row). * We define the stride, count and block to be 1 in the row dimension to achieve * this and advance until all points are printed. * An outer loop for cases where dimensionality is greater than 2D is made. * In each iteration, the 2D block is displayed in the inner loop. The remaining * slower dimensions above the first 2 are incremented one at a time in the outer loop * * The element position is obtained from the matrix according to: * Given an index I(z,y,x) its position from the beginning of an array * of sizes A(size_z, size_y,size_x) is given by * Position of I(z,y,x) = index_z * size_y * size_x * + index_y * size_x * + index_x * tested: windows, linux
This commit is contained in:
parent
5382d51033
commit
8005df6417
@ -3181,6 +3181,8 @@ parse_subset_params(char *dset)
|
||||
* Tuesday, 9. January 2001
|
||||
*
|
||||
* Modifications:
|
||||
* Pedro Vicente, Tuesday, January 15, 2008
|
||||
* check for block overlap
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -3253,6 +3255,38 @@ handle_datasets(hid_t fid, char *dset, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* check for block overlap
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if(sset)
|
||||
{
|
||||
hid_t sid = H5Dget_space(dsetid);
|
||||
unsigned int ndims = H5Sget_simple_extent_ndims(sid);
|
||||
unsigned int i;
|
||||
|
||||
for ( i = 0; i < ndims; i++)
|
||||
{
|
||||
if ( sset->count[i] > 1 )
|
||||
{
|
||||
|
||||
if ( sset->stride[i] < sset->block[i] )
|
||||
{
|
||||
error_msg(progname, "wrong subset selection; blocks overlap\n");
|
||||
d_status = EXIT_FAILURE;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
H5Sclose(sid);
|
||||
|
||||
}
|
||||
|
||||
H5Oget_info(dsetid, &oinfo);
|
||||
if(oinfo.rc > 1) {
|
||||
obj_t *found_obj; /* Found object */
|
||||
|
@ -374,17 +374,17 @@ TOOLTEST tindicesyes.ddl taindices.h5
|
||||
TOOLTEST tindicesno.ddl -y taindices.h5
|
||||
|
||||
########## array indices with subsetting
|
||||
# 1D case, start at 1, 2 counts of size 3 blocks, separated by stride 10 elements
|
||||
TOOLTEST tindicessub1.ddl -d 1d -s 1 -c 2 -k 3 -S 10 taindices.h5
|
||||
# 1D case
|
||||
TOOLTEST tindicessub1.ddl -d 1d -s 1 -S 10 -c 2 -k 3 taindices.h5
|
||||
|
||||
# 2D case
|
||||
TOOLTEST tindicessub2.ddl -d 2d -s 1,2 -c 2,3 -k 1,1 -S 2,1 taindices.h5
|
||||
TOOLTEST tindicessub2.ddl -d 2d -s 1,2 -S 3,3 -c 3,2 -k 2,2 taindices.h5
|
||||
|
||||
# 3D case
|
||||
TOOLTEST tindicessub3.ddl -d 3d -s 0,1,2 -c 1,2,3 -k 1,1,1 -S 1,2,1 taindices.h5
|
||||
TOOLTEST tindicessub3.ddl -d 3d -s 0,1,2 -S 1,3,3 -c 2,2,2 -k 1,2,2 taindices.h5
|
||||
|
||||
# 4D case
|
||||
TOOLTEST tindicessub4.ddl -d 4d -s 0,0,1,3 -c 2,2,6,4 taindices.h5
|
||||
TOOLTEST tindicessub4.ddl -d 4d -s 0,0,1,2 -c 2,2,3,2 -S 1,1,3,3 -k 1,1,2,2 taindices.h5
|
||||
|
||||
|
||||
# tests for filters
|
||||
|
@ -613,7 +613,7 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
|
||||
}
|
||||
|
||||
/*
|
||||
* We need to break after each row of a dimension---> we should
|
||||
* We need to break after each row_counter of a dimension---> we should
|
||||
* break at the end of the each last dimension well that is the
|
||||
* way the dumper did it before
|
||||
*/
|
||||
@ -707,33 +707,40 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
|
||||
* Chapter: H5Tools Library
|
||||
* Purpose: Dump out a subset of a dataset.
|
||||
* Description:
|
||||
* Select a hyperslab from the dataset DSET using the parameters
|
||||
* specified in SSET. Dump this out to STREAM.
|
||||
*
|
||||
* Select a hyperslab from the dataset DSET using the parameters
|
||||
* specified in SSET. Dump this out to STREAM.
|
||||
*
|
||||
* hyperslabs select "count" blocks of size "block",
|
||||
* spaced "stride" elements from each other, starting at coordinate
|
||||
* "start".
|
||||
* Hyperslabs select "count" blocks of size "block", spaced "stride" elements
|
||||
* from each other, starting at coordinate "start".
|
||||
*
|
||||
* Return:
|
||||
* On success, return SUCCEED. Otherwise, the function returns FAIL.
|
||||
* Programmer:
|
||||
* Bill Wendling, Wednesday, 07. March 2001
|
||||
* Modifications:
|
||||
* Pedro Vicente, 12 December 2006
|
||||
* Add information to print array indices from the element position
|
||||
* The algorythm used is
|
||||
*
|
||||
* Original programmer:
|
||||
* Bill Wendling, Wednesday, March 07, 2001
|
||||
*
|
||||
* Rewritten with modified algorithm by:
|
||||
* Pedro Vicente, Wednesday, January 16, 2008, contributions from Quincey Koziol
|
||||
*
|
||||
* Algorithm
|
||||
*
|
||||
* In a inner loop, the parameters from SSET are translated into temporary
|
||||
* variables so that 1 row is printed at a time (getting the coordinate indices
|
||||
* at each row).
|
||||
* We define the stride, count and block to be 1 in the row dimension to achieve
|
||||
* this and advance until all points are printed.
|
||||
* An outer loop for cases where dimensionality is greater than 2D is made.
|
||||
* In each iteration, the 2D block is displayed in the inner loop. The remaining
|
||||
* slower dimensions above the first 2 are incremented one at a time in the outer loop
|
||||
*
|
||||
* The element position is obtained from the matrix according to:
|
||||
* Given an index I(z,y,x) its position from the beginning of an array
|
||||
* of sizes A(size_z, size_y,size_x) is given by
|
||||
* Position of I(z,y,x) = index_z * size_y * size_x
|
||||
* + index_y * size_x
|
||||
* + index_x
|
||||
*
|
||||
* Pedro Vicente, Quincey Koziol, 4 January 2007
|
||||
* Introduced an outer loop for cases where dimensionality is greater
|
||||
* than 2D. In each iteration a 2D block is displayed by rows in a inner
|
||||
* loop. The remainning slower dimensions above the first 2 are incremented
|
||||
* one at a time in the outer loop
|
||||
*
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
@ -761,13 +768,15 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
|
||||
hid_t sm_space; /* stripmine data space */
|
||||
hsize_t count; /* hyperslab count */
|
||||
hsize_t outer_count; /* offset count */
|
||||
unsigned int row_dim; /* index of row dimension */
|
||||
unsigned int row_dim; /* index of row_counter dimension */
|
||||
int current_outer_dim; /* dimension for start */
|
||||
hsize_t temp_start[H5S_MAX_RANK];/* temporary start inside offset count loop */
|
||||
hsize_t max_start[H5S_MAX_RANK]; /* maximum start inside offset count loop */
|
||||
hsize_t temp_count[H5S_MAX_RANK];/* temporary count inside offset count loop */
|
||||
hsize_t temp_block[H5S_MAX_RANK];/* temporary block size used in loop */
|
||||
hsize_t temp_stride[H5S_MAX_RANK];/* temporary stride size used in loop */
|
||||
int reset_dim;
|
||||
hsize_t size_row_block; /* size for blocks along rows */
|
||||
|
||||
#if defined (SANITY_CHECK)
|
||||
hsize_t total_points = 1; /* to print */
|
||||
@ -836,6 +845,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
|
||||
temp_start[ i ] = sset->start[ i ];
|
||||
temp_count[ i ] = sset->count[ i ];
|
||||
temp_block[ i ] = sset->block[ i ];
|
||||
temp_stride[ i ] = sset->stride[ i ];
|
||||
max_start[ i ] = 0;
|
||||
|
||||
}
|
||||
@ -854,34 +864,67 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
|
||||
for (n = 0; n < outer_count; n++)
|
||||
{
|
||||
|
||||
hsize_t row_counter = 0;
|
||||
|
||||
/* number of read iterations in inner loop, read by rows, to match 2D display */
|
||||
if (ctx.ndims > 1)
|
||||
{
|
||||
|
||||
/* count is the number of iterations to display all the rows,
|
||||
the block size count times */
|
||||
|
||||
/* count is the number of iterations to display all the rows,
|
||||
the block size count times */
|
||||
count = sset->count[ row_dim ] * sset->block[ row_dim ];
|
||||
|
||||
/* always 1 row at a time, that is a block of size 1, 1 time */
|
||||
|
||||
/* always 1 row_counter at a time, that is a block of size 1, 1 time */
|
||||
temp_count[ row_dim ] = 1;
|
||||
temp_block[ row_dim ] = 1;
|
||||
|
||||
temp_block[ row_dim ] = 1;
|
||||
|
||||
/* advance 1 row_counter at a time */
|
||||
if (sset->block[ row_dim ] > 1 )
|
||||
temp_stride[ row_dim ] = 1;
|
||||
|
||||
|
||||
}
|
||||
/* for the 1D case */
|
||||
else
|
||||
{
|
||||
count = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_row_block = sset->block[ row_dim ];
|
||||
|
||||
|
||||
/* display loop */
|
||||
for (; count > 0; temp_start[ row_dim ] += sset->stride[ row_dim ],
|
||||
count--)
|
||||
{
|
||||
for (; count > 0;
|
||||
temp_start[ row_dim ] += temp_stride[ row_dim ],
|
||||
count--)
|
||||
{
|
||||
|
||||
|
||||
/* jump rows if size of block exceeded
|
||||
cases where block > 1 only and stride > block */
|
||||
if ( size_row_block > 1 &&
|
||||
row_counter == size_row_block &&
|
||||
sset->stride[ row_dim ] > sset->block[ row_dim ]
|
||||
)
|
||||
{
|
||||
|
||||
hsize_t increase_rows = sset->stride[ row_dim ] -
|
||||
sset->block[ row_dim ];
|
||||
|
||||
temp_start[ row_dim ] += increase_rows;
|
||||
|
||||
row_counter = 0;
|
||||
|
||||
}
|
||||
|
||||
row_counter++;
|
||||
|
||||
|
||||
/* calculate the potential number of elements we're going to print */
|
||||
H5Sselect_hyperslab(f_space, H5S_SELECT_SET,
|
||||
temp_start,
|
||||
sset->stride,
|
||||
temp_stride,
|
||||
temp_count,
|
||||
temp_block);
|
||||
sm_nelmts = H5Sget_select_npoints(f_space);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#############################
|
||||
Expected output for 'h5dump -d 1d -s 1 -c 2 -k 3 -S 10 taindices.h5'
|
||||
Expected output for 'h5dump -d 1d -s 1 -S 10 -c 2 -k 3 taindices.h5'
|
||||
#############################
|
||||
HDF5 "taindices.h5" {
|
||||
DATASET "1d" {
|
||||
|
@ -1,5 +1,5 @@
|
||||
#############################
|
||||
Expected output for 'h5dump -d 2d -s 1,2 -c 2,3 -k 1,1 -S 2,1 taindices.h5'
|
||||
Expected output for 'h5dump -d 2d -s 1,2 -S 3,3 -c 3,2 -k 2,2 taindices.h5'
|
||||
#############################
|
||||
HDF5 "taindices.h5" {
|
||||
DATASET "2d" {
|
||||
@ -7,12 +7,16 @@ DATASET "2d" {
|
||||
DATASPACE SIMPLE { ( 10, 10 ) / ( 10, 10 ) }
|
||||
SUBSET {
|
||||
START ( 1, 2 );
|
||||
STRIDE ( 2, 1 );
|
||||
COUNT ( 2, 3 );
|
||||
BLOCK ( 1, 1 );
|
||||
STRIDE ( 3, 3 );
|
||||
COUNT ( 3, 2 );
|
||||
BLOCK ( 2, 2 );
|
||||
DATA {
|
||||
(1,2): 12, 13, 14,
|
||||
(3,2): 32, 33, 34
|
||||
(1,2): 12, 13, 15, 16,
|
||||
(2,2): 22, 23, 25, 26,
|
||||
(4,2): 42, 43, 45, 46,
|
||||
(5,2): 52, 53, 55, 56,
|
||||
(7,2): 72, 73, 75, 76,
|
||||
(8,2): 82, 83, 85, 86
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#############################
|
||||
Expected output for 'h5dump -d 3d -s 0,1,2 -c 1,2,3 -k 1,1,1 -S 1,2,1 taindices.h5'
|
||||
Expected output for 'h5dump -d 3d -s 0,1,2 -S 1,3,3 -c 2,2,2 -k 1,2,2 taindices.h5'
|
||||
#############################
|
||||
HDF5 "taindices.h5" {
|
||||
DATASET "3d" {
|
||||
@ -7,12 +7,18 @@ DATASET "3d" {
|
||||
DATASPACE SIMPLE { ( 2, 10, 10 ) / ( 2, 10, 10 ) }
|
||||
SUBSET {
|
||||
START ( 0, 1, 2 );
|
||||
STRIDE ( 1, 2, 1 );
|
||||
COUNT ( 1, 2, 3 );
|
||||
BLOCK ( 1, 1, 1 );
|
||||
STRIDE ( 1, 3, 3 );
|
||||
COUNT ( 2, 2, 2 );
|
||||
BLOCK ( 1, 2, 2 );
|
||||
DATA {
|
||||
(0,1,2): 12, 13, 14,
|
||||
(0,3,2): 32, 33, 34
|
||||
(0,1,2): 12, 13, 15, 16,
|
||||
(0,2,2): 22, 23, 25, 26,
|
||||
(0,4,2): 42, 43, 45, 46,
|
||||
(0,5,2): 52, 53, 55, 56
|
||||
(1,1,2): 112, 113, 115, 116,
|
||||
(1,2,2): 122, 123, 125, 126,
|
||||
(1,4,2): 142, 143, 145, 146,
|
||||
(1,5,2): 152, 153, 155, 156
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,40 @@
|
||||
#############################
|
||||
Expected output for 'h5dump -d 4d -s 0,0,1,3 -c 2,2,6,4 taindices.h5'
|
||||
Expected output for 'h5dump -d 4d -s 0,0,1,2 -c 2,2,3,2 -S 1,1,3,3 -k 1,1,2,2 taindices.h5'
|
||||
#############################
|
||||
HDF5 "taindices.h5" {
|
||||
DATASET "4d" {
|
||||
DATATYPE H5T_STD_I32LE
|
||||
DATASPACE SIMPLE { ( 2, 2, 10, 10 ) / ( 2, 2, 10, 10 ) }
|
||||
SUBSET {
|
||||
START ( 0, 0, 1, 3 );
|
||||
STRIDE ( 1, 1, 1, 1 );
|
||||
COUNT ( 2, 2, 6, 4 );
|
||||
BLOCK ( 1, 1, 1, 1 );
|
||||
START ( 0, 0, 1, 2 );
|
||||
STRIDE ( 1, 1, 3, 3 );
|
||||
COUNT ( 2, 2, 3, 2 );
|
||||
BLOCK ( 1, 1, 2, 2 );
|
||||
DATA {
|
||||
(0,0,1,3): 13, 14, 15, 16,
|
||||
(0,0,2,3): 23, 24, 25, 26,
|
||||
(0,0,3,3): 33, 34, 35, 36,
|
||||
(0,0,4,3): 43, 44, 45, 46,
|
||||
(0,0,5,3): 53, 54, 55, 56,
|
||||
(0,0,6,3): 63, 64, 65, 66
|
||||
(0,1,1,3): 113, 114, 115, 116,
|
||||
(0,1,2,3): 123, 124, 125, 126,
|
||||
(0,1,3,3): 133, 134, 135, 136,
|
||||
(0,1,4,3): 143, 144, 145, 146,
|
||||
(0,1,5,3): 153, 154, 155, 156,
|
||||
(0,1,6,3): 163, 164, 165, 166
|
||||
(1,0,1,3): 213, 214, 215, 216,
|
||||
(1,0,2,3): 223, 224, 225, 226,
|
||||
(1,0,3,3): 233, 234, 235, 236,
|
||||
(1,0,4,3): 243, 244, 245, 246,
|
||||
(1,0,5,3): 253, 254, 255, 256,
|
||||
(1,0,6,3): 263, 264, 265, 266
|
||||
(1,1,1,3): 313, 314, 315, 316,
|
||||
(1,1,2,3): 323, 324, 325, 326,
|
||||
(1,1,3,3): 333, 334, 335, 336,
|
||||
(1,1,4,3): 343, 344, 345, 346,
|
||||
(1,1,5,3): 353, 354, 355, 356,
|
||||
(1,1,6,3): 363, 364, 365, 366
|
||||
(0,0,1,2): 12, 13, 15, 16,
|
||||
(0,0,2,2): 22, 23, 25, 26,
|
||||
(0,0,4,2): 42, 43, 45, 46,
|
||||
(0,0,5,2): 52, 53, 55, 56,
|
||||
(0,0,7,2): 72, 73, 75, 76,
|
||||
(0,0,8,2): 82, 83, 85, 86
|
||||
(0,1,1,2): 112, 113, 115, 116,
|
||||
(0,1,2,2): 122, 123, 125, 126,
|
||||
(0,1,4,2): 142, 143, 145, 146,
|
||||
(0,1,5,2): 152, 153, 155, 156,
|
||||
(0,1,7,2): 172, 173, 175, 176,
|
||||
(0,1,8,2): 182, 183, 185, 186
|
||||
(1,0,1,2): 212, 213, 215, 216,
|
||||
(1,0,2,2): 222, 223, 225, 226,
|
||||
(1,0,4,2): 242, 243, 245, 246,
|
||||
(1,0,5,2): 252, 253, 255, 256,
|
||||
(1,0,7,2): 272, 273, 275, 276,
|
||||
(1,0,8,2): 282, 283, 285, 286
|
||||
(1,1,1,2): 312, 313, 315, 316,
|
||||
(1,1,2,2): 322, 323, 325, 326,
|
||||
(1,1,4,2): 342, 343, 345, 346,
|
||||
(1,1,5,2): 352, 353, 355, 356,
|
||||
(1,1,7,2): 372, 373, 375, 376,
|
||||
(1,1,8,2): 382, 383, 385, 386
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user